From d52ce400fb76be0f72e01df644c0692cbbf5e765 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Sat, 18 Oct 2025 10:43:58 +0200 Subject: [PATCH] Update AppImage --- AppImage/components/proxmox-dashboard.tsx | 2 +- AppImage/components/system-logs.tsx | 100 ++++++++-------------- 2 files changed, 37 insertions(+), 65 deletions(-) diff --git a/AppImage/components/proxmox-dashboard.tsx b/AppImage/components/proxmox-dashboard.tsx index edea424..4d415e7 100644 --- a/AppImage/components/proxmox-dashboard.tsx +++ b/AppImage/components/proxmox-dashboard.tsx @@ -455,7 +455,7 @@ export function ProxmoxDashboard() { - + diff --git a/AppImage/components/system-logs.tsx b/AppImage/components/system-logs.tsx index 1122da6..59685c2 100644 --- a/AppImage/components/system-logs.tsx +++ b/AppImage/components/system-logs.tsx @@ -95,13 +95,7 @@ interface CombinedLogEntry { sortTimestamp: number } -// MODIFIED: Fixed props interface - nodeName is already optional -interface SystemLogsProps { - nodeName?: string -} - -// MODIFIED: Fixed function signature - removed incorrect default value syntax -export function SystemLogs({ nodeName }: SystemLogsProps) { +export function SystemLogs() { const [logs, setLogs] = useState([]) const [backups, setBackups] = useState([]) const [events, setEvents] = useState([]) @@ -132,13 +126,9 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { const getApiUrl = (endpoint: string) => { if (typeof window !== "undefined") { - // MODIFIED: Appended nodeName to URL if provided - const baseUrl = `${window.location.protocol}//${window.location.hostname}:8008${endpoint}` - return nodeName ? `${baseUrl}?node=${nodeName}` : baseUrl + return `${window.location.protocol}//${window.location.hostname}:8008${endpoint}` } - // MODIFIED: Appended nodeName to URL if provided - const baseUrl = `http://localhost:8008${endpoint}` - return nodeName ? `${baseUrl}?node=${nodeName}` : baseUrl + return `http://localhost:8008${endpoint}` } useEffect(() => { @@ -162,7 +152,7 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { console.error("[v0] Error loading logs:", err) setLoading(false) }) - }, [dateFilter, customDays, nodeName]) // Added nodeName dependency + }, [dateFilter, customDays]) useEffect(() => { console.log("[v0] Level or service filter changed:", levelFilter, serviceFilter) @@ -184,19 +174,16 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { console.error("[v0] Error loading logs:", err) setLoading(false) }) - }, [levelFilter, serviceFilter, nodeName]) // Added nodeName dependency + }, [levelFilter, serviceFilter]) const fetchAllData = async () => { try { setLoading(true) setError(null) - // Similar to how /api/vms filters VMs/LXCs by node. This ensures that in a cluster - // environment, only backups from the current node are displayed. const [logsRes, backupsRes, eventsRes, notificationsRes] = await Promise.all([ fetchSystemLogs(), - // MODIFIED: getApiUrl will now include nodeName if provided - fetch(getApiUrl("/api/backups")), // Backend should filter by node + fetch(getApiUrl("/api/backups")), fetch(getApiUrl("/api/events?limit=50")), fetch(getApiUrl("/api/notifications")), ]) @@ -308,8 +295,8 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { if (searchTerm) { filters.push("searched") } - // MODIFIED: Include nodeName in filename if available - const filename = `proxmox_logs${nodeName ? `_${nodeName}` : ""}_${filters.length > 0 ? filters.join("_") + "_" : ""}${new Date().toISOString().split("T")[0]}.txt` + + const filename = `proxmox_logs_${filters.length > 0 ? filters.join("_") + "_" : ""}${new Date().toISOString().split("T")[0]}.txt` // Generate log content const logContent = [ @@ -322,8 +309,6 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { `- Level: ${levelFilter === "all" ? "All Levels" : levelFilter}`, `- Service: ${serviceFilter === "all" ? "All Services" : serviceFilter}`, `- Search: ${searchTerm || "None"}`, - // MODIFIED: Include Node in filters if available - nodeName && `- Node: ${nodeName}`, ``, `${"=".repeat(80)}`, ``, @@ -367,7 +352,6 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { if (upid) { // Try to fetch the complete task log from Proxmox try { - // MODIFIED: getApiUrl will now include nodeName if provided const response = await fetch(getApiUrl(`/api/task-log/${encodeURIComponent(upid)}`)) if (response.ok) { @@ -455,10 +439,7 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { const matchesLevel = levelFilter === "all" || log.level === levelFilter const matchesService = serviceFilter === "all" || log.service === serviceFilter - // MODIFIED: Filter by nodeName if provided - const matchesNode = !nodeName || log.source.includes(`Node: ${nodeName}`) - - return matchesSearch && matchesLevel && matchesService && matchesNode + return matchesSearch && matchesLevel && matchesService }) const displayedLogs = filteredCombinedLogs.slice(0, displayedLogsCount) @@ -555,10 +536,7 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { info: logs.filter((log) => ["info", "notice", "debug"].includes(log.level)).length, } - // MODIFIED: Filter uniqueServices by nodeName if provided - const uniqueServices = [ - ...new Set(logs.filter((log) => !nodeName || log.source.includes(`Node: ${nodeName}`)).map((log) => log.service)), - ] + const uniqueServices = [...new Set(logs.map((log) => log.service))] const getBackupType = (volid: string): "vm" | "lxc" => { if (volid.includes("/vm/") || volid.includes("vzdump-qemu")) { @@ -600,16 +578,14 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { return type === "pbs" ? "PBS" : "PVE" } - // MODIFIED: Filter backups by nodeName if provided - const filteredBackups = nodeName ? backups.filter((b) => b.storage.includes(nodeName)) : backups const backupStats = { - total: filteredBackups.length, - totalSize: filteredBackups.reduce((sum, b) => sum + b.size, 0), - qemu: filteredBackups.filter((b) => { + total: backups.length, + totalSize: backups.reduce((sum, b) => sum + b.size, 0), + qemu: backups.filter((b) => { // Check if volid contains /vm/ for QEMU or vzdump-qemu for PVE return b.volid.includes("/vm/") || b.volid.includes("vzdump-qemu") }).length, - lxc: filteredBackups.filter((b) => { + lxc: backups.filter((b) => { // Check if volid contains /ct/ for LXC or vzdump-lxc for PVE return b.volid.includes("/ct/") || b.volid.includes("vzdump-lxc") }).length, @@ -653,8 +629,7 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { } } - // MODIFIED: Conditionally render loading state based on nodeName - if (loading && logs.length === 0 && events.length === 0 && backups.length === 0 && notifications.length === 0) { + if (loading && logs.length === 0 && events.length === 0) { return (
@@ -664,7 +639,7 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { return (
- {loading && (logs.length > 0 || events.length > 0 || backups.length > 0 || notifications.length > 0) && ( + {loading && (logs.length > 0 || events.length > 0) && (
@@ -730,8 +705,6 @@ export function SystemLogs({ nodeName }: SystemLogsProps) { System Logs & Events - {/* MODIFIED: Display nodeName if provided */} - {nodeName && ({nodeName})}