diff --git a/components/modules/Kue705FO.jsx b/components/modules/Kue705FO.jsx index 3ccbbf2..1e5f3f0 100644 --- a/components/modules/Kue705FO.jsx +++ b/components/modules/Kue705FO.jsx @@ -38,21 +38,52 @@ function Kue705FO({ slot: slot, }; - // Die Basis-URL von der Umgebungsvariable holen const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL; - // Sende die POST-Anfrage an den Server mit der Basis-URL fetch(`${apiUrl}/CPL?Service/KUEdetailTDR.ACP`, { method: "POST", headers: { "Content-Type": "application/json", }, - body: JSON.stringify(data), // Konvertiere die Daten in JSON-Format + body: JSON.stringify(data), + }) + .then((response) => { + if (response.ok) { + console.log("POST erfolgreich gesendet für Slot", slot); + } else { + console.error("Fehler beim Senden der POST-Anfrage"); + } + }) + .catch((error) => { + console.error("Fehler:", error); + }); + }; + + const goLoop = () => { + let slot = slotIndex + 1; + + if (slot >= 32) { + return; + } + + let slotFormat = slot < 10 ? `0${slot}` : `${slot}`; + const data = { + [`KS_${slotFormat}`]: 1, + slot: slot, + }; + + const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL; + + fetch(`${apiUrl}/CPL?Service/KUEdetail.HTML`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(data), }) .then((response) => { if (response.ok) { console.log("POST erfolgreich gesendet für Slot", slot); - // Hier kannst du zusätzliche Logik hinzufügen, z. B. eine Erfolgsnachricht anzeigen } else { console.error("Fehler beim Senden der POST-Anfrage"); } @@ -65,23 +96,27 @@ function Kue705FO({ // Überprüfe, ob ein Modul im Slot vorhanden ist const isModulPresent = kueOnline[slotIndex] === 1; + // Bestimme, welche Funktion ausgeführt wird, basierend auf dem aktiven Button + const handleRefreshClick = () => { + if (activeButton === "Schleife") { + goLoop(); // Wenn Schleife aktiv ist, starte goLoop + } else if (activeButton === "TDR") { + goTDR(); // Wenn TDR aktiv ist, starte goTDR + } + }; + return (
{schleifenwiderstand || "0"} kOhm