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:
1 parent
c17e9aa140
commit
540ab704b7
32 files changed
+3003
-66
No files matched your search
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user