infra locale
This commit is contained in:
1 parent
64d1ba08f9
commit
63dd455e4a
8 files changed
+121
-45
No files matched your search
@@ -5,6 +5,7 @@ import prettyMilliseconds from "pretty-ms";
|
||||
import { getStatusPalette } from "@/utils/MonitorUtils";
|
||||
import { InfraDetailsGraphs } from "@/pages/infrastructure/InfraDetailsGraphs";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useGet, usePatch } from "@/hooks/UseApi";
|
||||
import { useState } from "react";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
@@ -25,6 +26,7 @@ import { config } from "@/config/index";
|
||||
const GLOBAL_REFRESH = config.GLOBAL_REFRESH;
|
||||
|
||||
const InfraDetailsPage = () => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
const { id } = useParams();
|
||||
const [range, setRange] = useState("2h");
|
||||
@@ -68,13 +70,13 @@ const InfraDetailsPage = () => {
|
||||
<Stack direction="row" gap={theme.spacing(8)} flexWrap={"wrap"}>
|
||||
<StatBox
|
||||
palette={palette}
|
||||
title="Active for"
|
||||
title={t("monitors.common.stats.activeFor")}
|
||||
subtitle={prettyMilliseconds(streakDuration, {
|
||||
secondsDecimalDigits: 0,
|
||||
})}
|
||||
/>
|
||||
<StatBox
|
||||
title="Last check"
|
||||
title={t("monitors.common.stats.lastCheck")}
|
||||
subtitle={
|
||||
lastChecked >= 0
|
||||
? `${prettyMilliseconds(lastChecked, {
|
||||
@@ -84,35 +86,40 @@ const InfraDetailsPage = () => {
|
||||
}
|
||||
/>
|
||||
<StatBox
|
||||
title="Last response time"
|
||||
title={t("monitors.common.stats.lastResponseTime")}
|
||||
subtitle={
|
||||
stats?.lastResponseTime ? `${stats?.lastResponseTime} ms` : "N/A"
|
||||
}
|
||||
/>
|
||||
<StatBox
|
||||
title="CPU (physical)"
|
||||
title={t("monitors.common.stats.cpuPhysical")}
|
||||
subtitle={getCores(checks[0]?.cpu?.physical_core)}
|
||||
/>
|
||||
<StatBox
|
||||
title="CPU (logical)"
|
||||
title={t("monitors.common.stats.cpuLogical")}
|
||||
subtitle={getCores(checks[0]?.cpu?.logical_core)}
|
||||
/>
|
||||
<StatBox
|
||||
title="CPU frequency"
|
||||
title={t("monitors.common.stats.cpuFrequency")}
|
||||
subtitle={getFrequency(checks[0]?.cpu?.current_frequency)}
|
||||
/>
|
||||
<StatBox
|
||||
title="Avg CPU temp"
|
||||
title={t("monitors.common.stats.cpuTemperature")}
|
||||
subtitle={getAvgTemp(checks[0]?.cpu?.temperature)}
|
||||
/>
|
||||
<StatBox
|
||||
title="Memory"
|
||||
title={t("monitors.common.stats.memory")}
|
||||
subtitle={getGbs(checks[0]?.memory?.total_bytes)}
|
||||
/>
|
||||
<StatBox title="Disk" subtitle={getDiskTotalGbs(checks[0]?.disk)} />
|
||||
<StatBox title="OS" subtitle={getOsAndPlatform(checks[0]?.host)} />
|
||||
<StatBox
|
||||
title={t("monitors.common.stats.disk")}
|
||||
subtitle={getDiskTotalGbs(checks[0]?.disk)}
|
||||
/>
|
||||
<StatBox
|
||||
title={t("monitors.common.stats.os")}
|
||||
subtitle={getOsAndPlatform(checks[0]?.host)}
|
||||
/>
|
||||
</Stack>
|
||||
{/* <Typography variant="h1">Infrastructure overview</Typography> */}
|
||||
|
||||
<InfraDetailsGauges checks={checks} />
|
||||
<HeaderRange loading={isValidating} range={range} setRange={setRange} />
|
||||
|
||||
@@ -3,6 +3,7 @@ import Typography from "@mui/material/Typography";
|
||||
import { BaseChart } from "@/components/monitors/Chart";
|
||||
import { Gauge } from "@/components/design-elements";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { getGbs, getFrequency } from "./InfraUtils";
|
||||
import type { IInfraCheck } from "@/types/check";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
@@ -42,6 +43,7 @@ const InfraDetailGauge = ({
|
||||
};
|
||||
|
||||
export const InfraDetailsGauges = ({ checks }: { checks: IInfraCheck[] }) => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
||||
return (
|
||||
@@ -51,30 +53,31 @@ export const InfraDetailsGauges = ({ checks }: { checks: IInfraCheck[] }) => {
|
||||
alignItems={"center"}
|
||||
>
|
||||
<InfraDetailGauge
|
||||
title="Memory Usage"
|
||||
title={t("monitors.infrastructure.gauges.memory.title")}
|
||||
progress={(checks[0]?.memory.usage_percent || 0) * 100}
|
||||
upperLabel="Used"
|
||||
upperLabel={t("monitors.infrastructure.gauges.memory.upperLabel")}
|
||||
upperValue={getGbs(checks[0]?.memory.used_bytes)}
|
||||
lowerLabel="Free"
|
||||
lowerLabel={t("monitors.infrastructure.gauges.memory.lowerLabel")}
|
||||
lowerValue={getGbs(checks[0]?.memory.total_bytes)}
|
||||
/>
|
||||
<InfraDetailGauge
|
||||
title="CPU Usage"
|
||||
title={t("monitors.infrastructure.gauges.cpu.title")}
|
||||
progress={(checks[0]?.cpu.usage_percent || 0) * 100}
|
||||
upperLabel="Current frequency"
|
||||
upperLabel={t("monitors.infrastructure.gauges.cpu.upperLabel")}
|
||||
upperValue={getFrequency(checks[0]?.cpu.current_frequency)}
|
||||
lowerLabel="Max Frequency"
|
||||
lowerLabel={t("monitors.infrastructure.gauges.cpu.lowerLabel")}
|
||||
lowerValue={getFrequency(checks[0]?.cpu.frequency)}
|
||||
/>
|
||||
{checks[0]?.disk?.map((disk, idx) => {
|
||||
return (
|
||||
<InfraDetailGauge
|
||||
key={disk.device + idx}
|
||||
title={`Disk ${idx} usage`}
|
||||
// title={`Disk ${idx} usage`}
|
||||
title={t("monitors.infrastructure.gauges.disk.title", { idx })}
|
||||
progress={(disk.usage_percent || 0) * 100}
|
||||
upperLabel="Used"
|
||||
upperLabel={t("monitors.infrastructure.gauges.disk.upperLabel")}
|
||||
upperValue={getGbs(disk.used_bytes)}
|
||||
lowerLabel="Free"
|
||||
lowerLabel={t("monitors.infrastructure.gauges.disk.lowerLabel")}
|
||||
lowerValue={getGbs(disk.total_bytes)}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import Grid from "@mui/material/Grid";
|
||||
import { HistogramInfrastructure } from "@/components/monitors";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { IInfraCheck } from "@/types/check";
|
||||
import { useMemo } from "react";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
||||
|
||||
const getChartConfigs = (theme: any, checks: IInfraCheck[]) => {
|
||||
const getChartConfigs = (theme: any, checks: IInfraCheck[], t: any) => {
|
||||
return [
|
||||
{
|
||||
title: t("common.charts.infrastructure.memory.title"),
|
||||
type: "memory",
|
||||
dataKeys: ["memory.usage_percent"],
|
||||
strokeColor: theme.palette.primary.main,
|
||||
@@ -17,6 +19,7 @@ const getChartConfigs = (theme: any, checks: IInfraCheck[]) => {
|
||||
idx: null,
|
||||
},
|
||||
{
|
||||
title: t("common.charts.infrastructure.cpu.title"),
|
||||
type: "cpu",
|
||||
dataKeys: ["cpu.used_percent"],
|
||||
strokeColor: theme.palette.success.main,
|
||||
@@ -25,6 +28,7 @@ const getChartConfigs = (theme: any, checks: IInfraCheck[]) => {
|
||||
idx: null,
|
||||
},
|
||||
{
|
||||
title: t("common.charts.infrastructure.temp.title"),
|
||||
type: "temp",
|
||||
dataKeys: ["avg_temp"],
|
||||
strokeColor: theme.palette.error.main,
|
||||
@@ -33,6 +37,7 @@ const getChartConfigs = (theme: any, checks: IInfraCheck[]) => {
|
||||
idx: null,
|
||||
},
|
||||
...(checks[0]?.disk?.map((_, idx) => ({
|
||||
title: t("common.charts.infrastructure.disk.title", { idx }),
|
||||
type: "disk",
|
||||
dataKeys: [`disk[${idx}].usage_percent`],
|
||||
strokeColor: theme.palette.warning.main,
|
||||
@@ -52,9 +57,10 @@ export const InfraDetailsGraphs = ({
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
||||
const { t } = useTranslation();
|
||||
const chartConfigs = useMemo(
|
||||
() => getChartConfigs(theme, checks),
|
||||
[theme, checks]
|
||||
() => getChartConfigs(theme, checks, t),
|
||||
[theme, checks, t]
|
||||
);
|
||||
return (
|
||||
<Grid container spacing={theme.spacing(8)}>
|
||||
@@ -66,7 +72,8 @@ export const InfraDetailsGraphs = ({
|
||||
>
|
||||
<HistogramInfrastructure
|
||||
range={range}
|
||||
title={config.type}
|
||||
title={config.title}
|
||||
type={config.type}
|
||||
idx={config.idx}
|
||||
key={`${config.type}-${config.idx ?? ""}`}
|
||||
checks={checks}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { HistogramPageSpeedScores } from "@/components/monitors/HistogramPageSpe
|
||||
import { ChartPageSpeedReport } from "@/components/monitors/ChartPageSpeedReport";
|
||||
import { ChartPageSpeedReportLegend } from "@/components/monitors/ChartPageSpeedReportLegend";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useState } from "react";
|
||||
import { useParams } from "react-router";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
@@ -18,6 +19,7 @@ import { config } from "@/config/index";
|
||||
|
||||
const GLOBAL_REFRESH = config.GLOBAL_REFRESH;
|
||||
const PageSpeedDetailsPage = () => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
const { id } = useParams();
|
||||
const [range, setRange] = useState("2h");
|
||||
@@ -62,13 +64,13 @@ const PageSpeedDetailsPage = () => {
|
||||
<Stack direction="row" gap={theme.spacing(8)}>
|
||||
<StatBox
|
||||
palette={palette}
|
||||
title="Active for"
|
||||
title={t("monitors.common.stats.activeFor")}
|
||||
subtitle={prettyMilliseconds(streakDuration, {
|
||||
secondsDecimalDigits: 0,
|
||||
})}
|
||||
/>
|
||||
<StatBox
|
||||
title="Last check"
|
||||
title={t("monitors.common.stats.lastCheck")}
|
||||
subtitle={
|
||||
lastChecked >= 0
|
||||
? `${prettyMilliseconds(lastChecked, {
|
||||
@@ -78,7 +80,7 @@ const PageSpeedDetailsPage = () => {
|
||||
}
|
||||
/>
|
||||
<StatBox
|
||||
title="Last response time"
|
||||
title={t("monitors.common.stats.lastResponseTime")}
|
||||
subtitle={
|
||||
stats?.lastResponseTime ? `${stats?.lastResponseTime} ms` : "N/A"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user