diff --git a/dashboard/api.py b/dashboard/api.py index 37abb86..19c750c 100644 --- a/dashboard/api.py +++ b/dashboard/api.py @@ -84,6 +84,8 @@ class TaskBoardHandler(SimpleHTTPRequestHandler): self.handle_eco_sessions_clear() elif self.path == '/api/eco/git-commit': self.handle_eco_git_commit() + elif self.path == '/api/eco/restart-taskboard': + self.handle_eco_restart_taskboard() else: self.send_error(404) @@ -2403,6 +2405,18 @@ class TaskBoardHandler(SimpleHTTPRequestHandler): except Exception as e: self.send_json({'success': False, 'error': str(e)}, 500) + def handle_eco_restart_taskboard(self): + """Restart the taskboard itself. Sends response then exits; systemd restarts.""" + import threading + self.send_json({'success': True, 'message': 'Restarting taskboard in 1s...'}) + + def _exit(): + import time + time.sleep(1) + os._exit(0) + + threading.Thread(target=_exit, daemon=True).start() + def handle_eco_sessions_clear(self): """Clear active sessions (all or specific channel).""" try: diff --git a/dashboard/eco.html b/dashboard/eco.html index 3485e0f..d9f5f78 100644 --- a/dashboard/eco.html +++ b/dashboard/eco.html @@ -649,6 +649,10 @@ Refresh + @@ -1237,6 +1241,24 @@ } } + // ── Taskboard Restart ───────────────────────────────────── + + async function restartTaskboard() { + if (!confirm('Restart taskboard? Pagina va fi indisponibila ~5 secunde.')) return; + try { + await fetch('/echo/api/eco/restart-taskboard', { method: 'POST' }); + } catch (e) { /* expected — server dies */ } + // Wait for restart, then reload + setTimeout(() => { + const check = setInterval(async () => { + try { + const r = await fetch('/echo/api/status'); + if (r.ok) { clearInterval(check); location.reload(); } + } catch (e) { /* still restarting */ } + }, 1000); + }, 2000); + } + // ── Init ──────────────────────────────────────────────── loadStatus();