feat(dev): API zum Umschalten der TDR-Aktivierung in Mock-Datei eingebunden

- Neuer Endpunkt: /api/cpl/updateTdrSettingsDataAPIHandler
- Aktualisiert win_tdrActive[slot] in Mockdatei
- Entwicklung vollständig ohne Hardware möglich
This commit is contained in:
ISA
2025-04-30 15:05:19 +02:00
parent f59fd0d773
commit 40777f212b
3 changed files with 76 additions and 15 deletions

View File

@@ -60,18 +60,34 @@ export default function TdrEinstellung({ slot }: Props) {
const newState = !tdrActive;
setTdrActive(newState);
const url = `${
window.location.origin
}/CPL?/kabelueberwachung.html&KTX${slot}=${newState ? 1 : 0}`;
fetch(url)
.then((res) => {
if (!res.ok) throw new Error("TDR-Befehl fehlgeschlagen");
console.log("TDR aktiviert/deaktiviert:", res.status);
})
.catch((err) => {
console.error("Fehler beim TDR-Befehl:", err);
alert("Fehler beim Umschalten der TDR-Funktion.");
});
const isDev = window.location.hostname === "localhost";
const slotParam = `KTX${slot}=${newState ? 1 : 0}`;
if (isDev) {
fetch(
`/api/cpl/updateTdrSettingsDataAPIHandler?slot=${slot}&value=${
newState ? 1 : 0
}`
)
.then((res) => res.json())
.then((data) => {
console.log("Mock-Status aktualisiert:", data);
})
.catch((err) => {
console.error("Fehler in DEV-API:", err);
});
} else {
const url = `${window.location.origin}/CPL?/kabelueberwachung.html&${slotParam}`;
fetch(url)
.then((res) => {
if (!res.ok) throw new Error("TDR-Befehl fehlgeschlagen");
console.log("TDR aktiviert/deaktiviert:", res.status);
})
.catch((err) => {
console.error("Fehler beim TDR-Befehl:", err);
alert("Fehler beim Umschalten der TDR-Funktion.");
});
}
};
return (