time formatting
This commit is contained in:
1 parent
1558b27497
commit
43ac5b57cf
5 files changed
+29
-15
No files matched your search
@@ -1,9 +1,9 @@
|
|||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import { StatBox } from "@/Components/v2/design-elements";
|
import { StatBox } from "@/Components/v2/design-elements";
|
||||||
|
|
||||||
|
import prettyMilliseconds from "pretty-ms";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import type { MonitorStats, Monitor } from "@/Types/Monitor";
|
import type { MonitorStats, Monitor } from "@/Types/Monitor";
|
||||||
import { getHumanReadableDuration } from "@/Utils/timeUtilsLegacy.js";
|
|
||||||
import { getStatusPalette } from "@/Utils/MonitorUtils";
|
import { getStatusPalette } from "@/Utils/MonitorUtils";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
@@ -32,11 +32,16 @@ export const MonitorStatBoxes = ({
|
|||||||
|
|
||||||
// Determine time since last check
|
// Determine time since last check
|
||||||
const timeOfLastCheck = monitorStats?.lastCheckTimestamp || 0;
|
const timeOfLastCheck = monitorStats?.lastCheckTimestamp || 0;
|
||||||
const timeSinceLastCheck = Date.now() - timeOfLastCheck;
|
const timeSinceLastCheck = Date.now() - timeOfLastCheck || 0;
|
||||||
|
|
||||||
const streakTime = getHumanReadableDuration(timeSinceLastFailure);
|
const options = {
|
||||||
|
secondsDecimalDigits: 0,
|
||||||
|
millisecondsDecimalDigits: 0,
|
||||||
|
};
|
||||||
|
|
||||||
const lastCheckTime = getHumanReadableDuration(timeSinceLastCheck);
|
const streakTime = prettyMilliseconds(timeSinceLastFailure, options);
|
||||||
|
|
||||||
|
const lastCheckTime = prettyMilliseconds(timeSinceLastCheck, options);
|
||||||
const palette = getStatusPalette(monitor?.status);
|
const palette = getStatusPalette(monitor?.status);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -55,7 +60,7 @@ export const MonitorStatBoxes = ({
|
|||||||
/>
|
/>
|
||||||
<StatBox
|
<StatBox
|
||||||
title={t("pages.common.monitors.statBoxes.lastResponseTime")}
|
title={t("pages.common.monitors.statBoxes.lastResponseTime")}
|
||||||
subtitle={monitorStats?.lastResponseTime + " ms"}
|
subtitle={prettyMilliseconds(monitorStats?.lastResponseTime ?? 0)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{monitor?.type === "http" && (
|
{monitor?.type === "http" && (
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { Incident, IncidentSummaryItem } from "@/Types/Incident";
|
import type { Incident, IncidentSummaryItem } from "@/Types/Incident";
|
||||||
import { getHumanReadableDuration } from "@/Utils/timeUtilsLegacy.js";
|
import prettyMilliseconds from "pretty-ms";
|
||||||
|
|
||||||
type IncidentLike = Pick<Incident, "startTime" | "endTime" | "status">;
|
type IncidentLike = Pick<Incident, "startTime" | "endTime" | "status">;
|
||||||
|
|
||||||
@@ -24,5 +24,8 @@ export const getIncidentsDuration = (incident: IncidentLike | IncidentSummaryIte
|
|||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
return getHumanReadableDuration(durationMs);
|
return prettyMilliseconds(durationMs, {
|
||||||
|
secondsDecimalDigits: 0,
|
||||||
|
millisecondsDecimalDigits: 0,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import prettyMilliseconds from "pretty-ms";
|
|
||||||
import { Table, ValueLabel } from "@/Components/v2/design-elements";
|
import { Table, ValueLabel } from "@/Components/v2/design-elements";
|
||||||
import { Pagination } from "@/Components/v2/design-elements/Table";
|
import { Pagination } from "@/Components/v2/design-elements/Table";
|
||||||
import { ActionsMenu } from "@/Components/v2/actions-menu";
|
import { ActionsMenu } from "@/Components/v2/actions-menu";
|
||||||
import { DialogInput } from "@/Components/v2/inputs/Dialog";
|
import { DialogInput } from "@/Components/v2/inputs/Dialog";
|
||||||
|
|
||||||
|
import prettyMilliseconds from "pretty-ms";
|
||||||
import { useTheme } from "@mui/material";
|
import { useTheme } from "@mui/material";
|
||||||
import type { Header } from "@/Components/v2/design-elements/Table";
|
import type { Header } from "@/Components/v2/design-elements/Table";
|
||||||
import type { ActionMenuItem } from "@/Components/v2/actions-menu";
|
import type { ActionMenuItem } from "@/Components/v2/actions-menu";
|
||||||
@@ -15,7 +15,6 @@ import { useSelector, useDispatch } from "react-redux";
|
|||||||
import type { RootState } from "@/Types/state";
|
import type { RootState } from "@/Types/state";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import { setRowsPerPage } from "@/Features/UI/uiSlice";
|
import { setRowsPerPage } from "@/Features/UI/uiSlice";
|
||||||
import { formatDurationRounded } from "@/Utils/timeUtilsLegacy";
|
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useDelete, usePatch } from "@/Hooks/UseApi";
|
import { useDelete, usePatch } from "@/Hooks/UseApi";
|
||||||
@@ -153,7 +152,9 @@ export const MaintenanceWindowTable = ({
|
|||||||
id: "repeat",
|
id: "repeat",
|
||||||
content: t("pages.maintenanceWindow.table.headers.repeat"),
|
content: t("pages.maintenanceWindow.table.headers.repeat"),
|
||||||
render: (row) =>
|
render: (row) =>
|
||||||
row.repeat === 0 ? t("common.labels.na") : formatDurationRounded(row.repeat),
|
row.repeat === 0
|
||||||
|
? t("common.labels.na")
|
||||||
|
: prettyMilliseconds(row.repeat, { verbose: true }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: "actions",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { useGet } from "@/Hooks/UseApi";
|
|||||||
import type { MonitorDetailsResponse } from "@/Types/Monitor";
|
import type { MonitorDetailsResponse } from "@/Types/Monitor";
|
||||||
import type { ChecksResponse } from "@/Types/Check";
|
import type { ChecksResponse } from "@/Types/Check";
|
||||||
import type { RootState } from "@/Types/state";
|
import type { RootState } from "@/Types/state";
|
||||||
import { formatDateWithTz } from "@/Utils/timeUtilsLegacy";
|
import { formatDateWithTz } from "@/Utils/TimeUtils";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
|
|
||||||
const certificateDateFormat = "MMM D, YYYY h A";
|
const certificateDateFormat = "MMM D, YYYY h A";
|
||||||
|
|||||||
@@ -55,10 +55,15 @@ class DiagnosticService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const used = process.memoryUsage();
|
const used = process.memoryUsage();
|
||||||
const memoryUsage: Record<string, number> = {};
|
|
||||||
for (const key of Object.keys(used) as Array<keyof NodeJS.MemoryUsage>) {
|
// In MB
|
||||||
memoryUsage[`${key}Mb`] = Math.round((used[key] / 1024 / 1024) * 100) / 100; // MB
|
const memoryUsage: Record<keyof NodeJS.MemoryUsage, number> = {
|
||||||
}
|
rss: Math.round((used.rss / 1024 / 1024) * 100) / 100,
|
||||||
|
heapTotal: Math.round((used.heapTotal / 1024 / 1024) * 100) / 100,
|
||||||
|
heapUsed: Math.round((used.heapUsed / 1024 / 1024) * 100) / 100,
|
||||||
|
external: Math.round((used.external / 1024 / 1024) * 100) / 100,
|
||||||
|
arrayBuffers: Math.round((used.arrayBuffers / 1024 / 1024) * 100) / 100,
|
||||||
|
};
|
||||||
|
|
||||||
// CPU Usage
|
// CPU Usage
|
||||||
const cpuMetrics = await this.getCPUUsage();
|
const cpuMetrics = await this.getCPUUsage();
|
||||||
|
|||||||
Reference in new issue
Block a user