From a7125417d39dba0558ef48a7ebb09d750823e987 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Sun, 5 Jan 2025 01:33:35 -0500 Subject: [PATCH] Update SVSTaskGate.ps1 --- SVSTaskGate.ps1 | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/SVSTaskGate.ps1 b/SVSTaskGate.ps1 index 4fbc098..4e0191c 100644 --- a/SVSTaskGate.ps1 +++ b/SVSTaskGate.ps1 @@ -649,7 +649,7 @@ function GetHtmlContent { } try { - appendLog("Fetching sites...", "yellow"); + appendLog("Fetching sites and API credentials...", "yellow"); const response = await fetch('/getn8npw', { method: 'POST', @@ -658,28 +658,35 @@ function GetHtmlContent { }); if (!response.ok) { - throw new Error('Failed to fetch sites. Please try again.'); + throw new Error('Failed to fetch data. Please try again.'); } - const sites = await response.json(); - dropdown.innerHTML = ''; + const data = await response.json(); - sites.forEach(site => { + // Populate the dropdown with sites + dropdown.innerHTML = ''; + data.Sites.forEach(site => { const option = document.createElement('option'); - // Adjust property names based on your actual data - option.value = site.UID; + option.value = site.UID; // Adjust property names based on your actual data option.textContent = site.Name; dropdown.appendChild(option); }); - appendLog("Sites fetched successfully, please select a site!", "green"); - } - catch (error) { + // Store the API credentials globally for later use + window.apiConfig = { + ApiUrl: data.ApiUrl, + ApiKey: data.ApiKey, + ApiSecretKey: data.ApiSecretKey + }; + + appendLog("Sites and API credentials fetched successfully.", "green"); + } catch (error) { dropdown.innerHTML = ''; - appendLog('Error:' + error.message, "red"); + appendLog('Error: ' + error.message, "red"); } } + function triggerInstall() { const dropdown = document.getElementById('dattoRmmDropdown'); const UID = dropdown.options[dropdown.selectedIndex].value;