Merge pull request #27 in DNS/adguard-dns from feature/316 to master
* commit '0e173d2f705752c335c7fa78fdd5c578420e8a43': add progress bar and filters notifications
This commit is contained in:
commit
81c7dbbc16
|
@ -12895,6 +12895,15 @@
|
||||||
"prop-types": "^15.6.0"
|
"prop-types": "^15.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"react-redux-loading-bar": {
|
||||||
|
"version": "4.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-redux-loading-bar/-/react-redux-loading-bar-4.0.7.tgz",
|
||||||
|
"integrity": "sha512-jWq9HJ2BDdmvSEUmf1NzILxFYBRnel+HfYCX50OqNW8dnOVgYyzkHgNqVFBwigPWjDOIYh99eoGcl0kf2HGo/w==",
|
||||||
|
"requires": {
|
||||||
|
"prop-types": "^15.6.2",
|
||||||
|
"react-lifecycles-compat": "^3.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"react-router": {
|
"react-router": {
|
||||||
"version": "4.3.1",
|
"version": "4.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-4.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/react-router/-/react-router-4.3.1.tgz",
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
"react-dom": "^16.4.0",
|
"react-dom": "^16.4.0",
|
||||||
"react-modal": "^3.4.5",
|
"react-modal": "^3.4.5",
|
||||||
"react-redux": "^5.0.7",
|
"react-redux": "^5.0.7",
|
||||||
|
"react-redux-loading-bar": "^4.0.7",
|
||||||
"react-router-dom": "^4.2.2",
|
"react-router-dom": "^4.2.2",
|
||||||
"react-table": "^6.8.6",
|
"react-table": "^6.8.6",
|
||||||
"react-transition-group": "^2.4.0",
|
"react-transition-group": "^2.4.0",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { createAction } from 'redux-actions';
|
import { createAction } from 'redux-actions';
|
||||||
import round from 'lodash/round';
|
import round from 'lodash/round';
|
||||||
|
import { showLoading, hideLoading } from 'react-redux-loading-bar';
|
||||||
|
|
||||||
import { normalizeHistory, normalizeFilteringStatus, normalizeLogs } from '../helpers/helpers';
|
import { normalizeHistory, normalizeFilteringStatus, normalizeLogs } from '../helpers/helpers';
|
||||||
import Api from '../api/Api';
|
import Api from '../api/Api';
|
||||||
|
@ -212,13 +213,17 @@ export const toggleLogStatusSuccess = createAction('TOGGLE_LOGS_SUCCESS');
|
||||||
export const toggleLogStatus = queryLogEnabled => async (dispatch) => {
|
export const toggleLogStatus = queryLogEnabled => async (dispatch) => {
|
||||||
dispatch(toggleLogStatusRequest());
|
dispatch(toggleLogStatusRequest());
|
||||||
let toggleMethod;
|
let toggleMethod;
|
||||||
|
let successMessage;
|
||||||
if (queryLogEnabled) {
|
if (queryLogEnabled) {
|
||||||
toggleMethod = apiClient.disableQueryLog.bind(apiClient);
|
toggleMethod = apiClient.disableQueryLog.bind(apiClient);
|
||||||
|
successMessage = 'disabled';
|
||||||
} else {
|
} else {
|
||||||
toggleMethod = apiClient.enableQueryLog.bind(apiClient);
|
toggleMethod = apiClient.enableQueryLog.bind(apiClient);
|
||||||
|
successMessage = 'enabled';
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await toggleMethod();
|
await toggleMethod();
|
||||||
|
dispatch(addSuccessToast(`Query log ${successMessage}`));
|
||||||
dispatch(toggleLogStatusSuccess());
|
dispatch(toggleLogStatusSuccess());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(addErrorToast({ error }));
|
dispatch(addErrorToast({ error }));
|
||||||
|
@ -234,6 +239,7 @@ export const setRules = rules => async (dispatch) => {
|
||||||
dispatch(setRulesRequest());
|
dispatch(setRulesRequest());
|
||||||
try {
|
try {
|
||||||
await apiClient.setRules(rules);
|
await apiClient.setRules(rules);
|
||||||
|
dispatch(addSuccessToast('Custom rules saved'));
|
||||||
dispatch(setRulesSuccess());
|
dispatch(setRulesSuccess());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(addErrorToast({ error }));
|
dispatch(addErrorToast({ error }));
|
||||||
|
@ -288,13 +294,27 @@ export const refreshFiltersSuccess = createAction('FILTERING_REFRESH_SUCCESS');
|
||||||
|
|
||||||
export const refreshFilters = () => async (dispatch) => {
|
export const refreshFilters = () => async (dispatch) => {
|
||||||
dispatch(refreshFiltersRequest);
|
dispatch(refreshFiltersRequest);
|
||||||
|
dispatch(showLoading());
|
||||||
try {
|
try {
|
||||||
await apiClient.refreshFilters();
|
const refreshText = await apiClient.refreshFilters();
|
||||||
dispatch(refreshFiltersSuccess);
|
dispatch(refreshFiltersSuccess);
|
||||||
|
|
||||||
|
if (refreshText.includes('OK')) {
|
||||||
|
if (refreshText.includes('OK 0')) {
|
||||||
|
dispatch(addSuccessToast('All filters are already up-to-date'));
|
||||||
|
} else {
|
||||||
|
dispatch(addSuccessToast(refreshText.replace(/OK /g, '')));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dispatch(addErrorToast({ error: refreshText }));
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(getFilteringStatus());
|
dispatch(getFilteringStatus());
|
||||||
|
dispatch(hideLoading());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(addErrorToast({ error }));
|
dispatch(addErrorToast({ error }));
|
||||||
dispatch(refreshFiltersFailure());
|
dispatch(refreshFiltersFailure());
|
||||||
|
dispatch(hideLoading());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -378,6 +398,7 @@ export const setUpstream = url => async (dispatch) => {
|
||||||
dispatch(setUpstreamRequest());
|
dispatch(setUpstreamRequest());
|
||||||
try {
|
try {
|
||||||
await apiClient.setUpstream(url);
|
await apiClient.setUpstream(url);
|
||||||
|
dispatch(addSuccessToast('Upstream DNS servers saved'));
|
||||||
dispatch(setUpstreamSuccess());
|
dispatch(setUpstreamSuccess());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(addErrorToast({ error }));
|
dispatch(addErrorToast({ error }));
|
||||||
|
|
|
@ -17,3 +17,10 @@ body {
|
||||||
min-height: calc(100vh - 117px);
|
min-height: calc(100vh - 117px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loading-bar {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 103;
|
||||||
|
height: 3px;
|
||||||
|
background: linear-gradient(45deg, rgba(99, 125, 120, 1) 0%, rgba(88, 177, 101, 1) 100%);
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React, { Component, Fragment } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
import { HashRouter, Route } from 'react-router-dom';
|
import { HashRouter, Route } from 'react-router-dom';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import LoadingBar from 'react-redux-loading-bar';
|
||||||
|
|
||||||
import 'react-table/react-table.css';
|
import 'react-table/react-table.css';
|
||||||
import '../ui/Tabler.css';
|
import '../ui/Tabler.css';
|
||||||
|
@ -31,6 +32,7 @@ class App extends Component {
|
||||||
return (
|
return (
|
||||||
<HashRouter hashType='noslash'>
|
<HashRouter hashType='noslash'>
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
<LoadingBar className="loading-bar" updateTime={1000} />
|
||||||
<Route component={Header} />
|
<Route component={Header} />
|
||||||
<div className="container container--wrap">
|
<div className="container container--wrap">
|
||||||
{!dashboard.processing && !dashboard.isCoreRunning &&
|
{!dashboard.processing && !dashboard.isCoreRunning &&
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Dashboard extends Component {
|
||||||
this.props.getStats();
|
this.props.getStats();
|
||||||
this.props.getStatsHistory();
|
this.props.getStatsHistory();
|
||||||
this.props.getTopStats();
|
this.props.getTopStats();
|
||||||
};
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { dashboard } = this.props;
|
const { dashboard } = this.props;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { combineReducers } from 'redux';
|
import { combineReducers } from 'redux';
|
||||||
import { handleActions } from 'redux-actions';
|
import { handleActions } from 'redux-actions';
|
||||||
|
import { loadingBarReducer } from 'react-redux-loading-bar';
|
||||||
import nanoid from 'nanoid';
|
import nanoid from 'nanoid';
|
||||||
|
|
||||||
import * as actions from '../actions';
|
import * as actions from '../actions';
|
||||||
|
@ -207,4 +208,5 @@ export default combineReducers({
|
||||||
queryLogs,
|
queryLogs,
|
||||||
filtering,
|
filtering,
|
||||||
toasts,
|
toasts,
|
||||||
|
loadingBar: loadingBarReducer,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue