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:
Ismail Ali
2025-02-23 11:06:15 +01:00
parent b85c8c67e2
commit 772ef50af5
6 changed files with 256 additions and 62 deletions

View 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;

View File

@@ -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,
},
});