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