Update TGBeta.ps1
This commit is contained in:
35
TGBeta.ps1
35
TGBeta.ps1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user