From f021afb6a4c094cd1853fc6b3b57633d24589343 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Sat, 18 Oct 2025 16:11:28 +0200 Subject: [PATCH] Update AppImage and ZimaOS --- AppImage/components/system-logs.tsx | 269 ++++++++++++++-------------- scripts/vm/zimaos.sh | 74 +++++++- 2 files changed, 207 insertions(+), 136 deletions(-) diff --git a/AppImage/components/system-logs.tsx b/AppImage/components/system-logs.tsx index 3ee4b8c..627193a 100644 --- a/AppImage/components/system-logs.tsx +++ b/AppImage/components/system-logs.tsx @@ -121,7 +121,7 @@ export function SystemLogs() { const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false) - const [dateFilter, setDateFilter] = useState("1") + const [dateFilter, setDateFilter] = useState("1") // Changed from "now" to "1" to load 1 day by default const [customDays, setCustomDays] = useState("1") const getApiUrl = (endpoint: string) => { @@ -132,12 +132,10 @@ export function SystemLogs() { } useEffect(() => { - // Initial fetch might be redundant if dateFilter is not "now" anymore, but keeping for now - // if (dateFilter === "now") { fetchAllData() - // } }, []) + // CHANGE: Simplified useEffect - always fetch logs with date filter (no more "now" option) useEffect(() => { console.log("[v0] Date filter changed:", dateFilter, "Custom days:", customDays) setLoading(true) @@ -156,24 +154,30 @@ export function SystemLogs() { useEffect(() => { console.log("[v0] Level or service filter changed:", levelFilter, serviceFilter) - setLoading(true) - fetchSystemLogs() - .then((newLogs) => { - console.log( - "[v0] Loaded logs for filters - Level:", - levelFilter, - "Service:", - serviceFilter, - "Count:", - newLogs.length, - ) - setLogs(newLogs) - setLoading(false) - }) - .catch((err) => { - console.error("[v0] Error loading logs:", err) - setLoading(false) - }) + if (levelFilter !== "all" || serviceFilter !== "all") { + setLoading(true) + fetchSystemLogs() + .then((newLogs) => { + console.log( + "[v0] Loaded logs for filters - Level:", + levelFilter, + "Service:", + serviceFilter, + "Count:", + newLogs.length, + ) + setLogs(newLogs) + setLoading(false) + }) + .catch((err) => { + console.error("[v0] Error loading logs:", err) + setLoading(false) + }) + } else { + // Only reload all data if we're on "now" and all filters are cleared + // This else block is now theoretically unreachable given the change above, but kept for safety + fetchAllData() + } }, [levelFilter, serviceFilter]) const fetchAllData = async () => { @@ -181,13 +185,6 @@ export function SystemLogs() { setLoading(true) setError(null) - // NOTE: Backend endpoints should filter data by current node only - // When a node belongs to a cluster, only show data for that specific node: - // - /api/logs - should return logs only from current node - // - /api/backups - should return backups only from current node - // - /api/events - should return events only from current node - // - /api/notifications - should return notifications only from current node - const [logsRes, backupsRes, eventsRes, notificationsRes] = await Promise.all([ fetchSystemLogs(), fetch(getApiUrl("/api/backups")), @@ -224,6 +221,7 @@ export function SystemLogs() { let apiUrl = getApiUrl("/api/logs") const params = new URLSearchParams() + // CHANGE: Always add since_days parameter (no more "now" option) const daysAgo = dateFilter === "custom" ? Number.parseInt(customDays) : Number.parseInt(dateFilter) params.append("since_days", daysAgo.toString()) console.log("[v0] Fetching logs since_days:", daysAgo) @@ -289,10 +287,10 @@ export function SystemLogs() { try { // Generate filename based on active filters const filters = [] - if (dateFilter !== "30") { - const days = dateFilter === "custom" ? customDays : dateFilter - filters.push(`${days}days`) - } + // CHANGE: Always include days in filename (no more "now" option) + const days = dateFilter === "custom" ? customDays : dateFilter + filters.push(`${days}days`) + if (levelFilter !== "all") { filters.push(levelFilter) } @@ -312,7 +310,7 @@ export function SystemLogs() { `Total Entries: ${filteredCombinedLogs.length.toLocaleString()}`, ``, `Filters Applied:`, - `- Date Range: ${dateFilter === "custom" ? `${customDays} days ago` : `${dateFilter} days ago`}`, + `- Date Range: ${dateFilter === "now" ? "Current logs" : dateFilter === "custom" ? `${customDays} days ago` : `${dateFilter} days ago`}`, `- Level: ${levelFilter === "all" ? "All Levels" : levelFilter}`, `- Service: ${serviceFilter === "all" ? "All Services" : serviceFilter}`, `- Search: ${searchTerm || "None"}`, @@ -812,7 +810,6 @@ export function SystemLogs() { 1 week ago 2 weeks ago 1 month ago - 3 months ago Custom days @@ -828,6 +825,18 @@ export function SystemLogs() { /> )} + +