diff --git a/app/dashboard/applications/Applications.tsx b/app/dashboard/applications/Applications.tsx index cd67711..ba6922d 100644 --- a/app/dashboard/applications/Applications.tsx +++ b/app/dashboard/applications/Applications.tsx @@ -474,140 +474,142 @@ export default function Dashboard() { )} - deleteApplication(app.id)} - > - - - - - openEditDialog(app)} - > - - - - - - - Edit Application - - - - - Name - - setEditName(e.target.value) - } - /> - - - Server - - setEditServerId(Number(v)) - } - required - > - - - - - {servers.map((server) => ( - - {server.name} - - ))} - - - - - - Description{" "} - - (optional) - - - - setEditDescription(e.target.value) - } - /> - - - - Icon URL{" "} - - (optional) - - - - setEditIcon(e.target.value) - } - /> - - - Public URL - - setEditPublicURL(e.target.value) - } - /> - - - - Local URL{" "} - - (optional) - - - - setEditLocalURL(e.target.value) - } - /> - - - - - - Cancel - + deleteApplication(app.id)} + > + + + + + openEditDialog(app)} > - Save Changes - - - - + + + + + + + Edit Application + + + + + Name + + setEditName(e.target.value) + } + /> + + + Server + + setEditServerId(Number(v)) + } + required + > + + + + + {servers.map((server) => ( + + {server.name} + + ))} + + + + + + Description{" "} + + (optional) + + + + setEditDescription(e.target.value) + } + /> + + + + Icon URL{" "} + + (optional) + + + + setEditIcon(e.target.value) + } + /> + + + Public URL + + setEditPublicURL(e.target.value) + } + /> + + + + Local URL{" "} + + (optional) + + + + setEditLocalURL(e.target.value) + } + /> + + + + + + Cancel + + Save Changes + + + + + diff --git a/app/dashboard/servers/Servers.tsx b/app/dashboard/servers/Servers.tsx index bf1a2cf..9b5853f 100644 --- a/app/dashboard/servers/Servers.tsx +++ b/app/dashboard/servers/Servers.tsx @@ -16,7 +16,20 @@ import { SidebarTrigger, } from "@/components/ui/sidebar"; import { Button } from "@/components/ui/button"; -import { Plus, Link, MonitorCog, FileDigit, Trash2, LayoutGrid, List, Pencil, Cpu, Microchip, MemoryStick, HardDrive } from "lucide-react"; +import { + Plus, + Link, + MonitorCog, + FileDigit, + Trash2, + LayoutGrid, + List, + Pencil, + Cpu, + Microchip, + MemoryStick, + HardDrive, +} from "lucide-react"; import { Card, CardContent, @@ -62,7 +75,7 @@ import { } from "@/components/ui/tooltip"; import Cookies from "js-cookie"; import { useState, useEffect } from "react"; -import axios from 'axios'; +import axios from "axios"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; interface Server { @@ -112,72 +125,75 @@ export default function Dashboard() { const [isSearching, setIsSearching] = useState(false); useEffect(() => { - const savedLayout = Cookies.get('layoutPreference-servers'); - setIsGridLayout(savedLayout === 'grid'); + const savedLayout = Cookies.get("layoutPreference-servers"); + setIsGridLayout(savedLayout === "grid"); }, []); const toggleLayout = () => { const newLayout = !isGridLayout; setIsGridLayout(newLayout); - Cookies.set('layoutPreference-servers', newLayout ? 'grid' : 'standard', { + Cookies.set("layoutPreference-servers", newLayout ? "grid" : "standard", { expires: 365, - path: '/', - sameSite: 'strict' + path: "/", + sameSite: "strict", }); }; const add = async () => { try { - await axios.post('/api/servers/add', { - name, - os, - ip, - url, - cpu, - gpu, - ram, - disk + await axios.post("/api/servers/add", { + name, + os, + ip, + url, + cpu, + gpu, + ram, + disk, }); getServers(); } catch (error: any) { console.log(error.response.data); } - } + }; const getServers = async () => { try { setLoading(true); - const response = await axios.post('/api/servers/get', { - page: currentPage - }); + const response = await axios.post( + "/api/servers/get", + { + page: currentPage, + } + ); setServers(response.data.servers); setMaxPage(response.data.maxPage); setLoading(false); } catch (error: any) { console.log(error.response); } - } + }; useEffect(() => { getServers(); }, [currentPage]); const handlePrevious = () => { - setCurrentPage(prev => Math.max(1, prev - 1)); - } + setCurrentPage((prev) => Math.max(1, prev - 1)); + }; const handleNext = () => { - setCurrentPage(prev => Math.min(maxPage, prev + 1)); - } + setCurrentPage((prev) => Math.min(maxPage, prev + 1)); + }; const deleteApplication = async (id: number) => { try { - await axios.post('/api/servers/delete', { id }); + await axios.post("/api/servers/delete", { id }); getServers(); } catch (error: any) { console.log(error.response.data); } - } + }; const openEditDialog = (server: Server) => { setEditId(server.id); @@ -193,9 +209,9 @@ export default function Dashboard() { const edit = async () => { if (!editId) return; - + try { - await axios.put('/api/servers/edit', { + await axios.put("/api/servers/edit", { id: editId, name: editName, os: editOs, @@ -204,14 +220,14 @@ export default function Dashboard() { cpu: editCpu, gpu: editGpu, ram: editRam, - disk: editDisk + disk: editDisk, }); getServers(); setEditId(null); } catch (error: any) { console.log(error.response.data); } - } + }; const searchServers = async () => { try { @@ -272,8 +288,8 @@ export default function Dashboard() { - @@ -285,9 +301,9 @@ export default function Dashboard() { - {isGridLayout ? - "Switch to list view" : - "Switch to grid view"} + {isGridLayout + ? "Switch to list view" + : "Switch to grid view"} @@ -301,70 +317,144 @@ export default function Dashboard() { Add an server - - - General - Hardware - - - - - Name - setName(e.target.value)}/> - - - Operating System (optional) - setOs(value)}> + + + General + Hardware + + + + + Name + setName(e.target.value)} + /> + + + + Operating System{" "} + + (optional) + + + setOs(value)}> - + - Windows - Linux - MacOS + + Windows + + Linux + MacOS - - - - IP Adress (optional) - setIp(e.target.value)}/> - - - + + + + + IP Adress{" "} + + (optional) + + + setIp(e.target.value)} + /> + + + - - Management URL (optional) - - - Link to a web interface (e.g. Proxmox or Portainer) with which the server can be managed - + + + Management URL{" "} + + (optional) + + + + + Link to a web interface (e.g. Proxmox or + Portainer) with which the server can be + managed + - - setUrl(e.target.value)}/> + + setUrl(e.target.value)} + /> + - - - - - - CPU (optional) - setCpu(e.target.value)}/> + + + + + + CPU{" "} + + (optional) + + + setCpu(e.target.value)} + /> + + + + GPU{" "} + + (optional) + + + setGpu(e.target.value)} + /> + + + + RAM{" "} + + (optional) + + + setRam(e.target.value)} + /> + + + + Disk{" "} + + (optional) + + + setDisk(e.target.value)} + /> + - - GPU (optional) - setGpu(e.target.value)}/> - - - RAM (optional) - setRam(e.target.value)}/> - - - Disk (optional) - setDisk(e.target.value)}/> - - - - + + @@ -384,30 +474,48 @@ export default function Dashboard() { /> - {!loading ? - + {!loading ? ( + {servers.map((server) => ( - - {server.name} - + + {server.name} + + - OS: {server.os || '-'} + + OS: {server.os || "-"} + - IP: {server.ip || 'Nicht angegeben'} + + IP: {server.ip || "Nicht angegeben"} + @@ -416,150 +524,197 @@ export default function Dashboard() { - CPU: {server.cpu || '-'} + + CPU: {server.cpu || "-"} + - GPU: {server.gpu || '-'} + + GPU: {server.gpu || "-"} + - RAM: {server.ram || '-'} + + RAM: {server.ram || "-"} + - Disk: {server.disk || '-'} + + Disk: {server.disk || "-"} + - + {server.url && ( - window.open(server.url, "_blank")} - > + onClick={() => + window.open(server.url, "_blank") + } + > Open Management URL - - )} - - deleteApplication(server.id)} - > - - - - - openEditDialog(server)} - > - - - - - Edit Server - - - - General - Hardware - - - - - Operating System - - - - - - Windows - Linux - MacOS - - - - - IP Adress - setEditIp(e.target.value)} - /> - - - Management URL - setEditUrl(e.target.value)} - /> - - - + )} + + + deleteApplication(server.id)} + > + + + + + openEditDialog(server)} + > + + + + + + + Edit Server + + + + + + General + + + Hardware + + + + + + + Operating System + + + + + + + + Windows + + + Linux + + + MacOS + + + + + + + IP Adress + + + setEditIp(e.target.value) + } + /> + + + + Management URL + + + setEditUrl(e.target.value) + } + /> + + + - - - - CPU - setEditCpu(e.target.value)} - /> - - - GPU - setEditGpu(e.target.value)} - /> - - - RAM - setEditRam(e.target.value)} - /> - - - Disk - setEditDisk(e.target.value)} - /> - - - - - - - - Cancel - Save - - - + + + + CPU + + setEditCpu(e.target.value) + } + /> + + + GPU + + setEditGpu(e.target.value) + } + /> + + + RAM + + setEditRam(e.target.value) + } + /> + + + + Disk + + + setEditDisk(e.target.value) + } + /> + + + + + + + + Cancel + Save + + + + @@ -567,41 +722,52 @@ export default function Dashboard() { ))} - : + ) : ( - - - - + + + + - - - + + + - - Loading... - + + Loading... - } + + )} - 1} /> - + {currentPage} - @@ -612,5 +778,5 @@ export default function Dashboard() { - ) -} \ No newline at end of file + ); +}