feat: Meldungen in in Iso Chart

This commit is contained in:
ISA
2025-07-31 15:57:50 +02:00
parent cdd26931a1
commit 63e1b85a44
8 changed files with 253 additions and 91 deletions

View File

@@ -33,11 +33,48 @@ const Report: React.FC = () => {
(allMessages: Meldung[], slot: number) => {
if (slot === null) return [];
// Filter basierend auf der Quelle (i-Feld)
return allMessages.filter((msg: Meldung) => {
// Verschiedene mögliche Slot-Identifikationen
const slotIdentifiers = [
`CableLine${slot + 1}`,
// Primärer Filter: Exakte CableLineX Übereinstimmung (X = slot + 1)
const primaryIdentifier = `CableLine${slot + 1}`;
console.log(
`🔍 Filtere Nachrichten für Slot ${slot} (${primaryIdentifier}):`
);
console.log(`📥 Gesamt Nachrichten: ${allMessages.length}`);
// Debug: Zeige alle verfügbaren Quellen
const allSources = [...new Set(allMessages.map((msg) => msg.i))];
console.log(`📋 Alle verfügbaren Quellen:`, allSources);
// Filter basierend auf der Quelle (i-Feld) - EXAKTE Übereinstimmung
const filtered = allMessages.filter((msg: Meldung) => {
// Exakte Übereinstimmung: msg.i sollte genau "CableLineX" sein
const isExactMatch = msg.i === primaryIdentifier;
// Fallback: Falls die Quelle mehr Informationen enthält (z.B. "CableLine1_Sensor")
const isPartialMatch =
msg.i.startsWith(primaryIdentifier) &&
(msg.i === primaryIdentifier ||
msg.i.charAt(primaryIdentifier.length).match(/[^0-9]/));
const isMatch = isExactMatch || isPartialMatch;
if (isMatch) {
console.log(`✅ Gefunden: "${msg.i}" -> ${msg.m}`);
}
return isMatch;
});
console.log(
`📤 Gefilterte Nachrichten für ${primaryIdentifier}: ${filtered.length}`
);
// Falls keine Nachrichten mit CableLineX gefunden, versuche alternative Identifikatoren
if (filtered.length === 0) {
console.log(
`⚠️ Keine Nachrichten für ${primaryIdentifier} gefunden. Versuche alternative Identifikatoren...`
);
const alternativeIdentifiers = [
`Slot${slot + 1}`,
`${slot + 1}`,
`Kue${slot + 1}`,
@@ -45,8 +82,29 @@ const Report: React.FC = () => {
`Line${slot + 1}`,
];
return slotIdentifiers.some((identifier) => msg.i.includes(identifier));
});
const alternativeFiltered = allMessages.filter((msg: Meldung) => {
return alternativeIdentifiers.some((identifier) => {
const isExactMatch = msg.i === identifier;
const isPartialMatch =
msg.i.startsWith(identifier) &&
(msg.i === identifier ||
msg.i.charAt(identifier.length).match(/[^0-9]/));
const isMatch = isExactMatch || isPartialMatch;
if (isMatch) {
console.log(`🔄 Alternative gefunden: "${msg.i}" -> ${msg.m}`);
}
return isMatch;
});
});
console.log(
`📤 Alternative gefilterte Nachrichten: ${alternativeFiltered.length}`
);
return alternativeFiltered;
}
return filtered;
},
[]
);
@@ -107,25 +165,15 @@ const Report: React.FC = () => {
}
return (
<div className="w-full h-full flex flex-col">
<div className="flex justify-between items-center mb-4">
<h4 className="text-lg font-semibold">
Meldungen für {slotNumber !== null ? slotNumber + 1 : "-"}
</h4>
<button
onClick={loadMessages}
className="px-3 py-1 bg-littwin-blue text-white rounded text-sm hover:bg-blue-600"
>
Aktualisieren
</button>
</div>
<div className="w-full h-full flex flex-col p-4">
{filteredMessages.length === 0 ? (
<div className="text-center text-gray-500 py-8">
Keine Meldungen im gewählten Zeitraum gefunden.
<div className="text-center text-gray-500 ">
Keine Meldungen für CableLine
{slotNumber !== null ? slotNumber + 1 : "-"} im gewählten Zeitraum
gefunden.
</div>
) : (
<div className="flex-1 overflow-auto max-h-[80vh]">
<div className="flex-1 overflow-auto ">
<table className="min-w-full border text-sm">
<thead className="bg-gray-100 text-left sticky top-0 z-10">
<tr>
@@ -165,7 +213,7 @@ const Report: React.FC = () => {
</div>
)}
<div className="mt-4 text-sm text-gray-500 text-center">
<div className="mt-4 text-sm text-gray-500 text-center mt-4">
{filteredMessages.length} Meldung(en) gefunden
</div>
</div>