Close #1866
Squashed commit of the following:
commit 3347832caa33b01a0155b212987f02dc4824ab08
Merge: 7766502d d794b11e
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri Jul 17 15:12:45 2020 +0300
Merge branch 'master' into fix/1866
commit 7766502d4a904ad0a4d240481f7eabf0e25cfb62
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri Jul 17 12:16:59 2020 +0300
Fix icon color classes
commit 90191bf74b5eb1855c733c226f7acb4e906c7ad9
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Fri Jul 17 11:46:22 2020 +0300
Use logs icons, use pointer cursor, fix review markup formatting
commit 0ba50fcd956101f5054ce38c2329df3e8abdfcd2
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Thu Jul 16 18:05:30 2020 +0300
Use help cursor on tooltips
commit bf4e14afe69f874d29be73d8cd4cfbe240ca0304
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Thu Jul 16 17:41:47 2020 +0300
Use tooltip in logs, rename tooltip classes
commit 00568fdc8e8484c5bae67c51ee8189a3a558e219
Author: ArtemBaskal <a.baskal@adguard.com>
Date: Thu Jul 16 17:01:49 2020 +0300
- client: Use the same tooltip style everywhere
118 lines
3.8 KiB
JavaScript
118 lines
3.8 KiB
JavaScript
import React, { Component } from 'react';
|
||
import PropTypes from 'prop-types';
|
||
import { withTranslation } from 'react-i18next';
|
||
import ReactTable from 'react-table';
|
||
|
||
import Card from '../../ui/Card';
|
||
import CellWrap from '../../ui/CellWrap';
|
||
|
||
import whoisCell from './whoisCell';
|
||
import LogsSearchLink from '../../ui/LogsSearchLink';
|
||
|
||
const COLUMN_MIN_WIDTH = 200;
|
||
|
||
class AutoClients extends Component {
|
||
columns = [
|
||
{
|
||
Header: this.props.t('table_client'),
|
||
accessor: 'ip',
|
||
minWidth: COLUMN_MIN_WIDTH,
|
||
Cell: CellWrap,
|
||
},
|
||
{
|
||
Header: this.props.t('table_name'),
|
||
accessor: 'name',
|
||
minWidth: COLUMN_MIN_WIDTH,
|
||
Cell: CellWrap,
|
||
},
|
||
{
|
||
Header: this.props.t('source_label'),
|
||
accessor: 'source',
|
||
minWidth: COLUMN_MIN_WIDTH,
|
||
Cell: CellWrap,
|
||
},
|
||
{
|
||
Header: this.props.t('whois'),
|
||
accessor: 'whois_info',
|
||
minWidth: COLUMN_MIN_WIDTH,
|
||
Cell: whoisCell(this.props.t),
|
||
},
|
||
{
|
||
Header: this.props.t('requests_count'),
|
||
accessor: (row) => this.props.normalizedTopClients.auto[row.ip] || 0,
|
||
sortMethod: (a, b) => b - a,
|
||
id: 'statistics',
|
||
minWidth: COLUMN_MIN_WIDTH,
|
||
Cell: (row) => {
|
||
const { value: clientStats } = row;
|
||
|
||
if (clientStats) {
|
||
return (
|
||
<div className="logs__row">
|
||
<div className="logs__text" title={clientStats}>
|
||
<LogsSearchLink search={row.original.ip}>
|
||
{clientStats}
|
||
</LogsSearchLink>
|
||
</div>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
return '–';
|
||
},
|
||
},
|
||
];
|
||
|
||
render() {
|
||
const { t, autoClients } = this.props;
|
||
|
||
return (
|
||
<Card
|
||
title={t('auto_clients_title')}
|
||
subtitle={t('auto_clients_desc')}
|
||
bodyType="card-body box-body--settings"
|
||
>
|
||
<ReactTable
|
||
data={autoClients || []}
|
||
columns={this.columns}
|
||
defaultSorted={[
|
||
{
|
||
id: 'statistics',
|
||
asc: true,
|
||
},
|
||
]}
|
||
className="-striped -highlight card-table-overflow"
|
||
showPagination
|
||
defaultPageSize={10}
|
||
minRows={5}
|
||
showPageSizeOptions={false}
|
||
showPageJump={false}
|
||
renderTotalPagesCount={() => false}
|
||
previousText={
|
||
<svg className="icons icon--24 icon--gray w-100 h-100">
|
||
<use xlinkHref="#arrow-left" />
|
||
</svg>}
|
||
nextText={
|
||
<svg className="icons icon--24 icon--gray w-100 h-100">
|
||
<use xlinkHref="#arrow-right" />
|
||
</svg>}
|
||
loadingText={t('loading_table_status')}
|
||
pageText=''
|
||
ofText=''
|
||
rowsText={t('rows_table_footer_text')}
|
||
noDataText={t('clients_not_found')}
|
||
getPaginationProps={() => ({ className: 'custom-pagination' })}
|
||
/>
|
||
</Card>
|
||
);
|
||
}
|
||
}
|
||
|
||
AutoClients.propTypes = {
|
||
t: PropTypes.func.isRequired,
|
||
autoClients: PropTypes.array.isRequired,
|
||
normalizedTopClients: PropTypes.object.isRequired,
|
||
};
|
||
|
||
export default withTranslation()(AutoClients);
|