Update SVSTaskGate.ps1

This commit is contained in:
2025-01-05 01:33:35 -05:00
parent 4269f8714a
commit a7125417d3

View File

@@ -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 = '<option value="">Fetching sites failed</option>';
appendLog('Error:' + error.message, "red");
appendLog('Error: ' + error.message, "red");
}
}
function triggerInstall() {
const dropdown = document.getElementById('dattoRmmDropdown');
const UID = dropdown.options[dropdown.selectedIndex].value;