X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Ftools%2Fdash%2Fapp%2Fpal%2Ftrending%2Flayout.py;h=ac866cfe40c6d9febeb079be4740eae14e304fdb;hp=35668a475199b0e5c349a156e13dbca65d1962ab;hb=05cb018450ac15bcfa59f2a10ffd08607eee8f97;hpb=25c3aa43a0022d180fc9b31d68071790721c008b diff --git a/resources/tools/dash/app/pal/trending/layout.py b/resources/tools/dash/app/pal/trending/layout.py index 35668a4751..ac866cfe40 100644 --- a/resources/tools/dash/app/pal/trending/layout.py +++ b/resources/tools/dash/app/pal/trending/layout.py @@ -19,12 +19,13 @@ import dash_bootstrap_components as dbc from dash import dcc from dash import html -from dash import callback_context, no_update +from dash import callback_context, no_update, ALL from dash import Input, Output, State from dash.exceptions import PreventUpdate from yaml import load, FullLoader, YAMLError from datetime import datetime, timedelta from copy import deepcopy +from json import loads, JSONDecodeError from ..data.data import Data from .graphs import graph_trending, graph_hdrh_latency, \ @@ -67,12 +68,12 @@ class Layout: data_mrr = Data( data_spec_file=self._data_spec_file, debug=True - ).read_trending_mrr(days=5) + ).read_trending_mrr(days=180) data_ndrpdr = Data( data_spec_file=self._data_spec_file, debug=True - ).read_trending_ndrpdr(days=14) + ).read_trending_ndrpdr(days=180) self._data = pd.concat([data_mrr, data_ndrpdr], ignore_index=True) @@ -265,48 +266,54 @@ class Layout: class_name="g-0 p-2", children=[ dbc.Row( - class_name="gy-1", + class_name="g-0", children=[ - dbc.Label( - "Physical Test Bed Topology, NIC and Driver", - class_name="p-0" - ), - dbc.Select( - id="dd-ctrl-phy", - placeholder="Select a Physical Test Bed Topology...", - options=[ - {"label": k, "value": k} for k in self.spec_tbs.keys() + dbc.InputGroup( + [ + dbc.InputGroupText("Infra"), + dbc.Select( + id="dd-ctrl-phy", + placeholder="Select a Physical Test Bed Topology...", + options=[ + {"label": k, "value": k} for k in self.spec_tbs.keys() + ], + ), ], + class_name="mb-3", size="sm", ), ] ), dbc.Row( - class_name="gy-1", + class_name="g-0", children=[ - dbc.Label( - "Area", - class_name="p-0" - ), - dbc.Select( - id="dd-ctrl-area", - placeholder="Select an Area...", - disabled=True, + dbc.InputGroup( + [ + dbc.InputGroupText("Area"), + dbc.Select( + id="dd-ctrl-area", + placeholder="Select an Area...", + disabled=True, + ), + ], + class_name="mb-3", size="sm", ), ] ), dbc.Row( - class_name="gy-1", + class_name="g-0", children=[ - dbc.Label( - "Test", - class_name="p-0" - ), - dbc.Select( - id="dd-ctrl-test", - placeholder="Select a Test...", - disabled=True, + dbc.InputGroup( + [ + dbc.InputGroupText("Test"), + dbc.Select( + id="dd-ctrl-test", + placeholder="Select a Test...", + disabled=True, + ), + ], + class_name="mb-3", size="sm", ), ] @@ -402,14 +409,15 @@ class Layout: ] ), dbc.Row( - class_name="gy-1", + class_name="gy-1 p-0", children=[ dbc.ButtonGroup( [ dbc.Button( id="btn-ctrl-add", children="Add Selected", - color="secondary", + class_name="me-1", + color="info" ) ], size="md", @@ -455,19 +463,20 @@ class Layout: style=self.STYLE_DISABLED, children=[ dbc.ButtonGroup( + class_name="gy-2", children=[ dbc.Button( - id="btn-sel-remove-all", - children="Remove All", - class_name="w-100", - color="secondary", + id="btn-sel-remove", + children="Remove Selected", + class_name="w-100 me-1", + color="info", disabled=False ), dbc.Button( - id="btn-sel-remove", - children="Remove Selected", - class_name="w-100", - color="secondary", + id="btn-sel-remove-all", + children="Remove All", + class_name="w-100 me-1", + color="info", disabled=False ), ], @@ -576,7 +585,7 @@ class Layout: row_fig_tput = [ dcc.Loading( dcc.Graph( - id="graph-tput", + id={"type": "graph", "index": "tput"}, figure=fig_tput ) ), @@ -585,7 +594,9 @@ class Layout: dcc.Loading(children=[ dbc.Button( id="btn-download-data", - children=["Download Data"] + children=["Download Data"], + class_name="me-1", + color="info" ), dcc.Download(id="download-data") ]), @@ -594,7 +605,7 @@ class Layout: row_fig_lat = [ dcc.Loading( dcc.Graph( - id="graph-latency", + id={"type": "graph", "index": "lat"}, figure=fig_lat ) ) @@ -938,37 +949,35 @@ class Layout: Output("metadata-tput-lat", "children"), Output("metadata-hdrh-graph", "children"), Output("offcanvas-metadata", "is_open"), - Input("graph-tput", "clickData"), - Input("graph-latency", "clickData") + Input({"type": "graph", "index": ALL}, "clickData"), + prevent_initial_call=True ) - def _show_metadata_from_graphs( - tput_data: dict, lat_data: dict) -> tuple: + def _show_metadata_from_graphs(graph_data: dict) -> tuple: """ """ - if not (tput_data or lat_data): + try: + trigger_id = loads( + callback_context.triggered[0]["prop_id"].split(".")[0] + )["index"] + idx = 0 if trigger_id == "tput" else 1 + graph_data = graph_data[idx]["points"][0] + except (JSONDecodeError, IndexError, KeyError, ValueError, + TypeError): raise PreventUpdate metadata = no_update graph = list() - trigger_id = callback_context.triggered[0]["prop_id"].split(".")[0] - if trigger_id == "graph-tput": + children = [ + dbc.ListGroupItem( + [dbc.Badge(x.split(":")[0]), x.split(": ")[1]] + ) for x in graph_data.get("text", "").split("
") + ] + if trigger_id == "tput": title = "Throughput" - array = tput_data["points"][0]["text"].split("
") - children = [ - dbc.ListGroupItem( - [dbc.Badge(x.split(":")[0]), x.split(": ")[1]] - ) for x in array - ] - elif trigger_id == "graph-latency": + elif trigger_id == "lat": title = "Latency" - array = lat_data["points"][0]["text"].split("
") - children = [ - dbc.ListGroupItem( - [dbc.Badge(x.split(":")[0]), x.split(": ")[1]] - ) for x in array - ] - hdrh_data = lat_data["points"][0].get("customdata", None) + hdrh_data = graph_data.get("customdata", None) if hdrh_data: graph = [dbc.Card( class_name="gy-2 p-0", @@ -999,9 +1008,7 @@ class Layout: dbc.CardBody( id="tput-lat-metadata", class_name="p-0", - children=[ - dbc.ListGroup(children, flush=True) - ] + children=[dbc.ListGroup(children, flush=True), ] ) ] )