From 9483c456d4167802aaf1f85110df6d7b562d6b46 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Tue, 28 Nov 2023 15:50:23 -0500 Subject: [PATCH] fix(web): storage decimals (#5363) --- .../admin-page/server-stats/server-stats-panel.svelte | 3 ++- web/src/lib/utils/byte-units.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web/src/lib/components/admin-page/server-stats/server-stats-panel.svelte b/web/src/lib/components/admin-page/server-stats/server-stats-panel.svelte index a4f5274454..aabb86d88a 100644 --- a/web/src/lib/components/admin-page/server-stats/server-stats-panel.svelte +++ b/web/src/lib/components/admin-page/server-stats/server-stats-panel.svelte @@ -21,7 +21,8 @@ return '0'.repeat(zeroLength); }; - $: [statsUsage, statsUsageUnit] = getBytesWithUnit(stats.usage, 0); + const TiB = 1024 ** 4; + $: [statsUsage, statsUsageUnit] = getBytesWithUnit(stats.usage, stats.usage > TiB ? 2 : 0);
diff --git a/web/src/lib/utils/byte-units.ts b/web/src/lib/utils/byte-units.ts index 97afe1285e..4a41a23bc5 100644 --- a/web/src/lib/utils/byte-units.ts +++ b/web/src/lib/utils/byte-units.ts @@ -9,7 +9,7 @@ * @returns size (number) and unit (string) */ export function getBytesWithUnit(bytes: number, maxPrecision = 1): [number, string] { - const units = ['B', 'KiB', 'MiB', 'GiB']; + const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB']; let magnitude = 0; let remainder = bytes;