diff --git a/AppImage/components/proxmox-dashboard.tsx b/AppImage/components/proxmox-dashboard.tsx index 09bfa5c..afe2031 100644 --- a/AppImage/components/proxmox-dashboard.tsx +++ b/AppImage/components/proxmox-dashboard.tsx @@ -45,11 +45,24 @@ export function ProxmoxDashboard() { const fetchSystemData = useCallback(async () => { console.log("[v0] Fetching system data from Flask server...") + console.log("[v0] Current window location:", window.location.href) + + // Usar ruta relativa si estamos en el mismo servidor, sino usar localhost:8008 + const apiUrl = + window.location.hostname === "localhost" && window.location.port === "8008" + ? "/api/system" // Ruta relativa cuando estamos en el servidor Flask + : "http://localhost:8008/api/system" // URL completa para desarrollo + + console.log("[v0] API URL:", apiUrl) + try { - const response = await fetch("http://localhost:8008/api/system") + const response = await fetch(apiUrl) + console.log("[v0] Response status:", response.status) + if (!response.ok) { - throw new Error("Server not responding") + throw new Error(`Server responded with status: ${response.status}`) } + const data: FlaskSystemData = await response.json() console.log("[v0] System data received:", data) @@ -70,6 +83,12 @@ export function ProxmoxDashboard() { setIsServerConnected(true) } catch (error) { console.error("[v0] Failed to fetch system data from Flask server:", error) + console.error("[v0] Error details:", { + message: error instanceof Error ? error.message : "Unknown error", + apiUrl, + windowLocation: window.location.href, + }) + setIsServerConnected(false) setSystemStatus((prev) => ({ ...prev, @@ -122,14 +141,25 @@ export function ProxmoxDashboard() {
{!isServerConnected && (
-
-
+
+
- Flask Server Offline - - • Start the server:{" "} - python3 AppImage/scripts/flask_server.py - + Flask Server Connection Failed +
+
+

• Check that the AppImage is running correctly

+

• The Flask server should start automatically on port 8008

+

+ • Try accessing:{" "} + + http://localhost:8008/api/health + +

@@ -140,7 +170,7 @@ export function ProxmoxDashboard() {
-
+
ProxMenux Logo { + console.log("[v0] Logo failed to load, using fallback icon") const target = e.target as HTMLImageElement target.style.display = "none" - document.querySelector(".fallback-icon")?.classList.remove("hidden") + const fallback = target.parentElement?.querySelector(".fallback-icon") + if (fallback) { + fallback.classList.remove("hidden") + } }} /> diff --git a/AppImage/scripts/flask_server.py b/AppImage/scripts/flask_server.py index 93fee19..c93f15b 100644 --- a/AppImage/scripts/flask_server.py +++ b/AppImage/scripts/flask_server.py @@ -191,17 +191,31 @@ def serve_static_files(filename): def serve_images(filename): """Serve image files""" try: + appimage_root = os.environ.get('APPDIR') + if not appimage_root: + base_dir = os.path.dirname(os.path.abspath(__file__)) + appimage_root = os.path.dirname(base_dir) + image_paths = [ - os.path.join(os.path.dirname(__file__), '..', 'web', 'public', 'images'), - os.path.join(os.path.dirname(__file__), '..', 'public', 'images'), - os.path.dirname(__file__) + os.path.join(appimage_root, 'web', 'images'), # Ruta principal para exportación estática + os.path.join(appimage_root, 'usr', 'web', 'images'), # Fallback con usr/ + os.path.join(appimage_root, 'web', 'public', 'images'), # Ruta con public/ + os.path.join(appimage_root, 'usr', 'web', 'public', 'images'), # Fallback usr/public/ + os.path.join(appimage_root, 'public', 'images'), # Ruta directa a public + os.path.join(appimage_root, 'usr', 'public', 'images'), # Fallback usr/public ] + print(f"[v0] Looking for image: {filename}") for image_dir in image_paths: file_path = os.path.join(image_dir, filename) - if os.path.exists(file_path): + abs_path = os.path.abspath(file_path) + exists = os.path.exists(abs_path) + print(f"[v0] Checking: {abs_path} - {'FOUND' if exists else 'NOT FOUND'}") + if exists: + print(f"[v0] Serving image from: {abs_path}") return send_from_directory(image_dir, filename) - + + print(f"[v0] Image not found: {filename}") return '', 404 except Exception as e: print(f"Error serving image {filename}: {e}")