diff --git a/beszel/internal/agent/agent.go b/beszel/internal/agent/agent.go index dad4845..ec0c3b0 100644 --- a/beszel/internal/agent/agent.go +++ b/beszel/internal/agent/agent.go @@ -141,10 +141,10 @@ func (a *Agent) getSystemStats() (*system.Info, *system.Stats) { } systemInfo := &system.Info{ - Cpu: systemStats.Cpu, - MemPct: systemStats.MemPct, - DiskPct: systemStats.DiskPct, - Vers: beszel.Version, + Cpu: systemStats.Cpu, + MemPct: systemStats.MemPct, + DiskPct: systemStats.DiskPct, + AgentVersion: beszel.Version, } // add host info @@ -164,7 +164,6 @@ func (a *Agent) getSystemStats() (*system.Info, *system.Stats) { } return systemInfo, systemStats - } func (a *Agent) getDockerStats() ([]*container.Stats, error) { diff --git a/beszel/internal/entities/system/system.go b/beszel/internal/entities/system/system.go index 8fe23cc..154ab1a 100644 --- a/beszel/internal/entities/system/system.go +++ b/beszel/internal/entities/system/system.go @@ -41,11 +41,11 @@ type Info struct { Threads int `json:"t"` CpuModel string `json:"m"` // Os string `json:"o"` - Uptime uint64 `json:"u"` - Cpu float64 `json:"cpu"` - MemPct float64 `json:"mp"` - DiskPct float64 `json:"dp"` - Vers string `json:"v"` + Uptime uint64 `json:"u"` + Cpu float64 `json:"cpu"` + MemPct float64 `json:"mp"` + DiskPct float64 `json:"dp"` + AgentVersion string `json:"v"` } // Final data structure to return to the hub diff --git a/beszel/site/src/components/add-system.tsx b/beszel/site/src/components/add-system.tsx index 0732fc1..85f2567 100644 --- a/beszel/site/src/components/add-system.tsx +++ b/beszel/site/src/components/add-system.tsx @@ -14,7 +14,7 @@ import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { $publicKey, pb } from '@/lib/stores' import { Copy, Plus } from 'lucide-react' -import { useState, useRef, MutableRefObject, useEffect } from 'react' +import { useState, useRef, MutableRefObject } from 'react' import { useStore } from '@nanostores/react' import { copyToClipboard } from '@/lib/utils' @@ -38,16 +38,6 @@ export function AddSystemButton() { # FILESYSTEM: /dev/sda1 # set to the correct filesystem for disk I/O stats`) } - useEffect(() => { - if (publicKey || !open) { - return - } - // get public key - pb.send('/api/beszel/getkey', {}).then(({ key }) => { - $publicKey.set(key) - }) - }, [open]) - async function handleSubmit(e: SubmitEvent) { e.preventDefault() const formData = new FormData(e.target as HTMLFormElement) diff --git a/beszel/site/src/components/routes/home.tsx b/beszel/site/src/components/routes/home.tsx index 8516e72..60df5e7 100644 --- a/beszel/site/src/components/routes/home.tsx +++ b/beszel/site/src/components/routes/home.tsx @@ -1,30 +1,57 @@ import { Suspense, lazy, useEffect } from 'react' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card' +import { $hubVersion } from '@/lib/stores' +import { useStore } from '@nanostores/react' +import { GithubIcon } from 'lucide-react' +import { Separator } from '../ui/separator' const SystemsTable = lazy(() => import('../systems-table/systems-table')) export default function () { + const hubVersion = useStore($hubVersion) + useEffect(() => { document.title = 'Dashboard / Beszel' }, []) return ( - - - All Systems - - Updated in real time. Press{' '} - - K - {' '} - to open the command palette. - - - - - - - - + <> + + + All Systems + + Updated in real time. Press{' '} + + K + {' '} + to open the command palette. + + + + + + + + + {hubVersion && ( +
+ + GitHub + + + + Beszel {hubVersion} + +
+ )} + ) } diff --git a/beszel/site/src/components/systems-table/systems-table.tsx b/beszel/site/src/components/systems-table/systems-table.tsx index 6cadc01..1eb15bf 100644 --- a/beszel/site/src/components/systems-table/systems-table.tsx +++ b/beszel/site/src/components/systems-table/systems-table.tsx @@ -55,10 +55,10 @@ import { PauseCircleIcon, PlayCircleIcon, Trash2Icon, - Wifi, + WifiIcon, } from 'lucide-react' import { useMemo, useState } from 'react' -import { $systems, pb } from '@/lib/stores' +import { $hubVersion, $systems, pb } from '@/lib/stores' import { useStore } from '@nanostores/react' import { AddSystemButton } from '../add-system' import { cn, copyToClipboard, isReadOnlyUser } from '@/lib/utils' @@ -83,7 +83,12 @@ function CellFormatter(info: CellContext) { ) } -function sortableHeader(column: Column, name: string, Icon: any) { +function sortableHeader( + column: Column, + name: string, + Icon: any, + hideSortIcon = false +) { return ( ) } export default function SystemsTable() { const data = useStore($systems) + const hubVersion = useStore($hubVersion) const [sorting, setSorting] = useState([]) const [columnFilters, setColumnFilters] = useState([]) @@ -136,14 +142,6 @@ export default function SystemsTable() { }, header: ({ column }) => sortableHeader(column, 'System', Server), }, - { - accessorKey: 'info.v', - cell: (info) => { - return( -
{info.getValue() as string}
) - }, - header: ({ column }) => sortableHeader(column, 'Version', Wifi), - }, { accessorKey: 'info.cpu', cell: CellFormatter, @@ -159,6 +157,29 @@ export default function SystemsTable() { cell: CellFormatter, header: ({ column }) => sortableHeader(column, 'Disk', HardDrive), }, + { + accessorKey: 'info.v', + size: 50, + cell: (info) => { + const version = info.getValue() as string + if (!version || !hubVersion) { + return null + } + return ( + + + {info.getValue() as string} + + ) + }, + header: ({ column }) => sortableHeader(column, 'Agent', WifiIcon, true), + }, { id: 'actions', size: 120, diff --git a/beszel/site/src/lib/stores.ts b/beszel/site/src/lib/stores.ts index 19c2ccb..5dbdd79 100644 --- a/beszel/site/src/lib/stores.ts +++ b/beszel/site/src/lib/stores.ts @@ -20,5 +20,8 @@ export const $alerts = atom([] as AlertRecord[]) /** SSH public key */ export const $publicKey = atom('') +/** Beszel hub version */ +export const $hubVersion = atom('') + /** Chart time period */ export const $chartTime = atom('1h') as WritableAtom diff --git a/beszel/site/src/main.tsx b/beszel/site/src/main.tsx index 024753c..d702962 100644 --- a/beszel/site/src/main.tsx +++ b/beszel/site/src/main.tsx @@ -3,7 +3,15 @@ import React, { Suspense, lazy, useEffect } from 'react' import ReactDOM from 'react-dom/client' import Home from './components/routes/home.tsx' import { ThemeProvider } from './components/theme-provider.tsx' -import { $alerts, $authenticated, $updatedSystem, $systems, pb } from './lib/stores.ts' +import { + $alerts, + $authenticated, + $updatedSystem, + $systems, + pb, + $publicKey, + $hubVersion, +} from './lib/stores.ts' import { ModeToggle } from './components/mode-toggle.tsx' import { cn, @@ -16,7 +24,6 @@ import { import { buttonVariants } from './components/ui/button.tsx' import { DatabaseBackupIcon, - GithubIcon, LockKeyholeIcon, LogOutIcon, LogsIcon, @@ -27,12 +34,6 @@ import { import { useStore } from '@nanostores/react' import { Toaster } from './components/ui/toaster.tsx' import { Logo } from './components/logo.tsx' -import { - TooltipProvider, - Tooltip, - TooltipTrigger, - TooltipContent, -} from '@/components/ui/tooltip.tsx' import { DropdownMenu, DropdownMenuContent, @@ -60,6 +61,11 @@ const App = () => { pb.authStore.onChange(() => { $authenticated.set(pb.authStore.isValid) }) + // get version / public key + pb.send('/api/beszel/getkey', {}).then(({ key, v }) => { + $publicKey.set(key) + $hubVersion.set(v) + }) // get servers / alerts updateSystemList() updateAlerts() @@ -137,24 +143,6 @@ const Layout = () => {
- - - - - - - - -

Github Repository

-
-
-