From b2c8de61bb951d75b5522cef0f788778c2c9568a Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Sat, 23 Jan 2021 22:36:19 -0800 Subject: [PATCH] Change layout of TasksTable --- ui/src/components/QueueInfoBanner.tsx | 101 +++++++++++++++++ ui/src/components/TasksTable.tsx | 149 +++++--------------------- ui/src/views/TasksView.tsx | 24 ++--- 3 files changed, 140 insertions(+), 134 deletions(-) create mode 100644 ui/src/components/QueueInfoBanner.tsx diff --git a/ui/src/components/QueueInfoBanner.tsx b/ui/src/components/QueueInfoBanner.tsx new file mode 100644 index 0000000..fef48a7 --- /dev/null +++ b/ui/src/components/QueueInfoBanner.tsx @@ -0,0 +1,101 @@ +import React from "react"; +import { connect, ConnectedProps } from "react-redux"; +import { makeStyles } from "@material-ui/core/styles"; +import Typography from "@material-ui/core/Typography"; +import { AppState } from "../store"; + +const useStyles = makeStyles((theme) => ({ + banner: { + paddingTop: theme.spacing(2), + paddingBottom: theme.spacing(2), + display: "flex", + }, + bannerItem: { + flexGrow: 1, + borderLeft: `1px solid ${theme.palette.divider}`, + paddingLeft: theme.spacing(2), + paddingRight: theme.spacing(2), + }, +})); + +interface Props { + qname: string; +} + +function mapStateToProps(state: AppState, ownProps: Props) { + const queueInfo = state.queues.data.find((q) => q.name === ownProps.qname); + return { + queue: queueInfo?.currentStats, + }; +} + +const connector = connect(mapStateToProps); + +type ReduxProps = ConnectedProps; + +function QueueInfoBanner(props: Props & ReduxProps) { + const classes = useStyles(); + const { queue, qname } = props; + return ( +
+
+ + Queue name + + {qname} +
+ +
+ + Queue state + + + {queue ? (queue.paused ? "paused" : "run") : "-"} + +
+ +
+ + Queue size + + + {queue ? queue.size : "-"} + +
+ +
+ + Memory usage + + 1.2MB +
+ +
+ + Processed + + + {queue ? queue.processed : "-"} + +
+ +
+ + Failed + + + {queue ? queue.failed : "-"} + +
+ +
+ + Error rate + + 0.3 % +
+
+ ); +} + +export default connector(QueueInfoBanner); diff --git a/ui/src/components/TasksTable.tsx b/ui/src/components/TasksTable.tsx index 7eccfe5..50562fa 100644 --- a/ui/src/components/TasksTable.tsx +++ b/ui/src/components/TasksTable.tsx @@ -45,53 +45,6 @@ function a11yProps(value: string) { }; } -const usePanelHeadingStyles = makeStyles((theme) => ({ - paper: { - padding: theme.spacing(2), - marginBottom: theme.spacing(2), - display: "flex", - justifyContent: "space-between", - }, -})); - -function PanelHeading(props: { - queue: string; - processed: number; - failed: number; - paused: boolean; -}) { - const classes = usePanelHeadingStyles(); - return ( - -
- - Queue Name - - {props.queue} -
- -
- - Processed Today (UTC) - - {props.processed} -
-
- - Failed Today (UTC) - - {props.failed} -
-
- - Paused - - {props.paused ? "YES" : "No"} -
-
- ); -} - function mapStatetoProps(state: AppState, ownProps: Props) { // TODO: Add loading state for each queue. const queueInfo = state.queues.data.find( @@ -126,52 +79,46 @@ interface Props { const useStyles = makeStyles((theme) => ({ container: { - display: "flex", width: "100%", height: "100%", background: theme.palette.background.paper, }, heading: { - fontSize: "1.7rem", - fontWeight: 500, - paddingLeft: "28px", // TODO: maybe use theme.spacing(3), - paddingTop: "28px", - paddingBottom: "28px", - color: theme.palette.text.primary, + paddingTop: theme.spacing(1), + paddingBottom: theme.spacing(1), + paddingLeft: theme.spacing(2), + paddingRight: theme.spacing(2), + borderBottom: `1px solid ${theme.palette.divider}`, }, tabsContainer: { - background: - theme.palette.type === "dark" - ? "#303030" - : theme.palette.background.default, + // background: + // theme.palette.type === "dark" + // ? "#303030" + // : theme.palette.background.default, }, tabsRoot: { - paddingLeft: theme.spacing(2), - background: - theme.palette.type === "dark" - ? "#303030" - : theme.palette.background.default, + // background: + // theme.palette.type === "dark" + // ? "#303030" + // : theme.palette.background.default, }, tabsIndicator: { right: "auto", left: "0", }, tabroot: { - width: "204px", - textAlign: "left", + flexGrow: 1, + textAlign: "center", padding: theme.spacing(2), }, tabwrapper: { - alignItems: "flex-start", + alignItems: "center", color: theme.palette.text.primary, }, tabSelected: { background: theme.palette.background.paper, - boxShadow: theme.shadows[1], - }, - panelContainer: { - padding: "24px", }, + panelContainer: {}, taskCount: { fontSize: "2rem", fontWeight: 600, @@ -185,24 +132,22 @@ function TasksTable(props: Props & ReduxProps) { const history = useHistory(); return ( -
+ + + Tasks list +
-
Tasks
history.push(queueDetailsPath(props.queue, value)) } aria-label="tasks table" - orientation="vertical" classes={{ root: classes.tabsRoot, indicator: classes.tabsIndicator }} > {currentStats.active}
- } + label={`Active (${currentStats.active})`} classes={{ root: classes.tabroot, wrapper: classes.tabwrapper, @@ -212,10 +157,7 @@ function TasksTable(props: Props & ReduxProps) { /> {currentStats.pending}
- } + label={`Pending (${currentStats.pending})`} classes={{ root: classes.tabroot, wrapper: classes.tabwrapper, @@ -225,10 +167,7 @@ function TasksTable(props: Props & ReduxProps) { /> {currentStats.scheduled} - } + label={`Scheduled (${currentStats.scheduled})`} classes={{ root: classes.tabroot, wrapper: classes.tabwrapper, @@ -238,8 +177,7 @@ function TasksTable(props: Props & ReduxProps) { /> {currentStats.retry}} + label={`Retry (${currentStats.retry})`} classes={{ root: classes.tabroot, wrapper: classes.tabwrapper, @@ -249,10 +187,7 @@ function TasksTable(props: Props & ReduxProps) { /> {currentStats.archived} - } + label={`Archived (${currentStats.archived})`} classes={{ root: classes.tabroot, wrapper: classes.tabwrapper, @@ -264,23 +199,11 @@ function TasksTable(props: Props & ReduxProps) {
-
-
-
-
-
-
+ ); } diff --git a/ui/src/views/TasksView.tsx b/ui/src/views/TasksView.tsx index a9ae167..f423d2e 100644 --- a/ui/src/views/TasksView.tsx +++ b/ui/src/views/TasksView.tsx @@ -3,21 +3,18 @@ import { makeStyles } from "@material-ui/core/styles"; import Container from "@material-ui/core/Container"; import Grid from "@material-ui/core/Grid"; import TasksTable from "../components/TasksTable"; +import QueueInfoBanner from "../components/QueueInfoBanner"; import { useParams, useLocation } from "react-router-dom"; const useStyles = makeStyles((theme) => ({ container: { - paddingLeft: 0, - marginLeft: 0, - height: "100%", + paddingTop: theme.spacing(2), }, - gridContainer: { - height: "100%", - paddingBottom: 0, + bannerContainer: { + marginBottom: theme.spacing(2), }, - gridItem: { - height: "100%", - paddingBottom: 0, + taskTableContainer: { + marginBottom: theme.spacing(4), }, })); @@ -42,9 +39,12 @@ function TasksView() { } return ( - - - + + + + + +