feat(jobs): show what mass passes do now on the desktop, the server section and the admin panel
A running job now says what it does now: "Verifying photo 812 of 2,400 · Harbour sunset · sequence 3 of 41". A paused or failed job says where it stopped. The line appears in the Jobs table under the target, in the job bar (at most 60 characters, the item dropped first, the bar text also its tooltip), in the Archive's recent maintenance (refreshed at most twice a second), in the editor's server-job line and in the sync tooltip. Byte jobs now count sizes in the bar. While connected, the Server section lists the server's running and paused jobs, live through the jobs API and the jobProgress events. Pause, Resume and Cancel are offered only to an account that manages the archive, which is what the server requires to act on someone else's job; for any other account the list is read-only. The list hides while nothing runs, and the capture gains a server-jobs scene. The admin panel's Jobs page and dashboard show the same line under the target and update it with every progress event. The steps, parts and sub-steps are in English and Italian, and an unknown step shows its counts only. Refs #65 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ee9505df22
commit
b95bc997d5
36 files changed
+1895
-28
No files matched your search
@@ -1,7 +1,7 @@
|
||||
// Dashboard (mockup Admin.html, BRIEF §14.8): storage, archive, jobs, render nodes, charts, activity, active jobs.
|
||||
import { t, plural, applyStrings, culture } from "../i18n.js";
|
||||
import { escapeHtml, attr, formatBytes, formatNumber, formatTime, formatDuration, bar, storageTip, writeVolumeLine, columns, toast, errorText, emptyState, redraw, fitColumns, PROXY_WARNING } from "../ui.js";
|
||||
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders } from "../jobs.js";
|
||||
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders, targetCell, updateStatus } from "../jobs.js";
|
||||
import { activityText } from "../audit.js";
|
||||
|
||||
const SCAN_BUTTON = `<button class="btn small" data-scan data-i18n="Admin.Archive.Scan" data-i18n-title="Admin.Archive.Scan.Tip"></button>`;
|
||||
@@ -23,6 +23,8 @@ function archiveProblemChip(problem) {
|
||||
|
||||
export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
let timer = null;
|
||||
// The active jobs drawn, by id, so a progress event updates the bar and the status line in place.
|
||||
let activeJobs = new Map();
|
||||
const refresh = () => {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(load, 1500);
|
||||
@@ -53,6 +55,7 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
const uploads = lastThirtyDays(d.uploads);
|
||||
const totalUploads = uploads.reduce((s, u) => s + u.value, 0);
|
||||
const peak = Math.max(0, ...uploads.map((u) => u.value));
|
||||
activeJobs = new Map(d.activeJobs.map((j) => [j.id, j]));
|
||||
|
||||
root.innerHTML = `
|
||||
<div class="tiles">
|
||||
@@ -111,7 +114,7 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
<div role="rowgroup">${d.activeJobs.map((j) => `
|
||||
<div class="row" role="row" data-key="${attr(j.id)}">
|
||||
<span class="ellipsis" role="cell">${escapeHtml(kindLabel(j.kind))}</span>
|
||||
<span class="ellipsis" role="cell" dir="auto" title="${attr(j.targetLabel ?? "")}">${escapeHtml(j.targetLabel ?? "")}</span>
|
||||
<span class="target-cell" role="cell">${targetCell(j)}</span>
|
||||
<span class="col-node ellipsis" role="cell" dir="auto">${escapeHtml(nodeLabel(j, d.nodes))}</span>
|
||||
<span class="progress" role="cell">${progressCell(j)}</span><span role="cell">${stateCell(j.state)}</span>
|
||||
<span class="row-actions" role="cell"><button class="btn small" data-cancel="${attr(j.id)}" data-i18n="${j.state === "queued" ? "Admin.Jobs.Remove" : "Admin.Jobs.Cancel"}"
|
||||
@@ -145,8 +148,16 @@ export async function render(root, { api, setMeta, actions, onEvent }) {
|
||||
|
||||
onEvent((e) => {
|
||||
if (e.type === "jobProgress") {
|
||||
const cell = root.querySelector(`[data-key="${CSS.escape(e.jobId)}"] .progress`);
|
||||
if (cell) cell.innerHTML = progressCell({ progressDone: e.done, progressTotal: e.total });
|
||||
const job = activeJobs.get(e.jobId) ?? { kind: "", state: "running" };
|
||||
job.progressDone = e.done;
|
||||
job.progressTotal = e.total;
|
||||
job.itemsPerSecond = e.itemsPerSecond;
|
||||
job.etaSeconds = e.etaSeconds;
|
||||
if (e.detail) job.detail = e.detail;
|
||||
const row = root.querySelector(`[data-key="${CSS.escape(e.jobId)}"]`);
|
||||
const cell = row?.querySelector(".progress");
|
||||
if (cell) cell.innerHTML = progressCell(job);
|
||||
updateStatus(row, job);
|
||||
} else {
|
||||
refresh();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user