diff --git a/samy.js b/samy.js index 6fa8f98..9400e87 100644 --- a/samy.js +++ b/samy.js @@ -457,23 +457,28 @@ async function triggerInstall() { // 1. DattoRMM first const dattoCB = document.getElementById("installDattoRMM"); if (dattoCB && dattoCB.checked) { - try { - const sub = Array.from( - document.querySelectorAll(".sub-option-installDattoRMM:checked") - ).map((x) => x.value); - const dropdown = document.getElementById("dattoDropdown"); - const uid = dropdown?.value; - const name = dropdown?.selectedOptions?.[0]?.text || "Datto"; + const sub = Array.from( + document.querySelectorAll(".sub-option-installDattoRMM:checked") + ).map((x) => x.value); + const dropdown = document.getElementById("dattoDropdown"); + const uid = dropdown?.value; + const name = dropdown?.selectedOptions?.[0]?.text || "Datto"; - await fetch("/installDattoRMM", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ checkedValues: sub, UID: uid, Name: name }), - }); - logProgress("Install DattoRMM", true); - } catch (e) { - logProgress("Install DattoRMM", false); - console.error(e); + if (!uid) { + alert("Please select a Datto RMM site before running."); + logProgress("Install DattoRMM (no site selected)", false); + } else { + try { + await fetch("/installDattoRMM", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ checkedValues: sub, UID: uid, Name: name }), + }); + logProgress("Install DattoRMM", true); + } catch (e) { + logProgress("Install DattoRMM", false); + console.error(e); + } } }