diff --git a/src/api/SwaggerApi.js b/src/api/SwaggerApi.js index 118f158d7528555376329529d8b3a254c98e9850..e9f1f938c5496065c87a98cdc376012f192631da 100644 --- a/src/api/SwaggerApi.js +++ b/src/api/SwaggerApi.js @@ -374,20 +374,6 @@ export function useTagsAndCommitIds(onError) { return useAsync({ fcn: method, call: false, onError: onError, init: [] }); } -export function unpackActiveIOCHistory(statistics) { - return { ...statistics }; -} - -export function useActiveIOCHistory() { - const api = useContext(apiContext); - const method = useCallAndUnpack( - api.apis.Statistics.activeIocHistory, - unpackActiveIOCHistory - ); - - return useAsync({ fcn: method, call: false }); -} - export function unpackParam(param) { return { ...param }; } diff --git a/src/components/statistics/DeploymentLineChart/DeploymentLineChart.js b/src/components/statistics/DeploymentLineChart/DeploymentLineChart.js index 912af09df10751491a764d2a8152db935e904b6d..2b12c5038ae389ad1e4ae8bac64087df1b5be0af 100644 --- a/src/components/statistics/DeploymentLineChart/DeploymentLineChart.js +++ b/src/components/statistics/DeploymentLineChart/DeploymentLineChart.js @@ -13,8 +13,12 @@ import { Tooltip } from "recharts"; -export default function DeploymentLineChart({ title, chartLabel, hook }) { - const [iocDeployments, getIOCDeployments] = hook(); +export default function DeploymentLineChart({ + title, + chartLabel, + iocDeployments, + getIOCDeployments +}) { const theme = useTheme(); useEffect(() => { diff --git a/src/views/statistics/StatisticsView.js b/src/views/statistics/StatisticsView.js index 00043bb0fd4beedc25fd627dd5aaf991c9969e57..22b9ab73ab36d038da69a8cdba74e49d7dcea8a3 100644 --- a/src/views/statistics/StatisticsView.js +++ b/src/views/statistics/StatisticsView.js @@ -5,14 +5,13 @@ import { GlobalAppBarContext } from "@ess-ics/ce-ui-common"; import { RootContainer } from "../../components/common/Container/RootContainer"; import ActiveIOCChart from "../../components/statistics/ActiveIOCChart"; import DeploymentLineChart from "../../components/statistics/DeploymentLineChart"; -import { - useActiveIOCHistory, - useDeploymenStatistics -} from "../../api/SwaggerApi"; +import { useDeploymenStatistics } from "../../api/SwaggerApi"; import { HostStatistics } from "../../components/statistics/HostStatistics"; import { IOCStatistics } from "../../components/statistics/IOCStatistics"; import OperationChart from "../../components/statistics/OperationChart/OperationChart"; import { applicationTitle } from "../../components/common/Helper"; +import { apiContext } from "../../api/DeployApi"; +import { useAPIMethod } from "@ess-ics/ce-ui-common"; const PREFIX = "StatisticsView"; @@ -29,9 +28,15 @@ const StyledRootContainer = styled(RootContainer)(({ theme }) => ({ export function StatisticsView() { const { setTitle } = useContext(GlobalAppBarContext); useEffect(() => setTitle(applicationTitle("Statistics")), [setTitle]); + const client = useContext(apiContext); const theme = useTheme(); + const { value: iocsOverTime, wrapper: getIocsOverTime } = useAPIMethod({ + fcn: client.apis.Statistics.activeIocHistory, + call: false + }); + return ( <StyledRootContainer> <Grid @@ -79,7 +84,8 @@ export function StatisticsView() { <DeploymentLineChart title="Number of IOCs detected over time" chartLabel="Active IOCs over time" - hook={useActiveIOCHistory} + iocDeployments={iocsOverTime} + getIOCDeployments={getIocsOverTime} /> </Paper> </Grid>