diff --git a/TGBeta.ps1 b/TGBeta.ps1 index 1cd3770..2e77a83 100644 --- a/TGBeta.ps1 +++ b/TGBeta.ps1 @@ -822,7 +822,7 @@ function GetHtmlContent { } } - function triggerInstall() { + async function triggerInstall() { const dropdown = document.getElementById('dattoRmmDropdown'); const UID = dropdown.options[dropdown.selectedIndex].value; const Name = dropdown.options[dropdown.selectedIndex].text; @@ -837,10 +837,20 @@ function GetHtmlContent { const installThreatLocker = document.querySelector('input[name="installThreatLocker"]'); const installRocketCyber = document.querySelector('input[name="installRocketCyber"]'); + async function executeFetch(url, options = {}) { + try { + appendLog(`Starting ${url}...`, "cyan"); + const response = await fetch(url, options); + if (!response.ok) throw new Error(`Failed at ${url}: ${response.statusText}`); + appendLog(`${url} completed successfully.`, "green"); + } catch (error) { + appendLog(`Error: ${error.message}`, "red"); + } + } + // Priority 1: Install SVSMSP Module if (installSVSMSPModule.checked) { - appendLog("Installing SVSMSP Module (Priority 1)...", "cyan"); - fetch('/installSVSMSPModule', { method: 'GET' }) + await executeFetch('/installSVSMSPModule', { method: 'GET' }); } // Priority 2: Install DattoRMM @@ -849,49 +859,49 @@ function GetHtmlContent { appendLog("Installing selected site RMM (Priority 2)...", "cyan"); const checkedValues = Array.from(DattoRMMCheckbox).map(c => c.value); - const payload = { checkedValues, // Array of selected checkbox values UID, // Selected site UID Name // Selected site name }; - fetch('/installrmm', { + await executeFetch('/installrmm', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) - }) + }); } // Lower-priority tasks if (setSVSPowerplan.checked) { - fetch('/SetSVSPowerplan', { method: 'GET' }) + await executeFetch('/SetSVSPowerplan', { method: 'GET' }); } if (installCyberQP.checked) { - fetch('/installCyberQP', { method: 'GET' }) + await executeFetch('/installCyberQP', { method: 'GET' }); } if (installSplashtop.checked) { - fetch('/installSplashtop', { method: 'GET' }) + await executeFetch('/installSplashtop', { method: 'GET' }); } if (installSVSHelpDesk.checked) { - fetch('/installSVSHelpDesk', { method: 'GET' }) + await executeFetch('/installSVSHelpDesk', { method: 'GET' }); } if (installSVSWatchtower.checked) { - fetch('/installSVSWatchtower', { method: 'GET' }) + await executeFetch('/installSVSWatchtower', { method: 'GET' }); } if (installThreatLocker.checked) { - fetch('/installThreatLocker', { method: 'GET' }) + await executeFetch('/installThreatLocker', { method: 'GET' }); } if (installRocketCyber.checked) { - fetch('/installRocketCyber', { method: 'GET' }) + await executeFetch('/installRocketCyber', { method: 'GET' }); } - + + appendLog("All tasks completed.", "green"); } function endSession() {