mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-16 21:14:23 +00:00
feat(site): display NVMe data units as human-readable GB/TB (#2303)
This commit is contained in:
@@ -75,7 +75,12 @@ export const smartColumns: ColumnDef<SmartAttribute>[] = [
|
||||
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 = (
|
||||
|
||||
Reference in New Issue
Block a user