Show Proxmox guests and scheduled backup status in device details
Rust development slice / linux (push) Failing after 14s

The host detail lists VMs and containers with linked inventory devices and
last successful backup, each vzdump job with its due time and result, an
overall 'all scheduled backups ran' answer and guests without a job. VM hosts
detected from a Proxmox guest list are labelled and the assignment form can
hand the decision back to automatic detection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 12:12:54 +01:00
co-authored by Claude Opus 5.5
parent 70977df577
commit ce356f0de7
6 changed files with 190 additions and 6 deletions
+11 -5
View File
@@ -4,6 +4,8 @@ import { NavIcon } from './navigation';
import { ErrorBox, errorText, useResource } from './resource';
type Host = { asset_id: string; agent_id: string; hostname: string };
/** Select value that hands the decision back to automatic Proxmox detection. */
const AUTO = 'automatic';
function host(value: unknown): Host | null {
if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
@@ -24,7 +26,7 @@ export function HypervisorLabel({ device }: { device: RecordValue }) {
return <span className="vm-hypervisor">
<NavIcon name="geraete" /><span>Hypervisor <a href={'#' + path} onClick={event => event.stopPropagation()}>
{target.hostname}
</a></span>
</a>{info.source === 'proxmox' && <span className="muted"> · automatisch über Proxmox erkannt</span>}</span>
</span>;
}
return info.kind === 'placeholder' && info.provider === 'hetzner' ? (
@@ -53,7 +55,8 @@ export function HypervisorAssignment({ device, customer, asset, agent, auth }: {
const [busy, setBusy] = useState(false);
const [notice, setNotice] = useState('');
const [error, setError] = useState<string | null>(null);
const assigned = typeof device.assigned_hypervisor_asset_id === 'string' ? device.assigned_hypervisor_asset_id : '';
const automatic = device.hypervisor_source !== 'manual';
const assigned = automatic ? AUTO : typeof device.assigned_hypervisor_asset_id === 'string' ? device.assigned_hypervisor_asset_id : '';
const value = draft ?? assigned;
useEffect(() => {
@@ -70,7 +73,7 @@ export function HypervisorAssignment({ device, customer, asset, agent, auth }: {
}, [customer, open, query]);
const assignedHost = host(device.hypervisor);
const hosts = options.data?.hosts ?? [];
const selectedMissing = !!value && !hosts.some(item => item.asset_id === value);
const selectedMissing = !!value && value !== AUTO && !hosts.some(item => item.asset_id === value);
const canSave = value !== assigned && (!value || !selectedMissing);
return <details onToggle={e => {
@@ -91,9 +94,11 @@ export function HypervisorAssignment({ device, customer, asset, agent, auth }: {
setNotice('');
try {
await request(tenantPath(customer, '/devices/' + encodeURIComponent(asset) + '/hypervisor?agent_id=' + encodeURIComponent(agent)), {
tenantId: customer, csrf: auth.csrf_token, body: { hypervisor_asset_id: value || null }
tenantId: customer, csrf: auth.csrf_token,
body: value === AUTO ? { hypervisor_asset_id: null, automatic: true } : { hypervisor_asset_id: value || null }
});
setNotice(value ? 'Hypervisor zugeordnet.' : 'Hostzuordnung entfernt.');
setNotice(value === AUTO ? 'Automatische Zuordnung über Proxmox aktiviert.'
: value ? 'Hypervisor zugeordnet.' : 'Hostzuordnung entfernt.');
} catch (e) {
setError(assignmentError(e));
} finally {
@@ -106,6 +111,7 @@ export function HypervisorAssignment({ device, customer, asset, agent, auth }: {
{options.data?.truncated && <p className="muted">Weitere Hypervisoren lassen sich über die Suche finden.</p>}
<label>Hypervisor auswählen<select aria-label="Hypervisor auswählen" value={value}
onChange={e => { setDraft(e.target.value); setNotice(''); setError(null); }} disabled={busy}>
<option value={AUTO}>Automatisch (Proxmox-Gastliste)</option>
<option value="">Kein konkreter Hypervisor</option>
{selectedMissing && <option value={value} disabled>
{assignedHost?.asset_id === value ? assignedHost.hostname : 'Zugeordneter Host außerhalb der Treffer'}