diff --git a/components/modules/Kue705FO.jsx b/components/modules/Kue705FO.jsx index 7fb5697..a504b55 100644 --- a/components/modules/Kue705FO.jsx +++ b/components/modules/Kue705FO.jsx @@ -15,6 +15,10 @@ function Kue705FO({ tdrLocation, alarmStatus, }) { + console.log( + `Rendering Kue705FO - SlotIndex: ${slotIndex}, ModulName: ${modulName}` + ); + const chartRef = useRef(null); const [zoomPlugin, setZoomPlugin] = useState(null); // Plugin-Status für Chart.js const [kueVersion, setKueVersion] = useState("V4.19"); @@ -376,7 +380,16 @@ function Kue705FO({ kueAlarm2, kueOverflow, ]); - + // In Kue705FO.jsx + useEffect(() => { + console.log("modulName for Kue705FO:", modulName); + }, [modulName]); + //--------------------------------------------------- + // Effekt, um Modulnamen zu aktualisieren, wenn sich der Prop ändert + useEffect(() => { + setCurrentModulName(modulName); + console.log(`Modulname aktualisiert für Slot ${slotIndex}:`, modulName); + }, [modulName, slotIndex]); //--------------------------------------------------- return (
@@ -397,7 +410,7 @@ function Kue705FO({
- + {}
- {currentModulName || "Test1"} + {currentModulName || `Modul ${slotIndex + 1}`}
diff --git a/pages/kabelueberwachung.js b/pages/kabelueberwachung.js index fd6713c..8711f1b 100644 --- a/pages/kabelueberwachung.js +++ b/pages/kabelueberwachung.js @@ -1,10 +1,8 @@ -"use client"; // app/kabelueberwachung/page.jsx +"use client"; import React, { useState, useEffect } from "react"; import { useRouter } from "next/navigation"; import Kue705FO from "../components/modules/Kue705FO"; import { useDispatch, useSelector } from "react-redux"; -import { setVariables } from "../store/variablesSlice"; -//import { loadWindowVariables } from "../utils/loadWindowVariables"; function Kabelueberwachung() { const router = useRouter(); @@ -24,24 +22,6 @@ function Kabelueberwachung() { kueGroundFault, } = useSelector((state) => state.variables); - // URL-Parameter 'rack' abfragen und setzen - useEffect(() => { - const query = new URLSearchParams(window.location.search); - const rackParam = query.get("rack"); - if (rackParam) { - setActiveRack(parseInt(rackParam)); - } - }, [router.query]); - - // Laden der `window`-Variablen und Speichern in Redux - /* useEffect(() => { - const fetchData = async () => { - const variables = await loadWindowVariables(); - dispatch(setVariables(variables)); - }; - fetchData(); - }, [dispatch]); - */ // Alarmstatus basierend auf Redux-Variablen berechnen const updateAlarmStatus = () => { const updatedAlarmStatus = kueIso.map((_, index) => { @@ -66,10 +46,11 @@ function Kabelueberwachung() { const allModules = kueIso.map((iso, index) => ({ isolationswert: iso, schleifenwiderstand: kueRes[index], - modulName: kueID[index] || "Unknown", + modulName: kueID[index] || `Modul ${index + 1}`, // Eindeutiger Name pro Index kueOnlineStatus: kueOnline[index], alarmStatus: alarmStatus[index], })); + console.log("Alle Module:", allModules); const racks = { rack1: allModules.slice(0, 8), @@ -78,20 +59,49 @@ function Kabelueberwachung() { rack4: allModules.slice(24, 32), }; + // Konsolenausgaben für jede Rack-Aufteilung + console.log( + "Rack 1 Module:", + racks.rack1.map((slot) => slot.modulName) + ); + console.log( + "Rack 2 Module:", + racks.rack2.map((slot) => slot.modulName) + ); + console.log( + "Rack 3 Module:", + racks.rack3.map((slot) => slot.modulName) + ); + console.log( + "Rack 4 Module:", + racks.rack4.map((slot) => slot.modulName) + ); + // Funktion zum Wechseln des Racks - const changeRack = (rack) => setActiveRack(rack); + const changeRack = (rack) => { + setActiveRack(rack); + console.log(`Aktives Rack geändert zu: ${rack}`); + }; + + useEffect(() => { + console.log(`Aktives Rack: ${activeRack}`); + console.log( + `Rack ${activeRack} Modulnamen:`, + racks[`rack${activeRack}`].map((slot) => slot.modulName) + ); + }, [activeRack, racks]); return (

Kabelüberwachung

- +

Aktives Rack: {activeRack}

{/* Zeigt aktives Rack an */}
{[1, 2, 3, 4].map((rack) => ( ))}
-
{racks[`rack${activeRack}`].map((slot, index) => { const slotIndex = index + (activeRack - 1) * 8;