refactor: Lade alle window-basierten .js-Dateien dynamisch und umgebungsabhängig
- Alle Services (ae.js, de.js, da.js, kueData.js, Start.js, System.js, opcua.js) laden ihre Scripte abhängig von der Umgebung - Vermeidet unnötige globale Script-Ladung über loadWindowVariables.ts - Reduziert Netzwerklast und verbessert Modularität und Performance
This commit is contained in:
52
redux/slices/kueDataSlice.ts
Normal file
52
redux/slices/kueDataSlice.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
// ✅ Slice: /redux/slices/kueDataSlice.ts
|
||||
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
interface KueDataState {
|
||||
kueOnline: boolean;
|
||||
kueID: string | null;
|
||||
pstMinus96V: number | null;
|
||||
alarm1: number | null;
|
||||
alarm2: number | null;
|
||||
iso: number | null;
|
||||
residence: number | null;
|
||||
cableBreak: number | null;
|
||||
groundFault: number | null;
|
||||
limit1: number | null;
|
||||
limit2Low: number | null;
|
||||
delay1: number | null;
|
||||
loopInterval: number | null;
|
||||
kueVersion: string | null;
|
||||
overflow: number | null;
|
||||
}
|
||||
|
||||
const initialState: KueDataState = {
|
||||
kueOnline: false,
|
||||
kueID: null,
|
||||
pstMinus96V: null,
|
||||
alarm1: null,
|
||||
alarm2: null,
|
||||
iso: null,
|
||||
residence: null,
|
||||
cableBreak: null,
|
||||
groundFault: null,
|
||||
limit1: null,
|
||||
limit2Low: null,
|
||||
delay1: null,
|
||||
loopInterval: null,
|
||||
kueVersion: null,
|
||||
overflow: null,
|
||||
};
|
||||
|
||||
const kueDataSlice = createSlice({
|
||||
name: "kueData",
|
||||
initialState,
|
||||
reducers: {
|
||||
setKueData: (state, action: PayloadAction<Partial<KueDataState>>) => {
|
||||
return { ...state, ...action.payload };
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setKueData } = kueDataSlice.actions;
|
||||
export default kueDataSlice.reducer;
|
||||
@@ -18,6 +18,7 @@ import tdrReferenceChartReducer from "./slices/tdrReferenceChartSlice";
|
||||
import loopChartReducer from "./slices/loopChartSlice";
|
||||
import tdmChartReducer from "./slices/tdmChartSlice";
|
||||
import tdrDataByIdReducer from "./slices/tdrDataByIdSlice";
|
||||
import kueDataReducer from "./slices/kueDataSlice";
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
@@ -38,6 +39,7 @@ const store = configureStore({
|
||||
loopChart: loopChartReducer,
|
||||
tdmChart: tdmChartReducer,
|
||||
tdrDataById: tdrDataByIdReducer,
|
||||
kueData: kueDataReducer,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
15
redux/thunks/fetchKueDataThunk.ts
Normal file
15
redux/thunks/fetchKueDataThunk.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// ✅ Thunk: /redux/thunks/fetchKueDataThunk.ts
|
||||
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchKueData } from "../../services/fetchKueData";
|
||||
import { setKueData } from "../slices/kueDataSlice";
|
||||
|
||||
export const fetchKueDataThunk = createAsyncThunk(
|
||||
"kueData/fetch",
|
||||
async (_, { dispatch }) => {
|
||||
const data = await fetchKueData();
|
||||
if (data) {
|
||||
dispatch(setKueData(data));
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user