Export CSV on every table, edit recurring maintenance, runs-on nothing, and run package checks outside the agent sandbox

- Export CSV for the small tables that had none (reads the table as shown)
- Servers page shows a skeleton while loading instead of "No servers registered yet"
- Recurring maintenance schedules can be edited (PUT /schedules/:id)
- A server can be set to run on nothing (servers.no_parent, migration 0028)
- Linux agent v3: package-manager question runs in ExecStartPre=-+ outside the sandbox,
  with --prepare-updates and --check-updates modes
- Docs: README, DATABASE, AGENT_UPDATE

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-17 22:25:18 +02:00
1 parent c17e9aa140
commit 540ab704b7
32 files changed
+3003 -66

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import { useEffect, useRef, useState } from "react";
import { downloadCsv, tableToRows } from "../utils/csv";
/**
* "Export CSV" for a table that has no export of its own. It reads the table as it is on screen, so what you see is what you get.
* By default it takes the first table in the same card; `of="next"` takes the table that follows the element this button sits in
* (for a card with several tables, each under its own small heading). With no table to read it shows nothing.
*/
export default function ExportTableButton({ filename, of = "card", className = "btn btn-sm btn-outline-secondary" }: { filename: string; of?: "card" | "next"; className?: string }) {
const ref = useRef<HTMLButtonElement>(null);
const [hasTable, setHasTable] = useState(true);
function findTable(): HTMLTableElement | null {
const button = ref.current;
if (!button) return null;
const scope = of === "next" ? button.parentElement?.nextElementSibling : button.closest(".card");
return scope instanceof HTMLTableElement ? scope : (scope?.querySelector("table") ?? null);
}
// The table may arrive after the button (loading, an empty list filling up), so look again after every render.
useEffect(() => {
const found = findTable() !== null;
if (found !== hasTable) setHasTable(found);
});
function exportNow() {
const table = findTable();
if (!table) return;
const { headers, rows } = tableToRows(table);
downloadCsv(filename.endsWith(".csv") ? filename : `${filename}.csv`, headers, rows);
}
return (
<button ref={ref} type="button" className={className} onClick={exportNow} hidden={!hasTable}>
Export CSV
</button>
);
}
+49 -14
View File
@@ -5,6 +5,7 @@ import { readableError } from "../utils/errors";
import { toast } from "../utils/toast";
import TimeAgo from "./TimeAgo";
import { ErrorNotice } from "./Notice";
import ExportTableButton from "./ExportTableButton";
// Monday first, as a week reads; the numbers are what the server keeps (0 = Sunday).
const DAYS: { value: number; short: string }[] = [
@@ -57,9 +58,14 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
const [schedules, setSchedules] = useState<MaintenanceSchedule[] | null>(null);
const [error, setError] = useState<string | null>(null);
const [adding, setAdding] = useState(false);
// The schedule being changed, if the form is open to change one rather than to add one.
const [editingId, setEditingId] = useState<number | null>(null);
const [busy, setBusy] = useState(false);
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
const browserTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
// A schedule keeps the zone it was made in when it is changed; a new one uses this browser's.
const [scheduleZone, setScheduleZone] = useState<string | null>(null);
const timezone = scheduleZone ?? browserTimezone;
const [name, setName] = useState("");
const [reason, setReason] = useState("");
const [days, setDays] = useState<number[]>([0]);
@@ -91,6 +97,31 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
});
}
function closeForm() {
setAdding(false);
setEditingId(null);
setScheduleZone(null);
setName("");
setReason("");
setDays([0]);
setStartTime("02:00");
setMinutes(120);
setPicked(new Set());
}
function startEditing(s: MaintenanceSchedule) {
setError(null);
setEditingId(s.id);
setScheduleZone(s.timezone);
setName(s.name);
setReason(s.reason ?? "");
setDays(s.days);
setStartTime(s.startTime);
setMinutes(s.durationMinutes);
setPicked(new Set(s.targets.map((t) => key(t.type, t.id))));
setAdding(true);
}
async function create(e: React.FormEvent) {
e.preventDefault();
setError(null);
@@ -100,12 +131,10 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
const [type, id] = k.split(":");
return { type: type as MaintenanceTargetType, id: Number(id) };
});
const res = await api.maintenance.schedules.create({ name: name.trim(), reason: reason.trim() || undefined, targets: chosen, days, startTime, durationMinutes: minutes, timezone });
const input = { name: name.trim(), reason: reason.trim() || undefined, targets: chosen, days, startTime, durationMinutes: minutes, timezone };
const res = editingId === null ? await api.maintenance.schedules.create(input) : await api.maintenance.schedules.update(editingId, input);
toast.success(`Saved. ${res.windowsMade} maintenance window${res.windowsMade === 1 ? "" : "s"} made for the coming week.`);
setName("");
setReason("");
setPicked(new Set());
setAdding(false);
closeForm();
load();
onChanged();
} catch (err) {
@@ -143,13 +172,14 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">Recurring</h3>
{canEdit && !adding && (
<div className="card-actions">
<button type="button" className="btn btn-sm btn-primary" onClick={() => setAdding(true)}>
<div className="card-actions">
<ExportTableButton filename="maintenance-recurring" />
{canEdit && !adding && (
<button type="button" className="btn btn-sm btn-primary" onClick={() => { setError(null); setAdding(true); }}>
Add recurring maintenance
</button>
</div>
)}
)}
</div>
</div>
{adding && (
@@ -194,6 +224,8 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
For
</label>
<select id="rec-length" className="form-select" value={minutes} onChange={(e) => setMinutes(Number(e.target.value))}>
{/* A schedule made some other way (or before these choices) keeps whatever length it has. */}
{!LENGTHS.some((l) => l.minutes === minutes) && <option value={minutes}>{minutes} minutes</option>}
{LENGTHS.map((l) => (
<option key={l.minutes} value={l.minutes}>
{l.label}
@@ -245,9 +277,9 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
</div>
<div className="card-footer d-flex gap-2">
<button type="submit" className="btn btn-primary" disabled={busy || picked.size === 0 || days.length === 0 || name.trim() === ""}>
{busy ? "Saving…" : "Save"}
{busy ? "Saving…" : editingId === null ? "Save" : "Save changes"}
</button>
<button type="button" className="btn" onClick={() => setAdding(false)}>
<button type="button" className="btn" onClick={closeForm}>
Cancel
</button>
</div>
@@ -277,12 +309,15 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
<td>{namesWords(s.targets.map((t) => t.name))}</td>
<td>
{daysWords(s.days)} {timeWords(s.startTime, s.durationMinutes)}
{s.timezone !== timezone && <span className="text-secondary small"> ({s.timezone})</span>}
{s.timezone !== browserTimezone && <span className="text-secondary small"> ({s.timezone})</span>}
</td>
<td>{s.nextStart ? <TimeAgo value={s.nextStart} /> : "—"}</td>
{canEdit && (
<td>
<div className="btn-list flex-nowrap">
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={() => startEditing(s)} disabled={editingId === s.id}>
Edit
</button>
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={() => void toggle(s)}>
{s.enabled ? "Turn off" : "Turn on"}
</button>
+11 -7
View File
@@ -7,9 +7,12 @@ import { toast } from "../utils/toast";
/**
* Which server this one runs on (a virtual machine on its host). When the host stops reporting, this server's own "offline" alert is
* folded under the host's instead of being a second one. Left alone it is worked out from the Proxmox node the server is linked to;
* an admin can say it by hand. Everyone sees it; only admins change it.
* an admin can say it by hand, or say it runs on nothing (a physical machine that happens to carry a Proxmox node name).
* Everyone sees it; only admins change it.
*/
export default function RunsOn({ serverId, parent, canEdit, onChanged }: { serverId: number; parent: ServerRelation | null; canEdit: boolean; onChanged: () => void }) {
const NONE = "none";
export default function RunsOn({ serverId, parent, noParent, canEdit, onChanged }: { serverId: number; parent: ServerRelation | null; noParent: boolean; canEdit: boolean; onChanged: () => void }) {
const [servers, setServers] = useState<ServerRecord[] | null>(null);
const [busy, setBusy] = useState(false);
@@ -24,8 +27,8 @@ export default function RunsOn({ serverId, parent, canEdit, onChanged }: { serve
async function change(value: string) {
setBusy(true);
try {
await api.servers.update(serverId, { parentServerId: value === "" ? null : Number(value) });
toast.success(value === "" ? "Back to working it out from the Proxmox node." : "Saved.");
await api.servers.update(serverId, value === NONE ? { noParent: true } : { parentServerId: value === "" ? null : Number(value) });
toast.success(value === "" ? "Back to working it out from the Proxmox node." : value === NONE ? "It runs on nothing, so its alerts always stand alone." : "Saved.");
onChanged();
} catch (err) {
toast.error(readableError(err));
@@ -39,8 +42,9 @@ export default function RunsOn({ serverId, parent, canEdit, onChanged }: { serve
}
return (
<div>
<select className="form-select form-select-sm" aria-label="The server this one runs on" value={parent && !parent.auto ? String(parent.id) : ""} disabled={busy || servers === null} onChange={(e) => void change(e.target.value)}>
<option value="">{parent?.auto ? `Automatic: ${parent.name}` : "None (automatic)"}</option>
<select className="form-select form-select-sm" aria-label="The server this one runs on" value={noParent ? NONE : parent && !parent.auto ? String(parent.id) : ""} disabled={busy || servers === null} onChange={(e) => void change(e.target.value)}>
<option value="">{parent?.auto ? `Automatic: ${parent.name}` : "Automatic (none found)"}</option>
<option value={NONE}>Nothing — it runs on its own</option>
{(servers ?? [])
.filter((s) => s.id !== serverId)
.map((s) => (
@@ -49,7 +53,7 @@ export default function RunsOn({ serverId, parent, canEdit, onChanged }: { serve
</option>
))}
</select>
<div className="form-hint text-secondary small mt-1">Automatic means worked out from its Proxmox node. If it stops reporting, this server's offline alert is folded under its host's.</div>
<div className="form-hint text-secondary small mt-1">Automatic means worked out from its Proxmox node. If it stops reporting, this server's offline alert is folded under its host's. "Nothing" stops that, so it always alerts for itself.</div>
</div>
);
}