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:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user