This commit is contained in:
@@ -247,15 +247,48 @@ function updateWidgetCard(widget, status) {
|
||||
}
|
||||
}
|
||||
|
||||
function setBadge(el, text, tone) {
|
||||
if (!el) return;
|
||||
el.textContent = text;
|
||||
el.className = `badge ${tone} widget-badge`;
|
||||
}
|
||||
|
||||
function renderBuilds(builds) {
|
||||
const grid = document.getElementById('buildGrid');
|
||||
grid.innerHTML = '';
|
||||
function setBadge(el, text, tone) {
|
||||
if (!el) return;
|
||||
el.textContent = text;
|
||||
el.className = `badge ${tone} widget-badge`;
|
||||
}
|
||||
|
||||
function safeDomId(value) {
|
||||
return String(value).replace(/[^a-zA-Z0-9_-]/g, '-');
|
||||
}
|
||||
|
||||
function buildDomIds(build) {
|
||||
if (build.id === 'org_web') {
|
||||
return {
|
||||
btnId: 'buildBtn',
|
||||
killId: 'killWebBtn',
|
||||
resultId: 'buildResult',
|
||||
logId: 'logOutput',
|
||||
lastRunId: 'webLastRunMeta',
|
||||
};
|
||||
}
|
||||
if (build.id === 'emacs') {
|
||||
return {
|
||||
btnId: 'emacsBtn',
|
||||
killId: 'killEmacsBtn',
|
||||
resultId: 'emacsResult',
|
||||
logId: 'emacsLogs',
|
||||
lastRunId: 'emacsLastRunMeta',
|
||||
};
|
||||
}
|
||||
const id = safeDomId(build.id);
|
||||
return {
|
||||
btnId: `${id}Btn`,
|
||||
killId: `${id}CancelBtn`,
|
||||
resultId: `${id}Result`,
|
||||
logId: `${id}Logs`,
|
||||
lastRunId: `${id}LastRunMeta`,
|
||||
};
|
||||
}
|
||||
|
||||
function renderBuilds(builds) {
|
||||
const grid = document.getElementById('buildGrid');
|
||||
grid.innerHTML = '';
|
||||
for (const build of builds) {
|
||||
grid.appendChild(createBuildCard(build));
|
||||
}
|
||||
@@ -270,15 +303,11 @@ function renderBuilds(builds) {
|
||||
|
||||
function createBuildCard(build) {
|
||||
const article = document.createElement('article');
|
||||
article.className = 'panel run-card';
|
||||
article.dataset.buildId = build.id;
|
||||
article.setAttribute('data-build-id', build.id);
|
||||
|
||||
const btnId = build.id === 'org_web' ? 'buildBtn' : 'emacsBtn';
|
||||
const killId = build.id === 'org_web' ? 'killWebBtn' : 'killEmacsBtn';
|
||||
const resultId = build.id === 'org_web' ? 'buildResult' : 'emacsResult';
|
||||
const logId = build.id === 'org_web' ? 'logOutput' : 'emacsLogs';
|
||||
const lastRunId = build.id === 'org_web' ? 'webLastRunMeta' : 'emacsLastRunMeta';
|
||||
article.className = 'panel run-card';
|
||||
article.dataset.buildId = build.id;
|
||||
article.setAttribute('data-build-id', build.id);
|
||||
|
||||
const { btnId, killId, resultId, logId, lastRunId } = buildDomIds(build);
|
||||
|
||||
article.innerHTML = `
|
||||
<div class="panel-header">
|
||||
@@ -383,17 +412,16 @@ async function fetchUptime() {
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
async function fetchLastRuns() {
|
||||
try {
|
||||
const res = await fetch(manifest.status.lastRuns);
|
||||
const data = await res.json();
|
||||
for (const build of manifest.builds) {
|
||||
const metaId = build.id === 'org_web' ? 'webLastRunMeta' : 'emacsLastRunMeta';
|
||||
renderLastRun(metaId, data[build.lastRunKey]);
|
||||
updateBuildStatusFromLastRun(build, data[build.lastRunKey]);
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
async function fetchLastRuns() {
|
||||
try {
|
||||
const res = await fetch(manifest.status.lastRuns);
|
||||
const data = await res.json();
|
||||
for (const build of manifest.builds) {
|
||||
renderLastRun(buildDomIds(build).lastRunId, data[build.lastRunKey]);
|
||||
updateBuildStatusFromLastRun(build, data[build.lastRunKey]);
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
function updateBuildStatusFromLastRun(build, info) {
|
||||
if (!build.statusDotId || !info || info.lastRun === 'never') return;
|
||||
|
||||
Reference in New Issue
Block a user