From 9d81ffffe8f32d4a0b05eae809c7f903fb6f97f4 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Tue, 4 Nov 2025 22:47:11 +0100 Subject: [PATCH] Update proxmox-dashboard.tsx --- AppImage/components/proxmox-dashboard.tsx | 336 ++++++---------------- 1 file changed, 95 insertions(+), 241 deletions(-) diff --git a/AppImage/components/proxmox-dashboard.tsx b/AppImage/components/proxmox-dashboard.tsx index 7daf7a0..da744ba 100644 --- a/AppImage/components/proxmox-dashboard.tsx +++ b/AppImage/components/proxmox-dashboard.tsx @@ -10,12 +10,10 @@ import { NetworkMetrics } from "./network-metrics" import { VirtualMachines } from "./virtual-machines" import Hardware from "./hardware" import { SystemLogs } from "./system-logs" -import { AuthSetup } from "./auth-setup" -import { Login } from "./login" -import { Settings } from "./settings" -import { getApiUrl, getApiBaseUrl } from "../lib/api-config" -import { HealthStatusModal } from "./health-status-modal" +import { OnboardingCarousel } from "./onboarding-carousel" +import { getApiUrl } from "../lib/api-config" import { + RefreshCw, AlertTriangle, CheckCircle, XCircle, @@ -27,8 +25,8 @@ import { Box, Cpu, FileText, - SettingsIcon, } from "lucide-react" +import Image from "next/image" import { ThemeToggle } from "./theme-toggle" import { Sheet, SheetContent, SheetTrigger } from "./ui/sheet" @@ -50,18 +48,7 @@ interface FlaskSystemData { load_average: number[] } -console.log("[v0] ========================================") -console.log("[v0] ProxmoxDashboard component file loaded!") -console.log("[v0] Timestamp:", new Date().toISOString()) -console.log("[v0] ========================================") - export function ProxmoxDashboard() { - console.log("[v0] ========================================") - console.log("[v0] ProxmoxDashboard component MOUNTING") - console.log("[v0] Window location:", typeof window !== "undefined" ? window.location.href : "SSR") - console.log("[v0] API Base URL:", typeof window !== "undefined" ? getApiBaseUrl() : "SSR") - console.log("[v0] ========================================") - const [systemStatus, setSystemStatus] = useState({ status: "healthy", uptime: "Loading...", @@ -76,11 +63,6 @@ export function ProxmoxDashboard() { const [activeTab, setActiveTab] = useState("overview") const [showNavigation, setShowNavigation] = useState(true) const [lastScrollY, setLastScrollY] = useState(0) - const [authChecked, setAuthChecked] = useState(false) - const [authRequired, setAuthRequired] = useState(false) - const [isAuthenticated, setIsAuthenticated] = useState(false) - const [authDeclined, setAuthDeclined] = useState(false) - const [showHealthModal, setShowHealthModal] = useState(false) const fetchSystemData = useCallback(async () => { console.log("[v0] Fetching system data from Flask server...") @@ -232,205 +214,14 @@ export function ProxmoxDashboard() { return "Hardware" case "logs": return "System Logs" - case "settings": - return "Settings" default: return "Navigation Menu" } } - const setupTokenRefresh = () => { - let refreshTimeout: ReturnType - - const refreshToken = async () => { - const token = localStorage.getItem("proxmenux-auth-token") - if (!token) return - - try { - const response = await fetch(getApiUrl("/api/auth/refresh"), { - method: "POST", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${token}`, - }, - }) - - if (response.ok) { - const data = await response.json() - localStorage.setItem("proxmenux-auth-token", data.token) - console.log("[v0] Token refreshed successfully") - } - } catch (error) { - console.error("[v0] Failed to refresh token:", error) - } - } - - const resetRefreshTimer = () => { - clearTimeout(refreshTimeout) - // Refresh token every 25 minutes (before 30 min expiry) - refreshTimeout = setTimeout(refreshToken, 25 * 60 * 1000) - } - - // Refresh on user activity - const events = ["mousedown", "keydown", "scroll", "touchstart"] - events.forEach((event) => { - window.addEventListener(event, resetRefreshTimer, { passive: true }) - }) - - resetRefreshTimer() - - return () => { - clearTimeout(refreshTimeout) - events.forEach((event) => { - window.removeEventListener(event, resetRefreshTimer) - }) - } - } - - const handleAuthSetupComplete = () => { - setAuthDeclined(true) - setIsAuthenticated(true) - } - - const handleLoginSuccess = () => { - setIsAuthenticated(true) - setupTokenRefresh() - } - - const handleLogout = () => { - localStorage.removeItem("proxmenux-auth-token") - setIsAuthenticated(false) - } - - useEffect(() => { - const checkAuth = async () => { - console.log("[v0] ===== AUTH CHECK START =====") - console.log("[v0] Current URL:", window.location.href) - console.log("[v0] Window origin:", window.location.origin) - - try { - const token = localStorage.getItem("proxmenux-auth-token") - const headers: HeadersInit = { "Content-Type": "application/json" } - - if (token) { - headers["Authorization"] = `Bearer ${token}` - console.log("[v0] Token found in localStorage") - } else { - console.log("[v0] No token in localStorage") - } - - const apiUrl = getApiUrl("/api/auth/status") - console.log("[v0] Auth status API URL:", apiUrl) - - const response = await fetch(apiUrl, { headers }) - console.log("[v0] Auth status response status:", response.status) - console.log("[v0] Auth status response ok:", response.ok) - - if (!response.ok) { - throw new Error(`Auth status check failed with status: ${response.status}`) - } - - const data = await response.json() - console.log("[v0] Auth status response data:", JSON.stringify(data, null, 2)) - - console.log("[v0] Setting authRequired to:", data.auth_enabled) - console.log("[v0] Setting isAuthenticated to:", data.authenticated) - console.log("[v0] auth_configured value:", data.auth_configured) - - setAuthRequired(data.auth_enabled) - setIsAuthenticated(data.authenticated) - - // auth_configured will be true if user either set up auth OR declined it - const shouldShowModal = !data.auth_configured - console.log("[v0] Should show modal:", shouldShowModal) - console.log("[v0] Setting authDeclined to:", data.auth_configured) - - setAuthDeclined(data.auth_configured) // If configured (either way), don't show modal - setAuthChecked(true) - - if (data.authenticated && token) { - setupTokenRefresh() - } - - console.log("[v0] ===== AUTH CHECK SUCCESS =====") - } catch (error) { - console.error("[v0] ===== AUTH CHECK FAILED =====") - console.error("[v0] Failed to check auth status:", error) - console.error("[v0] Error message:", error instanceof Error ? error.message : "Unknown error") - - console.log("[v0] Setting authDeclined to false (show modal on error)") - console.log("[v0] Setting authRequired to false (don't require login on error)") - - setAuthDeclined(false) // Show modal when API fails - setAuthRequired(false) // Don't require login on error - setAuthChecked(true) - - console.log("[v0] ===== AUTH CHECK ERROR HANDLED =====") - } - } - - checkAuth() - }, []) - - if (!authChecked) { - return ( -
-
-
-

Loading...

-
-
- ) - } - - if (authRequired && !isAuthenticated) { - return - } - return (
- - -
setShowHealthModal(true)} - > -
-
-
-
- -

ProxMenuX

-
- - {systemStatus.status === "healthy" && "Healthy"} - {systemStatus.status === "warning" && "Warning"} - {systemStatus.status === "critical" && "Critical"} - {systemStatus.serverName === "Loading..." && "Loading..."} - -
-
- - {isAuthenticated && ( - - )} -
-
-
-
- - {!authDeclined && !authRequired && } + {!isServerConnected && (
@@ -453,6 +244,94 @@ export function ProxmoxDashboard() {
)} +
+
+ {/* Logo and Title */} +
+ {/* Logo and Title */} +
+
+ ProxMenux Logo { + console.log("[v0] Logo failed to load, using fallback icon") + const target = e.target as HTMLImageElement + target.style.display = "none" + const fallback = target.parentElement?.querySelector(".fallback-icon") + if (fallback) { + fallback.classList.remove("hidden") + } + }} + /> + +
+
+

ProxMenux Monitor

+

Proxmox System Dashboard

+
+ + Node: {systemStatus.serverName} +
+
+
+ + {/* Desktop Actions */} +
+
+ +
+
Node: {systemStatus.serverName}
+
+
+ + + {statusIcon} + {systemStatus.status} + + +
Uptime: {systemStatus.uptime}
+ + + + +
+ + {/* Mobile Actions */} +
+ + {statusIcon} + {systemStatus.status} + + + + + +
+
+ + {/* Mobile Server Info */} +
+ Uptime: {systemStatus.uptime} +
+
+
+
- + System Logs - - Settings - @@ -613,21 +486,6 @@ export function ProxmoxDashboard() { System Logs -
@@ -660,14 +518,10 @@ export function ProxmoxDashboard() { - - - -