Implement event pruning

This commit is contained in:
cuigh
2022-01-04 16:44:03 +08:00
parent e70d907c06
commit d0eb101aee
9 changed files with 62 additions and 8 deletions

View File

@@ -28,6 +28,10 @@ export class EventApi {
search(args: SearchArgs) {
return ajax.get<SearchResult>('/event/search', args)
}
prune(days: number) {
return ajax.post<Result<Object>>('/event/prune', { days })
}
}
export default new EventApi

View File

@@ -247,6 +247,10 @@ export default {
"title": "Prune volume",
"body": "Are you sure you want to clean up unused data volumes?",
},
"prune_event": {
"title": "Prune event",
"label": "Retention days",
},
},
"objects": {
"registry": "Registry | Registries",

View File

@@ -247,6 +247,10 @@ export default {
"title": "清理数据卷",
"body": "是否确实要清理未使用的数据卷?",
},
"prune_event": {
"title": "清理事件",
"label": "保留天数",
},
},
"objects": {
"registry": "镜像仓库",

View File

@@ -45,7 +45,7 @@
</template>
<script setup lang="ts">
import { reactive } from "vue";
import { h, reactive, ref } from "vue";
import {
NSpace,
NButton,
@@ -53,6 +53,8 @@ import {
NSelect,
NInput,
NIcon,
NFormItem,
NInputNumber,
} from "naive-ui";
import { CloseOutline as CloseIcon } from "@vicons/ionicons5";
import XPageHeader from "@/components/PageHeader.vue";
@@ -61,7 +63,6 @@ import type { Event } from "@/api/event";
import { useDataTable } from "@/utils/data-table";
import { renderLink, renderTag, renderTime } from "@/utils/render";
import { useI18n } from 'vue-i18n'
import type { RouteLocationRaw } from "vue-router";
const { t } = useI18n()
const filter = reactive({
@@ -225,6 +226,21 @@ function renderObject(e: Event) {
}
function prune() {
window.message.info("TODO...")
const days = ref(7) as any
window.dialog.warning({
title: t('dialogs.prune_event.title'),
content: () => h(
NFormItem,
{ label: t('dialogs.prune_event.label'), labelPlacement: 'top', showFeedback: false },
{ default: () => h(NInputNumber, { min: 0, defaultValue: days, style: 'width: 100%' }) }
),
positiveText: t('buttons.confirm'),
negativeText: t('buttons.cancel'),
onPositiveClick: async () => {
eventApi.prune(days.value);
window.message.success(t('texts.action_success'))
fetchData()
}
})
}
</script>