feat: Implement dynamic module name rendering using window.kueVersion
- Updated KabelModulStatus component to dynamically display module names based on version. - Integrated window.kueVersion[slot] to determine the correct module name (KÜ705, KÜ605, or KÜSS). - Enhanced UI to reflect the module type and status accordingly.
This commit is contained in:
@@ -7,7 +7,7 @@ import { loadWindowVariables } from "../../utils/loadWindowVariables";
|
||||
import CPLStatus from "../../components/modulesStatus/CPLStatus";
|
||||
import Access1Status from "../../components/modulesStatus/Access1Status";
|
||||
import Access2Status from "../../components/modulesStatus/Access2Status";
|
||||
import Kue705_FO from "../../components/modulesStatus/Kue705_FO";
|
||||
import KabelModulStatus from "../../components/modulesStatus/KabelModulStatus";
|
||||
import XioPM1Status from "../../components/modulesStatus/XioPM1Status";
|
||||
import XioPM2Status from "../../components/modulesStatus/XioPM2Status";
|
||||
import { Icon } from "@iconify/react";
|
||||
@@ -94,14 +94,13 @@ function Dashboard() {
|
||||
useEffect(() => {
|
||||
loadWindowVariables(apiUrl)
|
||||
.then(() => {
|
||||
console.log("kueOnline Data: ", window.kueOnline); // Debug: Ausgabe von kueOnline
|
||||
|
||||
if (window.kueOnline) {
|
||||
// Prüfe, ob kueOnline ein Array ist
|
||||
if (Array.isArray(window.kueOnline)) {
|
||||
// Verarbeite das Array, indem es in einen String umgewandelt wird
|
||||
const versionArray = window.kueOnline.map(Number);
|
||||
setkueOnline(versionArray);
|
||||
} else {
|
||||
// Falls kueOnline kein Array ist, gibt eine Fehlermeldung aus
|
||||
console.error("kueOnline ist kein Array:", window.kueOnline);
|
||||
setError("Konnte kueOnline nicht als Array verarbeiten.");
|
||||
}
|
||||
@@ -118,10 +117,10 @@ function Dashboard() {
|
||||
});
|
||||
}, [apiUrl]);
|
||||
|
||||
// Dashboard.jsx (Abschnitt renderBaugruppentraeger)
|
||||
const renderBaugruppentraeger = () => {
|
||||
const baugruppen = [];
|
||||
|
||||
// Adjust based on actual length of kueOnline
|
||||
const numBaugruppen = Math.ceil(kueOnline.length / 8);
|
||||
|
||||
for (let i = 0; i < numBaugruppen; i++) {
|
||||
@@ -133,11 +132,17 @@ function Dashboard() {
|
||||
{slots.map((version, index) => {
|
||||
const slotNumber = i * 8 + index + 1;
|
||||
|
||||
// Verwende window.kueVersion[slotNumber - 1] für die Modulversion
|
||||
const moduleVersion = window.kueVersion
|
||||
? window.kueVersion[slotNumber - 1]
|
||||
: version;
|
||||
|
||||
return (
|
||||
<Kue705_FO
|
||||
<KabelModulStatus
|
||||
key={slotNumber}
|
||||
slot={slotNumber}
|
||||
isOnline={version === 1} // Only pass isOnline true if the slot is connected
|
||||
isOnline={version !== 0} // Prüfen, ob ein Modul online ist
|
||||
moduleVersion={moduleVersion} // Modulversion aus window.kueVersion oder fallback auf version
|
||||
kueCableBreak={kueCableBreak}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user