Merge: - client: block/unblock client without requesting stats

Closes #896

Squashed commit of the following:

commit 66b781438aa668a16b19455c3e0dc5100417d869
Author: Ildar Kamalov <i.kamalov@adguard.com>
Date:   Mon Feb 3 12:59:25 2020 +0300

    - client: block/unblock client without requesting stats

commit e70f62738d549e32339bae3d5e996a912b99c21d
Author: Ildar Kamalov <i.kamalov@adguard.com>
Date:   Mon Feb 3 12:22:13 2020 +0300

    - client: get current access settings before set

commit 65c59d1d55f3255f33f917b61b6ab2c6c2e54271
Author: Ildar Kamalov <i.kamalov@adguard.com>
Date:   Mon Feb 3 12:21:12 2020 +0300

    * client: mode svg-url-loader to devDependencies
This commit is contained in:
Ildar Kamalov
2020-02-04 15:48:07 +03:00
parent d4069f824a
commit a5c2ad1b2f
8 changed files with 63 additions and 45 deletions

View File

@@ -57,10 +57,12 @@ const renderBlockingButton = (blocked, ip, handleClick, processing) => {
);
};
const clientCell = (t, toggleClientStatus, processing) =>
const isBlockedClient = (clients, ip) => !!(clients && clients.includes(ip));
const clientCell = (t, toggleClientStatus, processing, disallowedClients) =>
function cell(row) {
const { original, value } = row;
const { blocked } = original;
const { value } = row;
const blocked = isBlockedClient(disallowedClients, value);
return (
<Fragment>
@@ -80,6 +82,7 @@ const Clients = ({
dnsQueries,
toggleClientStatus,
processingAccessSet,
disallowedClients,
}) => (
<Card
title={t('top_clients')}
@@ -102,7 +105,7 @@ const Clients = ({
accessor: 'ip',
sortMethod: (a, b) =>
parseInt(a.replace(/\./g, ''), 10) - parseInt(b.replace(/\./g, ''), 10),
Cell: clientCell(t, toggleClientStatus, processingAccessSet),
Cell: clientCell(t, toggleClientStatus, processingAccessSet, disallowedClients),
},
{
Header: <Trans>requests_count</Trans>,
@@ -122,9 +125,9 @@ const Clients = ({
return {};
}
const { blocked } = rowInfo.original;
const { ip } = rowInfo.original;
if (blocked) {
if (isBlockedClient(disallowedClients, ip)) {
return {
className: 'red',
};
@@ -148,6 +151,7 @@ Clients.propTypes = {
t: PropTypes.func.isRequired,
toggleClientStatus: PropTypes.func.isRequired,
processingAccessSet: PropTypes.bool.isRequired,
disallowedClients: PropTypes.string.isRequired,
};
export default withNamespaces()(Clients);

View File

@@ -19,6 +19,7 @@ class Dashboard extends Component {
}
getAllStats = () => {
this.props.getAccessList();
this.props.getStats();
this.props.getStatsConfig();
};
@@ -53,7 +54,8 @@ class Dashboard extends Component {
dashboard, stats, access, t,
} = this.props;
const statsProcessing = stats.processingStats
|| stats.processingGetConfig;
|| stats.processingGetConfig
|| access.processing;
const subtitle =
stats.interval === 1
@@ -130,6 +132,7 @@ class Dashboard extends Component {
refreshButton={refreshButton}
toggleClientStatus={this.toggleClientStatus}
processingAccessSet={access.processingSet}
disallowedClients={access.disallowed_clients}
/>
</div>
<div className="col-lg-6">