|
|
@ -1,5 +1,5 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
<script setup lang="ts"> |
|
|
|
import { Tooltip as ATooltip, Empty } from 'ant-design-vue' |
|
|
|
import { Empty } from 'ant-design-vue' |
|
|
|
import type { AuditType, WorkspaceUserType } from 'nocodb-sdk' |
|
|
|
import type { AuditType, WorkspaceUserType } from 'nocodb-sdk' |
|
|
|
import { timeAgo, AuditOperationTypes, AuditOperationSubTypes } from 'nocodb-sdk' |
|
|
|
import { timeAgo, AuditOperationTypes, AuditOperationSubTypes } from 'nocodb-sdk' |
|
|
|
|
|
|
|
|
|
|
@ -11,10 +11,24 @@ const props = defineProps<Props>() |
|
|
|
|
|
|
|
|
|
|
|
const workspaceStore = useWorkspace() |
|
|
|
const workspaceStore = useWorkspace() |
|
|
|
|
|
|
|
|
|
|
|
const { collaborators } = storeToRefs(workspaceStore) |
|
|
|
const { loadAudits: _loadAudits } = workspaceStore |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { |
|
|
|
|
|
|
|
collaborators, |
|
|
|
|
|
|
|
audits, |
|
|
|
|
|
|
|
auditLogsQuery, |
|
|
|
|
|
|
|
auditCurrentLimit: currentLimit, |
|
|
|
|
|
|
|
auditCurrentPage: currentPage, |
|
|
|
|
|
|
|
auditTotalRows: totalRows, |
|
|
|
|
|
|
|
} = storeToRefs(workspaceStore) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const basesStore = useBases() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { bases, basesList } = storeToRefs(basesStore) |
|
|
|
|
|
|
|
|
|
|
|
const collaboratorsMap = computed<Map<string, WorkspaceUserType & { id: string }>>(() => { |
|
|
|
const collaboratorsMap = computed<Map<string, WorkspaceUserType & { id: string }>>(() => { |
|
|
|
const map = new Map<string, WorkspaceUserType & { id: string }>() |
|
|
|
const map = new Map<string, WorkspaceUserType & { id: string }>() |
|
|
|
|
|
|
|
|
|
|
|
collaborators.value?.forEach((coll) => { |
|
|
|
collaborators.value?.forEach((coll) => { |
|
|
|
if (coll?.email) { |
|
|
|
if (coll?.email) { |
|
|
|
map.set(coll.email, coll) |
|
|
|
map.set(coll.email, coll) |
|
|
@ -23,26 +37,10 @@ const collaboratorsMap = computed<Map<string, WorkspaceUserType & { id: string } |
|
|
|
return map |
|
|
|
return map |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const basesStore = useBases() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { bases, basesList } = storeToRefs(basesStore) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { $api } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { appInfo } = useGlobal() |
|
|
|
const { appInfo } = useGlobal() |
|
|
|
|
|
|
|
|
|
|
|
const isLoading = ref(false) |
|
|
|
const isLoading = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const audits = ref<null | Array<AuditType>>(null) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const totalRows = ref(0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const currentPage = ref(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const currentLimit = ref(25) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isRowExpanded = ref(false) |
|
|
|
const isRowExpanded = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const selectedAudit = ref<null | AuditType>(null) |
|
|
|
const selectedAudit = ref<null | AuditType>(null) |
|
|
@ -54,41 +52,13 @@ const auditDropdowns = ref({ |
|
|
|
user: false, |
|
|
|
user: false, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const auditLogsQuery = ref<{ |
|
|
|
|
|
|
|
type?: string |
|
|
|
|
|
|
|
subType?: string |
|
|
|
|
|
|
|
base?: string |
|
|
|
|
|
|
|
user?: string |
|
|
|
|
|
|
|
search?: string |
|
|
|
|
|
|
|
}>({ |
|
|
|
|
|
|
|
type: undefined, |
|
|
|
|
|
|
|
subType: undefined, |
|
|
|
|
|
|
|
base: undefined, |
|
|
|
|
|
|
|
user: undefined, |
|
|
|
|
|
|
|
search: undefined, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function loadAudits(page = currentPage.value, limit = currentLimit.value) { |
|
|
|
async function loadAudits(page = currentPage.value, limit = currentLimit.value) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (!props.workspaceId) return |
|
|
|
if (!props.workspaceId) return |
|
|
|
|
|
|
|
|
|
|
|
isLoading.value = true |
|
|
|
isLoading.value = true |
|
|
|
|
|
|
|
await _loadAudits(props.workspaceId, page, limit) |
|
|
|
if (limit * (page - 1) > totalRows.value) { |
|
|
|
} catch { |
|
|
|
currentPage.value = 1 |
|
|
|
|
|
|
|
page = 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { list, pageInfo } = await $api.workspace.auditList(props.workspaceId, { |
|
|
|
|
|
|
|
offset: limit * (page - 1), |
|
|
|
|
|
|
|
limit, |
|
|
|
|
|
|
|
...auditLogsQuery.value, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
audits.value = list |
|
|
|
|
|
|
|
totalRows.value = pageInfo.totalRows ?? 0 |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.error(e) |
|
|
|
|
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
isLoading.value = false |
|
|
|
isLoading.value = false |
|
|
|
} |
|
|
|
} |
|
|
@ -100,7 +70,6 @@ const handleRowClick = (audit: AuditType) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleSearchAuditLogs = useDebounceFn(() => { |
|
|
|
const handleSearchAuditLogs = useDebounceFn(() => { |
|
|
|
console.log('searched', auditLogsQuery.value.search) |
|
|
|
|
|
|
|
loadAudits() |
|
|
|
loadAudits() |
|
|
|
}, 500) |
|
|
|
}, 500) |
|
|
|
|
|
|
|
|
|
|
@ -134,7 +103,7 @@ onMounted(async () => { |
|
|
|
v-model:value="auditLogsQuery.search" |
|
|
|
v-model:value="auditLogsQuery.search" |
|
|
|
type="text" |
|
|
|
type="text" |
|
|
|
autocomplete="off" |
|
|
|
autocomplete="off" |
|
|
|
class="!h-9 !px-3 !py-1 !rounded-lg nc-input-sm nc-input-shadow" |
|
|
|
class="nc-input-sm nc-input-shadow" |
|
|
|
placeholder="Search a record" |
|
|
|
placeholder="Search a record" |
|
|
|
name="nc-audit-logs-search-input" |
|
|
|
name="nc-audit-logs-search-input" |
|
|
|
data-testid="nc-audit-logs-search-input" |
|
|
|
data-testid="nc-audit-logs-search-input" |
|
|
@ -160,7 +129,7 @@ onMounted(async () => { |
|
|
|
<NcButton type="secondary" size="small" class="!border-none !rounded-none"> |
|
|
|
<NcButton type="secondary" size="small" class="!border-none !rounded-none"> |
|
|
|
<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-[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="flex-none h-4 w-4" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</NcButton> |
|
|
|
</NcButton> |
|
|
|
|
|
|
|
|
|
|
@ -247,7 +216,7 @@ onMounted(async () => { |
|
|
|
<div class="max-w-[120px] truncate text-sm !leading-5"> |
|
|
|
<div class="max-w-[120px] truncate text-sm !leading-5"> |
|
|
|
Base: {{ (auditLogsQuery.base && bases.get(auditLogsQuery.base)?.title) || 'All' }} |
|
|
|
Base: {{ (auditLogsQuery.base && bases.get(auditLogsQuery.base)?.title) || 'All' }} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<GeneralIcon icon="arrowDown" class="h-4 w-4" /> |
|
|
|
<GeneralIcon icon="arrowDown" class="flex-none h-4 w-4" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</NcButton> |
|
|
|
</NcButton> |
|
|
|
|
|
|
|
|
|
|
@ -261,18 +230,31 @@ onMounted(async () => { |
|
|
|
} |
|
|
|
} |
|
|
|
" |
|
|
|
" |
|
|
|
> |
|
|
|
> |
|
|
|
<NcMenuItem class="!children:w-full" @click="auditLogsQuery.base = undefined"> |
|
|
|
<NcMenuItem |
|
|
|
|
|
|
|
class="!children:w-full" |
|
|
|
|
|
|
|
@click=" |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
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"> All Bases </span> |
|
|
|
<span class="flex-1"> All Bases </span> |
|
|
|
<GeneralIcon v-if="!auditLogsQuery.base" icon="check" class="flex-none text-primary w-4 h-4" /> |
|
|
|
<GeneralIcon v-if="!auditLogsQuery.base" icon="check" class="flex-none text-primary w-4 h-4" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</NcMenuItem> |
|
|
|
</NcMenuItem> |
|
|
|
<NcDivider /> |
|
|
|
<NcDivider /> |
|
|
|
|
|
|
|
<template v-for="(base, index) of basesList" :key="index"> |
|
|
|
<NcMenuItem |
|
|
|
<NcMenuItem |
|
|
|
v-for="(base, index) of basesList" |
|
|
|
v-if="base?.sources?.[0]?.enabled" |
|
|
|
:key="index" |
|
|
|
|
|
|
|
class="!children:w-full" |
|
|
|
class="!children:w-full" |
|
|
|
@click="auditLogsQuery.base = base.id" |
|
|
|
@click=" |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
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)]"> |
|
|
@ -291,6 +273,7 @@ onMounted(async () => { |
|
|
|
<GeneralIcon v-if="auditLogsQuery.base === base.id" icon="check" class="flex-none text-primary w-4 h-4" /> |
|
|
|
<GeneralIcon v-if="auditLogsQuery.base === base.id" icon="check" class="flex-none text-primary w-4 h-4" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</NcMenuItem> |
|
|
|
</NcMenuItem> |
|
|
|
|
|
|
|
</template> |
|
|
|
</NcMenu> |
|
|
|
</NcMenu> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</NcDropdown> |
|
|
|
</NcDropdown> |
|
|
@ -308,7 +291,7 @@ onMounted(async () => { |
|
|
|
'All' |
|
|
|
'All' |
|
|
|
}} |
|
|
|
}} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<GeneralIcon icon="arrowDown" class="h-4 w-4" /> |
|
|
|
<GeneralIcon icon="arrowDown" class="flex-none h-4 w-4" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</NcButton> |
|
|
|
</NcButton> |
|
|
|
|
|
|
|
|
|
|
|