fix(widgets): clean up health monitoring disk and size display (#6019)

This commit is contained in:
Afonso Jorge Ramos authored and GitHub committed 2026-06-20 11:47:38 +02:00
1 parent a19c9d88ca
commit e29c79a902
1 file changed
+40 -47
@@ -13,7 +13,6 @@ import {
Progress, Progress,
Stack, Stack,
Text, Text,
Tooltip,
} from "@mantine/core"; } from "@mantine/core";
import { useDisclosure } from "@mantine/hooks"; import { useDisclosure } from "@mantine/hooks";
import { import {
@@ -33,6 +32,7 @@ import duration from "dayjs/plugin/duration";
import { clientApi } from "@homarr/api/client"; import { clientApi } from "@homarr/api/client";
import { useRequiredBoard } from "@homarr/boards/context"; import { useRequiredBoard } from "@homarr/boards/context";
import { humanFileSize } from "@homarr/common";
import type { TranslationFunction } from "@homarr/translation"; import type { TranslationFunction } from "@homarr/translation";
import { useI18n } from "@homarr/translation/client"; import { useI18n } from "@homarr/translation/client";
@@ -91,7 +91,7 @@ export const SystemHealthMonitoring = ({
return ( return (
<Stack h="100%" gap="sm" className="health-monitoring"> <Stack h="100%" gap="sm" className="health-monitoring">
{healthData.map(({ integrationId, integrationName, healthInfo, updatedAt }) => { {healthData.map(({ integrationId, integrationName, healthInfo }) => {
const disksData = matchFileSystemAndSmart(healthInfo.fileSystem, healthInfo.smart); const disksData = matchFileSystemAndSmart(healthInfo.fileSystem, healthInfo.smart);
const memoryUsage = formatMemoryUsage(healthInfo.memAvailableInBytes, healthInfo.memUsedInBytes); const memoryUsage = formatMemoryUsage(healthInfo.memAvailableInBytes, healthInfo.memUsedInBytes);
return ( return (
@@ -196,11 +196,6 @@ export const SystemHealthMonitoring = ({
<GpuRing key={gpu.gpuId} gpu={gpu} isTiny={isTiny} fahrenheit={options.fahrenheit} /> <GpuRing key={gpu.gpuId} gpu={gpu} isTiny={isTiny} fahrenheit={options.fahrenheit} />
))} ))}
</Flex> </Flex>
{
<Text className="health-monitoring-status-update-time" c="dimmed" size="xs" ta="center">
{t("widget.healthMonitoring.popover.lastSeen", { lastSeen: dayjs(updatedAt).fromNow() })}
</Text>
}
{options.fileSystem && {options.fileSystem &&
disksData.map((disk) => { disksData.map((disk) => {
return ( return (
@@ -214,7 +209,7 @@ export const SystemHealthMonitoring = ({
radius={board.itemRadius} radius={board.itemRadius}
p="xs" p="xs"
> >
<Stack gap="sm"> <Stack gap="xs">
<Group <Group
className="health-monitoring-disk-status" className="health-monitoring-disk-status"
justify="space-between" justify="space-between"
@@ -228,14 +223,16 @@ export const SystemHealthMonitoring = ({
{disk.deviceName} {disk.deviceName}
</Text> </Text>
</Group> </Group>
<Group gap={4} wrap="nowrap"> {disk.temperature !== null && (
<IconTemperature className="health-monitoring-disk-temperature-icon" size="1rem" /> <Group gap={4} wrap="nowrap">
<Text className="health-monitoring-disk-temperature-value" size="xs"> <IconTemperature className="health-monitoring-disk-temperature-icon" size="1rem" />
{options.fahrenheit <Text className="health-monitoring-disk-temperature-value" size="xs">
? `${(disk.temperature * 1.8 + 32).toFixed(1)}°F` {options.fahrenheit
: `${disk.temperature}°C`} ? `${(disk.temperature * 1.8 + 32).toFixed(1)}°F`
</Text> : `${disk.temperature}°C`}
</Group> </Text>
</Group>
)}
<Group gap={4} wrap="nowrap"> <Group gap={4} wrap="nowrap">
<IconFileReport className="health-monitoring-disk-status-icon" size="1rem" /> <IconFileReport className="health-monitoring-disk-status-icon" size="1rem" />
<Text className="health-monitoring-disk-status-value" size="xs"> <Text className="health-monitoring-disk-status-value" size="xs">
@@ -243,37 +240,26 @@ export const SystemHealthMonitoring = ({
</Text> </Text>
</Group> </Group>
</Group> </Group>
<Progress.Root className="health-monitoring-disk-use" radius={board.itemRadius} h="md"> <Progress.Root className="health-monitoring-disk-use" radius={board.itemRadius} size="lg">
<Tooltip label={disk.used}> <Progress.Section
<Progress.Section value={disk.percentage}
value={disk.percentage} color={progressColor(disk.percentage)}
color={progressColor(disk.percentage)} className="health-monitoring-disk-use-percentage"
className="health-monitoring-disk-use-percentage" />
> <Progress.Section
<Progress.Label className="health-monitoring-disk-use-value" fz="xs"> className="health-monitoring-disk-available-percentage"
{t("widget.healthMonitoring.popover.used")} value={100 - disk.percentage}
</Progress.Label> color="default"
</Progress.Section> />
</Tooltip>
<Tooltip
label={
Number(disk.available) / 1024 ** 4 >= 1
? `${(Number(disk.available) / 1024 ** 4).toFixed(2)} TiB`
: `${(Number(disk.available) / 1024 ** 3).toFixed(2)} GiB`
}
>
<Progress.Section
className="health-monitoring-disk-available-percentage"
value={100 - disk.percentage}
color="default"
>
<Progress.Label className="health-monitoring-disk-available-value" fz="xs">
{t("widget.healthMonitoring.popover.available")}
</Progress.Label>
</Progress.Section>
</Tooltip>
</Progress.Root> </Progress.Root>
<Group justify="space-between" gap={8} wrap="nowrap">
<Text className="health-monitoring-disk-use-value" size="xs" c="dimmed">
{t("widget.healthMonitoring.popover.used")} {formatFileSize(disk.used)}
</Text>
<Text className="health-monitoring-disk-available-value" size="xs" c="dimmed">
{formatFileSize(disk.available)} {t("widget.healthMonitoring.popover.available")}
</Text>
</Group>
</Stack> </Stack>
</Card> </Card>
); );
@@ -307,6 +293,13 @@ export const progressColor = (percentage: number) => {
else return "red"; 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 { interface FileSystem {
deviceName: string; deviceName: string;
used: string; used: string;
@@ -331,7 +324,7 @@ export const matchFileSystemAndSmart = (fileSystems: FileSystem[], smartData: Sm
used: fileSystem.used, used: fileSystem.used,
available: fileSystem.available, available: fileSystem.available,
percentage: fileSystem.percentage, percentage: fileSystem.percentage,
temperature: smartDisk?.temperature ?? 0, temperature: smartDisk?.temperature ?? null,
overallStatus: smartDisk?.overallStatus ?? "", overallStatus: smartDisk?.overallStatus ?? "",
}; };
}) })