Skip to content

Commit

Permalink
feat(ui-tasks): auto refresh launcher metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
skamril committed Mar 4, 2024
1 parent ac9ba03 commit 4467940
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions webapp/src/components/App/Tasks/JobTableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import usePromiseWithSnackbarError from "../../../hooks/usePromiseWithSnackbarEr
import { getLauncherMetrics } from "../../../services/api/study";
import LinearProgressWithLabel from "../../common/LinearProgressWithLabel";
import UsePromiseCond from "../../common/utils/UsePromiseCond";
import { useInterval } from "react-use";

interface PropType {
content: TaskView[];
Expand All @@ -46,13 +47,10 @@ function JobTableView(props: PropType) {
useState<boolean>(false);
const [currentContent, setCurrentContent] = useState<TaskView[]>(content);

const laucherMetrics = usePromiseWithSnackbarError(
() => getLauncherMetrics(),
{
errorMessage: t("study.error.launchLoad"),
deps: [],
},
);
const launcherMetrics = usePromiseWithSnackbarError(getLauncherMetrics, {
errorMessage: t("study.error.launchLoad"),
deps: [],
});

const applyFilter = useCallback(
(taskList: TaskView[]) => {
Expand Down Expand Up @@ -91,6 +89,8 @@ function JobTableView(props: PropType) {
setCurrentContent(applyFilter(content));
}, [content, applyFilter]);

useInterval(launcherMetrics.reload, 5000);

return (
<Box
sx={{
Expand Down Expand Up @@ -121,7 +121,8 @@ function JobTableView(props: PropType) {
}}
>
<UsePromiseCond
response={laucherMetrics}
response={launcherMetrics}
keepLastResolvedOnReload
ifResolved={(data) => (
<>
<Typography>{t("study.allocatedCpuRate")}</Typography>
Expand Down Expand Up @@ -152,7 +153,6 @@ function JobTableView(props: PropType) {
color="primary"
onClick={() => {
refresh();
laucherMetrics.reload();
}}
variant="outlined"
>
Expand Down

0 comments on commit 4467940

Please sign in to comment.