+ client: handle the new statistics format
This commit is contained in:
@@ -63,8 +63,9 @@ class ClientsTable extends Component {
|
||||
};
|
||||
|
||||
getStats = (ip, stats) => {
|
||||
if (stats && stats.top_clients) {
|
||||
return stats.top_clients[ip];
|
||||
if (stats) {
|
||||
const statsForCurrentIP = stats.find(item => item.name === ip);
|
||||
return statsForCurrentIP && statsForCurrentIP.count;
|
||||
}
|
||||
|
||||
return '';
|
||||
@@ -149,11 +150,11 @@ class ClientsTable extends Component {
|
||||
},
|
||||
},
|
||||
{
|
||||
Header: this.props.t('table_statistics'),
|
||||
Header: this.props.t('requests_count'),
|
||||
accessor: 'statistics',
|
||||
Cell: (row) => {
|
||||
const clientIP = row.original.ip;
|
||||
const clientStats = clientIP && this.getStats(clientIP, this.props.topStats);
|
||||
const clientStats = clientIP && this.getStats(clientIP, this.props.topClients);
|
||||
|
||||
if (clientStats) {
|
||||
return (
|
||||
@@ -276,7 +277,7 @@ class ClientsTable extends Component {
|
||||
ClientsTable.propTypes = {
|
||||
t: PropTypes.func.isRequired,
|
||||
clients: PropTypes.array.isRequired,
|
||||
topStats: PropTypes.object.isRequired,
|
||||
topClients: PropTypes.array.isRequired,
|
||||
toggleClientModal: PropTypes.func.isRequired,
|
||||
deleteClient: PropTypes.func.isRequired,
|
||||
addClient: PropTypes.func.isRequired,
|
||||
|
||||
Reference in New Issue
Block a user