phase 1 rework

This commit is contained in:
admin_rb committed 2026-10-23 16:38:55 +02:00
1 parent 211bfd174d
commit 20054198f3
38 files changed
+5001 -1019

No files matched your search

+1 -5
View File
@@ -7,11 +7,7 @@
<%= message %>
</p>
<% if (details) { %>
<pre class="bg-dark text-white p-3 mt-3"><%= details %></pre>
<% } %>
<a href="/" class="btn btn-danger mt-3">Return to Home</a>
</div>
<%- include("partials/footer") %>
<%- include("partials/footer") %>
+5 -2
View File
@@ -46,11 +46,11 @@
<!-- 2. TITEL (shared) -->
<!-- ===================== -->
<div class="mb-3">
<label class="form-label">Titel</label>
<label class="form-label">Title / filename</label>
<input
class="form-control"
name="name"
placeholder="Titel S01E01"
placeholder="Title S01E01"
/>
</div>
@@ -104,6 +104,9 @@
<input
class="form-control"
name="token"
type="password"
autocomplete="off"
required
placeholder="Token"
/>
</div>
+9 -3
View File
@@ -11,10 +11,12 @@
<body>
<!-- CAPTCHA ALERT (initially hidden, will be toggled by JS) -->
<div id="captcha-alert" class="alert alert-danger text-center m-0" style="display: <%= (global && global.captcha_blocked) ? 'block' : 'none' %>;">
⚠ Human Action Required: Proxer CAPTCHA triggered. Workers paused until cleared.
<div id="captcha-alert" class="alert alert-danger text-center m-0" style="display: <%= (typeof global !== 'undefined' && global.captcha_blocked) ? 'block' : 'none' %>;">
<span id="captcha-message"><%= (typeof global !== 'undefined' && global.pause_reason === 'resolution')
? '⚠ The video link could not be resolved. Possible causes include CAPTCHA or login verification, an unavailable video, or a source change. Workers are paused for verification.'
: '⚠ Authentication or access needs verification on Proxer. Workers are paused until verification is complete.' %></span>
<form id="clear-captcha-form" action="/clear-captcha" method="POST" class="d-inline ms-2">
<button class="btn btn-danger btn-sm">⚠ Clear CAPTCHA</button>
<button class="btn btn-danger btn-sm">Resume after verification</button>
</form>
</div>
<div class="container-fluid py-4" style="max-width: 2000px;">
@@ -34,8 +36,12 @@
const res = await fetch('/status-data', { cache: 'no-store' });
const data = await res.json();
const alertEl = document.getElementById('captcha-alert');
const messageEl = document.getElementById('captcha-message');
if (data.global && data.global.captcha_blocked) {
messageEl.textContent = data.global.pause_reason === 'resolution'
? '⚠ The video link could not be resolved. Possible causes include CAPTCHA or login verification, an unavailable video, or a source change. Workers are paused for verification.'
: '⚠ Authentication or access needs verification on Proxer. Workers are paused until verification is complete.';
alertEl.style.display = 'block';
} else {
alertEl.style.display = 'none';
+210 -256
View File
@@ -42,15 +42,15 @@
<div class="d-flex justify-content-between mb-2">
<div>
<h4 class="mb-0">PM2 Processes</h4>
<div class="subtle">Select a process to manage and view details.</div>
<h4 class="mb-0">Downloader Workers</h4>
<div class="subtle">Select a worker to manage it and view its logs.</div>
</div>
<div class="d-flex gap-2 align-items-center">
<button id="refresh-list" class="btn btn-sm btn-outline-light">⟳</button>
<button id="refresh-list" class="btn btn-sm btn-outline-light" aria-label="Refresh worker list">⟳</button>
<!-- NEW: ONE-CLICK CREATE -->
<button id="btn-create" class="btn btn-sm btn-success">
<button id="btn-create" class="btn btn-sm btn-success" aria-label="Create downloader worker">
<strong>+</strong>
</button>
</div>
@@ -86,10 +86,12 @@
</a>
<% }) %>
<% } else { %>
<div class="alert alert-warning">No PM2 processes found.</div>
<div class="alert alert-warning">No downloader workers found.</div>
<% } %>
</div>
<pre id="control-output" class="mt-3 p-2" role="status" aria-live="polite" style="background:#0b0b0b; max-height:110px; overflow:auto; border-radius:6px; white-space:pre-wrap;">Worker action results will appear here.</pre>
<!-- CONTROL CENTRE -->
<div id="control-centre" class="mt-3 p-3" style="display:none; background:#3A3A3A; border-radius:8px; border:1px solid #555;">
<h5 id="cc-name">Process Name</h5>
@@ -101,7 +103,6 @@
<button id="btn-stop" class="btn btn-danger btn-sm">Stop</button>
<button id="btn-restart" class="btn btn-warning btn-sm">Restart</button>
<button id="btn-delete" class="btn btn-outline-light btn-sm">Delete</button>
<button id="btn-save" class="btn btn-outline-light btn-sm">Save</button>
</div>
<!-- Details -->
@@ -116,7 +117,6 @@
<div><span class="kv-label">Exec Path</span> <span class="kv-value" id="detail-exec">—</span></div>
</div>
<pre id="control-output" class="mt-3 p-2" style="background:#0b0b0b; height:110px; overflow:auto; border-radius:6px;">Actions output will appear here.</pre>
</div>
</div>
@@ -142,307 +142,261 @@
</div>
<script>
/* ============================================================
WEBSOCKET LOG CONNECTION
============================================================ */
const ws = new WebSocket(
(location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host
);
const logsEl = document.getElementById("logs");
function appendLog(msg) {
const line = `[${new Date().toLocaleTimeString()}] ${msg}`;
logsEl.textContent += line + "\n";
logsEl.scrollTop = logsEl.scrollHeight; // auto-scroll always
}
ws.addEventListener("open", () => appendLog("[ws connected]"));
ws.addEventListener("close", () => appendLog("[ws closed]"));
ws.addEventListener("message", ev => {
let obj;
try { obj = JSON.parse(ev.data); } catch { appendLog(ev.data); return; }
if (obj.type === "stdout") appendLog(obj.data);
else if (obj.type === "stderr") appendLog(obj.data);
else if (obj.type === "info") appendLog("[info] " + obj.message);
else if (obj.type === "error") appendLog("[error] " + obj.error);
else if (obj.type === "close") appendLog("[log stream closed]");
});
/* ============================================================
PROCESS SELECTION & DETAILS
============================================================ */
const ws = new WebSocket((location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host);
const logsEl = document.getElementById('logs');
const actionOutput = document.getElementById('control-output');
const MAX_VISIBLE_LOG = 64 * 1024;
let selectedEl = null;
let selectedData = null;
let selectionGeneration = 0;
let logWorkerName = null;
let commandInFlight = false;
function appendLog(message) {
const following = logsEl.scrollHeight - logsEl.scrollTop - logsEl.clientHeight < 40;
const combined = logsEl.textContent + `[${new Date().toLocaleTimeString()}] ${String(message)}\n`;
logsEl.textContent = combined.length > MAX_VISIBLE_LOG
? '[earlier log output omitted]\n' + combined.slice(-MAX_VISIBLE_LOG)
: combined;
if (following) logsEl.scrollTop = logsEl.scrollHeight;
}
function sendLogRequest(payload, showUnavailable = true) {
if (ws.readyState !== WebSocket.OPEN) {
if (showUnavailable) appendLog('[log connection is not ready]');
return false;
}
try {
ws.send(JSON.stringify(payload));
return true;
} catch {
if (showUnavailable) appendLog('[log request could not be sent]');
return false;
}
}
function startSelectedLogs() {
if (!selectedData || logWorkerName === selectedData.name) return;
if (sendLogRequest({ type: 'logs', name: selectedData.name })) logWorkerName = selectedData.name;
}
ws.addEventListener('open', () => {
appendLog('[log connection ready]');
startSelectedLogs();
});
ws.addEventListener('close', () => {
logWorkerName = null;
appendLog('[log connection closed; reload this page to reconnect]');
});
ws.addEventListener('error', () => appendLog('[log connection unavailable]'));
ws.addEventListener('message', event => {
let payload;
try { payload = JSON.parse(event.data); } catch { return; }
if (!payload || typeof payload !== 'object') return;
if (payload.type === 'stdout' || payload.type === 'stderr') appendLog(payload.data || '');
else if (payload.type === 'info') appendLog('[info] ' + (payload.message || ''));
else if (payload.type === 'error') {
logWorkerName = null;
appendLog('[error] ' + (payload.error || 'The log stream failed.'));
} else if (payload.type === 'close') {
logWorkerName = null;
appendLog('[log stream closed]');
}
});
function clearSelection() {
document.querySelectorAll('.pm2-row')
.forEach(r => r.classList.remove('active', 'selected-outline'));
selectionGeneration++;
document.querySelectorAll('.pm2-row').forEach(row => row.classList.remove('active', 'selected-outline'));
selectedEl = null;
selectedData = null;
document.getElementById("control-centre").style.display = "none";
logWorkerName = null;
document.getElementById('control-centre').style.display = 'none';
sendLogRequest({ type: 'stop-logs' }, false);
}
function populateControlCentre(d) {
document.getElementById("cc-name").innerText = d.name;
document.getElementById("cc-sub").innerText =
`pm_id: ${d.pmid} • pid: ${d.pid} • status: ${d.status}`;
document.getElementById("detail-name").innerText = d.name;
document.getElementById("detail-pmid").innerText = d.pmid;
document.getElementById("detail-pid").innerText = d.pid;
document.getElementById("detail-status").innerText = d.status;
document.getElementById("detail-uptime").innerText = d.uptime;
document.getElementById("detail-cpu").innerText = d.cpu;
document.getElementById("detail-mem").innerText = d.memoryMB;
document.getElementById("detail-exec").innerText = d.execPath;
function controlData(process) {
return { ...process, pmid: process.pm_id ?? process.pmid ?? '—' };
}
async function fetchFullProcess(name) {
try {
const res = await fetch('/pm2/list-json');
const json = await res.json();
if (!json.ok) return null;
return json.processes.find(p => p.name === name) || null;
} catch {
return null;
}
function populateControlCentre(data) {
const values = {
'cc-name': data.name,
'cc-sub': `pm_id: ${data.pmid} • pid: ${data.pid} • status: ${data.status}`,
'detail-name': data.name,
'detail-pmid': data.pmid,
'detail-pid': data.pid,
'detail-status': data.status,
'detail-uptime': data.uptime,
'detail-cpu': data.cpu,
'detail-mem': data.memoryMB,
'detail-exec': data.execPath,
};
for (const [id, value] of Object.entries(values)) document.getElementById(id).textContent = value ?? '—';
}
async function readProcesses() {
const response = await fetch('/pm2/list-json', { cache: 'no-store' });
const result = await response.json();
if (!response.ok || !result.ok || !Array.isArray(result.processes)) throw new Error('The worker list is unavailable.');
return result.processes;
}
function bindRowEvents() {
document.querySelectorAll('.pm2-row').forEach(row => {
row.addEventListener('click', async ev => {
ev.preventDefault();
// toggle deselect
row.addEventListener('click', async event => {
event.preventDefault();
if (selectedEl === row) {
clearSelection();
return;
}
// highlight selected
document.querySelectorAll('.pm2-row')
.forEach(r => r.classList.remove('active', 'selected-outline'));
clearSelection();
const requestGeneration = selectionGeneration;
row.classList.add('active', 'selected-outline');
selectedEl = row;
// base data
selectedData = {
selectedData = controlData({
name: row.dataset.name,
pmid: row.dataset.pmid,
pid: row.dataset.pid,
status: row.dataset.status
};
// fetch detailed data
const full = await fetchFullProcess(selectedData.name);
if (full) {
selectedData = {
name: full.name,
pmid: full.pm_id,
pid: full.pid,
status: full.status,
uptime: full.uptime,
cpu: full.cpu,
memoryMB: full.memoryMB,
execPath: full.execPath
};
}
status: row.dataset.status,
});
populateControlCentre(selectedData);
document.getElementById("control-centre").style.display = "block";
// AUTO-START LOGS
ws.send(JSON.stringify({
type: "logs",
name: selectedData.name
}));
appendLog("[auto logs for: " + selectedData.name + "]");
document.getElementById('control-centre').style.display = 'block';
const name = selectedData.name;
try {
const full = (await readProcesses()).find(process => process.name === name);
if (requestGeneration !== selectionGeneration || selectedData?.name !== name) return;
if (!full) {
clearSelection();
actionOutput.textContent = 'The selected worker is no longer available.';
return;
}
selectedData = controlData(full);
populateControlCentre(selectedData);
} catch {
if (requestGeneration !== selectionGeneration || selectedData?.name !== name) return;
actionOutput.textContent = 'Could not refresh the selected worker details.';
}
if (requestGeneration === selectionGeneration && selectedData?.name === name) startSelectedLogs();
});
});
}
bindRowEvents();
function element(tag, className, text) {
const node = document.createElement(tag);
if (className) node.className = className;
if (text !== undefined) node.textContent = String(text ?? '—');
return node;
}
/* ============================================================
REFRESH PROCESS LIST
============================================================ */
function processRow(process) {
const row = element('a', 'list-group-item pm2-row d-flex justify-content-between');
row.href = '#';
row.dataset.name = String(process.name);
row.dataset.pid = String(process.pid);
row.dataset.pmid = String(process.pm_id);
row.dataset.status = String(process.status);
const status = String(process.status || '').toLowerCase();
let badge = 'bg-secondary';
if (status === 'online' || status === 'running') badge = 'bg-success';
else if (status.includes('stop') || status.includes('exit')) badge = 'bg-danger';
else if (status.includes('start') || status.includes('launch')) badge = 'bg-warning text-dark';
const description = element('div');
description.append(element('strong', '', process.name), ' ', element('span', 'badge badge-small ' + badge, process.status), element('div', 'subtle', process.execPath));
const detail = element('div', 'text-end');
detail.append(element('div', '', 'pid: ' + process.pid), element('div', 'subtle', process.uptime));
row.append(description, detail);
return row;
}
async function refreshList() {
try {
const res = await fetch('/pm2/list-json');
const json = await res.json();
if (!json.ok) return;
const list = document.getElementById("process-list");
list.innerHTML = '';
json.processes.forEach(p => {
let status = (p.status || '').toLowerCase();
let badge = 'bg-secondary';
if (status === 'online' || status === 'running') badge = 'bg-success';
else if (status.includes('stop') || status.includes('exit')) badge = 'bg-danger';
else if (status.includes('start') || status.includes('launch')) badge = 'bg-warning text-dark';
const item = document.createElement('a');
item.href = "#";
item.className = "list-group-item pm2-row d-flex justify-content-between";
item.dataset.name = p.name;
item.dataset.pid = p.pid;
item.dataset.pmid = p.pm_id;
item.dataset.status = p.status;
item.innerHTML = `
<div>
<strong>${p.name}</strong>
<span class="badge badge-small ${badge}">${p.status}</span>
<div class="subtle">${p.execPath}</div>
</div>
<div class="text-end">
<div>pid: <span>${p.pid}</span></div>
<div class="subtle">${p.uptime}</div>
</div>
`;
list.appendChild(item);
});
const processes = await readProcesses();
const list = document.getElementById('process-list');
const selectedName = selectedData?.name;
list.replaceChildren();
for (const process of processes) {
const row = processRow(process);
list.appendChild(row);
if (process.name === selectedName) {
selectedEl = row;
selectedData = controlData(process);
row.classList.add('active', 'selected-outline');
populateControlCentre(selectedData);
}
}
if (!processes.length) list.appendChild(element('div', 'alert alert-warning', 'No downloader workers found.'));
if (selectedName && !processes.some(process => process.name === selectedName)) clearSelection();
bindRowEvents();
} catch (err) {
console.error(err);
return true;
} catch {
actionOutput.textContent = 'Could not refresh the worker list. Please try again.';
return false;
}
}
document.getElementById("refresh-list").addEventListener("click", refreshList);
/* ============================================================
PM2 COMMAND EXECUTION
============================================================ */
async function execCommand(payload, outEl) {
outEl.textContent = "Running...";
async function execCommand(payload) {
if (commandInFlight) return false;
commandInFlight = true;
actionOutput.textContent = 'Running worker command…';
try {
const res = await fetch('/pm2/command', {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
const response = await fetch('/pm2/command', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
const json = await res.json();
outEl.textContent = JSON.stringify(json, null, 2);
if (json.ok) refreshList();
} catch (err) {
outEl.textContent = "Error: " + err.message;
const result = await response.json();
actionOutput.textContent = result.message || result.error || 'The worker command could not be completed.';
if (response.ok && result.ok) {
await refreshList();
return true;
}
return false;
} catch {
actionOutput.textContent = 'Could not contact the worker supervisor. Please try again.';
return false;
} finally {
commandInFlight = false;
}
}
/* ============================================================
ONE-CLICK CREATE WORKER
============================================================ */
async function findNextWorkerName() {
const res = await fetch('/pm2/list-json');
const json = await res.json();
if (!json.ok) return "proxerdl-worker1";
const names = json.processes
.map(p => p.name)
.filter(n => /^proxerdl-worker\d+$/.test(n));
const nums = names.map(n => parseInt(n.replace("proxerdl-worker", ""), 10));
if (nums.length === 0) return "proxerdl-worker1";
nums.sort((a, b) => a - b);
const names = new Set((await readProcesses()).map(process => process.name));
let next = 1;
for (let n of nums) {
if (n === next) next++;
else if (n > next) break;
}
return "proxerdl-worker" + next;
while (names.has('proxerdl-worker' + next)) next++;
return 'proxerdl-worker' + next;
}
document.getElementById("btn-create").addEventListener("click", async () => {
const out = document.getElementById("control-output");
document.getElementById('btn-create').addEventListener('click', async event => {
const button = event.currentTarget;
if (button.disabled || commandInFlight) return;
button.disabled = true;
actionOutput.textContent = 'Preparing a downloader worker…';
try {
const name = await findNextWorkerName();
const scriptPath = "/home/pm2/Proxer-Downloader/queue_worker.js";
out.textContent = "Creating " + name + "...";
const res = await fetch('/pm2/command', {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
cmd: "create",
name,
scriptPath
})
});
const json = await res.json();
out.textContent = JSON.stringify(json, null, 2);
if (json.ok) {
await refreshList();
const row = [...document.querySelectorAll(".pm2-row")]
.find(r => r.dataset.name === name);
if (await execCommand({ cmd: 'create', name })) {
const row = [...document.querySelectorAll('.pm2-row')].find(item => item.dataset.name === name);
if (row) row.click();
}
} catch (err) {
out.textContent = "Error: " + err.message;
} catch {
actionOutput.textContent = 'Could not prepare the worker. Refresh the list and try again.';
} finally {
button.disabled = false;
}
});
/* ============================================================
QUICK ACTION BUTTONS
============================================================ */
document.getElementById("btn-start").addEventListener("click", () => {
if (!selectedData) return alert("Select a process.");
execCommand({ cmd: "start", name: selectedData.name }, document.getElementById("control-output"));
});
document.getElementById("btn-stop").addEventListener("click", () => {
if (!selectedData) return alert("Select a process.");
execCommand({ cmd: "stop", name: selectedData.name }, document.getElementById("control-output"));
});
document.getElementById("btn-restart").addEventListener("click", () => {
if (!selectedData) return alert("Select a process.");
execCommand({ cmd: "restart", name: selectedData.name }, document.getElementById("control-output"));
});
document.getElementById("btn-delete").addEventListener("click", () => {
if (!selectedData) return alert("Select a process.");
execCommand({ cmd: "delete", name: selectedData.name }, document.getElementById("control-output"));
});
document.getElementById("btn-save").addEventListener("click", () => {
execCommand({ cmd: "save" }, document.getElementById("control-output"));
});
/* ============================================================
LOG ACTIONS
============================================================ */
document.getElementById("clear-logs").addEventListener("click", () => {
logsEl.textContent = "";
});
for (const command of ['start', 'stop', 'restart', 'delete']) {
document.getElementById('btn-' + command).addEventListener('click', () => {
if (!selectedData) {
actionOutput.textContent = 'Select a downloader worker first.';
return;
}
execCommand({ cmd: command, name: selectedData.name });
});
}
document.getElementById('refresh-list').addEventListener('click', refreshList);
document.getElementById('clear-logs').addEventListener('click', () => { logsEl.textContent = ''; });
window.addEventListener('beforeunload', () => sendLogRequest({ type: 'stop-logs' }, false));
bindRowEvents();
</script>
<%- include('partials/footer') %>
+15 -18
View File
@@ -101,9 +101,6 @@
<div class="section-header">
<h3 class="status-title" style="color:#58a6ff;">Processing</h3>
<form action="/clear-processing" method="POST">
<button class="btn btn-outline-primary btn-sm rounded-pill">🗑️</button>
</form>
</div>
<ul class="list-group" id="processingList">
@@ -116,7 +113,7 @@
<strong style="color:#58a6ff"><%= job.filename %></strong>
<span class="spinner-border spinner-border-sm ms-1" style="color:#58a6ff"></span><br>
<small><%= job.url %></small><br>
<small>Started: <%= new Date(job.created_at).toLocaleString() %></small><br>
<small><%= job.started_at ? 'Started' : 'Queued' %>: <%= new Date(job.started_at || job.created_at).toLocaleString() %></small><br>
<% if (job.fileSize) { %>
<small>Downloaded: <%= job.fileSize %></small>
@@ -125,7 +122,7 @@
<% if (job.output_log) { %>
<details data-id="processing-<%= job._id %>">
<summary class="text-light">Live Log</summary>
<pre class="log-box"><%- job.output_log %></pre>
<pre class="log-box"><%= job.output_log %></pre>
</details>
<% } %>
</li>
@@ -166,7 +163,7 @@
<% if (job.output_log) { %>
<details data-id="done-<%= job._id %>">
<summary class="text-light">Show Log</summary>
<pre class="log-box-light"><%- job.output_log %></pre>
<pre class="log-box-light"><%= job.output_log %></pre>
</details>
<% } %>
@@ -204,7 +201,7 @@
<% if (job.output_log) { %>
<details data-id="failed-<%= job._id %>">
<summary class="text-danger">Show Error Log</summary>
<pre class="log-box-error"><%- job.output_log %></pre>
<pre class="log-box-error"><%= job.output_log %></pre>
</details>
<% } %>
@@ -244,20 +241,20 @@ async function refreshStatus() {
/* Renderer helpers */
const q = job => `
<li class="list-group-item">
<strong>${job.filename}</strong><br>
<small>${job.url}</small><br>
<strong>${escapeHtml(job.filename)}</strong><br>
<small>${escapeHtml(job.url)}</small><br>
<small>${new Date(job.created_at).toLocaleString()}</small>
</li>`;
const p = job => `
<li class="list-group-item">
<strong style="color:#58a6ff">${job.filename}</strong>
<strong style="color:#58a6ff">${escapeHtml(job.filename)}</strong>
<span class="spinner-border spinner-border-sm ms-1" style="color:#58a6ff"></span><br>
<small>${job.url}</small><br>
<small>Started: ${new Date(job.created_at).toLocaleString()}</small><br>
<small>${escapeHtml(job.url)}</small><br>
<small>${job.started_at ? 'Started' : 'Queued'}: ${new Date(job.started_at || job.created_at).toLocaleString()}</small><br>
<small>Downloaded: ${formatBytes(job.fileSize || 0)}</small>
${job.output_log ? `
<details data-id="processing-${job._id}">
<details data-id="processing-${escapeHtml(job._id)}">
<summary class="text-light">Live Log</summary>
<pre class="log-box">${escapeHtml(job.output_log)}</pre>
</details>` : ""}
@@ -265,11 +262,11 @@ async function refreshStatus() {
const d = job => `
<li class="list-group-item">
<strong class="text-success">${job.filename}</strong><br>
<strong class="text-success">${escapeHtml(job.filename)}</strong><br>
<small>${new Date(job.finished_at).toLocaleString()}</small><br>
<small>Size: ${formatBytes(job.fileSize || 0)}</small>
${job.output_log ? `
<details data-id="done-${job._id}">
<details data-id="done-${escapeHtml(job._id)}">
<summary class="text-light">Show Log</summary>
<pre class="log-box-light">${escapeHtml(job.output_log)}</pre>
</details>` : ""}
@@ -277,10 +274,10 @@ async function refreshStatus() {
const f = job => `
<li class="list-group-item">
<strong class="text-danger">${job.filename}</strong><br>
<strong class="text-danger">${escapeHtml(job.filename)}</strong><br>
<small>${new Date(job.failed_at).toLocaleString()}</small><br>
${job.output_log ? `
<details data-id="failed-${job._id}">
<details data-id="failed-${escapeHtml(job._id)}">
<summary class="text-danger">Show Error Log</summary>
<pre class="log-box-error">${escapeHtml(job.output_log)}</pre>
</details>` : ""}
@@ -305,7 +302,7 @@ async function refreshStatus() {
}
function escapeHtml(text) {
return text.replace(/[&<>"']/g, c =>
return String(text ?? "").replace(/[&<>"']/g, c =>
({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#039;" }[c])
);
}