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,39 +856,49 @@ $style = @'
const runBtn = document.querySelector('.run-button');
async function triggerInstall() {
for (const t of tasks) {
const cb = document.getElementById(t.id);
if (!cb || !cb.checked) continue;
// disable the button so you cant doubleclick while work is in flight
runBtn.disabled = true;
// special case: DattoRMM is POST
if (t.id === 'installDattoRMM') {
const sub = Array.from(
document.querySelectorAll('.sub-option-installDattoRMM:checked')
).map(x=>x.value);
const dropdown = document.getElementById('dattoDropdown');
const uid = dropdown.value;
const name = dropdown.selectedOptions[0].text;
try {
for (const t of tasks) {
const cb = document.getElementById(t.id);
if (!cb || !cb.checked) continue;
await fetch('/installDattoRMM', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
checkedValues: sub,
UID: uid,
Name: name
})
});
}
else {
// your existing GET for everyone else
await fetch(t.handler, { method: 'GET' });
if (t.id === 'installDattoRMM') {
const sub = Array.from(
document.querySelectorAll('.sub-option-installDattoRMM:checked')
).map(x => x.value);
const dropdown = document.getElementById('dattoDropdown');
const uid = dropdown.value;
const name = dropdown.selectedOptions[0].text;
await fetch('/installDattoRMM', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
checkedValues: sub,
UID: uid,
Name: name
})
});
} else {
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;
}
}
// =======================================================================
// Shutdown Handler
// =======================================================================