diff --git a/client/src/Components/v2/design-elements/Gauge.tsx b/client/src/Components/v2/design-elements/Gauge.tsx
index 34c57487d..4fee5386c 100644
--- a/client/src/Components/v2/design-elements/Gauge.tsx
+++ b/client/src/Components/v2/design-elements/Gauge.tsx
@@ -1,3 +1,5 @@
+import { BaseChart } from "@/Components/v2/design-elements";
+import Stack from "@mui/material/Stack";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
@@ -104,3 +106,50 @@ export const Gauge = ({
);
};
+
+export const DetailGauge = ({
+ title,
+ progress,
+ upperLabel,
+ upperValue,
+ lowerLabel,
+ lowerValue,
+}: {
+ title: string;
+ progress: number;
+ upperLabel?: string;
+ upperValue?: string | number;
+ lowerLabel?: string;
+ lowerValue?: string | number;
+}) => {
+ const theme = useTheme();
+ return (
+
+
+
+
+
+ {upperLabel}
+ {upperValue}
+
+
+ {lowerLabel}
+ {lowerValue}
+
+
+ );
+};
diff --git a/client/src/Pages/Infrastructure/Details/Components/Gauges.tsx b/client/src/Pages/Infrastructure/Details/Components/Gauges.tsx
index a72530db4..7e508a545 100644
--- a/client/src/Pages/Infrastructure/Details/Components/Gauges.tsx
+++ b/client/src/Pages/Infrastructure/Details/Components/Gauges.tsx
@@ -1,6 +1,5 @@
import Stack from "@mui/material/Stack";
-import Typography from "@mui/material/Typography";
-import { BaseChart, Gauge } from "@/Components/v2/design-elements";
+import { DetailGauge } from "@/Components/v2/design-elements";
import { useTranslation } from "react-i18next";
import { getGbs, getFrequency } from "@/Utils/InfraUtils";
@@ -8,53 +7,6 @@ import { useTheme } from "@mui/material";
import useMediaQuery from "@mui/material/useMediaQuery";
import type { CheckSnapshot } from "@/Types/Check";
-const InfraDetailGauge = ({
- title,
- progress,
- upperLabel,
- upperValue,
- lowerLabel,
- lowerValue,
-}: {
- title: string;
- progress: number;
- upperLabel?: string;
- upperValue?: string | number;
- lowerLabel?: string;
- lowerValue?: string | number;
-}) => {
- const theme = useTheme();
- return (
-
-
-
-
-
- {upperLabel}
- {upperValue}
-
-
- {lowerLabel}
- {lowerValue}
-
-
- );
-};
-
export const InfraDetailsGauges = ({
snapshot,
}: {
@@ -74,7 +26,7 @@ export const InfraDetailsGauges = ({
spacing={theme.spacing(8)}
alignItems={"center"}
>
-
-
{snapshot?.disk?.map((disk, idx) => {
return (
- {
- const theme = useTheme()
- return(
+const BaseContainer = ({ children }) => {
+ const theme = useTheme();
+ return (
{
[theme.breakpoints.down("md")]: {
width: `calc(50% - (1 * ${theme.spacing(8)} / 2))`,
},
- }}>
- {children}
+ }}
+ >
+ {children}
);
};
-const InfrastructureStyleGauge = ({ value, heading, metricOne, valueOne, metricTwo, valueTwo }) => {
+const InfrastructureStyleGauge = ({
+ value,
+ heading,
+ metricOne,
+ valueOne,
+ metricTwo,
+ valueTwo,
+}) => {
const theme = useTheme();
const MetricRow = ({ label, value }) => (
@@ -39,40 +47,58 @@ const InfrastructureStyleGauge = ({ value, heading, metricOne, valueOne, metricT
gap={theme.spacing(2)}
>
{label}
-
+
{value}
);
- return(
+ return (
-
+
-
-
+
+
{heading}
-
+
-
-
+
+
{metricTwo && valueTwo && (
-
+
)}
@@ -147,16 +173,16 @@ Gauges.propTypes = {
};
InfrastructureStyleGauge.propTypes = {
- value: PropTypes.number,
- heading: PropTypes.string,
- metricOne: PropTypes.string,
- valueOne: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
- metricTwo: PropTypes.string,
- valueTwo: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
+ value: PropTypes.number,
+ heading: PropTypes.string,
+ metricOne: PropTypes.string,
+ valueOne: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
+ metricTwo: PropTypes.string,
+ valueTwo: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
};
-
+
BaseContainer.propTypes = {
- children: PropTypes.node.isRequired,
+ children: PropTypes.node.isRequired,
};
export default Gauges;
diff --git a/client/src/Pages/Logs/StatGauges.tsx b/client/src/Pages/Logs/StatGauges.tsx
index e69de29bb..e78c89ced 100644
--- a/client/src/Pages/Logs/StatGauges.tsx
+++ b/client/src/Pages/Logs/StatGauges.tsx
@@ -0,0 +1,84 @@
+import Stack from "@mui/material/Stack";
+import { DetailGauge } from "@/Components/v2/design-elements";
+
+import prettyBytes from "pretty-bytes";
+import { useTranslation } from "react-i18next";
+import { useTheme } from "@mui/material";
+import type { Diagnostics } from "@/Types/Diagnostics";
+
+interface StatGaugesProps {
+ diagnostics: Diagnostics | null;
+}
+
+const getPercentage = (value: number, total: number) => {
+ if (!value || !total) return 0;
+ return (value / total) * 100;
+};
+
+const formatPerecentage = new Intl.NumberFormat("en-US", {
+ style: "percent",
+ minimumFractionDigits: 1,
+ maximumFractionDigits: 1,
+});
+
+export const StatGauges = ({ diagnostics }: StatGaugesProps) => {
+ const theme = useTheme();
+ const { t } = useTranslation();
+ if (!diagnostics) {
+ return null;
+ }
+
+ const heapTotalSize = getPercentage(
+ diagnostics?.v8HeapStats?.totalHeapSizeBytes,
+ diagnostics?.v8HeapStats?.heapSizeLimitBytes
+ );
+
+ const heapUsedSize = getPercentage(
+ diagnostics?.v8HeapStats?.usedHeapSizeBytes,
+ diagnostics?.v8HeapStats?.heapSizeLimitBytes
+ );
+
+ const actualHeapUsed = getPercentage(
+ diagnostics?.v8HeapStats?.usedHeapSizeBytes,
+ diagnostics?.v8HeapStats?.totalHeapSizeBytes
+ );
+
+ return (
+
+
+
+
+
+
+ );
+};
diff --git a/client/src/Pages/Logs/Stats.tsx b/client/src/Pages/Logs/Stats.tsx
index e4ffcca7a..429330873 100644
--- a/client/src/Pages/Logs/Stats.tsx
+++ b/client/src/Pages/Logs/Stats.tsx
@@ -26,29 +26,25 @@ export const Stats = ({ diagnostics }: StatsProps) => {
>
-
);
diff --git a/client/src/Pages/Logs/TabDiagnostics.tsx b/client/src/Pages/Logs/TabDiagnostics.tsx
index 94c17c2f1..fb18fa091 100644
--- a/client/src/Pages/Logs/TabDiagnostics.tsx
+++ b/client/src/Pages/Logs/TabDiagnostics.tsx
@@ -1,5 +1,6 @@
import Stack from "@mui/material/Stack";
import { Stats } from "@/Pages/Logs/Stats";
+import { StatGauges } from "@/Pages/Logs/StatGauges";
import { useTheme } from "@mui/material";
import { useGet } from "@/Hooks/UseApi";
@@ -9,14 +10,15 @@ export const TabDiagnostics = () => {
const theme = useTheme();
const {
data: diagnostics,
- isLoading,
- error,
- refetch,
- } = useGet("/diagnostic/system");
+ isLoading: _isLoading,
+ error: _error,
+ refetch: _refetch,
+ } = useGet("/diagnostic/system", {}, { refreshInterval: 5000 });
return (
+
);
};