Skip to content
Snippets Groups Projects

CE-3061: Update ioc alerts and status separately

Merged Johanna Szepanski requested to merge CE-3061-update-IOC-alerts-async into develop
1 file
+ 28
7
Compare changes
  • Side-by-side
  • Inline
import { useContext, useMemo } from "react";
import { useContext, useMemo, useEffect } from "react";
import { Grid, Skeleton } from "@mui/material";
import { Grid, Skeleton } from "@mui/material";
import { IOCStatusIcon } from "../IOCIcons";
import { Status } from "../../common/Status";
import { apiContext } from "../../../api/DeployApi";
import { apiContext } from "../../../api/DeployApi";
import { useAPIMethod } from "@ess-ics/ce-ui-common";
import { useAPIMethod } from "@ess-ics/ce-ui-common";
@@ -16,14 +16,32 @@ export const IOCStatus = ({ id }) => {
@@ -16,14 +16,32 @@ export const IOCStatus = ({ id }) => {
const params = useMemo(() => createRequest(id), [id]);
const params = useMemo(() => createRequest(id), [id]);
const {
const {
value: ioc,
wrapper: callFetchIocAlerts,
loading,
value: iocAlert,
dataReady
abort: abortCallFetchIocAlerts
 
} = useAPIMethod({
 
fcn: client.apis.IOCs.fetchIocAlerts,
 
params,
 
call: false
 
});
 
 
const {
 
value: iocStateStatus,
 
loading: fetchIocStatusLoading,
 
dataReady: iocStatusReady
} = useAPIMethod({
} = useAPIMethod({
fcn: client.apis.IOCs.fetchIocStatus,
fcn: client.apis.IOCs.fetchIocStatus,
params
params
});
});
 
useEffect(() => {
 
callFetchIocAlerts();
 
 
return () => {
 
abortCallFetchIocAlerts();
 
};
 
}, [iocStateStatus]);
 
return (
return (
<Grid
<Grid
container
container
@@ -31,14 +49,17 @@ export const IOCStatus = ({ id }) => {
@@ -31,14 +49,17 @@ export const IOCStatus = ({ id }) => {
justifyContent="center"
justifyContent="center"
alignItems="center"
alignItems="center"
>
>
{loading || !dataReady ? (
{fetchIocStatusLoading || !iocStatusReady ? (
<Skeleton
<Skeleton
variant="circular"
variant="circular"
height={20}
height={20}
width={20}
width={20}
/>
/>
) : (
) : (
<IOCStatusIcon ioc={ioc} />
<Status
 
state={iocStateStatus}
 
alert={iocAlert}
 
/>
)}
)}
</Grid>
</Grid>
);
);
Loading