Update samy.js

This commit is contained in:
2025-12-08 16:20:55 -05:00
parent 33259348c7
commit e5da914b51

13
samy.js
View File

@@ -265,7 +265,7 @@ async function fetchSites() {
// ======================================================================= // =======================================================================
let allPrinters = []; let allPrinters = [];
// GET /getprinters with password from Devices tab (sent via SAMYPW header) // POST /getprinters with password from Devices tab
async function fetchPrinters() { async function fetchPrinters() {
const pwdInput = document.getElementById("PrinterPassword"); const pwdInput = document.getElementById("PrinterPassword");
const pwd = pwdInput?.value; const pwd = pwdInput?.value;
@@ -290,8 +290,9 @@ async function fetchPrinters() {
try { try {
const resp = await fetch("/getprinters", { const resp = await fetch("/getprinters", {
method: "GET", method: "POST",
headers: { SAMYPW: pwd }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ password: pwd }),
}); });
if (!resp.ok) throw new Error("HTTP " + resp.status); if (!resp.ok) throw new Error("HTTP " + resp.status);
@@ -441,10 +442,8 @@ async function installSelectedPrinters() {
const result = await resp.json().catch(() => null); const result = await resp.json().catch(() => null);
alert( console.log("Printer install result:", result);
`Requested installation for ${selected.length} printer(s).` +
(result && result.Message ? "\n" + result.Message : "")
);
} catch (e) { } catch (e) {
console.error("installSelectedPrinters error:", e); console.error("installSelectedPrinters error:", e);
alert("Failed to trigger printer install."); alert("Failed to trigger printer install.");