-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates #1453. Squashed commit of the following: commit f08f68e Merge: b70b088 54aee22 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Aug 8 19:04:06 2023 +0300 Merge branch 'master' into 1453-stats-tests commit b70b088 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Aug 3 19:32:04 2023 +0300 stats: imp code commit c341012 Merge: a2ac8c3 5eb3cd0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Aug 3 13:36:24 2023 +0300 Merge branch 'master' into 1453-stats-tests commit a2ac8c3 Author: Ildar Kamalov <ik@adguard.com> Date: Thu Aug 3 13:25:12 2023 +0300 client: add top upstreams and average processing time tables commit 1111894 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Aug 1 17:24:57 2023 +0300 stats: imp docs commit 904cf81 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jul 31 17:34:06 2023 +0300 stats: imp code commit 34f0c96 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Jul 31 15:43:46 2023 +0300 all: imp docs commit 2cb2d0d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Jul 28 17:24:31 2023 +0300 all: imp code commit 5251a89 Merge: b6c2b12 300821a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jul 27 20:34:39 2023 +0300 Merge branch 'master' into 1453-stats-tests commit b6c2b12 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jul 27 20:32:18 2023 +0300 stats: imp code commit 5546b82 Merge: 8a3d6b1 5f8fa00 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jul 27 14:24:01 2023 +0300 Merge branch 'master' into 1453-stats-tests commit 8a3d6b1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jul 27 14:17:47 2023 +0300 all: imp code commit 2a48001 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jul 25 18:27:20 2023 +0300 all: imp docs commit 3dd2189 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jul 25 16:00:39 2023 +0300 all: imp naming commit 6124456 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Jul 20 16:15:56 2023 +0300 all: add upstreams avg processing time commit 187ad0c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Jul 18 16:42:19 2023 +0300 all: add top upstreams
- Loading branch information
Showing
19 changed files
with
687 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
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'; | ||
|
||
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} ms | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
TimeCell.propTypes = { | ||
value: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.number, | ||
]), | ||
}; | ||
|
||
const UpstreamAvgTime = ({ | ||
t, | ||
refreshButton, | ||
topUpstreamsAvgTime, | ||
subtitle, | ||
}) => ( | ||
<Card | ||
title={t('average_processing_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>processing_time</Trans>, | ||
accessor: 'count', | ||
maxWidth: 190, | ||
Cell: TimeCell, | ||
}, | ||
]} | ||
showPagination={false} | ||
noDataText={t('no_upstreams_data_found')} | ||
minRows={6} | ||
defaultPageSize={100} | ||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from 'react'; | ||
import ReactTable from 'react-table'; | ||
import PropTypes from 'prop-types'; | ||
import { withTranslation, Trans } from 'react-i18next'; | ||
|
||
import Card from '../ui/Card'; | ||
import Cell from '../ui/Cell'; | ||
import DomainCell from './DomainCell'; | ||
|
||
import { getPercent } from '../../helpers/helpers'; | ||
import { STATUS_COLORS } from '../../helpers/constants'; | ||
|
||
const CountCell = (totalBlocked) => ( | ||
function cell(row) { | ||
const { value } = row; | ||
const percent = getPercent(totalBlocked, value); | ||
|
||
return ( | ||
<Cell | ||
value={value} | ||
percent={percent} | ||
color={STATUS_COLORS.green} | ||
/> | ||
); | ||
} | ||
); | ||
|
||
const UpstreamResponses = ({ | ||
t, | ||
refreshButton, | ||
topUpstreamsResponses, | ||
dnsQueries, | ||
subtitle, | ||
}) => ( | ||
<Card | ||
title={t('top_upstreams')} | ||
subtitle={subtitle} | ||
bodyType="card-table" | ||
refresh={refreshButton} | ||
> | ||
<ReactTable | ||
data={topUpstreamsResponses.map(({ name: domain, count }) => ({ | ||
domain, | ||
count, | ||
}))} | ||
columns={[ | ||
{ | ||
Header: <Trans>upstream</Trans>, | ||
accessor: 'domain', | ||
Cell: DomainCell, | ||
}, | ||
{ | ||
Header: <Trans>requests_count</Trans>, | ||
accessor: 'count', | ||
maxWidth: 190, | ||
Cell: CountCell(dnsQueries), | ||
}, | ||
]} | ||
showPagination={false} | ||
noDataText={t('no_upstreams_data_found')} | ||
minRows={6} | ||
defaultPageSize={100} | ||
className="-highlight card-table-overflow--limited stats__table" | ||
/> | ||
</Card> | ||
); | ||
|
||
UpstreamResponses.propTypes = { | ||
topUpstreamsResponses: PropTypes.array.isRequired, | ||
dnsQueries: PropTypes.number.isRequired, | ||
refreshButton: PropTypes.node.isRequired, | ||
subtitle: PropTypes.string.isRequired, | ||
t: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default withTranslation()(UpstreamResponses); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.