feat(audit) : pagination défaut 10 + filtres employé/utilisateur en select

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-24 11:52:20 +02:00
parent e6a84af9b5
commit 06e462ef31
6 changed files with 37 additions and 13 deletions
+13 -2
View File
@@ -2,18 +2,21 @@ import { ref, computed } from 'vue'
import type { AuditLog } from '~/services/dto/audit-log'
import { fetchAuditLogs, type AuditLogFilters } from '~/services/audit-logs'
import { listEmployees } from '~/services/employees'
import { listUsers } from '~/services/users'
type Range = { start: string, end: string } | null
type SelectOption = { value: number, text: string }
type UsernameOption = { value: string, text: string }
export const useAuditLogsList = () => {
const items = ref<AuditLog[]>([])
const total = ref(0)
const page = ref(1)
const perPage = ref(50)
const perPage = ref(10)
const loading = ref(false)
const filterOpen = ref(false)
const employeeOptions = ref<SelectOption[]>([])
const usernameOptions = ref<UsernameOption[]>([])
// Applied filters (drive the fetch)
const appliedEmployeeId = ref<number | undefined>(undefined)
@@ -85,6 +88,14 @@ export const useAuditLogsList = () => {
} catch {
employeeOptions.value = []
}
try {
const users = await listUsers()
usernameOptions.value = users
.map(u => ({ value: u.username, text: u.username }))
.sort((a, b) => a.text.localeCompare(b.text))
} catch {
usernameOptions.value = []
}
await load()
}
@@ -149,7 +160,7 @@ export const useAuditLogsList = () => {
const toggleAction = (value: string, selected: boolean) => toggle(draftActions, value, selected)
return {
items, total, page, perPage, loading, filterOpen, employeeOptions, activeFilterCount,
items, total, page, perPage, loading, filterOpen, employeeOptions, usernameOptions, activeFilterCount,
draftEmployeeId, draftRange, draftEntityTypes, draftActions, draftUsername, draftIp, draftDevice,
init, goToPage, setPerPage, openFilters, applyFilters, resetFilters, toggleEntityType, toggleAction,
}