From 24b98e580798be6c14ce7953b6ff3c211ef7ebfc Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Sat, 1 Feb 2025 20:14:21 -0500 Subject: [PATCH] Update TGBeta.ps1 --- TGBeta.ps1 | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/TGBeta.ps1 b/TGBeta.ps1 index 2871083..cbf6520 100644 --- a/TGBeta.ps1 +++ b/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 = ''; + 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;