diff --git a/packages/widgets/src/health-monitoring/system-health.tsx b/packages/widgets/src/health-monitoring/system-health.tsx index 1f0dd02e5..405838cac 100644 --- a/packages/widgets/src/health-monitoring/system-health.tsx +++ b/packages/widgets/src/health-monitoring/system-health.tsx @@ -13,7 +13,6 @@ import { Progress, Stack, Text, - Tooltip, } from "@mantine/core"; import { useDisclosure } from "@mantine/hooks"; import { @@ -33,6 +32,7 @@ import duration from "dayjs/plugin/duration"; import { clientApi } from "@homarr/api/client"; import { useRequiredBoard } from "@homarr/boards/context"; +import { humanFileSize } from "@homarr/common"; import type { TranslationFunction } from "@homarr/translation"; import { useI18n } from "@homarr/translation/client"; @@ -91,7 +91,7 @@ export const SystemHealthMonitoring = ({ return ( - {healthData.map(({ integrationId, integrationName, healthInfo, updatedAt }) => { + {healthData.map(({ integrationId, integrationName, healthInfo }) => { const disksData = matchFileSystemAndSmart(healthInfo.fileSystem, healthInfo.smart); const memoryUsage = formatMemoryUsage(healthInfo.memAvailableInBytes, healthInfo.memUsedInBytes); return ( @@ -196,11 +196,6 @@ export const SystemHealthMonitoring = ({ ))} - { - - {t("widget.healthMonitoring.popover.lastSeen", { lastSeen: dayjs(updatedAt).fromNow() })} - - } {options.fileSystem && disksData.map((disk) => { return ( @@ -214,7 +209,7 @@ export const SystemHealthMonitoring = ({ radius={board.itemRadius} p="xs" > - + - - - - {options.fahrenheit - ? `${(disk.temperature * 1.8 + 32).toFixed(1)}°F` - : `${disk.temperature}°C`} - - + {disk.temperature !== null && ( + + + + {options.fahrenheit + ? `${(disk.temperature * 1.8 + 32).toFixed(1)}°F` + : `${disk.temperature}°C`} + + + )} @@ -243,37 +240,26 @@ export const SystemHealthMonitoring = ({ - - - - - {t("widget.healthMonitoring.popover.used")} - - - - - = 1 - ? `${(Number(disk.available) / 1024 ** 4).toFixed(2)} TiB` - : `${(Number(disk.available) / 1024 ** 3).toFixed(2)} GiB` - } - > - - - {t("widget.healthMonitoring.popover.available")} - - - + + + + + + {t("widget.healthMonitoring.popover.used")} {formatFileSize(disk.used)} + + + {formatFileSize(disk.available)} {t("widget.healthMonitoring.popover.available")} + + ); @@ -307,6 +293,13 @@ export const progressColor = (percentage: number) => { else return "red"; }; +// Some integrations report file sizes as raw bytes (e.g. TrueNAS, Glances) while others pre-format +// them (e.g. Unraid, dashdot). Format the former and pass the latter through untouched. +const formatFileSize = (value: string) => { + const bytes = Number(value); + return Number.isFinite(bytes) ? humanFileSize(Math.round(bytes)) : value; +}; + interface FileSystem { deviceName: string; used: string; @@ -331,7 +324,7 @@ export const matchFileSystemAndSmart = (fileSystems: FileSystem[], smartData: Sm used: fileSystem.used, available: fileSystem.available, percentage: fileSystem.percentage, - temperature: smartDisk?.temperature ?? 0, + temperature: smartDisk?.temperature ?? null, overallStatus: smartDisk?.overallStatus ?? "", }; })