From 16e610ee8fd5642ba8e747390d38aabe6975f956 Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Wed, 9 Mar 2022 10:16:54 +0100 Subject: [PATCH] Add a tooltip for unix times (ISO strings) (#10376) * Add a tooltip for unix times (ISO strings) Signed-off-by: Ondrej Kokes * Leverage useLocalTime to adjust ISO string tooltips Signed-off-by: Ondrej Kokes * revert pre styling removal Signed-off-by: Ondrej Kokes --- .../react-app/src/pages/graph/DataTable.tsx | 21 ++++++++++++------- web/ui/react-app/src/pages/graph/Panel.tsx | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/web/ui/react-app/src/pages/graph/DataTable.tsx b/web/ui/react-app/src/pages/graph/DataTable.tsx index d82d88cf9..4e0f4e61d 100644 --- a/web/ui/react-app/src/pages/graph/DataTable.tsx +++ b/web/ui/react-app/src/pages/graph/DataTable.tsx @@ -5,6 +5,8 @@ import { Alert, Table } from 'reactstrap'; import SeriesName from './SeriesName'; import { Metric } from '../../types/types'; +import moment from 'moment'; + export interface QueryResult { data: | null @@ -24,6 +26,7 @@ export interface QueryResult { resultType: 'string'; result: string; }; + useLocalTime: boolean; } interface InstantSample { @@ -47,7 +50,7 @@ const limitSeries = (series: S[]): S[] = return series; }; -const DataTable: FC = ({ data }) => { +const DataTable: FC = ({ data, useLocalTime }) => { if (data === null) { return No data queried yet; } @@ -76,17 +79,21 @@ const DataTable: FC = ({ data }) => { break; case 'matrix': rows = (limitSeries(data.result) as RangeSamples[]).map((s, index) => { - const valueText = s.values - .map((v) => { - return v[1] + ' @' + v[0]; - }) - .join('\n'); + const valuesAndTimes = s.values.map((v) => { + const printedDatetime = moment.unix(v[0]).toISOString(useLocalTime); + return ( + + {v[1]} @{{v[0]}} +
+
+ ); + }); return ( - {valueText} + {valuesAndTimes} ); }); diff --git a/web/ui/react-app/src/pages/graph/Panel.tsx b/web/ui/react-app/src/pages/graph/Panel.tsx index 1cb0c1fde..244a7606e 100644 --- a/web/ui/react-app/src/pages/graph/Panel.tsx +++ b/web/ui/react-app/src/pages/graph/Panel.tsx @@ -325,7 +325,7 @@ class Panel extends Component { onChangeTime={this.handleChangeEndTime} /> - + )}