aboutsummaryrefslogtreecommitdiffstats
path: root/csit.infra.dash/app/cdash/comparisons/layout.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2024-03-11 12:00:34 +0000
committerTibor Frank <tifrank@cisco.com>2024-03-11 12:03:32 +0000
commit0ca1dcc08772c39ea98fb304ce06ab794b65166c (patch)
tree7781d481c13e0e24886f3d6d4c25ba7993af4979 /csit.infra.dash/app/cdash/comparisons/layout.py
parent18aa02486b8ca1e6143c1c492d079184ee63ee2b (diff)
C-Dash: add "download row data" feature to comparison tables
Change-Id: Iaf5a57402e954453c237fb1e082da6c620cff59f Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'csit.infra.dash/app/cdash/comparisons/layout.py')
-rw-r--r--csit.infra.dash/app/cdash/comparisons/layout.py47
1 files changed, 45 insertions, 2 deletions
diff --git a/csit.infra.dash/app/cdash/comparisons/layout.py b/csit.infra.dash/app/cdash/comparisons/layout.py
index 82b5b2d544..9c89a55bcb 100644
--- a/csit.infra.dash/app/cdash/comparisons/layout.py
+++ b/csit.infra.dash/app/cdash/comparisons/layout.py
@@ -616,7 +616,7 @@ class Layout:
),
dbc.Button(
id="plot-btn-download",
- children="Download Data",
+ children="Download Table",
class_name="me-1",
color="info",
style={
@@ -624,7 +624,18 @@ class Layout:
"padding": "0rem 1rem"
}
),
- dcc.Download(id="download-iterative-data")
+ dcc.Download(id="download-iterative-data"),
+ dbc.Button(
+ id="plot-btn-download-raw",
+ children="Download Raw Data",
+ class_name="me-1",
+ color="info",
+ style={
+ "text-transform": "none",
+ "padding": "0rem 1rem"
+ }
+ ),
+ dcc.Download(id="download-raw-data")
],
className=\
"d-grid gap-0 d-md-flex justify-content-md-end"
@@ -1047,6 +1058,38 @@ class Layout:
return dcc.send_data_frame(table.to_csv, C.COMP_DOWNLOAD_FILE_NAME)
@app.callback(
+ Output("download-raw-data", "data"),
+ State("store-selected", "data"),
+ Input("plot-btn-download-raw", "n_clicks"),
+ prevent_initial_call=True
+ )
+ def _download_raw_comparison_data(selected: dict, _: int) -> dict:
+ """Download the data.
+
+ :param selected: Selected tests.
+ :type selected: dict
+ :returns: dict of data frame content (base64 encoded) and meta data
+ used by the Download component.
+ :rtype: dict
+ """
+
+ if not selected:
+ raise PreventUpdate
+
+ _, table = comparison_table(
+ data=self._data,
+ selected=selected,
+ normalize=False,
+ remove_outliers=False,
+ raw_data=True
+ )
+
+ return dcc.send_data_frame(
+ table.dropna(how="all", axis=1).to_csv,
+ f"raw_{C.COMP_DOWNLOAD_FILE_NAME}"
+ )
+
+ @app.callback(
Output("offcanvas-documentation", "is_open"),
Input("btn-documentation", "n_clicks"),
State("offcanvas-documentation", "is_open")