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:
@@ -2,7 +2,18 @@
|
||||
{% block title %}Imaging Progress - PXE Server Manager{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
|
||||
{% block content %}
|
||||
@@ -240,6 +251,7 @@ function renderLapsQR(card) {
|
||||
container.innerHTML = qr.createImgTag(cellSize, 4);
|
||||
makeBtn.style.display = 'none';
|
||||
clearBtn.style.display = '';
|
||||
cancelImagingReload(); // freeze page refresh while QR is visible
|
||||
var remaining = 60;
|
||||
timerEl.textContent = '(auto-clears in ' + remaining + 's)';
|
||||
if (card._lapsTimer) clearInterval(card._lapsTimer);
|
||||
@@ -264,6 +276,10 @@ function clearLapsQR(card) {
|
||||
timerEl.textContent = '';
|
||||
makeBtn.style.display = '';
|
||||
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) {
|
||||
var card;
|
||||
|
||||
Reference in New Issue
Block a user