08a430bc3bd1265421132fe1942797af1d6af144
[csit.git] / csit.infra.dash / app / cdash / report / layout.py
1 # Copyright (c) 2023 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 """Plotly Dash HTML layout override.
15 """
16
17
18 import logging
19 import pandas as pd
20 import dash_bootstrap_components as dbc
21
22 from flask import Flask
23 from dash import dcc
24 from dash import html
25 from dash import callback_context, no_update, ALL
26 from dash import Input, Output, State
27 from dash.exceptions import PreventUpdate
28 from yaml import load, FullLoader, YAMLError
29 from ast import literal_eval
30
31 from ..utils.constants import Constants as C
32 from ..utils.control_panel import ControlPanel
33 from ..utils.trigger import Trigger
34 from ..utils.utils import show_tooltip, label, sync_checklists, gen_new_url, \
35     generate_options, get_list_group_items, graph_hdrh_latency
36 from ..utils.url_processing import url_decode
37 from .graphs import graph_iterative, select_iterative_data
38
39
40 # Control panel partameters and their default values.
41 CP_PARAMS = {
42     "dd-rls-val": str(),
43     "dd-dut-opt": list(),
44     "dd-dut-dis": True,
45     "dd-dut-val": str(),
46     "dd-dutver-opt": list(),
47     "dd-dutver-dis": True,
48     "dd-dutver-val": str(),
49     "dd-phy-opt": list(),
50     "dd-phy-dis": True,
51     "dd-phy-val": str(),
52     "dd-area-opt": list(),
53     "dd-area-dis": True,
54     "dd-area-val": str(),
55     "dd-test-opt": list(),
56     "dd-test-dis": True,
57     "dd-test-val": str(),
58     "cl-core-opt": list(),
59     "cl-core-val": list(),
60     "cl-core-all-val": list(),
61     "cl-core-all-opt": C.CL_ALL_DISABLED,
62     "cl-frmsize-opt": list(),
63     "cl-frmsize-val": list(),
64     "cl-frmsize-all-val": list(),
65     "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
66     "cl-tsttype-opt": list(),
67     "cl-tsttype-val": list(),
68     "cl-tsttype-all-val": list(),
69     "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
70     "btn-add-dis": True,
71     "cl-normalize-val": list()
72 }
73
74
75 class Layout:
76     """The layout of the dash app and the callbacks.
77     """
78
79     def __init__(
80             self,
81             app: Flask,
82             data_iterative: pd.DataFrame,
83             html_layout_file: str,
84             graph_layout_file: str,
85             tooltip_file: str
86         ) -> None:
87         """Initialization:
88         - save the input parameters,
89         - read and pre-process the data,
90         - prepare data for the control panel,
91         - read HTML layout file,
92         - read tooltips from the tooltip file.
93
94         :param app: Flask application running the dash application.
95         :param html_layout_file: Path and name of the file specifying the HTML
96             layout of the dash application.
97         :param graph_layout_file: Path and name of the file with layout of
98             plot.ly graphs.
99         :param tooltip_file: Path and name of the yaml file specifying the
100             tooltips.
101         :type app: Flask
102         :type html_layout_file: str
103         :type graph_layout_file: str
104         :type tooltip_file: str
105         """
106
107         # Inputs
108         self._app = app
109         self._html_layout_file = html_layout_file
110         self._graph_layout_file = graph_layout_file
111         self._tooltip_file = tooltip_file
112         self._data = data_iterative
113
114         # Get structure of tests:
115         tbs = dict()
116         cols = [
117             "job", "test_id", "test_type", "dut_version", "tg_type", "release"
118         ]
119         for _, row in self._data[cols].drop_duplicates().iterrows():
120             rls = row["release"]
121             lst_job = row["job"].split("-")
122             dut = lst_job[1]
123             d_ver = row["dut_version"]
124             tbed = "-".join(lst_job[-2:])
125             lst_test_id = row["test_id"].split(".")
126             if dut == "dpdk":
127                 area = "dpdk"
128             else:
129                 area = ".".join(lst_test_id[3:-2])
130             suite = lst_test_id[-2].replace("2n1l-", "").replace("1n1l-", "").\
131                 replace("2n-", "")
132             test = lst_test_id[-1]
133             nic = suite.split("-")[0]
134             for drv in C.DRIVERS:
135                 if drv in test:
136                     driver = drv.replace("-", "_")
137                     test = test.replace(f"{drv}-", "")
138                     break
139             else:
140                 driver = "dpdk"
141             infra = "-".join((tbed, nic, driver))
142             lst_test = test.split("-")
143             framesize = lst_test[0]
144             core = lst_test[1] if lst_test[1] else "8C"
145             test = "-".join(lst_test[2: -1])
146
147             if tbs.get(rls, None) is None:
148                 tbs[rls] = dict()
149             if tbs[rls].get(dut, None) is None:
150                 tbs[rls][dut] = dict()
151             if tbs[rls][dut].get(d_ver, None) is None:
152                 tbs[rls][dut][d_ver] = dict()
153             if tbs[rls][dut][d_ver].get(area, None) is None:
154                 tbs[rls][dut][d_ver][area] = dict()
155             if tbs[rls][dut][d_ver][area].get(test, None) is None:
156                 tbs[rls][dut][d_ver][area][test] = dict()
157             if tbs[rls][dut][d_ver][area][test].get(infra, None) is None:
158                 tbs[rls][dut][d_ver][area][test][infra] = {
159                     "core": list(),
160                     "frame-size": list(),
161                     "test-type": list()
162                 }
163             tst_params = tbs[rls][dut][d_ver][area][test][infra]
164             if core.upper() not in tst_params["core"]:
165                 tst_params["core"].append(core.upper())
166             if framesize.upper() not in tst_params["frame-size"]:
167                 tst_params["frame-size"].append(framesize.upper())
168             if row["test_type"] == "mrr":
169                 if "MRR" not in tst_params["test-type"]:
170                     tst_params["test-type"].append("MRR")
171             elif row["test_type"] == "ndrpdr":
172                 if "NDR" not in tst_params["test-type"]:
173                     tst_params["test-type"].extend(("NDR", "PDR", ))
174             elif row["test_type"] == "hoststack" and \
175                     row["tg_type"] in ("iperf", "vpp"):
176                 if "BPS" not in tst_params["test-type"]:
177                     tst_params["test-type"].append("BPS")
178             elif row["test_type"] == "hoststack" and row["tg_type"] == "ab":
179                 if "CPS" not in tst_params["test-type"]:
180                     tst_params["test-type"].extend(("CPS", "RPS"))
181         self._spec_tbs = tbs
182
183         # Read from files:
184         self._html_layout = str()
185         self._graph_layout = None
186         self._tooltips = dict()
187
188         try:
189             with open(self._html_layout_file, "r") as file_read:
190                 self._html_layout = file_read.read()
191         except IOError as err:
192             raise RuntimeError(
193                 f"Not possible to open the file {self._html_layout_file}\n{err}"
194             )
195
196         try:
197             with open(self._graph_layout_file, "r") as file_read:
198                 self._graph_layout = load(file_read, Loader=FullLoader)
199         except IOError as err:
200             raise RuntimeError(
201                 f"Not possible to open the file {self._graph_layout_file}\n"
202                 f"{err}"
203             )
204         except YAMLError as err:
205             raise RuntimeError(
206                 f"An error occurred while parsing the specification file "
207                 f"{self._graph_layout_file}\n{err}"
208             )
209
210         try:
211             with open(self._tooltip_file, "r") as file_read:
212                 self._tooltips = load(file_read, Loader=FullLoader)
213         except IOError as err:
214             logging.warning(
215                 f"Not possible to open the file {self._tooltip_file}\n{err}"
216             )
217         except YAMLError as err:
218             logging.warning(
219                 f"An error occurred while parsing the specification file "
220                 f"{self._tooltip_file}\n{err}"
221             )
222
223         # Callbacks:
224         if self._app is not None and hasattr(self, "callbacks"):
225             self.callbacks(self._app)
226
227     @property
228     def html_layout(self):
229         return self._html_layout
230
231     def add_content(self):
232         """Top level method which generated the web page.
233
234         It generates:
235         - Store for user input data,
236         - Navigation bar,
237         - Main area with control panel and ploting area.
238
239         If no HTML layout is provided, an error message is displayed instead.
240
241         :returns: The HTML div with the whole page.
242         :rtype: html.Div
243         """
244
245         if self.html_layout and self._spec_tbs:
246             return html.Div(
247                 id="div-main",
248                 className="small",
249                 children=[
250                     dbc.Row(
251                         id="row-navbar",
252                         class_name="g-0",
253                         children=[
254                             self._add_navbar()
255                         ]
256                     ),
257                     dbc.Row(
258                         id="row-main",
259                         class_name="g-0",
260                         children=[
261                             dcc.Store(id="store-selected-tests"),
262                             dcc.Store(id="store-control-panel"),
263                             dcc.Location(id="url", refresh=False),
264                             self._add_ctrl_col(),
265                             self._add_plotting_col()
266                         ]
267                     ),
268                     dbc.Spinner(
269                         dbc.Offcanvas(
270                             class_name="w-50",
271                             id="offcanvas-metadata",
272                             title="Throughput And Latency",
273                             placement="end",
274                             is_open=False,
275                             children=[
276                                 dbc.Row(id="metadata-tput-lat"),
277                                 dbc.Row(id="metadata-hdrh-graph")
278                             ]
279                         ),
280                         delay_show=C.SPINNER_DELAY
281                     ),
282                     dbc.Offcanvas(
283                         class_name="w-75",
284                         id="offcanvas-documentation",
285                         title="Documentation",
286                         placement="end",
287                         is_open=False,
288                         children=html.Iframe(
289                             src=C.URL_DOC_REL_NOTES,
290                             width="100%",
291                             height="100%"
292                         )
293                     )
294                 ]
295             )
296         else:
297             return html.Div(
298                 id="div-main-error",
299                 children=[
300                     dbc.Alert(
301                         [
302                             "An Error Occured"
303                         ],
304                         color="danger"
305                     )
306                 ]
307             )
308
309     def _add_navbar(self):
310         """Add nav element with navigation panel. It is placed on the top.
311
312         :returns: Navigation bar.
313         :rtype: dbc.NavbarSimple
314         """
315         return dbc.NavbarSimple(
316             id="navbarsimple-main",
317             children=[
318                 dbc.NavItem(dbc.NavLink(
319                     C.REPORT_TITLE,
320                     active=True,
321                     external_link=True,
322                     href="/report"
323                 )),
324                 dbc.NavItem(dbc.NavLink(
325                     "Comparisons",
326                     external_link=True,
327                     href="/comparisons"
328                 )),
329                 dbc.NavItem(dbc.NavLink(
330                     "Coverage Data",
331                     external_link=True,
332                     href="/coverage"
333                 )),
334                 dbc.NavItem(dbc.NavLink(
335                     "Documentation",
336                     id="btn-documentation",
337                 ))
338             ],
339             brand=C.BRAND,
340             brand_href="/",
341             brand_external_link=True,
342             class_name="p-2",
343             fluid=True
344         )
345
346     def _add_ctrl_col(self) -> dbc.Col:
347         """Add column with controls. It is placed on the left side.
348
349         :returns: Column with the control panel.
350         :rtype: dbc.Col
351         """
352         return dbc.Col([
353             html.Div(
354                 children=self._add_ctrl_panel(),
355                 className="sticky-top"
356             )
357         ])
358
359     def _add_plotting_col(self) -> dbc.Col:
360         """Add column with plots. It is placed on the right side.
361
362         :returns: Column with plots.
363         :rtype: dbc.Col
364         """
365         return dbc.Col(
366             id="col-plotting-area",
367             children=[
368                 dbc.Spinner(
369                     children=[
370                         dbc.Row(
371                             id="plotting-area",
372                             class_name="g-0 p-0",
373                             children=[
374                                 C.PLACEHOLDER
375                             ]
376                         )
377                     ]
378                 )
379             ],
380             width=9
381         )
382
383     def _add_ctrl_panel(self) -> list:
384         """Add control panel.
385
386         :returns: Control panel.
387         :rtype: list
388         """
389         return [
390             dbc.Row(
391                 class_name="g-0 p-1",
392                 children=[
393                     dbc.InputGroup(
394                         [
395                             dbc.InputGroupText(
396                                 children=show_tooltip(
397                                     self._tooltips,
398                                     "help-release",
399                                     "CSIT Release"
400                                 )
401                             ),
402                             dbc.Select(
403                                 id={"type": "ctrl-dd", "index": "rls"},
404                                 placeholder="Select a Release...",
405                                 options=sorted(
406                                     [
407                                         {"label": k, "value": k} \
408                                             for k in self._spec_tbs.keys()
409                                     ],
410                                     key=lambda d: d["label"]
411                                 )
412                             )
413                         ],
414                         size="sm"
415                     )
416                 ]
417             ),
418             dbc.Row(
419                 class_name="g-0 p-1",
420                 children=[
421                     dbc.InputGroup(
422                         [
423                             dbc.InputGroupText(
424                                 children=show_tooltip(
425                                     self._tooltips,
426                                     "help-dut",
427                                     "DUT"
428                                 )
429                             ),
430                             dbc.Select(
431                                 id={"type": "ctrl-dd", "index": "dut"},
432                                 placeholder="Select a Device under Test..."
433                             )
434                         ],
435                         size="sm"
436                     )
437                 ]
438             ),
439             dbc.Row(
440                 class_name="g-0 p-1",
441                 children=[
442                     dbc.InputGroup(
443                         [
444                             dbc.InputGroupText(
445                                 children=show_tooltip(
446                                     self._tooltips,
447                                     "help-dut-ver",
448                                     "DUT Version"
449                                 )
450                             ),
451                             dbc.Select(
452                                 id={"type": "ctrl-dd", "index": "dutver"},
453                                 placeholder=\
454                                     "Select a Version of Device under Test..."
455                             )
456                         ],
457                         size="sm"
458                     )
459                 ]
460             ),
461             dbc.Row(
462                 class_name="g-0 p-1",
463                 children=[
464                     dbc.InputGroup(
465                         [
466                             dbc.InputGroupText(
467                                 children=show_tooltip(
468                                     self._tooltips,
469                                     "help-area",
470                                     "Area"
471                                 )
472                             ),
473                             dbc.Select(
474                                 id={"type": "ctrl-dd", "index": "area"},
475                                 placeholder="Select an Area..."
476                             )
477                         ],
478                         size="sm"
479                     )
480                 ]
481             ),
482             dbc.Row(
483                 class_name="g-0 p-1",
484                 children=[
485                     dbc.InputGroup(
486                         [
487                             dbc.InputGroupText(
488                                 children=show_tooltip(
489                                     self._tooltips,
490                                     "help-test",
491                                     "Test"
492                                 )
493                             ),
494                             dbc.Select(
495                                 id={"type": "ctrl-dd", "index": "test"},
496                                 placeholder="Select a Test..."
497                             )
498                         ],
499                         size="sm"
500                     )
501                 ]
502             ),
503             dbc.Row(
504                 class_name="g-0 p-1",
505                 children=[
506                     dbc.InputGroup(
507                         [
508                             dbc.InputGroupText(
509                                 children=show_tooltip(
510                                     self._tooltips,
511                                     "help-infra",
512                                     "Infra"
513                                 )
514                             ),
515                             dbc.Select(
516                                 id={"type": "ctrl-dd", "index": "phy"},
517                                 placeholder=\
518                                     "Select a Physical Test Bed Topology..."
519                             )
520                         ],
521                         size="sm"
522                     )
523                 ]
524             ),
525             dbc.Row(
526                 class_name="g-0 p-1",
527                 children=[
528                     dbc.InputGroup(
529                         [
530                             dbc.InputGroupText(
531                                 children=show_tooltip(
532                                     self._tooltips,
533                                     "help-framesize",
534                                     "Frame Size"
535                                 )
536                             ),
537                             dbc.Col(
538                                 children=[
539                                     dbc.Checklist(
540                                         id={
541                                             "type": "ctrl-cl",
542                                             "index": "frmsize-all"
543                                         },
544                                         options=C.CL_ALL_DISABLED,
545                                         inline=True,
546                                         class_name="ms-2"
547                                     )
548                                 ],
549                                 width=2
550                             ),
551                             dbc.Col(
552                                 children=[
553                                     dbc.Checklist(
554                                         id={
555                                             "type": "ctrl-cl",
556                                             "index": "frmsize"
557                                         },
558                                         inline=True
559                                     )
560                                 ]
561                             )
562                         ],
563                         style={"align-items": "center"},
564                         size="sm"
565                     )
566                 ]
567             ),
568             dbc.Row(
569                 class_name="g-0 p-1",
570                 children=[
571                     dbc.InputGroup(
572                         [
573                             dbc.InputGroupText(
574                                 children=show_tooltip(
575                                     self._tooltips,
576                                     "help-cores",
577                                     "Number of Cores"
578                                 )
579                             ),
580                             dbc.Col(
581                                 children=[
582                                     dbc.Checklist(
583                                         id={
584                                             "type": "ctrl-cl",
585                                             "index": "core-all"
586                                         },
587                                         options=C.CL_ALL_DISABLED,
588                                         inline=True,
589                                         class_name="ms-2"
590                                     )
591                                 ],
592                                 width=2
593                             ),
594                             dbc.Col(
595                                 children=[
596                                     dbc.Checklist(
597                                         id={
598                                             "type": "ctrl-cl",
599                                             "index": "core"
600                                         },
601                                         inline=True
602                                     )
603                                 ]
604                             )
605                         ],
606                         style={"align-items": "center"},
607                         size="sm"
608                     )
609                 ]
610             ),
611             dbc.Row(
612                 class_name="g-0 p-1",
613                 children=[
614                     dbc.InputGroup(
615                         [
616                             dbc.InputGroupText(
617                                 children=show_tooltip(
618                                     self._tooltips,
619                                     "help-ttype",
620                                     "Test Type"
621                                 )
622                             ),
623                             dbc.Col(
624                                 children=[
625                                     dbc.Checklist(
626                                         id={
627                                             "type": "ctrl-cl",
628                                             "index": "tsttype-all"
629                                         },
630                                         options=C.CL_ALL_DISABLED,
631                                         inline=True,
632                                         class_name="ms-2"
633                                     )
634                                 ],
635                                 width=2
636                             ),
637                             dbc.Col(
638                                 children=[
639                                     dbc.Checklist(
640                                         id={
641                                             "type": "ctrl-cl",
642                                             "index": "tsttype"
643                                         },
644                                         inline=True
645                                     )
646                                 ]
647                             )
648                         ],
649                         style={"align-items": "center"},
650                         size="sm"
651                     )
652                 ]
653             ),
654             dbc.Row(
655                 class_name="g-0 p-1",
656                 children=[
657                     dbc.InputGroup(
658                         [
659                             dbc.InputGroupText(
660                                 children=show_tooltip(
661                                     self._tooltips,
662                                     "help-normalize",
663                                     "Normalization"
664                                 )
665                             ),
666                             dbc.Col(
667                                 children=[
668                                     dbc.Checklist(
669                                         id="normalize",
670                                         options=[{
671                                             "value": "normalize",
672                                             "label": (
673                                                 "Normalize to CPU frequency "
674                                                 "2GHz"
675                                             )
676                                         }],
677                                         value=[],
678                                         inline=True,
679                                         class_name="ms-2"
680                                     )
681                                 ]
682                             )
683                         ],
684                         style={"align-items": "center"},
685                         size="sm"
686                     )
687                 ]
688             ),
689             dbc.Row(
690                 class_name="g-0 p-1",
691                 children=[
692                     dbc.Button(
693                         id={"type": "ctrl-btn", "index": "add-test"},
694                         children="Add Selected",
695                         color="info"
696                     )
697                 ]
698             ),
699             dbc.Row(
700                 id="row-card-sel-tests",
701                 class_name="g-0 p-1",
702                 style=C.STYLE_DISABLED,
703                 children=[
704                     dbc.ListGroup(
705                         class_name="overflow-auto p-0",
706                         id="lg-selected",
707                         children=[],
708                         style={"max-height": "20em"},
709                         flush=True
710                     )
711                 ]
712             ),
713             dbc.Stack(
714                 id="row-btns-sel-tests",
715                 class_name="g-0 p-1",
716                 style=C.STYLE_DISABLED,
717                 gap=2,
718                 children=[
719                     dbc.ButtonGroup(children=[
720                         dbc.Button(
721                             id={"type": "ctrl-btn", "index": "rm-test"},
722                             children="Remove Selected",
723                             class_name="w-100",
724                             color="info",
725                             disabled=False
726                         ),
727                         dbc.Button(
728                             id={"type": "ctrl-btn", "index": "rm-test-all"},
729                             children="Remove All",
730                             class_name="w-100",
731                             color="info",
732                             disabled=False
733                         )
734                     ]),
735                     dbc.ButtonGroup(children=[
736                         dbc.Button(
737                             id="plot-btn-url",
738                             children="Show URL",
739                             class_name="w-100",
740                             color="info",
741                             disabled=False
742                         ),
743                         dbc.Button(
744                             id="plot-btn-download",
745                             children="Download Data",
746                             class_name="w-100",
747                             color="info",
748                             disabled=False
749                         )
750                     ])
751                 ]
752             )
753         ]
754
755     def _get_plotting_area(
756             self,
757             tests: list,
758             normalize: bool,
759             url: str
760         ) -> list:
761         """Generate the plotting area with all its content.
762
763         :param tests: List of tests to be displayed in the graphs.
764         :param normalize: If true, the values in graphs are normalized.
765         :param url: URL to be displayed in the modal window.
766         :type tests: list
767         :type normalize: bool
768         :type url: str
769         :returns: List of rows with elements to be displayed in the plotting
770             area.
771         :rtype: list
772         """
773         if not tests:
774             return C.PLACEHOLDER
775
776         graphs = \
777             graph_iterative(self._data, tests, self._graph_layout, normalize)
778
779         if not graphs[0]:
780             return C.PLACEHOLDER
781         
782         tab_items = [
783             dbc.Tab(
784                 children=dcc.Graph(
785                     id={"type": "graph", "index": "tput"},
786                     figure=graphs[0]
787                 ),
788                 label="Throughput",
789                 tab_id="tab-tput"
790             )
791         ]
792
793         if graphs[1]:
794             tab_items.append(
795                 dbc.Tab(
796                     children=dcc.Graph(
797                         id={"type": "graph", "index": "bandwidth"},
798                         figure=graphs[1]
799                     ),
800                     label="Bandwidth",
801                     tab_id="tab-bandwidth"
802                 )
803             )
804
805         if graphs[2]:
806             tab_items.append(
807                 dbc.Tab(
808                     children=dcc.Graph(
809                         id={"type": "graph", "index": "lat"},
810                         figure=graphs[2]
811                     ),
812                     label="Latency",
813                     tab_id="tab-lat"
814                 )
815             )
816
817         return [
818             dbc.Row(
819                 dbc.Tabs(
820                     children=tab_items,
821                     id="tabs",
822                     active_tab="tab-tput",
823                 ),
824                 class_name="g-0 p-0"
825             ),
826             dbc.Modal(
827                 [
828                     dbc.ModalHeader(dbc.ModalTitle("URL")),
829                     dbc.ModalBody(url)
830                 ],
831                 id="plot-mod-url",
832                 size="xl",
833                 is_open=False,
834                 scrollable=True
835             ),
836             dcc.Download(id="download-iterative-data")
837         ]
838
839     def callbacks(self, app):
840         """Callbacks for the whole application.
841
842         :param app: The application.
843         :type app: Flask
844         """
845
846         @app.callback(
847             [
848                 Output("store-control-panel", "data"),
849                 Output("store-selected-tests", "data"),
850                 Output("plotting-area", "children"),
851                 Output("row-card-sel-tests", "style"),
852                 Output("row-btns-sel-tests", "style"),
853                 Output("lg-selected", "children"),
854
855                 Output({"type": "ctrl-dd", "index": "rls"}, "value"),
856                 Output({"type": "ctrl-dd", "index": "dut"}, "options"),
857                 Output({"type": "ctrl-dd", "index": "dut"}, "disabled"),
858                 Output({"type": "ctrl-dd", "index": "dut"}, "value"),
859                 Output({"type": "ctrl-dd", "index": "dutver"}, "options"),
860                 Output({"type": "ctrl-dd", "index": "dutver"}, "disabled"),
861                 Output({"type": "ctrl-dd", "index": "dutver"}, "value"),
862                 Output({"type": "ctrl-dd", "index": "phy"}, "options"),
863                 Output({"type": "ctrl-dd", "index": "phy"}, "disabled"),
864                 Output({"type": "ctrl-dd", "index": "phy"}, "value"),
865                 Output({"type": "ctrl-dd", "index": "area"}, "options"),
866                 Output({"type": "ctrl-dd", "index": "area"}, "disabled"),
867                 Output({"type": "ctrl-dd", "index": "area"}, "value"),
868                 Output({"type": "ctrl-dd", "index": "test"}, "options"),
869                 Output({"type": "ctrl-dd", "index": "test"}, "disabled"),
870                 Output({"type": "ctrl-dd", "index": "test"}, "value"),
871                 Output({"type": "ctrl-cl", "index": "core"}, "options"),
872                 Output({"type": "ctrl-cl", "index": "core"}, "value"),
873                 Output({"type": "ctrl-cl", "index": "core-all"}, "value"),
874                 Output({"type": "ctrl-cl", "index": "core-all"}, "options"),
875                 Output({"type": "ctrl-cl", "index": "frmsize"}, "options"),
876                 Output({"type": "ctrl-cl", "index": "frmsize"}, "value"),
877                 Output({"type": "ctrl-cl", "index": "frmsize-all"}, "value"),
878                 Output({"type": "ctrl-cl", "index": "frmsize-all"}, "options"),
879                 Output({"type": "ctrl-cl", "index": "tsttype"}, "options"),
880                 Output({"type": "ctrl-cl", "index": "tsttype"}, "value"),
881                 Output({"type": "ctrl-cl", "index": "tsttype-all"}, "value"),
882                 Output({"type": "ctrl-cl", "index": "tsttype-all"}, "options"),
883                 Output({"type": "ctrl-btn", "index": "add-test"}, "disabled"),
884                 Output("normalize", "value")
885             ],
886             [
887                 State("store-control-panel", "data"),
888                 State("store-selected-tests", "data"),
889                 State({"type": "sel-cl", "index": ALL}, "value")
890             ],
891             [
892                 Input("url", "href"),
893                 Input("normalize", "value"),
894
895                 Input({"type": "ctrl-dd", "index": ALL}, "value"),
896                 Input({"type": "ctrl-cl", "index": ALL}, "value"),
897                 Input({"type": "ctrl-btn", "index": ALL}, "n_clicks")
898             ]
899         )
900         def _update_application(
901                 control_panel: dict,
902                 store_sel: list,
903                 lst_sel: list,
904                 href: str,
905                 normalize: list,
906                 *_
907             ) -> tuple:
908             """Update the application when the event is detected.
909             """
910
911             ctrl_panel = ControlPanel(CP_PARAMS, control_panel)
912             on_draw = False
913
914             # Parse the url:
915             parsed_url = url_decode(href)
916             if parsed_url:
917                 url_params = parsed_url["params"]
918             else:
919                 url_params = None
920
921             plotting_area = no_update
922             row_card_sel_tests = no_update
923             row_btns_sel_tests = no_update
924             lg_selected = no_update
925
926             trigger = Trigger(callback_context.triggered)
927
928             if trigger.type == "url" and url_params:
929                 try:
930                     store_sel = literal_eval(url_params["store_sel"][0])
931                     normalize = literal_eval(url_params["norm"][0])
932                 except (KeyError, IndexError, AttributeError):
933                     pass
934                 if store_sel:
935                     row_card_sel_tests = C.STYLE_ENABLED
936                     row_btns_sel_tests = C.STYLE_ENABLED
937                     last_test = store_sel[-1]
938                     test = self._spec_tbs[last_test["rls"]][last_test["dut"]]\
939                         [last_test["dutver"]][last_test["area"]]\
940                             [last_test["test"]][last_test["phy"]]
941                     ctrl_panel.set({
942                         "dd-rls-val": last_test["rls"],
943                         "dd-dut-val": last_test["dut"],
944                         "dd-dut-opt": generate_options(
945                             self._spec_tbs[last_test["rls"]].keys()
946                         ),
947                         "dd-dut-dis": False,
948                         "dd-dutver-val": last_test["dutver"],
949                         "dd-dutver-opt": generate_options(
950                             self._spec_tbs[last_test["rls"]]\
951                                 [last_test["dut"]].keys()
952                         ),
953                         "dd-dutver-dis": False,
954                         "dd-area-val": last_test["area"],
955                         "dd-area-opt": [
956                             {"label": label(v), "value": v} for v in \
957                                 sorted(self._spec_tbs[last_test["rls"]]\
958                                     [last_test["dut"]]\
959                                         [last_test["dutver"]].keys())
960                         ],
961                         "dd-area-dis": False,
962                         "dd-test-val": last_test["test"],
963                         "dd-test-opt": generate_options(
964                             self._spec_tbs[last_test["rls"]][last_test["dut"]]\
965                                 [last_test["dutver"]][last_test["area"]].keys()
966                         ),
967                         "dd-test-dis": False,
968                         "dd-phy-val": last_test["phy"],
969                         "dd-phy-opt": generate_options(
970                             self._spec_tbs[last_test["rls"]][last_test["dut"]]\
971                                 [last_test["dutver"]][last_test["area"]]\
972                                     [last_test["test"]].keys()
973                         ),
974                         "dd-phy-dis": False,
975                         "cl-core-opt": generate_options(test["core"]),
976                         "cl-core-val": [last_test["core"].upper(), ],
977                         "cl-core-all-val": list(),
978                         "cl-core-all-opt": C.CL_ALL_ENABLED,
979                         "cl-frmsize-opt": generate_options(test["frame-size"]),
980                         "cl-frmsize-val": [last_test["framesize"].upper(), ],
981                         "cl-frmsize-all-val": list(),
982                         "cl-frmsize-all-opt": C.CL_ALL_ENABLED,
983                         "cl-tsttype-opt": generate_options(test["test-type"]),
984                         "cl-tsttype-val": [last_test["testtype"].upper(), ],
985                         "cl-tsttype-all-val": list(),
986                         "cl-tsttype-all-opt": C.CL_ALL_ENABLED,
987                         "cl-normalize-val": normalize,
988                         "btn-add-dis": False
989                     })
990                     on_draw = True
991             elif trigger.type == "normalize":
992                 ctrl_panel.set({"cl-normalize-val": normalize})
993                 on_draw = True
994             elif trigger.type == "ctrl-dd":
995                 if trigger.idx == "rls":
996                     try:
997                         options = generate_options(
998                             self._spec_tbs[trigger.value].keys()
999                         )
1000                         disabled = False
1001                     except KeyError:
1002                         options = list()
1003                         disabled = True
1004                     ctrl_panel.set({
1005                         "dd-rls-val": trigger.value,
1006                         "dd-dut-val": str(),
1007                         "dd-dut-opt": options,
1008                         "dd-dut-dis": disabled,
1009                         "dd-dutver-val": str(),
1010                         "dd-dutver-opt": list(),
1011                         "dd-dutver-dis": True,
1012                         "dd-phy-val": str(),
1013                         "dd-phy-opt": list(),
1014                         "dd-phy-dis": True,
1015                         "dd-area-val": str(),
1016                         "dd-area-opt": list(),
1017                         "dd-area-dis": True,
1018                         "dd-test-val": str(),
1019                         "dd-test-opt": list(),
1020                         "dd-test-dis": True,
1021                         "cl-core-opt": list(),
1022                         "cl-core-val": list(),
1023                         "cl-core-all-val": list(),
1024                         "cl-core-all-opt": C.CL_ALL_DISABLED,
1025                         "cl-frmsize-opt": list(),
1026                         "cl-frmsize-val": list(),
1027                         "cl-frmsize-all-val": list(),
1028                         "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1029                         "cl-tsttype-opt": list(),
1030                         "cl-tsttype-val": list(),
1031                         "cl-tsttype-all-val": list(),
1032                         "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1033                         "btn-add-dis": True
1034                     })
1035                 elif trigger.idx == "dut":
1036                     try:
1037                         rls = ctrl_panel.get("dd-rls-val")
1038                         dut = self._spec_tbs[rls][trigger.value]
1039                         options = generate_options(dut.keys())
1040                         disabled = False
1041                     except KeyError:
1042                         options = list()
1043                         disabled = True
1044                     ctrl_panel.set({
1045                         "dd-dut-val": trigger.value,
1046                         "dd-dutver-val": str(),
1047                         "dd-dutver-opt": options,
1048                         "dd-dutver-dis": disabled,
1049                         "dd-phy-val": str(),
1050                         "dd-phy-opt": list(),
1051                         "dd-phy-dis": True,
1052                         "dd-area-val": str(),
1053                         "dd-area-opt": list(),
1054                         "dd-area-dis": True,
1055                         "dd-test-val": str(),
1056                         "dd-test-opt": list(),
1057                         "dd-test-dis": True,
1058                         "cl-core-opt": list(),
1059                         "cl-core-val": list(),
1060                         "cl-core-all-val": list(),
1061                         "cl-core-all-opt": C.CL_ALL_DISABLED,
1062                         "cl-frmsize-opt": list(),
1063                         "cl-frmsize-val": list(),
1064                         "cl-frmsize-all-val": list(),
1065                         "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1066                         "cl-tsttype-opt": list(),
1067                         "cl-tsttype-val": list(),
1068                         "cl-tsttype-all-val": list(),
1069                         "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1070                         "btn-add-dis": True
1071                     })
1072                 elif trigger.idx == "dutver":
1073                     try:
1074                         rls = ctrl_panel.get("dd-rls-val")
1075                         dut = ctrl_panel.get("dd-dut-val")
1076                         dutver = self._spec_tbs[rls][dut][trigger.value]
1077                         options = [{"label": label(v), "value": v} \
1078                             for v in sorted(dutver.keys())]
1079                         disabled = False
1080                     except KeyError:
1081                         options = list()
1082                         disabled = True
1083                     ctrl_panel.set({
1084                         "dd-dutver-val": trigger.value,
1085                         "dd-area-val": str(),
1086                         "dd-area-opt": options,
1087                         "dd-area-dis": disabled,
1088                         "dd-test-val": str(),
1089                         "dd-test-opt": list(),
1090                         "dd-test-dis": True,
1091                         "dd-phy-val": str(),
1092                         "dd-phy-opt": list(),
1093                         "dd-phy-dis": True,
1094                         "cl-core-opt": list(),
1095                         "cl-core-val": list(),
1096                         "cl-core-all-val": list(),
1097                         "cl-core-all-opt": C.CL_ALL_DISABLED,
1098                         "cl-frmsize-opt": list(),
1099                         "cl-frmsize-val": list(),
1100                         "cl-frmsize-all-val": list(),
1101                         "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1102                         "cl-tsttype-opt": list(),
1103                         "cl-tsttype-val": list(),
1104                         "cl-tsttype-all-val": list(),
1105                         "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1106                         "btn-add-dis": True
1107                     })
1108                 elif trigger.idx == "area":
1109                     try:
1110                         rls = ctrl_panel.get("dd-rls-val")
1111                         dut = ctrl_panel.get("dd-dut-val")
1112                         dutver = ctrl_panel.get("dd-dutver-val")
1113                         area = self._spec_tbs[rls][dut][dutver][trigger.value]
1114                         options = generate_options(area.keys())
1115                         disabled = False
1116                     except KeyError:
1117                         options = list()
1118                         disabled = True
1119                     ctrl_panel.set({
1120                         "dd-area-val": trigger.value,
1121                         "dd-test-val": str(),
1122                         "dd-test-opt": options,
1123                         "dd-test-dis": disabled,
1124                         "dd-phy-val": str(),
1125                         "dd-phy-opt": list(),
1126                         "dd-phy-dis": True,
1127                         "cl-core-opt": list(),
1128                         "cl-core-val": list(),
1129                         "cl-core-all-val": list(),
1130                         "cl-core-all-opt": C.CL_ALL_DISABLED,
1131                         "cl-frmsize-opt": list(),
1132                         "cl-frmsize-val": list(),
1133                         "cl-frmsize-all-val": list(),
1134                         "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1135                         "cl-tsttype-opt": list(),
1136                         "cl-tsttype-val": list(),
1137                         "cl-tsttype-all-val": list(),
1138                         "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1139                         "btn-add-dis": True
1140                     })
1141                 elif trigger.idx == "test":
1142                     try:
1143                         rls = ctrl_panel.get("dd-rls-val")
1144                         dut = ctrl_panel.get("dd-dut-val")
1145                         dutver = ctrl_panel.get("dd-dutver-val")
1146                         area = ctrl_panel.get("dd-area-val")
1147                         test = self._spec_tbs[rls][dut][dutver][area]\
1148                             [trigger.value]
1149                         options = generate_options(test.keys())
1150                         disabled = False
1151                     except KeyError:
1152                         options = list()
1153                         disabled = True
1154                     ctrl_panel.set({
1155                         "dd-test-val": trigger.value,
1156                         "dd-phy-val": str(),
1157                         "dd-phy-opt": options,
1158                         "dd-phy-dis": disabled,
1159                         "cl-core-opt": list(),
1160                         "cl-core-val": list(),
1161                         "cl-core-all-val": list(),
1162                         "cl-core-all-opt": C.CL_ALL_DISABLED,
1163                         "cl-frmsize-opt": list(),
1164                         "cl-frmsize-val": list(),
1165                         "cl-frmsize-all-val": list(),
1166                         "cl-frmsize-all-opt": C.CL_ALL_DISABLED,
1167                         "cl-tsttype-opt": list(),
1168                         "cl-tsttype-val": list(),
1169                         "cl-tsttype-all-val": list(),
1170                         "cl-tsttype-all-opt": C.CL_ALL_DISABLED,
1171                         "btn-add-dis": True
1172                     })
1173                 elif trigger.idx == "phy":
1174                     rls = ctrl_panel.get("dd-rls-val")
1175                     dut = ctrl_panel.get("dd-dut-val")
1176                     dutver = ctrl_panel.get("dd-dutver-val")
1177                     area = ctrl_panel.get("dd-area-val")
1178                     test = ctrl_panel.get("dd-test-val")
1179                     if all((rls, dut, dutver, area, test, trigger.value, )):
1180                         phy = self._spec_tbs[rls][dut][dutver][area][test]\
1181                             [trigger.value]
1182                         ctrl_panel.set({
1183                             "dd-phy-val": trigger.value,
1184                             "cl-core-opt": generate_options(phy["core"]),
1185                             "cl-core-val": list(),
1186                             "cl-core-all-val": list(),
1187                             "cl-core-all-opt": C.CL_ALL_ENABLED,
1188                             "cl-frmsize-opt": \
1189                                 generate_options(phy["frame-size"]),
1190                             "cl-frmsize-val": list(),
1191                             "cl-frmsize-all-val": list(),
1192                             "cl-frmsize-all-opt": C.CL_ALL_ENABLED,
1193                             "cl-tsttype-opt": \
1194                                 generate_options(phy["test-type"]),
1195                             "cl-tsttype-val": list(),
1196                             "cl-tsttype-all-val": list(),
1197                             "cl-tsttype-all-opt": C.CL_ALL_ENABLED,
1198                             "btn-add-dis": True
1199                         })
1200             elif trigger.type == "ctrl-cl":
1201                 param = trigger.idx.split("-")[0]
1202                 if "-all" in trigger.idx:
1203                     c_sel, c_all, c_id = list(), trigger.value, "all"
1204                 else:
1205                     c_sel, c_all, c_id = trigger.value, list(), str()
1206                 val_sel, val_all = sync_checklists(
1207                     options=ctrl_panel.get(f"cl-{param}-opt"),
1208                     sel=c_sel,
1209                     all=c_all,
1210                     id=c_id
1211                 )
1212                 ctrl_panel.set({
1213                     f"cl-{param}-val": val_sel,
1214                     f"cl-{param}-all-val": val_all,
1215                 })
1216                 if all((ctrl_panel.get("cl-core-val"),
1217                         ctrl_panel.get("cl-frmsize-val"),
1218                         ctrl_panel.get("cl-tsttype-val"), )):
1219                     ctrl_panel.set({"btn-add-dis": False})
1220                 else:
1221                     ctrl_panel.set({"btn-add-dis": True})
1222             elif trigger.type == "ctrl-btn":
1223                 on_draw = True
1224                 if trigger.idx == "add-test":
1225                     rls = ctrl_panel.get("dd-rls-val")
1226                     dut = ctrl_panel.get("dd-dut-val")
1227                     dutver = ctrl_panel.get("dd-dutver-val")
1228                     phy = ctrl_panel.get("dd-phy-val")
1229                     area = ctrl_panel.get("dd-area-val")
1230                     test = ctrl_panel.get("dd-test-val")
1231                     # Add selected test to the list of tests in store:
1232                     if store_sel is None:
1233                         store_sel = list()
1234                     for core in ctrl_panel.get("cl-core-val"):
1235                         for framesize in ctrl_panel.get("cl-frmsize-val"):
1236                             for ttype in ctrl_panel.get("cl-tsttype-val"):
1237                                 if dut == "trex":
1238                                     core = str()
1239                                 tid = "-".join((
1240                                     rls,
1241                                     dut,
1242                                     dutver,
1243                                     phy.replace("af_xdp", "af-xdp"),
1244                                     area,
1245                                     framesize.lower(),
1246                                     core.lower(),
1247                                     test,
1248                                     ttype.lower()
1249                                 ))
1250                                 if tid not in [i["id"] for i in store_sel]:
1251                                     store_sel.append({
1252                                         "id": tid,
1253                                         "rls": rls,
1254                                         "dut": dut,
1255                                         "dutver": dutver,
1256                                         "phy": phy,
1257                                         "area": area,
1258                                         "test": test,
1259                                         "framesize": framesize.lower(),
1260                                         "core": core.lower(),
1261                                         "testtype": ttype.lower()
1262                                     })
1263                     store_sel = sorted(store_sel, key=lambda d: d["id"])
1264                     if C.CLEAR_ALL_INPUTS:
1265                         ctrl_panel.set(ctrl_panel.defaults)
1266                 elif trigger.idx == "rm-test" and lst_sel:
1267                     new_store_sel = list()
1268                     for idx, item in enumerate(store_sel):
1269                         if not lst_sel[idx]:
1270                             new_store_sel.append(item)
1271                     store_sel = new_store_sel
1272                 elif trigger.idx == "rm-test-all":
1273                     store_sel = list()
1274
1275             if on_draw:
1276                 if store_sel:
1277                     lg_selected = get_list_group_items(
1278                         store_sel, "sel-cl", add_index=True
1279                     )
1280                     plotting_area = self._get_plotting_area(
1281                         store_sel,
1282                         bool(normalize),
1283                         gen_new_url(
1284                             parsed_url,
1285                             {"store_sel": store_sel, "norm": normalize}
1286                         )
1287                     )
1288                     row_card_sel_tests = C.STYLE_ENABLED
1289                     row_btns_sel_tests = C.STYLE_ENABLED
1290                 else:
1291                     plotting_area = C.PLACEHOLDER
1292                     row_card_sel_tests = C.STYLE_DISABLED
1293                     row_btns_sel_tests = C.STYLE_DISABLED
1294                     store_sel = list()
1295
1296             ret_val = [
1297                 ctrl_panel.panel,
1298                 store_sel,
1299                 plotting_area,
1300                 row_card_sel_tests,
1301                 row_btns_sel_tests,
1302                 lg_selected
1303             ]
1304             ret_val.extend(ctrl_panel.values)
1305             return ret_val
1306
1307         @app.callback(
1308             Output("plot-mod-url", "is_open"),
1309             Output("plot-btn-url", "n_clicks"),
1310             Input("plot-btn-url", "n_clicks"),
1311             State("plot-mod-url", "is_open")
1312         )
1313         def toggle_plot_mod_url(n, is_open):
1314             """Toggle the modal window with url.
1315             """
1316             if n:
1317                 return not is_open, 0
1318             return is_open, 0
1319
1320         @app.callback(
1321             Output("download-iterative-data", "data"),
1322             State("store-selected-tests", "data"),
1323             Input("plot-btn-download", "n_clicks"),
1324             prevent_initial_call=True
1325         )
1326         def _download_iterative_data(store_sel, _):
1327             """Download the data
1328
1329             :param store_sel: List of tests selected by user stored in the
1330                 browser.
1331             :type store_sel: list
1332             :returns: dict of data frame content (base64 encoded) and meta data
1333                 used by the Download component.
1334             :rtype: dict
1335             """
1336
1337             if not store_sel:
1338                 raise PreventUpdate
1339
1340             df = pd.DataFrame()
1341             for itm in store_sel:
1342                 sel_data = select_iterative_data(self._data, itm)
1343                 if sel_data is None:
1344                     continue
1345                 df = pd.concat([df, sel_data], ignore_index=True)
1346
1347             return dcc.send_data_frame(df.to_csv, C.REPORT_DOWNLOAD_FILE_NAME)
1348
1349         @app.callback(
1350             Output("metadata-tput-lat", "children"),
1351             Output("metadata-hdrh-graph", "children"),
1352             Output("offcanvas-metadata", "is_open"),
1353             Input({"type": "graph", "index": ALL}, "clickData"),
1354             prevent_initial_call=True
1355         )
1356         def _show_metadata_from_graphs(graph_data: dict) -> tuple:
1357             """Generates the data for the offcanvas displayed when a particular
1358             point in a graph is clicked on.
1359
1360             :param graph_data: The data from the clicked point in the graph.
1361             :type graph_data: dict
1362             :returns: The data to be displayed on the offcanvas and the
1363                 information to show the offcanvas.
1364             :rtype: tuple(list, list, bool)
1365             """
1366
1367             trigger = Trigger(callback_context.triggered)
1368
1369             if trigger.idx == "tput":
1370                 idx = 0
1371             elif trigger.idx == "bandwidth":
1372                 idx = 1
1373             elif trigger.idx == "lat":
1374                 idx = len(graph_data) - 1
1375             else:
1376                 return list(), list(), False
1377
1378             try:
1379                 graph_data = graph_data[idx]["points"]
1380             except (IndexError, KeyError, ValueError, TypeError):
1381                 raise PreventUpdate
1382
1383             def _process_stats(data: list, param: str) -> list:
1384                 """Process statistical data provided by plot.ly box graph.
1385
1386                 :param data: Statistical data provided by plot.ly box graph.
1387                 :param param: Parameter saying if the data come from "tput" or
1388                     "lat" graph.
1389                 :type data: list
1390                 :type param: str
1391                 :returns: Listo of tuples where the first value is the
1392                     statistic's name and the secont one it's value.
1393                 :rtype: list
1394                 """
1395                 if len(data) == 7:
1396                     stats = ("max", "upper fence", "q3", "median", "q1",
1397                             "lower fence", "min")
1398                 elif len(data) == 9:
1399                     stats = ("outlier", "max", "upper fence", "q3", "median",
1400                             "q1", "lower fence", "min", "outlier")
1401                 elif len(data) == 1:
1402                     if param == "lat":
1403                         stats = ("average latency at 50% PDR", )
1404                     elif param == "bandwidth":
1405                         stats = ("bandwidth", )
1406                     else:
1407                         stats = ("throughput", )
1408                 else:
1409                     return list()
1410                 unit = " [us]" if param == "lat" else str()
1411                 return [(f"{stat}{unit}", f"{value['y']:,.0f}")
1412                         for stat, value in zip(stats, data)]
1413
1414             customdata = graph_data[0].get("customdata", dict())
1415             datapoint = customdata.get("metadata", dict())
1416             hdrh_data = customdata.get("hdrh", dict())
1417
1418             list_group_items = list()
1419             for k, v in datapoint.items():
1420                 if k == "csit-ref":
1421                     if len(graph_data) > 1:
1422                         continue
1423                     list_group_item = dbc.ListGroupItem([
1424                         dbc.Badge(k),
1425                         html.A(v, href=f"{C.URL_JENKINS}{v}", target="_blank")
1426                     ])
1427                 else:
1428                     list_group_item = dbc.ListGroupItem([dbc.Badge(k), v])
1429                 list_group_items.append(list_group_item)
1430
1431             graph = list()
1432             if trigger.idx == "tput":
1433                 title = "Throughput"
1434             elif trigger.idx == "bandwidth":
1435                 title = "Bandwidth"
1436             elif trigger.idx == "lat":
1437                 title = "Latency"
1438                 if len(graph_data) == 1:
1439                     if hdrh_data:
1440                         graph = [dbc.Card(
1441                             class_name="gy-2 p-0",
1442                             children=[
1443                                 dbc.CardHeader(hdrh_data.pop("name")),
1444                                 dbc.CardBody(dcc.Graph(
1445                                     id="hdrh-latency-graph",
1446                                     figure=graph_hdrh_latency(
1447                                         hdrh_data, self._graph_layout
1448                                     )
1449                                 ))
1450                             ])
1451                         ]
1452             else:
1453                 raise PreventUpdate
1454
1455             for k, v in _process_stats(graph_data, trigger.idx):
1456                 list_group_items.append(dbc.ListGroupItem([dbc.Badge(k), v]))
1457
1458             metadata = [
1459                 dbc.Card(
1460                     class_name="gy-2 p-0",
1461                     children=[
1462                         dbc.CardHeader(children=[
1463                             dcc.Clipboard(
1464                                 target_id="tput-lat-metadata",
1465                                 title="Copy",
1466                                 style={"display": "inline-block"}
1467                             ),
1468                             title
1469                         ]),
1470                         dbc.CardBody(
1471                             dbc.ListGroup(list_group_items, flush=True),
1472                             id="tput-lat-metadata",
1473                             class_name="p-0"
1474                         )
1475                     ]
1476                 )
1477             ]
1478
1479             return metadata, graph, True
1480
1481         @app.callback(
1482             Output("offcanvas-documentation", "is_open"),
1483             Input("btn-documentation", "n_clicks"),
1484             State("offcanvas-documentation", "is_open")
1485         )
1486         def toggle_offcanvas_documentation(n_clicks, is_open):
1487             if n_clicks:
1488                 return not is_open
1489             return is_open