updated logging
This commit is contained in:
@@ -27,8 +27,9 @@ let _updateLog = "";
|
|||||||
let _updatePollTimer = null;
|
let _updatePollTimer = null;
|
||||||
let _updateLogOffset = 0;
|
let _updateLogOffset = 0;
|
||||||
let _serverWasDown = false;
|
let _serverWasDown = false;
|
||||||
|
let _updateFinished = false;
|
||||||
|
|
||||||
// ── DOM refs ────────────────────────────────────────────<EFBFBD><EFBFBD><EFBFBD>─────────
|
// ── 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");
|
||||||
@@ -250,8 +251,13 @@ async function loadNetwork() {
|
|||||||
async function checkUpdates() {
|
async function checkUpdates() {
|
||||||
try {
|
try {
|
||||||
const data = await apiFetch("/api/updates/check");
|
const data = await apiFetch("/api/updates/check");
|
||||||
|
const hasUpdates = !!data.available;
|
||||||
if ($updateBadge) {
|
if ($updateBadge) {
|
||||||
$updateBadge.classList.toggle("visible", !!data.available);
|
$updateBadge.classList.toggle("visible", hasUpdates);
|
||||||
|
}
|
||||||
|
// Toggle button color: blue (default) → green (updates available)
|
||||||
|
if ($updateBtn) {
|
||||||
|
$updateBtn.classList.toggle("has-updates", hasUpdates);
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
@@ -263,6 +269,7 @@ function openUpdateModal() {
|
|||||||
_updateLog = "";
|
_updateLog = "";
|
||||||
_updateLogOffset = 0;
|
_updateLogOffset = 0;
|
||||||
_serverWasDown = false;
|
_serverWasDown = false;
|
||||||
|
_updateFinished = false;
|
||||||
if ($modalLog) $modalLog.textContent = "";
|
if ($modalLog) $modalLog.textContent = "";
|
||||||
if ($modalStatus) $modalStatus.textContent = "Starting update…";
|
if ($modalStatus) $modalStatus.textContent = "Starting update…";
|
||||||
if ($modalSpinner) $modalSpinner.classList.add("spinning");
|
if ($modalSpinner) $modalSpinner.classList.add("spinning");
|
||||||
@@ -323,6 +330,9 @@ function stopUpdatePoll() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function pollUpdateStatus() {
|
async function pollUpdateStatus() {
|
||||||
|
// Don't poll if we already know it's done
|
||||||
|
if (_updateFinished) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await apiFetch(`/api/updates/status?offset=${_updateLogOffset}`);
|
const data = await apiFetch(`/api/updates/status?offset=${_updateLogOffset}`);
|
||||||
|
|
||||||
@@ -340,6 +350,7 @@ async function pollUpdateStatus() {
|
|||||||
|
|
||||||
// Check if finished
|
// Check if finished
|
||||||
if (!data.running) {
|
if (!data.running) {
|
||||||
|
_updateFinished = true;
|
||||||
stopUpdatePoll();
|
stopUpdatePoll();
|
||||||
if (data.result === "success") {
|
if (data.result === "success") {
|
||||||
onUpdateDone(true);
|
onUpdateDone(true);
|
||||||
@@ -402,7 +413,7 @@ if ($modal) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Init ──────────────────────────────────────────────────────────
|
// ── Init ──────<EFBFBD><EFBFBD>───────────────────────────────────────────────────
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -100,9 +100,10 @@ button:disabled {
|
|||||||
opacity: 0.88;
|
opacity: 0.88;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update button: blue by default, green when updates available */
|
||||||
.btn-update {
|
.btn-update {
|
||||||
background-color: var(--green);
|
background-color: var(--accent-color);
|
||||||
color: #fff;
|
color: #1e1e2e;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -110,6 +111,15 @@ button:disabled {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-update:hover:not(:disabled) {
|
.btn-update:hover:not(:disabled) {
|
||||||
|
opacity: 0.88;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-update.has-updates {
|
||||||
|
background-color: var(--green);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-update.has-updates:hover:not(:disabled) {
|
||||||
background-color: #27ae6e;
|
background-color: #27ae6e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,6 +461,7 @@ button:disabled {
|
|||||||
background-color: #12121c;
|
background-color: #12121c;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
min-height: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-footer {
|
.modal-footer {
|
||||||
@@ -462,13 +473,14 @@ button:disabled {
|
|||||||
border-top: 1px solid var(--border-color);
|
border-top: 1px solid var(--border-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reboot button: green */
|
||||||
.btn-reboot {
|
.btn-reboot {
|
||||||
background-color: var(--red);
|
background-color: var(--green);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-reboot:hover:not(:disabled) {
|
.btn-reboot:hover:not(:disabled) {
|
||||||
background-color: #c0181f;
|
background-color: #27ae6e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-save {
|
.btn-save {
|
||||||
@@ -527,4 +539,4 @@ button:disabled {
|
|||||||
width: 160px;
|
width: 160px;
|
||||||
min-height: 200px;
|
min-height: 200px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user