X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Fdash%2Fapp%2Fpal%2Freport%2Flayout.py;h=7afa0ea0c59b4b43c6b9a2798bb65ee05503646b;hp=164f2d48d9661155b1e70f6b7d55e5deb84e236b;hb=aa9f6d2b4d417b439e2953a9c82c31b0d561f632;hpb=ae1fe880286d7b0414664bce2b2c7c91c3f543f3 diff --git a/resources/tools/dash/app/pal/report/layout.py b/resources/tools/dash/app/pal/report/layout.py index 164f2d48d9..7afa0ea0c5 100644 --- a/resources/tools/dash/app/pal/report/layout.py +++ b/resources/tools/dash/app/pal/report/layout.py @@ -28,7 +28,9 @@ from copy import deepcopy from ast import literal_eval from ..utils.constants import Constants as C -from ..utils.url_processing import url_decode, url_encode +from ..utils.utils import show_tooltip, label, sync_checklists, list_tests, \ + gen_new_url +from ..utils.url_processing import url_decode from ..data.data import Data from .graphs import graph_iterative, table_comparison, get_short_version @@ -189,32 +191,6 @@ class Layout: def layout(self): return self._graph_layout - def label(self, key: str) -> str: - return C.LABELS.get(key, key) - - def _show_tooltip(self, id: str, title: str, - clipboard_id: str=None) -> list: - """ - """ - return [ - dcc.Clipboard(target_id=clipboard_id, title="Copy URL") \ - if clipboard_id else str(), - f"{title} ", - dbc.Badge( - id=id, - children="?", - pill=True, - color="white", - text_color="info", - class_name="border ms-1", - ), - dbc.Tooltip( - children=self._tooltips.get(id, str()), - target=id, - placement="auto" - ) - ] - def add_content(self): """ """ @@ -358,7 +334,7 @@ class Layout: dbc.InputGroup( [ dbc.InputGroupText( - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-release", "CSIT Release") ), dbc.Select( @@ -384,7 +360,7 @@ class Layout: dbc.InputGroup( [ dbc.InputGroupText( - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-dut", "DUT") ), dbc.Select( @@ -405,7 +381,7 @@ class Layout: dbc.InputGroup( [ dbc.InputGroupText( - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-dut-ver", "DUT Version") ), dbc.Select( @@ -427,7 +403,7 @@ class Layout: dbc.InputGroup( [ dbc.InputGroupText( - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-infra", "Infra") ), dbc.Select( @@ -449,7 +425,7 @@ class Layout: dbc.InputGroup( [ dbc.InputGroupText( - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-area", "Area") ), dbc.Select( @@ -469,7 +445,7 @@ class Layout: dbc.InputGroup( [ dbc.InputGroupText( - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-test", "Test") ), dbc.Select( @@ -488,7 +464,7 @@ class Layout: class_name="gy-1", children=[ dbc.Label( - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-framesize", "Frame Size"), class_name="p-0" ), @@ -519,7 +495,7 @@ class Layout: class_name="gy-1", children=[ dbc.Label( - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-cores", "Number of Cores"), class_name="p-0" ), @@ -550,7 +526,7 @@ class Layout: class_name="gy-1", children=[ dbc.Label( - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-ttype", "Test Type"), class_name="p-0" ), @@ -581,7 +557,7 @@ class Layout: class_name="gy-1", children=[ dbc.Label( - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-normalize", "Normalize"), class_name="p-0" ), @@ -731,26 +707,6 @@ class Layout: def values(self) -> tuple: return tuple(self._panel.values()) - @staticmethod - def _sync_checklists(opt: list, sel: list, all: list, id: str) -> tuple: - """ - """ - options = {v["value"] for v in opt} - if id =="all": - sel = list(options) if all else list() - else: - all = ["all", ] if set(sel) == options else list() - return sel, all - - @staticmethod - def _list_tests(selection: dict) -> list: - """Display selected tests with checkboxes - """ - if selection: - return [{"label": v["id"], "value": v["id"]} for v in selection] - else: - return list() - def callbacks(self, app): def _generate_plotting_area(figs: tuple, table: pd.DataFrame, @@ -779,7 +735,7 @@ class Layout: dcc.Loading(children=[ dbc.Button( id="btn-download-data", - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-download", "Download Data"), class_name="me-1", color="info" @@ -796,7 +752,7 @@ class Layout: children=[ dbc.InputGroupText( style=C.URL_STYLE, - children=self._show_tooltip( + children=show_tooltip(self._tooltips, "help-url", "URL", "input-url") ), dbc.Input( @@ -901,21 +857,6 @@ class Layout: """ """ - def _gen_new_url(parsed_url: dict, store_sel: list) -> str: - - if parsed_url: - new_url = url_encode({ - "scheme": parsed_url["scheme"], - "netloc": parsed_url["netloc"], - "path": parsed_url["path"], - "params": { - "store_sel": store_sel, - } - }) - else: - new_url = str() - return new_url - ctrl_panel = self.ControlPanel(cp_data) # Parse the url: @@ -1054,8 +995,7 @@ class Layout: dutver = ctrl_panel.get("dd-dutver-value") phy = self.spec_tbs[rls][dut][dutver][dd_phy] options = sorted( - [{"label": self.label(v), "value": v} - for v in phy.keys()], + [{"label": label(v), "value": v} for v in phy.keys()], key=lambda d: d["label"] ) disabled = False @@ -1143,8 +1083,8 @@ class Layout: "cl-testtype-all-options": C.CL_ALL_ENABLED, }) elif trigger_id == "cl-ctrl-core": - val_sel, val_all = self._sync_checklists( - opt=ctrl_panel.get("cl-core-options"), + val_sel, val_all = sync_checklists( + options=ctrl_panel.get("cl-core-options"), sel=cl_core, all=list(), id="" @@ -1154,8 +1094,8 @@ class Layout: "cl-core-all-value": val_all, }) elif trigger_id == "cl-ctrl-core-all": - val_sel, val_all = self._sync_checklists( - opt = ctrl_panel.get("cl-core-options"), + val_sel, val_all = sync_checklists( + options = ctrl_panel.get("cl-core-options"), sel=list(), all=cl_core_all, id="all" @@ -1165,8 +1105,8 @@ class Layout: "cl-core-all-value": val_all, }) elif trigger_id == "cl-ctrl-framesize": - val_sel, val_all = self._sync_checklists( - opt = ctrl_panel.get("cl-framesize-options"), + val_sel, val_all = sync_checklists( + options = ctrl_panel.get("cl-framesize-options"), sel=cl_framesize, all=list(), id="" @@ -1176,8 +1116,8 @@ class Layout: "cl-framesize-all-value": val_all, }) elif trigger_id == "cl-ctrl-framesize-all": - val_sel, val_all = self._sync_checklists( - opt = ctrl_panel.get("cl-framesize-options"), + val_sel, val_all = sync_checklists( + options = ctrl_panel.get("cl-framesize-options"), sel=list(), all=cl_framesize_all, id="all" @@ -1187,8 +1127,8 @@ class Layout: "cl-framesize-all-value": val_all, }) elif trigger_id == "cl-ctrl-testtype": - val_sel, val_all = self._sync_checklists( - opt = ctrl_panel.get("cl-testtype-options"), + val_sel, val_all = sync_checklists( + options = ctrl_panel.get("cl-testtype-options"), sel=cl_testtype, all=list(), id="" @@ -1198,8 +1138,8 @@ class Layout: "cl-testtype-all-value": val_all, }) elif trigger_id == "cl-ctrl-testtype-all": - val_sel, val_all = self._sync_checklists( - opt = ctrl_panel.get("cl-testtype-options"), + val_sel, val_all = sync_checklists( + options = ctrl_panel.get("cl-testtype-options"), sel=list(), all=cl_testtype_all, id="all" @@ -1252,7 +1192,7 @@ class Layout: if C.CLEAR_ALL_INPUTS: ctrl_panel.set(ctrl_panel.defaults) ctrl_panel.set({ - "cl-selected-options": self._list_tests(store_sel) + "cl-selected-options": list_tests(store_sel) }) elif trigger_id == "btn-sel-remove-all": _ = btn_remove_all @@ -1294,10 +1234,10 @@ class Layout: table_comparison( self.data, store_sel, bool(cl_normalize) ), - _gen_new_url(parsed_url, store_sel) + gen_new_url(parsed_url, {"store_sel": store_sel}) ) ctrl_panel.set({ - "cl-selected-options": self._list_tests(store_sel) + "cl-selected-options": list_tests(store_sel) }) else: row_fig_tput = C.PLACEHOLDER