"use client"; // app/dashboard/page.jsx import React, { useEffect, useState } from "react"; import "tailwindcss/tailwind.css"; import "@fontsource/roboto"; import "bootstrap-icons/font/bootstrap-icons.css"; 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 { Icon } from "@iconify/react"; function Dashboard() { const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL; const [last20Messages, setLast20Messages] = useState([]); const [ip, setIp] = useState(""); const [subnet, setSubnet] = useState(""); const [gateway, setGateway] = useState(""); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { loadWindowVariables(apiUrl) .then(() => { if (window.last20Messages) { const parsedMessages = parseMessages(window.last20Messages); setLast20Messages(parsedMessages); setIp(window.ip); setSubnet(window.subnet); setGateway(window.gateway); } else { console.error("Konnte last20Messages nicht finden."); setError("Konnte last20Messages nicht finden."); } setLoading(false); }) .catch((error) => { console.error("Fehler beim Laden des Skripts:", error); setError(error); setLoading(false); }); }, [apiUrl]); const parseMessages = (messages) => { messages = messages .replace(//g, "\n") .replace(/<\/?td>/g, "") .replace(/<\/tr>/g, "") .trim(); const rows = messages.split("\n"); return rows.map((row) => { const columns = [ row.substring(0, 5), // ID row.substring(5, 10), // Wert (z.B. Modulnummer) row.substring(10, 29), // Zeitstempel, Millisekunden entfernt :000 row.substring(33, row.length - 1), // Meldung (ohne letztes Zeichen) row.substring(row.length - 1), // Status (letztes Zeichen) ]; return columns; }); }; return (
{/* Letzte Meldungen - Titel und Icon Bereich */}

Letzten 20 Meldungen

{/* Meldungen Liste */}
{last20Messages.length > 0 ? ( last20Messages.map((columns, index) => ( )) ) : ( )}
ID Modul Zeitstempel Meldung Status
{columns[0]} {columns[1]} {columns[2]} {columns[3]} {columns[4]}
Keine Meldungen verfügbar.
{/* Sidebar mit Informationen */}
{/* Versionsinformationen */}

Versionsinformationen

Applikationsversion: 5.1.1.8 C-24-KA

Webserverversion: 5.3.4.1

{/* Beispiel für Geräteanzeige */}
{/* Footer Informationen */}
IP Address

IP-Adresse

{ip}

subnet mask

Subnet-Maske

{subnet}

gateway

Gateway

{gateway}

); } export default Dashboard;