From b8a3e977f0c8cc13f886e1a6bac53b9e7668a1e0 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 16 Oct 2024 10:30:19 +0200 Subject: [PATCH] TDR und Schleifen-Messung funktionieren mit der Icon --- components/modules/Kue705FO.jsx | 78 +++++++++++++++++---------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/components/modules/Kue705FO.jsx b/components/modules/Kue705FO.jsx index 1e5f3f0..5f21cbd 100644 --- a/components/modules/Kue705FO.jsx +++ b/components/modules/Kue705FO.jsx @@ -1,5 +1,4 @@ import React, { useState } from "react"; -import { Icon } from "@iconify/react"; // Für Iconify Icons function Kue705FO({ isolationswert, // Übergabeparameter für den Isolationswert @@ -11,6 +10,7 @@ function Kue705FO({ }) { const [activeButton, setActiveButton] = useState("Schleife"); const [displayText, setDisplayText] = useState("Schleifenwiderstand [kOhm]"); + const [loading, setLoading] = useState(false); const handleButtonClick = (button) => { if (button === "Schleife") { @@ -22,75 +22,76 @@ function Kue705FO({ } }; - // Funktion für die Aktualisierung (TDR-Aufruf) + // Funktion für die TDR-Messung const goTDR = () => { - let slot = slotIndex + 1; // Slotnummer (index beginnt bei 0, also +1) + let slot = slotIndex; // Verwende direkt slotIndex, da Slot 0 der erste Slot ist - // Bedingung: wenn der Slot größer als 32 ist, wird die Funktion beendet if (slot >= 32) { return; } - // Bereite die Slot-Informationen vor let slotFormat = slot < 10 ? `0${slot}` : `${slot}`; - const data = { - [`KTT${slotFormat}`]: 1, - slot: slot, - }; - const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL; - fetch(`${apiUrl}/CPL?Service/KUEdetailTDR.ACP`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(data), - }) + setLoading(true); // Ladezustand setzen + fetch( + `${apiUrl}/CPL?Service/KUEdetailTDR.ACP&KTT${slotFormat}=1&slot=${slot}`, + { + method: "GET", + } + ) .then((response) => { if (response.ok) { - console.log("POST erfolgreich gesendet für Slot", slot); + console.log("TDR erfolgreich gestartet für Slot", slot); + console.log( + "URL:", + `${apiUrl}/CPL?Service/KUEdetailTDR.ACP&KTT${slotFormat}=1&slot=${slot}` + ); + console.log("Antwort:", response); } else { - console.error("Fehler beim Senden der POST-Anfrage"); + console.error("Fehler beim Senden der TDR-Anfrage"); } }) .catch((error) => { console.error("Fehler:", error); - }); + }) + .finally(() => setLoading(false)); // Ladezustand wieder deaktivieren }; + // Funktion für die Schleifenmessung const goLoop = () => { - let slot = slotIndex + 1; + let slot = slotIndex; // Verwende direkt slotIndex 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), - }) + setLoading(true); // Ladezustand setzen + fetch( + `${apiUrl}/CPL?Service/KUEdetail.HTML&KS_${slotFormat}=1&slot=${slot}`, + { + method: "GET", + } + ) .then((response) => { if (response.ok) { - console.log("POST erfolgreich gesendet für Slot", slot); + console.log("Schleifenmessung erfolgreich gestartet für Slot", slot); + console.log( + "URL:", + `${apiUrl}/CPL?Service/KUEdetail.HTML&KS_${slotFormat}=1&slot=${slot}` + ); + console.log("Antwort:", response); } else { - console.error("Fehler beim Senden der POST-Anfrage"); + console.error("Fehler beim Senden der Schleifen-Anfrage"); } }) .catch((error) => { console.error("Fehler:", error); - }); + }) + .finally(() => setLoading(false)); // Ladezustand wieder deaktivieren }; // Überprüfe, ob ein Modul im Slot vorhanden ist @@ -112,7 +113,7 @@ function Kue705FO({
- {slotIndex + 1} + {slotIndex}

KÜ705-FO

@@ -164,6 +165,7 @@ function Kue705FO({ @@ -206,7 +208,7 @@ function Kue705FO({ ) : (
-

Kein Modul im Slot {slotIndex + 1}

+

Kein Modul im Slot {slotIndex}

)}