diff --git a/TGBeta.ps1 b/TGBeta.ps1 index 7a07260..dca3d88 100644 --- a/TGBeta.ps1 +++ b/TGBeta.ps1 @@ -822,64 +822,77 @@ function GetHtmlContent { } } - async function triggerInstall() { - const dropdown = document.getElementById('dattoRmmDropdown'); - const UID = dropdown.options[dropdown.selectedIndex]?.value || null; - const Name = dropdown.options[dropdown.selectedIndex]?.text || null; + function triggerInstall() { + const dropdown = document.getElementById('dattoRmmDropdown'); + const UID = dropdown.options[dropdown.selectedIndex]?.value || null; + const Name = dropdown.options[dropdown.selectedIndex]?.text || null; - const tasks = []; + const setSVSPowerplan = document.querySelector('input[name="setSVSPowerplan"]'); + const installSVSMSPModule = document.querySelector('input[name="installSVSMSPModule"]'); + const installDattoRMM = document.querySelector('input[name="installDattoRMM"]'); + const installCyberQP = document.querySelector('input[name="installCyberQP"]'); + const installSplashtop = document.querySelector('input[name="installSplashtop"]'); + const installSVSHelpDesk = document.querySelector('input[name="installSVSHelpDesk"]'); + const installSVSWatchtower = document.querySelector('input[name="installSVSWatchtower"]'); + const installThreatLocker = document.querySelector('input[name="installThreatLocker"]'); + const installRocketCyber = document.querySelector('input[name="installRocketCyber"]'); - if (document.querySelector('input[name="installSVSMSPModule"]').checked) { - tasks.push({ name: "installSVSMSPModule", priority: 1 }); - } + // Priority 1: Install SVSMSP Module + if (installSVSMSPModule.checked) { + appendLog("Installing SVSMSP Module (Priority 1)...", "cyan"); + fetch('/installSVSMSPModule', { method: 'GET' }) + } - if (document.querySelector('input[name="installDattoRMM"]').checked) { - const selectedOptions = Array.from(document.querySelectorAll('input[name="dattoRMMOption"]:checked')) - .map(option => option.value); + // Priority 2: Install DattoRMM + if (installDattoRMM.checked) { + const DattoRMMCheckbox = document.querySelectorAll('input[name="dattoRMMOption"]:checked'); + appendLog("Installing selected site RMM (Priority 2)...", "cyan"); - tasks.push({ - name: "installDattoRMM", - priority: 2, - details: { UID, Name, options: selectedOptions }, - }); - } + const checkedValues = Array.from(DattoRMMCheckbox).map(c => c.value); - if (document.querySelector('input[name="setSVSPowerplan"]').checked) { - tasks.push({ name: "setSVSPowerplan", priority: 3 }); - } + const payload = { + checkedValues, // Array of selected checkbox values + UID, // Selected site UID + Name // Selected site name + }; - if (document.querySelector('input[name="installCyberQP"]').checked) { - tasks.push({ name: "installCyberQP", priority: 4 }); - } + fetch('/installrmm', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(payload) + }) + } - if (document.querySelector('input[name="installRocketCyber"]').checked) { - tasks.push({ name: "installRocketCyber", priority: 5 }); - } + // Lower-priority tasks + if (setSVSPowerplan.checked) { + fetch('/SetSVSPowerplan', { method: 'GET' }) + } - if (document.querySelector('input[name="installThreatLocker"]').checked) { - tasks.push({ name: "installThreatLocker", priority: 6 }); - } + if (installCyberQP.checked) { + fetch('/installCyberQP', { method: 'GET' }) + } - try { - const response = await fetch('/executeTasks', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ tasks }), - }); + if (installSplashtop.checked) { + fetch('/installSplashtop', { method: 'GET' }) + } - if (!response.ok) { - throw new Error("Failed to execute tasks."); + if (installSVSHelpDesk.checked) { + fetch('/installSVSHelpDesk', { method: 'GET' }) + } + + if (installSVSWatchtower.checked) { + fetch('/installSVSWatchtower', { method: 'GET' }) + } + + if (installThreatLocker.checked) { + fetch('/installThreatLocker', { method: 'GET' }) + } + + if (installRocketCyber.checked) { + fetch('/installRocketCyber', { method: 'GET' }) + } + } - - const result = await response.json(); - console.log(result); - appendLog("All tasks completed successfully.", "green"); - } catch (error) { - console.error(error); - appendLog(`Error executing tasks: ${error.message}`, "red"); - } -} - function endSession() { appendLog("Session ended. Closing application...", "yellow"); fetch('/quit', { method: 'GET' })