import StatusBadge from './StatusBadge'; /** * @param {{ lxc: Array<{ vmid: number; name: string; type: string; status: string; cpu: number; memory: { total: number; used: number }; disk: { total: number; used: number }; node: string }> }} props * @returns {import('react').ReactNode} */ /** * @param {{ lxc: Array<{ vmid: number; name: string; type: string; status: string; cpu: number; memory: { total: number; used: number }; disk: { total: number; used: number }; node: string }>, onPowerAction: (node: string, vmid: number, type: string, action: string) => void }} props */ export default function LXCList({ lxc, onPowerAction }) { if (!lxc?.length) { return

No LXC containers found.

; } const running = lxc.filter((item) => item.status === 'running'); const stopped = lxc.filter((item) => item.status !== 'running'); return (
{running.length > 0 && (

Running ({running.length})

{running.map((item) => ( ))}
ID Name Node CPU Memory Status
{item.vmid} {item.name} {item.node} {(item.cpu * 100).toFixed(1)}% {formatBytes(item.memory?.used || 0)} / {formatBytes(item.memory?.total || 0)}
)} {stopped.length > 0 && (

Stopped ({stopped.length})

{stopped.map((item) => ( ))}
ID Name Node Disk Status Actions
{item.vmid} {item.name} {item.node} {formatBytes(item.disk?.used || 0)}
)}
); } /** @param {number} bytes @returns {string} */ function formatBytes(bytes) { if (!bytes) return '0 B'; const units = ['B', 'KB', 'MB', 'GB', 'TB']; let i = 0; let v = bytes; while (v >= 1024 && i < units.length - 1) { v /= 1024; i++; } return `${v.toFixed(1)} ${units[i]}`; }