import Box from '@mui/material/Box'; import Typography from '@mui/material/Typography'; import Chip from '@mui/material/Chip'; import type { QueueStatus as QueueStatusType } from '../../types/labeleval'; import { getQueueStatus, usePoll } from '../../services/labeleval'; import { SectionCard, MetricCard, HBar, fmtInt, fmtNum, ErrorNote } from './shared'; export default function QueueStatus({ queue: queueProp }: { queue?: QueueStatusType | null }) { // Self-fetches unless a queue snapshot is supplied (e.g. from the SSE stream). const { data, error } = usePoll(getQueueStatus, queueProp === undefined ? 3000 : null, [ queueProp === undefined, ]); const queue = queueProp !== undefined ? queueProp : data; const topics = queue ? Object.entries(queue.depth_by_topic) : []; const maxDepth = Math.max(1, ...topics.map(([, depth]) => depth)); return ( : null} > {!queue && error ? : null} {queue ? ( <> {topics.length > 0 ? ( <> DEPTH BY TOPIC {topics.map(([topic, depth]) => ( ))} ) : ( No topic depth data. )} ) : !error ? ( Waiting for queue data… ) : null} ); }