site updates

This commit is contained in:
Henry Dollman
2024-07-10 13:46:39 -04:00
parent 7e69e1665d
commit 476835b934
7 changed files with 204 additions and 254 deletions

View File

@@ -13,7 +13,7 @@ import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from '@/comp
import { Input } from '@/components/ui/input' import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label' import { Label } from '@/components/ui/label'
import { $publicKey, pb } from '@/lib/stores' import { $publicKey, pb } from '@/lib/stores'
import { ClipboardIcon, Plus } from 'lucide-react' import { Copy, Plus } from 'lucide-react'
import { useState, useRef, MutableRefObject, useEffect } from 'react' import { useState, useRef, MutableRefObject, useEffect } from 'react'
import { useStore } from '@nanostores/react' import { useStore } from '@nanostores/react'
import { copyToClipboard } from '@/lib/utils' import { copyToClipboard } from '@/lib/utils'
@@ -32,7 +32,9 @@ export function AddServerButton() {
ports: ports:
- '${port}:45876' - '${port}:45876'
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock`) - /var/run/docker.sock:/var/run/docker.sock
environment:
- KEY="${publicKey}"`)
} }
useEffect(() => { useEffect(() => {
@@ -119,7 +121,7 @@ export function AddServerButton() {
<Input readOnly id="pkey" value={publicKey} className="col-span-3" required></Input> <Input readOnly id="pkey" value={publicKey} className="col-span-3" required></Input>
<div <div
className={ className={
'h-6 w-28 bg-gradient-to-r from-transparent to-background to-70% absolute right-1 pointer-events-none' 'h-6 w-24 bg-gradient-to-r from-transparent to-background to-65% absolute right-1 pointer-events-none'
} }
></div> ></div>
<TooltipProvider delayDuration={100}> <TooltipProvider delayDuration={100}>
@@ -131,7 +133,7 @@ export function AddServerButton() {
className="absolute right-0" className="absolute right-0"
onClick={() => copyToClipboard(publicKey)} onClick={() => copyToClipboard(publicKey)}
> >
<ClipboardIcon className="h-4 w-4 " /> <Copy className="h-4 w-4 " />
</Button> </Button>
</TooltipTrigger> </TooltipTrigger>
<TooltipContent> <TooltipContent>

View File

@@ -38,7 +38,7 @@ export function CommandPalette() {
<CommandInput placeholder="Type a command or search..." /> <CommandInput placeholder="Type a command or search..." />
<CommandList> <CommandList>
<CommandEmpty>No results found.</CommandEmpty> <CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Suggestions0"> <CommandGroup heading="Suggestions">
<CommandItem <CommandItem
onSelect={() => { onSelect={() => {
navigate('/') navigate('/')
@@ -47,16 +47,16 @@ export function CommandPalette() {
> >
<Home className="mr-2 h-4 w-4" /> <Home className="mr-2 h-4 w-4" />
<span>Home</span> <span>Home</span>
<CommandShortcut>H</CommandShortcut> <CommandShortcut>Page</CommandShortcut>
</CommandItem> </CommandItem>
<CommandItem <CommandItem
onSelect={() => { onSelect={() => {
window.location.href = '/_/' window.location.href = '/_/#/collections?collectionId=2hz5ncl8tizk5nx'
}} }}
> >
<Database className="mr-2 h-4 w-4" /> <Database className="mr-2 h-4 w-4" />
<span>PocketBase</span> <span>Admin UI</span>
<CommandShortcut>P</CommandShortcut> <CommandShortcut>PocketBase</CommandShortcut>
</CommandItem> </CommandItem>
<CommandItem <CommandItem
onSelect={() => { onSelect={() => {
@@ -65,7 +65,7 @@ export function CommandPalette() {
> >
<Github className="mr-2 h-4 w-4" /> <Github className="mr-2 h-4 w-4" />
<span>Documentation</span> <span>Documentation</span>
<CommandShortcut>D</CommandShortcut> <CommandShortcut>GitHub</CommandShortcut>
</CommandItem> </CommandItem>
</CommandGroup> </CommandGroup>
<CommandSeparator /> <CommandSeparator />

View File

@@ -44,7 +44,16 @@ import {
} from '@/components/ui/alert-dialog' } from '@/components/ui/alert-dialog'
import { SystemRecord } from '@/types' import { SystemRecord } from '@/types'
import { MoreHorizontal, ArrowUpDown, Copy, RefreshCcw } from 'lucide-react' import {
MoreHorizontal,
ArrowUpDown,
Copy,
RefreshCcw,
Server,
Cpu,
MemoryStick,
HardDrive,
} from 'lucide-react'
import { useMemo, useState } from 'react' import { useMemo, useState } from 'react'
import { navigate } from 'wouter/use-browser-location' import { navigate } from 'wouter/use-browser-location'
import { $servers, pb } from '@/lib/stores' import { $servers, pb } from '@/lib/stores'
@@ -74,13 +83,14 @@ function CellFormatter(info: CellContext<SystemRecord, unknown>) {
) )
} }
function sortableHeader(column: Column<SystemRecord, unknown>, name: string) { function sortableHeader(column: Column<SystemRecord, unknown>, name: string, Icon: any) {
return ( return (
<Button <Button
variant="ghost" variant="ghost"
className="h-9 px-3" className="h-9 px-3"
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')} onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
> >
<Icon className="mr-2 h-4 w-4" />
{name} {name}
<ArrowUpDown className="ml-2 h-4 w-4" /> <ArrowUpDown className="ml-2 h-4 w-4" />
</Button> </Button>
@@ -89,7 +99,6 @@ function sortableHeader(column: Column<SystemRecord, unknown>, name: string) {
export function DataTable() { export function DataTable() {
const data = useStore($servers) const data = useStore($servers)
const [liveUpdates, setLiveUpdates] = useState(true)
const [deleteServer, setDeleteServer] = useState({} as SystemRecord) const [deleteServer, setDeleteServer] = useState({} as SystemRecord)
const [sorting, setSorting] = useState<SortingState>([]) const [sorting, setSorting] = useState<SortingState>([])
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]) const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([])
@@ -118,22 +127,22 @@ export function DataTable() {
</Button> </Button>
</span> </span>
), ),
header: ({ column }) => sortableHeader(column, 'Server'), header: ({ column }) => sortableHeader(column, 'Server', Server),
}, },
{ {
accessorKey: 'stats.cpu', accessorKey: 'stats.cpu',
cell: CellFormatter, cell: CellFormatter,
header: ({ column }) => sortableHeader(column, 'CPU'), header: ({ column }) => sortableHeader(column, 'CPU', Cpu),
}, },
{ {
accessorKey: 'stats.memPct', accessorKey: 'stats.memPct',
cell: CellFormatter, cell: CellFormatter,
header: ({ column }) => sortableHeader(column, 'Memory'), header: ({ column }) => sortableHeader(column, 'Memory', MemoryStick),
}, },
{ {
accessorKey: 'stats.diskPct', accessorKey: 'stats.diskPct',
cell: CellFormatter, cell: CellFormatter,
header: ({ column }) => sortableHeader(column, 'Disk'), header: ({ column }) => sortableHeader(column, 'Disk', HardDrive),
}, },
{ {
id: 'actions', id: 'actions',
@@ -203,37 +212,10 @@ export function DataTable() {
// @ts-ignore // @ts-ignore
placeholder="Filter..." placeholder="Filter..."
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''} value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
onChange={(event: Event) => table.getColumn('name')?.setFilterValue(event.target.value)} onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
className="max-w-sm" className="max-w-sm"
/> />
<div className="ml-auto flex gap-2"> <div className="ml-auto flex gap-2">
{liveUpdates || (
<Button
variant="outline"
onClick={() => {
alert('todo: refresh')
}}
className="flex gap-2"
>
<RefreshCcw className="h-4 w-4" />
Refresh
</Button>
)}
{/* <Button
variant="outline"
onClick={() => {
setLiveUpdates(!liveUpdates)
}}
className="flex gap-2"
>
<span
className={clsx('h-2.5 w-2.5 rounded-full', {
'bg-green-500': liveUpdates,
'bg-red-500': !liveUpdates,
})}
/>
Live Updates
</Button> */}
<AddServerButton /> <AddServerButton />
</div> </div>
</div> </div>
@@ -280,7 +262,7 @@ export function DataTable() {
</Table> </Table>
</div> </div>
</div> </div>
<AlertDialog open={deleteServer?.name}> <AlertDialog open={!!deleteServer?.name}>
<AlertDialogContent> <AlertDialogContent>
<AlertDialogHeader> <AlertDialogHeader>
<AlertDialogTitle> <AlertDialogTitle>

View File

@@ -1,8 +1,8 @@
import * as React from "react" import * as React from 'react'
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
import { cn } from "@/lib/utils" import { cn } from '@/lib/utils'
import { buttonVariants } from "@/components/ui/button" import { buttonVariants } from '@/components/ui/button'
const AlertDialog = AlertDialogPrimitive.Root const AlertDialog = AlertDialogPrimitive.Root
@@ -16,7 +16,7 @@ const AlertDialogOverlay = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Overlay <AlertDialogPrimitive.Overlay
className={cn( className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", 'fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
className className
)} )}
{...props} {...props}
@@ -34,7 +34,7 @@ const AlertDialogContent = React.forwardRef<
<AlertDialogPrimitive.Content <AlertDialogPrimitive.Content
ref={ref} ref={ref}
className={cn( className={cn(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg", 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
className className
)} )}
{...props} {...props}
@@ -43,33 +43,18 @@ const AlertDialogContent = React.forwardRef<
)) ))
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
const AlertDialogHeader = ({ const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
className, <div className={cn('flex flex-col space-y-2 text-center sm:text-left', className)} {...props} />
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-2 text-center sm:text-left",
className
)}
{...props}
/>
) )
AlertDialogHeader.displayName = "AlertDialogHeader" AlertDialogHeader.displayName = 'AlertDialogHeader'
const AlertDialogFooter = ({ const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div <div
className={cn( className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className
)}
{...props} {...props}
/> />
) )
AlertDialogFooter.displayName = "AlertDialogFooter" AlertDialogFooter.displayName = 'AlertDialogFooter'
const AlertDialogTitle = React.forwardRef< const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>, React.ElementRef<typeof AlertDialogPrimitive.Title>,
@@ -77,7 +62,7 @@ const AlertDialogTitle = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Title <AlertDialogPrimitive.Title
ref={ref} ref={ref}
className={cn("text-lg font-semibold", className)} className={cn('text-lg font-semibold', className)}
{...props} {...props}
/> />
)) ))
@@ -89,22 +74,17 @@ const AlertDialogDescription = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Description <AlertDialogPrimitive.Description
ref={ref} ref={ref}
className={cn("text-sm text-muted-foreground", className)} className={cn('text-sm text-muted-foreground', className)}
{...props} {...props}
/> />
)) ))
AlertDialogDescription.displayName = AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName
AlertDialogPrimitive.Description.displayName
const AlertDialogAction = React.forwardRef< const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>, React.ElementRef<typeof AlertDialogPrimitive.Action>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action> React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Action <AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
ref={ref}
className={cn(buttonVariants(), className)}
{...props}
/>
)) ))
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
@@ -114,11 +94,7 @@ const AlertDialogCancel = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Cancel <AlertDialogPrimitive.Cancel
ref={ref} ref={ref}
className={cn( className={cn(buttonVariants({ variant: 'outline' }), 'mt-2 sm:mt-0', className)}
buttonVariants({ variant: "outline" }),
"mt-2 sm:mt-0",
className
)}
{...props} {...props}
/> />
)) ))

