Updete AppImage

This commit is contained in:
MacRimi
2025-11-07 12:17:10 +01:00
parent a94000e114
commit ee57797890
9 changed files with 558 additions and 174 deletions

View File

@@ -73,6 +73,10 @@ interface NetworkInterface {
vm_status?: string
}
interface NetworkMetricsProps {
isActive?: boolean
}
const getInterfaceTypeBadge = (type: string) => {
switch (type) {
case "physical":
@@ -143,15 +147,16 @@ const fetcher = async (url: string): Promise<NetworkData> => {
return response.json()
}
export function NetworkMetrics() {
export function NetworkMetrics({ isActive = true }: NetworkMetricsProps) {
const {
data: networkData,
error,
isLoading,
} = useSWR<NetworkData>("/api/network", fetcher, {
refreshInterval: 60000, // Refresh every 60 seconds
refreshInterval: isActive ? 60000 : 0, // Refresh every 60 seconds only if active, otherwise pause
revalidateOnFocus: false,
revalidateOnReconnect: true,
isPaused: () => !isActive,
})
const [selectedInterface, setSelectedInterface] = useState<NetworkInterface | null>(null)
@@ -166,10 +171,15 @@ export function NetworkMetrics() {
revalidateOnReconnect: true,
})
const { data: interfaceHistoricalData } = useSWR<any>(`/api/node/metrics?timeframe=${timeframe}`, fetcher, {
refreshInterval: 30000,
revalidateOnFocus: false,
})
const { data: interfaceHistoricalData } = useSWR<any>(
isActive ? `/api/node/metrics?timeframe=${timeframe}` : null,
fetcher,
{
refreshInterval: isActive ? 30000 : 0,
revalidateOnFocus: false,
isPaused: () => !isActive,
},
)
if (isLoading) {
return (