This commit is contained in:
Alex Holliday committed 2025-11-25 23:07:16 +00:00
1 parent 4a79013ef2
commit b5bdd73a90
5 files changed
+200 -3

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
import { useMemo } from "react";
import type { ICheck } from "@/types/check";
import { HeatmapResponseTime } from "@/components/common/HeatmapResponseTime";
import { HistogramResponseTime } from "@/components/common/HistogramResponseTime";
import type { ChartType } from "@/features/uiSlice";
const buildDummyChecks = (): ICheck[] => {
const now = Date.now();
const arr: ICheck[] = [] as any;
for (let i = 0; i < 25; i++) {
const ms = Math.floor(50 + Math.random() * 800);
arr.push({
_id: `chk-${i}`,
metadata: { monitorId: "m1", type: "http", teamId: "t1" },
status: Math.random() > 0.3 ? "up" : "down",
message: "",
responseTime: ms,
normalResponseTime: 0,
httpStatusCode: 200,
ack: false,
expiry: new Date(now - i * 60000).toISOString(),
createdAt: new Date(now - i * 60000).toISOString(),
updatedAt: new Date(now - i * 60000).toISOString(),
timings: {
start: "",
socket: "",
lookup: "",
connect: "",
secureConnect: "",
response: "",
end: "",
phases: {
wait: 0,
dns: 0,
tcp: 0,
tls: 0,
request: 0,
firstByte: 0,
download: 0,
total: ms,
},
},
});
}
return arr;
};
const DummyChart = ({ type }: { type: ChartType }) => {
const checks = useMemo(() => buildDummyChecks(), []);
return type === "heatmap" ? (
<HeatmapResponseTime checks={checks} />
) : (
<HistogramResponseTime checks={checks} />
);
};
export default DummyChart;
+29 -1
View File
@@ -5,9 +5,10 @@ import MenuItem from "@mui/material/MenuItem";
import Typography from "@mui/material/Typography";
import { SettingsForm } from "@/pages/settings/SettingsForm";
import type { ChartType } from "@/features/uiSlice";
import { useTheme } from "@mui/material/styles";
import { useEffect, useMemo, useState } from "react";
import { setTimezone, setMode } from "@/features/uiSlice";
import { setTimezone, setMode, setChartType } from "@/features/uiSlice";
import { useAppSelector, useAppDispatch } from "@/hooks/AppHooks";
import timezones from "@/utils/timezones.json";
import type { ITimeZone } from "@/types/timezone";
@@ -16,6 +17,7 @@ import { useGet, usePatch, usePost } from "@/hooks/UseApi";
import type { ApiResponse } from "@/hooks/UseApi";
import { z } from "zod";
import { systemSettingsSchema } from "@/validation/zod";
import DummyChart from "./DummyChart";
const SettingsPage = () => {
type FormValues = z.infer<typeof systemSettingsSchema>;
@@ -29,6 +31,7 @@ const SettingsPage = () => {
const dispatch = useAppDispatch();
const timezone = useAppSelector((state) => state.ui.timezone);
const mode = useAppSelector((state) => state.ui.mode);
const chartType = useAppSelector((state) => state.ui.chartType);
const [selectedTimezone, setSelectedTimezone] = useState<ITimeZone | null>(
null
);
@@ -84,6 +87,7 @@ const SettingsPage = () => {
<MenuItem value="dark">Dark</MenuItem>
</Select>
</Stack>
<Stack spacing={theme.spacing(2)}>
<Typography>Language</Typography>
<LanguageSelector />
@@ -91,6 +95,30 @@ const SettingsPage = () => {
</Stack>
}
/>
<ConfigBox
title="Chart settings"
subtitle="Choose what type of Uptime chart you want to see on the dashboard and status page"
leftContent={<DummyChart type={chartType} />}
rightContent={
<Stack spacing={theme.spacing(2)}>
<Typography>Chart Type</Typography>
<Select
value={chartType}
onChange={(e: SelectChangeEvent<string>) => {
dispatch(setChartType(e.target.value as ChartType));
}}
>
<MenuItem value="heatmap">Heatmap</MenuItem>
<MenuItem value="histogram">Histogram</MenuItem>
</Select>
<Typography>
{chartType === "heatmap"
? "Heatmap: colored line indicates status"
: "Bar chart: color denotes status (up/down). height denotes response time"}
</Typography>
</Stack>
}
/>
{hasMaster && (
<SettingsForm
onSubmit={onSubmit}
+1
View File
@@ -3,6 +3,7 @@ import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import { Table, Pagination, StatusLabel } from "@/components/design-elements";
import { HeatmapResponseTime } from "@/components/common/HeatmapResponseTime";
import { HistogramResponseTime } from "@/components/common/HistogramResponseTime";
import type { Header } from "@/components/design-elements/Table";
import { ActionsMenu } from "@/components/actions-menu";
import { ArrowDown, ArrowUp } from "lucide-react";