-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Click to copy
-
-
-
-
-
+
+
+
+
+ {system ? `${t`Edit`} ${system?.name}` : Add New System}
+
+
+ Docker
+
+ Binary
+
+
+
+ {/* Docker (set tab index to prevent auto focusing content in edit system dialog) */}
+
+
+
+ The agent must be running on the system to connect. Copy the
+ docker-compose.yml
for the agent below.
+
+
+
+ {/* Binary */}
+
+
+
+ The agent must be running on the system to connect. Copy the installation command for the agent below.
+
+
+
+
-
-
-
+ {/* Save */}
+
+
+
+
+
)
-}
+})
diff --git a/beszel/site/src/components/systems-table/systems-table.tsx b/beszel/site/src/components/systems-table/systems-table.tsx
index 175756e..8f90367 100644
--- a/beszel/site/src/components/systems-table/systems-table.tsx
+++ b/beszel/site/src/components/systems-table/systems-table.tsx
@@ -37,7 +37,6 @@ import {
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
- AlertDialogTrigger,
} from "@/components/ui/alert-dialog"
import { SystemRecord } from "@/types"
@@ -59,8 +58,9 @@ import {
ArrowUpIcon,
Settings2Icon,
EyeIcon,
+ PenBoxIcon,
} from "lucide-react"
-import { useEffect, useMemo, useState } from "react"
+import { memo, useEffect, useMemo, useRef, useState } from "react"
import { $hubVersion, $systems, pb } from "@/lib/stores"
import { useStore } from "@nanostores/react"
import { cn, copyToClipboard, decimalString, isReadOnlyUser, useLocalStorage } from "@/lib/utils"
@@ -73,6 +73,8 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui
import { Input } from "../ui/input"
import { ClassValue } from "clsx"
import { getPagePath } from "@nanostores/router"
+import { SystemDialog } from "../add-system"
+import { Dialog } from "../ui/dialog"
type ViewMode = "table" | "grid"
@@ -559,11 +561,15 @@ function IndicatorDot({ system, className }: { system: SystemRecord; className?:
)
}
-function ActionsButton({ system }: { system: SystemRecord }) {
- // const [opened, setOpened] = useState(false)
+const ActionsButton = memo(({ system }: { system: SystemRecord }) => {
+ const [deleteOpen, setDeleteOpen] = useState(false)
+ const [editOpen, setEditOpen] = useState(false)
+ let editOpened = useRef(false)
+
const { id, status, host, name } = system
+
return (
-
+ <>
+ {!isReadOnlyUser() && (
+ {
+ editOpened.current = true
+ setEditOpen(true)
+ }}
+ >
+
+ Edit
+
+ )}
{
@@ -599,38 +616,43 @@ function ActionsButton({ system }: { system: SystemRecord }) {
Copy host
-
-
-
- Delete
-
-
+ setDeleteOpen(true)}>
+
+ Delete
+
-
-
-
- Are you sure you want to delete {name}?
-
-
-
- This action cannot be undone. This will permanently delete all current records for {name} from the
- database.
-
-
-
-
-
- Cancel
-
- pb.collection("systems").delete(id)}
- >
- Continue
-
-
-
-
+ {/* edit dialog */}
+
+ {/* deletion dialog */}
+
setDeleteOpen(open)}>
+
+
+
+ Are you sure you want to delete {name}?
+
+
+
+ This action cannot be undone. This will permanently delete all current records for {name} from the
+ database.
+
+
+
+
+
+ Cancel
+
+ pb.collection("systems").delete(id)}
+ >
+ Continue
+
+
+
+
+ >
)
-}
+})
diff --git a/beszel/site/src/lib/utils.ts b/beszel/site/src/lib/utils.ts
index 37f08ba..3302846 100644
--- a/beszel/site/src/lib/utils.ts
+++ b/beszel/site/src/lib/utils.ts
@@ -53,7 +53,7 @@ export const updateSystemList = (() => {
try {
const records = await pb
.collection
("systems")
- .getFullList({ sort: "+name", fields: "id,name,host,info,status" })
+ .getFullList({ sort: "+name", fields: "id,name,host,port,info,status" })
if (records.length) {
$systems.set(records)
@@ -107,7 +107,7 @@ export const formatDay = (timestamp: string) => {
}
export const updateFavicon = (newIcon: string) => {
- ;(document.querySelector("link[rel='icon']") as HTMLLinkElement).href = prependBasePath( `/static/${newIcon}` )
+ ;(document.querySelector("link[rel='icon']") as HTMLLinkElement).href = prependBasePath(`/static/${newIcon}`)
}
export const isAdmin = () => pb.authStore.record?.role === "admin"