Files
AdGuardHome/client/src/components/Dashboard/UpstreamAvgTime.js
Stanislav Chzhen d3862614e5 Pull request 2054: 6220-average-processing-time
Updates #6220.

Squashed commit of the following:

commit 2ad87979b4f8ade2cad8a1b86b8e0663dd53b098
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Nov 9 13:55:09 2023 +0300

    all: upd go

commit 387200c3de899e6f59e8d2455cb2aa2b7194b311
Merge: 37f2855ed f8fe9bfc8
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Nov 9 13:49:59 2023 +0300

    Merge branch 'master' into 6220-average-processing-time

commit 37f2855ed104c20faa3f4d57d48bd221a59cacb3
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Wed Nov 8 17:08:13 2023 +0300

    client: upd locales

commit a09be4183811cef29b594f9916dc76b87f89d304
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Nov 7 20:46:24 2023 +0300

    all: imp docs

commit f0b85ac1fef366da37b996d53e29d76d6279691f
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Fri Nov 3 14:17:32 2023 +0300

    all: add todo

commit 48a5879865a1625410787edef6d78b309056af7b
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Fri Nov 3 13:38:14 2023 +0300

    all: add upstream time

commit 4d7431c00e24f8a9d3e86160851b5ef3bd9d03fa
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Oct 31 17:27:19 2023 +0300

    all: upd chlog

commit 040b6b9cdebea2c9789d4d38f2a0a40ef4cb26d7
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Oct 31 15:42:04 2023 +0300

    all: imp average processing time
2023-11-09 16:14:05 +03:00

81 lines
2.2 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 from 'react';
import ReactTable from 'react-table';
import PropTypes from 'prop-types';
import round from 'lodash/round';
import { withTranslation, Trans } from 'react-i18next';
import Card from '../ui/Card';
import DomainCell from './DomainCell';
import { DASHBOARD_TABLES_DEFAULT_PAGE_SIZE, TABLES_MIN_ROWS } from '../../helpers/constants';
const TimeCell = ({ value }) => {
if (!value) {
return '';
}
const valueInMilliseconds = round(value * 1000);
return (
<div className="logs__row o-hidden">
<span className="logs__text logs__text--full" title={valueInMilliseconds}>
{valueInMilliseconds}&nbsp;ms
</span>
</div>
);
};
TimeCell.propTypes = {
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
]),
};
const UpstreamAvgTime = ({
t,
refreshButton,
topUpstreamsAvgTime,
subtitle,
}) => (
<Card
title={t('average_upstream_response_time')}
subtitle={subtitle}
bodyType="card-table"
refresh={refreshButton}
>
<ReactTable
data={topUpstreamsAvgTime.map(({ name: domain, count }) => ({
domain,
count,
}))}
columns={[
{
Header: <Trans>upstream</Trans>,
accessor: 'domain',
Cell: DomainCell,
},
{
Header: <Trans>response_time</Trans>,
accessor: 'count',
maxWidth: 190,
Cell: TimeCell,
},
]}
showPagination={false}
noDataText={t('no_upstreams_data_found')}
minRows={TABLES_MIN_ROWS}
defaultPageSize={DASHBOARD_TABLES_DEFAULT_PAGE_SIZE}
className="-highlight card-table-overflow--limited stats__table"
/>
</Card>
);
UpstreamAvgTime.propTypes = {
topUpstreamsAvgTime: PropTypes.array.isRequired,
refreshButton: PropTypes.node.isRequired,
subtitle: PropTypes.string.isRequired,
t: PropTypes.func.isRequired,
};
export default withTranslation()(UpstreamAvgTime);