All checks were successful
Test / frontend-tests (pull_request) Successful in 1m44s
Test / frontend-typecheck (pull_request) Successful in 1m57s
PR Review Automation / review (pull_request) Successful in 4m19s
Test / rust-fmt-check (pull_request) Successful in 12m57s
Test / rust-clippy (pull_request) Successful in 14m41s
Test / rust-tests (pull_request) Successful in 16m43s
- Replace hardcoded dummy data in VMs, Containers, Storage, Backup, and Firewall pages with live API calls; show empty-state UI when no clusters are configured - Add list_proxmox_containers backend command (LXC via cluster/resources) and register it in the Tauri handler and frontend proxmoxClient.ts - Fix add_proxmox_cluster to store credentials without requiring a live Proxmox connection; persist username in DB (migration 034); update list/get queries to read username column from new schema - Replace alert() in RemotesPage with toast.error() + rethrow so errors surface correctly in Tauri WebView - Replace tauri-plugin-updater with direct Gitea HTTP API call for update checks; use tauri-plugin-opener for browser launch; Updater UI now shows current/latest version and release notes - Add gogs.tftsr.com to CSP connect-src - Fix all 74 pre-existing ESLint no-explicit-any warnings in proxmoxClient.ts; remove stale eslint-disable directive in ACLPage.tsx - All checks pass: cargo fmt, clippy -D warnings, 411 Rust tests, tsc --noEmit, eslint --max-warnings 0, 386 frontend tests
109 lines
3.8 KiB
TypeScript
109 lines
3.8 KiB
TypeScript
import React, { useState, useEffect, useCallback } from 'react';
|
|
import { Button } from '@/components/ui/index';
|
|
import { RefreshCw } from 'lucide-react';
|
|
import { VMList } from '@/components/Proxmox';
|
|
import { listProxmoxClusters, listProxmoxVms } from '@/lib/proxmoxClient';
|
|
import type { ClusterInfo } from '@/lib/domain';
|
|
import { toast } from 'sonner';
|
|
|
|
export function ProxmoxVMsPage() {
|
|
const [clusters, setClusters] = useState<ClusterInfo[]>([]);
|
|
const [selectedClusterId, setSelectedClusterId] = useState<string>('');
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
const [vms, setVms] = useState<any[]>([]);
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
const [selectedVMs, setSelectedVMs] = useState<Set<string>>(new Set());
|
|
|
|
useEffect(() => {
|
|
listProxmoxClusters()
|
|
.then((cls) => {
|
|
setClusters(cls);
|
|
if (cls.length > 0) setSelectedClusterId(cls[0].id);
|
|
})
|
|
.catch((err) => {
|
|
console.error('Failed to load clusters:', err);
|
|
toast.error('Failed to load clusters');
|
|
});
|
|
}, []);
|
|
|
|
const loadVms = useCallback(async (clusterId: string) => {
|
|
if (!clusterId) return;
|
|
setIsLoading(true);
|
|
try {
|
|
const data = await listProxmoxVms(clusterId);
|
|
setVms(data);
|
|
} catch (err) {
|
|
console.error('Failed to load VMs:', err);
|
|
toast.error('Failed to load VMs');
|
|
} finally {
|
|
setIsLoading(false);
|
|
}
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
if (selectedClusterId) loadVms(selectedClusterId);
|
|
}, [selectedClusterId, loadVms]);
|
|
|
|
if (clusters.length === 0 && !isLoading) {
|
|
return (
|
|
<div className="space-y-4">
|
|
<div>
|
|
<h1 className="text-2xl font-bold">Virtual Machines</h1>
|
|
<p className="text-muted-foreground">Manage QEMU/KVM virtual machines</p>
|
|
</div>
|
|
<div className="text-center py-12 text-muted-foreground">
|
|
<p>No Proxmox clusters configured.</p>
|
|
<p className="text-sm mt-1">Add a remote connection first.</p>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
<div className="flex items-center justify-between">
|
|
<div>
|
|
<h1 className="text-2xl font-bold">Virtual Machines</h1>
|
|
<p className="text-muted-foreground">Manage QEMU/KVM virtual machines</p>
|
|
</div>
|
|
<div className="flex items-center space-x-2">
|
|
{clusters.length > 1 && (
|
|
<select
|
|
className="rounded-md border px-3 py-1.5 text-sm bg-background"
|
|
value={selectedClusterId}
|
|
onChange={(e) => setSelectedClusterId(e.target.value)}
|
|
>
|
|
{clusters.map((c) => (
|
|
<option key={c.id} value={c.id}>{c.name}</option>
|
|
))}
|
|
</select>
|
|
)}
|
|
<Button variant="outline" size="sm" onClick={() => loadVms(selectedClusterId)}>
|
|
<RefreshCw className="mr-2 h-4 w-4" />
|
|
Refresh
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
|
|
<VMList
|
|
vms={vms}
|
|
onRefresh={() => loadVms(selectedClusterId)}
|
|
onVMAction={(_vm, _action) => { toast.info('VM action — not yet implemented'); }}
|
|
onSnapshotAction={(_vm, _action) => { toast.info('Snapshot action — not yet implemented'); }}
|
|
onMigrate={(_vm) => { toast.info('Migrate — not yet implemented'); }}
|
|
onClone={(_vm) => { toast.info('Clone — not yet implemented'); }}
|
|
onDelete={(_vm) => { toast.info('Delete — not yet implemented'); }}
|
|
selectedVMs={selectedVMs}
|
|
onToggleSelect={(vm) => {
|
|
setSelectedVMs((prev) => {
|
|
const next = new Set(prev);
|
|
const id = String(vm.vmid);
|
|
if (next.has(id)) next.delete(id); else next.add(id);
|
|
return next;
|
|
});
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|