Update StackMonkey.ps1
This commit is contained in:
119
StackMonkey.ps1
119
StackMonkey.ps1
@@ -893,72 +893,49 @@ catch (e) {
|
|||||||
|
|
||||||
async function triggerInstall() {
|
async function triggerInstall() {
|
||||||
const runBtn = document.querySelector('.run-button');
|
const runBtn = document.querySelector('.run-button');
|
||||||
if (runBtn) runBtn.disabled = true;
|
runBtn.disabled = true;
|
||||||
|
|
||||||
const statusBox = document.getElementById('status-box');
|
|
||||||
if (statusBox) statusBox.innerHTML = '';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const allTasks = typeof tasks !== 'undefined' ? tasks : [];
|
// 1. Run DattoRMM first
|
||||||
const checkedTasks = allTasks.filter(t => {
|
|
||||||
const cb = document.getElementById(t.id);
|
|
||||||
return cb && cb.checked;
|
|
||||||
});
|
|
||||||
|
|
||||||
setTotalTaskCount(checkedTasks.length);
|
|
||||||
|
|
||||||
// Step 1: Run DattoRMM if selected
|
|
||||||
const dattoCB = document.getElementById('installDattoRMM');
|
const dattoCB = document.getElementById('installDattoRMM');
|
||||||
if (dattoCB && dattoCB.checked) {
|
if (dattoCB && dattoCB.checked) {
|
||||||
try {
|
|
||||||
const sub = Array.from(
|
const sub = Array.from(
|
||||||
document.querySelectorAll('.sub-option-installDattoRMM:checked')
|
document.querySelectorAll('.sub-option-installDattoRMM:checked')
|
||||||
).map(x => x.value);
|
).map(x => x.value);
|
||||||
const dropdown = document.getElementById('dattoDropdown');
|
const dropdown = document.getElementById('dattoDropdown');
|
||||||
const uid = dropdown?.value;
|
const uid = dropdown.value;
|
||||||
const name = dropdown?.selectedOptions?.[0]?.text || 'Datto';
|
const name = dropdown.selectedOptions[0].text;
|
||||||
|
|
||||||
await fetch('/installDattoRMM', {
|
await fetch('/installDattoRMM', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
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);
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2: Run SVSMSP module install
|
// 2. Run SVSMSP module install second
|
||||||
const svsCB = document.getElementById('installSVSMSPModule');
|
const svsCB = document.getElementById('installSVSMSPModule');
|
||||||
if (svsCB && svsCB.checked) {
|
if (svsCB && svsCB.checked) {
|
||||||
try {
|
|
||||||
await fetch('/installSVSMSPModule', { method: 'GET' });
|
await fetch('/installSVSMSPModule', { method: 'GET' });
|
||||||
logProgress('Install SVSMSP Module', true);
|
|
||||||
} catch (e) {
|
|
||||||
logProgress('Install SVSMSP Module', false);
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3: Remaining tasks
|
// 3. Run the remaining tasks
|
||||||
for (const t of checkedTasks) {
|
for (const t of tasks) {
|
||||||
if (['installDattoRMM', 'installSVSMSPModule'].includes(t.id)) continue;
|
if (['installDattoRMM', 'installSVSMSPModule'].includes(t.id)) continue;
|
||||||
|
|
||||||
try {
|
const cb = document.getElementById(t.id);
|
||||||
|
if (!cb || !cb.checked) continue;
|
||||||
|
|
||||||
await fetch(t.handler, { method: 'GET' });
|
await fetch(t.handler, { method: 'GET' });
|
||||||
logProgress(t.label || t.id, true);
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logProgress(t.label || t.id, false);
|
console.error('Error during triggerInstall:', e);
|
||||||
console.error(`Error running ${t.id}:`, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (mainErr) {
|
|
||||||
console.error('triggerInstall failed:', mainErr);
|
|
||||||
} finally {
|
} finally {
|
||||||
if (runBtn) runBtn.disabled = false;
|
runBtn.disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1042,66 +1019,6 @@ window.addEventListener('beforeunload', () => {
|
|||||||
fetch('/quit', { method: 'GET', keepalive: true });
|
fetch('/quit', { method: 'GET', keepalive: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
<script>
|
|
||||||
let completedTasks = 0;
|
|
||||||
let totalTasks = 0;
|
|
||||||
|
|
||||||
function setTotalTaskCount(count) {
|
|
||||||
totalTasks = count;
|
|
||||||
completedTasks = 0;
|
|
||||||
updateTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
function logProgress(label, isSuccess) {
|
|
||||||
const statusBox = document.getElementById('status-box');
|
|
||||||
completedTasks++;
|
|
||||||
updateTitle();
|
|
||||||
|
|
||||||
const msg = isSuccess
|
|
||||||
? `✅ ${completedTasks}/${totalTasks} done: ${label}`
|
|
||||||
: `❌ ${completedTasks}/${totalTasks} failed: ${label}`;
|
|
||||||
|
|
||||||
const div = document.createElement('div');
|
|
||||||
div.style.color = isSuccess ? 'lime' : 'red';
|
|
||||||
div.textContent = msg;
|
|
||||||
statusBox.appendChild(div);
|
|
||||||
|
|
||||||
if (completedTasks === totalTasks) {
|
|
||||||
const finalMsg = document.createElement('div');
|
|
||||||
finalMsg.style.marginTop = '10px';
|
|
||||||
finalMsg.innerHTML = `<strong>✅ All tasks complete (${completedTasks}/${totalTasks})</strong>`;
|
|
||||||
statusBox.appendChild(finalMsg);
|
|
||||||
|
|
||||||
document.title = `✅ ScriptMonkey - Complete (${completedTasks}/${totalTasks})`;
|
|
||||||
|
|
||||||
// Optional: Play sound
|
|
||||||
const sound = new Audio('data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAESsAACJWAAACABAAZGF0YQAAAAA=');
|
|
||||||
sound.play().catch(() => {});
|
|
||||||
|
|
||||||
// Optional: Flash title
|
|
||||||
flashTitle(`✅ ScriptMonkey - Complete (${completedTasks}/${totalTasks})`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateTitle() {
|
|
||||||
document.title = `ScriptMonkey - ${completedTasks}/${totalTasks} Done`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function flashTitle(finalTitle) {
|
|
||||||
let flashes = 0;
|
|
||||||
const interval = setInterval(() => {
|
|
||||||
document.title = (document.title === '') ? finalTitle : '';
|
|
||||||
flashes++;
|
|
||||||
if (flashes >= 10) {
|
|
||||||
clearInterval(interval);
|
|
||||||
document.title = finalTitle;
|
|
||||||
}
|
|
||||||
}, 800);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
'@
|
'@
|
||||||
|
|||||||
Reference in New Issue
Block a user