|
|
@ -75,7 +75,15 @@ const auditDropdownsSearch = ref({ |
|
|
|
user: '', |
|
|
|
user: '', |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
console.log('changing') |
|
|
|
const focusUserSearchRef: VNodeRef = (el) => { |
|
|
|
|
|
|
|
return el && auditDropdowns.value.user && el?.focus?.() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const focusBaseSearchRef: VNodeRef = (el) => { |
|
|
|
|
|
|
|
return el && auditDropdowns.value.base && el?.focus?.() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
|
|
|
|
return el && auditDropdowns.value.type && el?.focus?.() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const auditTypeOptions = computed(() => { |
|
|
|
const auditTypeOptions = computed(() => { |
|
|
|
return Object.values(AuditOperationTypes) |
|
|
|
return Object.values(AuditOperationTypes) |
|
|
@ -131,55 +139,39 @@ const handleRowClick = (audit: AuditType) => { |
|
|
|
isRowExpanded.value = true |
|
|
|
isRowExpanded.value = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const toggleOrderBy = (orderBy: 'created_at' | 'user') => { |
|
|
|
const handleUpdateBaseQuery = (baseId?: string, sourceId?: string) => { |
|
|
|
if (orderBy === 'created_at') { |
|
|
|
auditLogsQuery.value.base = baseId |
|
|
|
auditLogsQuery.value.orderBy = { |
|
|
|
auditLogsQuery.value.sourceId = sourceId |
|
|
|
...auditLogsQuery.value.orderBy, |
|
|
|
} |
|
|
|
created_at: |
|
|
|
|
|
|
|
auditLogsQuery.value.orderBy?.created_at === 'asc' |
|
|
|
const updateOrderBy = (field: 'created_at' | 'user') => { |
|
|
|
? 'desc' |
|
|
|
if (auditLogsQuery.value.orderBy?.[field] === 'asc') { |
|
|
|
: auditLogsQuery.value.orderBy?.created_at === 'desc' |
|
|
|
auditLogsQuery.value.orderBy[field] = 'desc' |
|
|
|
? undefined |
|
|
|
} else if (auditLogsQuery.value.orderBy?.[field] === 'desc') { |
|
|
|
: 'asc', |
|
|
|
auditLogsQuery.value.orderBy[field] = undefined |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
auditLogsQuery.value.orderBy[field] = 'asc' |
|
|
|
if (orderBy === 'user') { |
|
|
|
|
|
|
|
auditLogsQuery.value.orderBy = { |
|
|
|
|
|
|
|
...auditLogsQuery.value.orderBy, |
|
|
|
|
|
|
|
user: |
|
|
|
|
|
|
|
auditLogsQuery.value.orderBy?.user === 'asc' ? 'desc' : auditLogsQuery.value.orderBy?.user === 'desc' ? undefined : 'asc', |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
loadAudits() |
|
|
|
loadAudits() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleCloseDropdown = (field: 'user' | 'base' | 'type') => { |
|
|
|
|
|
|
|
auditDropdowns.value[field] = false |
|
|
|
|
|
|
|
loadAudits() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleClearDropdownSearch = (isOpen: boolean, field: 'user' | 'base' | 'type') => { |
|
|
|
|
|
|
|
if (isOpen) { |
|
|
|
|
|
|
|
auditDropdownsSearch.value[field] = '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => { |
|
|
|
onMounted(async () => { |
|
|
|
if (audits.value === null) { |
|
|
|
if (audits.value === null) { |
|
|
|
await loadAudits(currentPage.value, currentLimit.value) |
|
|
|
await loadAudits(currentPage.value, currentLimit.value) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
watchEffect(() => { |
|
|
|
|
|
|
|
console.log('auditDropdownsSearch', auditDropdownsSearch.value) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
watch( |
|
|
|
|
|
|
|
auditDropdownsSearch, |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
console.log('fdlsa', auditDropdownsSearch.value) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ deep: true }, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const focusUserSearchRef: VNodeRef = (el) => { |
|
|
|
|
|
|
|
return el && auditDropdowns.value.user && el?.focus?.() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const focusBaseSearchRef: VNodeRef = (el) => { |
|
|
|
|
|
|
|
return el && auditDropdowns.value.base && el?.focus?.() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
|
|
|
|
return el && auditDropdowns.value.type && el?.focus?.() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
@ -202,13 +194,7 @@ const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
<NcDropdown |
|
|
|
<NcDropdown |
|
|
|
v-if="collaborators?.length" |
|
|
|
v-if="collaborators?.length" |
|
|
|
v-model:visible="auditDropdowns.user" |
|
|
|
v-model:visible="auditDropdowns.user" |
|
|
|
@update:visible=" |
|
|
|
@update:visible="handleClearDropdownSearch($event, 'user')" |
|
|
|
(value) => { |
|
|
|
|
|
|
|
if (value) { |
|
|
|
|
|
|
|
auditDropdownsSearch.user = '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
<NcButton type="secondary" size="small"> |
|
|
|
<NcButton type="secondary" size="small"> |
|
|
|
<div class="!w-[106px] flex items-center justify-between gap-2"> |
|
|
|
<div class="!w-[106px] flex items-center justify-between gap-2"> |
|
|
@ -256,15 +242,7 @@ const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
</a-input> |
|
|
|
</a-input> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<NcMenu |
|
|
|
<NcMenu class="w-full max-h-[360px] nc-scrollbar-thin" @click="handleCloseDropdown('user')"> |
|
|
|
class="w-full max-h-[360px] nc-scrollbar-thin" |
|
|
|
|
|
|
|
@click=" |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
auditDropdowns.user = false |
|
|
|
|
|
|
|
loadAudits() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<NcMenuItem |
|
|
|
<NcMenuItem |
|
|
|
class="!children:w-full ant-dropdown-menu-item ant-dropdown-menu-item-only-child sticky top-0" |
|
|
|
class="!children:w-full ant-dropdown-menu-item ant-dropdown-menu-item-only-child sticky top-0" |
|
|
|
@click="auditLogsQuery.user = undefined" |
|
|
|
@click="auditLogsQuery.user = undefined" |
|
|
@ -315,13 +293,7 @@ const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
<NcDropdown |
|
|
|
<NcDropdown |
|
|
|
v-if="basesList?.length" |
|
|
|
v-if="basesList?.length" |
|
|
|
v-model:visible="auditDropdowns.base" |
|
|
|
v-model:visible="auditDropdowns.base" |
|
|
|
@update:visible=" |
|
|
|
@update:visible="handleClearDropdownSearch($event, 'base')" |
|
|
|
(value) => { |
|
|
|
|
|
|
|
if (value) { |
|
|
|
|
|
|
|
auditDropdownsSearch.base = '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
<NcButton type="secondary" size="small"> |
|
|
|
<NcButton type="secondary" size="small"> |
|
|
|
<div class="!w-[106px] flex items-center justify-between gap-2"> |
|
|
|
<div class="!w-[106px] flex items-center justify-between gap-2"> |
|
|
@ -362,23 +334,10 @@ const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
</a-input> |
|
|
|
</a-input> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<NcMenu |
|
|
|
<NcMenu class="w-full max-h-[360px] nc-scrollbar-thin" @click="handleCloseDropdown('base')"> |
|
|
|
class="w-full max-h-[360px] nc-scrollbar-thin" |
|
|
|
|
|
|
|
@click=" |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
auditDropdowns.base = false |
|
|
|
|
|
|
|
loadAudits() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<NcMenuItem |
|
|
|
<NcMenuItem |
|
|
|
class="!children:w-full ant-dropdown-menu-item ant-dropdown-menu-item-only-child" |
|
|
|
class="!children:w-full ant-dropdown-menu-item ant-dropdown-menu-item-only-child" |
|
|
|
@click=" |
|
|
|
@click="handleUpdateBaseQuery()" |
|
|
|
() => { |
|
|
|
|
|
|
|
auditLogsQuery.base = undefined |
|
|
|
|
|
|
|
auditLogsQuery.sourceId = undefined |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
<div class="w-full flex items-center justify-between gap-3"> |
|
|
|
<div class="w-full flex items-center justify-between gap-3"> |
|
|
|
<span class="flex-1 text-gray-800"> All Bases </span> |
|
|
|
<span class="flex-1 text-gray-800"> All Bases </span> |
|
|
@ -392,12 +351,7 @@ const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
base?.sources?.[0]?.enabled && base.title?.toLowerCase()?.includes(auditDropdownsSearch.base.toLowerCase()) |
|
|
|
base?.sources?.[0]?.enabled && base.title?.toLowerCase()?.includes(auditDropdownsSearch.base.toLowerCase()) |
|
|
|
" |
|
|
|
" |
|
|
|
class="!children:w-full ant-dropdown-menu-item ant-dropdown-menu-item-only-child" |
|
|
|
class="!children:w-full ant-dropdown-menu-item ant-dropdown-menu-item-only-child" |
|
|
|
@click=" |
|
|
|
@click="handleUpdateBaseQuery(base.id, base?.sources?.[0]?.id)" |
|
|
|
() => { |
|
|
|
|
|
|
|
auditLogsQuery.base = base.id |
|
|
|
|
|
|
|
auditLogsQuery.sourceId = base?.sources?.[0]?.id |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
<div class="w-full flex items-center justify-between gap-3"> |
|
|
|
<div class="w-full flex items-center justify-between gap-3"> |
|
|
|
<div class="flex-1 flex items-center gap-2 max-w-[calc(100%_-_28px)]"> |
|
|
|
<div class="flex-1 flex items-center gap-2 max-w-[calc(100%_-_28px)]"> |
|
|
@ -421,16 +375,7 @@ const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</NcDropdown> |
|
|
|
</NcDropdown> |
|
|
|
<NcDropdown |
|
|
|
<NcDropdown v-model:visible="auditDropdowns.type" @update:visible="handleClearDropdownSearch($event, 'type')"> |
|
|
|
v-model:visible="auditDropdowns.type" |
|
|
|
|
|
|
|
@update:visible=" |
|
|
|
|
|
|
|
(value) => { |
|
|
|
|
|
|
|
if (value) { |
|
|
|
|
|
|
|
auditDropdownsSearch.type = '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<NcButton type="secondary" size="small"> |
|
|
|
<NcButton type="secondary" size="small"> |
|
|
|
<div class="!w-[106px] flex items-center justify-between gap-2"> |
|
|
|
<div class="!w-[106px] flex items-center justify-between gap-2"> |
|
|
|
<div class="max-w-full truncate text-sm !leading-5"> |
|
|
|
<div class="max-w-full truncate text-sm !leading-5"> |
|
|
@ -470,15 +415,7 @@ const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
</a-input> |
|
|
|
</a-input> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<NcMenu |
|
|
|
<NcMenu class="w-full max-h-[360px] nc-scrollbar-thin" @click="handleCloseDropdown('type')"> |
|
|
|
class="w-full max-h-[360px] nc-scrollbar-thin" |
|
|
|
|
|
|
|
@click=" |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
auditDropdowns.type = false |
|
|
|
|
|
|
|
loadAudits() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<NcMenuItem |
|
|
|
<NcMenuItem |
|
|
|
class="!children:w-full ant-dropdown-menu-item ant-dropdown-menu-item-only-child" |
|
|
|
class="!children:w-full ant-dropdown-menu-item ant-dropdown-menu-item-only-child" |
|
|
|
@click="auditLogsQuery.type = undefined" |
|
|
|
@click="auditLogsQuery.type = undefined" |
|
|
@ -489,16 +426,11 @@ const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</NcMenuItem> |
|
|
|
</NcMenuItem> |
|
|
|
<NcDivider /> |
|
|
|
<NcDivider /> |
|
|
|
<template v-for="type in auditTypeOptions" :key="type.value"> |
|
|
|
<template v-for="type of auditTypeOptions" :key="type.value"> |
|
|
|
<NcMenuItem |
|
|
|
<NcMenuItem |
|
|
|
v-if="type.label.toLowerCase().includes(auditDropdownsSearch.type.toLowerCase())" |
|
|
|
v-if="type.label.toLowerCase().includes(auditDropdownsSearch.type.toLowerCase())" |
|
|
|
class="!children:w-full ant-dropdown-menu-item ant-dropdown-menu-item-only-child" |
|
|
|
class="!children:w-full ant-dropdown-menu-item ant-dropdown-menu-item-only-child" |
|
|
|
@click=" |
|
|
|
@click="auditLogsQuery.type = type.value" |
|
|
|
() => { |
|
|
|
|
|
|
|
auditLogsQuery.type = type.value |
|
|
|
|
|
|
|
auditLogsQuery.subType = undefined |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
" |
|
|
|
|
|
|
|
> |
|
|
|
> |
|
|
|
<div class="w-full flex items-center justify-between gap-3"> |
|
|
|
<div class="w-full flex items-center justify-between gap-3"> |
|
|
|
<div class="flex-1 flex items-center gap-2 max-w-[calc(100%_-_28px)] text-gray-800"> |
|
|
|
<div class="flex-1 flex items-center gap-2 max-w-[calc(100%_-_28px)] text-gray-800"> |
|
|
@ -524,7 +456,7 @@ const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
<div class="nc-audit-logs-table table h-full"> |
|
|
|
<div class="nc-audit-logs-table table h-full"> |
|
|
|
<div class="thead sticky top-0"> |
|
|
|
<div class="thead sticky top-0"> |
|
|
|
<div class="tr"> |
|
|
|
<div class="tr"> |
|
|
|
<div class="th cell-user !hover:bg-gray-100" @click="toggleOrderBy('user')"> |
|
|
|
<div class="th cell-user !hover:bg-gray-100" @click="updateOrderBy('user')"> |
|
|
|
<div class="flex items-center gap-3"> |
|
|
|
<div class="flex items-center gap-3"> |
|
|
|
<div class="flex-1">User</div> |
|
|
|
<div class="flex-1">User</div> |
|
|
|
<NcButton type="text" size="xs" class="!p-0"> |
|
|
|
<NcButton type="text" size="xs" class="!p-0"> |
|
|
@ -538,7 +470,7 @@ const focusTypeSearchRef: VNodeRef = (el) => { |
|
|
|
</NcButton> |
|
|
|
</NcButton> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="th cell-timestamp !hover:bg-gray-100" @click="toggleOrderBy('created_at')"> |
|
|
|
<div class="th cell-timestamp !hover:bg-gray-100" @click="updateOrderBy('created_at')"> |
|
|
|
<div class="flex items-center gap-3"> |
|
|
|
<div class="flex items-center gap-3"> |
|
|
|
<div class="flex-1">Time stamp</div> |
|
|
|
<div class="flex-1">Time stamp</div> |
|
|
|
<NcButton type="text" size="xs" class="!p-0"> |
|
|
|
<NcButton type="text" size="xs" class="!p-0"> |
|
|
|