- client: request version after DNS status request

Closes #660
This commit is contained in:
Ildar Kamalov 2019-03-28 11:45:31 +03:00
parent fd82e7c26a
commit 6f2e852e09
2 changed files with 32 additions and 34 deletions

View File

@ -139,6 +139,36 @@ export const toggleProtection = status => async (dispatch) => {
} }
}; };
export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = () => async (dispatch) => {
dispatch(getVersionRequest());
try {
const newVersion = await apiClient.getGlobalVersion();
dispatch(getVersionSuccess(newVersion));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getVersionFailure());
}
};
export const getClientsRequest = createAction('GET_CLIENTS_REQUEST');
export const getClientsFailure = createAction('GET_CLIENTS_FAILURE');
export const getClientsSuccess = createAction('GET_CLIENTS_SUCCESS');
export const getClients = () => async (dispatch) => {
dispatch(getClientsRequest());
try {
const clients = await apiClient.getGlobalClients();
dispatch(getClientsSuccess(clients));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getClientsFailure());
}
};
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');
@ -148,6 +178,8 @@ export const getDnsStatus = () => async (dispatch) => {
try { try {
const dnsStatus = await apiClient.getGlobalStatus(); const dnsStatus = await apiClient.getGlobalStatus();
dispatch(dnsStatusSuccess(dnsStatus)); dispatch(dnsStatusSuccess(dnsStatus));
dispatch(getVersion());
dispatch(getClients());
} catch (error) { } catch (error) {
dispatch(addErrorToast({ error })); dispatch(addErrorToast({ error }));
dispatch(initSettingsFailure()); dispatch(initSettingsFailure());
@ -205,21 +237,6 @@ export const getStats = () => async (dispatch) => {
} }
}; };
export const getVersionRequest = createAction('GET_VERSION_REQUEST');
export const getVersionFailure = createAction('GET_VERSION_FAILURE');
export const getVersionSuccess = createAction('GET_VERSION_SUCCESS');
export const getVersion = () => async (dispatch) => {
dispatch(getVersionRequest());
try {
const newVersion = await apiClient.getGlobalVersion();
dispatch(getVersionSuccess(newVersion));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getVersionFailure());
}
};
export const getTopStatsRequest = createAction('GET_TOP_STATS_REQUEST'); export const getTopStatsRequest = createAction('GET_TOP_STATS_REQUEST');
export const getTopStatsFailure = createAction('GET_TOP_STATS_FAILURE'); export const getTopStatsFailure = createAction('GET_TOP_STATS_FAILURE');
export const getTopStatsSuccess = createAction('GET_TOP_STATS_SUCCESS'); export const getTopStatsSuccess = createAction('GET_TOP_STATS_SUCCESS');
@ -665,18 +682,3 @@ export const toggleDhcp = config => async (dispatch) => {
} }
} }
}; };
export const getClientsRequest = createAction('GET_CLIENTS_REQUEST');
export const getClientsFailure = createAction('GET_CLIENTS_FAILURE');
export const getClientsSuccess = createAction('GET_CLIENTS_SUCCESS');
export const getClients = () => async (dispatch) => {
dispatch(getClientsRequest());
try {
const clients = await apiClient.getGlobalClients();
dispatch(getClientsSuccess(clients));
} catch (error) {
dispatch(addErrorToast({ error }));
dispatch(getClientsFailure());
}
};

View File

@ -25,8 +25,6 @@ import i18n from '../../i18n';
class App extends Component { class App extends Component {
componentDidMount() { componentDidMount() {
this.props.getDnsStatus(); this.props.getDnsStatus();
this.props.getVersion();
this.props.getClients();
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
@ -106,10 +104,8 @@ App.propTypes = {
dashboard: PropTypes.object, dashboard: PropTypes.object,
isCoreRunning: PropTypes.bool, isCoreRunning: PropTypes.bool,
error: PropTypes.string, error: PropTypes.string,
getVersion: PropTypes.func,
changeLanguage: PropTypes.func, changeLanguage: PropTypes.func,
encryption: PropTypes.object, encryption: PropTypes.object,
getClients: PropTypes.func,
}; };
export default withNamespaces()(App); export default withNamespaces()(App);