def Homepage(): # Body container body = dbc.Container( [ dbc.Row([ dcc.Markdown('---'), ]), dbc.Row([ dbc.Col(id='live_alert_header_btn'), ]), dbc.Row([ dbc.Col( user_selection_area(), id='user_selection_column', md=3), dbc.Col( [ # map object added here html.Div(build_alerts_map(), id='hp_map'), # interval object handling api calls every 10 seconds dcc.Interval( id='interval-component', interval=10 * 1000, # in milliseconds n_intervals=0), html.Div(id='img_url', style={'display': 'none'}) ], md=9), ]), # meteo graphs added here meteo_graphs(display=False) ], fluid=True, ) # Instantiating navbar object from navbar.py layout = html.Div([Navbar(), body]) return layout
def choose_map_style(n_clicks): """ This function allows, depending on user's choice, to display the right style of map and button content. It takes as input (thanks to a callback in main.py) the number of clicks on the button defined above and returns: - the alerts map and its attributes if the number of clicks is even; - the risks map and its attributes if the number of clicks on the button is odd. More precisely, it returns three elements: - the appropriate message for the button defined above; - the chosen map object; - and the slider object (simply a void string if the alerts view was chosen). """ # Because we start with the alerts map, if the number of clicks is even, this means that # we are still using the "Alerts and Infrastructure" map and we may want to switch to the "Risk Scores" one if n_clicks % 2 == 0: button_content_map = 'Afficher les niveaux de risques' map_object = build_alerts_map() slider = ' ' map_style_in_use = 'alerts' # If the number of clicks is odd, this means we are using the "Risk Scores" map # and we may want to come back to the "Alerts and Infrastructure" one else: button_content_map = 'Revenir à la carte Alertes' map_object = build_risks_map() slider = build_opacity_slider() map_style_in_use = 'risks' return button_content_map, map_object, slider, map_style_in_use
def choose_map_style(n_clicks): # Because we start with the alerts map, if the number of clicks is even, this means that # we are still using the alerts map and we may want to switch to the risks one if n_clicks % 2 == 0: button_content_map = 'Afficher les niveaux de risques' map_object = build_alerts_map() slider = ' ' # If the number of clicks is odd, this means we are using the risks map and may # want to come back to alerts one else: button_content_map = 'Revenir à la carte Alertes' map_object = build_risks_map() slider = build_opacity_slider() return button_content_map, map_object, slider
def Homepage(): """ The following function is used in the main.py file to build the layout of the web application. It builds upon methods defined above or in alerts.py or navbar.py files to instantiate the various components. """ # Body container body = dbc.Container([ # We add an HTML Div which displays the login background image as long as the user has not entered valid creden- # tials (so that he / she cannot see what lies behind on the platform before being connected) html.Center( html.Div( id='login_background', children=[ # The background image is directly stored in the /assets folder html.Img(src='assets/background.png', width="100%", height="100%") ] ) ), # Main part of the page layout dbc.Row( [ # Left column containing the user selection area dbc.Col([ # At first, the map is hidden (until the user logs in with valid credentials) html.Div(build_user_selection_area(), id='selection_area', style={'display': 'none'}), html.Div(id="alert_overview_area"), html.Div(id='new_alerts_selection_list', style={'display': 'none'}), # Placeholder containing the detection data for any alert of interest html.P(id="hp_alert_frame_metadata")], id='user_selection_column', ), # Right column containing the map and various hidden components dbc.Col([ # Map object added here html.Div(build_alerts_map(), id='hp_map', style={'display': 'none'}), # Two placeholders updated by callbacks in main.py to trigger a change in map style html.Div(id='map_style_btn_switch_view'), # Associated with the main map style button html.Div(id='alert_btn_switch_view'), # Associated with the alert banner in risks mode # Simple placeholder - Source of truth for the map style being viewed html.Div(id='current_map_style', children='alerts', style={'display': 'none'}), # Two placeholders updated by callbacks in main.py to change center and zoom attributes of the map dcc.Store(id='login_zoom_and_center', data={}), dcc.Store(id='alert_zoom_and_center', data={}), # Placeholders for the three inputs that can affect the style attribute of the alert overview area html.Div(id='alert_overview_style_zoom', style={'display': 'none'}), html.Div(id='alert_overview_style_closing_buttons', style={'display': 'none'}), html.Div(id='alert_overview_style_erase_buttons', style={'display': 'none'}) ], id='map_column', md=12), ] ), # Login modal added here build_login_modal(), # HTML Div containing alert modals added here html.Div(id='alert_modals') ], fluid=True, ) # Instantiating navbar object from navbar.py layout = html.Div([Navbar(), body]) return layout
def Homepage(): """ The following function is used in the main.py file to build the layout of the web application. It builds upon methods defined above or in alerts.py or navbar.py files to instantiate the various components. """ # Body container body = dbc.Container( [ # Markdown separator below the navigation bar dbc.Row(dcc.Markdown('---')), # Optional radio button to simulate alert events in debugging mode dbc.Row(dbc.Col(id='live_alert_header_btn')), # Main part of the page layout dbc.Row([ # Left column containing the user selection area dbc.Col(build_user_selection_area(), id='user_selection_column', md=3), # Right column containing the map and various hidden components dbc.Col( [ # Map object added here html.Div(build_alerts_map(), id='hp_map'), # Interval object triggering api calls every 10 seconds dcc.Interval( id='interval-component', interval=10 * 1000, # Timestep in milliseconds n_intervals=0), # Two placeholders updated by callbacks in main.py to trigger a change in map style html.Div( id='map_style_btn_switch_view' ), # Associated with the main map style button html.Div( id='alert_btn_switch_view' ), # Associated with the alert banner in risks mode # Simple placeholder - Source of truth for the map style being viewed html.Div(id='current_map_style', children='alerts'), # Hidden html.Div storing the URL address of the detection frame of the latest alert html.Div(id='img_url', style={'display': 'none'}) ], md=9), ]), # Meteo graphs added here display_meteo_graphs(display=False) ], fluid=True, ) # Instantiating navbar object from navbar.py layout = html.Div([Navbar(), body]) return layout