Add missing loadArc, arcTestPing, arcPurge functions

ARC REACTOR tab had HTML and PHP API handlers but no JS load function,
causing ReferenceError on every tab click. Adds all three missing functions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 18:14:56 +00:00
parent abe7a25141
commit d3d2b36257
+63
View File
@@ -4328,6 +4328,69 @@ async function clearanceRuleCreate() {
} catch(e) { toast('Failed', 'err'); }
}
// ── ARC REACTOR ──────────────────────────────────────────────────────────────
async function loadArc() {
const tbl = document.getElementById('arc-jobs-tbl');
if (!tbl) return;
tbl.innerHTML = '<div class="loading">LOADING...</div>';
const status = document.getElementById('arc-job-filter')?.value || '';
const [s, jobs] = await Promise.all([
api('arc_status'),
api('arc_jobs', {status, limit: 100}),
]);
// status bar
const online = s?.online;
document.getElementById('arc-status-val').textContent = online ? '● ONLINE' : '○ OFFLINE';
document.getElementById('arc-status-val').style.color = online ? 'var(--green)' : 'var(--red)';
document.getElementById('arc-version-val').textContent = s?.version || '—';
document.getElementById('arc-done-val').textContent = s?.jobs_done ?? s?.stats?.done ?? '—';
document.getElementById('arc-fail-val').textContent = s?.jobs_failed ?? s?.stats?.failed ?? '—';
document.getElementById('arc-hb-val').textContent = s?.last_heartbeat ? ts(s.last_heartbeat) : (online ? 'ALIVE' : '—');
document.getElementById('arc-caps-val').textContent = Array.isArray(s?.capabilities) ? s.capabilities.join(' · ') : (s?.capabilities || '—');
const list = Array.isArray(jobs) ? jobs : (jobs?.jobs || []);
if (!list.length) {
tbl.innerHTML = '<div class="empty">No jobs found.</div>';
return;
}
const STATUS_COLOR = {queued:'var(--cyan)',running:'var(--yellow)',done:'var(--green)',failed:'var(--red)',cancelled:'var(--dim)'};
const rows = list.map(j => {
const sc = STATUS_COLOR[j.status] || 'var(--text)';
return `<tr>
<td style="width:50px;font-family:var(--mono);font-size:0.65rem;color:var(--dim)">#${j.id}</td>
<td style="width:80px"><span style="color:${sc};font-size:0.62rem;font-weight:700">${esc(j.status||'').toUpperCase()}</span></td>
<td style="width:120px;font-size:0.65rem">${esc(j.type||'—')}</td>
<td style="font-size:0.62rem;color:var(--dim)">${esc(j.created_by||'—')}</td>
<td style="font-size:0.62rem;max-width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${j.result ? esc(JSON.stringify(j.result).substring(0,120)) : '—'}</td>
<td style="font-size:0.6rem;color:var(--dim);white-space:nowrap">${ts(j.created_at)}</td>
</tr>`;
}).join('');
tbl.innerHTML = `<table><thead><tr>
<th>ID</th><th>STATUS</th><th>TYPE</th><th>BY</th><th>RESULT</th><th>CREATED</th>
</tr></thead><tbody>${rows}</tbody></table>`;
}
async function arcTestPing() {
const d = await api('arc_ping');
if (d?.job_id || d?.id) {
toast('Ping job queued — ID #' + (d.job_id || d.id), 'ok');
setTimeout(loadArc, 1200);
} else {
toast('Ping failed: ' + (d?.error || 'no response'), 'err');
}
}
async function arcPurge() {
if (!confirm('Purge completed/failed jobs older than 24h?')) return;
const d = await api('arc_purge');
toast(d?.purged != null ? `Purged ${d.purged} jobs` : 'Purge complete', 'ok');
loadArc();
}
</script>
</body>
</html>