Add Gitea restart workflow and link-style "Run again" for the public view
Test and deploy enrollment demo / test (push) Successful in 36s
Test and deploy enrollment demo / deploy (push) Successful in 1m13s

The server deployment cannot mount the Docker socket safely, so the web
view's button now opens the Gitea page for a workflow_dispatch workflow
that recreates the stack and replays the demo. Gitea handles who may run it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 21:54:24 +03:30
co-authored by Claude Sonnet 5.5
parent bf40b92c52
commit 37ca9d4da1
7 changed files with 49 additions and 8 deletions
+11 -2
View File
@@ -239,7 +239,10 @@ for (const [id, cls] of [['onlychecks', 'only-checks'], ['hidedetail', 'hide-det
// refresh shows the whole run again.
// Run again: ask the viewer server to restart the whole demo (backend, boards and a fresh broker).
// The custom header is required by the server so other web pages cannot trigger it.
let cfg = { restart: false, restartUrl: '' };
document.getElementById('restart').addEventListener('click', async () => {
// Public deployment: no Docker access here, so send the user to Gitea, which requires a login.
if (!cfg.restart && cfg.restartUrl) { window.open(cfg.restartUrl, '_blank', 'noopener'); return; }
document.getElementById('restart').disabled = true;
try {
const r = await fetch('/api/restart', { method: 'POST', headers: { 'X-Demo-Action': 'restart' } });
@@ -259,7 +262,13 @@ function resetView() {
}
// The restart button only exists when the server was started with restart support enabled.
fetch('/api/config').then(r => r.json()).then(c => { if (!c.restart) document.getElementById('restart').style.display = 'none'; })
fetch('/api/config').then(r => r.json()).then(c => {
cfg = c;
const b = document.getElementById('restart');
if (c.restart) return;
if (c.restartUrl) { b.innerHTML = '&#8635; Run again (via Gitea)'; b.title = 'Opens Gitea, where you run the "Restart demo" workflow (login required)'; }
else b.style.display = 'none';
})
.catch(() => { document.getElementById('restart').style.display = 'none'; });
buildCards();
@@ -271,7 +280,7 @@ es.onmessage = e => add(JSON.parse(e.data));
es.addEventListener('reset', resetView);
es.addEventListener('status', e => {
const s = JSON.parse(e.data);
document.getElementById('restart').disabled = s.busy;
if (cfg.restart) document.getElementById('restart').disabled = s.busy;
document.getElementById('status').textContent = s.busy || s.text !== 'ready' ? s.text : liveText;
});
</script>