+ client: add whois info to clients and auto clients table

This commit is contained in:
Ildar Kamalov 2019-09-23 16:01:51 +03:00 committed by Simon Zolin
parent 192b58b9d9
commit 9e4f80f3c1
6 changed files with 90 additions and 22 deletions

View File

@ -392,5 +392,9 @@
"sign_in": "Sign in", "sign_in": "Sign in",
"sign_out": "Sign out", "sign_out": "Sign out",
"forgot_password": "Forgot password?", "forgot_password": "Forgot password?",
"forgot_password_desc": "Please follow <0>these steps</0> to create a new password for your user account." "forgot_password_desc": "Please follow <0>these steps</0> to create a new password for your user account.",
"city": "<0>City:</0> {{value}}",
"country": "<0>Country:</0> {{value}}",
"orgname": "<0>OrgName:</0> {{value}}",
"whois": "Whois"
} }

View File

@ -40,6 +40,10 @@
width: 100%; width: 100%;
} }
.logs__text--wrap {
white-space: normal;
}
.logs__row .tooltip-custom { .logs__row .tooltip-custom {
top: 0; top: 0;
margin-left: 0; margin-left: 0;

View File

@ -4,6 +4,8 @@ import { withNamespaces } from 'react-i18next';
import ReactTable from 'react-table'; import ReactTable from 'react-table';
import Card from '../../ui/Card'; import Card from '../../ui/Card';
import WhoisCell from './WhoisCell';
import WrapCell from './WrapCell';
class AutoClients extends Component { class AutoClients extends Component {
getStats = (ip, stats) => { getStats = (ip, stats) => {
@ -15,29 +17,26 @@ class AutoClients extends Component {
return ''; return '';
}; };
cellWrap = ({ value }) => (
<div className="logs__row logs__row--overflow">
<span className="logs__text" title={value}>
{value}
</span>
</div>
);
columns = [ columns = [
{ {
Header: this.props.t('table_client'), Header: this.props.t('table_client'),
accessor: 'ip', accessor: 'ip',
Cell: this.cellWrap, Cell: WrapCell,
}, },
{ {
Header: this.props.t('table_name'), Header: this.props.t('table_name'),
accessor: 'name', accessor: 'name',
Cell: this.cellWrap, Cell: WrapCell,
}, },
{ {
Header: this.props.t('source_label'), Header: this.props.t('source_label'),
accessor: 'source', accessor: 'source',
Cell: this.cellWrap, Cell: WrapCell,
},
{
Header: this.props.t('whois'),
accessor: 'whois_info',
Cell: WhoisCell,
}, },
{ {
Header: this.props.t('requests_count'), Header: this.props.t('requests_count'),

View File

@ -6,6 +6,8 @@ import ReactTable from 'react-table';
import { MODAL_TYPE, CLIENT_ID } from '../../../helpers/constants'; import { MODAL_TYPE, CLIENT_ID } from '../../../helpers/constants';
import Card from '../../ui/Card'; import Card from '../../ui/Card';
import Modal from './Modal'; import Modal from './Modal';
import WrapCell from './WrapCell';
import WhoisCell from './WhoisCell';
class ClientsTable extends Component { class ClientsTable extends Component {
handleFormAdd = (values) => { handleFormAdd = (values) => {
@ -33,14 +35,6 @@ class ClientsTable extends Component {
} }
}; };
cellWrap = ({ value }) => (
<div className="logs__row logs__row--overflow">
<span className="logs__text" title={value}>
{value}
</span>
</div>
);
getClient = (name, clients) => { getClient = (name, clients) => {
const client = clients.find(item => name === item.name); const client = clients.find(item => name === item.name);
@ -82,6 +76,7 @@ class ClientsTable extends Component {
{ {
Header: this.props.t('table_client'), Header: this.props.t('table_client'),
accessor: 'ip', accessor: 'ip',
minWidth: 150,
Cell: (row) => { Cell: (row) => {
if (row.original && row.original.mac) { if (row.original && row.original.mac) {
return ( return (
@ -107,11 +102,13 @@ class ClientsTable extends Component {
{ {
Header: this.props.t('table_name'), Header: this.props.t('table_name'),
accessor: 'name', accessor: 'name',
Cell: this.cellWrap, minWidth: 120,
Cell: WrapCell,
}, },
{ {
Header: this.props.t('settings'), Header: this.props.t('settings'),
accessor: 'use_global_settings', accessor: 'use_global_settings',
minWidth: 120,
Cell: ({ value }) => { Cell: ({ value }) => {
const title = value ? ( const title = value ? (
<Trans>settings_global</Trans> <Trans>settings_global</Trans>
@ -131,6 +128,7 @@ class ClientsTable extends Component {
{ {
Header: this.props.t('blocked_services'), Header: this.props.t('blocked_services'),
accessor: 'blocked_services', accessor: 'blocked_services',
minWidth: 210,
Cell: (row) => { Cell: (row) => {
const { value, original } = row; const { value, original } = row;
@ -149,6 +147,12 @@ class ClientsTable extends Component {
); );
}, },
}, },
{
Header: this.props.t('whois'),
accessor: 'whois_info',
minWidth: 200,
Cell: WhoisCell,
},
{ {
Header: this.props.t('requests_count'), Header: this.props.t('requests_count'),
accessor: 'statistics', accessor: 'statistics',
@ -172,7 +176,7 @@ class ClientsTable extends Component {
{ {
Header: this.props.t('actions_table_header'), Header: this.props.t('actions_table_header'),
accessor: 'actions', accessor: 'actions',
maxWidth: 150, maxWidth: 100,
Cell: (row) => { Cell: (row) => {
const clientName = row.original.name; const clientName = row.original.name;
const { const {

View File

@ -0,0 +1,38 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Trans } from 'react-i18next';
const getFormattedWhois = (value) => {
const keys = Object.keys(value);
if (keys.length > 0) {
return (
keys.map(key => (
<div key={key} title={value[key]}>
<Trans
values={{ value: value[key] }}
components={[<small key="0">text</small>]}
>
{key}
</Trans>
</div>
))
);
}
return '';
};
const WhoisCell = ({ value }) => (
<div className="logs__row logs__row--overflow">
<span className="logs__text logs__text--wrap">
{getFormattedWhois(value)}
</span>
</div>
);
WhoisCell.propTypes = {
value: PropTypes.object.isRequired,
};
export default WhoisCell;

View File

@ -0,0 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
const WrapCell = ({ value }) => (
<div className="logs__row logs__row--overflow">
<span className="logs__text" title={value}>
{value || ''}
</span>
</div>
);
WrapCell.propTypes = {
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
};
export default WrapCell;