Skip to content
Snippets Groups Projects
Commit e51817f4 authored by Imre Toth's avatar Imre Toth
Browse files

CE-2099: Convert useActiveHistory hook

parent c5351099
No related branches found
No related tags found
2 merge requests!407CE-2141: 3.0.0,!374CE-2099: Convert useActiveHistory hook
Pipeline #161225 passed
......@@ -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 };
}
......
......@@ -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(() => {
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment