Files
AdGuardHome/client/src/components/Settings/Clients/AutoClients.js
Artem Baskal ac156b9612 Merge: + client: add detailed date format for filters
Close #624

Squashed commit of the following:

commit 5a66d8ca350880abd0a7a146b75df385aa8f97b4
Author: Artem Baskal <a.baskal@adguard.com>
Date:   Mon Jan 20 19:16:27 2020 +0300

    update CellWrap logic

commit 072586493ef2cb73ba514a01d8b7f8904d4f5754
Author: Artem Baskal <a.baskal@adguard.com>
Date:   Mon Jan 20 15:37:26 2020 +0300

    fix invalid date case

commit bd2a21f2c788b2835485f4697dac1b797d5559c0
Author: Artem Baskal <a.baskal@adguard.com>
Date:   Fri Jan 17 18:44:23 2020 +0300

    + client: add detailed date format for filters
2020-01-24 18:59:38 +03:00

105 lines
3.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { withNamespaces } from 'react-i18next';
import ReactTable from 'react-table';
import Card from '../../ui/Card';
import CellWrap from '../../ui/CellWrap';
import whoisCell from './whoisCell';
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}>
{clientStats}
</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={true}
defaultPageSize={10}
minRows={5}
previousText={t('previous_btn')}
nextText={t('next_btn')}
loadingText={t('loading_table_status')}
pageText={t('page_table_footer_text')}
ofText="/"
rowsText={t('rows_table_footer_text')}
noDataText={t('clients_not_found')}
/>
</Card>
);
}
}
AutoClients.propTypes = {
t: PropTypes.func.isRequired,
autoClients: PropTypes.array.isRequired,
normalizedTopClients: PropTypes.object.isRequired,
};
export default withNamespaces()(AutoClients);