Update StackMonkey.ps1

This commit is contained in:
2025-07-11 09:29:18 -04:00
parent a3294d79db
commit 512fd452f0

View File

@@ -893,20 +893,21 @@ catch (e) {
async function triggerInstall() {
const runBtn = document.querySelector('.run-button');
runBtn.disabled = true;
if (runBtn) runBtn.disabled = true;
const statusBox = document.getElementById('status-box');
statusBox.innerHTML = '';
if (statusBox) statusBox.innerHTML = '';
try {
// Count how many tasks are checked
const taskCount = tasks.filter(t => {
const allTasks = typeof tasks !== 'undefined' ? tasks : [];
const checkedTasks = allTasks.filter(t => {
const cb = document.getElementById(t.id);
return cb && cb.checked;
}).length;
setTotalTaskCount(taskCount);
});
// 1. Run DattoRMM first
setTotalTaskCount(checkedTasks.length);
// Step 1: Run DattoRMM if selected
const dattoCB = document.getElementById('installDattoRMM');
if (dattoCB && dattoCB.checked) {
try {
@@ -914,18 +915,15 @@ async function triggerInstall() {
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;
const uid = dropdown?.value;
const name = dropdown?.selectedOptions?.[0]?.text || 'Datto';
await fetch('/installDattoRMM', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
checkedValues: sub,
UID: uid,
Name: name
})
body: JSON.stringify({ checkedValues: sub, UID: uid, Name: name })
});
logProgress('Install DattoRMM', true);
} catch (e) {
logProgress('Install DattoRMM', false);
@@ -933,7 +931,7 @@ async function triggerInstall() {
}
}
// 2. Run SVSMSP module install second
// Step 2: Run SVSMSP module install
const svsCB = document.getElementById('installSVSMSPModule');
if (svsCB && svsCB.checked) {
try {
@@ -945,13 +943,10 @@ async function triggerInstall() {
}
}
// 3. Run the remaining tasks
for (const t of tasks) {
// Step 3: Remaining tasks
for (const t of checkedTasks) {
if (['installDattoRMM', 'installSVSMSPModule'].includes(t.id)) continue;
const cb = document.getElementById(t.id);
if (!cb || !cb.checked) continue;
try {
await fetch(t.handler, { method: 'GET' });
logProgress(t.label || t.id, true);
@@ -960,14 +955,15 @@ async function triggerInstall() {
console.error(`Error running ${t.id}:`, e);
}
}
} catch (e) {
console.error('Error during triggerInstall:', e);
} catch (mainErr) {
console.error('triggerInstall failed:', mainErr);
} finally {
runBtn.disabled = false;
if (runBtn) runBtn.disabled = false;
}
}
// =======================================================================
// Shutdown Handler
// =======================================================================