attempt to fix dattoRMM sub items

This commit is contained in:
2025-05-26 21:17:01 -04:00
parent a995b16e62
commit ac207c2e7c

View File

@@ -500,40 +500,50 @@ $style = @'
});
// =======================================================================
// Fetch Sites Handler
// =======================================================================
async function fetchSites() {
const pwd = document.getElementById("Password").value;
if (!pwd) { alert("Please enter the password."); return; }
// =======================================================================
// Fetch Sites Handler
// =======================================================================
async function fetchSites() {
const pwd = document.getElementById("Password").value;
if (!pwd) {
alert("Please enter the password.");
return;
}
try {
const dropdown = document.getElementById("dattoDropdown");
dropdown.innerHTML = '<option disabled selected>Loading sites...</option>';
try {
const resp = await fetch("/getpw", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ password: pwd })
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ password: pwd })
});
if (!resp.ok) throw("HTTP " + resp.status);
const sites = await resp.json();
const dd = document.getElementById("dattoDropdown");
dd.innerHTML = ""; // clear old
sites.forEach(s => {
const opt = document.createElement("option");
opt.value = s.UID;
opt.text = s.Name;
dd.appendChild(opt);
dropdown.innerHTML = ''; // clear the loading message
sites.forEach(site => {
const option = document.createElement("option");
option.value = site.UID;
option.textContent = site.Name;
dropdown.appendChild(option);
});
document.getElementById("dattoRmmContainer").style.display = "block";
}
catch (e) {
}
catch (e) {
console.error(e);
dropdown.innerHTML = '<option disabled selected>Error loading sites</option>';
alert("Failed to fetch sites. Check password and try again.");
}
}
}
async function triggerInstall() {
for (const t of tasks) {
const cb = document.getElementById(t.id);
@@ -602,17 +612,13 @@ $htmlTemplate = @"
</div>
<!-- 1) password & fetch button -->
<div id="PasswordContainer" style="margin-bottom:1em;">
<label for="Password">Password:</label>
<input type="password" id="Password" placeholder="Enter password" />
<button onclick="fetchSites()">Fetch Sites</button>
</div>
<!-- 2) Datto RMM dropdown (populated after fetch) -->
<!-- 2) Datto RMM dropdown (populated after fetch) -->
<div id="dattoRmmContainer" style="display:none; margin-bottom:1em;">
<label for="dattoDropdown">Select Datto Site:</label>
<select id="dattoDropdown"></select>
<select id="dattoDropdown">
<option disabled selected hidden>Select a site...</option>
</select>
</div>
<div id="offboardTab" class="tab-content">