refactor: SystemSettings-Dispatch aus _app entfernt und in Seite 'Einstellungen' verlagert

This commit is contained in:
ISA
2025-03-25 08:35:46 +01:00
parent 6730ba92be
commit 8e6b26dff9
5 changed files with 78 additions and 47 deletions

View File

@@ -12,14 +12,11 @@ import WindowVariablesInitializer from "../components/WindowVariablesInitializer
import "../styles/globals.css";
import { AppProps } from "next/app";
import { setVariables } from "../redux/slices/variablesSlice";
import { setSystemSettings } from "../redux/slices/systemSettingsSlice";
import {
setOpcUaZustand,
setOpcUaActiveClientCount,
setOpcUaNodesetName,
} from "../redux/slices/opcuaSettingsSlice";
import { fetchAnalogeEingaengeThunk } from "../redux/thunks/fetchAnalogeEingaengeThunk";
import { fetchDigitaleEingaengeThunk } from "../redux/thunks/fetchDigitaleEingaengeThunk";
function MyApp({ Component, pageProps }: AppProps) {
return (
@@ -60,22 +57,6 @@ function AppContent({ Component, pageProps }: AppProps) {
...restVariables
} = variables;
dispatch(
setSystemSettings({
deviceName,
mac1,
ip,
subnet,
gateway,
cplInternalTimestamp,
ntp1,
ntp2,
ntp3,
ntpTimezone,
ntpActive,
})
);
dispatch(setOpcUaZustand(opcUaZustand || "Offline"));
dispatch(setOpcUaActiveClientCount(opcUaActiveClientCount || 0));
dispatch(setOpcUaNodesetName(opcUaNodesetName || "DefaultNodeset"));
@@ -97,26 +78,7 @@ function AppContent({ Component, pageProps }: AppProps) {
}
}, []);
//---------------------------------------------------------
useEffect(() => {
if (typeof window !== "undefined") {
dispatch(fetchAnalogeEingaengeThunk());
const interval = setInterval(() => {
dispatch(fetchAnalogeEingaengeThunk());
}, 10000);
return () => clearInterval(interval);
}
}, [dispatch]);
//---------------------------------------------------------
useEffect(() => {
if (typeof window !== "undefined") {
dispatch(fetchDigitaleEingaengeThunk());
const interval = setInterval(() => {
dispatch(fetchDigitaleEingaengeThunk());
}, 10000);
return () => clearInterval(interval);
}
}, [dispatch]);
//---------------------------------------------------------
return (
<div className="flex flex-col h-screen overflow-hidden">
<WindowVariablesInitializer />