From 97f79bbab8d87322e519059c851731a5c9e2625d Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Thu, 29 Aug 2019 16:52:29 +1000 Subject: [PATCH] Move graph and table elements into callback function --- daqviewer/daqviewer.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/daqviewer/daqviewer.py b/daqviewer/daqviewer.py index d3c2070..3d9e2fd 100644 --- a/daqviewer/daqviewer.py +++ b/daqviewer/daqviewer.py @@ -41,7 +41,7 @@ app.layout = html.Div([ ]) -def parse_contents(contents, filename, date): +def parse_contents(contents, filename): basename, ext = os.path.splitext(filename) content_type, content_string = contents.split(',') decoded = base64.b64decode(content_string) @@ -147,22 +147,23 @@ def parse_contents(contents, filename, date): }, ) - elements = html.Div([ - graph_timeseries, graph_energy, table_energy, - html.Div(id='datatable-row-ids-container') - ]) - - return elements + return graph_timeseries, graph_energy, table_energy @app.callback(Output('output-data-upload', 'children'), [ Input('upload-data', 'contents'), Input('upload-data', 'filename'), - Input('upload-data', 'last_modified'), ]) -def update_output(contents, name, date): +def update_output(contents, name): if contents is not None: - return parse_contents(contents, name, date) + graph_ts, graph_spec, table_spec = parse_contents(contents, name) + elements = html.Div([ + graph_ts, graph_spec, table_spec, + html.Div(id='datatable-row-ids-container') + ]) + + return elements + else: return html.Div([])