diff --git a/src/frontend/src/hooks/UseInstance.tsx b/src/frontend/src/hooks/UseInstance.tsx index d160269d14..54702b1f3b 100644 --- a/src/frontend/src/hooks/UseInstance.tsx +++ b/src/frontend/src/hooks/UseInstance.tsx @@ -23,7 +23,8 @@ export function useInstance({ hasPrimaryKey = true, refetchOnMount = true, refetchOnWindowFocus = false, - throwError = false + throwError = false, + updateInterval }: { endpoint: ApiEndpoints; pk?: string | undefined; @@ -34,6 +35,7 @@ export function useInstance({ refetchOnMount?: boolean; refetchOnWindowFocus?: boolean; throwError?: boolean; + updateInterval?: number; }) { const [instance, setInstance] = useState(defaultValue); @@ -74,7 +76,8 @@ export function useInstance({ }); }, refetchOnMount: refetchOnMount, - refetchOnWindowFocus: refetchOnWindowFocus + refetchOnWindowFocus: refetchOnWindowFocus, + refetchInterval: updateInterval }); const refreshInstance = useCallback(function () { diff --git a/src/frontend/src/pages/Index/Settings/AdminCenter/TaskManagementPanel.tsx b/src/frontend/src/pages/Index/Settings/AdminCenter/TaskManagementPanel.tsx index ab68858d14..729139dbad 100644 --- a/src/frontend/src/pages/Index/Settings/AdminCenter/TaskManagementPanel.tsx +++ b/src/frontend/src/pages/Index/Settings/AdminCenter/TaskManagementPanel.tsx @@ -1,9 +1,19 @@ import { t } from '@lingui/macro'; -import { Accordion } from '@mantine/core'; +import { + Accordion, + Alert, + Divider, + Paper, + SimpleGrid, + Stack, + Text +} from '@mantine/core'; import { lazy } from 'react'; import { StylishText } from '../../../../components/items/StylishText'; +import { ApiEndpoints } from '../../../../enums/ApiEndpoints'; import { Loadable } from '../../../../functions/loading'; +import { useInstance } from '../../../../hooks/UseInstance'; const PendingTasksTable = Loadable( lazy(() => import('../../../../tables/settings/PendingTasksTable')) @@ -17,33 +27,76 @@ const FailedTasksTable = Loadable( lazy(() => import('../../../../tables/settings/FailedTasksTable')) ); -export default function TaskManagementPanel() { +function TaskCountOverview({ title, value }: { title: string; value: number }) { return ( - - - - {t`Pending Tasks`} - - - - - - - - {t`Scheduled Tasks`} - - - - - - - - {t`Failed Tasks`} - - - - - - + + + {title} + {value} + + + ); +} + +export default function TaskManagementPanel() { + const { instance: taskInfo } = useInstance({ + endpoint: ApiEndpoints.task_overview, + hasPrimaryKey: false, + refetchOnMount: true, + defaultValue: {}, + updateInterval: 30 * 1000 + }); + + return ( + <> + {!taskInfo.is_running && ( + + {t`The background task manager service is not running. Contact your system administrator.`} + + )} + + + + + + + + + + + {t`Pending Tasks`} + + + + + + + + {t`Scheduled Tasks`} + + + + + + + + {t`Failed Tasks`} + + + + + + + + ); }