git commit -m "refactor: last20Messages aus _app.tsx entfernt und über Thunk in dashboard.tsx geladen"

This commit is contained in:
ISA
2025-03-25 09:34:19 +01:00
parent 8e6b26dff9
commit b536d31e48
5 changed files with 35 additions and 11 deletions

View File

@@ -12,11 +12,6 @@ import WindowVariablesInitializer from "../components/WindowVariablesInitializer
import "../styles/globals.css";
import { AppProps } from "next/app";
import { setVariables } from "../redux/slices/variablesSlice";
import {
setOpcUaZustand,
setOpcUaActiveClientCount,
setOpcUaNodesetName,
} from "../redux/slices/opcuaSettingsSlice";
function MyApp({ Component, pageProps }: AppProps) {
return (
@@ -39,7 +34,6 @@ function AppContent({ Component, pageProps }: AppProps) {
//console.log("✅ Window-Variablen geladen:", variables);
const {
last20Messages,
opcUaZustand,
opcUaActiveClientCount,
opcUaNodesetName,
@@ -57,10 +51,6 @@ function AppContent({ Component, pageProps }: AppProps) {
...restVariables
} = variables;
dispatch(setOpcUaZustand(opcUaZustand || "Offline"));
dispatch(setOpcUaActiveClientCount(opcUaActiveClientCount || 0));
dispatch(setOpcUaNodesetName(opcUaNodesetName || "DefaultNodeset"));
dispatch(setVariables(restVariables));
setSessionExpired(false);

View File

@@ -9,8 +9,21 @@ import Last20MessagesTable from "../components/main/uebersicht/Last20MessagesTab
import NetworkInfo from "../components/main/uebersicht/NetworkInfo";
import VersionInfo from "../components/main/uebersicht/VersionInfo";
import Baugruppentraeger from "../components/main/uebersicht/Baugruppentraeger";
import { fetchLast20MessagesThunk } from "../redux/thunks/fetchLast20MessagesThunk";
import { useAppDispatch } from "../redux/store";
const Dashboard: React.FC = () => {
//-------------------------------------
const dispatch = useAppDispatch();
useEffect(() => {
dispatch(fetchLast20MessagesThunk());
const interval = setInterval(() => {
dispatch(fetchLast20MessagesThunk());
}, 10000); // oder 5000
return () => clearInterval(interval);
}, [dispatch]);
//-------------------------------------
return (
<div className="flex flex-col gap-3 p-4 h-[calc(100vh-13vh-8vh)] laptop:h-[calc(100vh-10vh-5vh)] xl:h-[calc(100vh-10vh-6vh)] laptop:gap-0">
{/* Header */}