import { useEffect, useState } from "react"; import TimeAgo from "../components/TimeAgo"; import { Link } from "react-router-dom"; import { api, type CurrentUser, type IntegrationSummary, type ProxmoxGuest, type ProxmoxGuestsResponse, type ProxmoxNodeStats, type ProxmoxBackupJob, type ProxmoxBackupTask, } from "../api/client"; import { useSortable } from "../hooks/useSortable"; import SortableTh from "../components/SortableTh"; import { usePagination } from "../hooks/usePagination"; import Pagination from "../components/Pagination"; import { downloadCsv } from "../utils/csv"; import { confirmDialog } from "../utils/dialogs"; import IntegrationPageTitle from "../components/IntegrationPageTitle"; import { ErrorNotice } from "../components/Notice"; import { toast } from "../utils/toast"; import { SearchBox } from "../components/TableToolbar"; import { useTableSearch } from "../hooks/useTableSearch"; import DetailDrawer, { ObjectDetails } from "../components/DetailDrawer"; import { useRowDetail } from "../hooks/useRowDetail"; import { formatDateTime } from "../utils/date"; import ExportTableButton from "../components/ExportTableButton"; import { EmptyRow } from "../components/EmptyState"; function proxmoxStatusBadge(status: string) { return status === "running" ? ( Running ) : ( Stopped ); } function formatUptime(seconds: number | null): string { if (!seconds) return "—"; const days = Math.floor(seconds / 86400); const hours = Math.floor((seconds % 86400) / 3600); if (days > 0) return `${days}d ${hours}h`; const minutes = Math.floor((seconds % 3600) / 60); return `${hours}h ${minutes}m`; } function formatBytes(bytes: number | null): string { if (bytes === null) return "—"; const units = ["B", "KB", "MB", "GB", "TB", "PB"]; let value = bytes; let unit = 0; while (value >= 1024 && unit < units.length - 1) { value /= 1024; unit++; } return `${value.toFixed(1)} ${units[unit]}`; } function describeGuests(job: ProxmoxBackupJob): string { if (job.allGuests) return job.exclude ? `All guests (except ${job.exclude})` : "All guests"; return job.vmids ? `Guests ${job.vmids}` : "—"; } function formatDuration(startIso: string, endIso: string | null): string { if (!endIso) return "running…"; const seconds = Math.max(0, Math.round((new Date(endIso).getTime() - new Date(startIso).getTime()) / 1000)); const minutes = Math.floor(seconds / 60); const remSeconds = seconds % 60; return minutes > 0 ? `${minutes}m ${remSeconds}s` : `${remSeconds}s`; } function backupStatusBadge(task: ProxmoxBackupTask) { if (task.ok) return OK; if (task.status === "running") return Running; return ( Failed ); } function usageBar(used: number | null, total: number | null) { if (!total) return null; const pct = Math.min(100, Math.round(((used ?? 0) / total) * 100)); return (
| {s.id} {!s.active && Inactive} | {s.type} | {formatBytes(s.usedBytes)} / {formatBytes(s.totalBytes)} {usageBar(s.usedBytes, s.totalBytes)} |
Datastore.Audit (e.g. on{" "}
/storage) to see disk usage here.
| Schedule | Storage | Guests | Status |
|---|---|---|---|
| {j.schedule || "—"} | {j.storage} | {describeGuests(j)} | {j.enabled ? ( Enabled ) : ( Disabled )} |
| Name | Node | Type | Status |
|---|---|---|---|
| {g.name} #{g.vmid} | {g.node} | {g.type === "qemu" ? "VM" : "LXC"} | {proxmoxStatusBadge(g.status)} |
| Node | Guest | Status | Started | Duration |
|---|---|---|---|---|
| {t.node} | {t.guestId ?? "—"} | {backupStatusBadge(t)} | {formatDuration(t.startTime, t.endTime)} |
| Actions | }|||||
|---|---|---|---|---|---|
| {g.name} #{g.vmid} | {g.node} | {g.type === "qemu" ? "VM" : "LXC"} | {formatUptime(g.uptime)} | {proxmoxStatusBadge(g.status)} | {canEdit && (
{g.status === "running" ? (
<>
>
) : (
)}
|
)}