diff --git a/internal/site/src/components/routes/system/smart-table.tsx b/internal/site/src/components/routes/system/smart-table.tsx index 40a923b9..e712624d 100644 --- a/internal/site/src/components/routes/system/smart-table.tsx +++ b/internal/site/src/components/routes/system/smart-table.tsx @@ -93,53 +93,15 @@ export const smartColumns: ColumnDef[] = [ }, ] -export type DiskInfo = { - id: string - system: string - device: string - model: string - capacity: string - capacityBytes: number - status: string - temperature: number - deviceType: string - powerOnHours?: number - powerCycles?: number - attributes?: SmartAttribute[] - updated: string -} - // Function to format capacity display function formatCapacity(bytes: number): string { const { value, unit } = formatBytes(bytes) return `${toFixedFloat(value, value >= 10 ? 1 : 2)} ${unit}` } -// Function to convert SmartDeviceRecord to DiskInfo -function convertSmartDeviceRecordToDiskInfo(records: SmartDeviceRecord[]): DiskInfo[] { - const unknown = "Unknown" - return records.map((record) => ({ - id: record.id, - system: record.system, - device: record.name || unknown, - model: record.model || unknown, - serialNumber: record.serial || unknown, - firmwareVersion: record.firmware || unknown, - capacity: record.capacity ? formatCapacity(record.capacity) : unknown, - capacityBytes: record.capacity || 0, - status: record.state || unknown, - temperature: record.temp || 0, - deviceType: record.type || unknown, - attributes: record.attributes, - updated: record.updated, - powerOnHours: record.hours, - powerCycles: record.cycles, - })) -} - const SMART_DEVICE_FIELDS = "id,system,name,model,state,capacity,temp,type,hours,cycles,updated" -export const columns: ColumnDef[] = [ +export const columns: ColumnDef[] = [ { id: "system", accessorFn: (record) => record.system, @@ -156,12 +118,12 @@ export const columns: ColumnDef[] = [ }, }, { - accessorKey: "device", - sortingFn: (a, b) => a.original.device.localeCompare(b.original.device), + accessorKey: "name", + sortingFn: (a, b) => a.original.name.localeCompare(b.original.name), header: ({ column }) => , - cell: ({ row }) => ( -
- {row.getValue("device")} + cell: ({ getValue }) => ( +
+ {getValue() as string}
), }, @@ -169,20 +131,20 @@ export const columns: ColumnDef[] = [ accessorKey: "model", sortingFn: (a, b) => a.original.model.localeCompare(b.original.model), header: ({ column }) => , - cell: ({ row }) => ( -
- {row.getValue("model")} + cell: ({ getValue }) => ( +
+ {getValue() as string}
), }, { accessorKey: "capacity", - sortingFn: (a, b) => a.original.capacityBytes - b.original.capacityBytes, + invertSorting: true, header: ({ column }) => , - cell: ({ getValue }) => {getValue() as string}, + cell: ({ getValue }) => {formatCapacity(getValue() as number)}, }, { - accessorKey: "status", + accessorKey: "state", header: ({ column }) => , cell: ({ getValue }) => { const status = getValue() as string @@ -194,8 +156,8 @@ export const columns: ColumnDef[] = [ }, }, { - accessorKey: "deviceType", - sortingFn: (a, b) => a.original.deviceType.localeCompare(b.original.deviceType), + accessorKey: "type", + sortingFn: (a, b) => a.original.type.localeCompare(b.original.type), header: ({ column }) => , cell: ({ getValue }) => (
@@ -206,7 +168,7 @@ export const columns: ColumnDef[] = [ ), }, { - accessorKey: "powerOnHours", + accessorKey: "hours", invertSorting: true, header: ({ column }) => ( @@ -226,7 +188,7 @@ export const columns: ColumnDef[] = [ }, }, { - accessorKey: "powerCycles", + accessorKey: "cycles", invertSorting: true, header: ({ column }) => ( @@ -240,7 +202,7 @@ export const columns: ColumnDef[] = [ }, }, { - accessorKey: "temperature", + accessorKey: "temp", invertSorting: true, header: ({ column }) => , cell: ({ getValue }) => { @@ -249,14 +211,14 @@ export const columns: ColumnDef[] = [ }, }, // { - // accessorKey: "serialNumber", - // sortingFn: (a, b) => a.original.serialNumber.localeCompare(b.original.serialNumber), + // accessorKey: "serial", + // sortingFn: (a, b) => a.original.serial.localeCompare(b.original.serial), // header: ({ column }) => , // cell: ({ getValue }) => {getValue() as string}, // }, // { - // accessorKey: "firmwareVersion", - // sortingFn: (a, b) => a.original.firmwareVersion.localeCompare(b.original.firmwareVersion), + // accessorKey: "firmware", + // sortingFn: (a, b) => a.original.firmware.localeCompare(b.original.firmware), // header: ({ column }) => , // cell: ({ getValue }) => {getValue() as string}, // }, @@ -275,7 +237,15 @@ export const columns: ColumnDef[] = [ }, ] -function HeaderButton({ column, name, Icon }: { column: Column; name: string; Icon: React.ElementType }) { +function HeaderButton({ + column, + name, + Icon, +}: { + column: Column + name: string + Icon: React.ElementType +}) { const isSorted = column.getIsSorted() return (