+ 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 dnsStatusFailure = createAction('DNS_STATUS_FAILURE');
|
||||
export const dnsStatusSuccess = createAction('DNS_STATUS_SUCCESS');
|
||||
|
@ -224,6 +239,7 @@ export const getDnsStatus = () => async (dispatch) => {
|
|||
dispatch(dnsStatusSuccess(dnsStatus));
|
||||
dispatch(getVersion());
|
||||
dispatch(getTlsStatus());
|
||||
dispatch(getProfile());
|
||||
} catch (error) {
|
||||
dispatch(addErrorToast({ error }));
|
||||
dispatch(dnsStatusFailure());
|
||||
|
|
|
@ -525,6 +525,14 @@ class Api {
|
|||
};
|
||||
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();
|
||||
|
|
|
@ -60,9 +60,11 @@ class Header extends Component {
|
|||
/>
|
||||
<div className="header__column">
|
||||
<div className="header__right">
|
||||
{!dashboard.processingProfile && dashboard.name &&
|
||||
<a href="/control/logout" className="btn btn-sm btn-outline-secondary">
|
||||
<Trans>sign_out</Trans>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -189,6 +189,14 @@ const dashboard = handleActions(
|
|||
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,
|
||||
|
@ -198,6 +206,7 @@ const dashboard = handleActions(
|
|||
processingClients: true,
|
||||
processingUpdate: false,
|
||||
processingDnsSettings: true,
|
||||
processingProfile: true,
|
||||
upstreamDns: '',
|
||||
bootstrapDns: '',
|
||||
allServers: false,
|
||||
|
@ -209,6 +218,7 @@ const dashboard = handleActions(
|
|||
dnsVersion: '',
|
||||
clients: [],
|
||||
autoClients: [],
|
||||
name: '',
|
||||
},
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue