From ff1a39d04e53b428e34d46c55ecd6689189b5443 Mon Sep 17 00:00:00 2001 From: Haishan Date: Sat, 31 Oct 2020 18:18:04 +0800 Subject: chore: run ts-migrate --- src/components/ConnectionTable.js | 106 -------------------------------------- 1 file changed, 106 deletions(-) delete mode 100644 src/components/ConnectionTable.js (limited to 'src/components/ConnectionTable.js') diff --git a/src/components/ConnectionTable.js b/src/components/ConnectionTable.js deleted file mode 100644 index 6d9f86e..0000000 --- a/src/components/ConnectionTable.js +++ /dev/null @@ -1,106 +0,0 @@ -import cx from 'clsx'; -import { formatDistance } from 'date-fns'; -import React from 'react'; -import { ChevronDown } from 'react-feather'; -import { useSortBy, useTable } from 'react-table'; - -import prettyBytes from '../misc/pretty-bytes'; -import s from './ConnectionTable.module.css'; - -const sortDescFirst = true; - -const columns = [ - { accessor: 'id', show: false }, - { Header: 'Host', accessor: 'host' }, - { Header: 'DL', accessor: 'download', sortDescFirst }, - { Header: 'UL', accessor: 'upload', sortDescFirst }, - { Header: 'DL Speed', accessor: 'downloadSpeedCurr', sortDescFirst }, - { Header: 'UL Speed', accessor: 'uploadSpeedCurr', sortDescFirst }, - { Header: 'Chains', accessor: 'chains' }, - { Header: 'Rule', accessor: 'rule' }, - { Header: 'Time', accessor: 'start', sortDescFirst }, - { Header: 'Source', accessor: 'source' }, - { Header: 'Destination IP', accessor: 'destinationIP' }, - { Header: 'Type', accessor: 'type' }, -]; - -function renderCell(cell) { - switch (cell.column.id) { - case 'start': - return formatDistance(cell.value, 0); - case 'download': - case 'upload': - return prettyBytes(cell.value); - case 'downloadSpeedCurr': - case 'uploadSpeedCurr': - return prettyBytes(cell.value) + '/s'; - default: - return cell.value; - } -} - -const sortById = { id: 'id', desc: true }; -const tableState = { - sortBy: [ - // maintain a more stable order - sortById, - ], - hiddenColumns: ['id'], -}; - -function Table({ data }) { - const { getTableProps, headerGroups, rows, prepareRow } = useTable( - { - columns, - data, - initialState: tableState, - autoResetSortBy: false, - }, - useSortBy - ); - return ( -
- {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 ( -
= 1 && j <= 4 ? s.du : false - )} - > - {renderCell(cell)} -
- ); - }); - })} -
- ); - })} -
- ); -} - -export default Table; -- cgit v1.3.1