refactor: SystemSettings-Dispatch aus _app entfernt und in Seite 'Einstellungen' verlagert
This commit is contained in:
@@ -6,5 +6,5 @@
|
|||||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
const webVersion = "1.6.155";
|
const webVersion = "1.6.156";
|
||||||
export default webVersion;
|
export default webVersion;
|
||||||
|
|||||||
@@ -12,14 +12,11 @@ import WindowVariablesInitializer from "../components/WindowVariablesInitializer
|
|||||||
import "../styles/globals.css";
|
import "../styles/globals.css";
|
||||||
import { AppProps } from "next/app";
|
import { AppProps } from "next/app";
|
||||||
import { setVariables } from "../redux/slices/variablesSlice";
|
import { setVariables } from "../redux/slices/variablesSlice";
|
||||||
import { setSystemSettings } from "../redux/slices/systemSettingsSlice";
|
|
||||||
import {
|
import {
|
||||||
setOpcUaZustand,
|
setOpcUaZustand,
|
||||||
setOpcUaActiveClientCount,
|
setOpcUaActiveClientCount,
|
||||||
setOpcUaNodesetName,
|
setOpcUaNodesetName,
|
||||||
} from "../redux/slices/opcuaSettingsSlice";
|
} from "../redux/slices/opcuaSettingsSlice";
|
||||||
import { fetchAnalogeEingaengeThunk } from "../redux/thunks/fetchAnalogeEingaengeThunk";
|
|
||||||
import { fetchDigitaleEingaengeThunk } from "../redux/thunks/fetchDigitaleEingaengeThunk";
|
|
||||||
|
|
||||||
function MyApp({ Component, pageProps }: AppProps) {
|
function MyApp({ Component, pageProps }: AppProps) {
|
||||||
return (
|
return (
|
||||||
@@ -60,22 +57,6 @@ function AppContent({ Component, pageProps }: AppProps) {
|
|||||||
...restVariables
|
...restVariables
|
||||||
} = variables;
|
} = variables;
|
||||||
|
|
||||||
dispatch(
|
|
||||||
setSystemSettings({
|
|
||||||
deviceName,
|
|
||||||
mac1,
|
|
||||||
ip,
|
|
||||||
subnet,
|
|
||||||
gateway,
|
|
||||||
cplInternalTimestamp,
|
|
||||||
ntp1,
|
|
||||||
ntp2,
|
|
||||||
ntp3,
|
|
||||||
ntpTimezone,
|
|
||||||
ntpActive,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
dispatch(setOpcUaZustand(opcUaZustand || "Offline"));
|
dispatch(setOpcUaZustand(opcUaZustand || "Offline"));
|
||||||
dispatch(setOpcUaActiveClientCount(opcUaActiveClientCount || 0));
|
dispatch(setOpcUaActiveClientCount(opcUaActiveClientCount || 0));
|
||||||
dispatch(setOpcUaNodesetName(opcUaNodesetName || "DefaultNodeset"));
|
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 (
|
return (
|
||||||
<div className="flex flex-col h-screen overflow-hidden">
|
<div className="flex flex-col h-screen overflow-hidden">
|
||||||
<WindowVariablesInitializer />
|
<WindowVariablesInitializer />
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
"use client"; ///pages/analogeEingaenge.tsx
|
"use client"; ///pages/analogeEingaenge.tsx
|
||||||
import React, { useState } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import AnalogeEingaengeTabelle from "../components/main/analogeEingaenge/AnalogeEingaengeTable";
|
import AnalogeEingaengeTabelle from "../components/main/analogeEingaenge/AnalogeEingaengeTable";
|
||||||
import AnalogInputsChart from "../components/main/analogeEingaenge/AnalogInputsChart";
|
import AnalogInputsChart from "../components/main/analogeEingaenge/AnalogInputsChart";
|
||||||
|
import { fetchAnalogeEingaengeThunk } from "../redux/thunks/fetchAnalogeEingaengeThunk";
|
||||||
|
import { useAppDispatch } from "../redux/store";
|
||||||
|
|
||||||
function AnalogeEingaenge() {
|
function AnalogeEingaenge() {
|
||||||
const [activeConfig, setActiveConfig] = useState<number | null>(null);
|
const [activeConfig, setActiveConfig] = useState<number | null>(null);
|
||||||
|
//---------------------------------------------------------
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
dispatch(fetchAnalogeEingaengeThunk());
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
dispatch(fetchAnalogeEingaengeThunk());
|
||||||
|
}, 10000);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}
|
||||||
|
}, [dispatch]);
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
return (
|
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">
|
<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">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client"; // pages/einausgaenge.tsx
|
"use client"; // pages/einausgaenge.tsx
|
||||||
|
|
||||||
"use client";
|
"use client";
|
||||||
import React, { useState } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import DigitalOutputs from "../components/main/einausgaenge/DigitalOutputs";
|
import DigitalOutputs from "../components/main/einausgaenge/DigitalOutputs";
|
||||||
import DigitalInputs from "../components/main/einausgaenge/DigitalInputs";
|
import DigitalInputs from "../components/main/einausgaenge/DigitalInputs";
|
||||||
import InputModal from "../components/main/einausgaenge/modals/InputModal";
|
import InputModal from "../components/main/einausgaenge/modals/InputModal";
|
||||||
@@ -9,10 +9,11 @@ import OutputModal from "../components/main/einausgaenge/modals/OutputModal";
|
|||||||
import { useDigitalInputData } from "../hooks/einausgaenge/useDigitalInputsData";
|
import { useDigitalInputData } from "../hooks/einausgaenge/useDigitalInputsData";
|
||||||
import { useDigitalOutputs } from "../hooks/einausgaenge/useDigitalOutputsData";
|
import { useDigitalOutputs } from "../hooks/einausgaenge/useDigitalOutputsData";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
|
import { AppDispatch } from "../redux/store";
|
||||||
import { setDigitalOutputs } from "../redux/slices/digitalOutputsSlice";
|
import { setDigitalOutputs } from "../redux/slices/digitalOutputsSlice";
|
||||||
|
import { fetchDigitaleEingaengeThunk } from "../redux/thunks/fetchDigitaleEingaengeThunk";
|
||||||
function EinAusgaenge() {
|
const EinAusgaenge: React.FC = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch<AppDispatch>();
|
||||||
const { digitalOutputs, isLoading: isLoadingOutputs } = useDigitalOutputs();
|
const { digitalOutputs, isLoading: isLoadingOutputs } = useDigitalOutputs();
|
||||||
const { mockData, isLoading: isLoadingInputs } = useDigitalInputData();
|
const { mockData, isLoading: isLoadingInputs } = useDigitalInputData();
|
||||||
|
|
||||||
@@ -63,6 +64,17 @@ function EinAusgaenge() {
|
|||||||
|
|
||||||
const inputsGroup1 = digitalInputs.slice(0, 16);
|
const inputsGroup1 = digitalInputs.slice(0, 16);
|
||||||
const inputsGroup2 = digitalInputs.slice(16);
|
const inputsGroup2 = digitalInputs.slice(16);
|
||||||
|
//---------------------------------------------------------
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
dispatch(fetchDigitaleEingaengeThunk());
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
dispatch(fetchDigitaleEingaengeThunk());
|
||||||
|
}, 10000);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}
|
||||||
|
}, [dispatch]);
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
@@ -103,6 +115,6 @@ function EinAusgaenge() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default EinAusgaenge;
|
export default EinAusgaenge;
|
||||||
|
|||||||
@@ -1,9 +1,52 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { useAppDispatch } from "../redux/store";
|
||||||
|
import { setSystemSettings } from "../redux/slices/systemSettingsSlice";
|
||||||
|
import { loadWindowVariables } from "../utils/loadWindowVariables";
|
||||||
import GeneralSettings from "../components/main/settingsPageComponents/GeneralSettings";
|
import GeneralSettings from "../components/main/settingsPageComponents/GeneralSettings";
|
||||||
import OPCUAInterfaceSettings from "../components/main/settingsPageComponents/OPCUAInterfaceSettings";
|
import OPCUAInterfaceSettings from "../components/main/settingsPageComponents/OPCUAInterfaceSettings";
|
||||||
|
|
||||||
export default function Settings() {
|
export default function Settings() {
|
||||||
const [activeTab, setActiveTab] = useState("tab1");
|
const [activeTab, setActiveTab] = useState("tab1");
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadSettings = async () => {
|
||||||
|
const vars = await loadWindowVariables();
|
||||||
|
if (!vars) return;
|
||||||
|
|
||||||
|
const {
|
||||||
|
deviceName,
|
||||||
|
mac1,
|
||||||
|
ip,
|
||||||
|
subnet,
|
||||||
|
gateway,
|
||||||
|
cplInternalTimestamp,
|
||||||
|
ntp1,
|
||||||
|
ntp2,
|
||||||
|
ntp3,
|
||||||
|
ntpTimezone,
|
||||||
|
ntpActive,
|
||||||
|
} = vars;
|
||||||
|
|
||||||
|
dispatch(
|
||||||
|
setSystemSettings({
|
||||||
|
deviceName,
|
||||||
|
mac1,
|
||||||
|
ip,
|
||||||
|
subnet,
|
||||||
|
gateway,
|
||||||
|
cplInternalTimestamp,
|
||||||
|
ntp1,
|
||||||
|
ntp2,
|
||||||
|
ntp3,
|
||||||
|
ntpTimezone,
|
||||||
|
ntpActive,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
}, [dispatch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user