[Feature] Add Status Filtering to Systems Table (#927)

This commit is contained in:
Sven van Ginkel
2025-08-28 23:30:44 +02:00
committed by GitHub
parent 50d2406423
commit a989d121d3
6 changed files with 255 additions and 98 deletions

View File

@@ -57,7 +57,7 @@ export const updateSystemList = (() => {
try {
const records = await pb
.collection<SystemRecord>("systems")
.getFullList({ sort: "+name", fields: "id,name,host,port,info,status" })
.getFullList({ sort: "+name", fields: "id,name,host,port,info,status,updated" })
if (records.length) {
$systems.set(records)
@@ -357,6 +357,20 @@ export const chartMargin = { top: 12 }
*/
export const getHostDisplayValue = (system: SystemRecord): string => system.host.slice(system.host.lastIndexOf("/") + 1)
export function formatUptimeString(uptimeSeconds: number): string {
if (!uptimeSeconds || isNaN(uptimeSeconds)) return "";
if (uptimeSeconds < 3600) {
const mins = Math.trunc(uptimeSeconds / 60);
return mins === 1 ? "1 minute" : `${mins} minutes`;
} else if (uptimeSeconds < 172800) {
const hours = Math.trunc(uptimeSeconds / 3600);
return hours === 1 ? "1 hour" : `${hours} hours`;
} else {
const days = Math.trunc(uptimeSeconds / 86400);
return days === 1 ? "1 day" : `${days} days`;
}
}
/** Generate a random token for the agent */
export const generateToken = () => {
try {