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 CPLStatus from "../../components/modulesStatus/CPLStatus";
|
||||||
import Access1Status from "../../components/modulesStatus/Access1Status";
|
import Access1Status from "../../components/modulesStatus/Access1Status";
|
||||||
import Access2Status from "../../components/modulesStatus/Access2Status";
|
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 XioPM1Status from "../../components/modulesStatus/XioPM1Status";
|
||||||
import XioPM2Status from "../../components/modulesStatus/XioPM2Status";
|
import XioPM2Status from "../../components/modulesStatus/XioPM2Status";
|
||||||
import { Icon } from "@iconify/react";
|
import { Icon } from "@iconify/react";
|
||||||
@@ -94,14 +94,13 @@ function Dashboard() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadWindowVariables(apiUrl)
|
loadWindowVariables(apiUrl)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
console.log("kueOnline Data: ", window.kueOnline); // Debug: Ausgabe von kueOnline
|
||||||
|
|
||||||
if (window.kueOnline) {
|
if (window.kueOnline) {
|
||||||
// Prüfe, ob kueOnline ein Array ist
|
|
||||||
if (Array.isArray(window.kueOnline)) {
|
if (Array.isArray(window.kueOnline)) {
|
||||||
// Verarbeite das Array, indem es in einen String umgewandelt wird
|
|
||||||
const versionArray = window.kueOnline.map(Number);
|
const versionArray = window.kueOnline.map(Number);
|
||||||
setkueOnline(versionArray);
|
setkueOnline(versionArray);
|
||||||
} else {
|
} else {
|
||||||
// Falls kueOnline kein Array ist, gibt eine Fehlermeldung aus
|
|
||||||
console.error("kueOnline ist kein Array:", window.kueOnline);
|
console.error("kueOnline ist kein Array:", window.kueOnline);
|
||||||
setError("Konnte kueOnline nicht als Array verarbeiten.");
|
setError("Konnte kueOnline nicht als Array verarbeiten.");
|
||||||
}
|
}
|
||||||
@@ -118,10 +117,10 @@ function Dashboard() {
|
|||||||
});
|
});
|
||||||
}, [apiUrl]);
|
}, [apiUrl]);
|
||||||
|
|
||||||
|
// Dashboard.jsx (Abschnitt renderBaugruppentraeger)
|
||||||
const renderBaugruppentraeger = () => {
|
const renderBaugruppentraeger = () => {
|
||||||
const baugruppen = [];
|
const baugruppen = [];
|
||||||
|
|
||||||
// Adjust based on actual length of kueOnline
|
|
||||||
const numBaugruppen = Math.ceil(kueOnline.length / 8);
|
const numBaugruppen = Math.ceil(kueOnline.length / 8);
|
||||||
|
|
||||||
for (let i = 0; i < numBaugruppen; i++) {
|
for (let i = 0; i < numBaugruppen; i++) {
|
||||||
@@ -133,11 +132,17 @@ function Dashboard() {
|
|||||||
{slots.map((version, index) => {
|
{slots.map((version, index) => {
|
||||||
const slotNumber = i * 8 + index + 1;
|
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 (
|
return (
|
||||||
<Kue705_FO
|
<KabelModulStatus
|
||||||
key={slotNumber}
|
key={slotNumber}
|
||||||
slot={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}
|
kueCableBreak={kueCableBreak}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// components/Kue705_FO.jsx
|
// components/modulesStatus/KabelModulStatus.jsx
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const Kue705_FO = ({ slot, kueCableBreak, isOnline }) => {
|
const KabelModulStatus = ({ slot, kueCableBreak, isOnline, moduleVersion }) => {
|
||||||
if (!isOnline) {
|
if (!isOnline) {
|
||||||
return (
|
return (
|
||||||
<div className="border border-gray-400 w-10 h-20 flex items-center justify-center bg-gray-200">
|
<div className="border border-gray-400 w-10 h-20 flex items-center justify-center bg-gray-200">
|
||||||
@@ -10,17 +10,32 @@ const Kue705_FO = ({ slot, kueCableBreak, isOnline }) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bestimme den Modultyp basierend auf der Version
|
||||||
|
let moduleName = "";
|
||||||
|
let moduleType = "";
|
||||||
|
|
||||||
|
if (moduleVersion === 419) {
|
||||||
|
moduleName = "KÜ705";
|
||||||
|
moduleType = "FO";
|
||||||
|
} else if (moduleVersion === 350) {
|
||||||
|
moduleName = "KÜ605";
|
||||||
|
moduleType = "µC";
|
||||||
|
} else if (moduleVersion === 1100) {
|
||||||
|
moduleName = "KÜSS";
|
||||||
|
moduleType = "___";
|
||||||
|
}
|
||||||
|
|
||||||
const isCableBreak = kueCableBreak[slot - 1] === 1;
|
const isCableBreak = kueCableBreak[slot - 1] === 1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="border border-gray-400 w-10 h-20 flex flex-col">
|
<div className="border border-gray-400 w-10 h-20 flex flex-col">
|
||||||
{/* Erstes Kind, nimmt den restlichen Platz ein */}
|
{/* Slot-Nummer anzeigen */}
|
||||||
<div className="bg-blue-500 flex-grow flex flex-col items-center justify-center text-white text-[10px]">
|
<div className="bg-blue-500 flex-grow flex flex-col items-center justify-center text-white text-[10px]">
|
||||||
<div className="flex w-full mb-1 items-start justify-start">{slot}</div>
|
<div className="flex w-full mb-1 items-start justify-start">{slot}</div>
|
||||||
<div className="text-[10px]">KÜ705</div>
|
<div className="text-[10px]">{moduleName}</div>
|
||||||
<div className="text-[10px]">FO</div>
|
<div className="text-[10px]">{moduleType}</div>
|
||||||
</div>
|
</div>
|
||||||
{/* Die unteren Abschnitte behalten ihre festen Höhen */}
|
{/* Status-Anzeige */}
|
||||||
<div
|
<div
|
||||||
className={`w-full h-2/6 ${
|
className={`w-full h-2/6 ${
|
||||||
isCableBreak ? "bg-red-500" : "bg-green-500"
|
isCableBreak ? "bg-red-500" : "bg-green-500"
|
||||||
@@ -31,4 +46,4 @@ const Kue705_FO = ({ slot, kueCableBreak, isOnline }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Kue705_FO;
|
export default KabelModulStatus;
|
||||||
Reference in New Issue
Block a user