infra locale

This commit is contained in:
Alex Holliday committed 2025-12-11 13:30:43 -08:00
1 parent 64d1ba08f9
commit 63dd455e4a
8 files changed
+121 -45

No files matched your search

@@ -8,6 +8,7 @@ import { useTheme } from "@mui/material/styles";
import { alpha } from "@mui/material/styles";
import { useState } from "react";
import Tooltip from "@mui/material/Tooltip";
import { useTranslation } from "react-i18next";
const CenterLabel = ({ viewBox, value }: any) => {
const { cx, cy } = viewBox;
@@ -21,15 +22,16 @@ const CenterLabel = ({ viewBox, value }: any) => {
};
export const ChartPageSpeedReport = ({ latestCheck }: { latestCheck: any }) => {
const { t } = useTranslation();
const theme = useTheme();
const [hoverTitle, setHoverTitle] = useState<string | null>(null);
const LABELS: Record<string, string> = {
FCP: "First Contentful Paint",
SI: "Speed Index",
LCP: "Largest Contentful Paint",
TBT: "Total Blocking Time",
CLS: "Cumulative Layout Shift",
FCP: t("common.charts.pageSpeed.fcp"),
SI: t("common.charts.pageSpeed.si"),
LCP: t("common.charts.pageSpeed.lcp"),
TBT: t("common.charts.pageSpeed.tbt"),
CLS: t("common.charts.pageSpeed.cls"),
};
const metrics = [
{ key: "fcp", color: alpha("#1DE9B6", 0.6), weight: 0.1 },
@@ -80,7 +82,7 @@ export const ChartPageSpeedReport = ({ latestCheck }: { latestCheck: any }) => {
return (
<BaseChart
icon={<FileText size={20} strokeWidth={1.5} />}
title="Average PageSpeed score"
title={t("common.charts.pageSpeed.title")}
>
<Tooltip
open={Boolean(hoverTitle)}
@@ -4,6 +4,7 @@ import { BarChart3 } from "lucide-react";
import { BaseChart } from "@/components/monitors/Chart";
import Typography from "@mui/material/Typography";
import { useTranslation } from "react-i18next";
import { getPageSpeedPalette } from "@/utils/MonitorUtils";
import { useTheme } from "@mui/material/styles";
@@ -16,6 +17,7 @@ const MetricBox = ({
value: number;
weight: number;
}) => {
const { t } = useTranslation();
const theme = useTheme();
const palette = getPageSpeedPalette(value);
return (
@@ -32,7 +34,7 @@ const MetricBox = ({
<Typography textTransform={"uppercase"}>{label}</Typography>
<Stack direction="row" justifyContent={"space-between"}>
<Typography>{`${value}%`}</Typography>
<Typography>{`Weight: ${weight}%`}</Typography>
<Typography>{`${t("common.charts.pageSpeed.weight")}: ${weight}%`}</Typography>
</Stack>
</Stack>
<Box
@@ -53,31 +55,35 @@ export const ChartPageSpeedReportLegend = ({
latestCheck: any;
}) => {
const theme = useTheme();
const { t } = useTranslation();
return (
<BaseChart icon={<BarChart3 size={20} strokeWidth={1.5} />} title="PageSpeed report">
<BaseChart
icon={<BarChart3 size={20} strokeWidth={1.5} />}
title="PageSpeed report"
>
<Stack gap={theme.spacing(4)}>
<MetricBox
label="Speed index (SI)"
label={t("common.charts.pageSpeed.si")}
value={Math.floor(latestCheck?.si * 100 || 0 * 100)}
weight={10}
/>
<MetricBox
label="First contentful paint (FCP)"
label={t("common.charts.pageSpeed.fcp")}
value={Math.floor(latestCheck?.fcp * 100 || 0 * 100)}
weight={10}
/>
<MetricBox
label="Cumulative layout shift (CLS)"
label={t("common.charts.pageSpeed.cls")}
value={Math.floor(latestCheck?.cls * 100 || 0 * 100)}
weight={25}
/>
<MetricBox
label="Total blocking time (TBT)"
label={t("common.charts.pageSpeed.tbt")}
value={Math.floor(latestCheck?.tbt * 100 || 0 * 100)}
weight={30}
/>
<MetricBox
label="Largest contentful paint (LCP)"
label={t("common.charts.pageSpeed.lcp")}
value={Math.floor(latestCheck?.lcp * 100 || 0 * 100)}
weight={25}
/>
@@ -87,6 +87,7 @@ const createGradient = ({
export const HistogramInfrastructure = ({
range,
title,
type,
idx,
checks,
xKey,
@@ -101,6 +102,7 @@ export const HistogramInfrastructure = ({
}: {
range: string;
title: string;
type: string;
idx: number | null;
checks: IInfraCheck[];
xKey: string;
@@ -118,7 +120,7 @@ export const HistogramInfrastructure = ({
let avgTemps: { _id: string; avg_temp: number | null }[] = [];
let tempYDomain: number[] = [];
if (title === "temp") {
if (type === "temp") {
avgTemps = checks.map((check) => {
const temps = check.cpu.temperature || [];
if (temps.length === 0) return { ...check, avg_temp: null };
@@ -135,14 +137,14 @@ export const HistogramInfrastructure = ({
}
return (
<BaseChart icon={null} title={idx !== null ? title + ` ${idx}` : title}>
<BaseChart icon={null} title={title}>
<ResponsiveContainer width="100%" height={200}>
<AreaChart data={title === "temp" ? avgTemps : checks}>
<AreaChart data={type === "temp" ? avgTemps : checks}>
<XAxis
dataKey={xKey}
tick={(props) => <XTick {...props} range={range} />}
/>
<YAxis domain={title === "temp" ? tempYDomain : yDomain} />
<YAxis domain={type === "temp" ? tempYDomain : yDomain} />
<CartesianGrid
stroke={theme.palette.divider}