mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-17 10:46:16 +01:00
- Add new /containers route with virtualized table showing all containers across systems - Implement container stats collection (CPU, memory, network usage) with health status tracking - Add container logs and info API endpoints with syntax highlighting using Shiki - Create detailed container views with fullscreen logs/info dialogs and refresh functionality - Add container table to individual system pages with lazy loading - Implement container record storage with automatic cleanup and historical averaging - Update navbar with container navigation icon - Extract reusable ActiveAlerts component from home page - Add FooterRepoLink component for consistent GitHub/version display - Enhance filtering and search capabilities across container tables
240 lines
6.3 KiB
Go
240 lines
6.3 KiB
Go
import { t } from "@lingui/core/macro"
|
|
import { Trans } from "@lingui/react/macro"
|
|
import { getPagePath } from "@nanostores/router"
|
|
import { DialogDescription } from "@radix-ui/react-dialog"
|
|
import {
|
|
AlertOctagonIcon,
|
|
BookIcon,
|
|
ContainerIcon,
|
|
DatabaseBackupIcon,
|
|
FingerprintIcon,
|
|
LayoutDashboard,
|
|
LogsIcon,
|
|
MailIcon,
|
|
Server,
|
|
SettingsIcon,
|
|
UsersIcon,
|
|
} from "lucide-react"
|
|
import { memo, useEffect, useMemo } from "react"
|
|
import {
|
|
CommandDialog,
|
|
CommandEmpty,
|
|
CommandGroup,
|
|
CommandInput,
|
|
CommandItem,
|
|
CommandList,
|
|
CommandSeparator,
|
|
CommandShortcut,
|
|
} from "@/components/ui/command"
|
|
import { isAdmin } from "@/lib/api"
|
|
import { $systems } from "@/lib/stores"
|
|
import { getHostDisplayValue, listen } from "@/lib/utils"
|
|
import { $router, basePath, navigate, prependBasePath } from "./router"
|
|
|
|
export default memo(function CommandPalette({ open, setOpen }: { open: boolean; setOpen: (open: boolean) => void }) {
|
|
useEffect(() => {
|
|
const down = (e: KeyboardEvent) => {
|
|
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
|
|
e.preventDefault()
|
|
setOpen(!open)
|
|
}
|
|
}
|
|
return listen(document, "keydown", down)
|
|
}, [open, setOpen])
|
|
|
|
return useMemo(() => {
|
|
const systems = $systems.get()
|
|
const SettingsShortcut = (
|
|
<CommandShortcut>
|
|
<Trans>Settings</Trans>
|
|
</CommandShortcut>
|
|
)
|
|
const AdminShortcut = (
|
|
<CommandShortcut>
|
|
<Trans>Admin</Trans>
|
|
</CommandShortcut>
|
|
)
|
|
return (
|
|
<CommandDialog open={open} onOpenChange={setOpen}>
|
|
<DialogDescription className="sr-only">Command palette</DialogDescription>
|
|
<CommandInput placeholder={t`Search for systems or settings...`} />
|
|
<CommandList>
|
|
{systems.length > 0 && (
|
|
<>
|
|
<CommandGroup>
|
|
{systems.map((system) => (
|
|
<CommandItem
|
|
key={system.id}
|
|
onSelect={() => {
|
|
navigate(getPagePath($router, "system", { id: system.id }))
|
|
setOpen(false)
|
|
}}
|
|
>
|
|
<Server className="me-2 size-4" />
|
|
<span className="max-w-60 truncate">{system.name}</span>
|
|
<CommandShortcut>{getHostDisplayValue(system)}</CommandShortcut>
|
|
</CommandItem>
|
|
))}
|
|
</CommandGroup>
|
|
<CommandSeparator className="mb-1.5" />
|
|
</>
|
|
)}
|
|
<CommandGroup heading={t`Pages / Settings`}>
|
|
<CommandItem
|
|
keywords={["home", t`All Systems`]}
|
|
onSelect={() => {
|
|
navigate(basePath)
|
|
setOpen(false)
|
|
}}
|
|
>
|
|
<LayoutDashboard className="me-2 size-4" />
|
|
<span>
|
|
<Trans>Dashboard</Trans>
|
|
</span>
|
|
<CommandShortcut>
|
|
<Trans>Page</Trans>
|
|
</CommandShortcut>
|
|
</CommandItem>
|
|
<CommandItem
|
|
onSelect={() => {
|
|
navigate(getPagePath($router, "containers"))
|
|
setOpen(false)
|
|
}}
|
|
>
|
|
<ContainerIcon className="me-2 size-4" />
|
|
<span>
|
|
<Trans>All Containers</Trans>
|
|
</span>
|
|
<CommandShortcut>
|
|
<Trans>Page</Trans>
|
|
</CommandShortcut>
|
|
</CommandItem>
|
|
<CommandItem
|
|
onSelect={() => {
|
|
navigate(getPagePath($router, "settings", { name: "general" }))
|
|
setOpen(false)
|
|
}}
|
|
>
|
|
<SettingsIcon className="me-2 size-4" />
|
|
<span>
|
|
<Trans>Settings</Trans>
|
|
</span>
|
|
{SettingsShortcut}
|
|
</CommandItem>
|
|
<CommandItem
|
|
keywords={["alerts"]}
|
|
onSelect={() => {
|
|
navigate(getPagePath($router, "settings", { name: "notifications" }))
|
|
setOpen(false)
|
|
}}
|
|
>
|
|
<MailIcon className="me-2 size-4" />
|
|
<span>
|
|
<Trans>Notifications</Trans>
|
|
</span>
|
|
{SettingsShortcut}
|
|
</CommandItem>
|
|
<CommandItem
|
|
keywords={[t`Universal token`]}
|
|
onSelect={() => {
|
|
navigate(getPagePath($router, "settings", { name: "tokens" }))
|
|
setOpen(false)
|
|
}}
|
|
>
|
|
<FingerprintIcon className="me-2 size-4" />
|
|
<span>
|
|
<Trans>Tokens & Fingerprints</Trans>
|
|
</span>
|
|
{SettingsShortcut}
|
|
</CommandItem>
|
|
<CommandItem
|
|
onSelect={() => {
|
|
navigate(getPagePath($router, "settings", { name: "alert-history" }))
|
|
setOpen(false)
|
|
}}
|
|
>
|
|
<AlertOctagonIcon className="me-2 size-4" />
|
|
<span>
|
|
<Trans>Alert History</Trans>
|
|
</span>
|
|
{SettingsShortcut}
|
|
</CommandItem>
|
|
<CommandItem
|
|
keywords={["help", "oauth", "oidc"]}
|
|
onSelect={() => {
|
|
window.location.href = "https://beszel.dev/guide/what-is-beszel"
|
|
}}
|
|
>
|
|
<BookIcon className="me-2 size-4" />
|
|
<span>
|
|
<Trans>Documentation</Trans>
|
|
</span>
|
|
<CommandShortcut>beszel.dev</CommandShortcut>
|
|
</CommandItem>
|
|
</CommandGroup>
|
|
{isAdmin() && (
|
|
<>
|
|
<CommandSeparator className="mb-1.5" />
|
|
<CommandGroup heading={t`Admin`}>
|
|
<CommandItem
|
|
keywords={["pocketbase"]}
|
|
onSelect={() => {
|
|
setOpen(false)
|
|
window.open(prependBasePath("/_/"), "_blank")
|
|
}}
|
|
>
|
|
<UsersIcon className="me-2 size-4" />
|
|
<span>
|
|
<Trans>Users</Trans>
|
|
</span>
|
|
{AdminShortcut}
|
|
</CommandItem>
|
|
<CommandItem
|
|
onSelect={() => {
|
|
setOpen(false)
|
|
window.open(prependBasePath("/_/#/logs"), "_blank")
|
|
}}
|
|
>
|
|
<LogsIcon className="me-2 size-4" />
|
|
<span>
|
|
<Trans>Logs</Trans>
|
|
</span>
|
|
{AdminShortcut}
|
|
</CommandItem>
|
|
<CommandItem
|
|
onSelect={() => {
|
|
setOpen(false)
|
|
window.open(prependBasePath("/_/#/settings/backups"), "_blank")
|
|
}}
|
|
>
|
|
<DatabaseBackupIcon className="me-2 size-4" />
|
|
<span>
|
|
<Trans>Backups</Trans>
|
|
</span>
|
|
{AdminShortcut}
|
|
</CommandItem>
|
|
<CommandItem
|
|
keywords={["email"]}
|
|
onSelect={() => {
|
|
setOpen(false)
|
|
window.open(prependBasePath("/_/#/settings/mail"), "_blank")
|
|
}}
|
|
>
|
|
<MailIcon className="me-2 size-4" />
|
|
<span>
|
|
<Trans>SMTP settings</Trans>
|
|
</span>
|
|
{AdminShortcut}
|
|
</CommandItem>
|
|
</CommandGroup>
|
|
</>
|
|
)}
|
|
<CommandEmpty>
|
|
<Trans>No results found.</Trans>
|
|
</CommandEmpty>
|
|
</CommandList>
|
|
</CommandDialog>
|
|
)
|
|
}, [open])
|
|
})
|