From 8dc2b833f43fa1f801287f341548c7ff4852ec92 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Fri, 7 Nov 2025 12:54:10 +0100 Subject: [PATCH] Update AppImage --- AppImage/components/network-metrics.tsx | 22 +++++-------------- AppImage/components/network-traffic-chart.tsx | 10 ++------- AppImage/components/node-metrics-charts.tsx | 6 ----- AppImage/components/proxmox-dashboard.tsx | 12 ++++------ AppImage/components/system-overview.tsx | 20 +++-------------- AppImage/components/virtual-machines.tsx | 4 ++-- 6 files changed, 17 insertions(+), 57 deletions(-) diff --git a/AppImage/components/network-metrics.tsx b/AppImage/components/network-metrics.tsx index 5a5458b..0d9386a 100644 --- a/AppImage/components/network-metrics.tsx +++ b/AppImage/components/network-metrics.tsx @@ -73,10 +73,6 @@ interface NetworkInterface { vm_status?: string } -interface NetworkMetricsProps { - isActive?: boolean -} - const getInterfaceTypeBadge = (type: string) => { switch (type) { case "physical": @@ -147,16 +143,15 @@ const fetcher = async (url: string): Promise => { return response.json() } -export function NetworkMetrics({ isActive = true }: NetworkMetricsProps) { +export function NetworkMetrics() { const { data: networkData, error, isLoading, } = useSWR("/api/network", fetcher, { - refreshInterval: isActive ? 60000 : 0, // Refresh every 60 seconds only if active, otherwise pause + refreshInterval: 60000, // Refresh every 60 seconds revalidateOnFocus: false, revalidateOnReconnect: true, - isPaused: () => !isActive, }) const [selectedInterface, setSelectedInterface] = useState(null) @@ -171,15 +166,10 @@ export function NetworkMetrics({ isActive = true }: NetworkMetricsProps) { revalidateOnReconnect: true, }) - const { data: interfaceHistoricalData } = useSWR( - isActive ? `/api/node/metrics?timeframe=${timeframe}` : null, - fetcher, - { - refreshInterval: isActive ? 30000 : 0, - revalidateOnFocus: false, - isPaused: () => !isActive, - }, - ) + const { data: interfaceHistoricalData } = useSWR(`/api/node/metrics?timeframe=${timeframe}`, fetcher, { + refreshInterval: 30000, + revalidateOnFocus: false, + }) if (isLoading) { return ( diff --git a/AppImage/components/network-traffic-chart.tsx b/AppImage/components/network-traffic-chart.tsx index 770ebe3..a1576f3 100644 --- a/AppImage/components/network-traffic-chart.tsx +++ b/AppImage/components/network-traffic-chart.tsx @@ -16,7 +16,6 @@ interface NetworkTrafficChartProps { interfaceName?: string onTotalsCalculated?: (totals: { received: number; sent: number }) => void refreshInterval?: number // En milisegundos, por defecto 60000 (60 segundos) - isActive?: boolean } const CustomNetworkTooltip = ({ active, payload, label }: any) => { @@ -44,7 +43,6 @@ export function NetworkTrafficChart({ interfaceName, onTotalsCalculated, refreshInterval = 60000, - isActive = true, }: NetworkTrafficChartProps) { const [data, setData] = useState([]) const [loading, setLoading] = useState(true) @@ -61,20 +59,16 @@ export function NetworkTrafficChart({ }, [timeframe, interfaceName]) useEffect(() => { - if (refreshInterval > 0 && isActive) { + if (refreshInterval > 0) { const interval = setInterval(() => { fetchMetrics() }, refreshInterval) return () => clearInterval(interval) } - }, [timeframe, interfaceName, refreshInterval, isActive]) + }, [timeframe, interfaceName, refreshInterval]) const fetchMetrics = async () => { - if (!isActive) { - return - } - if (isInitialLoad) { setLoading(true) } diff --git a/AppImage/components/node-metrics-charts.tsx b/AppImage/components/node-metrics-charts.tsx index d6b16f7..a8d86e4 100644 --- a/AppImage/components/node-metrics-charts.tsx +++ b/AppImage/components/node-metrics-charts.tsx @@ -78,12 +78,6 @@ export function NodeMetricsCharts() { useEffect(() => { console.log("[v0] NodeMetricsCharts component mounted") fetchMetrics() - - const interval = setInterval(() => { - fetchMetrics() - }, 60000) // 60 seconds instead of 30 to reduce server load - - return () => clearInterval(interval) }, [timeframe]) const fetchMetrics = async () => { diff --git a/AppImage/components/proxmox-dashboard.tsx b/AppImage/components/proxmox-dashboard.tsx index 4fd11b2..e4cbda6 100644 --- a/AppImage/components/proxmox-dashboard.tsx +++ b/AppImage/components/proxmox-dashboard.tsx @@ -10,9 +10,9 @@ import { NetworkMetrics } from "./network-metrics" import { VirtualMachines } from "./virtual-machines" import Hardware from "./hardware" import { SystemLogs } from "./system-logs" +import { Settings } from "./settings" import { OnboardingCarousel } from "./onboarding-carousel" import { HealthStatusModal } from "./health-status-modal" -import { Settings } from "./settings" import { getApiUrl } from "../lib/api-config" import { RefreshCw, @@ -129,12 +129,8 @@ export function ProxmoxDashboard() { }, []) useEffect(() => { - // Only fetch if we actually need the data (always for header) fetchSystemData() - - // Poll every 30 seconds for header info (less frequent since it's just for display) - const interval = setInterval(fetchSystemData, 30000) - + const interval = setInterval(fetchSystemData, 10000) return () => clearInterval(interval) }, [fetchSystemData]) @@ -546,7 +542,7 @@ export function ProxmoxDashboard() {
- + @@ -554,7 +550,7 @@ export function ProxmoxDashboard() { - + diff --git a/AppImage/components/system-overview.tsx b/AppImage/components/system-overview.tsx index aa30682..20204f4 100644 --- a/AppImage/components/system-overview.tsx +++ b/AppImage/components/system-overview.tsx @@ -96,10 +96,6 @@ interface ProxmoxStorageData { }> } -interface SystemOverviewProps { - isActive?: boolean -} - const fetchSystemData = async (): Promise => { try { const apiUrl = getApiUrl("/api/system") @@ -223,7 +219,7 @@ const fetchProxmoxStorageData = async (): Promise => } } -export function SystemOverview({ isActive = true }: SystemOverviewProps) { +export function SystemOverview() { const [systemData, setSystemData] = useState(null) const [vmData, setVmData] = useState([]) const [storageData, setStorageData] = useState(null) @@ -235,10 +231,6 @@ export function SystemOverview({ isActive = true }: SystemOverviewProps) { const [networkTotals, setNetworkTotals] = useState<{ received: number; sent: number }>({ received: 0, sent: 0 }) useEffect(() => { - if (!isActive) { - return - } - const fetchData = async () => { try { setLoading(true) @@ -261,7 +253,6 @@ export function SystemOverview({ isActive = true }: SystemOverviewProps) { } } - // Initial fetch fetchData() const systemInterval = setInterval(() => { @@ -270,11 +261,10 @@ export function SystemOverview({ isActive = true }: SystemOverviewProps) { }) }, 10000) - // Clean up interval when component unmounts or becomes inactive return () => { clearInterval(systemInterval) } - }, [isActive]) // Add isActive as dependency + }, []) useEffect(() => { const fetchVMs = async () => { @@ -731,11 +721,7 @@ export function SystemOverview({ isActive = true }: SystemOverviewProps) {
- +
) : ( diff --git a/AppImage/components/virtual-machines.tsx b/AppImage/components/virtual-machines.tsx index 751e144..499f445 100644 --- a/AppImage/components/virtual-machines.tsx +++ b/AppImage/components/virtual-machines.tsx @@ -350,7 +350,7 @@ export function VirtualMachines() { headers: { "Content-Type": "application/json", }, - body: JSON.JSON.stringify({ action }), + body: JSON.stringify({ action }), }) if (response.ok) { @@ -451,7 +451,7 @@ export function VirtualMachines() { "/api/system", fetcher, { - refreshInterval: 60000, // Changed from 30s to 60s + refreshInterval: 30000, revalidateOnFocus: false, }, )