View File

@@ -1,10 +1,10 @@
import * as React from "react" import * as React from 'react'
import { type DialogProps } from "@radix-ui/react-dialog" import { type DialogProps } from '@radix-ui/react-dialog'
import { Command as CommandPrimitive } from "cmdk" import { Command as CommandPrimitive } from 'cmdk'
import { Search } from "lucide-react" import { Search } from 'lucide-react'
import { cn } from "@/lib/utils" import { cn } from '@/lib/utils'
import { Dialog, DialogContent } from "@/components/ui/dialog" import { Dialog, DialogContent } from '@/components/ui/dialog'
const Command = React.forwardRef< const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>, React.ElementRef<typeof CommandPrimitive>,
@@ -13,7 +13,7 @@ const Command = React.forwardRef<
<CommandPrimitive <CommandPrimitive
ref={ref} ref={ref}
className={cn( className={cn(
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground", 'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',
className className
)} )}
{...props} {...props}
@@ -44,7 +44,7 @@ const CommandInput = React.forwardRef<
<CommandPrimitive.Input <CommandPrimitive.Input
ref={ref} ref={ref}
className={cn( className={cn(
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50", 'flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50',
className className
)} )}
{...props} {...props}
@@ -60,7 +60,7 @@ const CommandList = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<CommandPrimitive.List <CommandPrimitive.List
ref={ref} ref={ref}
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)} className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)}
{...props} {...props}
/> />
)) ))
@@ -71,11 +71,7 @@ const CommandEmpty = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Empty>, React.ElementRef<typeof CommandPrimitive.Empty>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty> React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
>((props, ref) => ( >((props, ref) => (
<CommandPrimitive.Empty <CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />
ref={ref}
className="py-6 text-center text-sm"
{...props}
/>
)) ))
CommandEmpty.displayName = CommandPrimitive.Empty.displayName CommandEmpty.displayName = CommandPrimitive.Empty.displayName
@@ -87,7 +83,7 @@ const CommandGroup = React.forwardRef<
<CommandPrimitive.Group <CommandPrimitive.Group
ref={ref} ref={ref}
className={cn( className={cn(
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground", 'overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground',
className className
)} )}
{...props} {...props}
@@ -102,7 +98,7 @@ const CommandSeparator = React.forwardRef<
>(({ className, ...props }, ref) => ( >(({ className, ...props }, ref) => (
<CommandPrimitive.Separator <CommandPrimitive.Separator
ref={ref} ref={ref}
className={cn("-mx-1 h-px bg-border", className)} className={cn('-mx-1 h-px bg-border', className)}
{...props} {...props}
/> />
)) ))
@@ -115,7 +111,7 @@ const CommandItem = React.forwardRef<
<CommandPrimitive.Item <CommandPrimitive.Item
ref={ref} ref={ref}
className={cn( className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "relative flex cursor-default opacity-70 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:opacity-90 data-[disabled='true']:pointer-events-none data-[disabled='true']:opacity-50",
className className
)} )}
{...props} {...props}
@@ -124,21 +120,15 @@ const CommandItem = React.forwardRef<
CommandItem.displayName = CommandPrimitive.Item.displayName CommandItem.displayName = CommandPrimitive.Item.displayName
const CommandShortcut = ({ const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
className,
...props
}: React.HTMLAttributes<HTMLSpanElement>) => {
return ( return (
<span <span
className={cn( className={cn('ml-auto text-xs tracking-wide text-muted-foreground', className)}
"ml-auto text-xs tracking-widest text-muted-foreground",
className
)}
{...props} {...props}
/> />
) )
} }
CommandShortcut.displayName = "CommandShortcut" CommandShortcut.displayName = 'CommandShortcut'
export { export {
Command, Command,

View File

@@ -17,8 +17,8 @@
--muted-foreground: 24 2.79% 35.1%; --muted-foreground: 24 2.79% 35.1%;
--accent: 20 23.08% 94%; --accent: 20 23.08% 94%;
--accent-foreground: 240 5.88% 10%; --accent-foreground: 240 5.88% 10%;
--destructive: 30 67% 46%; --destructive: 0 66% 53%;
--destructive-foreground: 30 0% 98.04%; --destructive-foreground: 0 0% 98.04%;
--border: 30 8.11% 85.49%; --border: 30 8.11% 85.49%;
--input: 30 4.29% 72.55%; --input: 30 4.29% 72.55%;
--ring: 30 3.97% 49.41%; --ring: 30 3.97% 49.41%;

View File

@@ -8,7 +8,7 @@ import LoginPage from './components/login.tsx'
import { $authenticated, $servers, pb } from './lib/stores.ts' import { $authenticated, $servers, pb } from './lib/stores.ts'
import { ServerDetail } from './components/routes/server.tsx' import { ServerDetail } from './components/routes/server.tsx'
import { ModeToggle } from './components/mode-toggle.tsx' import { ModeToggle } from './components/mode-toggle.tsx'
import { CommandPalette } from './components/command-dialog.tsx' import { CommandPalette } from './components/command-palette.tsx'
import { cn } from './lib/utils.ts' import { cn } from './lib/utils.ts'
import { buttonVariants } from './components/ui/button.tsx' import { buttonVariants } from './components/ui/button.tsx'
import { Github } from 'lucide-react' import { Github } from 'lucide-react'