From a3294d79db65923dd97e281d2c26f6168d3988df Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Fri, 11 Jul 2025 09:24:30 -0400 Subject: [PATCH] added task count --- StackMonkey.ps1 | 123 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 105 insertions(+), 18 deletions(-) diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index f3da843..3b1286f 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -895,32 +895,54 @@ async function triggerInstall() { const runBtn = document.querySelector('.run-button'); runBtn.disabled = true; + const statusBox = document.getElementById('status-box'); + statusBox.innerHTML = ''; + try { + // Count how many tasks are checked + const taskCount = tasks.filter(t => { + const cb = document.getElementById(t.id); + return cb && cb.checked; + }).length; + setTotalTaskCount(taskCount); + // 1. Run DattoRMM 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; + try { + 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 - }) - }); + await fetch('/installDattoRMM', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + checkedValues: sub, + UID: uid, + Name: name + }) + }); + logProgress('Install DattoRMM', true); + } catch (e) { + logProgress('Install DattoRMM', false); + console.error(e); + } } // 2. Run SVSMSP module install second const svsCB = document.getElementById('installSVSMSPModule'); if (svsCB && svsCB.checked) { - await fetch('/installSVSMSPModule', { method: 'GET' }); + try { + await fetch('/installSVSMSPModule', { method: 'GET' }); + logProgress('Install SVSMSP Module', true); + } catch (e) { + logProgress('Install SVSMSP Module', false); + console.error(e); + } } // 3. Run the remaining tasks @@ -930,7 +952,13 @@ async function triggerInstall() { const cb = document.getElementById(t.id); if (!cb || !cb.checked) continue; - await fetch(t.handler, { method: 'GET' }); + try { + await fetch(t.handler, { method: 'GET' }); + logProgress(t.label || t.id, true); + } catch (e) { + logProgress(t.label || t.id, false); + console.error(`Error running ${t.id}:`, e); + } } } catch (e) { console.error('Error during triggerInstall:', e); @@ -940,7 +968,6 @@ async function triggerInstall() { } - // ======================================================================= // Shutdown Handler // ======================================================================= @@ -1019,6 +1046,66 @@ window.addEventListener('beforeunload', () => { fetch('/quit', { method: 'GET', keepalive: true }); }); + + + + '@