feat(dashboard): restarts from 30 seconds; no "undefined" in the restart banner

Restarts can be scheduled in seconds (30 s to 24 h; minutes still accepted), with 30 second and 1 minute choices for
quick restarts. The restart banner only names who scheduled it when that is known: staff who manage restarts read it
from /api/server/restart, everyone else gets when and why from the status, which leaves the name out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-27 15:43:32 -05:00
parent 55ea44e2e8
commit cb2c26d520
5 changed files with 21 additions and 16 deletions

View File

@@ -210,7 +210,7 @@
function tick() {
var left = Math.max(0, Math.round(restart.at - Date.now() / 1000));
var text = left >= 60 ? Math.floor(left / 60) + ' min ' + (left % 60) + ' s' : left + ' s';
banner.textContent = 'Server restart in ' + text + (restart.reason ? ': ' + restart.reason : '') + ' (scheduled by ' + restart.by + ')';
banner.textContent = 'Server restart in ' + text + (restart.reason ? ': ' + restart.reason : '') + (restart.by ? ' (scheduled by ' + restart.by + ')' : '');
}
tick();
restartTimer = setInterval(tick, 1000);
@@ -304,6 +304,8 @@
if (initial) initial.textContent = (document.body.dataset.username || '?').charAt(0).toUpperCase();
connect();
if (DASH.can('moderate_names')) api.get('/api/moderation/counts').then(updateBadges).catch(function () {});
api.get('/api/status').then(function (s) { showRestart(s.restart); }).catch(function () {});
// Staff who manage restarts also see who scheduled it; everyone else gets when and why from the status
if (DASH.can('server_restart')) api.get('/api/server/restart').then(function (r) { showRestart(r && r.at ? r : null); }).catch(function () {});
else api.get('/api/status').then(function (s) { showRestart(s.restart); }).catch(function () {});
});
})();