Servers and the agent, dashboard (2.1.0): servers, installs, updates, jobs, ports, download page

- Servers: add with a one-time join command, each server's CPU / RAM
  charts (24 h, 7 days, 90 days, spikes over 85% marked, table view),
  configuration, PM2 processes, sites, jobs and alerts.
- Installs: New install (server chooser with free RAM, CPU and sites),
  Link existing, FastPanel steps and Proxy done, schedule / emergency
  update, adopt, uninstall (2FA and the short name).
- Updates: one release to many installs (a batch), planned jobs.
- Jobs with their reports; Ports & defaults; the public download page
  that decrypts an export in the browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 13:18:20 +02:00
co-authored by Claude Opus 5.5
parent 041461f2b5
commit c8359c77e9
13 changed files with 1075 additions and 4 deletions
+52
View File
@@ -0,0 +1,52 @@
"use client";
import React, { useEffect, useState } from "react";
import Link from "next/link";
import { api, errorText } from "@/lib/api";
import { fmtDate } from "@/lib/format";
import { Loading, Message, PageTitle } from "@/components/ui";
import { ServersNav, StatusPill, type Job } from "@/components/servers";
const FILTERS = [
{ key: "", label: "All" },
{ key: "upcoming", label: "Planned and running" },
{ key: "failed", label: "Failed" },
{ key: "rolled_back", label: "Rolled back" },
{ key: "missed", label: "Missed" },
{ key: "refused", label: "Refused" },
];
/** Every job sent to a server's agent, newest first (§11: the full report is on each job). */
export default function JobsPage() {
const [filter, setFilter] = useState("");
const [jobs, setJobs] = useState<Job[] | null>(null);
const [err, setErr] = useState<string | null>(null);
useEffect(() => {
const q = filter === "upcoming" ? "?upcoming=true" : filter ? `?status=${filter}` : "";
setJobs(null);
api<{ jobs: Job[] }>(`/api/admin/jobs${q}`).then(r => setJobs(r.jobs)).catch(e => setErr(errorText(e)));
}, [filter]);
return (
<div>
<PageTitle title="Jobs" subtitle="Installs, updates, adopts, exports, uninstalls and checks run by the agents." />
<ServersNav active="/jobs" />
{err && <Message msg={{ type: "err", text: err }} />}
<div className="mb-4 flex flex-wrap gap-2">{FILTERS.map(f => <button key={f.key} className={filter === f.key ? "btn-primary" : "btn-secondary"} onClick={() => setFilter(f.key)}>{f.label}</button>)}</div>
{!jobs ? <Loading /> : (
<div className="card overflow-x-auto">
<table className="w-full text-sm">
<thead><tr className="text-left text-xs text-slate-500"><th className="py-1">Job</th><th>Server</th><th>Install</th><th>When</th><th>Status</th><th>Result</th></tr></thead>
<tbody>{jobs.map(j => (
<tr key={j.id} className="border-t">
<td className="py-1.5"><Link className="text-indigo-700 hover:underline" href={`/jobs/${j.id}`}>{j.type}</Link>{j.emergency && <span className="ml-1 text-xs text-red-700">emergency</span>}</td>
<td>{j.server?.name}</td><td>{j.deployment?.shortName || String(j.args?.church || "–")}</td><td>{fmtDate(j.notBefore)}</td><td><StatusPill status={j.status} /></td>
<td className="max-w-sm truncate text-xs text-slate-500">{j.message}</td>
</tr>
))}</tbody>
</table>
{!jobs.length && <p className="mt-2 text-sm text-slate-500">No jobs.</p>}
</div>
)}
</div>
);
}