Browse Source

feat(nc-gui): allow search

pull/8836/head
Ramesh Mane 5 months ago
parent
commit
3c1b51751e
  1. 91
      packages/nc-gui/components/workspace/AuditLogs.vue

91
packages/nc-gui/components/workspace/AuditLogs.vue

@ -59,7 +59,7 @@ const auditLogsQuery = ref<{
subType?: string subType?: string
base?: string base?: string
user?: string user?: string
search?:string search?: string
}>({ }>({
type: undefined, type: undefined,
subType: undefined, subType: undefined,
@ -99,6 +99,11 @@ const handleRowClick = (audit: AuditType) => {
isRowExpanded.value = true isRowExpanded.value = true
} }
const handleSearchAuditLogs = useDebounceFn(() => {
console.log('searched', auditLogsQuery.value.search)
loadAudits()
}, 500)
onMounted(async () => { onMounted(async () => {
if (audits.value === null) { if (audits.value === null) {
await loadAudits(currentPage.value, currentLimit.value) await loadAudits(currentPage.value, currentLimit.value)
@ -122,34 +127,38 @@ onMounted(async () => {
</div> </div>
<div class="text-sm text-gray-600">Track and monitor any changes made to any base in your workspace.</div> <div class="text-sm text-gray-600">Track and monitor any changes made to any base in your workspace.</div>
</div> </div>
<div class="px-6 flex items-center gap-3"> <div class="pr-6 pl-1 flex items-center gap-3">
<!-- <a-input <form autocomplete="off" @submit.prevent>
key="nc-form-field-search-input" <a-input
v-model:value="searchQuery" key="nc-audit-logs-search-input"
type="text" v-model:value="auditLogsQuery.search"
autocomplete="off" type="text"
class="!h-9 !px-3 !py-1 !rounded-lg" autocomplete="off"
:placeholder="`${$t('placeholder.searchFields')}...`" class="!h-9 !px-3 !py-1 !rounded-lg nc-input-sm nc-input-shadow"
name="nc-form-field-search-input" placeholder="Search a record"
data-testid="nc-form-field-search-input" name="nc-audit-logs-search-input"
> data-testid="nc-audit-logs-search-input"
<template #prefix> @input="handleSearchAuditLogs"
<GeneralIcon icon="search" class="mr-2 h-4 w-4 text-gray-500 group-hover:text-black" /> @keydown.enter.exact="loadAudits"
</template> >
<template #suffix> <template #prefix>
<GeneralIcon <GeneralIcon icon="search" class="mr-2 h-4 w-4 text-gray-500 group-hover:text-black" />
v-if="searchQuery.length > 0" </template>
icon="close" <template #suffix>
class="ml-2 h-4 w-4 text-gray-500 group-hover:text-black" <GeneralIcon
data-testid="nc-form-field-clear-search" v-if="auditLogsQuery.search && auditLogsQuery.search.length > 0"
@click="searchQuery = ''" icon="close"
/> class="ml-2 h-4 w-4 text-gray-500 group-hover:text-black"
</template> data-testid="nc-audit-logs-clear-search"
</a-input> --> @click="auditLogsQuery.search = undefined"
/>
</template>
</a-input>
</form>
<div class="flex items-stretch border-1 border-gray-200 rounded-lg overflow-hidden"> <div class="flex items-stretch border-1 border-gray-200 rounded-lg overflow-hidden">
<NcDropdown v-model:visible="auditDropdowns.type"> <NcDropdown v-model:visible="auditDropdowns.type">
<NcButton type="secondary" size="small" class="!border-none !rounded-none"> <NcButton type="secondary" size="small" class="!border-none !rounded-none">
<div class="flex items-center gap-2"> <div class="!w-[106px] flex items-center justify-between gap-2">
<div class="max-w-[120px] truncate text-sm !leading-5">Type: {{ auditLogsQuery.type || 'All' }}</div> <div class="max-w-[120px] truncate text-sm !leading-5">Type: {{ auditLogsQuery.type || 'All' }}</div>
<GeneralIcon icon="arrowDown" class="h-4 w-4" /> <GeneralIcon icon="arrowDown" class="h-4 w-4" />
</div> </div>
@ -191,9 +200,9 @@ onMounted(async () => {
</NcDropdown> </NcDropdown>
<NcDropdown v-model:visible="auditDropdowns.subType" placement="bottomRight"> <NcDropdown v-model:visible="auditDropdowns.subType" placement="bottomRight">
<NcButton type="secondary" size="small" class="!border-none !rounded-none"> <NcButton type="secondary" size="small" class="!border-none !rounded-none">
<div class="flex items-center gap-2"> <div class="!w-[146px] flex items-center justify-between gap-2">
<div class="max-w-[120px] truncate text-sm !leading-5">SubType: {{ auditLogsQuery.subType || 'All' }}</div> <div class="truncate text-sm !leading-5">Sub-Type: {{ auditLogsQuery.subType || 'All' }}</div>
<GeneralIcon icon="arrowDown" class="h-4 w-4" /> <GeneralIcon icon="arrowDown" class="flex-none h-4 w-4" />
</div> </div>
</NcButton> </NcButton>
@ -225,7 +234,7 @@ onMounted(async () => {
{{ subType }} {{ subType }}
</div> </div>
<GeneralIcon v-if="auditLogsQuery.base === subType" icon="check" class="flex-none text-primary w-4 h-4" /> <GeneralIcon v-if="auditLogsQuery.subType === subType" icon="check" class="flex-none text-primary w-4 h-4" />
</div> </div>
</NcMenuItem> </NcMenuItem>
</NcMenu> </NcMenu>
@ -422,8 +431,24 @@ onMounted(async () => {
{{ audit.base_id }} {{ audit.base_id }}
</template> </template>
</div> </div>
<div class="td cell-type">{{ audit.op_type }}</div> <div class="td cell-type">
<div class="td cell-sub-type">{{ audit.op_sub_type }}</div> <div class="truncate">
<NcTooltip class="truncate" placement="bottom" show-on-truncate-only>
<template #title> {{ audit.op_type }}</template>
<span class="truncate"> {{ audit.op_type }} </span>
</NcTooltip>
</div>
</div>
<div class="td cell-sub-type">
<div class="truncate">
<NcTooltip class="truncate" placement="bottom" show-on-truncate-only>
<template #title> {{ audit.op_sub_type }}</template>
<span class="truncate"> {{ audit.op_sub_type }} </span>
</NcTooltip>
</div>
</div>
<div class="td cell-description"> <div class="td cell-description">
<div class="truncate"> <div class="truncate">
{{ audit.description }} {{ audit.description }}
@ -462,7 +487,7 @@ onMounted(async () => {
@update:page-size="loadAudits(currentPage, $event)" @update:page-size="loadAudits(currentPage, $event)"
/> />
</template> </template>
<div class="text-gray-500 text-xs">{{ totalRows }} records</div> <div class="text-gray-500 text-xs">{{ totalRows }} {{ totalRows === 1 ? 'record' : 'records' }}</div>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save