From d5fdbf3cb0ded28ef710759ea7e0a2bacff033b0 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 27 Aug 2024 19:46:09 -0700 Subject: [PATCH] Added status box component --- Client/src/Pages/Monitors/Home/StatusBox.jsx | 105 +++++++++++++++++++ Client/src/Pages/Monitors/Home/index.jsx | 8 +- 2 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 Client/src/Pages/Monitors/Home/StatusBox.jsx diff --git a/Client/src/Pages/Monitors/Home/StatusBox.jsx b/Client/src/Pages/Monitors/Home/StatusBox.jsx new file mode 100644 index 000000000..cfb2ab838 --- /dev/null +++ b/Client/src/Pages/Monitors/Home/StatusBox.jsx @@ -0,0 +1,105 @@ +import PropTypes from "prop-types"; +import { useTheme } from "@emotion/react"; +import { Box, Stack, Typography } from "@mui/material"; +import Arrow from "../../../assets/icons/top-right-arrow.svg?react"; +import background from "../../../assets/Images/background-grid.svg"; +import ClockSnooze from "../../../assets/icons/clock-snooze.svg?react"; + +const StatusBox = ({ title, value }) => { + const theme = useTheme(); + + let sharedStyles = { position: "absolute", right: 8, opacity: 0.5 }; + + let color; + let icon; + if (title === "up") { + color = theme.pie.green.stroke; + icon = ( + + + + ); + } else if (title === "down") { + color = theme.pie.red.stroke; + icon = ( + + + + ); + } else if (title === "paused") { + color = theme.pie.yellow.stroke; + icon = ( + + + + ); + } + + return ( + + + {title} + + {icon} + + {value} + + # + + + + ); +}; + +StatusBox.propTypes = { + title: PropTypes.oneOf(["up", "down", "paused"]).isRequired, + value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, +}; + +export default StatusBox; diff --git a/Client/src/Pages/Monitors/Home/index.jsx b/Client/src/Pages/Monitors/Home/index.jsx index 13aa6067d..85f922f5e 100644 --- a/Client/src/Pages/Monitors/Home/index.jsx +++ b/Client/src/Pages/Monitors/Home/index.jsx @@ -4,13 +4,13 @@ import { useSelector, useDispatch } from "react-redux"; import { getUptimeMonitorsByTeamId } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"; import { useNavigate } from "react-router-dom"; import Button from "../../../Components/Button"; -import ServerStatus from "../../../Components/Charts/Servers/ServerStatus"; import { useTheme } from "@emotion/react"; import BasicTable from "../../../Components/BasicTable"; import { Box, Stack, Typography } from "@mui/material"; import PropTypes from "prop-types"; import SkeletonLayout from "./skeleton"; import Fallback from "./fallback"; +import StatusBox from "./StatusBox"; import { buildData } from "./monitorData"; const Monitors = ({ isAdmin }) => { @@ -73,9 +73,9 @@ const Monitors = ({ isAdmin }) => { direction="row" justifyContent="space-between" > - - - + + +