feat: OPC-UA Einstellungen in eigenen Redux Slice ausgelagert
- OPC-UA bezogene Variablen aus `variablesSlice` entfernt und in `opcuaSettingsSlice` ausgelagert
- Neue Redux Actions für:
- `setOpcUaZustand` (OPC-UA Zustand setzen)
- `setOpcUaEncryption` (Verschlüsselung setzen)
- `setOpcUaActiveClientCount` (Anzahl aktiver Clients setzen)
- `setOpcUaNodesetName` (Nodeset-Name setzen)
- `addOpcUaUser` & `removeOpcUaUser` (Benutzerverwaltung)
- `loadWindowVariables.ts` angepasst, um OPC-UA-Daten in `opcuaSettingsSlice` zu speichern
- Benutzerverwaltung optimiert:
- Manuell hinzugefügte Benutzer bleiben erhalten
- Benutzer werden nur aktualisiert, wenn sich `window.win_opcUaUsers` ändert
- Keine automatische Statusumschaltung mehr beim OPC-UA-Server-Button
Jetzt ist die OPC-UA Verwaltung sauber getrennt und stabil! 🚀
This commit is contained in:
76
redux/slices/opcuaSettingsSlice.ts
Normal file
76
redux/slices/opcuaSettingsSlice.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
// redux/slices/opcuaSettingsSlice.ts
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
interface OPCUAUser {
|
||||
id: number;
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
interface OPCUASettingsState {
|
||||
isEnabled: boolean;
|
||||
encryption: string;
|
||||
opcUaZustand: string;
|
||||
opcUaActiveClientCount: number;
|
||||
opcUaNodesetName: string;
|
||||
users: OPCUAUser[];
|
||||
}
|
||||
|
||||
const initialState: OPCUASettingsState = {
|
||||
isEnabled: true,
|
||||
encryption: "None",
|
||||
opcUaZustand: "Offline",
|
||||
opcUaActiveClientCount: 0,
|
||||
opcUaNodesetName: "DefaultNodeset",
|
||||
users: [
|
||||
{ id: 1, username: "admin", password: "admin123" },
|
||||
{ id: 2, username: "user1", password: "user123" },
|
||||
],
|
||||
};
|
||||
|
||||
const opcuaSettingsSlice = createSlice({
|
||||
name: "opcuaSettings",
|
||||
initialState,
|
||||
reducers: {
|
||||
toggleOpcUaServer(state) {
|
||||
state.isEnabled = !state.isEnabled;
|
||||
},
|
||||
setOpcUaEncryption(state, action: PayloadAction<string>) {
|
||||
state.encryption = action.payload;
|
||||
},
|
||||
setOpcUaZustand(state, action: PayloadAction<string>) {
|
||||
state.opcUaZustand = action.payload;
|
||||
},
|
||||
setOpcUaActiveClientCount(state, action: PayloadAction<number>) {
|
||||
state.opcUaActiveClientCount = action.payload;
|
||||
},
|
||||
setOpcUaNodesetName(state, action: PayloadAction<string>) {
|
||||
state.opcUaNodesetName = action.payload;
|
||||
},
|
||||
addOpcUaUser(
|
||||
state,
|
||||
action: PayloadAction<{ username: string; password: string }>
|
||||
) {
|
||||
const newUser = {
|
||||
id: state.users.length + 1,
|
||||
...action.payload,
|
||||
};
|
||||
state.users.push(newUser);
|
||||
},
|
||||
removeOpcUaUser(state, action: PayloadAction<number>) {
|
||||
state.users = state.users.filter((user) => user.id !== action.payload);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const {
|
||||
toggleOpcUaServer,
|
||||
setOpcUaEncryption,
|
||||
setOpcUaZustand,
|
||||
setOpcUaActiveClientCount,
|
||||
setOpcUaNodesetName,
|
||||
addOpcUaUser,
|
||||
removeOpcUaUser,
|
||||
} = opcuaSettingsSlice.actions;
|
||||
|
||||
export default opcuaSettingsSlice.reducer;
|
||||
@@ -8,6 +8,7 @@ import digitalInputsReducer from "./slices/digitalInputsSlice";
|
||||
import kabelueberwachungChartReducer from "./slices/kabelueberwachungChartSlice";
|
||||
import dashboardReducer from "./slices/dashboardSlice";
|
||||
import systemSettingsReducer from "./slices/systemSettingsSlice";
|
||||
import opcuaSettingsReducer from "./slices/opcuaSettingsSlice";
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
@@ -19,6 +20,7 @@ const store = configureStore({
|
||||
kabelueberwachungChart: kabelueberwachungChartReducer,
|
||||
dashboard: dashboardReducer,
|
||||
systemSettings: systemSettingsReducer,
|
||||
opcuaSettings: opcuaSettingsReducer,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user