From 25e8a3e84efed0cf3e6506cacddd9d7acfc09845 Mon Sep 17 00:00:00 2001 From: Imre Toth <imre.toth@ess.eu> Date: Fri, 22 Sep 2023 09:27:00 +0000 Subject: [PATCH] CE-2131: Statistics improvement --- .../statistics/ActiveIOCChart/ActiveIOCChart.js | 6 ++---- .../DeploymentLineChart/DeploymentLineChart.js | 6 ++---- .../statistics/HostStatistics/HostStatistics.js | 16 ++-------------- .../statistics/IOCStatistics/IOCStatistics.js | 16 ++-------------- .../statistics/OperationChart/OperationChart.js | 6 ++---- src/views/statistics/StatisticsView.js | 9 +-------- 6 files changed, 11 insertions(+), 48 deletions(-) diff --git a/src/components/statistics/ActiveIOCChart/ActiveIOCChart.js b/src/components/statistics/ActiveIOCChart/ActiveIOCChart.js index e63be41a..4536c358 100644 --- a/src/components/statistics/ActiveIOCChart/ActiveIOCChart.js +++ b/src/components/statistics/ActiveIOCChart/ActiveIOCChart.js @@ -1,7 +1,7 @@ import React from "react"; import { useCurrentlyActiveIOCs } from "../../../api/SwaggerApi"; import { useEffect } from "react"; -import { LinearProgress, useTheme } from "@mui/material"; +import { LinearProgress, useTheme, Typography } from "@mui/material"; import { circularPalette } from "../../common/Helper"; import { BarChart, @@ -60,9 +60,7 @@ export default function ActiveIOCChart({ title }) { return activeIocs ? ( <> - <div style={{ textAlign: "center" }}> - <h3>{title}</h3> - </div> + <Typography variant="h2">{title}</Typography> <ResponsiveContainer width="100%" aspect={2} diff --git a/src/components/statistics/DeploymentLineChart/DeploymentLineChart.js b/src/components/statistics/DeploymentLineChart/DeploymentLineChart.js index 3f6cb2b2..912af09d 100644 --- a/src/components/statistics/DeploymentLineChart/DeploymentLineChart.js +++ b/src/components/statistics/DeploymentLineChart/DeploymentLineChart.js @@ -2,7 +2,7 @@ import React from "react"; import { useEffect } from "react"; import { formatDateOnly } from "../../common/Helper"; import { circularPalette } from "../../common/Helper"; -import { LinearProgress, useTheme } from "@mui/material"; +import { LinearProgress, useTheme, Typography } from "@mui/material"; import { AreaChart, Area, @@ -25,9 +25,7 @@ export default function DeploymentLineChart({ title, chartLabel, hook }) { return iocDeployments ? ( <> - <div style={{ textAlign: "center" }}> - <h3>{title}</h3> - </div> + <Typography variant="h2">{title}</Typography> <ResponsiveContainer width="100%" aspect={3} diff --git a/src/components/statistics/HostStatistics/HostStatistics.js b/src/components/statistics/HostStatistics/HostStatistics.js index 06adc1c7..cec4d29a 100644 --- a/src/components/statistics/HostStatistics/HostStatistics.js +++ b/src/components/statistics/HostStatistics/HostStatistics.js @@ -24,29 +24,17 @@ export function HostStatistics() { fcn: client.apis.Statistics.calculateStatistics, call: false }); - const { value: hostsWithoutIssues, wrapper: getHostsWithoutIssues } = - useAPIMethod({ - fcn: client.apis.Statistics.calculateStatistics, - call: false - }); useEffect(() => { getHostsRegistered({ statistics_type: "HOSTS_REGISTERED" }); getHostsWithIocs({ statistics_type: "HOSTS_WITH_IOCS" }); getHostsReachable({ statistics_type: "HOSTS_REACHABLE" }); - getHostsWithoutIssues({ statistics_type: "HOSTS_WITHOUT_ISSUE" }); - }, [ - getHostsRegistered, - getHostsWithIocs, - getHostsReachable, - getHostsWithoutIssues - ]); + }, [getHostsRegistered, getHostsWithIocs, getHostsReachable]); const hostStats = { "Registered IOC-hosts": renderValue(hostsRegistered?.value), "IOC-hosts with IOCs": renderValue(hostsWithIocs?.value), - "Reachable IOC-hosts with IOCs": renderValue(hostsReachable?.value), - "Issue free IOC-hosts with IOCs": renderValue(hostsWithoutIssues?.value) + "Reachable IOC-hosts with IOCs": renderValue(hostsReachable?.value) }; return ( diff --git a/src/components/statistics/IOCStatistics/IOCStatistics.js b/src/components/statistics/IOCStatistics/IOCStatistics.js index 07466117..aefcfd45 100644 --- a/src/components/statistics/IOCStatistics/IOCStatistics.js +++ b/src/components/statistics/IOCStatistics/IOCStatistics.js @@ -25,29 +25,17 @@ export function IOCStatistics() { fcn: client.apis.Statistics.calculateStatistics, call: false }); - const { value: iocsWithoutIssues, wrapper: getIocsWithoutIssues } = - useAPIMethod({ - fcn: client.apis.Statistics.calculateStatistics, - call: false - }); useEffect(() => { getIocsRegistered({ statistics_type: "IOCS_REGISTERED" }); getIocsDeployed({ statistics_type: "IOCS_DEPLOYED" }); getIocsReachable({ statistics_type: "IOCS_RUNNING" }); - getIocsWithoutIssues({ statistics_type: "IOCS_RUNNING_WITHOUT_ISSUE" }); - }, [ - getIocsDeployed, - getIocsReachable, - getIocsRegistered, - getIocsWithoutIssues - ]); + }, [getIocsDeployed, getIocsReachable, getIocsRegistered]); const iocStats = { "Registered IOCs": renderValue(iocsRegistered?.value), "Deployed IOCs": renderValue(iocsDeployed?.value), - "Running IOCs": renderValue(iocsReachable?.value), - "Issue-free and running IOCs": renderValue(iocsWithoutIssues?.value) + "Running IOCs": renderValue(iocsReachable?.value) }; return ( diff --git a/src/components/statistics/OperationChart/OperationChart.js b/src/components/statistics/OperationChart/OperationChart.js index f7faf934..3c7d2dc7 100644 --- a/src/components/statistics/OperationChart/OperationChart.js +++ b/src/components/statistics/OperationChart/OperationChart.js @@ -2,7 +2,7 @@ import React from "react"; import { useEffect } from "react"; import { formatDateOnly } from "../../common/Helper"; import { circularPalette } from "../../common/Helper"; -import { LinearProgress, useTheme } from "@mui/material"; +import { LinearProgress, useTheme, Typography } from "@mui/material"; import { AreaChart, Area, @@ -24,9 +24,7 @@ export default function OperationChart({ title, hook }) { return iocDeployments ? ( <> - <div style={{ textAlign: "center" }}> - <h3>{title}</h3> - </div> + <Typography variant="h2">{title}</Typography> <ResponsiveContainer width="100%" aspect={3} diff --git a/src/views/statistics/StatisticsView.js b/src/views/statistics/StatisticsView.js index 99bf22c4..00043bb0 100644 --- a/src/views/statistics/StatisticsView.js +++ b/src/views/statistics/StatisticsView.js @@ -1,6 +1,6 @@ import React, { useContext, useEffect } from "react"; import { styled } from "@mui/material/styles"; -import { Paper, Grid, useTheme, Typography } from "@mui/material"; +import { Paper, Grid, useTheme } from "@mui/material"; import { GlobalAppBarContext } from "@ess-ics/ce-ui-common"; import { RootContainer } from "../../components/common/Container/RootContainer"; import ActiveIOCChart from "../../components/statistics/ActiveIOCChart"; @@ -38,13 +38,6 @@ export function StatisticsView() { container spacing={theme.spacing(0.5)} > - <Grid - item - xs={12} - > - <Typography variant="h2">Statistics</Typography> - </Grid> - <Grid item xs={6} -- GitLab