63 lines
1.2 KiB
JavaScript
63 lines
1.2 KiB
JavaScript
// store/variablesSlice.js
|
|
import { createSlice } from "@reduxjs/toolkit";
|
|
|
|
const initialState = {
|
|
last20Messages: null,
|
|
deviceName: null,
|
|
mac1: null,
|
|
mac2: null,
|
|
ip: null,
|
|
subnet: null,
|
|
gateway: null,
|
|
datetime: null,
|
|
ntp1: null,
|
|
ntp2: null,
|
|
ntp3: null,
|
|
de: null,
|
|
counter: null,
|
|
flutter: null,
|
|
kueOnline: [],
|
|
kueID: [],
|
|
kueIso: [],
|
|
kueAlarm1: [],
|
|
kueAlarm2: [],
|
|
kueRes: [],
|
|
kueCableBreak: [],
|
|
kueGroundFault: [],
|
|
kueLimit1: null,
|
|
kueLimit2Low: null,
|
|
kueDelay1: null,
|
|
kueLoopInterval: null,
|
|
kueVersion: null,
|
|
tdrAtten: null,
|
|
tdrPulse: null,
|
|
tdrSpeed: null,
|
|
tdrAmp: null,
|
|
tdrTrigger: null,
|
|
tdrLocation: null,
|
|
tdrActive: null,
|
|
kueOverflow: null,
|
|
kueResidence: null,
|
|
tdrLast: null,
|
|
appVersion: null,
|
|
};
|
|
|
|
const variablesSlice = createSlice({
|
|
name: "variables",
|
|
initialState,
|
|
reducers: {
|
|
setVariable(state, action) {
|
|
const { key, value } = action.payload;
|
|
state[key] = value;
|
|
},
|
|
setVariables(state, action) {
|
|
Object.entries(action.payload).forEach(([key, value]) => {
|
|
state[key] = value;
|
|
});
|
|
},
|
|
},
|
|
});
|
|
|
|
export const { setVariable, setVariables } = variablesSlice.actions;
|
|
export default variablesSlice.reducer;
|