diff --git a/app/dashboard/applications/Applications.tsx b/app/dashboard/applications/Applications.tsx index ae9f14f..d187546 100644 --- a/app/dashboard/applications/Applications.tsx +++ b/app/dashboard/applications/Applications.tsx @@ -16,7 +16,7 @@ import { SidebarTrigger, } from "@/components/ui/sidebar"; import { Button } from "@/components/ui/button"; -import { Plus, Link, Home, Trash2 } from "lucide-react"; +import { Plus, Link, Home, Trash2, LayoutGrid, List } from "lucide-react"; import { Card, CardContent, @@ -55,7 +55,7 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; - +import Cookies from "js-cookie"; import { useState, useEffect } from "react"; import axios from 'axios'; @@ -70,6 +70,22 @@ export default function Dashboard() { const [maxPage, setMaxPage] = useState(1); const [applications, setApplications] = useState([]); const [servers, setServers] = useState([]); + const [isGridLayout, setIsGridLayout] = useState(false); + + useEffect(() => { + const savedLayout = Cookies.get('layoutPreference'); + setIsGridLayout(savedLayout === 'grid'); + }, []); + + const toggleLayout = () => { + const newLayout = !isGridLayout; + setIsGridLayout(newLayout); + Cookies.set('layoutPreference', newLayout ? 'grid' : 'standard', { + expires: 365, + path: '/', + sameSite: 'strict' + }); + }; const add = async () => { try { @@ -142,20 +158,29 @@ export default function Dashboard() {
Your Applications - {servers.length === 0 ? ( -

You must first add a server.

- ) : ( - - - - - - - Add an application - -
+
+ + {servers.length === 0 ? ( +

You must first add a server.

+ ) : ( + + + + + + + Add an application + +
setName(e.target.value)}/> @@ -191,41 +216,50 @@ export default function Dashboard() { setLocalURL(e.target.value)}/>
-
-
-
- - Cancel - - -
-
- )} +
+ + + + Cancel + + + + + )} +

- {applications.map((app) => ( - - -
-
-
- {app.icon ? ( - {app.name} - ) : ( - Image - )} +
+ {applications.map((app) => ( + + +
+
+
+ {app.icon ? ( + {app.name} + ) : ( + Image + )} +
+
+ {app.name} + + {app.description}
+ Server: {app.server || 'No server'} +
+
-
- {app.name} - - {app.description}
- Server: {app.server || 'No server'} -
-
-
-
+
diff --git a/app/dashboard/servers/Servers.tsx b/app/dashboard/servers/Servers.tsx index 5015dab..e31f844 100644 --- a/app/dashboard/servers/Servers.tsx +++ b/app/dashboard/servers/Servers.tsx @@ -16,7 +16,7 @@ import { SidebarTrigger, } from "@/components/ui/sidebar" import { Button } from "@/components/ui/button" -import { Plus, Link, MonitorCog, FileDigit, Trash2 } from "lucide-react" // Importiere Icons +import { Plus, Link, MonitorCog, FileDigit, Trash2, LayoutGrid, List } from "lucide-react" import { Card, CardContent, @@ -54,13 +54,13 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select" - import { +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip" - +import Cookies from "js-cookie"; import { useState, useEffect } from "react"; import axios from 'axios'; @@ -69,10 +69,25 @@ export default function Dashboard() { const [os, setOs] = useState(""); const [ip, setIp] = useState(""); const [url, setUrl] = useState(""); - const [currentPage, setCurrentPage] = useState(1); const [maxPage, setMaxPage] = useState(1); const [servers, setServers] = useState([]); + const [isGridLayout, setIsGridLayout] = useState(false); + + useEffect(() => { + const savedLayout = Cookies.get('layoutPreference'); + setIsGridLayout(savedLayout === 'grid'); + }, []); + + const toggleLayout = () => { + const newLayout = !isGridLayout; + setIsGridLayout(newLayout); + Cookies.set('layoutPreference', newLayout ? 'grid' : 'standard', { + expires: 365, + path: '/', + sameSite: 'strict' + }); + }; const add = async () => { try { @@ -140,138 +155,171 @@ export default function Dashboard() {
-
+
Your Servers - - - - - - - Add an server - -
-
- - setName(e.target.value)}/> +
+ + + + + + + {isGridLayout ? + "Switch to list view" : + "Switch to grid view"} + + + + + + + + + + Add an server + +
+
+ + setName(e.target.value)}/> +
+
+ + +
+
+ + setIp(e.target.value)}/> +
+
+ + + + + + + Link to a web interface (e.g. Proxmox or Portainer) with which the server can be managed + + + + setUrl(e.target.value)}/> +
-
- - -
-
- - setIp(e.target.value)}/> -
-
- - - - - - - Link to a web interface (e.g. Proxmox or Portainer) with which the server can be managed - - - - setUrl(e.target.value)}/> -
-
- - - - Cancel - - - - + + + + Cancel + + + + +

- {servers.map((server) => ( - - -
-
-
- {server.name} - -
- - OS: {server.os || '-'} -
-
- - IP: {server.ip || 'Nicht angegeben'} -
-
+
+ {servers.map((server) => ( + + +
+
+
+ {server.name} + +
+ + OS: {server.os || '-'} +
+
+ + IP: {server.ip || 'Nicht angegeben'} +
+
+
+
+
+
+
+ {server.url && ( + + )} +
+ +
-
-
-
- {server.url && ( - - )} -
- -
-
-
- - - ))} + + + ))} +
- - - - 1} - /> - - - - {currentPage} - + + + + 1} + /> + + + + {currentPage} + - - - - - -
+ + + + + +
) -} +} \ No newline at end of file