Files
jobboard/app/static/messages.js
T
WolfandClaude Opus 5.5 59a301c351 Wire the app like the boilerplate: door, queue, schedules, eight tabs
app/main.py assembles it in the boilerplate's order, auth.connect first,
then the queue with the scheduler and the pages. TABS is Roles,
Applications, Agents, Companies, Jobs, Schedules, Messages and Account:
the alpha page's three views become templates on the boilerplate's
base.html, driven by static/roles.js (the old app.js) through api() and
toasts.js, over the unchanged JSON routes. Companies lists every board with
its open roles and the affinity control. A 422 is one sentence, so a toast
never reads [object Object].

Config takes the boilerplate's shape: APP_CONFIG or config.yaml, a missing
file is the defaults, an unknown key is an error. roles.yaml is gone;
config.yaml is the committed default and carries the starter agents.

pull is now a job that asks for the pull cascade, because a schedule
enqueues a job kind; its default schedule, every 6h, is declared beside it
in app/jobs/cascade.py. pull_batch's targets are keyword-only so the Jobs
tab offers no batch button. `app worker` is the boilerplate's; `app job`
still drains a queue of its own and fires no schedules.

test_coupling holds pipeline, auth and desk apart (desk may import
pipeline) and plugins to desk; test_architecture keeps app's layers, now
with main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 12:48:12 +02:00

86 lines
2.6 KiB
JavaScript

/* The Messages tab: the notice log as a table.
*
* `/api/notices` is the queue's own route (`pipeline/web/jobs.py`) -- the log
* belongs to the queue, the wording belongs to the app, and this page is only
* the reading of it. It redraws on `app:notice` so a failure that happens
* while you are looking at this tab appears without a reload.
*/
(function () {
"use strict";
const host = document.getElementById("notices");
const clearAll = document.getElementById("clear-all");
if (!host) return;
const esc = window.esc;
function when(iso) {
if (!iso) return "";
const d = new Date(iso);
return isNaN(d) ? iso : d.toLocaleString();
}
function row(n) {
const count = n.count > 1 ? `<span class="badge">x${n.count}</span>` : "";
return `
<article class="notice ${esc(n.level)}" data-id="${n.id}">
<div class="notice-head">
<span class="notice-text">${esc(n.text)} ${count}</span>
<button type="button" class="secondary" data-clear="${n.id}">Clear</button>
</div>
<div class="small muted">${esc(n.code)}${n.key ? " / " + esc(n.key) : ""}
-- last said ${esc(when(n.last_at))}
${n.kind === "bug" ? "-- looks like a bug rather than a bad day" : ""}</div>
${n.fix ? `<div class="small">${esc(n.fix)}</div>` : ""}
${n.detail ? `<details class="small"><summary>details</summary>
<pre>${esc(n.detail)}</pre></details>` : ""}
</article>`;
}
async function draw() {
let list;
try {
list = await window.api("/api/notices");
} catch (e) {
host.innerHTML = '<span class="muted">could not read the log</span>';
return;
}
if (!list.length) {
host.innerHTML = '<span class="muted">Nothing to report.</span>';
return;
}
host.innerHTML = list.map(row).join("");
}
host.addEventListener("click", async (e) => {
const id = e.target.dataset && e.target.dataset.clear;
if (!id) return;
e.target.disabled = true;
try {
await window.api(`/api/notices/${id}`, { method: "DELETE" });
await draw();
} catch (err) {
e.target.disabled = false;
}
});
if (clearAll) {
clearAll.addEventListener("click", async () => {
clearAll.disabled = true;
try {
const out = await window.api("/api/notices", { method: "DELETE" });
window.toast.good(`Cleared ${out.cleared}.`);
await draw();
} catch (e) {
/* already toasted */
} finally {
clearAll.disabled = false;
}
});
}
document.addEventListener("app:notice", draw);
document.addEventListener("DOMContentLoaded", draw);
})();