feat(connections): optimized search

This commit is contained in:
kunish 2023-09-05 00:47:27 +08:00
parent dac920a8c1
commit 17d9ae4872
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430

View File

@ -15,6 +15,7 @@ import {
createSolidTable, createSolidTable,
flexRender, flexRender,
getCoreRowModel, getCoreRowModel,
getFilteredRowModel,
getSortedRowModel, getSortedRowModel,
} from '@tanstack/solid-table' } from '@tanstack/solid-table'
import byteSize from 'byte-size' import byteSize from 'byte-size'
@ -217,20 +218,17 @@ export default () => {
get columnVisibility() { get columnVisibility() {
return columnVisibility() return columnVisibility()
}, },
get globalFilter() {
return search()
},
}, },
get data() { get data() {
return search() return connectionsWithSpeed()
? connectionsWithSpeed().filter((connection) =>
Object.values(connection).some((conn) =>
JSON.stringify(conn)
.toLowerCase()
.includes(search().toLowerCase()),
),
)
: connectionsWithSpeed()
}, },
enableHiding: true, enableHiding: true,
columns, columns,
onGlobalFilterChange: setSearch,
getFilteredRowModel: getFilteredRowModel(),
onSortingChange: setSorting, onSortingChange: setSorting,
getSortedRowModel: getSortedRowModel(), getSortedRowModel: getSortedRowModel(),
getCoreRowModel: getCoreRowModel(), getCoreRowModel: getCoreRowModel(),