fix remaining type issues

This commit is contained in:
Alex Holliday committed 2026-01-05 21:12:28 +00:00
1 parent 9583332852
commit ce568424a3
13 files changed
+108 -40

No files matched your search

@@ -7,7 +7,7 @@ import { useTranslation } from "react-i18next";
import { getGbs, getFrequency } from "./InfraUtils";
import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";
import type { GroupedCheck } from "@/types/check";
import type { AggregateCheck } from "@/types/check";
const InfraDetailGauge = ({
title,
@@ -42,7 +42,11 @@ const InfraDetailGauge = ({
);
};
export const InfraDetailsGauges = ({ checks }: { checks: GroupedCheck[] }) => {
export const InfraDetailsGauges = ({
checks,
}: {
checks: AggregateCheck[];
}) => {
const { t } = useTranslation();
const theme = useTheme();
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
@@ -2,12 +2,12 @@ import Grid from "@mui/material/Grid";
import { HistogramInfrastructure } from "@/components/monitors";
import { useTranslation } from "react-i18next";
import type { GroupedCheck } from "@/types/check";
import type { AggregateCheck } from "@/types/check";
import { useMemo } from "react";
import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";
const getChartConfigs = (theme: any, checks: GroupedCheck[], t: any) => {
const getChartConfigs = (theme: any, checks: AggregateCheck[], t: any) => {
return [
{
title: t("common.charts.infrastructure.memory.title"),
@@ -52,7 +52,7 @@ export const InfraDetailsGraphs = ({
checks,
range,
}: {
checks: GroupedCheck[];
checks: AggregateCheck[];
range: string;
}) => {
const theme = useTheme();
@@ -4,17 +4,18 @@ import Grid from "@mui/material/Grid";
import { HistogramInfrastructure } from "@/components/monitors";
import { Select } from "@/components/inputs";
import type { IInfraCheck } from "@/types/check";
import type { AggregateCheck } from "@/types/check";
import { useMemo, useState, useEffect } from "react";
import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";
const getChartConfigs = (
theme: any,
checks: IInfraCheck[],
checks: AggregateCheck[],
selectedInterface: string
) => {
const idx = checks[0]?.net.findIndex((i) => i.name === selectedInterface);
const idx =
checks?.[0]?.net?.findIndex((i) => i.name === selectedInterface) ?? -1;
if (idx === -1) return [];
return [
{
@@ -56,7 +57,7 @@ export const InfraDetailsNetGraphs = ({
checks,
range,
}: {
checks: IInfraCheck[];
checks: AggregateCheck[];
range: string;
}) => {
const theme = useTheme();
@@ -68,11 +69,15 @@ export const InfraDetailsNetGraphs = ({
);
useEffect(() => {
if (checks[0]) {
if (checks?.[0]?.net && checks[0].net.length > 0) {
const firstNonLoopback = checks[0].net.find(
(iface) => iface.name !== "lo"
);
setSelectedInterface(firstNonLoopback?.name || "");
setSelectedInterface(
firstNonLoopback?.name || checks[0].net[0]?.name || ""
);
} else {
setSelectedInterface("");
}
}, [checks]);
return (
@@ -84,7 +89,7 @@ export const InfraDetailsNetGraphs = ({
value={selectedInterface}
onChange={(e) => setSelectedInterface(e.target.value)}
>
{checks[0]?.net.map((iface) => {
{checks?.[0]?.net?.map((iface) => {
return (
<MenuItem key={iface.name} value={iface.name}>
{iface.name}
@@ -108,7 +113,7 @@ export const InfraDetailsNetGraphs = ({
idx={config.idx}
key={`${config.type}-${config.idx ?? ""}`}
checks={checks}
xKey="_id"
xKey="bucketDate"
yDomain={config.yDomain}
dataKeys={config.dataKeys}
gradient={true}