+ client: get profile info
This commit is contained in:
parent
0ede2b13c9
commit
2a2647dc3f
|
@ -213,6 +213,21 @@ export const getClients = () => async (dispatch) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getProfileRequest = createAction('GET_PROFILE_REQUEST');
|
||||||
|
export const getProfileFailure = createAction('GET_PROFILE_FAILURE');
|
||||||
|
export const getProfileSuccess = createAction('GET_PROFILE_SUCCESS');
|
||||||
|
|
||||||
|
export const getProfile = () => async (dispatch) => {
|
||||||
|
dispatch(getProfileRequest());
|
||||||
|
try {
|
||||||
|
const profile = await apiClient.getProfile();
|
||||||
|
dispatch(getProfileSuccess(profile));
|
||||||
|
} catch (error) {
|
||||||
|
dispatch(addErrorToast({ error }));
|
||||||
|
dispatch(getProfileFailure());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const dnsStatusRequest = createAction('DNS_STATUS_REQUEST');
|
export const dnsStatusRequest = createAction('DNS_STATUS_REQUEST');
|
||||||
export const dnsStatusFailure = createAction('DNS_STATUS_FAILURE');
|
export const dnsStatusFailure = createAction('DNS_STATUS_FAILURE');
|
||||||
export const dnsStatusSuccess = createAction('DNS_STATUS_SUCCESS');
|
export const dnsStatusSuccess = createAction('DNS_STATUS_SUCCESS');
|
||||||
|
@ -224,6 +239,7 @@ export const getDnsStatus = () => async (dispatch) => {
|
||||||
dispatch(dnsStatusSuccess(dnsStatus));
|
dispatch(dnsStatusSuccess(dnsStatus));
|
||||||
dispatch(getVersion());
|
dispatch(getVersion());
|
||||||
dispatch(getTlsStatus());
|
dispatch(getTlsStatus());
|
||||||
|
dispatch(getProfile());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(addErrorToast({ error }));
|
dispatch(addErrorToast({ error }));
|
||||||
dispatch(dnsStatusFailure());
|
dispatch(dnsStatusFailure());
|
||||||
|
|
|
@ -525,6 +525,14 @@ class Api {
|
||||||
};
|
};
|
||||||
return this.makeRequest(path, method, config);
|
return this.makeRequest(path, method, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Profile
|
||||||
|
GET_PROFILE = { path: 'profile', method: 'GET' };
|
||||||
|
|
||||||
|
getProfile() {
|
||||||
|
const { path, method } = this.GET_PROFILE;
|
||||||
|
return this.makeRequest(path, method);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiClient = new Api();
|
const apiClient = new Api();
|
||||||
|
|
|
@ -60,9 +60,11 @@ class Header extends Component {
|
||||||
/>
|
/>
|
||||||
<div className="header__column">
|
<div className="header__column">
|
||||||
<div className="header__right">
|
<div className="header__right">
|
||||||
|
{!dashboard.processingProfile && dashboard.name &&
|
||||||
<a href="/control/logout" className="btn btn-sm btn-outline-secondary">
|
<a href="/control/logout" className="btn btn-sm btn-outline-secondary">
|
||||||
<Trans>sign_out</Trans>
|
<Trans>sign_out</Trans>
|
||||||
</a>
|
</a>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -189,6 +189,14 @@ const dashboard = handleActions(
|
||||||
processingDnsSettings: false,
|
processingDnsSettings: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
[actions.getProfileRequest]: state => ({ ...state, processingProfile: true }),
|
||||||
|
[actions.getProfileFailure]: state => ({ ...state, processingProfile: false }),
|
||||||
|
[actions.getProfileSuccess]: (state, { payload }) => ({
|
||||||
|
...state,
|
||||||
|
name: payload.name,
|
||||||
|
processingProfile: false,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
processing: true,
|
processing: true,
|
||||||
|
@ -198,6 +206,7 @@ const dashboard = handleActions(
|
||||||
processingClients: true,
|
processingClients: true,
|
||||||
processingUpdate: false,
|
processingUpdate: false,
|
||||||
processingDnsSettings: true,
|
processingDnsSettings: true,
|
||||||
|
processingProfile: true,
|
||||||
upstreamDns: '',
|
upstreamDns: '',
|
||||||
bootstrapDns: '',
|
bootstrapDns: '',
|
||||||
allServers: false,
|
allServers: false,
|
||||||
|
@ -209,6 +218,7 @@ const dashboard = handleActions(
|
||||||
dnsVersion: '',
|
dnsVersion: '',
|
||||||
clients: [],
|
clients: [],
|
||||||
autoClients: [],
|
autoClients: [],
|
||||||
|
name: '',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue