Merge pull request #1830 from bluewave-labs/feat/responsive-status-page

feat: make status page responsive
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-02-26 11:44:40 -08:00
commit 29d6d01ce7
8 files changed
+58 -23

No files matched your search

+8 -4
View File
@@ -1,7 +1,6 @@
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { Box, Stack, Typography } from "@mui/material"; import { Stack, Typography } from "@mui/material";
import { RowContainer } from "../StandardContainer";
/** /**
@@ -9,6 +8,7 @@ import { RowContainer } from "../StandardContainer";
* @component * @component
* @example * @example
* *
* @param {string} props.direction - Direction of the subheader
* @param {string} props.headerText - Header text * @param {string} props.headerText - Header text
* @param {number} props.headerLevel - Font characteristic of the header * @param {number} props.headerLevel - Font characteristic of the header
* @param {string} props.subHeaderText - Subheader text * @param {string} props.subHeaderText - Subheader text
@@ -19,19 +19,22 @@ import { RowContainer } from "../StandardContainer";
*/ */
const SubHeader = ({ const SubHeader = ({
direction = "row",
headerText, headerText,
headerLevel = 1, headerLevel = 1,
subHeaderText, subHeaderText,
subHeaderLevel = 1, subHeaderLevel = 1,
alignItems = "center", alignItems = "center",
children, children,
...props
}) => { }) => {
const theme = useTheme(); const theme = useTheme();
return ( return (
<Stack <Stack
direction="row" direction={direction}
alignItems={alignItems} alignItems={alignItems}
justifyContent="space-between" justifyContent="space-between"
{...props}
> >
<Stack direction={"column"}> <Stack direction={"column"}>
<Typography <Typography
@@ -60,11 +63,12 @@ const SubHeader = ({
}; };
SubHeader.propTypes = { SubHeader.propTypes = {
direction: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
headerText: PropTypes.string, headerText: PropTypes.string,
headerLevel: PropTypes.number, headerLevel: PropTypes.number,
subHeaderText: PropTypes.string, subHeaderText: PropTypes.string,
subHeaderLevel: PropTypes.number, subHeaderLevel: PropTypes.number,
alignItems: PropTypes.string, alignItems: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
children: PropTypes.node, children: PropTypes.node,
}; };
@@ -1,14 +1,17 @@
// Components
import { Stack, Typography } from "@mui/material"; import { Stack, Typography } from "@mui/material";
import { useTheme } from "@emotion/react";
import PulseDot from "../../../../../Components/Animated/PulseDot"; import PulseDot from "../../../../../Components/Animated/PulseDot";
import "flag-icons/css/flag-icons.min.css"; import "flag-icons/css/flag-icons.min.css";
import { ColContainer } from "../../../../../Components/StandardContainer"; import { ColContainer } from "../../../../../Components/StandardContainer";
const BASE_BOX_PADDING_VERTICAL = 16; // Utils
const BASE_BOX_PADDING_HORIZONTAL = 8; import { useMediaQuery } from "@mui/material";
import { useTheme } from "@emotion/react";
import { safelyParseFloat } from "../../../../../Utils/utils";
const DeviceTicker = ({ data, width = "100%", connectionStatus }) => { const DeviceTicker = ({ data, width = "100%", connectionStatus }) => {
const theme = useTheme(); const theme = useTheme();
const isSmallScreen = useMediaQuery(theme.breakpoints.down("sm"));
const statusColor = { const statusColor = {
up: theme.palette.success.main, up: theme.palette.success.main,
down: theme.palette.error.main, down: theme.palette.error.main,
@@ -43,7 +46,7 @@ const DeviceTicker = ({ data, width = "100%", connectionStatus }) => {
<Typography>RESPONSE</Typography> <Typography>RESPONSE</Typography>
</th> </th>
<th style={{ textAlign: "right" }}> <th style={{ textAlign: "right" }}>
<Typography>UPT BURNED</Typography> <Typography>{isSmallScreen ? "UPT" : "UPT BURNED"}</Typography>
</th> </th>
</tr> </tr>
</thead> </thead>
@@ -68,7 +71,10 @@ const DeviceTicker = ({ data, width = "100%", connectionStatus }) => {
</td> </td>
<td style={{ textAlign: "right" }}> <td style={{ textAlign: "right" }}>
<Typography color={theme.palette.warning.main}> <Typography color={theme.palette.warning.main}>
+{dataPoint.uptBurnt} +
{isSmallScreen
? safelyParseFloat(dataPoint.uptBurnt).toFixed(4)
: dataPoint.uptBurnt}
</Typography> </Typography>
</td> </td>
</tr> </tr>
@@ -6,7 +6,12 @@ import maplibregl from "maplibre-gl";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import buildStyle from "./buildStyle"; import buildStyle from "./buildStyle";
const DistributedUptimeMap = ({ width = "100%", checks }) => { const DistributedUptimeMap = ({
width = "100%",
checks,
height,
minHeight = "350px",
}) => {
const mapContainer = useRef(null); const mapContainer = useRef(null);
const map = useRef(null); const map = useRef(null);
const theme = useTheme(); const theme = useTheme();
@@ -92,6 +97,8 @@ const DistributedUptimeMap = ({ width = "100%", checks }) => {
ref={mapContainer} ref={mapContainer}
style={{ style={{
width: width, width: width,
height: height,
minHeight: minHeight,
borderRadius: theme.spacing(4), borderRadius: theme.spacing(4),
borderColor: theme.palette.primary.lowContrast, borderColor: theme.palette.primary.lowContrast,
borderStyle: "solid", borderStyle: "solid",
@@ -105,6 +112,7 @@ DistributedUptimeMap.propTypes = {
checks: PropTypes.array, checks: PropTypes.array,
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
}; };
export default DistributedUptimeMap; export default DistributedUptimeMap;
@@ -2,7 +2,6 @@
import { Stack } from "@mui/material"; import { Stack } from "@mui/material";
import InfoBox from "../../../../../Components/InfoBox"; import InfoBox from "../../../../../Components/InfoBox";
import LastUpdate from "../LastUpdate"; import LastUpdate from "../LastUpdate";
import UptLogo from "../../../../../assets/icons/upt_logo.png";
// Utils // Utils
import { useTheme } from "@mui/material/styles"; import { useTheme } from "@mui/material/styles";
@@ -15,6 +14,7 @@ const StatBoxes = ({ monitor, lastUpdateTrigger }) => {
<Stack <Stack
direction="row" direction="row"
justifyContent="space-between" justifyContent="space-between"
flexWrap="wrap"
gap={theme.spacing(8)} gap={theme.spacing(8)}
> >
<InfoBox <InfoBox
@@ -32,7 +32,7 @@ const StatusHeader = ({ monitor, connectionStatus, elementToCapture }) => {
return ( return (
<ColContainer backgroundColor={bgColor}> <ColContainer backgroundColor={bgColor}>
<Stack <Stack
direction="row" direction={{ s: "column", md: "row" }}
justifyContent="space-between" justifyContent="space-between"
gap={theme.spacing(8)} gap={theme.spacing(8)}
> >
@@ -1,13 +1,14 @@
import { Stack, Button, ButtonGroup } from "@mui/material"; import { Stack, Button, ButtonGroup } from "@mui/material";
import { RowContainer } from "../../../../../Components/StandardContainer";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
const TimeFrameHeader = ({ timeFrame, setTimeFrame }) => { const TimeFrameHeader = ({ timeFrame, setTimeFrame, sx, ...props }) => {
const theme = useTheme(); const theme = useTheme();
return ( return (
<Stack <Stack
direction="row" direction="row"
justifyContent="flex-end" justifyContent="flex-end"
sx={{ ...sx }}
{...props}
> >
<ButtonGroup> <ButtonGroup>
<Button <Button
@@ -28,10 +28,13 @@ import { useDUStatusPageFetchByUrl } from "./Hooks/useDUStatusPageFetchByUrl";
import { useStatusPageDelete } from "../../StatusPage/Status/Hooks/useStatusPageDelete"; import { useStatusPageDelete } from "../../StatusPage/Status/Hooks/useStatusPageDelete";
import TimeFrameHeader from "./Components/TimeframeHeader"; import TimeFrameHeader from "./Components/TimeframeHeader";
import SubHeader from "../../../Components/Subheader"; import SubHeader from "../../../Components/Subheader";
import { safelyParseFloat } from "../../../Utils/utils";
import { useNavigate, useLocation } from "react-router-dom"; import { useNavigate, useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
// Responsive
import { useMediaQuery } from "@mui/material";
const DistributedUptimeStatus = () => { const DistributedUptimeStatus = () => {
const { url } = useParams(); const { url } = useParams();
const location = useLocation(); const location = useLocation();
@@ -45,6 +48,7 @@ const DistributedUptimeStatus = () => {
const [timeFrame, setTimeFrame] = useState(30); const [timeFrame, setTimeFrame] = useState(30);
// Utils // Utils
const theme = useTheme(); const theme = useTheme();
const isSmallScreen = useMediaQuery(theme.breakpoints.down("sm"));
const navigate = useNavigate(); const navigate = useNavigate();
const [ const [
@@ -170,8 +174,11 @@ const DistributedUptimeStatus = () => {
/> />
<SubHeader <SubHeader
direction={{ s: "column", md: "row" }}
headerText={t("distributedStatusHeaderText")} headerText={t("distributedStatusHeaderText")}
subHeaderText={t("distributedStatusSubHeaderText")} subHeaderText={t("distributedStatusSubHeaderText")}
gap={isSmallScreen ? theme.spacing(10) : 0}
alignItems={{ s: "flex-start", md: "flex-end" }}
> >
<RowContainer> <RowContainer>
<Stack> <Stack>
@@ -195,16 +202,15 @@ const DistributedUptimeStatus = () => {
setDateRange={setDateRange} setDateRange={setDateRange}
/> />
<Stack <Stack
direction="row"
gap={theme.spacing(8)} gap={theme.spacing(8)}
direction={{ s: "column", md: "row" }}
> >
<DistributedUptimeMap <DistributedUptimeMap
checks={monitor?.groupedMapChecks ?? []} checks={monitor?.groupedMapChecks ?? []}
height={"100%"} width={isSmallScreen ? "100%" : "50%"}
width={"50%"}
/> />
<Stack <Stack
width={"50%"} width={{ s: "100%", md: "50%" }}
gap={theme.spacing(8)} gap={theme.spacing(8)}
> >
<Stack <Stack
@@ -219,8 +225,8 @@ const DistributedUptimeStatus = () => {
sx={{ width: "50%" }} sx={{ width: "50%" }}
/> />
<InfoBox <InfoBox
heading="UPT Burned" heading={isSmallScreen ? "UPT" : "UPT Burned"}
subHeading={monitor?.totalUptBurnt ?? 0} subHeading={safelyParseFloat(monitor?.totalUptBurnt).toFixed(4)}
img={UptLogo} img={UptLogo}
alt="Upt Logo" alt="Upt Logo"
sx={{ width: "50%" }} sx={{ width: "50%" }}
@@ -240,13 +246,16 @@ const DistributedUptimeStatus = () => {
/> />
<SubHeader <SubHeader
direction={{ s: "column", md: "row" }}
headerText={t("distributedStatusServerMonitors")} headerText={t("distributedStatusServerMonitors")}
subHeaderText={t("distributedStatusServerMonitorsDescription")} subHeaderText={t("distributedStatusServerMonitorsDescription")}
alignItems="end" gap={isSmallScreen ? theme.spacing(10) : 0}
alignItems={{ s: "flex-start", md: "flex-end" }}
> >
<TimeFrameHeader <TimeFrameHeader
timeFrame={timeFrame} timeFrame={timeFrame}
setTimeFrame={setTimeFrame} setTimeFrame={setTimeFrame}
alignSelf="flex-start"
/> />
</SubHeader> </SubHeader>
+7
View File
@@ -0,0 +1,7 @@
export const safelyParseFloat = (value) => {
const parsedValue = parseFloat(value);
if (isNaN(parsedValue)) {
return 0;
}
return parsedValue;
};