diff --git a/pyzebra/app/panel_ccl_integrate.py b/pyzebra/app/panel_ccl_integrate.py index 8392212..512bdb5 100644 --- a/pyzebra/app/panel_ccl_integrate.py +++ b/pyzebra/app/panel_ccl_integrate.py @@ -5,6 +5,7 @@ import tempfile import types import numpy as np +from bokeh.io import curdoc from bokeh.layouts import column, row from bokeh.models import ( BasicTicker, @@ -70,12 +71,19 @@ for (let i = 0; i < js_data.data['fname'].length; i++) { def create(): + doc = curdoc() det_data = {} fit_params = {} js_data = ColumnDataSource(data=dict(content=["", ""], fname=["", ""], ext=["", ""])) - def proposal_textinput_callback(_attr, _old, new): - proposal = new.strip() + def file_select_update_for_proposal(): + proposal = proposal_textinput.value.strip() + if not proposal: + file_select.options = [] + file_open_button.disabled = True + file_append_button.disabled = True + return + for zebra_proposals_path in pyzebra.ZEBRA_PROPOSALS_PATHS: proposal_path = os.path.join(zebra_proposals_path, proposal) if os.path.isdir(proposal_path): @@ -92,6 +100,11 @@ def create(): file_open_button.disabled = False file_append_button.disabled = False + doc.add_periodic_callback(file_select_update_for_proposal, 5000) + + def proposal_textinput_callback(_attr, _old, _new): + file_select_update_for_proposal() + proposal_textinput = TextInput(title="Proposal number:", width=210) proposal_textinput.on_change("value", proposal_textinput_callback) @@ -150,6 +163,7 @@ def create(): def upload_button_callback(_attr, _old, new): nonlocal det_data det_data = [] + proposal_textinput.value = "" for f_str, f_name in zip(new, upload_button.filename): with io.StringIO(base64.b64decode(f_str).decode()) as file: base, ext = os.path.splitext(f_name) diff --git a/pyzebra/app/panel_hdf_viewer.py b/pyzebra/app/panel_hdf_viewer.py index b7a3b9b..9f5884c 100644 --- a/pyzebra/app/panel_hdf_viewer.py +++ b/pyzebra/app/panel_hdf_viewer.py @@ -58,9 +58,11 @@ def create(): num_formatter = NumberFormatter(format="0.00", nan_format="") - def proposal_textinput_callback(_attr, _old, new): - nonlocal cami_meta - proposal = new.strip() + def file_select_update_for_proposal(): + proposal = proposal_textinput.value.strip() + if not proposal: + return + for zebra_proposals_path in pyzebra.ZEBRA_PROPOSALS_PATHS: proposal_path = os.path.join(zebra_proposals_path, proposal) if os.path.isdir(proposal_path): @@ -75,13 +77,19 @@ def create(): file_list.append((os.path.join(proposal_path, file), file)) file_select.options = file_list + doc.add_periodic_callback(file_select_update_for_proposal, 5000) + + def proposal_textinput_callback(_attr, _old, _new): + nonlocal cami_meta cami_meta = {} + file_select_update_for_proposal() proposal_textinput = TextInput(title="Proposal number:", width=210) proposal_textinput.on_change("value", proposal_textinput_callback) def upload_button_callback(_attr, _old, new): nonlocal cami_meta + proposal_textinput.value = "" with io.StringIO(base64.b64decode(new).decode()) as file: cami_meta = pyzebra.parse_h5meta(file) file_list = cami_meta["filelist"] diff --git a/pyzebra/app/panel_param_study.py b/pyzebra/app/panel_param_study.py index 4f55e63..92ee7c4 100644 --- a/pyzebra/app/panel_param_study.py +++ b/pyzebra/app/panel_param_study.py @@ -6,6 +6,7 @@ import tempfile import types import numpy as np +from bokeh.io import curdoc from bokeh.layouts import column, row from bokeh.models import ( BasicTicker, @@ -75,12 +76,19 @@ def color_palette(n_colors): def create(): + doc = curdoc() det_data = [] fit_params = {} js_data = ColumnDataSource(data=dict(content=["", ""], fname=["", ""])) - def proposal_textinput_callback(_attr, _old, new): - proposal = new.strip() + def file_select_update_for_proposal(): + proposal = proposal_textinput.value.strip() + if not proposal: + file_select.options = [] + file_open_button.disabled = True + file_append_button.disabled = True + return + for zebra_proposals_path in pyzebra.ZEBRA_PROPOSALS_PATHS: proposal_path = os.path.join(zebra_proposals_path, proposal) if os.path.isdir(proposal_path): @@ -97,6 +105,11 @@ def create(): file_open_button.disabled = False file_append_button.disabled = False + doc.add_periodic_callback(file_select_update_for_proposal, 5000) + + def proposal_textinput_callback(_attr, _old, _new): + file_select_update_for_proposal() + proposal_textinput = TextInput(title="Proposal number:", width=210) proposal_textinput.on_change("value", proposal_textinput_callback) @@ -160,6 +173,7 @@ def create(): def upload_button_callback(_attr, _old, new): nonlocal det_data det_data = [] + proposal_textinput.value = "" for f_str, f_name in zip(new, upload_button.filename): with io.StringIO(base64.b64decode(f_str).decode()) as file: base, ext = os.path.splitext(f_name)