"use client"; import React, { useCallback, useEffect, useState } from "react"; import Link from "next/link"; import { useParams } from "next/navigation"; 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"; type Msg = { type: "ok" | "err"; text: string } | null; const OUTCOME: Record = { ok: "✓", failed: "✗", skipped: "–", "rolled-back": "↺" }; /** One job and its full report: steps, result and the last log lines (§11). */ export default function JobPage() { const { id } = useParams<{ id: string }>(); const [job, setJob] = useState(null); const [msg, setMsg] = useState(null); const load = useCallback(() => api<{ job: Job }>(`/api/admin/jobs/${id}`).then(r => setJob(r.job)).catch(e => setMsg({ type: "err", text: errorText(e) })), [id]); useEffect(() => { load(); const t = setInterval(() => { if (!job || ["queued", "delivered", "scheduled"].includes(job.status)) load(); }, 10000); return () => clearInterval(t); }, [load, job]); const post = async (path: string, ok: string) => { try { await api(path, { method: "POST", body: {} }); setMsg({ type: "ok", text: ok }); load(); } catch (e) { setMsg({ type: "err", text: errorText(e) }); } }; if (!job) return
{msg ? : }
; const r = job.report; return (
on {job.server?.name} · {job.id} } actions={
{["queued", "scheduled"].includes(job.status) && } {job.type === "purge" && job.status === "queued" && job.message !== "extended" && }
} />
Window: {fmtDate(job.notBefore)} – {fmtDate(job.expiresAt)}
Handed to the agent: {fmtDate(job.deliveredAt)}
Finished: {fmtDate(job.finishedAt)}
{job.reason &&
Reason: {job.reason}
} {job.message &&
Result: {job.message}
}
Arguments: {JSON.stringify(job.args)}
{r && ( <>

Steps

    {r.steps.map((s, i) =>
  1. {OUTCOME[s.outcome] || "•"}{s.name}{s.detail && ({s.detail})}
  2. )} {!r.steps.length &&
  3. No steps reported.
  4. }
{Object.keys(r.result || {}).length > 0 &&

Result

{JSON.stringify(r.result, null, 2)}
}

Last log lines

{(r.log || []).join("\n") || "(none)"}
)}
); }