mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
3.0 KiB
114 lines
3.0 KiB
2 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import { useI18n } from 'vue-i18n'
|
||
2 years ago
|
import { Tooltip as ATooltip, Empty } from 'ant-design-vue'
|
||
2 years ago
|
import type { AuditType } from 'nocodb-sdk'
|
||
2 years ago
|
import { timeAgo } from '~/utils/dateTimeUtils'
|
||
2 years ago
|
import { h, useNuxtApp, useProject } from '#imports'
|
||
2 years ago
|
import MdiReload from '~icons/mdi/reload'
|
||
|
|
||
2 years ago
|
const { $api } = useNuxtApp()
|
||
2 years ago
|
const { project } = useProject()
|
||
2 years ago
|
const { t } = useI18n()
|
||
2 years ago
|
|
||
|
let isLoading = $ref(false)
|
||
|
|
||
|
let audits = $ref<null | Array<AuditType>>(null)
|
||
2 years ago
|
|
||
2 years ago
|
let totalRows = $ref(0)
|
||
2 years ago
|
|
||
2 years ago
|
const currentPage = $ref(1)
|
||
|
const currentLimit = $ref(25)
|
||
2 years ago
|
|
||
2 years ago
|
async function loadAudits(page = currentPage, limit = currentLimit) {
|
||
2 years ago
|
try {
|
||
2 years ago
|
if (!project.value?.id) return
|
||
|
|
||
|
isLoading = true
|
||
|
|
||
|
const { list, pageInfo } = await $api.project.auditList(project.value?.id, {
|
||
|
offset: (limit * (page - 1)).toString(),
|
||
|
limit: limit.toString(),
|
||
2 years ago
|
})
|
||
|
|
||
2 years ago
|
audits = list
|
||
2 years ago
|
totalRows = pageInfo.totalRows ?? 0
|
||
2 years ago
|
} catch (e) {
|
||
|
console.error(e)
|
||
|
} finally {
|
||
2 years ago
|
isLoading = false
|
||
2 years ago
|
}
|
||
|
}
|
||
|
|
||
|
onMounted(async () => {
|
||
2 years ago
|
if (audits === null) {
|
||
2 years ago
|
await loadAudits(currentPage, currentLimit)
|
||
2 years ago
|
}
|
||
|
})
|
||
|
|
||
2 years ago
|
const tableHeaderRenderer = (label: string) => () => h('div', { class: 'text-gray-500' }, label)
|
||
2 years ago
|
|
||
2 years ago
|
const columns = [
|
||
|
{
|
||
2 years ago
|
// Operation Type
|
||
|
title: tableHeaderRenderer(t('labels.operationType')),
|
||
2 years ago
|
dataIndex: 'op_type',
|
||
|
key: 'op_type',
|
||
|
},
|
||
|
{
|
||
2 years ago
|
// Operation sub-type
|
||
|
title: tableHeaderRenderer(t('labels.operationSubType')),
|
||
2 years ago
|
dataIndex: 'op_sub_type',
|
||
|
key: 'op_sub_type',
|
||
|
},
|
||
|
{
|
||
2 years ago
|
// Description
|
||
|
title: tableHeaderRenderer(t('labels.description')),
|
||
2 years ago
|
dataIndex: 'description',
|
||
|
key: 'description',
|
||
|
},
|
||
|
{
|
||
2 years ago
|
// User
|
||
|
title: tableHeaderRenderer(t('objects.user')),
|
||
2 years ago
|
dataIndex: 'user',
|
||
|
key: 'user',
|
||
2 years ago
|
customRender: (value: { text: string }) => h('div', {}, value.text || 'Shared base'),
|
||
2 years ago
|
},
|
||
|
{
|
||
2 years ago
|
// Created
|
||
|
title: tableHeaderRenderer(t('labels.created')),
|
||
2 years ago
|
dataIndex: 'created_at',
|
||
|
key: 'created_at',
|
||
|
sort: 'desc',
|
||
|
customRender: (value: { text: string }) =>
|
||
2 years ago
|
h(ATooltip, { placement: 'bottom', title: h('span', {}, value.text) }, () => timeAgo(value.text)),
|
||
2 years ago
|
},
|
||
|
]
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<div class="flex flex-col gap-4 w-full">
|
||
2 years ago
|
<div class="flex flex-row justify-between items-center">
|
||
|
<a-button class="self-start" @click="loadAudits">
|
||
2 years ago
|
<!-- Reload -->
|
||
2 years ago
|
<div class="flex items-center gap-2 text-gray-600 font-light">
|
||
|
<MdiReload :class="{ 'animate-infinite animate-spin !text-success': isLoading }" />
|
||
2 years ago
|
{{ $t('general.reload') }}
|
||
2 years ago
|
</div>
|
||
|
</a-button>
|
||
|
<a-pagination
|
||
|
v-model:current="currentPage"
|
||
|
:page-size="currentLimit"
|
||
|
:total="totalRows"
|
||
|
show-less-items
|
||
|
@change="loadAudits"
|
||
|
/>
|
||
|
</div>
|
||
2 years ago
|
|
||
2 years ago
|
<a-table class="w-full" size="small" :data-source="audits ?? []" :columns="columns" :pagination="false" :loading="isLoading">
|
||
|
<template #emptyText>
|
||
|
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" :description="$t('labels.noData')" />
|
||
|
</template>
|
||
|
</a-table>
|
||
2 years ago
|
</div>
|
||
|
</template>
|