chore: fetch to get in redux thunks files name
This commit is contained in:
@@ -3,29 +3,29 @@
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { Provider } from "react-redux";
|
||||
import store, { useAppDispatch } from "../redux/store";
|
||||
import store, { useAppDispatch } from "@/redux/store";
|
||||
import { AppProps } from "next/app";
|
||||
import { loadWindowVariables } from "../utils/loadWindowVariables";
|
||||
import { loadWindowVariables } from "@/utils/loadWindowVariables";
|
||||
|
||||
import Header from "../components/header/Header";
|
||||
import Navigation from "../components/navigation/Navigation";
|
||||
import Footer from "../components/footer/Footer";
|
||||
import Header from "@/components/header/Header";
|
||||
import Navigation from "@/components/navigation/Navigation";
|
||||
import Footer from "@/components/footer/Footer";
|
||||
|
||||
// Thunks importieren
|
||||
import { fetchKueDataThunk } from "../redux/thunks/fetchKueDataThunk";
|
||||
import { fetchDigitalOutputsThunk } from "../redux/thunks/fetchDigitalOutputsThunk";
|
||||
import { fetchAnalogInputsThunk } from "../redux/thunks/fetchAnalogInputsThunk";
|
||||
import { getAnalogInputsHistoryThunk } from "../redux/thunks/getAnalogInputsHistoryThunk";
|
||||
import { fetchLast20MessagesThunk } from "../redux/thunks/fetchLast20MessagesThunk";
|
||||
import { fetchOpcUaSettingsThunk } from "../redux/thunks/fetchOpcUaSettingsThunk";
|
||||
import { fetchSystemSettingsThunk } from "../redux/thunks/fetchSystemSettingsThunk";
|
||||
import { fetchSystemVoltTempThunk } from "../redux/thunks/fetchSystemVoltTempThunk";
|
||||
import { fetchReferenceCurveBySlotThunk } from "../redux/thunks/fetchReferenceCurveBySlotThunk";
|
||||
import { getKueDataThunk } from "@/redux/thunks/getKueDataThunk";
|
||||
import { getDigitalOutputsThunk } from "@/redux/thunks/getDigitalOutputsThunk";
|
||||
import { getAnalogInputsThunk } from "@/redux/thunks/getAnalogInputsThunk";
|
||||
import { getAnalogInputsHistoryThunk } from "@/redux/thunks/getAnalogInputsHistoryThunk";
|
||||
import { getLast20MessagesThunk } from "@/redux/thunks/getLast20MessagesThunk";
|
||||
import { getOpcUaSettingsThunk } from "@/redux/thunks/getOpcUaSettingsThunk";
|
||||
import { getSystemSettingsThunk } from "@/redux/thunks/getSystemSettingsThunk";
|
||||
import { getSystemVoltTempThunk } from "@/redux/thunks/getSystemVoltTempThunk";
|
||||
import { getReferenceCurveBySlotThunk } from "@/redux/thunks/getReferenceCurveBySlotThunk";
|
||||
import { getAllTDRReferenceChartThunk } from "@/redux/thunks/getAllTDRReferenceChartThunk";
|
||||
import { fetchTDRChartDataByIdThunk } from "../redux/thunks/fetchTDRChartDataByIdThunk";
|
||||
import { fetchLoopChartDataThunk } from "../redux/thunks/fetchLoopChartDataThunk";
|
||||
import { getTDRChartDataByIdThunk } from "@/redux/thunks/getTDRChartDataByIdThunk";
|
||||
import { getLoopChartDataThunk } from "@/redux/thunks/getLoopChartDataThunk";
|
||||
|
||||
import "../styles/globals.css";
|
||||
import "@/styles/globals.css";
|
||||
|
||||
function MyApp({ Component, pageProps }: AppProps) {
|
||||
return (
|
||||
@@ -35,7 +35,13 @@ function MyApp({ Component, pageProps }: AppProps) {
|
||||
);
|
||||
}
|
||||
|
||||
function AppContent({ Component, pageProps }: AppProps) {
|
||||
function AppContent({
|
||||
Component,
|
||||
pageProps,
|
||||
}: {
|
||||
Component: AppProps["Component"];
|
||||
pageProps: AppProps["pageProps"];
|
||||
}): JSX.Element {
|
||||
const dispatch = useAppDispatch();
|
||||
const [sessionExpired, setSessionExpired] = useState(false);
|
||||
|
||||
@@ -45,31 +51,31 @@ function AppContent({ Component, pageProps }: AppProps) {
|
||||
|
||||
const loadAndDispatch = () => {
|
||||
if (pathname.includes("kabelueberwachung")) {
|
||||
dispatch(fetchKueDataThunk());
|
||||
dispatch(getKueDataThunk());
|
||||
} else if (pathname.includes("digitalOutputs")) {
|
||||
dispatch(fetchDigitalOutputsThunk());
|
||||
dispatch(getDigitalOutputsThunk());
|
||||
} else if (pathname.includes("digitalInputs")) {
|
||||
dispatch(fetchDigitalOutputsThunk()); // 🟠 evtl. anpassen
|
||||
dispatch(getDigitalOutputsThunk()); // 🟠 evtl. anpassen
|
||||
} else if (pathname.includes("analogInputs")) {
|
||||
dispatch(fetchAnalogInputsThunk());
|
||||
dispatch(getAnalogInputsThunk());
|
||||
} else if (pathname.includes("analogHistory")) {
|
||||
dispatch(getAnalogInputsHistoryThunk());
|
||||
} else if (pathname.includes("dashboard")) {
|
||||
dispatch(fetchLast20MessagesThunk());
|
||||
dispatch(getLast20MessagesThunk());
|
||||
} else if (pathname.includes("einstellungen")) {
|
||||
dispatch(fetchOpcUaSettingsThunk());
|
||||
dispatch(getOpcUaSettingsThunk());
|
||||
} else if (pathname.includes("systemvolt")) {
|
||||
dispatch(fetchSystemVoltTempThunk());
|
||||
dispatch(getSystemVoltTempThunk());
|
||||
} else if (pathname.includes("system")) {
|
||||
dispatch(fetchSystemSettingsThunk());
|
||||
dispatch(getSystemSettingsThunk());
|
||||
} else if (pathname.includes("tdrRef")) {
|
||||
dispatch(getAllTDRReferenceChartThunk());
|
||||
} else if (pathname.includes("tdrSlot")) {
|
||||
dispatch(fetchReferenceCurveBySlotThunk());
|
||||
dispatch(getReferenceCurveBySlotThunk());
|
||||
} else if (pathname.includes("tdrId")) {
|
||||
dispatch(fetchTDRChartDataByIdThunk());
|
||||
dispatch(getTDRChartDataByIdThunk());
|
||||
} else if (pathname.includes("loopChart")) {
|
||||
dispatch(fetchLoopChartDataThunk());
|
||||
dispatch(getLoopChartDataThunk());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import React, { useState, useEffect } from "react";
|
||||
import AnalogInputsTable from "../components/main/analogInputs/AnalogInputsTable";
|
||||
import AnalogInputsChart from "../components/main/analogInputs/AnalogInputsChart";
|
||||
import AnalogInputsSettingsModal from "../components/main/analogInputs/AnalogInputsSettingsModal";
|
||||
import { fetchAnalogInputsThunk } from "../redux/thunks/fetchAnalogInputsThunk";
|
||||
import { getAnalogInputsThunk } from "../redux/thunks/getAnalogInputsThunk";
|
||||
import { useAppDispatch } from "../redux/store";
|
||||
|
||||
function AnalogInputs() {
|
||||
@@ -14,9 +14,9 @@ function AnalogInputs() {
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
dispatch(fetchAnalogInputsThunk());
|
||||
dispatch(getAnalogInputsThunk());
|
||||
const interval = setInterval(() => {
|
||||
dispatch(fetchAnalogInputsThunk());
|
||||
dispatch(getAnalogInputsThunk());
|
||||
}, 10000);
|
||||
return () => clearInterval(interval);
|
||||
}
|
||||
|
||||
@@ -9,16 +9,16 @@ 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 { getLast20MessagesThunk } from "../redux/thunks/getLast20MessagesThunk";
|
||||
import { useAppDispatch } from "../redux/store";
|
||||
|
||||
const Dashboard: React.FC = () => {
|
||||
//-------------------------------------
|
||||
const dispatch = useAppDispatch();
|
||||
useEffect(() => {
|
||||
dispatch(fetchLast20MessagesThunk());
|
||||
dispatch(getLast20MessagesThunk());
|
||||
const interval = setInterval(() => {
|
||||
dispatch(fetchLast20MessagesThunk());
|
||||
dispatch(getLast20MessagesThunk());
|
||||
}, 10000); // oder 5000
|
||||
|
||||
return () => clearInterval(interval);
|
||||
|
||||
@@ -6,8 +6,8 @@ import { AppDispatch, RootState } from "../redux/store";
|
||||
|
||||
import InputModal from "../components/main/einausgaenge/modals/InputModal";
|
||||
|
||||
import { fetchDigitalInputsThunk } from "@/redux/thunks/fetchDigitalInputsThunk";
|
||||
import { fetchDigitalOutputsThunk } from "../redux/thunks/fetchDigitalOutputsThunk";
|
||||
import { getDigitalInputsThunk } from "@/redux/thunks/getDigitalInputsThunk";
|
||||
import { getDigitalOutputsThunk } from "../redux/thunks/getDigitalOutputsThunk";
|
||||
|
||||
import DigitalInputs from "../components/main/einausgaenge/DigitalInputs";
|
||||
|
||||
@@ -26,12 +26,12 @@ const EinAusgaenge: React.FC = () => {
|
||||
const [isOutputModalOpen, setIsOutputModalOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchDigitalInputsThunk());
|
||||
dispatch(fetchDigitalOutputsThunk());
|
||||
dispatch(getDigitalInputsThunk());
|
||||
dispatch(getDigitalOutputsThunk());
|
||||
|
||||
const interval = setInterval(() => {
|
||||
dispatch(fetchDigitalInputsThunk());
|
||||
dispatch(fetchDigitalOutputsThunk());
|
||||
dispatch(getDigitalInputsThunk());
|
||||
dispatch(getDigitalOutputsThunk());
|
||||
}, 10000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
|
||||
@@ -5,8 +5,8 @@ import { AppDispatch, RootState } from "@/redux/store";
|
||||
|
||||
import DigitalOutputsModal from "../components/main/einausgaenge/modals/DigitalOutputsModal";
|
||||
|
||||
import { fetchDigitalInputsThunk } from "@/redux/thunks/fetchDigitalInputsThunk";
|
||||
import { fetchDigitalOutputsThunk } from "@/redux/thunks/fetchDigitalOutputsThunk";
|
||||
import { getDigitalInputsThunk } from "@/redux/thunks/getDigitalInputsThunk";
|
||||
import { getDigitalOutputsThunk } from "@/redux/thunks/getDigitalOutputsThunk";
|
||||
|
||||
import DigitalOutputs from "../components/main/einausgaenge/DigitalOutputsWidget";
|
||||
|
||||
@@ -21,11 +21,11 @@ const EinAusgaenge: React.FC = () => {
|
||||
const [isOutputModalOpen, setIsOutputModalOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchDigitalOutputsThunk());
|
||||
dispatch(getDigitalOutputsThunk());
|
||||
|
||||
const interval = setInterval(() => {
|
||||
dispatch(fetchDigitalInputsThunk());
|
||||
dispatch(fetchDigitalOutputsThunk());
|
||||
dispatch(getDigitalInputsThunk());
|
||||
dispatch(getDigitalOutputsThunk());
|
||||
}, 500);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// /pages/einstellungen.tsx
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useAppDispatch } from "../redux/store";
|
||||
import { fetchSystemSettingsThunk } from "../redux/thunks/fetchSystemSettingsThunk";
|
||||
import { getSystemSettingsThunk } from "../redux/thunks/getSystemSettingsThunk";
|
||||
import GeneralSettings from "../components/main/settingsPageComponents/GeneralSettings";
|
||||
import OPCUAInterfaceSettings from "../components/main/settingsPageComponents/OPCUAInterfaceSettings";
|
||||
import DatabaseSettings from "../components/main/settingsPageComponents/DatabaseSettings";
|
||||
@@ -13,7 +13,7 @@ export default function Settings() {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchSystemSettingsThunk());
|
||||
dispatch(getSystemSettingsThunk());
|
||||
}, [dispatch]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -5,7 +5,7 @@ import Kue705FO from "../components/main/kabelueberwachung/kue705FO/Kue705FO";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { AppDispatch } from "../redux/store"; // Adjust the path to your Redux store file
|
||||
import { RootState } from "../redux/store"; // Adjust the path to your Redux store file
|
||||
import { fetchKueDataThunk } from "../redux/thunks/fetchKueDataThunk";
|
||||
import { getKueDataThunk } from "../redux/thunks/getKueDataThunk";
|
||||
|
||||
function Kabelueberwachung() {
|
||||
const dispatch: AppDispatch = useDispatch();
|
||||
@@ -119,8 +119,8 @@ function Kabelueberwachung() {
|
||||
//------------------------------------------------------------
|
||||
useEffect(() => {
|
||||
if (kueIso.length === 0) {
|
||||
console.log("📦 Lade KUE-Daten aus fetchKueDataThunk...");
|
||||
dispatch(fetchKueDataThunk());
|
||||
console.log("📦 Lade KUE-Daten aus getKueDataThunk...");
|
||||
dispatch(getKueDataThunk());
|
||||
}
|
||||
}, []);
|
||||
//------------------------------------------------------------
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { AppDispatch, RootState } from "../redux/store";
|
||||
import { fetchSystemVoltTempThunk } from "../redux/thunks/fetchSystemVoltTempThunk";
|
||||
import { getSystemVoltTempThunk } from "../redux/thunks/getSystemVoltTempThunk";
|
||||
import {
|
||||
Chart as ChartJS,
|
||||
CategoryScale,
|
||||
@@ -35,9 +35,9 @@ const SystemPage = () => {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchSystemVoltTempThunk());
|
||||
dispatch(getSystemVoltTempThunk());
|
||||
const interval = setInterval(() => {
|
||||
dispatch(fetchSystemVoltTempThunk());
|
||||
dispatch(getSystemVoltTempThunk());
|
||||
}, 5000);
|
||||
return () => clearInterval(interval);
|
||||
}, [dispatch]);
|
||||
|
||||
Reference in New Issue
Block a user