set the run button to gray out until script is done

This commit is contained in:
2025-05-29 01:48:46 -04:00
parent e3f48831ce
commit 17dcaaa097

View File

@@ -856,12 +856,17 @@ $style = @'
const runBtn = document.querySelector('.run-button');
async function triggerInstall() { async function triggerInstall() {
// disable the button so you cant doubleclick while work is in flight
runBtn.disabled = true;
try {
for (const t of tasks) { for (const t of tasks) {
const cb = document.getElementById(t.id); const cb = document.getElementById(t.id);
if (!cb || !cb.checked) continue; if (!cb || !cb.checked) continue;
// special case: DattoRMM is POST
if (t.id === 'installDattoRMM') { if (t.id === 'installDattoRMM') {
const sub = Array.from( const sub = Array.from(
document.querySelectorAll('.sub-option-installDattoRMM:checked') document.querySelectorAll('.sub-option-installDattoRMM:checked')
@@ -879,13 +884,18 @@ $style = @'
Name: name Name: name
}) })
}); });
} } else {
else {
// your existing GET for everyone else
await fetch(t.handler, { method: 'GET' }); await fetch(t.handler, { method: 'GET' });
} }
} }
} catch (e) {
console.error('Error during triggerInstall:', e);
} finally {
// always re-enable, even if an error occurred
runBtn.disabled = false;
} }
}