fix(system-disks): format absolute denominator with human-readable size (#5183)
This commit is contained in:
1 parent
7c10becc74
commit
85c460190c
1 file changed
+8
-2
@@ -4,6 +4,7 @@ import { Box, Card, Group, Stack, useMantineColorScheme } from "@mantine/core";
|
|||||||
|
|
||||||
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 { useI18n } from "@homarr/translation/client";
|
import { useI18n } from "@homarr/translation/client";
|
||||||
|
|
||||||
import type { WidgetComponentProps } from "../definition";
|
import type { WidgetComponentProps } from "../definition";
|
||||||
@@ -15,8 +16,13 @@ const getDisplayText = (item: { used: string; available: string; percentage: num
|
|||||||
switch (displayMode) {
|
switch (displayMode) {
|
||||||
case "percentage":
|
case "percentage":
|
||||||
return `${Math.round(item.percentage)}%`;
|
return `${Math.round(item.percentage)}%`;
|
||||||
case "absolute":
|
case "absolute": {
|
||||||
return `${item.used} / ${item.available}`;
|
const availableInBytes = Number(item.available);
|
||||||
|
const availableText = Number.isFinite(availableInBytes)
|
||||||
|
? humanFileSize(Math.round(availableInBytes))
|
||||||
|
: item.available;
|
||||||
|
return `${item.used} / ${availableText}`;
|
||||||
|
}
|
||||||
case "free":
|
case "free":
|
||||||
return `${Math.round(100 - item.percentage)}% free`;
|
return `${Math.round(100 - item.percentage)}% free`;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in new issue
Block a user