feat: Digitale Ausgänge aus Redux-Store in UI integriert
- DigitalOutputs.tsx auf Redux umgestellt, um Werte direkt aus dem Store zu lesen - toggleSwitch-Funktion angepasst, um den Status von digitalen Ausgängen in Redux zu aktualisieren - useDigitalOutputsData.ts nutzt nun Redux zum Speichern der `win_da_state` und `win_da_bezeichnung` Werte - Entfernen von Prop `digitalOutputs` in `DigitalOutputs.tsx`, da Redux nun als Datenquelle dient - Weboberfläche zeigt nun digitale Ausgänge korrekt an und Status kann geändert werden
This commit is contained in:
35
redux/slices/digitalOutputsSlice.ts
Normal file
35
redux/slices/digitalOutputsSlice.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// redux/slices/digitalOutputsSlice.ts
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
// Typ für den Zustand der digitalen Ausgänge
|
||||
interface DigitalOutput {
|
||||
id: number;
|
||||
label: string;
|
||||
status: boolean;
|
||||
}
|
||||
|
||||
interface DigitalOutputsState {
|
||||
outputs: DigitalOutput[];
|
||||
}
|
||||
|
||||
// Initialer Zustand
|
||||
const initialState: DigitalOutputsState = {
|
||||
outputs: [],
|
||||
};
|
||||
|
||||
// Slice erstellen
|
||||
const digitalOutputsSlice = createSlice({
|
||||
name: "digitalOutputs",
|
||||
initialState,
|
||||
reducers: {
|
||||
setDigitalOutputs(state, action: PayloadAction<DigitalOutput[]>) {
|
||||
state.outputs = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Aktionen exportieren
|
||||
export const { setDigitalOutputs } = digitalOutputsSlice.actions;
|
||||
|
||||
// Reducer exportieren
|
||||
export default digitalOutputsSlice.reducer;
|
||||
@@ -9,6 +9,7 @@ import kabelueberwachungChartReducer from "./slices/kabelueberwachungChartSlice"
|
||||
import dashboardReducer from "./slices/dashboardSlice";
|
||||
import systemSettingsReducer from "./slices/systemSettingsSlice";
|
||||
import opcuaSettingsReducer from "./slices/opcuaSettingsSlice";
|
||||
import digitalOutputsReducer from "./slices/digitalOutputsSlice";
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
@@ -21,6 +22,7 @@ const store = configureStore({
|
||||
dashboard: dashboardReducer,
|
||||
systemSettings: systemSettingsReducer,
|
||||
opcuaSettings: opcuaSettingsReducer,
|
||||
digitalOutputs: digitalOutputsReducer,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user