From 1e8682646d229da9d98b1484158a4edbd8e674d2 Mon Sep 17 00:00:00 2001 From: headlessdev Date: Tue, 15 Apr 2025 16:11:31 +0200 Subject: [PATCH] Dashboard Styling Update --- app/dashboard/Dashboard.tsx | 158 +++++++++++++++++++----------------- 1 file changed, 85 insertions(+), 73 deletions(-) diff --git a/app/dashboard/Dashboard.tsx b/app/dashboard/Dashboard.tsx index 30e29cf..b096e62 100644 --- a/app/dashboard/Dashboard.tsx +++ b/app/dashboard/Dashboard.tsx @@ -1,66 +1,61 @@ -import { AppSidebar } from "@/components/app-sidebar"; +"use client" + +import { useEffect, useState } from "react" +import axios from "axios" +import Link from "next/link" +import { Activity, Layers, Network, Server } from "lucide-react" + +import { AppSidebar } from "@/components/app-sidebar" import { Breadcrumb, BreadcrumbItem, - BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, -} from "@/components/ui/breadcrumb"; -import { Separator } from "@/components/ui/separator"; -import { - SidebarInset, - SidebarProvider, - SidebarTrigger, -} from "@/components/ui/sidebar"; -import { useEffect, useState } from "react"; -import axios from "axios"; // Korrekter Import +} from "@/components/ui/breadcrumb" +import { Separator } from "@/components/ui/separator" +import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" -import { Activity, Layers, Network, Server } from "lucide-react"; -import { Button } from "@/components/ui/button"; +import { Button } from "@/components/ui/button" interface StatsResponse { - serverCount: number; - applicationCount: number; - onlineApplicationsCount: number; + serverCount: number + applicationCount: number + onlineApplicationsCount: number } -import Link from "next/link"; - export default function Dashboard() { - const [serverCount, setServerCount] = useState(0); - const [applicationCount, setApplicationCount] = useState(0); - const [onlineApplicationsCount, setOnlineApplicationsCount] = useState(0); + const [serverCount, setServerCount] = useState(0) + const [applicationCount, setApplicationCount] = useState(0) + const [onlineApplicationsCount, setOnlineApplicationsCount] = useState(0) const getStats = async () => { try { - const response = await axios.post('/api/dashboard/get', {}); - setServerCount(response.data.serverCount); - setApplicationCount(response.data.applicationCount); - setOnlineApplicationsCount(response.data.onlineApplicationsCount); + const response = await axios.post("/api/dashboard/get", {}) + setServerCount(response.data.serverCount) + setApplicationCount(response.data.applicationCount) + setOnlineApplicationsCount(response.data.onlineApplicationsCount) } catch (error: any) { - console.log("Axios error:", error.response?.data); + console.log("Axios error:", error.response?.data) } - }; + } useEffect(() => { - getStats(); - }, []); + getStats() + }, []) return ( -
+
- - / - + / @@ -70,87 +65,104 @@ export default function Dashboard() {
-
-

Dashboard

-
+
+

Dashboard

-
- - +
+ +
- Servers - + Servers +
Manage your server infrastructure
- -
{serverCount}
-

Active servers

+ +
{serverCount}
+

Active servers

- -
- - + +
- Applications - + Applications +
Manage your deployed applications
- -
{applicationCount}
-

Running applications

+ +
{applicationCount}
+

Running applications

- -
- - + +
- Uptime - + Uptime +
Monitor your service availability
- -
{onlineApplicationsCount}/{applicationCount}
-

online Applications

+ +
+
+ + {onlineApplicationsCount}/{applicationCount} + +
+ {applicationCount > 0 ? Math.round((onlineApplicationsCount / applicationCount) * 100) : 0}% +
+
+
+
0 ? Math.round((onlineApplicationsCount / applicationCount) * 100) : 0}%`, + }} + >
+
+

Online applications

+
- -
- - + +
- Network - + Network +
Manage network configuration
- -
{serverCount + applicationCount}
-

Active connections

+ +
{serverCount + applicationCount}
+

Active connections

- -
+
)