ts errors

This commit is contained in:
Alex Holliday committed 2026-01-06 20:55:27 +00:00
1 parent 51081a6a0e
commit ba7cc3bb0c
13 files changed
+34 -58

No files matched your search

@@ -1,12 +1,12 @@
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 { ICheck } from "@/types/check"; import type { Check } from "@/types/check";
import { getResponseColor } from "@/utils/DataUtils"; import { getResponseColor } from "@/utils/DataUtils";
import { HeatmapResponseTimeTooltip } from "./HeatmapResponseTimeTooltip"; import { HeatmapResponseTimeTooltip } from "./HeatmapResponseTimeTooltip";
import type { SxProps } from "@mui/material/styles"; import type { SxProps } from "@mui/material/styles";
import type { ResponsiveStyleValue } from "@mui/system"; import type { ResponsiveStyleValue } from "@mui/system";
interface HeatmapResponseTimeProps { interface HeatmapResponseTimeProps {
checks: ICheck[]; checks: Check[];
gap?: ResponsiveStyleValue<number | string>; gap?: ResponsiveStyleValue<number | string>;
availabilityCellSx?: SxProps; availabilityCellSx?: SxProps;
responseCellSx?: SxProps; responseCellSx?: SxProps;
@@ -27,7 +27,7 @@ export const HeatmapResponseTime = ({
const latestChecks = checks.slice(-25).reverse(); const latestChecks = checks.slice(-25).reverse();
let data: Array<ICheck | { status: "placeholder" }>; let data: Array<Check | { status: "placeholder" }>;
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,
@@ -57,7 +57,7 @@ export const HeatmapResponseTime = ({
const respBg = const respBg =
check.status === "placeholder" check.status === "placeholder"
? theme.palette.action.hover ? theme.palette.action.hover
: getResponseColor(check.responseTime, { : getResponseColor(check.responseTime || 0, {
start: theme.palette.success.main, start: theme.palette.success.main,
mid: theme.palette.warning.main, mid: theme.palette.warning.main,
end: theme.palette.error.main, end: theme.palette.error.main,
@@ -1,12 +1,12 @@
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 { ICheck } from "@/types/check"; import type { Check } from "@/types/check";
import { normalizeResponseTimes } from "@/utils/DataUtils"; import { normalizeResponseTimes } from "@/utils/DataUtils";
import { HeatmapResponseTimeTooltip } from "./HeatmapResponseTimeTooltip"; import { HeatmapResponseTimeTooltip } from "./HeatmapResponseTimeTooltip";
interface HistogramResponseTimeProps { interface HistogramResponseTimeProps {
checks: ICheck[]; checks: Check[];
height?: ResponsiveStyleValue<number | string>; height?: ResponsiveStyleValue<number | string>;
gap?: ResponsiveStyleValue<number | string>; gap?: ResponsiveStyleValue<number | string>;
} }
@@ -9,16 +9,16 @@ import {
import { HistogramPageSpeedTooltip } from "@/components/monitors/HistogramPageSpeedTooltip"; import { HistogramPageSpeedTooltip } from "@/components/monitors/HistogramPageSpeedTooltip";
import { useTheme } from "@mui/material/styles"; import { useTheme } from "@mui/material/styles";
import type { ICheck } from "@/types/check"; import type { Check } 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: ICheck[]) => { const processData = (checks: Check[]) => {
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: ICheck) => { const calculateScore = (entry: Check) => {
const accessibility = entry?.lighthouse?.accessibility || 0; const accessibility = entry?.lighthouse?.accessibility || 0;
const bestPractices = entry?.lighthouse?.bestPractices || 0; const bestPractices = entry?.lighthouse?.bestPractices || 0;
const performance = entry?.lighthouse?.performance || 0; const performance = entry?.lighthouse?.performance || 0;
@@ -41,7 +41,7 @@ export const HistogramPageSpeed = ({
checks, checks,
status, status,
}: { }: {
checks: ICheck[]; checks: Check[];
status: MonitorStatus; status: MonitorStatus;
}) => { }) => {
const theme = useTheme(); const theme = useTheme();
@@ -1,12 +1,12 @@
import Stack from "@mui/material/Stack"; import Stack from "@mui/material/Stack";
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 { ICheck } from "@/types/check"; import type { Check } from "@/types/check";
import { normalizeResponseTimes } from "@/utils/DataUtils"; import { normalizeResponseTimes } from "@/utils/DataUtils";
import { HeatmapResponseTimeTooltip } from "../common/HeatmapResponseTimeTooltip"; import { HeatmapResponseTimeTooltip } from "../common/HeatmapResponseTimeTooltip";
const BAR_HEIGHT = "50px"; const BAR_HEIGHT = "50px";
export const HistogramStatusPage = ({ checks }: { checks: ICheck[] }) => { export const HistogramStatusPage = ({ checks }: { checks: Check[] }) => {
const theme = useTheme(); const theme = useTheme();
const normalChecks = normalizeResponseTimes(checks, "responseTime"); const normalChecks = normalizeResponseTimes(checks, "responseTime");
let data = Array<any>(); let data = Array<any>();
@@ -6,7 +6,7 @@ import { usePatch } from "@/hooks/UseApi";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useTheme } from "@mui/material/styles"; import { useTheme } from "@mui/material/styles";
import type { ICheck } from "@/types/check"; import type { Check } from "@/types/check";
import type { Header } from "@/components/design-elements/Table"; import type { Header } from "@/components/design-elements/Table";
import type { IMonitor } from "@/types/monitor"; import type { IMonitor } from "@/types/monitor";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -23,7 +23,7 @@ export const DockerMonitorsTable = ({
setSelectedMonitor, setSelectedMonitor,
}: { }: {
monitors: IMonitor[]; monitors: IMonitor[];
checksMap: Record<string, ICheck[]>; checksMap: Record<string, Check[]>;
count: number; count: number;
page: number; page: number;
setPage: (page: number) => void; setPage: (page: number) => void;
@@ -12,7 +12,6 @@ import { formatDateWithTz } from "@/utils/TimeUtils";
import { useAppSelector } from "@/hooks/AppHooks"; import { useAppSelector } from "@/hooks/AppHooks";
import prettyMilliseconds from "pretty-ms"; import prettyMilliseconds from "pretty-ms";
import { getMonitorPath } from "@/utils/MonitorUtils"; import { getMonitorPath } from "@/utils/MonitorUtils";
import type { MonitorType } from "@/types/monitor";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
const IncidentDetailsPage = () => { const IncidentDetailsPage = () => {
@@ -12,7 +12,7 @@ import { useTheme } from "@mui/material/styles";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { usePatch } from "@/hooks/UseApi"; import { usePatch } from "@/hooks/UseApi";
import type { ICheck } from "@/types/check"; import type { Check } from "@/types/check";
import type { IMonitor } from "@/types/monitor"; import type { IMonitor } from "@/types/monitor";
import type { ActionMenuItem } from "@/components/actions-menu"; import type { ActionMenuItem } from "@/components/actions-menu";
@@ -32,7 +32,7 @@ export const InfraMonitorsTable = ({
setRowsPerPage, setRowsPerPage,
}: { }: {
monitors: IMonitor[]; monitors: IMonitor[];
checksMap: Record<string, ICheck[]>; checksMap: Record<string, Check[]>;
refetch: Function; refetch: Function;
setSelectedMonitor: Function; setSelectedMonitor: Function;
sortField: string; sortField: string;
@@ -13,7 +13,7 @@ import { useTheme } from "@mui/material/styles";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { usePatch } from "@/hooks/UseApi"; import { usePatch } from "@/hooks/UseApi";
import type { ICheck } from "@/types/check"; import type { Check } from "@/types/check";
import type { IMonitor } from "@/types/monitor"; import type { IMonitor } from "@/types/monitor";
import type { ActionMenuItem } from "@/components/actions-menu"; import type { ActionMenuItem } from "@/components/actions-menu";
@@ -33,7 +33,7 @@ export const PageSpeedMonitorTable = ({
setRowsPerPage, setRowsPerPage,
}: { }: {
monitors: IMonitor[]; monitors: IMonitor[];
checksMap: Record<string, ICheck[]>; checksMap: Record<string, Check[]>;
refetch: Function; refetch: Function;
setSelectedMonitor: Function; setSelectedMonitor: Function;
sortField: string; sortField: string;
+7 -7
View File
@@ -1,23 +1,23 @@
import { useMemo } from "react"; import { useMemo } from "react";
import type { ICheck } from "@/types/check"; import type { Check } from "@/types/check";
import { HeatmapResponseTime } from "@/components/common/HeatmapResponseTime"; import { HeatmapResponseTime } from "@/components/common/HeatmapResponseTime";
import { HistogramResponseTime } from "@/components/common/HistogramResponseTime"; import { HistogramResponseTime } from "@/components/common/HistogramResponseTime";
import type { ChartType } from "@/features/uiSlice"; import type { ChartType } from "@/features/uiSlice";
const buildDummyChecks = (): ICheck[] => { const buildDummyChecks = (): Check[] => {
const now = Date.now(); const now = Date.now();
const arr: ICheck[] = [] as any; const arr: Check[] = [] as any;
for (let i = 0; i < 25; i++) { for (let i = 0; i < 25; i++) {
const ms = Math.floor(50 + Math.random() * 800); const ms = Math.floor(50 + Math.random() * 800);
arr.push({ arr.push({
_id: `chk-${i}`, id: `chk-${i}`,
metadata: { monitorId: "m1", type: "http", teamId: "t1" }, monitorId: "m1",
type: "http",
teamId: "t1",
status: Math.random() > 0.3 ? "up" : "down", status: Math.random() > 0.3 ? "up" : "down",
message: "", message: "",
responseTime: ms, responseTime: ms,
normalResponseTime: 0,
httpStatusCode: 200, httpStatusCode: 200,
ack: false,
expiry: new Date(now - i * 60000).toISOString(), expiry: new Date(now - i * 60000).toISOString(),
createdAt: new Date(now - i * 60000).toISOString(), createdAt: new Date(now - i * 60000).toISOString(),
updatedAt: new Date(now - i * 60000).toISOString(), updatedAt: new Date(now - i * 60000).toISOString(),
+3 -3
View File
@@ -2,7 +2,7 @@ import { Table, Pagination, StatusLabel } from "@/components/design-elements";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import type { Header } from "@/components/design-elements/Table"; import type { Header } from "@/components/design-elements/Table";
import type { ICheck, IChecksWithCount } from "@/types/check"; import type { Check, IChecksWithCount } from "@/types/check";
import type { ApiResponse } from "@/types/api"; import type { ApiResponse } from "@/types/api";
import type { MonitorStatus } from "@/types/monitor"; import type { MonitorStatus } from "@/types/monitor";
@@ -14,7 +14,7 @@ import { formatDateWithTz } from "@/utils/TimeUtils";
import { useAppSelector } from "@/hooks/AppHooks"; import { useAppSelector } from "@/hooks/AppHooks";
const getHeaders = (t: Function, uiTimezone: string) => { const getHeaders = (t: Function, uiTimezone: string) => {
const headers: Header<ICheck>[] = [ const headers: Header<Check>[] = [
{ {
id: "status", id: "status",
content: t("common.table.headers.status"), content: t("common.table.headers.status"),
@@ -93,7 +93,7 @@ export const CheckTable = ({ monitorId }: { monitorId: string }) => {
headers={headers} headers={headers}
data={checks} data={checks}
onRowClick={(row) => { onRowClick={(row) => {
navigate(`/checks/${row._id}`); navigate(`/checks/${row.id}`);
}} }}
/> />
<Pagination <Pagination
@@ -14,7 +14,7 @@ import { useTheme } from "@mui/material/styles";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { usePatch } from "@/hooks/UseApi"; import { usePatch } from "@/hooks/UseApi";
import type { ICheck } from "@/types/check"; import type { Check } from "@/types/check";
import type { IMonitor } from "@/types/monitor"; import type { IMonitor } from "@/types/monitor";
import type { ActionMenuItem } from "@/components/actions-menu"; import type { ActionMenuItem } from "@/components/actions-menu";
import type { ChartType } from "@/features/uiSlice"; import type { ChartType } from "@/features/uiSlice";
@@ -35,7 +35,7 @@ export const MonitorTable = ({
setRowsPerPage, setRowsPerPage,
}: { }: {
monitors: IMonitor[]; monitors: IMonitor[];
checksMap: Record<string, ICheck[]>; checksMap: Record<string, Check[]>;
refetch: Function; refetch: Function;
setSelectedMonitor: Function; setSelectedMonitor: Function;
sortField: string; sortField: string;
+1 -24
View File
@@ -109,29 +109,6 @@ export interface ICaptureInfo {
mode?: string; mode?: string;
} }
export interface ICheck {
_id: string;
metadata: {
monitorId: string;
type: MonitorType;
teamId: string;
};
status: string;
message: string;
responseTime: number;
normalResponseTime?: number;
httpStatusCode: number;
ack: boolean;
expiry: string;
createdAt: string;
updatedAt: string;
timings: GotTimings;
lighthouse?: ICheckLighthouseFields;
system?: ISystemInfo;
// Present for docker monitor checks
dockerContainers?: IDockerContainerSummary[];
}
export interface Check { export interface Check {
id: string; id: string;
monitorId: string; monitorId: string;
@@ -226,7 +203,7 @@ export interface IDokcerCheck {
} }
export interface IChecksWithCount { export interface IChecksWithCount {
checks: ICheck[]; checks: Check[];
count: number; count: number;
} }
+3 -3
View File
@@ -1,4 +1,4 @@
import type { AggregateCheck, ICheck } from "@/types/check"; import type { AggregateCheck, Check } from "@/types/check";
import type { IMonitorStats } from "./monitorStats"; import type { IMonitorStats } from "./monitorStats";
export const MonitorTypes = [ export const MonitorTypes = [
@@ -26,7 +26,7 @@ export type MonitorStatus = (typeof MonitorStatuses)[number];
export interface IMonitor { export interface IMonitor {
id: string; id: string;
checks: ICheck[]; checks: Check[];
createdAt: string; createdAt: string;
createdBy: string; createdBy: string;
interval: number; interval: number;
@@ -57,7 +57,7 @@ export interface IMonitorWithStats {
upCount: number; upCount: number;
pausedCount: number; pausedCount: number;
monitors: IMonitor[]; monitors: IMonitor[];
checksMap: Record<string, ICheck[]>; checksMap: Record<string, Check[]>;
} }
export interface IMonitorWithMonitorStats { export interface IMonitorWithMonitorStats {