From 99046265265d3ef7f0133c42132dc9ff83620e44 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Sat, 24 Jan 2026 00:51:13 +0000 Subject: [PATCH] chart type option --- client/src/Pages/Settings/DummyChart.tsx | 67 ++++++++++++++++++++++++ client/src/Pages/Settings/SettingsUI.jsx | 20 ++++++- client/src/Pages/Settings/index.jsx | 10 +++- client/src/Types/Check.ts | 1 - client/src/locales/en.json | 3 ++ 5 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 client/src/Pages/Settings/DummyChart.tsx diff --git a/client/src/Pages/Settings/DummyChart.tsx b/client/src/Pages/Settings/DummyChart.tsx new file mode 100644 index 000000000..6996af9c5 --- /dev/null +++ b/client/src/Pages/Settings/DummyChart.tsx @@ -0,0 +1,67 @@ +import Box from "@mui/material/Box"; +import Typography from "@mui/material/Typography"; +import { useTheme } from "@mui/material/styles"; +import { HeatmapResponseTime, HistogramResponseTime } from "@/Components/v2/common"; +import type { Check } from "@/Types/Check"; + +interface DummyChartProps { + chartType: string; +} + +const generateDummyChecks = (): Check[] => { + const checks: Check[] = []; + for (let i = 0; i < 25; i++) { + const isUp = Math.random() > 0.1; + checks.push({ + id: `dummy-${i}`, + metadata: { + monitorId: "dummy-monitor", + teamId: "dummy-team", + type: "http", + }, + status: isUp, + statusCode: isUp ? 200 : 500, + responseTime: Math.floor(Math.random() * 80) + 20, + message: "", + ack: false, + expiry: new Date(Date.now() + 86400000).toISOString(), + createdAt: new Date(Date.now() - i * 60000).toISOString(), + updatedAt: new Date(Date.now() - i * 60000).toISOString(), + }); + } + return checks; +}; + +const dummyChecks = generateDummyChecks(); + +const DummyChart = ({ chartType }: DummyChartProps) => { + const theme = useTheme(); + + return ( + + + Preview + + {chartType === "histogram" ? ( + + ) : ( + + )} + + ); +}; + +export default DummyChart; diff --git a/client/src/Pages/Settings/SettingsUI.jsx b/client/src/Pages/Settings/SettingsUI.jsx index 7129e775b..ef9f44eaa 100644 --- a/client/src/Pages/Settings/SettingsUI.jsx +++ b/client/src/Pages/Settings/SettingsUI.jsx @@ -3,16 +3,20 @@ import Stack from "@mui/material/Stack"; import Typography from "@mui/material/Typography"; import ConfigBox from "@/Components/v1/ConfigBox/index.jsx"; import Select from "@/Components/v1/Inputs/Select/index.jsx"; +import DummyChart from "./DummyChart"; +import { ThemeProvider } from "@mui/material/styles"; +import { lightTheme, darkTheme } from "@/Utils/Theme/v2Theme"; // Utils import { useTheme } from "@emotion/react"; import { PropTypes } from "prop-types"; import { useTranslation } from "react-i18next"; -const SettingsUI = ({ HEADING_SX, handleChange, mode, language }) => { +const SettingsUI = ({ HEADING_SX, handleChange, mode, language, chartType }) => { const { t, i18n } = useTranslation(); const theme = useTheme(); const languages = Object.keys(i18n.options.resources || {}); + const v2Theme = mode === "dark" ? darkTheme : lightTheme; return ( @@ -44,6 +48,19 @@ const SettingsUI = ({ HEADING_SX, handleChange, mode, language }) => { onChange={handleChange} items={languages.map((lang) => ({ _id: lang, name: lang.toUpperCase() }))} > + + + + ); @@ -54,6 +71,7 @@ SettingsUI.propTypes = { handleChange: PropTypes.func, mode: PropTypes.string, language: PropTypes.string, + chartType: PropTypes.string, }; export default SettingsUI; diff --git a/client/src/Pages/Settings/index.jsx b/client/src/Pages/Settings/index.jsx index 621640d8a..3f62f4ea4 100644 --- a/client/src/Pages/Settings/index.jsx +++ b/client/src/Pages/Settings/index.jsx @@ -17,7 +17,7 @@ import { useState } from "react"; import { useTheme } from "@emotion/react"; import { useTranslation } from "react-i18next"; import { useSelector, useDispatch } from "react-redux"; -import { setTimezone, setMode, setLanguage, setShowURL } from "@/Features/UI/uiSlice.js"; +import { setTimezone, setMode, setLanguage, setShowURL, setChartType } from "@/Features/UI/uiSlice.js"; import SettingsStats from "./SettingsStats.jsx"; import { useFetchSettings, useSaveSettings } from "@/Hooks/settingsHooks.js"; @@ -33,7 +33,7 @@ const BREADCRUMBS = [{ name: `Settings`, path: "/settings" }]; const Settings = () => { // Redux state - const { mode, language = "en", timezone, showURL } = useSelector((state) => state.ui); + const { mode, language = "en", timezone, showURL, chartType = "histogram" } = useSelector((state) => state.ui); // Local state const [settingsData, setSettingsData] = useState({}); @@ -112,6 +112,11 @@ const Settings = () => { return; } + if (name === "chartType") { + dispatch(setChartType(value)); + return; + } + if (name === "deleteStats") { await deleteMonitorStats(); return; @@ -209,6 +214,7 @@ const Settings = () => { handleChange={handleChange} mode={mode} language={language} + chartType={chartType} />