From 2ff62bb0b90176b51058c3858ab9c5b2bc4a603f Mon Sep 17 00:00:00 2001 From: Haishan Date: Sun, 23 Feb 2020 18:02:03 +0800 Subject: feat(conns): show download upload speed --- src/components/ConnectionTable.js | 79 +++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 36 deletions(-) (limited to 'src/components/ConnectionTable.js') diff --git a/src/components/ConnectionTable.js b/src/components/ConnectionTable.js index d2afd22..52fd1d6 100644 --- a/src/components/ConnectionTable.js +++ b/src/components/ConnectionTable.js @@ -12,6 +12,8 @@ const columns = [ { Header: 'Host', accessor: 'host' }, { Header: 'Download', accessor: 'download' }, { Header: 'Upload', accessor: 'upload' }, + { Header: 'Download Speed', accessor: 'downloadSpeedCurr' }, + { Header: 'Upload Speed', accessor: 'uploadSpeedCurr' }, { Header: 'Network', accessor: 'network' }, { Header: 'Type', accessor: 'type' }, { Header: 'Chains', accessor: 'chains' }, @@ -29,6 +31,9 @@ function renderCell(cell, now) { case 'download': case 'upload': return prettyBytes(cell.value); + case 'downloadSpeedCurr': + case 'uploadSpeedCurr': + return prettyBytes(cell.value) + '/s'; default: return cell.value; } @@ -57,43 +62,45 @@ function Table({ data }) { return (
- {headerGroups.map(headerGroup => ( -
- {headerGroup.headers.map(column => ( -
- {column.render('Header')} - - {column.isSorted ? ( - - - - ) : null} - -
- ))} + {headerGroups.map(headerGroup => { + return ( +
+ {headerGroup.headers.map(column => ( +
+ {column.render('Header')} + + {column.isSorted ? ( + + + + ) : null} + +
+ ))} - {rows.map((row, i) => { - prepareRow(row); - return row.cells.map((cell, j) => { - return ( -
- {renderCell(cell, now)} -
- ); - }); - })} -
- ))} + {rows.map((row, i) => { + prepareRow(row); + return row.cells.map((cell, j) => { + return ( +
= 1 && j <= 4 ? s.du : false + )} + > + {renderCell(cell, now)} +
+ ); + }); + })} +
+ ); + })}
); -- cgit v1.3.1