mirror of
https://github.com/henrygd/beszel.git
synced 2026-04-05 04:21:50 +02:00
feat: add uptime to table (#1719)
This commit is contained in:
@@ -8,6 +8,7 @@ import type { ClassValue } from "clsx"
|
|||||||
import {
|
import {
|
||||||
ArrowUpDownIcon,
|
ArrowUpDownIcon,
|
||||||
ChevronRightSquareIcon,
|
ChevronRightSquareIcon,
|
||||||
|
ClockArrowUp,
|
||||||
CopyIcon,
|
CopyIcon,
|
||||||
CpuIcon,
|
CpuIcon,
|
||||||
HardDriveIcon,
|
HardDriveIcon,
|
||||||
@@ -34,6 +35,7 @@ import {
|
|||||||
formatTemperature,
|
formatTemperature,
|
||||||
getMeterState,
|
getMeterState,
|
||||||
parseSemVer,
|
parseSemVer,
|
||||||
|
secondsToString,
|
||||||
} from "@/lib/utils"
|
} from "@/lib/utils"
|
||||||
import { batteryStateTranslations } from "@/lib/i18n"
|
import { batteryStateTranslations } from "@/lib/i18n"
|
||||||
import type { SystemRecord } from "@/types"
|
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,
|
accessorFn: ({ info }) => info.v,
|
||||||
id: "agent",
|
id: "agent",
|
||||||
|
|||||||
Reference in New Issue
Block a user