From 27d613b594279fdcb45c67e435dc586eee7d52bd Mon Sep 17 00:00:00 2001 From: "anton.strover" Date: Fri, 29 Aug 2025 10:49:22 +0100 Subject: [PATCH] remove carried away-ness --- .../Charts/StatusPageBarChart/index.jsx | 38 ++++++++++--------- .../Status/Components/MonitorsList/index.jsx | 18 ++++++--- client/src/Pages/StatusPage/Status/index.jsx | 5 ++- .../src/db/mongo/modules/statusPageModule.js | 11 ++++++ 4 files changed, 49 insertions(+), 23 deletions(-) diff --git a/client/src/Components/Charts/StatusPageBarChart/index.jsx b/client/src/Components/Charts/StatusPageBarChart/index.jsx index e912934a0..0e14bce88 100644 --- a/client/src/Components/Charts/StatusPageBarChart/index.jsx +++ b/client/src/Components/Charts/StatusPageBarChart/index.jsx @@ -1,7 +1,7 @@ import { useTheme } from "@emotion/react"; import { Box, Stack, Tooltip, Typography } from "@mui/material"; import { formatDateWithTz } from "../../../Utils/timeUtils"; -import { useEffect, useState } from "react"; +import { useEffect, useState, forwardRef } from "react"; import { useSelector } from "react-redux"; import PropTypes from "prop-types"; @@ -17,23 +17,27 @@ import PropTypes from "prop-types"; * @returns {JSX.Element} The Bar component. */ -const Bar = ({ width, height, backgroundColor, borderRadius, children }) => { - const theme = useTheme(); +const Bar = forwardRef( + ({ width, height, backgroundColor, borderRadius, children, ...otherProps }, ref) => { + const theme = useTheme(); - return ( - - {children} - - ); -}; + return ( + + {children} + + ); + } +); Bar.propTypes = { width: PropTypes.string.isRequired, diff --git a/client/src/Pages/StatusPage/Status/Components/MonitorsList/index.jsx b/client/src/Pages/StatusPage/Status/Components/MonitorsList/index.jsx index 1097cf1da..545974c57 100644 --- a/client/src/Pages/StatusPage/Status/Components/MonitorsList/index.jsx +++ b/client/src/Pages/StatusPage/Status/Components/MonitorsList/index.jsx @@ -11,7 +11,12 @@ import PropTypes from "prop-types"; import { useSelector } from "react-redux"; -const MonitorsList = ({ isLoading = false, shouldRender = true, monitors = [] }) => { +const MonitorsList = ({ + isLoading = false, + shouldRender = true, + monitors = [], + statusPage = {}, +}) => { const theme = useTheme(); const { determineState } = useMonitorUtils(); @@ -40,10 +45,12 @@ const MonitorsList = ({ isLoading = false, shouldRender = true, monitors = [] }) alignItems="center" gap={theme.spacing(20)} > - - - - + {statusPage.showCharts !== false && ( + + + + )} + { /> {t("statusPageStatusServiceStatus")} - + {link} ); diff --git a/server/src/db/mongo/modules/statusPageModule.js b/server/src/db/mongo/modules/statusPageModule.js index 10710d0f7..aadde0c81 100755 --- a/server/src/db/mongo/modules/statusPageModule.js +++ b/server/src/db/mongo/modules/statusPageModule.js @@ -162,6 +162,14 @@ class StatusPageModule { as: "monitors.checks", }, }, + { + $lookup: { + from: "monitorstats", + localField: "monitors._id", + foreignField: "monitorId", + as: "monitors.stats", + }, + }, { $addFields: { "monitors.orderIndex": { @@ -181,6 +189,9 @@ class StatusPageModule { }, }, }, + "monitors.uptimePercentage": { + $arrayElemAt: ["$monitors.stats.uptimePercentage", 0], + }, }, }, { $match: { "monitors.orderIndex": { $ne: -1 } } },