imaging: pause page auto-refresh while a LAPS QR is showing

meta http-equiv=refresh fires every 5s and reloads the entire page,
wiping the LAPS QR state mid-scan. Replaced the meta tag with a
JS-driven setTimeout(location.reload, 5000) so renderLapsQR() can
clearTimeout it. Reload resumes when the QR is cleared (manual or
60s auto). Multi-bay safety: only resumes if no other bay still has
a QR rendered.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-05-14 19:50:24 -04:00
parent d5398bdd74
commit 1b7e1bfee4

View File

@@ -2,7 +2,18 @@
{% block title %}Imaging Progress - PXE Server Manager{% endblock %} {% block title %}Imaging Progress - PXE Server Manager{% endblock %}
{% block extra_head %} {% block extra_head %}
<meta http-equiv="refresh" content="5"> {# JS-driven refresh instead of meta http-equiv so we can cancel it while a #}
{# LAPS-password QR is showing (otherwise the 5s reload wipes the in-page #}
{# state every cycle). #}
<script>
function scheduleImagingReload() {
window._imagingReloadTimer = setTimeout(function() { location.reload(); }, 5000);
}
function cancelImagingReload() {
if (window._imagingReloadTimer) { clearTimeout(window._imagingReloadTimer); window._imagingReloadTimer = null; }
}
window.addEventListener('DOMContentLoaded', scheduleImagingReload);
</script>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@@ -240,6 +251,7 @@ function renderLapsQR(card) {
container.innerHTML = qr.createImgTag(cellSize, 4); container.innerHTML = qr.createImgTag(cellSize, 4);
makeBtn.style.display = 'none'; makeBtn.style.display = 'none';
clearBtn.style.display = ''; clearBtn.style.display = '';
cancelImagingReload(); // freeze page refresh while QR is visible
var remaining = 60; var remaining = 60;
timerEl.textContent = '(auto-clears in ' + remaining + 's)'; timerEl.textContent = '(auto-clears in ' + remaining + 's)';
if (card._lapsTimer) clearInterval(card._lapsTimer); if (card._lapsTimer) clearInterval(card._lapsTimer);
@@ -264,6 +276,10 @@ function clearLapsQR(card) {
timerEl.textContent = ''; timerEl.textContent = '';
makeBtn.style.display = ''; makeBtn.style.display = '';
clearBtn.style.display = 'none'; clearBtn.style.display = 'none';
// Resume page refresh now that no QR is showing on any card.
if (!document.querySelector('.laps-qr-container img')) {
scheduleImagingReload();
}
} }
document.addEventListener('click', function(e) { document.addEventListener('click', function(e) {
var card; var card;