feat: update connection columns

This commit is contained in:
kunish 2023-08-29 21:39:52 +08:00
parent cf0b7bc9f0
commit 7336948ad3
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430

View File

@ -46,12 +46,6 @@ export default () => {
const onCloseConnection = (id: string) => request.delete(`connections/${id}`) const onCloseConnection = (id: string) => request.delete(`connections/${id}`)
const defaultSorting = Object.freeze({
id: 'ID',
desc: true,
})
const [sorting, setSorting] = createSignal<SortingState>([defaultSorting])
const columns: ColumnDef<Connection>[] = [ const columns: ColumnDef<Connection>[] = [
{ {
id: 'close', id: 'close',
@ -81,40 +75,35 @@ export default () => {
accessorFn: (row) => row.id, accessorFn: (row) => row.id,
}, },
{ {
accessorKey: 'Network', accessorKey: 'Type',
accessorFn: (row) => row.metadata.network, accessorFn: (row) => `${row.metadata.type}(${row.metadata.network})`,
}, },
{ {
accessorKey: 'Download', accessorKey: 'Process',
accessorFn: (row) => byteSize(row.download), accessorFn: (row) => row.metadata.process || '-',
},
{
accessorKey: 'Upload',
accessorFn: (row) => byteSize(row.upload),
},
{
accessorKey: 'Rule',
accessorFn: (row) => row.rule,
},
{
accessorKey: 'Chains',
accessorFn: (row) => row.chains.join(' -> '),
},
{
accessorKey: 'Remote Destination',
accessorFn: (row) => row.metadata.remoteDestination,
}, },
{ {
accessorKey: 'Host', accessorKey: 'Host',
accessorFn: (row) => row.metadata.host, accessorFn: (row) => row.metadata.host,
}, },
{ {
accessorKey: 'DNS Mode', accessorKey: 'Rule',
accessorFn: (row) => row.metadata.dnsMode, accessorFn: (row) =>
!row.rulePayload ? row.rule : `${row.rule} :: ${row.rulePayload}`,
}, },
{ {
accessorKey: 'Type', accessorKey: 'Chains',
accessorFn: (row) => row.metadata.type, accessorFn: (row) => row.chains.join(' -> '),
},
{
accessorKey: 'Download',
accessorFn: (row) => byteSize(row.download),
sortingFn: (a, b) => a.original.download - b.original.download,
},
{
accessorKey: 'Upload',
accessorFn: (row) => byteSize(row.upload),
sortingFn: (a, b) => a.original.upload - b.original.upload,
}, },
{ {
accessorKey: 'Source', accessorKey: 'Source',
@ -132,6 +121,10 @@ export default () => {
}, },
] ]
const [sorting, setSorting] = createSignal<SortingState>([
{ id: 'ID', desc: true },
])
const table = createSolidTable({ const table = createSolidTable({
state: { state: {
get sorting() { get sorting() {