feat(connections): add isClosingConnections spinner

This commit is contained in:
kunish 2024-10-11 02:23:33 +08:00
parent 14b1b39e2c
commit 23193c5c98
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430

View File

@ -89,6 +89,7 @@ export default () => {
const [activeTab, setActiveTab] = createSignal(ActiveTab.activeConnections) const [activeTab, setActiveTab] = createSignal(ActiveTab.activeConnections)
const { activeConnections, closedConnections, paused, setPaused } = const { activeConnections, closedConnections, paused, setPaused } =
useConnections() useConnections()
const [isClosingConnections, setIsClosingConnections] = createSignal(false)
const [globalFilter, setGlobalFilter] = createSignal('') const [globalFilter, setGlobalFilter] = createSignal('')
const [enableQuickFilter, setEnableQuickFilter] = makePersisted( const [enableQuickFilter, setEnableQuickFilter] = makePersisted(
@ -429,18 +430,30 @@ export default () => {
<Button <Button
class="btn btn-primary join-item btn-sm" class="btn btn-primary join-item btn-sm"
onClick={() => { onClick={async () => {
setIsClosingConnections(true)
if (table.getState().globalFilter) { if (table.getState().globalFilter) {
table await Promise.allSettled(
.getFilteredRowModel() table
.rows.forEach(({ original }) => .getFilteredRowModel()
closeSingleConnectionAPI(original.id), .rows.map(({ original }) =>
) closeSingleConnectionAPI(original.id),
),
)
} else { } else {
closeAllConnectionsAPI() await closeAllConnectionsAPI()
} }
setIsClosingConnections(false)
}} }}
icon={<IconX />} icon={
isClosingConnections() ? (
<div class="loading loading-spinner" />
) : (
<IconX />
)
}
/> />
<Button <Button