fix: Die Daten (.js) Kabelüberwachungsseite aktualisieren sich zwar alle paar Sekunden aber die Darstellung des BGT bleibt unverändert.

Bei der Kabelüberwachungsseite werden auch die analoge und digitale Eingänge geladen
This commit is contained in:
ISA
2025-05-12 16:17:40 +02:00
parent c3de2ab3a9
commit 959b0b1ec2
2 changed files with 70 additions and 30 deletions

View File

@@ -8,6 +8,7 @@ import { loadWindowVariables } from "../utils/loadWindowVariables";
import Header from "../components/header/Header";
import Navigation from "../components/navigation/Navigation";
import Footer from "../components/footer/Footer";
import { setKueData } from "../redux/slices/kueDataSlice";
import "../styles/globals.css";
import { AppProps } from "next/app";
@@ -25,14 +26,17 @@ function AppContent({ Component, pageProps }: AppProps) {
const [sessionExpired, setSessionExpired] = useState(false);
useEffect(() => {
let intervalId: NodeJS.Timeout;
const loadAndStoreVariables = async () => {
try {
const variables = await loadWindowVariables();
const { variables, kueData } = await loadWindowVariables();
if (!variables) throw new Error("Sitzungsfehler");
//console.log("✅ Window-Variablen geladen:", variables);
const { ...restVariables } = variables;
// Nur auf kabelueberwachung.html Redux aktualisieren
if (window.location.pathname.includes("kabelueberwachung")) {
dispatch(setKueData(kueData));
}
setSessionExpired(false);
} catch (error) {
@@ -44,13 +48,15 @@ function AppContent({ Component, pageProps }: AppProps) {
if (typeof window !== "undefined") {
loadAndStoreVariables();
const intervalId = setInterval(loadAndStoreVariables, 10000);
// Nur auf kabelueberwachung.html regelmäßig aktualisieren
if (window.location.pathname.includes("kabelueberwachung")) {
intervalId = setInterval(loadAndStoreVariables, 10000);
}
return () => clearInterval(intervalId);
}
}, []);
//---------------------------------------------------------
return (
<div className="flex flex-col h-screen overflow-hidden">
<Header />