import React, { useEffect } from "react"; import { connect, ConnectedProps } from "react-redux"; import Container from "@material-ui/core/Container"; import { makeStyles } from "@material-ui/core/styles"; import Grid from "@material-ui/core/Grid"; import Paper from "@material-ui/core/Paper"; import Typography from "@material-ui/core/Typography"; import InfoIcon from "@material-ui/icons/Info"; import { listQueuesAsync, pauseQueueAsync, resumeQueueAsync, } from "../actions/queuesActions"; import { AppState } from "../store"; import QueueSizeChart from "../components/QueueSizeChart"; import ProcessedTasksChart from "../components/ProcessedTasksChart"; import QueuesOverviewTable from "../components/QueuesOverviewTable"; import Tooltip from "../components/Tooltip"; import { getCurrentUTCDate } from "../timeutil"; const useStyles = makeStyles((theme) => ({ container: { paddingTop: theme.spacing(4), paddingBottom: theme.spacing(4), }, paper: { padding: theme.spacing(2), display: "flex", overflow: "auto", flexDirection: "column", }, chartHeader: { display: "flex", alignItems: "center", marginBottom: theme.spacing(2), }, chartContainer: { width: "100%", height: "300px", }, infoIcon: { marginLeft: theme.spacing(1), color: theme.palette.grey[500], cursor: "pointer", }, tooltipSection: { marginBottom: "4px", }, })); function mapStateToProps(state: AppState) { return { loading: state.queues.loading, queues: state.queues.data.map((q) => ({ ...q.currentStats, pauseRequestPending: q.pauseRequestPending, })), pollInterval: state.settings.pollInterval, }; } const mapDispatchToProps = { listQueuesAsync, pauseQueueAsync, resumeQueueAsync, }; const connector = connect(mapStateToProps, mapDispatchToProps); type Props = ConnectedProps; function DashboardView(props: Props) { const { pollInterval, listQueuesAsync, queues } = props; const classes = useStyles(); useEffect(() => { listQueuesAsync(); const interval = setInterval(listQueuesAsync, pollInterval * 1000); return () => clearInterval(interval); }, [pollInterval, listQueuesAsync]); const processedStats = queues.map((q) => ({ queue: q.queue, succeeded: q.processed - q.failed, failed: q.failed, })); return (
Queue Size
Total number of tasks in the queue
Active: number of tasks currently being processed
Pending: number of tasks ready to be processed
Scheduled: number of tasks scheduled to be processed in the future
Retry: number of tasks scheduled to be retried in the future
Dead: number of tasks exhausted their retries
} >
Tasks Processed
Total number of tasks processed today ( {getCurrentUTCDate()} UTC)
Succeeded: number of tasks successfully processed from the queue
Failed: number of tasks failed to be processed from the queue
} >
{/* TODO: Add loading indicator */}
); } export default connector(DashboardView);