+ plotting_area_trending = no_update
+ plotting_area_buttons = no_update
+ row_card_sel_tests = no_update
+ row_btns_sel_tests = no_update
+ lg_selected = no_update
+
+ ret_val = [
+ ctrl_panel.panel,
+ store_sel,
+ plotting_area_trending,
+ plotting_area_buttons,
+ row_card_sel_tests,
+ row_btns_sel_tests,
+ lg_selected
+ ]
+ ret_val.extend(ctrl_panel.values)
+ return ret_val
+
+ @app.callback(
+ Output("plot-mod-url", "is_open"),
+ Input("plot-btn-url", "n_clicks"),
+ State("plot-mod-url", "is_open")
+ )
+ def toggle_plot_mod_url(n, is_open):
+ """Toggle the modal window with url.
+ """
+ if n:
+ return not is_open
+ return is_open
+
+ @app.callback(
+ Output("store-telemetry-data", "data"),
+ Output("store-telemetry-user", "data"),
+ Output("telemetry-search-in", "value"),
+ Output("telemetry-search-out", "children"),
+ Output("telemetry-list-metrics", "value"),
+ Output("telemetry-dd", "children"),
+ Output("plotting-area-telemetry", "children"),
+ Output("plot-mod-telemetry-1", "is_open"),
+ Output("plot-mod-telemetry-2", "is_open"),
+ Output({"type": "telemetry-btn", "index": "select"}, "disabled"),
+ Output({"type": "telemetry-btn", "index": "add"}, "disabled"),
+ State("store-telemetry-data", "data"),
+ State("store-telemetry-user", "data"),
+ State("store-selected-tests", "data"),
+ Input({"type": "tele-cl", "index": ALL}, "value"),
+ Input("telemetry-search-in", "value"),
+ Input({"type": "telemetry-btn", "index": ALL}, "n_clicks"),
+ Input({"type": "tm-dd", "index": ALL}, "value"),
+ prevent_initial_call=True
+ )
+ def _update_plot_mod_telemetry(
+ tm_data: dict,
+ tm_user: dict,
+ store_sel: list,
+ cl_metrics: list,
+ search_in: str,
+ n_clicks: list,
+ tm_dd_in: list
+ ) -> tuple:
+ """Toggle the modal window with telemetry.
+ """
+
+ if not any(n_clicks):
+ raise PreventUpdate
+
+ if tm_user is None:
+ # Telemetry user data
+ # The data provided by user or result of user action
+ tm_user = {
+ # List of unique metrics:
+ "unique_metrics": list(),
+ # List of metrics selected by user:
+ "selected_metrics": list(),
+ # Labels from metrics selected by user (key: label name,
+ # value: list of all possible values):
+ "unique_labels": dict(),
+ # Labels selected by the user (subset of 'unique_labels'):
+ "selected_labels": dict(),
+ # All unique metrics with labels (output from the step 1)
+ # converted from pandas dataframe to dictionary.
+ "unique_metrics_with_labels": dict(),
+ # Metrics with labels selected by the user using dropdowns.
+ "selected_metrics_with_labels": dict()
+ }
+
+ tm = TelemetryData(tests=store_sel)
+ tm_json = no_update
+ search_out = no_update
+ list_metrics = no_update
+ tm_dd = no_update
+ plotting_area_telemetry = no_update
+ is_open = (False, False)
+ is_btn_disabled = (True, True)
+
+ trigger = Trigger(callback_context.triggered)
+ if trigger.type == "telemetry-btn":
+ if trigger.idx in ("open", "back"):
+ tm.from_dataframe(self._data)
+ tm_json = tm.to_json()
+ tm_user["unique_metrics"] = tm.unique_metrics
+ tm_user["selected_metrics"] = list()
+ tm_user["unique_labels"] = dict()
+ tm_user["selected_labels"] = dict()
+ search_in = str()
+ search_out = get_list_group_items(
+ tm_user["unique_metrics"],
+ "tele-cl",
+ False
+ )
+ is_open = (True, False)
+ elif trigger.idx == "select":
+ tm.from_json(tm_data)
+ if any(cl_metrics):
+ if not tm_user["selected_metrics"]:
+ tm_user["selected_metrics"] = \
+ tm_user["unique_metrics"]
+ metrics = [a for a, b in \
+ zip(tm_user["selected_metrics"], cl_metrics) if b]
+ tm_user["selected_metrics"] = metrics
+ tm_user["unique_labels"] = \
+ tm.get_selected_labels(metrics)
+ tm_user["unique_metrics_with_labels"] = \
+ tm.unique_metrics_with_labels
+ list_metrics = tm.str_metrics
+ tm_dd = _get_dd_container(tm_user["unique_labels"])
+ if list_metrics:
+ is_btn_disabled = (True, False)
+ is_open = (False, True)
+ else:
+ tm_user = None
+ is_open = (False, False)
+ elif trigger.idx == "add":
+ tm.from_json(tm_data)
+ plotting_area_telemetry = self._get_plotting_area_telemetry(
+ graph_tm_trending(
+ tm.select_tm_trending_data(
+ tm_user["selected_metrics_with_labels"]
+ ),
+ self._graph_layout)
+ )
+ tm_user = None
+ is_open = (False, False)
+ elif trigger.idx == "cancel":
+ tm_user = None
+ is_open = (False, False)
+ elif trigger.type == "telemetry-search-in":
+ tm.from_metrics(tm_user["unique_metrics"])
+ tm_user["selected_metrics"] = \
+ tm.search_unique_metrics(search_in)
+ search_out = get_list_group_items(
+ tm_user["selected_metrics"],
+ type="tele-cl",
+ colorize=False
+ )
+ is_open = (True, False)
+ elif trigger.type == "tele-cl":
+ if any(cl_metrics):
+ is_btn_disabled = (False, True)
+ is_open = (True, False)
+ elif trigger.type == "tm-dd":
+ tm.from_metrics_with_labels(
+ tm_user["unique_metrics_with_labels"]
+ )
+ selected = dict()
+ previous_itm = None
+ for itm in tm_dd_in:
+ if itm is None:
+ show_new = True
+ elif isinstance(itm, str):
+ show_new = False
+ selected[itm] = list()
+ elif isinstance(itm, list):
+ if previous_itm is not None:
+ selected[previous_itm] = itm
+ show_new = True
+ previous_itm = itm
+
+ tm_dd = _get_dd_container(
+ tm_user["unique_labels"],
+ selected,
+ show_new
+ )
+ sel_metrics = tm.filter_selected_metrics_by_labels(selected)
+ tm_user["selected_metrics_with_labels"] = sel_metrics.to_dict()
+ if not sel_metrics.empty:
+ list_metrics = tm.metrics_to_str(sel_metrics)
+ else:
+ list_metrics = str()
+ if list_metrics:
+ is_btn_disabled = (True, False)
+ is_open = (False, True)