+ client: handle the new statistics format
This commit is contained in:
@@ -94,27 +94,6 @@ const dashboard = handleActions({
|
||||
return newState;
|
||||
},
|
||||
|
||||
[actions.getStatsRequest]: state => ({ ...state, processingStats: true }),
|
||||
[actions.getStatsFailure]: state => ({ ...state, processingStats: false }),
|
||||
[actions.getStatsSuccess]: (state, { payload }) => {
|
||||
const newState = { ...state, stats: payload, processingStats: false };
|
||||
return newState;
|
||||
},
|
||||
|
||||
[actions.getTopStatsRequest]: state => ({ ...state, processingTopStats: true }),
|
||||
[actions.getTopStatsFailure]: state => ({ ...state, processingTopStats: false }),
|
||||
[actions.getTopStatsSuccess]: (state, { payload }) => {
|
||||
const newState = { ...state, topStats: payload, processingTopStats: false };
|
||||
return newState;
|
||||
},
|
||||
|
||||
[actions.getStatsHistoryRequest]: state => ({ ...state, processingStatsHistory: true }),
|
||||
[actions.getStatsHistoryFailure]: state => ({ ...state, processingStatsHistory: false }),
|
||||
[actions.getStatsHistorySuccess]: (state, { payload }) => {
|
||||
const newState = { ...state, statsHistory: payload, processingStatsHistory: false };
|
||||
return newState;
|
||||
},
|
||||
|
||||
[actions.toggleLogStatusRequest]: state => ({ ...state, logStatusProcessing: true }),
|
||||
[actions.toggleLogStatusFailure]: state => ({ ...state, logStatusProcessing: false }),
|
||||
[actions.toggleLogStatusSuccess]: (state) => {
|
||||
@@ -200,8 +179,6 @@ const dashboard = handleActions({
|
||||
}, {
|
||||
processing: true,
|
||||
isCoreRunning: false,
|
||||
processingTopStats: true,
|
||||
processingStats: true,
|
||||
logStatusProcessing: false,
|
||||
processingVersion: true,
|
||||
processingFiltering: true,
|
||||
@@ -218,15 +195,6 @@ const dashboard = handleActions({
|
||||
dnsVersion: '',
|
||||
clients: [],
|
||||
autoClients: [],
|
||||
topStats: [],
|
||||
stats: {
|
||||
dns_queries: '',
|
||||
blocked_filtering: '',
|
||||
replaced_safebrowsing: '',
|
||||
replaced_parental: '',
|
||||
replaced_safesearch: '',
|
||||
avg_processing_time: '',
|
||||
},
|
||||
});
|
||||
|
||||
const queryLogs = handleActions({
|
||||
|
||||
@@ -2,26 +2,83 @@ 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,
|
||||
}),
|
||||
const stats = handleActions(
|
||||
{
|
||||
[actions.getStatsConfigRequest]: state => ({ ...state, processingGetConfig: true }),
|
||||
[actions.getStatsConfigFailure]: state => ({ ...state, processingGetConfig: false }),
|
||||
[actions.getStatsConfigSuccess]: (state, { payload }) => ({
|
||||
...state,
|
||||
interval: payload.interval,
|
||||
processingGetConfig: 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,
|
||||
});
|
||||
[actions.setStatsConfigRequest]: state => ({ ...state, processingSetConfig: true }),
|
||||
[actions.setStatsConfigFailure]: state => ({ ...state, processingSetConfig: false }),
|
||||
[actions.setStatsConfigSuccess]: (state, { payload }) => ({
|
||||
...state,
|
||||
interval: payload.interval,
|
||||
processingSetConfig: false,
|
||||
}),
|
||||
|
||||
[actions.getStatsRequest]: state => ({ ...state, processingStats: true }),
|
||||
[actions.getStatsFailure]: state => ({ ...state, processingStats: false }),
|
||||
[actions.getStatsSuccess]: (state, { payload }) => {
|
||||
const {
|
||||
dns_queries: dnsQueries,
|
||||
blocked_filtering: blockedFiltering,
|
||||
replaced_parental: replacedParental,
|
||||
replaced_safebrowsing: replacedSafebrowsing,
|
||||
top_blocked_domains: topBlockedDomains,
|
||||
top_clients: topClients,
|
||||
top_queried_domains: topQueriedDomains,
|
||||
num_blocked_filtering: numBlockedFiltering,
|
||||
num_dns_queries: numDnsQueries,
|
||||
num_replaced_parental: numReplacedParental,
|
||||
num_replaced_safebrowsing: numReplacedSafebrowsing,
|
||||
num_replaced_safesearch: numReplacedSafesearch,
|
||||
avg_processing_time: avgProcessingTime,
|
||||
} = payload;
|
||||
|
||||
const newState = {
|
||||
...state,
|
||||
processingStats: false,
|
||||
dnsQueries,
|
||||
blockedFiltering,
|
||||
replacedParental,
|
||||
replacedSafebrowsing,
|
||||
topBlockedDomains,
|
||||
topClients,
|
||||
topQueriedDomains,
|
||||
numBlockedFiltering,
|
||||
numDnsQueries,
|
||||
numReplacedParental,
|
||||
numReplacedSafebrowsing,
|
||||
numReplacedSafesearch,
|
||||
avgProcessingTime,
|
||||
};
|
||||
|
||||
return newState;
|
||||
},
|
||||
},
|
||||
{
|
||||
processingGetConfig: false,
|
||||
processingSetConfig: false,
|
||||
processingStats: true,
|
||||
interval: 1,
|
||||
dnsQueries: [],
|
||||
blockedFiltering: [],
|
||||
replacedParental: [],
|
||||
replacedSafebrowsing: [],
|
||||
topBlockedDomains: [],
|
||||
topClients: [],
|
||||
topQueriedDomains: [],
|
||||
numBlockedFiltering: 0,
|
||||
numDnsQueries: 0,
|
||||
numReplacedParental: 0,
|
||||
numReplacedSafebrowsing: 0,
|
||||
numReplacedSafesearch: 0,
|
||||
avgProcessingTime: 0,
|
||||
},
|
||||
);
|
||||
|
||||
export default stats;
|
||||
|
||||
Reference in New Issue
Block a user