diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index f4b84ed..56ab31e 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -852,18 +852,44 @@ $style = @' async function triggerInstall() { - for (const t of tasks) { - const cb = document.getElementById(t.id); - if (cb && cb.checked) { - try { - await fetch(t.handler, { method: "GET" }); - } catch (e) { - console.error(`Error running ${t.label}:`, e); - } - } + for (const t of tasks) { + const cb = document.getElementById(t.id); + if (!cb || !cb.checked) continue; + + // special-case DattoRMM: POST JSON with sub-options + site info + if (t.id === 'installDattoRMM') { + const checkedValues = Array.from( + document.querySelectorAll('.sub-option-installDattoRMM') + ) + .filter(sub => sub.checked) + .map(sub => sub.value); + + const dropdown = document.getElementById('dattoDropdown'); + const UID = dropdown.value; + const Name = dropdown.options[dropdown.selectedIndex].text; + + try { + await fetch('/installDattoRMM', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ checkedValues, UID, Name }) + }); + } catch (e) { + console.error(`Error running ${t.label}:`, e); + } + + } else { + // everything else remains a simple GET + try { + await fetch(t.handler, { method: 'GET' }); + } catch (e) { + console.error(`Error running ${t.label}:`, e); + } } + } } + // ======================================================================= // Shutdown Handler // =======================================================================