From 5731283c46275ce4925cdecc56f1c3f42c37bd99 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 27 Jan 2026 19:23:34 +0000 Subject: [PATCH] recent checks --- .../v2/common/charts/HeatmapResponseTime.tsx | 6 +- .../charts/HeatmapResponseTimeTooltip.tsx | 6 +- .../common/charts/HistogramResponseTime.tsx | 4 +- .../v2/monitors/charts/HistogramPageSpeed.tsx | 8 +-- .../charts/HistogramPageSpeedDetails.tsx | 4 +- .../v2/monitors/charts/PiePageSpeed.tsx | 4 +- .../v2/monitors/charts/PiePageSpeedLegend.tsx | 4 +- client/src/Pages/PageSpeed/Details/index.tsx | 6 +- .../Components/PageSpeedMonitorsTable.tsx | 2 +- .../Components/UptimeMonitorsTable.tsx | 4 +- client/src/Types/Check.ts | 2 + client/src/Types/Monitor.ts | 64 +++++++++++++------ 12 files changed, 72 insertions(+), 42 deletions(-) diff --git a/client/src/Components/v2/common/charts/HeatmapResponseTime.tsx b/client/src/Components/v2/common/charts/HeatmapResponseTime.tsx index 97289ba43..972291f57 100644 --- a/client/src/Components/v2/common/charts/HeatmapResponseTime.tsx +++ b/client/src/Components/v2/common/charts/HeatmapResponseTime.tsx @@ -1,6 +1,6 @@ import Box from "@mui/material/Box"; import { useTheme } from "@mui/material/styles"; -import type { Check } from "@/Types/Check"; +import type { CheckSnapshot } from "@/Types/Check"; import { getResponseColor } from "@/Utils/DataUtils"; import { HeatmapResponseTimeTooltip } from "@/Components/v2/common/charts/HeatmapResponseTimeTooltip"; import type { SxProps } from "@mui/material/styles"; @@ -13,7 +13,7 @@ interface PlaceholderCheck { } interface HeatmapResponseTimeProps { - checks: Check[]; + checks: CheckSnapshot[]; gap?: ResponsiveStyleValue; availabilityCellSx?: SxProps; responseCellSx?: SxProps; @@ -34,7 +34,7 @@ export const HeatmapResponseTime = ({ const latestChecks = checks.slice(-25).reverse(); - let data: Array; + let data: Array; if (latestChecks.length !== 25) { const placeholders = Array(25 - latestChecks.length).fill({ status: "placeholder" as const, diff --git a/client/src/Components/v2/common/charts/HeatmapResponseTimeTooltip.tsx b/client/src/Components/v2/common/charts/HeatmapResponseTimeTooltip.tsx index 7e9ae4470..e928269ce 100644 --- a/client/src/Components/v2/common/charts/HeatmapResponseTimeTooltip.tsx +++ b/client/src/Components/v2/common/charts/HeatmapResponseTimeTooltip.tsx @@ -2,12 +2,14 @@ import Stack from "@mui/material/Stack"; import Tooltip from "@mui/material/Tooltip"; import Typography from "@mui/material/Typography"; import { formatDateWithTz } from "@/Utils/TimeUtils"; -import type { Check } from "@/Types/Check"; +import type { CheckSnapshot } from "@/Types/Check"; import { useTheme } from "@mui/material/styles"; import { useSelector } from "react-redux"; import type { RootState } from "@/Types/state"; import { useTranslation } from "react-i18next"; -type HeatmapCheck = Check | { status: "placeholder"; responseTime: 0; createdAt: "" }; +type HeatmapCheck = + | CheckSnapshot + | { status: "placeholder"; responseTime: 0; createdAt: "" }; export const HeatmapResponseTimeTooltip = ({ children, diff --git a/client/src/Components/v2/common/charts/HistogramResponseTime.tsx b/client/src/Components/v2/common/charts/HistogramResponseTime.tsx index bbe3bd9d4..e3b82cd50 100644 --- a/client/src/Components/v2/common/charts/HistogramResponseTime.tsx +++ b/client/src/Components/v2/common/charts/HistogramResponseTime.tsx @@ -1,11 +1,11 @@ import Box from "@mui/material/Box"; import { useTheme } from "@mui/material/styles"; import type { ResponsiveStyleValue } from "@mui/system"; -import type { Check } from "@/Types/Check"; +import type { CheckSnapshot } from "@/Types/Check"; import { HeatmapResponseTimeTooltip } from "./HeatmapResponseTimeTooltip"; interface HistogramResponseTimeProps { - checks: Check[]; + checks: CheckSnapshot[]; height?: ResponsiveStyleValue; gap?: ResponsiveStyleValue; } diff --git a/client/src/Components/v2/monitors/charts/HistogramPageSpeed.tsx b/client/src/Components/v2/monitors/charts/HistogramPageSpeed.tsx index 1bcceebd1..f19e0323c 100644 --- a/client/src/Components/v2/monitors/charts/HistogramPageSpeed.tsx +++ b/client/src/Components/v2/monitors/charts/HistogramPageSpeed.tsx @@ -2,16 +2,16 @@ import Stack from "@mui/material/Stack"; import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip } from "recharts"; import { HistogramPageSpeedTooltip } from "@/Components/v2/monitors/charts/HistogramPageSpeedTooltip"; import { useTheme } from "@mui/material/styles"; -import type { Check } from "@/Types/Check"; +import type { CheckSnapshot } from "@/Types/Check"; import type { MonitorStatus } from "@/Types/Monitor"; import { getStatusColor } from "@/Utils/MonitorUtils"; -const processData = (checks: Check[]) => { +const processData = (checks: CheckSnapshot[]) => { if (checks.length === 0) return []; const formattedData: { score: number; date: string }[] = []; - const calculateScore = (entry: Check) => { + const calculateScore = (entry: CheckSnapshot) => { const accessibility = entry?.accessibility || 0; const bestPractices = entry?.bestPractices || 0; const performance = entry?.performance || 0; @@ -32,7 +32,7 @@ export const HistogramPageSpeed = ({ checks, status, }: { - checks: Check[]; + checks: CheckSnapshot[]; status: MonitorStatus; }) => { const theme = useTheme(); diff --git a/client/src/Components/v2/monitors/charts/HistogramPageSpeedDetails.tsx b/client/src/Components/v2/monitors/charts/HistogramPageSpeedDetails.tsx index 8fc39e16c..05bee8bc8 100644 --- a/client/src/Components/v2/monitors/charts/HistogramPageSpeedDetails.tsx +++ b/client/src/Components/v2/monitors/charts/HistogramPageSpeedDetails.tsx @@ -12,7 +12,7 @@ import { import { HistogramPageSpeedScoresTooltip } from "@/Components/v2/monitors"; import { useTheme } from "@mui/material/styles"; -import type { Check } from "@/Types/Check"; +import type { CheckSnapshot } from "@/Types/Check"; import type { Palette } from "@mui/material/styles"; type PaletteColorKey = Extract< keyof Palette, @@ -52,7 +52,7 @@ export const HistogramPageSpeedDetails = ({ checks, range, }: { - checks: Check[]; + checks: CheckSnapshot[]; range: string; }) => { const theme = useTheme(); diff --git a/client/src/Components/v2/monitors/charts/PiePageSpeed.tsx b/client/src/Components/v2/monitors/charts/PiePageSpeed.tsx index 1c58bb3f7..205ec9a96 100644 --- a/client/src/Components/v2/monitors/charts/PiePageSpeed.tsx +++ b/client/src/Components/v2/monitors/charts/PiePageSpeed.tsx @@ -1,6 +1,6 @@ import { BaseChart } from "@/Components/v2/design-elements"; import { FileText } from "lucide-react"; -import type { Check, CheckAudits } from "@/Types/Check"; +import type { CheckAudits, CheckSnapshot } from "@/Types/Check"; import { Pie, PieChart, ResponsiveContainer, Label } from "recharts"; import Typography from "@mui/material/Typography"; import Box from "@mui/material/Box"; @@ -30,7 +30,7 @@ const CenterLabel = ({ viewBox, value }: any) => { ); }; -export const PiePageSpeed = ({ latestCheck }: { latestCheck?: Check }) => { +export const PiePageSpeed = ({ latestCheck }: { latestCheck?: CheckSnapshot }) => { const { t } = useTranslation(); const theme = useTheme(); const [hoverTitle, setHoverTitle] = useState(null); diff --git a/client/src/Components/v2/monitors/charts/PiePageSpeedLegend.tsx b/client/src/Components/v2/monitors/charts/PiePageSpeedLegend.tsx index 5d220ae4e..b98b09b33 100644 --- a/client/src/Components/v2/monitors/charts/PiePageSpeedLegend.tsx +++ b/client/src/Components/v2/monitors/charts/PiePageSpeedLegend.tsx @@ -4,7 +4,7 @@ import { BarChart3 } from "lucide-react"; import { BaseChart } from "@/Components/v2/design-elements"; import Typography from "@mui/material/Typography"; -import type { Check } from "@/Types/Check"; +import type { CheckSnapshot } from "@/Types/Check"; import { useTranslation } from "react-i18next"; import { getPageSpeedPalette } from "@/Utils/MonitorUtils"; import { useTheme } from "@mui/material/styles"; @@ -56,7 +56,7 @@ const MetricBox = ({ ); }; -export const PiePageSpeedLegend = ({ latestCheck }: { latestCheck?: Check }) => { +export const PiePageSpeedLegend = ({ latestCheck }: { latestCheck?: CheckSnapshot }) => { const theme = useTheme(); const { t } = useTranslation(); diff --git a/client/src/Pages/PageSpeed/Details/index.tsx b/client/src/Pages/PageSpeed/Details/index.tsx index 2028f47c0..f1e4df4ba 100644 --- a/client/src/Pages/PageSpeed/Details/index.tsx +++ b/client/src/Pages/PageSpeed/Details/index.tsx @@ -48,15 +48,15 @@ const PageSpeedDetails = () => { monitorStats={monitorStats} /> - - + + ); diff --git a/client/src/Pages/PageSpeed/Monitors/Components/PageSpeedMonitorsTable.tsx b/client/src/Pages/PageSpeed/Monitors/Components/PageSpeedMonitorsTable.tsx index f38e1c706..37093c7a2 100644 --- a/client/src/Pages/PageSpeed/Monitors/Components/PageSpeedMonitorsTable.tsx +++ b/client/src/Pages/PageSpeed/Monitors/Components/PageSpeedMonitorsTable.tsx @@ -208,7 +208,7 @@ export const PageSpeedMonitorsTable = ({ return ( diff --git a/client/src/Pages/Uptime/Monitors/Components/UptimeMonitorsTable.tsx b/client/src/Pages/Uptime/Monitors/Components/UptimeMonitorsTable.tsx index c7f5c4c7f..cc225ad81 100644 --- a/client/src/Pages/Uptime/Monitors/Components/UptimeMonitorsTable.tsx +++ b/client/src/Pages/Uptime/Monitors/Components/UptimeMonitorsTable.tsx @@ -199,9 +199,9 @@ export const MonitorTable = ({ content: t("pages.uptime.table.headers.responseTime"), render: (row) => { if (chartType === "histogram") { - return ; + return ; } else { - return ; + return ; } }, }, diff --git a/client/src/Types/Check.ts b/client/src/Types/Check.ts index 0aa953dbb..19b9dd966 100644 --- a/client/src/Types/Check.ts +++ b/client/src/Types/Check.ts @@ -144,3 +144,5 @@ export interface ChecksResponse { checks: Check[]; checksCount: number; } + +export type CheckSnapshot = Omit; diff --git a/client/src/Types/Monitor.ts b/client/src/Types/Monitor.ts index 6baca2845..d4dcf5a38 100644 --- a/client/src/Types/Monitor.ts +++ b/client/src/Types/Monitor.ts @@ -1,4 +1,5 @@ -import type { Check, GroupedCheck } from "@/Types/Check"; +import type { GroupedCheck } from "@/Types/Check"; +import type { CheckSnapshot } from "@/Types/Check"; export type MonitorStatus = boolean | undefined; export const MonitorTypes = [ @@ -13,28 +14,53 @@ export const MonitorTypes = [ ] as const; export type MonitorType = (typeof MonitorTypes)[number]; -export interface Monitor { - checks: Check[]; - createdAt: string; - createdBy: string; - interval: number; - isActive: boolean; - latestChecks: Check[]; - n: number; - name: string; - status: MonitorStatus; - type: string; - updatedAt: string; - updatedBy: string; - url: string; - id: string; +export interface MonitorThresholds { + usage_cpu?: number; + usage_memory?: number; + usage_disk?: number; + usage_temperature?: number; } -export interface MonitorWithChecks extends Monitor { - checks: Check[]; +export type MonitorMatchMethod = "equal" | "include" | "regex" | ""; + +export interface Monitor { + id: string; + userId: string; + teamId: string; + name: string; + description?: string; + status?: boolean; + statusWindow: boolean[]; + statusWindowSize: number; + statusWindowThreshold: number; + type: MonitorType; + ignoreTlsErrors: boolean; + jsonPath?: string; + expectedValue?: string; + matchMethod?: MonitorMatchMethod; + url: string; + port?: number; + isActive: boolean; + interval: number; uptimePercentage?: number; + notifications: string[]; + secret?: string; + thresholds?: MonitorThresholds; + alertThreshold: number; + cpuAlertThreshold: number; + memoryAlertThreshold: number; + diskAlertThreshold: number; + tempAlertThreshold: number; + selectedDisks: string[]; + gameId?: string; + group: string | null; + recentChecks: CheckSnapshot[]; + createdAt: string; + updatedAt: string; } +export type MonitorWithChecks = Monitor; + export interface MonitorsSummary { totalMonitors: number; upMonitors: number; @@ -45,7 +71,7 @@ export interface MonitorsSummary { export interface MonitorsWithChecksResponse { count: number; monitors: MonitorWithChecks[]; - summary: MonitorsSummary; + summary: MonitorsSummary | null; } export interface MonitorStats {