2019-08-27 13:43:58 +00:00
|
|
|
import React from 'react';
|
2018-08-30 14:25:33 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2019-08-27 13:43:58 +00:00
|
|
|
import { withNamespaces, Trans } from 'react-i18next';
|
2018-08-30 14:25:33 +00:00
|
|
|
|
2019-08-27 13:43:58 +00:00
|
|
|
import StatsCard from './StatsCard';
|
2019-08-22 13:10:47 +00:00
|
|
|
import { getPercent, normalizeHistory } from '../../helpers/helpers';
|
|
|
|
|
2019-08-27 13:43:58 +00:00
|
|
|
const getNormalizedHistory = (data, interval, id) => [
|
|
|
|
{ data: normalizeHistory(data, interval), id },
|
|
|
|
];
|
2018-10-12 12:23:21 +00:00
|
|
|
|
2019-08-27 13:43:58 +00:00
|
|
|
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={<Trans>dns_query</Trans>}
|
|
|
|
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={[<a href="#filters" key="0">link</a>]}>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={<Trans>stats_malware_phishing</Trans>}
|
|
|
|
color="green"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="col-sm-6 col-lg-3">
|
|
|
|
<StatsCard
|
|
|
|
total={numReplacedParental}
|
|
|
|
lineData={getNormalizedHistory(replacedParental, interval, 'replacedParental')}
|
|
|
|
percent={getPercent(numDnsQueries, numReplacedParental)}
|
|
|
|
title={<Trans>stats_adult</Trans>}
|
|
|
|
color="yellow"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2018-08-30 14:25:33 +00:00
|
|
|
|
|
|
|
Statistics.propTypes = {
|
2019-08-22 13:10:47 +00:00
|
|
|
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,
|
2018-10-12 12:23:21 +00:00
|
|
|
refreshButton: PropTypes.node.isRequired,
|
2018-08-30 14:25:33 +00:00
|
|
|
};
|
|
|
|
|
2018-10-29 03:26:19 +00:00
|
|
|
export default withNamespaces()(Statistics);
|