From c9cac59e38ca358e6d9de63f54edb91aec74f72f Mon Sep 17 00:00:00 2001 From: Peter Carl Pardo Date: Fri, 6 Dec 2024 14:41:25 +0800 Subject: [PATCH 01/18] feat: add configure button in infrastructure monitor details page --- .../Pages/Infrastructure/Details/index.jsx | 107 ++++++++++++++---- 1 file changed, 86 insertions(+), 21 deletions(-) diff --git a/Client/src/Pages/Infrastructure/Details/index.jsx b/Client/src/Pages/Infrastructure/Details/index.jsx index 06fb1296a..6a3860b35 100644 --- a/Client/src/Pages/Infrastructure/Details/index.jsx +++ b/Client/src/Pages/Infrastructure/Details/index.jsx @@ -1,7 +1,7 @@ import { useParams } from "react-router-dom"; import { useEffect, useState } from "react"; import Breadcrumbs from "../../../Components/Breadcrumbs"; -import { Stack, Box, Typography } from "@mui/material"; +import { Stack, Box, Typography, Tooltip, Button } from "@mui/material"; import { useTheme } from "@emotion/react"; import CustomGauge from "../../../Components/Charts/CustomGauge"; import AreaChart from "../../../Components/Charts/AreaChart"; @@ -12,7 +12,7 @@ import useUtils from "../../Monitors/utils"; import { useNavigate } from "react-router-dom"; import Empty from "./empty"; import { logger } from "../../../Utils/Logger"; -import { formatDurationRounded, formatDurationSplit } from "../../../Utils/timeUtils"; +import { formatDurationRounded } from "../../../Utils/timeUtils"; import { TzTick, PercentTick, @@ -20,6 +20,7 @@ import { TemperatureTooltip, } from "../../../Components/Charts/Utils/chartUtils"; import PropTypes from "prop-types"; +import SettingsIcon from "../../../assets/icons/settings-bold.svg?react"; const BASE_BOX_PADDING_VERTICAL = 4; const BASE_BOX_PADDING_HORIZONTAL = 8; @@ -182,7 +183,7 @@ GaugeBox.propTypes = { * Renders the infrastructure details page * @returns {React.ReactElement} Infrastructure details page component */ -const InfrastructureDetails = () => { +const InfrastructureDetails = ({ isAdmin }) => { const navigate = useNavigate(); const theme = useTheme(); const { monitorId } = useParams(); @@ -193,7 +194,7 @@ const InfrastructureDetails = () => { const [monitor, setMonitor] = useState(null); const { authToken } = useSelector((state) => state.auth); const [dateRange, setDateRange] = useState("all"); - const { statusColor, determineState } = useUtils(); + const { statusColor, statusMsg, determineState } = useUtils(); // These calculations are needed because ResponsiveContainer // doesn't take padding of parent/siblings into account // when calculating height. @@ -482,26 +483,90 @@ const InfrastructureDetails = () => { - + + {monitor.name} + + + + + + + + + {monitor.url?.replace(/^https?:\/\//, "") || "..."} + + + Checking every {formatDurationRounded(monitor?.interval)}. + + - - {monitor.name} - - {monitor.url || "..."} - - - Checking every {formatDurationRounded(monitor?.interval)} - - - Last checked {formatDurationSplit(monitor?.lastChecked).time}{" "} - {formatDurationSplit(monitor?.lastChecked).format} ago - + {isAdmin && ( + + )} Date: Fri, 6 Dec 2024 14:45:43 +0800 Subject: [PATCH 02/18] feat: add configure insfrastructure monitor route and component --- Client/src/App.jsx | 6 ++++++ Client/src/Pages/Infrastructure/Configure/index.jsx | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 Client/src/Pages/Infrastructure/Configure/index.jsx diff --git a/Client/src/App.jsx b/Client/src/App.jsx index 82c8203a8..245d8f153 100644 --- a/Client/src/App.jsx +++ b/Client/src/App.jsx @@ -41,6 +41,8 @@ import { logger } from "./Utils/Logger"; // Import the logger import { networkService } from "./main"; import { Infrastructure } from "./Pages/Infrastructure"; import InfrastructureDetails from "./Pages/Infrastructure/Details"; +import ConfigureInfrastructureMonitor from "./Pages/Infrastructure/Configure"; + function App() { const AdminCheckedRegister = withAdminCheck(Register); const MonitorsWithAdminProp = withAdminProp(Monitors); @@ -138,6 +140,10 @@ function App() { path="infrastructure/:monitorId" element={} /> + } + /> { + return
Configure Infrastructure Monitor Page
; +}; + +export default ConfigureInfrastructureMonitor; From 98ea47bca2e8d03bfddaa30d3eb9c6e7c69aa431 Mon Sep 17 00:00:00 2001 From: Peter Carl Pardo Date: Fri, 6 Dec 2024 15:23:27 +0800 Subject: [PATCH 03/18] feat: update configure button link --- Client/src/Pages/Infrastructure/Details/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/src/Pages/Infrastructure/Details/index.jsx b/Client/src/Pages/Infrastructure/Details/index.jsx index 6a3860b35..a0069a900 100644 --- a/Client/src/Pages/Infrastructure/Details/index.jsx +++ b/Client/src/Pages/Infrastructure/Details/index.jsx @@ -553,7 +553,7 @@ const InfrastructureDetails = ({ isAdmin }) => {