From 86cfa5079ee543bd4b68ac83e333b5a30030cb23 Mon Sep 17 00:00:00 2001 From: Henry Dollman Date: Sat, 13 Jul 2024 12:41:05 -0400 Subject: [PATCH] updates --- main.go | 10 ++-- site/src/components/add-server.tsx | 7 +-- site/src/components/login.tsx | 60 +++++++------------ site/src/components/logo.tsx | 2 +- .../components/server-table/data-table.tsx | 40 +++++++++---- site/src/lib/stores.ts | 4 +- site/src/main.tsx | 8 ++- site/tailwind.config.js | 5 +- 8 files changed, 74 insertions(+), 62 deletions(-) diff --git a/main.go b/main.go index 38bb464..ec11478 100644 --- a/main.go +++ b/main.go @@ -131,7 +131,7 @@ func main() { } func serverUpdateTicker() { - ticker := time.NewTicker(30 * time.Second) + ticker := time.NewTicker(60 * time.Second) for range ticker.C { updateServers() } @@ -220,9 +220,11 @@ func setInactive(record *models.Record) { delete(serverConnections, record.Id) } // set inactive - record.Set("status", "down") - if err := app.Dao().SaveRecord(record); err != nil { - app.Logger().Error("Failed to update record: ", "err", err.Error()) + if record.Get("status") != "down" { + record.Set("status", "down") + if err := app.Dao().SaveRecord(record); err != nil { + app.Logger().Error("Failed to update record: ", "err", err.Error()) + } } } diff --git a/site/src/components/add-server.tsx b/site/src/components/add-server.tsx index 6c30993..0d15b06 100644 --- a/site/src/components/add-server.tsx +++ b/site/src/components/add-server.tsx @@ -44,7 +44,6 @@ export function AddServerButton() { } // get public key pb.send('/getkey', {}).then(({ key }) => { - console.log('key', key) $publicKey.set(key) }) }, [open]) @@ -77,12 +76,12 @@ export function AddServerButton() { - Add New Server + Add New System The agent must be running on the server to connect. Copy the{' '} docker-compose.yml for the agent @@ -153,7 +152,7 @@ export function AddServerButton() { > Copy docker compose - + diff --git a/site/src/components/login.tsx b/site/src/components/login.tsx index fe7e84b..692cf78 100644 --- a/site/src/components/login.tsx +++ b/site/src/components/login.tsx @@ -1,56 +1,38 @@ -import { cn } from '@/lib/utils' -import { buttonVariants } from '@/components/ui/button' import { UserAuthForm } from '@/components/user-auth-form' -import { ChevronLeft } from 'lucide-react' +import { Logo } from './logo' export default function () { return ( -
-
-
-
- {/* */} -

Welcome back

+
+ -
-
-
- placeholder - -
- {/*
-
-

- “This library has saved me countless hours of work and helped me deliver stunning - designs to my clients faster than ever before.” -

-
Sofia Davis
-
-
*/} +
+
) diff --git a/site/src/components/logo.tsx b/site/src/components/logo.tsx index 5715bdc..a0bc5fe 100644 --- a/site/src/components/logo.tsx +++ b/site/src/components/logo.tsx @@ -1,7 +1,7 @@ export function Logo({ className }: { className?: string }) { return ( // audiowide - + ) diff --git a/site/src/components/server-table/data-table.tsx b/site/src/components/server-table/data-table.tsx index 1f05b3f..3084d4e 100644 --- a/site/src/components/server-table/data-table.tsx +++ b/site/src/components/server-table/data-table.tsx @@ -55,6 +55,7 @@ import { PauseCircleIcon, PlayCircleIcon, Trash2Icon, + BellIcon, } from 'lucide-react' import { useMemo, useState } from 'react' import { $servers, pb, navigate } from '@/lib/stores' @@ -65,7 +66,7 @@ import { cn, copyToClipboard } from '@/lib/utils' function CellFormatter(info: CellContext) { const val = info.getValue() as number return ( -
+
[] = useMemo(() => { return [ { - // size: 70, + // size: 200, + size: 200, + minSize: 0, accessorKey: 'name', cell: (info) => { const { status } = info.row.original return ( - + { const { id, name, status, host } = row.original return ( -
+
+ - @@ -241,6 +251,11 @@ export default function () { sorting, columnFilters, }, + defaultColumn: { + minSize: 0, + size: Number.MAX_SAFE_INTEGER, + maxSize: Number.MAX_SAFE_INTEGER, + }, }) return ( @@ -294,8 +309,13 @@ export default function () { {row.getVisibleCells().map((cell) => ( {flexRender(cell.column.columnDef.cell, cell.getContext())} diff --git a/site/src/lib/stores.ts b/site/src/lib/stores.ts index e2ae86c..b979508 100644 --- a/site/src/lib/stores.ts +++ b/site/src/lib/stores.ts @@ -19,11 +19,11 @@ export const navigate = (urlString: string) => { $router.open(urlString) } -export const $servers = atom([] as SystemRecord[]) - export const $authenticated = atom(pb.authStore.isValid) pb.authStore.onChange(() => { $authenticated.set(pb.authStore.isValid) }) +export const $servers = atom([] as SystemRecord[]) + export const $publicKey = atom('') diff --git a/site/src/main.tsx b/site/src/main.tsx index 02fc661..3f76e37 100644 --- a/site/src/main.tsx +++ b/site/src/main.tsx @@ -40,18 +40,24 @@ const App = () => { // update favicon useEffect(() => { if (!authenticated || !servers.length) { + console.log('no auth favicon') updateFavicon('/favicon.svg') } else { + const cleanup = () => { + updateFavicon('/favicon.svg') + } let up = false for (const server of servers) { if (server.status === 'down') { + console.log('down', server) updateFavicon('/favicon-red.svg') - break + return cleanup } else if (server.status === 'up') { up = true } } updateFavicon(up ? '/favicon-green.svg' : '/favicon.svg') + return cleanup } return () => { updateFavicon('/favicon.svg') diff --git a/site/tailwind.config.js b/site/tailwind.config.js index a6d13a8..d4c78f8 100644 --- a/site/tailwind.config.js +++ b/site/tailwind.config.js @@ -11,7 +11,7 @@ module.exports = { theme: { container: { center: true, - padding: '2rem', + padding: '1rem', screens: { '2xl': '1400px', }, @@ -22,6 +22,9 @@ module.exports = { // display: ['Inter', 'sans-serif'], }, extend: { + screens: { + xs: '425px', + }, colors: { green: { 50: '#EBF9F0',