Skip to content

Commit a7588f6

Browse files
committed
Loading spinner + fix per page bug in audit logs
1 parent afa4381 commit a7588f6

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

frontend/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"@redocly/json-to-json-schema": "^0.0.1",
9090
"@scalar/openapi-parser": "^0.15.0",
9191
"@tanstack/svelte-table": "npm:tanstack-table-8-svelte-5@^0.1",
92-
"@tutorlatin/svelte-tiny-virtual-list": "^3.0.2",
92+
"@tutorlatin/svelte-tiny-virtual-list": "^3.0.16",
9393
"@windmill-labs/svelte-dnd-action": "^0.9.44",
9494
"@xterm/addon-fit": "^0.10.0",
9595
"@xyflow/svelte": "^1.0.0",

frontend/src/lib/components/auditLogs/AuditLogsFilters.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
4444
let usernames: string[] | undefined = $state()
4545
let resources = usePromise(() => loadResources($workspaceStore!), { loadInit: false })
46-
let loading: boolean = $state(false)
4746
let page: number | undefined = undefined
4847
4948
interface Props {
@@ -58,6 +57,7 @@
5857
resource?: string | undefined
5958
actionKind?: ActionKind | 'all'
6059
scope?: undefined | 'all_workspaces' | 'instance'
60+
loading?: boolean
6161
}
6262
6363
let {
@@ -71,7 +71,8 @@
7171
operation = $bindable(),
7272
resource = $bindable() as string | undefined,
7373
actionKind = $bindable(undefined),
74-
scope = $bindable(undefined)
74+
scope = $bindable(undefined),
75+
loading = $bindable(false)
7576
}: Props = $props()
7677
7778
$effect.pre(() => {

frontend/src/lib/components/auditLogs/AuditLogsTable.svelte

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { displayDate } from '$lib/utils'
55
import { onMount, tick } from 'svelte'
66
import Button from '../common/button/Button.svelte'
7-
import { ChevronLeft, ChevronRight, ListFilterPlus } from 'lucide-svelte'
7+
import { ChevronLeft, ChevronRight, ListFilterPlus, Loader2 } from 'lucide-svelte'
88
import VirtualList from '@tutorlatin/svelte-tiny-virtual-list'
99
import { twMerge } from 'tailwind-merge'
1010
@@ -19,6 +19,7 @@
1919
usernameFilter?: string | undefined
2020
resourceFilter?: string | undefined
2121
showWorkspace?: boolean
22+
loading?: boolean
2223
onselect?: (id: number) => void
2324
}
2425
@@ -33,7 +34,8 @@
3334
usernameFilter = $bindable(),
3435
resourceFilter = $bindable(),
3536
showWorkspace = false,
36-
onselect
37+
onselect,
38+
loading
3739
}: Props = $props()
3840
3941
function groupLogsByDay(logs: AuditLog[]): Record<string, AuditLog[]> {
@@ -120,6 +122,7 @@
120122
}
121123
return 'gray'
122124
}
125+
let height = $derived(tableHeight - headerHeight - footerHeight)
123126
</script>
124127

125128
<svelte:window onresize={() => computeHeight()} />
@@ -141,10 +144,14 @@
141144
</div>
142145
{#if logs?.length == 0}
143146
<div class="text-xs text-secondary p-8"> No logs found for the selected filters. </div>
147+
{:else if loading}
148+
<div style="height: {height}px;" class="flex justify-center items-center">
149+
<Loader2 class="animate-spin" />
150+
</div>
144151
{:else}
145152
<VirtualList
146153
width="100%"
147-
height={tableHeight - headerHeight - footerHeight}
154+
{height}
148155
itemCount={flatLogs?.length ?? 0}
149156
itemSize={(index) => {
150157
if (flatLogs?.[index]?.type === 'date') {

frontend/src/routes/(root)/(logged)/audit_logs/+page.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
let pageIndex: number | undefined = $state(Number(page.url.searchParams.get('page')) || 0)
2222
let before: string | undefined = $state(page.url.searchParams.get('before') ?? undefined)
2323
let hasMore: boolean = $state(false)
24+
let loading: boolean = $state(false)
2425
let after: string | undefined = $state(page.url.searchParams.get('after') ?? undefined)
2526
let perPage: number | undefined = $state(Number(page.url.searchParams.get('perPage')) || 100)
2627
let operation: string = $state(page.url.searchParams.get('operation') ?? 'all')
@@ -107,6 +108,7 @@
107108
bind:perPage
108109
bind:scope
109110
bind:hasMore
111+
bind:loading
110112
/>
111113
</div>
112114
<div class="2xl:hidden">
@@ -161,6 +163,7 @@
161163
<Pane size={70} minSize={50}>
162164
{#if logs}
163165
<AuditLogsTable
166+
{loading}
164167
{logs}
165168
{selectedId}
166169
bind:pageIndex

0 commit comments

Comments
 (0)