mirror of
https://github.com/henrygd/beszel.git
synced 2026-03-22 05:36:15 +01:00
feat: add uptime to table (#1719)
This commit is contained in:
@@ -8,6 +8,7 @@ import type { ClassValue } from "clsx"
|
||||
import {
|
||||
ArrowUpDownIcon,
|
||||
ChevronRightSquareIcon,
|
||||
ClockArrowUp,
|
||||
CopyIcon,
|
||||
CpuIcon,
|
||||
HardDriveIcon,
|
||||
@@ -34,6 +35,7 @@ import {
|
||||
formatTemperature,
|
||||
getMeterState,
|
||||
parseSemVer,
|
||||
secondsToString,
|
||||
} from "@/lib/utils"
|
||||
import { batteryStateTranslations } from "@/lib/i18n"
|
||||
import type { SystemRecord } from "@/types"
|
||||
@@ -373,6 +375,29 @@ export function SystemsTableColumns(viewMode: "table" | "grid"): ColumnDef<Syste
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorFn: ({ info }) => info.u || undefined,
|
||||
id: "uptime",
|
||||
name: () => t`Uptime`,
|
||||
size: 50,
|
||||
Icon: ClockArrowUp,
|
||||
header: sortableHeader,
|
||||
cell(info) {
|
||||
const uptime = info.getValue() as number
|
||||
if (!uptime) {
|
||||
return null
|
||||
}
|
||||
let formatted: string
|
||||
if (uptime < 3600) {
|
||||
formatted = secondsToString(uptime, "minute")
|
||||
} else if (uptime < 360000) {
|
||||
formatted = secondsToString(uptime, "hour")
|
||||
} else {
|
||||
formatted = secondsToString(uptime, "day")
|
||||
}
|
||||
return <span className="tabular-nums whitespace-nowrap">{formatted}</span>
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorFn: ({ info }) => info.v,
|
||||
id: "agent",
|
||||
|
||||
Reference in New Issue
Block a user