"""Plotly Dash HTML layout override.
"""
+import logging
import pandas as pd
import dash_bootstrap_components as dbc
}
def __init__(self, app: Flask, html_layout_file: str, spec_file: str,
- graph_layout_file: str, data_spec_file: str,
+ graph_layout_file: str, data_spec_file: str, tooltip_file: str,
time_period: str=None) -> None:
"""
"""
self._spec_file = spec_file
self._graph_layout_file = graph_layout_file
self._data_spec_file = data_spec_file
+ self._tooltip_file = tooltip_file
self._time_period = time_period
# Read the data:
infra = "-".join((tbed, nic, driver))
lst_test = test.split("-")
framesize = lst_test[0]
- core = lst_test[1] if lst_test[1] else "1C"
+ core = lst_test[1] if lst_test[1] else "8C"
test = "-".join(lst_test[2: -1])
if tbs.get(dut, None) is None:
# Read from files:
self._html_layout = ""
self._graph_layout = None
+ self._tooltips = dict()
try:
with open(self._html_layout_file, "r") as file_read:
except YAMLError as err:
raise RuntimeError(
f"An error occurred while parsing the specification file "
- f"{self._graph_layout_file}\n"
- f"{err}"
+ f"{self._graph_layout_file}\n{err}"
+ )
+
+ try:
+ with open(self._tooltip_file, "r") as file_read:
+ self._tooltips = load(file_read, Loader=FullLoader)
+ except IOError as err:
+ logging.warning(
+ f"Not possible to open the file {self._tooltip_file}\n{err}"
+ )
+ except YAMLError as err:
+ logging.warning(
+ f"An error occurred while parsing the specification file "
+ f"{self._tooltip_file}\n{err}"
)
# Callbacks:
def label(self, key: str) -> str:
return self.LABELS.get(key, key)
+ def _show_tooltip(self, id: str, title: str) -> list:
+ """
+ """
+ return [
+ 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):
"""
"""
children=[
dbc.InputGroup(
[
- dbc.InputGroupText("DUT"),
+ dbc.InputGroupText(
+ children=self._show_tooltip(
+ "help-dut", "DUT")
+ ),
dbc.Select(
id="dd-ctrl-dut",
placeholder=(
children=[
dbc.InputGroup(
[
- dbc.InputGroupText("Infra"),
+ dbc.InputGroupText(
+ children=self._show_tooltip(
+ "help-infra", "Infra")
+ ),
dbc.Select(
id="dd-ctrl-phy",
placeholder=(
children=[
dbc.InputGroup(
[
- dbc.InputGroupText("Area"),
+ dbc.InputGroupText(
+ children=self._show_tooltip(
+ "help-area", "Area")
+ ),
dbc.Select(
id="dd-ctrl-area",
placeholder="Select an Area...",
children=[
dbc.InputGroup(
[
- dbc.InputGroupText("Test"),
+ dbc.InputGroupText(
+ children=self._show_tooltip(
+ "help-test", "Test")
+ ),
dbc.Select(
id="dd-ctrl-test",
placeholder="Select a Test...",
]
),
dbc.Row(
- id="row-ctrl-core",
+ id="row-ctrl-framesize",
class_name="gy-1",
children=[
dbc.Label(
- "Number of Cores",
+ children=self._show_tooltip(
+ "help-framesize", "Frame Size"),
class_name="p-0"
),
dbc.Col(
children=[
dbc.Checklist(
- id="cl-ctrl-core-all",
+ id="cl-ctrl-framesize-all",
options=self.CL_ALL_DISABLED,
- inline=False,
+ inline=True,
switch=False
- )
+ ),
],
width=3
),
dbc.Col(
children=[
dbc.Checklist(
- id="cl-ctrl-core",
+ id="cl-ctrl-framesize",
inline=True,
switch=False
)
]
),
dbc.Row(
- id="row-ctrl-framesize",
+ id="row-ctrl-core",
class_name="gy-1",
children=[
dbc.Label(
- "Frame Size",
+ children=self._show_tooltip(
+ "help-cores", "Number of Cores"),
class_name="p-0"
),
dbc.Col(
children=[
dbc.Checklist(
- id="cl-ctrl-framesize-all",
+ id="cl-ctrl-core-all",
options=self.CL_ALL_DISABLED,
- inline=True,
+ inline=False,
switch=False
- ),
+ )
],
width=3
),
dbc.Col(
children=[
dbc.Checklist(
- id="cl-ctrl-framesize",
+ id="cl-ctrl-core",
inline=True,
switch=False
)
class_name="gy-1",
children=[
dbc.Label(
- "Test Type",
+ children=self._show_tooltip(
+ "help-ttype", "Test Type"),
class_name="p-0"
),
dbc.Col(
dbc.Row(
class_name="gy-1",
children=[
+ dbc.Label(
+ class_name="gy-1",
+ children=self._show_tooltip(
+ "help-time-period", "Time Period"),
+ ),
dcc.DatePickerRange(
id="dpr-period",
className="d-flex justify-content-center",
datetime.utcnow() - timedelta(
days=self.time_period),
end_date=datetime.utcnow(),
- display_format="D MMMM YY"
+ display_format="D MMM YY"
)
]
),
dcc.Loading(children=[
dbc.Button(
id="btn-download-data",
- children=["Download Data"],
+ children=self._show_tooltip(
+ "help-download", "Download"),
class_name="me-1",
color="info"
),