re commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
const dialogReducer = (state = [], action) => {
|
||||
switch(action.type) {
|
||||
case 'dialog_addmsg':
|
||||
return [...state, {
|
||||
msg: action.msg,
|
||||
act: action.act || null
|
||||
}];
|
||||
case 'dialog_remove_first':
|
||||
return state.slice(1);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export default dialogReducer;
|
||||
@@ -0,0 +1,10 @@
|
||||
const i18nReducer = (state = {}, action) => {
|
||||
switch(action.type) {
|
||||
case 'i18n_set_ctx':
|
||||
return action.i18n;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export default i18nReducer;
|
||||
@@ -0,0 +1,16 @@
|
||||
import {combineReducers} from 'redux';
|
||||
import dialog from './dialog';
|
||||
import i18n from './i18n';
|
||||
import ui from './ui';
|
||||
import sysinfo from './sysinfo';
|
||||
import lists from './lists';
|
||||
|
||||
const reducers = combineReducers({
|
||||
dialog,
|
||||
i18n,
|
||||
ui,
|
||||
sysinfo,
|
||||
lists
|
||||
});
|
||||
|
||||
export default reducers;
|
||||
@@ -0,0 +1,214 @@
|
||||
const getDefaultState = () => ({
|
||||
user: [],
|
||||
dio: {
|
||||
di: [],
|
||||
do: [],
|
||||
diSt: {},
|
||||
doSt: {}
|
||||
},
|
||||
log: {
|
||||
list: [],
|
||||
page: {}
|
||||
},
|
||||
leone: {
|
||||
scanList: [],
|
||||
list: [],
|
||||
status: [],
|
||||
scanning: false
|
||||
},
|
||||
iogroup: {
|
||||
list: [],
|
||||
do: [],
|
||||
leone: []
|
||||
},
|
||||
schedule: {
|
||||
list: [],
|
||||
do: [],
|
||||
leone: [],
|
||||
iogroup: []
|
||||
},
|
||||
modbus: {
|
||||
list: []
|
||||
},
|
||||
link: {
|
||||
list: []
|
||||
},
|
||||
selectdev: []
|
||||
})
|
||||
|
||||
const listsReducer = (state = getDefaultState(), action) => {
|
||||
switch (action.type) {
|
||||
case 'user_list':
|
||||
return {...state, user: action.user };
|
||||
case 'clear_user_list':
|
||||
return {...state, user: [] };
|
||||
case 'dio_list':
|
||||
return {...state,
|
||||
dio: {
|
||||
...state.dio,
|
||||
di: action.di,
|
||||
do: action.do
|
||||
}
|
||||
};
|
||||
case 'dio_status':
|
||||
return {...state,
|
||||
dio: {
|
||||
...state.dio,
|
||||
diSt: action.diSt,
|
||||
doSt: action.doSt
|
||||
}
|
||||
};
|
||||
case 'clear_dio':
|
||||
return {...state, dio: {...getDefaultState().dio } };
|
||||
case 'log_list':
|
||||
return {...state,
|
||||
log: {
|
||||
list: action.list,
|
||||
page: action.page
|
||||
}
|
||||
};
|
||||
case 'clear_log':
|
||||
return {...state, log: {...getDefaultState().log } };
|
||||
case 'leone_list':
|
||||
return {
|
||||
...state,
|
||||
leone: {
|
||||
...state.leone,
|
||||
list: action.list,
|
||||
status: action.status
|
||||
}
|
||||
};
|
||||
case 'leone_scanning':
|
||||
return {
|
||||
...state,
|
||||
leone: {
|
||||
...state.leone,
|
||||
scanning: true
|
||||
}
|
||||
}
|
||||
case 'leone_scan':
|
||||
return {
|
||||
...state,
|
||||
leone: {
|
||||
...state.leone,
|
||||
scanList: action.list,
|
||||
scanning: false
|
||||
}
|
||||
};
|
||||
case 'leone_clear_scan':
|
||||
return {
|
||||
...state,
|
||||
leone: {
|
||||
...state.leone,
|
||||
scanList: []
|
||||
}
|
||||
}
|
||||
case 'clear_leone':
|
||||
return {...state, leone: {...getDefaultState().leone } };
|
||||
case 'iogroup_list':
|
||||
return {
|
||||
...state,
|
||||
iogroup: {
|
||||
...state.iogroup,
|
||||
list: action.list,
|
||||
do: action.do,
|
||||
leone: action.leone
|
||||
}
|
||||
};
|
||||
case 'clear_iogroup':
|
||||
return {...state, iogroup: {...getDefaultState().iogroup } };
|
||||
case 'select_list':
|
||||
return {
|
||||
...state,
|
||||
selectdev: action.list
|
||||
};
|
||||
case 'clear_select_list':
|
||||
return {
|
||||
...state,
|
||||
selectdev: []
|
||||
};
|
||||
case 'schedule_list':
|
||||
return {
|
||||
...state,
|
||||
schedule: {
|
||||
list: action.list,
|
||||
do: action.dos,
|
||||
leone: action.les,
|
||||
iogroup: action.ios
|
||||
}
|
||||
};
|
||||
case 'clear_schedule':
|
||||
return {...state,
|
||||
schedule: {
|
||||
...getDefaultState().schedule
|
||||
}
|
||||
}
|
||||
case 'modbus_list':
|
||||
return {...state, modbus:{
|
||||
...state.modbus,
|
||||
list: action.list
|
||||
}}
|
||||
case 'mb_data':
|
||||
return {
|
||||
...state,
|
||||
modbus: {
|
||||
list: state.modbus.list.map(t=> mb_data(t, action))
|
||||
}
|
||||
}
|
||||
case 'mb_iostatus':
|
||||
return {
|
||||
...state,
|
||||
modbus: {
|
||||
list: state.modbus.list.map(t=> mb_data(t, action))
|
||||
}
|
||||
}
|
||||
case 'clear_modbus':
|
||||
return {...state, modbus: {...getDefaultState().modbus}};
|
||||
case 'link_list':
|
||||
return {
|
||||
...state,
|
||||
link: {
|
||||
list: action.list
|
||||
}
|
||||
}
|
||||
case 'clear_link':
|
||||
return {
|
||||
...state,
|
||||
link:{
|
||||
...getDefaultState().link
|
||||
}
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
function mb_data(state = {}, action){
|
||||
switch(action.type){
|
||||
case 'mb_data':
|
||||
if(action.id != state.uid) return state;
|
||||
return {
|
||||
...state,
|
||||
iolist: action.iolist || [],
|
||||
aioset: action.aioset || []
|
||||
};
|
||||
case 'mb_iostatus':
|
||||
if(action.id != state.uid) return state;
|
||||
let json = {};
|
||||
json[action.iotype] = action.list;
|
||||
return {
|
||||
...state,
|
||||
status: {
|
||||
...(state.status || {}),
|
||||
...json
|
||||
}
|
||||
};
|
||||
default:
|
||||
return {
|
||||
...state,
|
||||
iolist: state.iolist || []
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default listsReducer;
|
||||
@@ -0,0 +1,15 @@
|
||||
const sysinfoReducer = (state = {
|
||||
network: {},
|
||||
time: ''
|
||||
}, action) => {
|
||||
switch(action.type) {
|
||||
case 'network_info':
|
||||
return {...state, network: action.network};
|
||||
case 'system_time':
|
||||
return {...state, time: action.time || ''};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export default sysinfoReducer;
|
||||
@@ -0,0 +1,19 @@
|
||||
const uiReducer = (state = {
|
||||
showMenu: false,
|
||||
showLoading: false
|
||||
}, action) => {
|
||||
switch (action.type) {
|
||||
case 'ui_show_menu':
|
||||
return {...state, showMenu: true };
|
||||
case 'ui_hide_menu':
|
||||
return {...state, showMenu: false };
|
||||
case 'ui_show_loading':
|
||||
return {...state, showLoading: true};
|
||||
case 'ui_hide_loading':
|
||||
return {...state, showLoading: false};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export default uiReducer;
|
||||
Reference in New Issue
Block a user