2017-08-18 21:30:16 +00:00
|
|
|
import { SERVER } from '../actions/actionsTypes';
|
|
|
|
|
2017-09-01 19:42:50 +00:00
|
|
|
const initialState = {
|
|
|
|
connecting: false,
|
|
|
|
connected: false,
|
|
|
|
errorMessage: '',
|
|
|
|
failure: false,
|
2018-04-24 19:34:03 +00:00
|
|
|
server: '',
|
2018-08-01 19:35:06 +00:00
|
|
|
adding: false,
|
|
|
|
loading: true
|
2017-09-01 19:42:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default function server(state = initialState, action) {
|
2017-08-18 21:30:16 +00:00
|
|
|
switch (action.type) {
|
2017-09-01 19:42:50 +00:00
|
|
|
case SERVER.REQUEST:
|
2017-11-13 12:58:35 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-09-01 19:42:50 +00:00
|
|
|
connecting: true,
|
|
|
|
failure: false
|
|
|
|
};
|
|
|
|
case SERVER.SUCCESS:
|
2017-11-13 12:58:35 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-09-01 19:42:50 +00:00
|
|
|
connecting: false,
|
|
|
|
connected: true,
|
|
|
|
failure: false
|
|
|
|
};
|
|
|
|
case SERVER.FAILURE:
|
2017-11-13 12:58:35 +00:00
|
|
|
return {
|
|
|
|
...state,
|
2017-09-01 19:42:50 +00:00
|
|
|
connecting: false,
|
|
|
|
connected: false,
|
|
|
|
failure: true,
|
|
|
|
errorMessage: action.err
|
|
|
|
};
|
2018-04-24 19:34:03 +00:00
|
|
|
case SERVER.ADD:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
adding: true
|
|
|
|
};
|
2018-08-01 19:35:06 +00:00
|
|
|
case SERVER.SELECT_REQUEST:
|
2018-04-24 19:34:03 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
server: action.server,
|
2018-08-01 19:35:06 +00:00
|
|
|
loading: true
|
|
|
|
};
|
|
|
|
case SERVER.SELECT_SUCCESS:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
server: action.server,
|
|
|
|
adding: false,
|
|
|
|
loading: false
|
2018-04-24 19:34:03 +00:00
|
|
|
};
|
2017-08-18 21:30:16 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|