Tables become ARIA tables laid out as subgrids that drop secondary columns in narrow panels; stat tiles stay on one row; charts are named and keep their axis labels inside; paths, templates and logs stay left to right; counts use plural keys; the panel follows the system theme with a toggle. Own account: Change password instead of Reset password. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
59 lines
2.5 KiB
JavaScript
59 lines
2.5 KiB
JavaScript
// Job and node labels shared by the dashboard and the Jobs page.
|
|
import { t, has } from "./i18n.js";
|
|
import { escapeHtml, attr, bar } from "./ui.js";
|
|
|
|
const CODECS = { h264: "H.264", hevc: "HEVC", av1: "AV1" };
|
|
/** Hardware encoder families as users know them, recognised in the Media Foundation encoder names. */
|
|
const VENDORS = [[/nvidia|nvenc/i, "NVENC"], [/intel|quick ?sync|qsv/i, "QSV"], [/amd|radeon|amf/i, "AMF"]];
|
|
|
|
export function pascal(text) {
|
|
return String(text).split(/[-_]/).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("");
|
|
}
|
|
|
|
export function kindLabel(kind) {
|
|
const key = `Admin.Job.Kind.${pascal(kind)}`;
|
|
return has(key) ? t(key) : kind;
|
|
}
|
|
|
|
export function stateLabel(state) {
|
|
const key = `Admin.Job.State.${pascal(state)}`;
|
|
return has(key) ? t(key) : state;
|
|
}
|
|
|
|
/** Where a job runs: this server, a render node by name, or nowhere yet. */
|
|
export function nodeLabel(job, nodes) {
|
|
if (!job.nodeId) return "—";
|
|
if (job.nodeId.startsWith("server:")) return t("Admin.Jobs.Server");
|
|
return nodes.find((n) => n.id === job.nodeId)?.clientName ?? "—";
|
|
}
|
|
|
|
export function progressCell(job) {
|
|
if (job.progressTotal <= 0) return `<div class="progress-cell">${bar(0, true)}<span class="muted">—</span></div>`;
|
|
const fraction = job.progressDone / job.progressTotal;
|
|
return `<div class="progress-cell">${bar(fraction)}<span class="num">${Math.floor(fraction * 100)} %</span></div>`;
|
|
}
|
|
|
|
export function stateCell(state) {
|
|
const glyph = { running: "◐", queued: "○", paused: "❚❚", done: "●", failed: "✕", cancelled: "○" }[state] ?? "";
|
|
return `<span class="state ${attr(state)}"><span aria-hidden="true">${glyph}</span> ${escapeHtml(stateLabel(state))}</span>`;
|
|
}
|
|
|
|
/** The job log: the tail, then the error unless the tail already ends with it. */
|
|
export function logText(job) {
|
|
const tail = (job.logTail ?? "").trimEnd();
|
|
return job.error && !tail.endsWith(job.error.trim()) ? `${tail}\n${job.error}`.trim() : tail;
|
|
}
|
|
|
|
/** Node encoders by family, as "NVENC HEVC/H.264/AV1" (software encoders without a family name). */
|
|
export function encoders(node) {
|
|
const families = new Map();
|
|
for (const e of node.encoders) {
|
|
const family = e.hardware ? VENDORS.find(([pattern]) => pattern.test(e.name))?.[1] ?? "" : "";
|
|
const codec = CODECS[e.codec] ?? e.codec.toUpperCase();
|
|
const codecs = families.get(family) ?? [];
|
|
if (!codecs.includes(codec)) codecs.push(codec);
|
|
families.set(family, codecs);
|
|
}
|
|
return [...families].map(([family, codecs]) => `${family} ${codecs.join("/")}`.trim()).join(", ");
|
|
}
|