- client: add setDnsRunningStatus action
This commit is contained in:
parent
39640d8190
commit
7fade498b9
|
@ -233,6 +233,7 @@ export const getProfile = () => async (dispatch) => {
|
|||
export const dnsStatusRequest = createAction('DNS_STATUS_REQUEST');
|
||||
export const dnsStatusFailure = createAction('DNS_STATUS_FAILURE');
|
||||
export const dnsStatusSuccess = createAction('DNS_STATUS_SUCCESS');
|
||||
export const setDnsRunningStatus = createAction('SET_DNS_RUNNING_STATUS');
|
||||
|
||||
export const getDnsStatus = () => async (dispatch) => {
|
||||
dispatch(dnsStatusRequest());
|
||||
|
@ -242,14 +243,17 @@ export const getDnsStatus = () => async (dispatch) => {
|
|||
dispatch(dnsStatusFailure());
|
||||
window.location.reload(true);
|
||||
};
|
||||
|
||||
const handleRequestSuccess = (response) => {
|
||||
const dnsStatus = response.data;
|
||||
if (dnsStatus) {
|
||||
const { running } = dnsStatus;
|
||||
const runningStatus = dnsStatus && running;
|
||||
if (runningStatus === true) {
|
||||
dispatch(dnsStatusSuccess(dnsStatus));
|
||||
dispatch(getVersion());
|
||||
dispatch(getTlsStatus());
|
||||
dispatch(getProfile());
|
||||
} else {
|
||||
dispatch(setDnsRunningStatus(running));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -58,12 +58,13 @@ const settings = handleActions(
|
|||
|
||||
const dashboard = handleActions(
|
||||
{
|
||||
[actions.setDnsRunningStatus]: (state, { payload }) =>
|
||||
({ ...state, isCoreRunning: payload }),
|
||||
[actions.dnsStatusRequest]: state => ({ ...state, processing: true }),
|
||||
[actions.dnsStatusFailure]: state => ({ ...state, processing: false }),
|
||||
[actions.dnsStatusSuccess]: (state, { payload }) => {
|
||||
const {
|
||||
version,
|
||||
running,
|
||||
dns_port: dnsPort,
|
||||
dns_addresses: dnsAddresses,
|
||||
upstream_dns: upstreamDns,
|
||||
|
@ -75,7 +76,7 @@ const dashboard = handleActions(
|
|||
} = payload;
|
||||
const newState = {
|
||||
...state,
|
||||
isCoreRunning: running,
|
||||
isCoreRunning: true,
|
||||
processing: false,
|
||||
dnsVersion: version,
|
||||
dnsPort,
|
||||
|
|
Loading…
Reference in New Issue