def create_select_model(modelname): """ Function that creates the 'model selection' element """ selected_model = None if modelname: for model in get_model_options(): if model[1] == modelname.lower(): selected_model = model[0] select_model = SelectInput(display_text='', name='model1', multiple=False, initial=[selected_model if selected_model else None], original=True, options=get_model_options(), attributes="onchange=oc_model();" ) return select_model
def create_select_model(modelname): """ Function that creates the 'model selection' element """ selected_model = None if modelname: for model in get_model_options(): if model[1] == modelname.lower(): selected_model = model[0] select_model = SelectInput( display_text='', name='model1', multiple=False, initial=[selected_model if selected_model else None], original=True, options=get_model_options(), attributes="onchange=oc_model();") return select_model
def home(request): """ Controller for the app 'home' page. """ init_model() model = get_model_options()[0][1] select_model = create_select_model(model) select_date, select_hour = create_map_date_ctrls(model) # Load map map_view, map_view_options = create_map() start_date1, end_date1, plot_button1 = create_plot_ctrls(model, 'plot') start_date2, end_date2, plot_button2 = create_plot_ctrls(model, 'plot2') select_model2 = SelectInput(display_text='', name='model2', multiple=False, original=True, options=get_model_options(), attributes="onchange=oc_model2();" ) years_list = create_years_list(1979) select_years = SelectInput(display_text='', name='years', multiple=True, original=False, options=years_list, attributes="onchange=oc_years();" ) plot_button3 = Button(display_text='Plot', name='years', style='', icon='', href='', submit=False, disabled=False, attributes='onclick=createPlot(this.name);', classes='btn-plot') # Context variables context = { 'select_model': select_model, 'MapView': map_view, 'map_view_options': map_view_options, 'select_date': select_date, 'select_hour': select_hour, 'MODEL_FENCES': dumps(get_model_fences()), 'VAR_DICT': dumps(get_var_dict()), 'DATARODS_PNG': dumps(get_datarods_png()), 'DATARODS_TSB': dumps(get_datarods_tsb()), 'WMS_VARS': dumps(get_wms_vars()), 'start_date1': start_date1, 'end_date1': end_date1, 'plot_button1': plot_button1, 'start_date2': start_date2, 'end_date2': end_date2, 'plot_button2': plot_button2, 'select_model2': select_model2, 'plot_button3': plot_button3, 'select_years': select_years, # 'messages': [{ # 'category': 'info', # 'text': 'Click on the map to define data query location.', # 'id': 'click-map' # }] } return render(request, 'data_rods_explorer/app_base_dre.html', context)
def home(request): """ Controller for the app 'home' page. """ init_model() model = get_model_options()[0][1] select_model = create_select_model(model) select_date, select_hour = create_map_date_ctrls(model) # Load map map_view, map_view_options = create_map() start_date1, end_date1, plot_button1 = create_plot_ctrls(model, 'plot') start_date2, end_date2, plot_button2 = create_plot_ctrls(model, 'plot2') select_model2 = SelectInput(display_text='', name='model2', multiple=False, original=True, options=get_model_options(), attributes="onchange=oc_model2();" ) years_list = create_years_list(1979) select_years = SelectInput(display_text='', name='years', multiple=True, original=False, options=years_list, attributes="onchange=oc_years();" ) plot_button3 = Button(display_text='Plot', name='years', style='', icon='', href='', submit=False, disabled=False, attributes='onclick=createPlot(this.name);', classes='btn-plot') # Context variables context = { 'select_model': select_model, 'MapView': map_view, 'map_view_options': map_view_options, 'select_date': select_date, 'select_hour': select_hour, 'MODEL_FENCES': dumps(get_model_fences()), 'VAR_DICT': dumps(get_var_dict()), 'DATARODS_PNG': dumps(get_datarods_png()), 'DATARODS_TSB': dumps(get_datarods_tsb()), 'WMS_VARS': dumps(get_wms_vars()), 'start_date1': start_date1, 'end_date1': end_date1, 'plot_button1': plot_button1, 'start_date2': start_date2, 'end_date2': end_date2, 'plot_button2': plot_button2, 'select_model2': select_model2, 'plot_button3': plot_button3, 'select_years': select_years } return render(request, 'data_rods_explorer/app_base_dre.html', context)