diff --git a/AppImage/app/page.tsx b/AppImage/app/page.tsx
index 4184221..b6d2032 100644
--- a/AppImage/app/page.tsx
+++ b/AppImage/app/page.tsx
@@ -1,7 +1,94 @@
"use client"
+import { useState, useEffect } from "react"
import { ProxmoxDashboard } from "../components/proxmox-dashboard"
+import { Login } from "../components/login"
+import { AuthSetup } from "../components/auth-setup"
+import { getApiUrl } from "../lib/api-config"
export default function Home() {
+ const [authState, setAuthState] = useState<"loading" | "setup" | "login" | "authenticated">("loading")
+
+ useEffect(() => {
+ checkAuthStatus()
+ }, [])
+
+ const checkAuthStatus = async () => {
+ try {
+ const response = await fetch(getApiUrl("/api/auth/status"), {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ })
+
+ const data = await response.json()
+
+ if (!data.auth_enabled) {
+ // Auth no está habilitada, permitir acceso directo
+ setAuthState("authenticated")
+ return
+ }
+
+ // Auth está habilitada, verificar si hay token válido
+ const token = localStorage.getItem("proxmenux-auth-token")
+
+ if (!token) {
+ setAuthState("login")
+ return
+ }
+
+ // Verificar que el token sea válido
+ const verifyResponse = await fetch(getApiUrl("/api/auth/verify"), {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`,
+ },
+ })
+
+ if (verifyResponse.ok) {
+ setAuthState("authenticated")
+ } else {
+ // Token inválido, limpiar y pedir login
+ localStorage.removeItem("proxmenux-auth-token")
+ localStorage.removeItem("proxmenux-saved-username")
+ localStorage.removeItem("proxmenux-saved-password")
+ setAuthState("login")
+ }
+ } catch (error) {
+ console.error("Error checking auth status:", error)
+ // En caso de error, mostrar setup
+ setAuthState("setup")
+ }
+ }
+
+ const handleSetupComplete = () => {
+ setAuthState("login")
+ }
+
+ const handleLoginSuccess = () => {
+ setAuthState("authenticated")
+ }
+
+ if (authState === "loading") {
+ return (
+
+ )
+ }
+
+ if (authState === "setup") {
+ return
+ }
+
+ if (authState === "login") {
+ return
+ }
+
return
}
diff --git a/AppImage/components/proxmox-dashboard.tsx b/AppImage/components/proxmox-dashboard.tsx
index 5090510..a55838e 100644
--- a/AppImage/components/proxmox-dashboard.tsx
+++ b/AppImage/components/proxmox-dashboard.tsx
@@ -56,9 +56,13 @@ interface FlaskSystemData {
interface FlaskSystemInfo {
hostname: string
- node_id: string
- uptime: string
- health_status: "healthy" | "warning" | "critical"
+ uptime_seconds: number
+ uptime_formatted: string
+ health: {
+ status: string
+ summary: string
+ }
+ timestamp: string
}
export function ProxmoxDashboard() {
@@ -98,14 +102,26 @@ export function ProxmoxDashboard() {
const data: FlaskSystemInfo = await response.json()
const uptimeValue =
- data.uptime && typeof data.uptime === "string" && data.uptime.trim() !== "" ? data.uptime : "N/A"
+ data.uptime_formatted && typeof data.uptime_formatted === "string" && data.uptime_formatted.trim() !== ""
+ ? data.uptime_formatted
+ : "N/A"
+
+ const healthStatus = data.health?.status || "healthy"
+ const mappedStatus =
+ healthStatus === "OK"
+ ? "healthy"
+ : healthStatus === "WARNING"
+ ? "warning"
+ : healthStatus === "CRITICAL"
+ ? "critical"
+ : "healthy"
setSystemStatus({
- status: data.health_status || "healthy",
+ status: mappedStatus as "healthy" | "warning" | "critical",
uptime: uptimeValue,
lastUpdate: new Date().toLocaleTimeString("en-US", { hour12: false }),
serverName: data.hostname || "Unknown",
- nodeId: data.node_id || "Unknown",
+ nodeId: data.hostname || "Unknown",
})
setIsServerConnected(true)
} catch (error) {
@@ -193,7 +209,7 @@ export function ProxmoxDashboard() {
localStorage.removeItem("proxmenux-auth-token")
localStorage.removeItem("proxmenux-saved-username")
localStorage.removeItem("proxmenux-saved-password")
- window.location.reload()
+ window.location.href = "/"
}
useEffect(() => {
@@ -273,17 +289,16 @@ export function ProxmoxDashboard() {
onClick={() => setShowHealthModal(true)}
>
- {/* Logo and Title */}
{/* Logo and Title */}
-
-
+
+
{
console.log("[v0] Logo failed to load, using fallback icon")
@@ -295,20 +310,16 @@ export function ProxmoxDashboard() {
}
}}
/>
-
+
-
-
ProxMenux Monitor
-
Proxmox System Dashboard
-
-
- Node: {systemStatus.serverName}
-
+
+
ProxMenux Monitor
+
Proxmox System Dashboard
{/* Desktop Actions */}
-
+
@@ -321,9 +332,7 @@ export function ProxmoxDashboard() {
{systemStatus.status}
-
- Uptime: {systemStatus.uptime || "N/A"}
-
+
Uptime: {systemStatus.uptime}
-
- {/* Mobile Server Info */}
-
- Uptime: {systemStatus.uptime || "N/A"}
-