Tabelle in Dashboard angeordnet Spalten und zeichen , Millisekunden entfernt

This commit is contained in:
ISA
2024-09-25 12:26:27 +02:00
parent 0bdfa9dd8d
commit 57868c30ef

View File

@@ -51,6 +51,13 @@ function Dashboard() {
// Funktion zum Parsen der Nachrichten // Funktion zum Parsen der Nachrichten
const parseMessages = (messages) => { const parseMessages = (messages) => {
// Ersetze die HTML-Tags durch Zeilenumbrüche und entferne alle <td> und </td> Tags
messages = messages
.replace(/<tr>/g, "\n")
.replace(/<\/?td>/g, "")
.replace(/<\/tr>/g, "")
.trim();
// Nachrichten in Zeilen aufteilen // Nachrichten in Zeilen aufteilen
const rows = messages.split("\n"); const rows = messages.split("\n");
return rows.map((row) => { return rows.map((row) => {
@@ -58,9 +65,9 @@ function Dashboard() {
const columns = [ const columns = [
row.substring(0, 5), // ID row.substring(0, 5), // ID
row.substring(5, 10), // Wert (z.B. Modulnummer) row.substring(5, 10), // Wert (z.B. Modulnummer)
row.substring(10, 34), // Zeitstempel row.substring(10, 29), // Zeitstempel , Millisekunden entfernt :000
row.substring(34, 60), // Meldung row.substring(33, row.length - 1), // Meldung (ohne letztes Zeichen)
row.substring(60), // Status row.substring(row.length - 1), // Status (letztes Zeichen)
]; ];
return columns; return columns;
}); });
@@ -111,7 +118,8 @@ function Dashboard() {
<th className="py-2 px-4">ID</th> <th className="py-2 px-4">ID</th>
<th className="py-2 px-4">Wert</th> <th className="py-2 px-4">Wert</th>
<th className="py-2 px-4">Zeitstempel</th> <th className="py-2 px-4">Zeitstempel</th>
<th className="py-2 px-4">Meldung</th> {/* Meldung breiter machen */}
<th className="py-2 px-4 w-2/3">Meldung</th>
<th className="py-2 px-4">Status</th> <th className="py-2 px-4">Status</th>
</tr> </tr>
</thead> </thead>
@@ -123,7 +131,9 @@ function Dashboard() {
<td className="py-2 px-4">{columns[0]}</td> <td className="py-2 px-4">{columns[0]}</td>
<td className="py-2 px-4">{columns[1]}</td> <td className="py-2 px-4">{columns[1]}</td>
<td className="py-2 px-4">{columns[2]}</td> <td className="py-2 px-4">{columns[2]}</td>
<td className="py-2 px-4">{columns[3]}</td> {/* Meldung ohne letztes Zeichen anzeigen */}
<td className="py-2 px-4 w-2/3">{columns[3]}</td>
{/* Status anzeigen */}
<td className="py-2 px-4">{columns[4]}</td> <td className="py-2 px-4">{columns[4]}</td>
</tr> </tr>
)) ))