Virtualize All Systems table to improve performance with hundreds of systems (#1100)

- Also truncate long system names in tables and alerts sheet. (#1104)
This commit is contained in:
henrygd
2025-08-29 16:16:45 -04:00
parent 0e95caaee9
commit 96f441de40
20 changed files with 176 additions and 175 deletions

View File

@@ -1,5 +1,5 @@
import { ChartTimes, SystemRecord, UserSettings } from "@/types"
import { $alerts, $systems, $userSettings } from "./stores"
import { $alerts, $longestSystemNameLen, $systems, $userSettings } from "./stores"
import { toast } from "@/components/ui/use-toast"
import { t } from "@lingui/core/macro"
import { chartTimeData } from "./utils"
@@ -88,11 +88,29 @@ export const updateSystemList = (() => {
}
isFetchingSystems = true
try {
const records = await pb
let records = await pb
.collection<SystemRecord>("systems")
.getFullList({ sort: "+name", fields: "id,name,host,port,info,status" })
if (records.length) {
// records = [
// ...records,
// ...records,
// ...records,
// ...records,
// ...records,
// ...records,
// ...records,
// ...records,
// ...records,
// ]
// we need to loop once to get the longest name
let longestName = $longestSystemNameLen.get()
for (const { name } of records) {
if (name.length > longestName) {
$longestSystemNameLen.set(Math.min(20, name.length))
}
}
$systems.set(records)
} else {
verifyAuth()