From 306d2fc3367edfec80d4b3fe27a9af50c3b62fbf Mon Sep 17 00:00:00 2001 From: samang-dauth Date: Thu, 3 Jul 2025 17:22:30 +0700 Subject: [PATCH] Fix: Instance monitoring dashboard styling --- application/src/pages/InstanceMonitoring.tsx | 66 ++++++++++++-------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/application/src/pages/InstanceMonitoring.tsx b/application/src/pages/InstanceMonitoring.tsx index 586cdfe..7ad1fc4 100644 --- a/application/src/pages/InstanceMonitoring.tsx +++ b/application/src/pages/InstanceMonitoring.tsx @@ -1,3 +1,4 @@ + import { useState, useEffect } from "react"; import { useQuery } from "@tanstack/react-query"; import { useTheme } from "@/contexts/ThemeContext"; @@ -11,70 +12,83 @@ import { Server, ServerStats } from "@/types/server.types"; import { useSidebar } from "@/contexts/SidebarContext"; import { authService } from "@/services/authService"; import { useNavigate } from "react-router-dom"; + const InstanceMonitoring = () => { - const { - theme - } = useTheme(); - const { - t - } = useLanguage(); - const { - sidebarCollapsed, - toggleSidebar - } = useSidebar(); + const { theme } = useTheme(); + const { t } = useLanguage(); + const { sidebarCollapsed, toggleSidebar } = useSidebar(); const navigate = useNavigate(); + const [stats, setStats] = useState({ total: 0, online: 0, offline: 0, warning: 0 }); + const [currentUser, setCurrentUser] = useState(authService.getCurrentUser()); - const { - data: servers = [], - isLoading, - error, - refetch - } = useQuery({ + + const { data: servers = [], isLoading, error, refetch } = useQuery({ queryKey: ['servers'], queryFn: serverService.getServers, refetchInterval: 30000 // Refetch every 30 seconds }); + useEffect(() => { if (servers.length > 0) { serverService.getServerStats(servers).then(setStats); } }, [servers]); + const handleRefresh = () => { refetch(); }; + const handleLogout = () => { authService.logout(); navigate('/login'); }; + if (error) { - return
+ return ( +
-
-
+
+

Error loading servers

Unable to fetch server data. Please check your connection and try again.

-
-
; +
+ ); } - return
+ + return ( +
-
-
+
+
{/* Header Section */} @@ -103,6 +117,8 @@ const InstanceMonitoring = () => {
-
; +
+ ); }; + export default InstanceMonitoring; \ No newline at end of file