import { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { Box, Search, Server as ServerIcon } from "lucide-react"; import { cn } from "@/lib/utils"; import { Input } from "@/components/input"; import type { ProxmoxGuestSummary } from "@/types/proxmox"; type StatusFilter = "all" | "running" | "stopped"; type TypeFilter = "all" | "qemu" | "lxc"; function formatUptime(seconds: number | null): string { if (seconds === null || seconds <= 0) return "-"; const days = Math.floor(seconds / 86400); const hours = Math.floor((seconds % 86400) / 3600); const minutes = Math.floor((seconds % 3600) / 60); if (days > 0) return `${days}d ${hours}h`; if (hours > 0) return `${hours}h ${minutes}m`; return `${minutes}m`; } function UsageCell({ percent, usedGiB, totalGiB, }: { percent: number | null; usedGiB?: number | null; totalGiB?: number | null; }) { if (percent === null) { return -; } const clamped = Math.min(100, Math.max(0, percent)); const barColor = clamped >= 90 ? "bg-red-500" : clamped >= 75 ? "bg-yellow-500" : "bg-accent-brand"; return (
| {t("proxmoxStats.name")} | {t("proxmoxStats.status")} | ID | {t("proxmoxStats.cpu")} | {t("proxmoxStats.mem")} | {t("proxmoxStats.disk")} | {t("proxmoxStats.uptime")} |
|---|---|---|---|---|---|---|
|
{guest.type === "lxc" ? (
|
{guest.status === "running"
? t("proxmoxStats.running")
: t("proxmoxStats.stopped")}
|
{guest.vmid} |
|
|
|
{formatUptime(guest.uptimeSeconds)} |