C-Dash: Add hyperlinks to job/builds
[csit.git] / csit.infra.dash / app / cdash / trending / layout.py
index 74c39eb..84a68f5 100644 (file)
@@ -274,6 +274,18 @@ class Layout:
                             ]
                         ),
                         delay_show=C.SPINNER_DELAY
+                    ),
+                    dbc.Offcanvas(
+                        class_name="w-75",
+                        id="offcanvas-documentation",
+                        title="Documentation",
+                        placement="end",
+                        is_open=False,
+                        children=html.Iframe(
+                            src=C.URL_DOC_TRENDING,
+                            width="100%",
+                            height="100%"
+                        )
                     )
                 ]
             )
@@ -290,14 +302,28 @@ class Layout:
         :rtype: dbc.NavbarSimple
         """
         return dbc.NavbarSimple(
-            dbc.NavItem(
-                dbc.NavLink(
+            children=[
+                dbc.NavItem(dbc.NavLink(
                     C.TREND_TITLE,
-                    disabled=True,
+                    active=True,
                     external_link=True,
-                    href="#"
-                )
-            ),
+                    href="/trending"
+                )),
+                dbc.NavItem(dbc.NavLink(
+                    C.NEWS_TITLE,
+                    external_link=True,
+                    href="/news"
+                )),
+                dbc.NavItem(dbc.NavLink(
+                    C.STATS_TITLE,
+                    external_link=True,
+                    href="/stats"
+                )),
+                dbc.NavItem(dbc.NavLink(
+                    "Documentation",
+                    id="btn-documentation",
+                ))
+            ],
             id="navbarsimple-main",
             brand=C.BRAND,
             brand_href="/",
@@ -575,13 +601,10 @@ class Layout:
         return dbc.Col(
             id="col-plotting-area",
             children=[
-                dbc.Spinner(
-                    dbc.Row(
-                        id="plotting-area-trending",
-                        class_name="g-0 p-0",
-                        children=C.PLACEHOLDER
-                    ),
-                    delay_show=C.SPINNER_DELAY
+                dbc.Row(
+                    id="plotting-area-trending",
+                    class_name="g-0 p-0",
+                    children=C.PLACEHOLDER
                 ),
                 dbc.Row(
                     id="plotting-area-telemetry",
@@ -1455,6 +1478,10 @@ class Layout:
                     if not end_idx:
                         plotting_area_telemetry = C.PLACEHOLDER
                     elif on_draw[1] and (end_idx >= start_idx):
+                        if len(tm_all_in_one) != end_idx:
+                            tm_all_in_one = [[None], ] * end_idx
+                        if len(tm_ignore_host) != end_idx:
+                            tm_ignore_host = [[None], ] * end_idx
                         for idx in range(start_idx, end_idx):
                             store["telemetry-graphs"].append(graph_tm_trending(
                                 tm.select_tm_trending_data(
@@ -1671,11 +1698,27 @@ class Layout:
             metadata = no_update
             graph = list()
 
-            children = [
-                dbc.ListGroupItem(
-                    [dbc.Badge(x.split(":")[0]), x.split(": ")[1]]
-                ) for x in graph_data.get("text", "").split("<br>")
-            ]
+            list_group_items = list()
+            for itm in graph_data.get("text", None).split("<br>"):
+                if not itm:
+                    continue
+                lst_itm = itm.split(": ")
+                if lst_itm[0] == "csit-ref":
+                    list_group_item = dbc.ListGroupItem([
+                        dbc.Badge(lst_itm[0]),
+                        html.A(
+                            lst_itm[1],
+                            href=f"{C.URL_JENKINS}{lst_itm[1]}",
+                            target="_blank"
+                        )
+                    ])
+                else:
+                    list_group_item = dbc.ListGroupItem([
+                        dbc.Badge(lst_itm[0]),
+                        lst_itm[1]
+                    ])
+                list_group_items.append(list_group_item)
+
             if trigger.idx == "tput":
                 title = "Throughput"
             elif trigger.idx == "lat":
@@ -1686,14 +1729,14 @@ class Layout:
                         class_name="gy-2 p-0",
                         children=[
                             dbc.CardHeader(hdrh_data.pop("name")),
-                            dbc.CardBody(children=[
+                            dbc.CardBody(
                                 dcc.Graph(
                                     id="hdrh-latency-graph",
                                     figure=graph_hdrh_latency(
                                         hdrh_data, self._graph_layout
                                     )
                                 )
-                            ])
+                            )
                         ])
                     ]
             else:
@@ -1712,9 +1755,9 @@ class Layout:
                             title
                         ]),
                         dbc.CardBody(
+                            dbc.ListGroup(list_group_items, flush=True),
                             id="tput-lat-metadata",
                             class_name="p-0",
-                            children=[dbc.ListGroup(children, flush=True), ]
                         )
                     ]
                 )
@@ -1771,3 +1814,13 @@ class Layout:
                 raise PreventUpdate
 
             return dcc.send_data_frame(df.to_csv, file_name)
+
+        @app.callback(
+            Output("offcanvas-documentation", "is_open"),
+            Input("btn-documentation", "n_clicks"),
+            State("offcanvas-documentation", "is_open")
+        )
+        def toggle_offcanvas_documentation(n_clicks, is_open):
+            if n_clicks:
+                return not is_open
+            return is_open