recent checks
This commit is contained in:
1 parent
420ff292d9
commit
5731283c46
12 files changed
+72
-42
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import type { Check } from "@/Types/Check";
|
import type { CheckSnapshot } from "@/Types/Check";
|
||||||
import { getResponseColor } from "@/Utils/DataUtils";
|
import { getResponseColor } from "@/Utils/DataUtils";
|
||||||
import { HeatmapResponseTimeTooltip } from "@/Components/v2/common/charts/HeatmapResponseTimeTooltip";
|
import { HeatmapResponseTimeTooltip } from "@/Components/v2/common/charts/HeatmapResponseTimeTooltip";
|
||||||
import type { SxProps } from "@mui/material/styles";
|
import type { SxProps } from "@mui/material/styles";
|
||||||
@@ -13,7 +13,7 @@ interface PlaceholderCheck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface HeatmapResponseTimeProps {
|
interface HeatmapResponseTimeProps {
|
||||||
checks: Check[];
|
checks: CheckSnapshot[];
|
||||||
gap?: ResponsiveStyleValue<number | string>;
|
gap?: ResponsiveStyleValue<number | string>;
|
||||||
availabilityCellSx?: SxProps;
|
availabilityCellSx?: SxProps;
|
||||||
responseCellSx?: SxProps;
|
responseCellSx?: SxProps;
|
||||||
@@ -34,7 +34,7 @@ export const HeatmapResponseTime = ({
|
|||||||
|
|
||||||
const latestChecks = checks.slice(-25).reverse();
|
const latestChecks = checks.slice(-25).reverse();
|
||||||
|
|
||||||
let data: Array<Check | PlaceholderCheck>;
|
let data: Array<CheckSnapshot | PlaceholderCheck>;
|
||||||
if (latestChecks.length !== 25) {
|
if (latestChecks.length !== 25) {
|
||||||
const placeholders = Array(25 - latestChecks.length).fill({
|
const placeholders = Array(25 - latestChecks.length).fill({
|
||||||
status: "placeholder" as const,
|
status: "placeholder" as const,
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ import Stack from "@mui/material/Stack";
|
|||||||
import Tooltip from "@mui/material/Tooltip";
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { formatDateWithTz } from "@/Utils/TimeUtils";
|
import { formatDateWithTz } from "@/Utils/TimeUtils";
|
||||||
import type { Check } from "@/Types/Check";
|
import type { CheckSnapshot } from "@/Types/Check";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import type { RootState } from "@/Types/state";
|
import type { RootState } from "@/Types/state";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
type HeatmapCheck = Check | { status: "placeholder"; responseTime: 0; createdAt: "" };
|
type HeatmapCheck =
|
||||||
|
| CheckSnapshot
|
||||||
|
| { status: "placeholder"; responseTime: 0; createdAt: "" };
|
||||||
|
|
||||||
export const HeatmapResponseTimeTooltip = ({
|
export const HeatmapResponseTimeTooltip = ({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import type { ResponsiveStyleValue } from "@mui/system";
|
import type { ResponsiveStyleValue } from "@mui/system";
|
||||||
import type { Check } from "@/Types/Check";
|
import type { CheckSnapshot } from "@/Types/Check";
|
||||||
import { HeatmapResponseTimeTooltip } from "./HeatmapResponseTimeTooltip";
|
import { HeatmapResponseTimeTooltip } from "./HeatmapResponseTimeTooltip";
|
||||||
|
|
||||||
interface HistogramResponseTimeProps {
|
interface HistogramResponseTimeProps {
|
||||||
checks: Check[];
|
checks: CheckSnapshot[];
|
||||||
height?: ResponsiveStyleValue<number | string>;
|
height?: ResponsiveStyleValue<number | string>;
|
||||||
gap?: ResponsiveStyleValue<number | string>;
|
gap?: ResponsiveStyleValue<number | string>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,16 @@ import Stack from "@mui/material/Stack";
|
|||||||
import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip } from "recharts";
|
import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip } from "recharts";
|
||||||
import { HistogramPageSpeedTooltip } from "@/Components/v2/monitors/charts/HistogramPageSpeedTooltip";
|
import { HistogramPageSpeedTooltip } from "@/Components/v2/monitors/charts/HistogramPageSpeedTooltip";
|
||||||
import { useTheme } from "@mui/material/styles";
|
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 type { MonitorStatus } from "@/Types/Monitor";
|
||||||
|
|
||||||
import { getStatusColor } from "@/Utils/MonitorUtils";
|
import { getStatusColor } from "@/Utils/MonitorUtils";
|
||||||
|
|
||||||
const processData = (checks: Check[]) => {
|
const processData = (checks: CheckSnapshot[]) => {
|
||||||
if (checks.length === 0) return [];
|
if (checks.length === 0) return [];
|
||||||
const formattedData: { score: number; date: string }[] = [];
|
const formattedData: { score: number; date: string }[] = [];
|
||||||
|
|
||||||
const calculateScore = (entry: Check) => {
|
const calculateScore = (entry: CheckSnapshot) => {
|
||||||
const accessibility = entry?.accessibility || 0;
|
const accessibility = entry?.accessibility || 0;
|
||||||
const bestPractices = entry?.bestPractices || 0;
|
const bestPractices = entry?.bestPractices || 0;
|
||||||
const performance = entry?.performance || 0;
|
const performance = entry?.performance || 0;
|
||||||
@@ -32,7 +32,7 @@ export const HistogramPageSpeed = ({
|
|||||||
checks,
|
checks,
|
||||||
status,
|
status,
|
||||||
}: {
|
}: {
|
||||||
checks: Check[];
|
checks: CheckSnapshot[];
|
||||||
status: MonitorStatus;
|
status: MonitorStatus;
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
import { HistogramPageSpeedScoresTooltip } from "@/Components/v2/monitors";
|
import { HistogramPageSpeedScoresTooltip } from "@/Components/v2/monitors";
|
||||||
|
|
||||||
import { useTheme } from "@mui/material/styles";
|
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";
|
import type { Palette } from "@mui/material/styles";
|
||||||
type PaletteColorKey = Extract<
|
type PaletteColorKey = Extract<
|
||||||
keyof Palette,
|
keyof Palette,
|
||||||
@@ -52,7 +52,7 @@ export const HistogramPageSpeedDetails = ({
|
|||||||
checks,
|
checks,
|
||||||
range,
|
range,
|
||||||
}: {
|
}: {
|
||||||
checks: Check[];
|
checks: CheckSnapshot[];
|
||||||
range: string;
|
range: string;
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { BaseChart } from "@/Components/v2/design-elements";
|
import { BaseChart } from "@/Components/v2/design-elements";
|
||||||
import { FileText } from "lucide-react";
|
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 { Pie, PieChart, ResponsiveContainer, Label } from "recharts";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import Box from "@mui/material/Box";
|
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 { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [hoverTitle, setHoverTitle] = useState<string | null>(null);
|
const [hoverTitle, setHoverTitle] = useState<string | null>(null);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { BarChart3 } from "lucide-react";
|
|||||||
import { BaseChart } from "@/Components/v2/design-elements";
|
import { BaseChart } from "@/Components/v2/design-elements";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
||||||
import type { Check } from "@/Types/Check";
|
import type { CheckSnapshot } from "@/Types/Check";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { getPageSpeedPalette } from "@/Utils/MonitorUtils";
|
import { getPageSpeedPalette } from "@/Utils/MonitorUtils";
|
||||||
import { useTheme } from "@mui/material/styles";
|
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 theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
|||||||
@@ -48,15 +48,15 @@ const PageSpeedDetails = () => {
|
|||||||
monitorStats={monitorStats}
|
monitorStats={monitorStats}
|
||||||
/>
|
/>
|
||||||
<HistogramPageSpeedDetails
|
<HistogramPageSpeedDetails
|
||||||
checks={monitor?.checks || []}
|
checks={monitor?.recentChecks || []}
|
||||||
range="day"
|
range="day"
|
||||||
/>
|
/>
|
||||||
<Stack
|
<Stack
|
||||||
direction={{ xs: "column", md: "row" }}
|
direction={{ xs: "column", md: "row" }}
|
||||||
gap={theme.spacing(10)}
|
gap={theme.spacing(10)}
|
||||||
>
|
>
|
||||||
<PiePageSpeed latestCheck={monitor?.checks?.[0]} />
|
<PiePageSpeed latestCheck={monitor?.recentChecks?.[0]} />
|
||||||
<PiePageSpeedLegend latestCheck={monitor?.checks?.[0]} />
|
<PiePageSpeedLegend latestCheck={monitor?.recentChecks?.[0]} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</BasePage>
|
</BasePage>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ export const PageSpeedMonitorsTable = ({
|
|||||||
return (
|
return (
|
||||||
<Stack alignItems={"center"}>
|
<Stack alignItems={"center"}>
|
||||||
<HistogramPageSpeed
|
<HistogramPageSpeed
|
||||||
checks={row.checks}
|
checks={row.recentChecks}
|
||||||
status={row.status}
|
status={row.status}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -199,9 +199,9 @@ export const MonitorTable = ({
|
|||||||
content: t("pages.uptime.table.headers.responseTime"),
|
content: t("pages.uptime.table.headers.responseTime"),
|
||||||
render: (row) => {
|
render: (row) => {
|
||||||
if (chartType === "histogram") {
|
if (chartType === "histogram") {
|
||||||
return <HistogramResponseTime checks={row.checks} />;
|
return <HistogramResponseTime checks={row.recentChecks} />;
|
||||||
} else {
|
} else {
|
||||||
return <HeatmapResponseTime checks={row.checks} />;
|
return <HeatmapResponseTime checks={row.recentChecks} />;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -144,3 +144,5 @@ export interface ChecksResponse {
|
|||||||
checks: Check[];
|
checks: Check[];
|
||||||
checksCount: number;
|
checksCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type CheckSnapshot = Omit<Check, "metadata" | "ack" | "ackAt" | "expiry" | "updatedAt">;
|
||||||
+45
-19
@@ -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 type MonitorStatus = boolean | undefined;
|
||||||
|
|
||||||
export const MonitorTypes = [
|
export const MonitorTypes = [
|
||||||
@@ -13,28 +14,53 @@ export const MonitorTypes = [
|
|||||||
] as const;
|
] as const;
|
||||||
export type MonitorType = (typeof MonitorTypes)[number];
|
export type MonitorType = (typeof MonitorTypes)[number];
|
||||||
|
|
||||||
export interface Monitor {
|
export interface MonitorThresholds {
|
||||||
checks: Check[];
|
usage_cpu?: number;
|
||||||
createdAt: string;
|
usage_memory?: number;
|
||||||
createdBy: string;
|
usage_disk?: number;
|
||||||
interval: number;
|
usage_temperature?: number;
|
||||||
isActive: boolean;
|
|
||||||
latestChecks: Check[];
|
|
||||||
n: number;
|
|
||||||
name: string;
|
|
||||||
status: MonitorStatus;
|
|
||||||
type: string;
|
|
||||||
updatedAt: string;
|
|
||||||
updatedBy: string;
|
|
||||||
url: string;
|
|
||||||
id: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MonitorWithChecks extends Monitor {
|
export type MonitorMatchMethod = "equal" | "include" | "regex" | "";
|
||||||
checks: Check[];
|
|
||||||
|
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;
|
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 {
|
export interface MonitorsSummary {
|
||||||
totalMonitors: number;
|
totalMonitors: number;
|
||||||
upMonitors: number;
|
upMonitors: number;
|
||||||
@@ -45,7 +71,7 @@ export interface MonitorsSummary {
|
|||||||
export interface MonitorsWithChecksResponse {
|
export interface MonitorsWithChecksResponse {
|
||||||
count: number;
|
count: number;
|
||||||
monitors: MonitorWithChecks[];
|
monitors: MonitorWithChecks[];
|
||||||
summary: MonitorsSummary;
|
summary: MonitorsSummary | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MonitorStats {
|
export interface MonitorStats {
|
||||||
|
|||||||
Reference in new issue
Block a user