diff --git a/dashboard/src/components/RunsTable.tsx b/dashboard/src/components/RunsTable.tsx index 70c2409d..3add88e2 100644 --- a/dashboard/src/components/RunsTable.tsx +++ b/dashboard/src/components/RunsTable.tsx @@ -23,6 +23,16 @@ interface RunsTableProps { namespace: string; } +const REFRESH_OPTIONS = [ + { label: "Off", value: 0 }, + { label: "5 seconds", value: 5000 }, + { label: "10 seconds", value: 10000 }, + { label: "30 seconds", value: 30000 }, + { label: "1 minute", value: 60000 }, +] as const; + +type RefreshMs = typeof REFRESH_OPTIONS[number]['value']; + export const RunsTable: React.FC = ({ namespace }) => { @@ -33,6 +43,7 @@ export const RunsTable: React.FC = ({ const [error, setError] = useState(null); const [selectedRunId, setSelectedRunId] = useState(null); const [showGraph, setShowGraph] = useState(false); + const [refreshInterval, setRefreshInterval] = useState(0); const loadRuns = useCallback(async (page: number, size: number) => { setIsLoading(true); @@ -54,6 +65,30 @@ export const RunsTable: React.FC = ({ } }, [namespace, currentPage, pageSize, loadRuns]); + useEffect(() => { + if (refreshInterval === 0) { + return; + } + + let isCancelled = false; + let timeoutId: ReturnType; + + const poll = () => { + loadRuns(currentPage, pageSize).finally(() => { + if (!isCancelled) { + timeoutId = setTimeout(poll, refreshInterval); + } + }); + }; + + timeoutId = setTimeout(poll, refreshInterval); + + return () => { + isCancelled = true; + clearTimeout(timeoutId); + }; + }, [refreshInterval, currentPage, pageSize, loadRuns]); + const handlePageChange = (newPage: number) => { setCurrentPage(newPage); setSelectedRunId(null); @@ -144,15 +179,40 @@ export const RunsTable: React.FC = ({

Monitor and visualize workflow executions

- + +
+ + + + +
+ {/* Graph Visualization */} {showGraph && selectedRunId && (