ssb_sirius_dash.setup package

ssb_sirius_dash.setup.alert_handler module

class AlertHandler

Bases: object

Handler class to manage and display alerts within the application.

This class provides functionality to: - Display alerts categorized as “info”, “warning”, or “danger”. - Filter alerts based on their type using buttons. - Maintain a modal interface for viewing alerts.

layout()

Generates the layout for the alert modal and sidebar button.

Return type:

Div

callbacks()

Defines and registers Dash callbacks for managing alerts.

Return type:

None

callbacks()

Define and register the Dash callbacks for the alert modal and alerts.

Return type:

None

layout()

Generate the layout for the alert modal and sidebar button.

Returns:

The layout containing the modal and the sidebar button.

Return type:

html.Div

ssb_sirius_dash.setup.app_setup module

app_setup(port, service_prefix, domain, stylesheet)

Set up and configure a Dash application with the specified parameters.

Parameters:
  • port (int) – The port number for the Dash application.

  • service_prefix (str) – The service prefix used for constructing the app’s pathname.

  • domain (str) – The domain name where the app is hosted.

  • stylesheet (str) – The name of the Bootstrap theme to apply to the app. Must be a key in theme_map.

Returns:

Configured Dash application instance.

Return type:

Dash

Notes

  • The function maps the stylesheet parameter to a Bootstrap theme using theme_map.

  • A callback is registered within the app to toggle the visibility of an element with the ID main-varvelger based on the number of clicks on sidebar-varvelger-button.

Examples

>>> app = app_setup(port=8050, service_prefix="/", domain="localhost", stylesheet="slate")
>>> app.run_server() 

ssb_sirius_dash.setup.main_layout module

main_layout(modal_list, tab_list, variable_list)

Generate the main layout for the Dash application.

Parameters:
  • modal_list (list[html.Div]) – List of modal components to be included in the sidebar.

  • tab_list (list[html.Div]) – List of tab objects, each containing a layout method and a label attribute.

  • variable_list (list[html.Div]) – List of variable selection components to be included in the main layout.

Returns:

A Dash Container component representing the app’s main layout.

Return type:

dbc.Container

Notes

  • The function includes an alert handler modal and a toggle button for the variable selector.

  • Each tab in tab_list must implement a layout() method and have a label attribute.

ssb_sirius_dash.setup.variableselector module

create_variable_card(text, component_id, input_type, value=None)

Generate a Dash Bootstrap card with an input field.

Parameters:
  • text (str) – The title text to display on the card.

  • component_id (str) – The ID to assign to the input field within the card.

  • input_type (str) – The type of the input field (e.g., “text”, “number”).

  • value (str, optional) – The default value for the input field. Defaults to an empty string.

Returns:

A column containing the card with an input field.

Return type:

dbc.Col

create_variable_selector_content(selected_keys, default_values=None)

Generate a list of Dash Bootstrap cards based on selected variable keys.

Parameters:
  • selected_keys (list[str]) – Keys representing variables to include as cards. Each key corresponds to an entry in the variable_options dictionary.

  • default_values (dict, optional) – A dictionary containing default values for the cards, where the keys are variable names, and the values are the default input values. Defaults to an empty dictionary.

Returns:

A list of cards, each represented as a Dash Bootstrap column.

Return type:

list[dbc.Col]

Raises:
  • KeyError – If any required key (‘title’, ‘id’, ‘type’) is missing in variable_options for a selected key.

  • ValueError – If the value provided in default_values is not of a supported type.

Notes

  • The variable_options dictionary provides configuration for each card, including its title, ID, and type.

  • If selected_keys includes keys not found in variable_options, those keys are ignored.