+ client: handle time interval for statistics

This commit is contained in:
Ildar Kamalov
2019-08-08 13:43:06 +03:00
parent 7ff27dbb42
commit 011bc3e36b
11 changed files with 251 additions and 4 deletions

View File

@@ -11,6 +11,7 @@ import clients from './clients';
import access from './access';
import rewrites from './rewrites';
import services from './services';
import stats from './stats';
const settings = handleActions({
[actions.initSettingsRequest]: state => ({ ...state, processing: true }),
@@ -218,6 +219,14 @@ const dashboard = handleActions({
clients: [],
autoClients: [],
topStats: [],
stats: {
dns_queries: '',
blocked_filtering: '',
replaced_safebrowsing: '',
replaced_parental: '',
replaced_safesearch: '',
avg_processing_time: '',
},
});
const queryLogs = handleActions({
@@ -230,7 +239,11 @@ const queryLogs = handleActions({
[actions.downloadQueryLogRequest]: state => ({ ...state, logsDownloading: true }),
[actions.downloadQueryLogFailure]: state => ({ ...state, logsDownloading: false }),
[actions.downloadQueryLogSuccess]: state => ({ ...state, logsDownloading: false }),
}, { getLogsProcessing: false, logsDownloading: false });
}, {
getLogsProcessing: false,
logsDownloading: false,
logs: [],
});
const filtering = handleActions({
[actions.setRulesRequest]: state => ({ ...state, processingRules: true }),
@@ -426,6 +439,7 @@ export default combineReducers({
access,
rewrites,
services,
stats,
loadingBar: loadingBarReducer,
form: formReducer,
});

View File

@@ -0,0 +1,27 @@
import { handleActions } from 'redux-actions';
import * as actions from '../actions/stats';
const stats = handleActions({
[actions.getStatsConfigRequest]: state => ({ ...state, getConfigProcessing: true }),
[actions.getStatsConfigFailure]: state => ({ ...state, getConfigProcessing: false }),
[actions.getStatsConfigSuccess]: (state, { payload }) => ({
...state,
interval: payload.interval,
getConfigProcessing: false,
}),
[actions.setStatsConfigRequest]: state => ({ ...state, setConfigProcessing: true }),
[actions.setStatsConfigFailure]: state => ({ ...state, setConfigProcessing: false }),
[actions.setStatsConfigSuccess]: (state, { payload }) => ({
...state,
interval: payload.interval,
setConfigProcessing: false,
}),
}, {
getConfigProcessing: false,
setConfigProcessing: false,
interval: 1,
});
export default stats;