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:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
:total-items="list.total.value"
|
||||
:page="list.page.value"
|
||||
:per-page="list.perPage.value"
|
||||
:per-page-options="[25, 50, 100]"
|
||||
:per-page-options="[10, 25, 50, 100]"
|
||||
empty-message="Aucune entrée trouvée."
|
||||
@row-click="openDetail"
|
||||
@update:page="list.goToPage($event)"
|
||||
@@ -97,7 +97,11 @@
|
||||
</MalioAccordionItem>
|
||||
|
||||
<MalioAccordionItem title="Utilisateur / compte" value="username">
|
||||
<MalioInputText v-model="list.draftUsername.value" icon-name="mdi:magnify" />
|
||||
<MalioSelect
|
||||
v-model="list.draftUsername.value"
|
||||
:options="list.usernameOptions.value"
|
||||
empty-option-label="Tous"
|
||||
/>
|
||||
</MalioAccordionItem>
|
||||
|
||||
<MalioAccordionItem title="IP" value="ip">
|
||||
|
||||
Reference in New Issue
Block a user