From 72869399c58c4615305b964edf331c337a1e738c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Vila=C3=A7a?= Date: Wed, 18 Oct 2023 13:32:14 +0100 Subject: [PATCH] Update dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Vilaça --- frontend/src/app/Dashboard/Dashboard.tsx | 99 ++++++++++++++++-------- 1 file changed, 67 insertions(+), 32 deletions(-) diff --git a/frontend/src/app/Dashboard/Dashboard.tsx b/frontend/src/app/Dashboard/Dashboard.tsx index d34e39f5..989f75c2 100644 --- a/frontend/src/app/Dashboard/Dashboard.tsx +++ b/frontend/src/app/Dashboard/Dashboard.tsx @@ -23,11 +23,11 @@ import { PageSection, Title, CodeBlock, - CodeBlockCode, SimpleList, SimpleListGroup, SimpleListItem, + CodeBlockCode, SimpleList, SimpleListGroup, SimpleListItem, Alert, ExpandableSection, } from "@patternfly/react-core"; import {apiBaseUrl} from "@app/config"; import {CheckCircleIcon, ExclamationCircleIcon, ExclamationTriangleIcon} from "@patternfly/react-icons"; -import {Table, TableHeader, TableBody, TableProps, TableVariant} from '@patternfly/react-table'; +import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table'; type data = { meta: { @@ -419,26 +419,28 @@ const Dashboard: React.FunctionComponent = () => { name: 'File name', importTime: 'Import date', gatherTime: 'Gather date', + insightsData: 'Insights data', }; - const columns: TableProps['cells'] = ['File name', 'Gather date', 'Import date']; + const insightsIcons = (data) => { + const nReports = JSON.parse(data)["reports"].length - let rows: TableProps['rows'] = [ - ['Loading...', 'Loading...', 'Loading...'], - ]; - - if (importedMustGathers !== undefined) { - if (importedMustGathers.data.length === 0) { - rows = [ - ['No must-gathers imported', '', ''], - ]; + if (nReports === 0) { + return ( + + + + ) } - rows = importedMustGathers.data.map((mustGather) => [ - setMustGatherInsightData(mustGather.insightsData)}>{mustGather.name}, - setMustGatherInsightData(mustGather.insightsData)}>{new Date(mustGather.gatherTime).toLocaleString()}, - setMustGatherInsightData(mustGather.insightsData)}>{new Date(mustGather.importTime).toLocaleString()}, - ]); + return ( + <> + {nReports} + + + + + ) } return ( @@ -451,13 +453,35 @@ const Dashboard: React.FunctionComponent = () => { ) : ( - - - +
+ + + + + + + + + + {importedMustGathers.data.map((mustGather) => ( + setMustGatherInsightData(mustGather.insightsData)} + isSelectable + isHoverable={mustGather.insightsData !== undefined && mustGather.insightsData !== null} + > + + + + + + ))} +
{columnNames.name}{columnNames.gatherTime}{columnNames.importTime}{columnNames.insightsData}
{mustGather.name}{new Date(mustGather.gatherTime).toLocaleString()}{new Date(mustGather.importTime).toLocaleString()}{ + mustGather.insightsData === undefined || mustGather.insightsData === null ? + - + : + insightsIcons(mustGather.insightsData) + }
) } @@ -468,19 +492,24 @@ const Dashboard: React.FunctionComponent = () => { const reportTable = (report) => { return ( -
- {report["key"]} ({report["type"]} - {report["component"]}) - + + } + > - {JSON.stringify(report, null, 2)} + {JSON.stringify(report["details"], null, 2)} -
+ ) } const mustGatherInsightsDataModalContent = (data) => { const metadata = data["analysis_metadata"] const plugins = metadata["plugin_sets"] + const reports = data["reports"] return ( <> @@ -497,7 +526,11 @@ const Dashboard: React.FunctionComponent = () => { - {data["reports"].map((report) => reportTable(report))} + {reports.length === 0 ? + + : + reports.map((report) => reportTable(report)) + } ) } @@ -540,9 +573,12 @@ const Dashboard: React.FunctionComponent = () => { {mustGatherInsightsDataModal()} + {/* line 0 */} + {importedMustGathersCard()} + {/* line 1 */} {clusterInventoryCard()} - {importedMustGathersCard()} + {nodesStatusCard()} {/* line 2 */} {subscriptionsCard()} @@ -550,7 +586,6 @@ const Dashboard: React.FunctionComponent = () => { {/* line 3 */} {podsCard()} - {nodesStatusCard()}