From 70c14a0ec2319d27668db1be22d8ad6972bfa6a6 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Wed, 9 Jul 2025 17:16:19 -0400 Subject: [PATCH] attempted to install-dattormm --- StackMonkey.ps1 | 54 +++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index 22d637d..b89a4d6 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -870,53 +870,49 @@ catch (e) { } } - - - - - async function triggerInstall() { - // disable the button so you can't double-click while work is in flight const runBtn = document.querySelector('.run-button'); runBtn.disabled = true; try { + // 1. If installDattoRMM is selected, run it first + const dattoCB = document.getElementById('installDattoRMM'); + if (dattoCB && dattoCB.checked) { + 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 + }) + }); + } + + // 2. Now run everything else for (const t of tasks) { + if (t.id === 'installDattoRMM') continue; + const cb = document.getElementById(t.id); if (!cb || !cb.checked) continue; - 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' }); - } + 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 // =======================================================================