fixed reboot menu
This commit is contained in:
@@ -5,6 +5,7 @@ const POLL_INTERVAL_SERVICES = 5000; // 5 s
|
|||||||
const POLL_INTERVAL_UPDATES = 1800000; // 30 min
|
const POLL_INTERVAL_UPDATES = 1800000; // 30 min
|
||||||
const ACTION_REFRESH_DELAY = 1500; // 1.5 s after start/stop/restart
|
const ACTION_REFRESH_DELAY = 1500; // 1.5 s after start/stop/restart
|
||||||
const UPDATE_POLL_INTERVAL = 2000; // 2 s while update is running
|
const UPDATE_POLL_INTERVAL = 2000; // 2 s while update is running
|
||||||
|
const REBOOT_CHECK_INTERVAL = 5000; // 5 s between reconnect attempts
|
||||||
|
|
||||||
const CATEGORY_ORDER = [
|
const CATEGORY_ORDER = [
|
||||||
"infrastructure",
|
"infrastructure",
|
||||||
@@ -19,7 +20,7 @@ const STATUS_LOADING_STATES = new Set([
|
|||||||
"reloading", "activating", "deactivating", "maintenance",
|
"reloading", "activating", "deactivating", "maintenance",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// ── State ─────────────────────────────────────────────────────────
|
// ── State ──────────────────────────────────────────────<EFBFBD><EFBFBD><EFBFBD>──────────
|
||||||
|
|
||||||
let _servicesCache = [];
|
let _servicesCache = [];
|
||||||
let _categoryLabels = {};
|
let _categoryLabels = {};
|
||||||
@@ -31,20 +32,22 @@ let _updateFinished = false;
|
|||||||
|
|
||||||
// ── DOM refs ──────────────────────────────────────────────────────
|
// ── DOM refs ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
const $tilesArea = document.getElementById("tiles-area");
|
const $tilesArea = document.getElementById("tiles-area");
|
||||||
const $updateBtn = document.getElementById("btn-update");
|
const $updateBtn = document.getElementById("btn-update");
|
||||||
const $updateBadge = document.getElementById("update-badge");
|
const $updateBadge = document.getElementById("update-badge");
|
||||||
const $refreshBtn = document.getElementById("btn-refresh");
|
const $refreshBtn = document.getElementById("btn-refresh");
|
||||||
const $internalIp = document.getElementById("ip-internal");
|
const $internalIp = document.getElementById("ip-internal");
|
||||||
const $externalIp = document.getElementById("ip-external");
|
const $externalIp = document.getElementById("ip-external");
|
||||||
|
|
||||||
const $modal = document.getElementById("update-modal");
|
const $modal = document.getElementById("update-modal");
|
||||||
const $modalSpinner = document.getElementById("modal-spinner");
|
const $modalSpinner = document.getElementById("modal-spinner");
|
||||||
const $modalStatus = document.getElementById("modal-status");
|
const $modalStatus = document.getElementById("modal-status");
|
||||||
const $modalLog = document.getElementById("modal-log");
|
const $modalLog = document.getElementById("modal-log");
|
||||||
const $btnReboot = document.getElementById("btn-reboot");
|
const $btnReboot = document.getElementById("btn-reboot");
|
||||||
const $btnSave = document.getElementById("btn-save-report");
|
const $btnSave = document.getElementById("btn-save-report");
|
||||||
const $btnCloseModal = document.getElementById("btn-close-modal");
|
const $btnCloseModal = document.getElementById("btn-close-modal");
|
||||||
|
|
||||||
|
const $rebootOverlay = document.getElementById("reboot-overlay");
|
||||||
|
|
||||||
// ── Helpers ───────────────────────────────────────────────────────
|
// ── Helpers ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -334,25 +337,21 @@ async function pollUpdateStatus() {
|
|||||||
try {
|
try {
|
||||||
const data = await apiFetch(`/api/updates/status?offset=${_updateLogOffset}`);
|
const data = await apiFetch(`/api/updates/status?offset=${_updateLogOffset}`);
|
||||||
|
|
||||||
// Server came back after being down
|
|
||||||
if (_serverWasDown) {
|
if (_serverWasDown) {
|
||||||
_serverWasDown = false;
|
_serverWasDown = false;
|
||||||
appendLog("[Server reconnected]\n");
|
appendLog("[Server reconnected]\n");
|
||||||
if ($modalStatus) $modalStatus.textContent = "Updating…";
|
if ($modalStatus) $modalStatus.textContent = "Updating…";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append new log content
|
|
||||||
if (data.log) {
|
if (data.log) {
|
||||||
appendLog(data.log);
|
appendLog(data.log);
|
||||||
}
|
}
|
||||||
_updateLogOffset = data.offset;
|
_updateLogOffset = data.offset;
|
||||||
|
|
||||||
// RUNNING → keep polling
|
|
||||||
if (data.running) {
|
if (data.running) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finished — check result
|
|
||||||
_updateFinished = true;
|
_updateFinished = true;
|
||||||
stopUpdatePoll();
|
stopUpdatePoll();
|
||||||
|
|
||||||
@@ -362,7 +361,6 @@ async function pollUpdateStatus() {
|
|||||||
onUpdateDone(false);
|
onUpdateDone(false);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Server is restarting during nixos-rebuild switch — keep polling
|
|
||||||
if (!_serverWasDown) {
|
if (!_serverWasDown) {
|
||||||
_serverWasDown = true;
|
_serverWasDown = true;
|
||||||
appendLog("\n[Server restarting — waiting for it to come back…]\n");
|
appendLog("\n[Server restarting — waiting for it to come back…]\n");
|
||||||
@@ -397,9 +395,37 @@ function saveErrorReport() {
|
|||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Reboot with confirmation overlay ──────────────────────────────
|
||||||
|
|
||||||
function doReboot() {
|
function doReboot() {
|
||||||
|
// Close the update modal
|
||||||
|
if ($modal) $modal.classList.remove("open");
|
||||||
|
stopUpdatePoll();
|
||||||
|
|
||||||
|
// Show the reboot overlay
|
||||||
|
if ($rebootOverlay) $rebootOverlay.classList.add("visible");
|
||||||
|
|
||||||
|
// Send the reboot command
|
||||||
fetch("/api/reboot", { method: "POST" }).catch(() => {});
|
fetch("/api/reboot", { method: "POST" }).catch(() => {});
|
||||||
if ($modalStatus) $modalStatus.textContent = "Rebooting…";
|
|
||||||
|
// Start polling to detect when the server comes back
|
||||||
|
setTimeout(waitForServerReboot, REBOOT_CHECK_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
function waitForServerReboot() {
|
||||||
|
fetch("/api/config", { cache: "no-store" })
|
||||||
|
.then(res => {
|
||||||
|
if (res.ok) {
|
||||||
|
// Server is back — reload the page to get the fresh state
|
||||||
|
window.location.reload();
|
||||||
|
} else {
|
||||||
|
setTimeout(waitForServerReboot, REBOOT_CHECK_INTERVAL);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// Still down — keep trying
|
||||||
|
setTimeout(waitForServerReboot, REBOOT_CHECK_INTERVAL);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Event listeners ───────────────────────────────────────────────
|
// ── Event listeners ───────────────────────────────────────────────
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Sovran_SystemsOS Hub — Web UI Stylesheet
|
/* Sovran_SystemsOS Hub — Web UI Stylesheet
|
||||||
Dark theme matching the Adwaita dark aesthetic
|
Dark theme matching the Adwaita dark aesthetic
|
||||||
v2 — cache bust */
|
v3 — reboot overlay */
|
||||||
|
|
||||||
*, *::before, *::after {
|
*, *::before, *::after {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -70,7 +70,7 @@ body {
|
|||||||
letter-spacing: 0.03em;
|
letter-spacing: 0.03em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Buttons ────────────────────────────────────────────────────── */
|
/* ── Buttons ────────────────────────────────────────────────────<EFBFBD><EFBFBD>─ */
|
||||||
|
|
||||||
button {
|
button {
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
@@ -101,7 +101,7 @@ button:disabled {
|
|||||||
opacity: 0.88;
|
opacity: 0.88;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update System button: BLUE (#89b4fa) by default */
|
/* Update System button: BLUE by default */
|
||||||
.btn-update {
|
.btn-update {
|
||||||
background-color: #89b4fa;
|
background-color: #89b4fa;
|
||||||
color: #1e1e2e;
|
color: #1e1e2e;
|
||||||
@@ -320,7 +320,6 @@ button:disabled {
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CSS-only toggle switch */
|
|
||||||
.toggle-label {
|
.toggle-label {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -475,19 +474,15 @@ button:disabled {
|
|||||||
border-top: 1px solid var(--border-color);
|
border-top: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Modal footer buttons ────────────────────────────────────────
|
/* Reboot = GREEN */
|
||||||
Reboot = GREEN, Save = YELLOW, Close = GREY */
|
|
||||||
|
|
||||||
.modal-footer .btn-reboot,
|
.modal-footer .btn-reboot,
|
||||||
.modal-footer button.btn-reboot,
|
button.btn-reboot {
|
||||||
button#btn-reboot {
|
|
||||||
background-color: #2ec27e;
|
background-color: #2ec27e;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-footer .btn-reboot:hover:not(:disabled),
|
.modal-footer .btn-reboot:hover:not(:disabled),
|
||||||
.modal-footer button.btn-reboot:hover:not(:disabled),
|
button.btn-reboot:hover:not(:disabled) {
|
||||||
button#btn-reboot:hover:not(:disabled) {
|
|
||||||
background-color: #27ae6e;
|
background-color: #27ae6e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,6 +504,94 @@ button#btn-reboot:hover:not(:disabled) {
|
|||||||
background-color: #5a5c72;
|
background-color: #5a5c72;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Reboot overlay ─────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
.reboot-overlay {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background-color: rgba(15, 15, 25, 0.92);
|
||||||
|
z-index: 999;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reboot-overlay.visible {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reboot-card {
|
||||||
|
background-color: var(--surface-color);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 48px 56px;
|
||||||
|
text-align: center;
|
||||||
|
max-width: 480px;
|
||||||
|
box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
|
||||||
|
animation: reboot-fade-in 0.4s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes reboot-fade-in {
|
||||||
|
from { opacity: 0; transform: scale(0.92) translateY(12px); }
|
||||||
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.reboot-icon {
|
||||||
|
font-size: 3rem;
|
||||||
|
color: var(--accent-color);
|
||||||
|
margin-bottom: 16px;
|
||||||
|
animation: reboot-spin 2s linear infinite;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes reboot-spin {
|
||||||
|
to { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.reboot-title {
|
||||||
|
font-size: 1.35rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reboot-message {
|
||||||
|
font-size: 0.92rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reboot-dots {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reboot-dot {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: var(--accent-color);
|
||||||
|
animation: reboot-bounce 1.4s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reboot-dot:nth-child(2) { animation-delay: 0.2s; }
|
||||||
|
.reboot-dot:nth-child(3) { animation-delay: 0.4s; }
|
||||||
|
|
||||||
|
@keyframes reboot-bounce {
|
||||||
|
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
|
||||||
|
40% { opacity: 1; transform: scale(1.2); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.reboot-submessage {
|
||||||
|
font-size: 0.82rem;
|
||||||
|
color: var(--text-dim);
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
/* ── Empty state ────────────────────────────────────────────────── */
|
/* ── Empty state ────────────────────────────────────────────────── */
|
||||||
|
|
||||||
.empty-state {
|
.empty-state {
|
||||||
@@ -547,4 +630,8 @@ button#btn-reboot:hover:not(:disabled) {
|
|||||||
width: 160px;
|
width: 160px;
|
||||||
min-height: 200px;
|
min-height: 200px;
|
||||||
}
|
}
|
||||||
|
.reboot-card {
|
||||||
|
padding: 36px 28px;
|
||||||
|
margin: 0 16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Sovran_SystemsOS Hub</title>
|
<title>Sovran_SystemsOS Hub</title>
|
||||||
<link rel="stylesheet" href="/static/style.css?v=2" />
|
<link rel="stylesheet" href="/static/style.css?v=3" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -54,6 +54,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/app.js?v=2"></script>
|
<!-- Reboot overlay -->
|
||||||
|
<div class="reboot-overlay" id="reboot-overlay">
|
||||||
|
<div class="reboot-card">
|
||||||
|
<div class="reboot-icon">↻</div>
|
||||||
|
<h2 class="reboot-title">System Rebooting</h2>
|
||||||
|
<p class="reboot-message">
|
||||||
|
Sovran_SystemsOS is now restarting.<br />
|
||||||
|
This page will automatically reconnect once the system is back online.
|
||||||
|
</p>
|
||||||
|
<div class="reboot-dots">
|
||||||
|
<span class="reboot-dot"></span>
|
||||||
|
<span class="reboot-dot"></span>
|
||||||
|
<span class="reboot-dot"></span>
|
||||||
|
</div>
|
||||||
|
<p class="reboot-submessage">Stay tuned…</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/static/app.js?v=3"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user