feat: Verwende fetch statt window.location.href für Digitalausgang-Schalteraktionen

This commit is contained in:
ISA
2025-07-08 10:09:46 +02:00
parent 2af99f2740
commit 976f3126f2
8 changed files with 41 additions and 20 deletions

View File

@@ -32,9 +32,25 @@ export default function DigitalOutputsWidget({
try {
if (isCPL) {
window.location.href = `/CPL?digitalOutputs.html&DAS0${id}=${
updatedOutputs[id - 1].status ? 1 : 0
}`;
// Statt redirect:
// window.location.href = `/CPL?...`;
// Verwende fetch:
fetch(
`/CPL?digitalOutputs.html&DAS0${id}=${
updatedOutputs[id - 1].status ? 1 : 0
}`,
{
method: "GET",
}
)
.then((res) => {
if (!res.ok) throw new Error("Fehler beim Schalten");
// Optional: Feedback anzeigen
})
.catch((err) => {
console.error("CPL Fehler:", err);
});
} else {
await fetch("/api/cpl/updateDigitalOutputsHandler", {
method: "POST",