import React, { useState, useEffect, useCallback } from 'react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/index'; import { Button } from '@/components/ui/index'; import { Badge } from '@/components/ui/index'; import { RefreshCw, Network } from 'lucide-react'; import { listNetworkInterfaces, listProxmoxClusters, NetworkInterface } from '@/lib/proxmoxClient'; export function ProxmoxNetworkPage() { const [interfaces, setInterfaces] = useState([]); const [clusterId, setClusterId] = useState(''); const [nodeId] = useState('localhost'); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const loadInterfaces = useCallback(async (cId: string, nId: string) => { if (!cId) return; setLoading(true); setError(null); try { const ifaces = await listNetworkInterfaces(cId, nId); setInterfaces(ifaces); } catch (e) { setError(String(e)); } finally { setLoading(false); } }, []); useEffect(() => { listProxmoxClusters() .then((cls) => { if (cls.length > 0) { setClusterId(cls[0].id); void loadInterfaces(cls[0].id, nodeId); } }) .catch(console.error); }, [loadInterfaces, nodeId]); return (

Network

Network interfaces and bridges

{error && (
{error}
)} Network Interfaces {loading ? (
Loading...
) : interfaces.length === 0 ? (
{clusterId ? 'No network interfaces found.' : 'No cluster configured.'}
) : (
{interfaces.map((iface, i) => (
{iface.iface} {iface.type} {iface.active ? 'Active' : 'Inactive'} {iface.autostart && ( Autostart )}
{(iface.address || iface.gateway) && (
{iface.address && ( {iface.address} {iface.netmask ? `/${iface.netmask}` : ''} )} {iface.gateway && ( gw {iface.gateway} )}
)} {iface.comments && (
{iface.comments}
)}
))}
)}
); }