import { Button } from "@/components/ui/button" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog" import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { $publicKey, pb } from "@/lib/stores" import { Copy, PlusIcon } from "lucide-react" import { useState, useRef, MutableRefObject } from "react" import { useStore } from "@nanostores/react" import { cn, copyToClipboard, isReadOnlyUser } from "@/lib/utils" import { navigate } from "./router" import { Trans } from "@lingui/macro" import { i18n } from "@lingui/core" export function AddSystemButton({ className }: { className?: string }) { const [open, setOpen] = useState(false) const port = useRef() as MutableRefObject const publicKey = useStore($publicKey) function copyDockerCompose(port: string) { copyToClipboard(`services: beszel-agent: image: "henrygd/beszel-agent" container_name: "beszel-agent" restart: unless-stopped network_mode: host volumes: - /var/run/docker.sock:/var/run/docker.sock:ro # monitor other disks / partitions by mounting a folder in /extra-filesystems # - /mnt/disk/.beszel:/extra-filesystems/sda1:ro environment: PORT: ${port} KEY: "${publicKey}"`) } function copyInstallCommand(port: string) { let cmd = `curl -sL https://raw.githubusercontent.com/henrygd/beszel/main/supplemental/scripts/install-agent.sh -o install-agent.sh && chmod +x install-agent.sh && ./install-agent.sh -p ${port} -k "${publicKey}"` // add china mirrors flag if zh-CN if ((i18n.locale + navigator.language).includes("zh-CN")) { cmd += ` --china-mirrors` } copyToClipboard(cmd) } async function handleSubmit(e: SubmitEvent) { e.preventDefault() const formData = new FormData(e.target as HTMLFormElement) const data = Object.fromEntries(formData) as Record data.users = pb.authStore.model!.id try { setOpen(false) await pb.collection("systems").create(data) navigate("/") // console.log(record) } catch (e) { console.log(e) } } return ( Add New System Docker Binary {/* Docker */} 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.

Click to copy

{/* Docker */} {/* Binary */}
) }