This commit is contained in:
@@ -146,6 +146,28 @@
|
||||
plcMode: el("mapIoPlcMode"),
|
||||
};
|
||||
|
||||
async function refreshMapIoModuleList() {
|
||||
const listEl = document.getElementById("mapIoModuleList");
|
||||
if (!listEl) return;
|
||||
let modules = [];
|
||||
try {
|
||||
if (window.IoModulesCatalog?.refresh) {
|
||||
modules = await window.IoModulesCatalog.refresh();
|
||||
} else {
|
||||
const res = await fetch("/api/io_modules", { credentials: "include" });
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
modules = Array.isArray(data.io_modules) ? data.io_modules : [];
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
modules = [];
|
||||
}
|
||||
listEl.innerHTML = modules
|
||||
.map((m) => `<option value="${String(m.name || "").replace(/"/g, """)}"></option>`)
|
||||
.join("");
|
||||
}
|
||||
|
||||
/** Off-screen base scan layer (map_base.png — eraser edits this). */
|
||||
let baseCanvasEl = null;
|
||||
function getBaseCanvas() {
|
||||
@@ -1177,13 +1199,15 @@
|
||||
}
|
||||
if (zone.type === obj.TYPES.io) {
|
||||
const s = adv.normalizeIoSettings(zone);
|
||||
if (ioFields.module) ioFields.module.value = s.io_module || "";
|
||||
if (ioFields.plcRegister) {
|
||||
ioFields.plcRegister.value = s.plc_register == null ? "" : String(s.plc_register);
|
||||
}
|
||||
if (ioFields.plcValue) ioFields.plcValue.value = s.plc_value == null ? "" : String(s.plc_value);
|
||||
if (ioFields.plcMode) ioFields.plcMode.value = s.plc_mode || "set";
|
||||
ioDialogEl?.showModal();
|
||||
void refreshMapIoModuleList().then(() => {
|
||||
if (ioFields.module) ioFields.module.value = s.io_module || "";
|
||||
if (ioFields.plcRegister) {
|
||||
ioFields.plcRegister.value = s.plc_register == null ? "" : String(s.plc_register);
|
||||
}
|
||||
if (ioFields.plcValue) ioFields.plcValue.value = s.plc_value == null ? "" : String(s.plc_value);
|
||||
if (ioFields.plcMode) ioFields.plcMode.value = s.plc_mode || "set";
|
||||
ioDialogEl?.showModal();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user