Update TGBeta.ps1

This commit is contained in:
2025-02-01 20:14:21 -05:00
parent 55cb002ec3
commit 24b98e5807

View File

@@ -788,6 +788,41 @@ function GetHtmlContent {
const n8nPasswordInput = document.getElementById('n8nPassword');
const fetchSitesButton = document.getElementById('fetchSitesButton');
async function fetchSites() {
const password = n8nPasswordInput.value;
const dropdown = document.getElementById('dattoRmmDropdown');
if (!password) {
appendLog("Please enter the n8n password.", "red");
return;
}
try {
appendLog("Fetching sites...", "yellow");
const response = await fetch('/getn8npw', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ password })
});
if (!response.ok) {
throw new Error('Failed to fetch sites. Please try again.');
}
const sites = await response.json();
dropdown.innerHTML = '';
sites.forEach(site => {
const option = document.createElement('option');
option.value = site.UID;
option.textContent = site.Name;
dropdown.appendChild(option);
});
appendLog("Sites fetched successfully, please select a site!", "green");
} catch (error) {
dropdown.innerHTML = '<option value="">Fetching sites failed</option>';
appendLog("Error: " + error.message, "red");
}
}
// Update the disabled state based on password length (now 12 characters)
n8nPasswordInput.addEventListener('input', () => {
fetchSitesButton.disabled = n8nPasswordInput.value.length < 12;