import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; import { Trans, withNamespaces } from 'react-i18next'; import Statistics from './Statistics'; import Counters from './Counters'; import Clients from './Clients'; import QueriedDomains from './QueriedDomains'; import BlockedDomains from './BlockedDomains'; import PageTitle from '../ui/PageTitle'; import Loading from '../ui/Loading'; import './Dashboard.css'; class Dashboard extends Component { componentDidMount() { this.getAllStats(); } getAllStats = () => { this.props.getStats(); this.props.getStatsConfig(); }; getToggleFilteringButton = () => { const { protectionEnabled, processingProtection } = this.props.dashboard; const buttonText = protectionEnabled ? 'disable_protection' : 'enable_protection'; const buttonClass = protectionEnabled ? 'btn-gray' : 'btn-success'; return ( ); }; render() { const { dashboard, stats, t } = this.props; const dashboardProcessing = dashboard.processing || stats.processingStats || stats.processingGetConfig; const subtitle = stats.interval === 1 ? t('for_last_24_hours') : t('for_last_days', { count: stats.interval }); const refreshFullButton = ( ); const refreshButton = ( ); return (
{this.getToggleFilteringButton()} {refreshFullButton}
{dashboardProcessing && } {!dashboardProcessing && (
)}
); } } Dashboard.propTypes = { dashboard: PropTypes.object.isRequired, stats: PropTypes.object.isRequired, getStats: PropTypes.func.isRequired, getStatsConfig: PropTypes.func.isRequired, toggleProtection: PropTypes.func.isRequired, getClients: PropTypes.func.isRequired, t: PropTypes.func.isRequired, }; export default withNamespaces()(Dashboard);