Updates #3245. Squashed commit of the following: commit 32ca6e12f34e78ab51501f27609ed21fd5a1d1e7 Merge: b5cd0bee77c70193Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jun 29 17:06:50 2021 +0300 Merge branch 'master' into 3245-imp-dashboard commit b5cd0beea03d39a65f97922e3cdbc6af3e19ffdc Author: Ildar Kamalov <ik@adguard.com> Date: Tue Jun 29 16:16:45 2021 +0300 client: remove links from labels commit 3a3003aeed737819888a6974c878b88aa6abee38 Merge: 2dc1a5f890a85362Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jun 22 13:42:21 2021 +0300 Merge branch 'master' into 3245-imp-dashboard commit 2dc1a5f8b936c771cb0c7c26a529c824d0e445a2 Author: Ildar Kamalov <ik@adguard.com> Date: Fri Jun 11 19:24:12 2021 +0300 client: get response status from const commit 1bb9dc2abd6e9f2263fca09fed4d393f1969446c Merge:137dcb0512f1e4edAuthor: Ildar Kamalov <ik@adguard.com> Date: Fri Jun 11 19:08:24 2021 +0300 Merge branch 'master' into 3245-imp-dashboard commit137dcb058eAuthor: Mark Hicken <mhicken@adobe.com> Date: Tue Jun 8 15:05:17 2021 -0600 Add links to all the dashboard things
82 lines
3.1 KiB
JavaScript
82 lines
3.1 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Link } from 'react-router-dom';
|
|
import { withTranslation, Trans } from 'react-i18next';
|
|
|
|
import StatsCard from './StatsCard';
|
|
import { getPercent, normalizeHistory } from '../../helpers/helpers';
|
|
import { RESPONSE_FILTER } from '../../helpers/constants';
|
|
|
|
const getNormalizedHistory = (data, interval, id) => [
|
|
{ data: normalizeHistory(data, interval), id },
|
|
];
|
|
|
|
const Statistics = ({
|
|
interval,
|
|
dnsQueries,
|
|
blockedFiltering,
|
|
replacedSafebrowsing,
|
|
replacedParental,
|
|
numDnsQueries,
|
|
numBlockedFiltering,
|
|
numReplacedSafebrowsing,
|
|
numReplacedParental,
|
|
}) => (
|
|
<div className="row">
|
|
<div className="col-sm-6 col-lg-3">
|
|
<StatsCard
|
|
total={numDnsQueries}
|
|
lineData={getNormalizedHistory(dnsQueries, interval, 'dnsQuery')}
|
|
title={<Link to="logs"><Trans>dns_query</Trans></Link>}
|
|
color="blue"
|
|
/>
|
|
</div>
|
|
<div className="col-sm-6 col-lg-3">
|
|
<StatsCard
|
|
total={numBlockedFiltering}
|
|
lineData={getNormalizedHistory(blockedFiltering, interval, 'blockedFiltering')}
|
|
percent={getPercent(numDnsQueries, numBlockedFiltering)}
|
|
title={<Trans components={[<Link to={`logs?response_status=${RESPONSE_FILTER.BLOCKED.QUERY}`} key="0">link</Link>]}>blocked_by</Trans>}
|
|
color="red"
|
|
/>
|
|
</div>
|
|
<div className="col-sm-6 col-lg-3">
|
|
<StatsCard
|
|
total={numReplacedSafebrowsing}
|
|
lineData={getNormalizedHistory(
|
|
replacedSafebrowsing,
|
|
interval,
|
|
'replacedSafebrowsing',
|
|
)}
|
|
percent={getPercent(numDnsQueries, numReplacedSafebrowsing)}
|
|
title={<Link to={`logs?response_status=${RESPONSE_FILTER.BLOCKED_THREATS.QUERY}`}><Trans>stats_malware_phishing</Trans></Link>}
|
|
color="green"
|
|
/>
|
|
</div>
|
|
<div className="col-sm-6 col-lg-3">
|
|
<StatsCard
|
|
total={numReplacedParental}
|
|
lineData={getNormalizedHistory(replacedParental, interval, 'replacedParental')}
|
|
percent={getPercent(numDnsQueries, numReplacedParental)}
|
|
title={<Link to={`logs?response_status=${RESPONSE_FILTER.BLOCKED_ADULT_WEBSITES.QUERY}`}><Trans>stats_adult</Trans></Link>}
|
|
color="yellow"
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
|
|
Statistics.propTypes = {
|
|
interval: PropTypes.number.isRequired,
|
|
dnsQueries: PropTypes.array.isRequired,
|
|
blockedFiltering: PropTypes.array.isRequired,
|
|
replacedSafebrowsing: PropTypes.array.isRequired,
|
|
replacedParental: PropTypes.array.isRequired,
|
|
numDnsQueries: PropTypes.number.isRequired,
|
|
numBlockedFiltering: PropTypes.number.isRequired,
|
|
numReplacedSafebrowsing: PropTypes.number.isRequired,
|
|
numReplacedParental: PropTypes.number.isRequired,
|
|
refreshButton: PropTypes.node.isRequired,
|
|
};
|
|
|
|
export default withTranslation()(Statistics);
|