mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-15 10:30:09 +00:00
fix: make sorting consistent around tables
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import { ACCESS_TOKEN_COOKIE_NAME } from '$lib/constants';
|
||||
import AuditLogService from '$lib/services/audit-log-service';
|
||||
import type { SearchPaginationSortRequest } from '$lib/types/pagination.type';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async ({ cookies }) => {
|
||||
const auditLogService = new AuditLogService(cookies.get(ACCESS_TOKEN_COOKIE_NAME));
|
||||
const auditLogs = await auditLogService.list({
|
||||
const auditLogsRequestOptions: SearchPaginationSortRequest = {
|
||||
sort: {
|
||||
column: 'createdAt',
|
||||
direction: 'desc'
|
||||
}
|
||||
});
|
||||
return {
|
||||
auditLogs
|
||||
};
|
||||
const auditLogs = await auditLogService.list(auditLogsRequestOptions);
|
||||
return { auditLogs, auditLogsRequestOptions };
|
||||
};
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import AuditLogList from './audit-log-list.svelte';
|
||||
|
||||
let { data } = $props();
|
||||
let { auditLogs } = data;
|
||||
let auditLogsRequestOptions = $state(data.auditLogsRequestOptions);
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -17,6 +19,6 @@
|
||||
>
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
<AuditLogList auditLogs={data.auditLogs} />
|
||||
<AuditLogList auditLogs={data.auditLogs} requestOptions={auditLogsRequestOptions} />
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
import * as Table from '$lib/components/ui/table';
|
||||
import AuditLogService from '$lib/services/audit-log-service';
|
||||
import type { AuditLog } from '$lib/types/audit-log.type';
|
||||
import type { Paginated } from '$lib/types/pagination.type';
|
||||
import type { Paginated, SearchPaginationSortRequest } from '$lib/types/pagination.type';
|
||||
|
||||
let { auditLogs: initialAuditLog }: { auditLogs: Paginated<AuditLog> } = $props();
|
||||
let auditLogs = $state<Paginated<AuditLog>>(initialAuditLog);
|
||||
let {
|
||||
auditLogs,
|
||||
requestOptions
|
||||
}: { auditLogs: Paginated<AuditLog>; requestOptions: SearchPaginationSortRequest } = $props();
|
||||
|
||||
const auditLogService = new AuditLogService();
|
||||
|
||||
@@ -22,8 +24,8 @@
|
||||
|
||||
<AdvancedTable
|
||||
items={auditLogs}
|
||||
{requestOptions}
|
||||
onRefresh={async (options) => (auditLogs = await auditLogService.list(options))}
|
||||
defaultSort={{ column: 'createdAt', direction: 'desc' }}
|
||||
columns={[
|
||||
{ label: 'Time', sortColumn: 'createdAt' },
|
||||
{ label: 'Event', sortColumn: 'event' },
|
||||
|
||||
Reference in New Issue
Block a user