login and other updates

This commit is contained in:
Henry Dollman
2024-07-13 16:25:27 -04:00
parent 86cfa5079e
commit 357e3ad5d7
8 changed files with 193 additions and 145 deletions

View File

@@ -1,48 +1,12 @@
import { Suspense, lazy, useEffect } from 'react'
import { $servers, pb } from '@/lib/stores'
// import { DataTable } from '../server-table/data-table'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card'
import { SystemRecord } from '@/types'
import { updateServerList } from '@/lib/utils'
const DataTable = lazy(() => import('../server-table/data-table'))
export default function () {
useEffect(() => {
document.title = 'Qoma Dashboard'
}, [])
useEffect(updateServerList, [])
useEffect(() => {
pb.collection<SystemRecord>('systems').subscribe('*', (e) => {
const curServers = $servers.get()
const newServers = []
console.log('e', e)
if (e.action === 'delete') {
for (const server of curServers) {
if (server.id !== e.record.id) {
newServers.push(server)
}
}
} else {
let found = 0
for (const server of curServers) {
if (server.id === e.record.id) {
found = newServers.push(e.record)
} else {
newServers.push(server)
}
}
if (!found) {
newServers.push(e.record)
}
}
$servers.set(newServers)
})
return () => {
pb.collection('systems').unsubscribe('*')
}
document.title = 'Dashboard / Qoma'
}, [])
return (

View File

@@ -71,7 +71,7 @@ export default function ServerDetail({ name }: { name: string }) {
// console.log('sctats', records)
setServerStats(records.items)
})
}, [server])
}, [server, servers])
// get cpu data
useEffect(() => {
@@ -100,16 +100,9 @@ export default function ServerDetail({ name }: { name: string }) {
}
// console.log('running')
const matchingServer = servers.find((s) => s.name === name) as SystemRecord
// console.log('found server', matchingServer)
setServer(matchingServer)
console.log('found server', matchingServer)
// pb.collection<SystemRecord>('systems')
// .getOne(serverId)
// .then((record) => {
// setServer(record)
// })
pb.collection<ContainerStatsRecord>('container_stats')
.getList(1, 60, {
filter: `system="${matchingServer.id}"`,