From af43063619f3cf9459729b65fe5a6a3201f1c1f4 Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Sun, 5 Dec 2021 16:34:30 -0800 Subject: [PATCH] (ui): Add top level shift buttons --- ui/src/components/MetricsFetchControls.tsx | 582 +++++++++++---------- 1 file changed, 318 insertions(+), 264 deletions(-) diff --git a/ui/src/components/MetricsFetchControls.tsx b/ui/src/components/MetricsFetchControls.tsx index fc0fa9c..678ca58 100644 --- a/ui/src/components/MetricsFetchControls.tsx +++ b/ui/src/components/MetricsFetchControls.tsx @@ -1,7 +1,8 @@ import React from "react"; import { connect, ConnectedProps } from "react-redux"; import { makeStyles } from "@material-ui/core/styles"; -import Button from "@material-ui/core/Button"; +import Button, { ButtonProps } from "@material-ui/core/Button"; +import ButtonGroup from "@material-ui/core/ButtonGroup"; import Popover from "@material-ui/core/Popover"; import Radio from "@material-ui/core/Radio"; import RadioGroup from "@material-ui/core/RadioGroup"; @@ -53,6 +54,12 @@ const useStyles = makeStyles((theme) => ({ endTimeCaption: { marginRight: theme.spacing(1), }, + shiftButtons: { + marginLeft: theme.spacing(1), + }, + buttonGroupRoot: { + height: 30, + }, endTimeShiftControls: { padding: theme.spacing(1), display: "flex", @@ -331,269 +338,311 @@ function MetricsFetchControls(props: Props) { {formatTime(props.endTimeSec)} - - -
-
- - - - - +
+ + +
+
+ + + + + +
+
+ + + + + +
-
- - - - - -
-
-
-
- - End Time - +
+ - - } - label="Real Time" - /> - - } - label="Freeze at now" - /> - - } - label="Custom End Time" - /> - -
- -
-
-
-
- - Duration - End Time + + + } + label="Real Time" + /> + + } + label="Freeze at now" + /> + + } + label="Custom End Time" + /> + +
+ +
+
+
+
+ - - } - label="1h" - /> - - } - label="6h" - /> - - } - label="1 day" - /> - - } - label="8 days" - /> - - } - label="30 days" - /> - - } - label="Custom Duration" - /> - -
- -
-
+ Duration + + + } + label="1h" + /> + + } + label="6h" + /> + + } + label="1 day" + /> + + } + label="8 days" + /> + + } + label="30 days" + /> + + } + label="Custom Duration" + /> + +
+ +
+ +
-
- + +
+
+ + + + +
); } @@ -605,10 +654,11 @@ function formatTime(unixtime: number): string { return dayjs.unix(unixtime).format("ddd, DD MMM YYYY HH:mm:ss ") + tz; } -interface ShiftButtonProps { +interface ShiftButtonProps extends ButtonProps { text: string; onClick: () => void; direction: "left" | "right"; + dense?: boolean; } const useShiftButtonStyles = makeStyles((theme) => ({ @@ -616,9 +666,9 @@ const useShiftButtonStyles = makeStyles((theme) => ({ label: { fontSize: 12, textTransform: "none" }, iconRoot: { marginRight: (props: ShiftButtonProps) => - props.direction === "left" ? -8 : 0, + props.direction === "left" && props.dense ? -8 : 0, marginLeft: (props: ShiftButtonProps) => - props.direction === "right" ? -8 : 0, + props.direction === "right" && props.dense ? -8 : 0, color: theme.palette.grey[700], }, })); @@ -627,12 +677,12 @@ function ShiftButton(props: ShiftButtonProps) { const classes = useShiftButtonStyles(props); return (