mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-10-07 20:52:02 +08:00
(ui): Show error message when metrics data is not available
This commit is contained in:
@@ -6,6 +6,7 @@ import { makeStyles } from "@material-ui/core/styles";
|
|||||||
import Container from "@material-ui/core/Container";
|
import Container from "@material-ui/core/Container";
|
||||||
import Grid from "@material-ui/core/Grid";
|
import Grid from "@material-ui/core/Grid";
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
|
import WarningIcon from "@material-ui/icons/Warning";
|
||||||
import { getMetricsAsync } from "../actions/metricsActions";
|
import { getMetricsAsync } from "../actions/metricsActions";
|
||||||
import { AppState } from "../store";
|
import { AppState } from "../store";
|
||||||
import QueueMetricsChart from "../components/QueueMetricsChart";
|
import QueueMetricsChart from "../components/QueueMetricsChart";
|
||||||
@@ -22,6 +23,19 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "flex-end",
|
justifyContent: "flex-end",
|
||||||
},
|
},
|
||||||
|
chartInfo: {
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
errorMessage: {
|
||||||
|
marginLeft: "auto",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
warningIcon: {
|
||||||
|
color: "#ff6700",
|
||||||
|
marginRight: 6,
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function mapStateToProps(state: AppState) {
|
function mapStateToProps(state: AppState) {
|
||||||
@@ -97,10 +111,23 @@ function MetricsView(props: Props) {
|
|||||||
</div>
|
</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
|
<div className={classes.chartInfo}>
|
||||||
<Typography>Queue Size</Typography>
|
<Typography>Queue Size</Typography>
|
||||||
{/* TODO: show error message if data.queue_size.status === "error" */}
|
{data?.queue_size.status === "error" && (
|
||||||
|
<div className={classes.errorMessage}>
|
||||||
|
<WarningIcon fontSize="small" className={classes.warningIcon} />
|
||||||
|
<Typography color="textSecondary">
|
||||||
|
Failed to get metrics data: {data?.queue_size.error || ""}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<QueueMetricsChart
|
<QueueMetricsChart
|
||||||
data={data?.queue_size.data?.result || []}
|
data={
|
||||||
|
data?.queue_size.status === "error"
|
||||||
|
? []
|
||||||
|
: data?.queue_size.data?.result || []
|
||||||
|
}
|
||||||
endTime={endTimeSec}
|
endTime={endTimeSec}
|
||||||
startTime={endTimeSec - durationSec}
|
startTime={endTimeSec - durationSec}
|
||||||
/>
|
/>
|
||||||
@@ -111,25 +138,70 @@ function MetricsView(props: Props) {
|
|||||||
<div>TODO: Queue latency chart here</div>
|
<div>TODO: Queue latency chart here</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
|
<div className={classes.chartInfo}>
|
||||||
<Typography>Pending Tasks</Typography>
|
<Typography>Pending Tasks</Typography>
|
||||||
|
{data?.pending_tasks_by_queue.status === "error" && (
|
||||||
|
<div className={classes.errorMessage}>
|
||||||
|
<WarningIcon fontSize="small" className={classes.warningIcon} />
|
||||||
|
<Typography color="textSecondary">
|
||||||
|
Failed to get metrics data:{" "}
|
||||||
|
{data?.pending_tasks_by_queue.error || ""}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<QueueMetricsChart
|
<QueueMetricsChart
|
||||||
data={data?.pending_tasks_by_queue.data?.result || []}
|
data={
|
||||||
|
data?.pending_tasks_by_queue.status === "error"
|
||||||
|
? []
|
||||||
|
: data?.pending_tasks_by_queue.data?.result || []
|
||||||
|
}
|
||||||
endTime={endTimeSec}
|
endTime={endTimeSec}
|
||||||
startTime={endTimeSec - durationSec}
|
startTime={endTimeSec - durationSec}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
|
<div className={classes.chartInfo}>
|
||||||
<Typography>Retry Tasks</Typography>
|
<Typography>Retry Tasks</Typography>
|
||||||
|
{data?.retry_tasks_by_queue.status === "error" && (
|
||||||
|
<div className={classes.errorMessage}>
|
||||||
|
<WarningIcon fontSize="small" className={classes.warningIcon} />
|
||||||
|
<Typography color="textSecondary">
|
||||||
|
Failed to get metrics data:{" "}
|
||||||
|
{data?.retry_tasks_by_queue.error || ""}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<QueueMetricsChart
|
<QueueMetricsChart
|
||||||
data={data?.retry_tasks_by_queue.data?.result || []}
|
data={
|
||||||
|
data?.retry_tasks_by_queue.status === "error"
|
||||||
|
? []
|
||||||
|
: data?.retry_tasks_by_queue.data?.result || []
|
||||||
|
}
|
||||||
endTime={endTimeSec}
|
endTime={endTimeSec}
|
||||||
startTime={endTimeSec - durationSec}
|
startTime={endTimeSec - durationSec}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
|
<div className={classes.chartInfo}>
|
||||||
<Typography>Archived Tasks</Typography>
|
<Typography>Archived Tasks</Typography>
|
||||||
|
{data?.archived_tasks_by_queue.status === "error" && (
|
||||||
|
<div className={classes.errorMessage}>
|
||||||
|
<WarningIcon fontSize="small" className={classes.warningIcon} />
|
||||||
|
<Typography color="textSecondary">
|
||||||
|
Failed to get metrics data:{" "}
|
||||||
|
{data?.archived_tasks_by_queue.error || ""}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<QueueMetricsChart
|
<QueueMetricsChart
|
||||||
data={data?.archived_tasks_by_queue.data?.result || []}
|
data={
|
||||||
|
data?.archived_tasks_by_queue.status === "error"
|
||||||
|
? []
|
||||||
|
: data?.archived_tasks_by_queue.data?.result || []
|
||||||
|
}
|
||||||
endTime={endTimeSec}
|
endTime={endTimeSec}
|
||||||
startTime={endTimeSec - durationSec}
|
startTime={endTimeSec - durationSec}
|
||||||
/>
|
/>
|
||||||
|
Reference in New Issue
Block a user