From ad24484caabf5dfd4bd02cdfa4561dbd70aac3b5 Mon Sep 17 00:00:00 2001 From: Matthew D'Souza <64600706+matth3wdsouza@users.noreply.github.com> Date: Sun, 6 Sep 2026 00:14:03 +0530 Subject: [PATCH] feat(site): display NVMe data units as human-readable GB/TB (#2303) --- .../src/components/routes/system/smart-table.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/site/src/components/routes/system/smart-table.tsx b/internal/site/src/components/routes/system/smart-table.tsx index d6ec6730..2efeb791 100644 --- a/internal/site/src/components/routes/system/smart-table.tsx +++ b/internal/site/src/components/routes/system/smart-table.tsx @@ -75,7 +75,12 @@ export const smartColumns: ColumnDef[] = [ header: "Name", }, { - accessorFn: (row) => row.rs || row.rv?.toString(), + accessorFn: (row) => { + if (row.n === "DataUnitsWritten" || row.n === "DataUnitsRead") { + return formatDataUnits(Number(row.rv ?? 0)) + } + return row.rs || row.rv?.toString() + }, header: "Value", }, { @@ -103,6 +108,12 @@ function formatCapacity(bytes: number): string { return `${toFixedFloat(value, value >= 10 ? 1 : 2)} ${unit}` } +// Function to format NVMe data units +// (1 unit = 1000 * 512 bytes) as a human-readable size +function formatDataUnits(units: number): string { + return formatCapacity(units * 1000 * 512) +} + const SMART_DEVICE_FIELDS = "id,system,name,model,state,capacity,temp,type,hours,cycles,updated" export const createColumns = (