Update SVSTaskGate.ps1
This commit is contained in:
@@ -649,7 +649,7 @@ function GetHtmlContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
appendLog("Fetching sites...", "yellow");
|
appendLog("Fetching sites and API credentials...", "yellow");
|
||||||
|
|
||||||
const response = await fetch('/getn8npw', {
|
const response = await fetch('/getn8npw', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -658,28 +658,35 @@ function GetHtmlContent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
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();
|
const data = await response.json();
|
||||||
dropdown.innerHTML = '';
|
|
||||||
|
|
||||||
sites.forEach(site => {
|
// Populate the dropdown with sites
|
||||||
|
dropdown.innerHTML = '';
|
||||||
|
data.Sites.forEach(site => {
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
// Adjust property names based on your actual data
|
option.value = site.UID; // Adjust property names based on your actual data
|
||||||
option.value = site.UID;
|
|
||||||
option.textContent = site.Name;
|
option.textContent = site.Name;
|
||||||
dropdown.appendChild(option);
|
dropdown.appendChild(option);
|
||||||
});
|
});
|
||||||
|
|
||||||
appendLog("Sites fetched successfully, please select a site!", "green");
|
// Store the API credentials globally for later use
|
||||||
}
|
window.apiConfig = {
|
||||||
catch (error) {
|
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>';
|
dropdown.innerHTML = '<option value="">Fetching sites failed</option>';
|
||||||
appendLog('Error:' + error.message, "red");
|
appendLog('Error: ' + error.message, "red");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function triggerInstall() {
|
function triggerInstall() {
|
||||||
const dropdown = document.getElementById('dattoRmmDropdown');
|
const dropdown = document.getElementById('dattoRmmDropdown');
|
||||||
const UID = dropdown.options[dropdown.selectedIndex].value;
|
const UID = dropdown.options[dropdown.selectedIndex].value;
|
||||||
|
|||||||
Reference in New Issue
Block a user