feat: Integration von CGI-Platzhaltern für digitale Ausgänge (DASx, DANx)
- Platzhalter in da.js auf neue Struktur (DAS1–DAS4, DAN1–DAN4) umgestellt - fetchDigitalOutputsService liest Werte dynamisch über da.js vom CPL-Webserver - Schreibvorgänge via window.location.href mit CGI-Parametern (DASx=, DANx=) - Umschaltlogik zwischen Entwicklungs- und Produktionsmodus eingebaut - Modal-Speichern aktualisiert sowohl Status als auch Bezeichnung per CGI - Unterstützung für lokale Mockdaten über API bleibt bestehen
This commit is contained in:
@@ -14,6 +14,7 @@ export default function DigitalOutputsWidget({ openOutputModal }) {
|
||||
const digitalOutputs = useSelector(
|
||||
(state: RootState) => state.digitalOutputsSlice.outputs
|
||||
);
|
||||
const isCPL = process.env.NEXT_PUBLIC_NODE_ENV === "production";
|
||||
|
||||
const handleToggle = async (id: number) => {
|
||||
const updatedOutputs = digitalOutputs.map((output) =>
|
||||
@@ -23,14 +24,21 @@ export default function DigitalOutputsWidget({ openOutputModal }) {
|
||||
dispatch(setDigitalOutputs(updatedOutputs));
|
||||
|
||||
try {
|
||||
await fetch("/api/cpl/updateDigitalOutputs", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ outputs: updatedOutputs }),
|
||||
});
|
||||
console.log("✅ Status gespeichert für Ausgang", id);
|
||||
if (isCPL) {
|
||||
window.location.href = `/CPL?dummy.htm&DAS${id}=${
|
||||
updatedOutputs[id - 1].status ? 1 : 0
|
||||
}`;
|
||||
} else {
|
||||
await fetch("/api/cpl/updateDigitalOutputs", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ outputs: updatedOutputs }),
|
||||
});
|
||||
}
|
||||
|
||||
console.log("✅ Ausgang aktualisiert:", id);
|
||||
} catch (error) {
|
||||
console.error("❌ Fehler beim Speichern:", error);
|
||||
console.error("❌ Fehler beim Schreiben:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user