Dashboard Übersicht
+Letzten 20 Meldungen:
+ {loading &&Loading data...
} + {error &&Error: {error.message}
} + {data && ( +diff --git a/app/dashboard/page.jsx b/app/dashboard/page.jsx index 6131b8f..0190ba3 100644 --- a/app/dashboard/page.jsx +++ b/app/dashboard/page.jsx @@ -1,19 +1,58 @@ "use client"; -import React, { useEffect } from "react"; - -import Image from "next/image"; -import "tailwindcss/tailwind.css"; // Stelle sicher, dass Tailwind CSS korrekt importiert wird -import "@fontsource/roboto"; // Standardimport für alle Schriftstärken +import React, { useEffect, useState } from "react"; +import "tailwindcss/tailwind.css"; +import "@fontsource/roboto"; import "bootstrap-icons/font/bootstrap-icons.css"; function Dashboard() { + const [data, setData] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + // Funktion zum Abrufen der ersetzten Platzhalterdaten vom Server + const fetchData = async () => { + try { + // Abrufen des Inhalts der Datei mit Platzhalterersetzung + const response = await fetch( + "http://localhost:3000/api/server?path=main.js", + { + mode: "cors", // stellt sicher, dass eine CORS-Anfrage gesendet wird + } + ); + + if (!response.ok) { + throw new Error(`HTTP error! Status: ${response.status}`); + } + + const result = await response.text(); // Beachte, dass dies `text()` statt `json()` ist, da wir den JS-Inhalt bekommen wollen + setData(result); + setLoading(false); + } catch (error) { + console.error("Error fetching data:", error); + setError(error); + setLoading(false); + } + }; + + fetchData(); + }, []); + return (
Loading data...
} + {error &&Error: {error.message}
} + {data && ( +Hardware Version: (.*?)<\/p>/);
+
+ return {
+ stationsname: stationsnameMatch ? stationsnameMatch[1] : "Unbekannt",
+ cplStatus: cplStatusMatch ? cplStatusMatch[1] : "Unbekannt",
+ };
+ }
+
return (
CPLV4Rastede {stationsname} CPL StatusStationsname
-