feat: update notification template for config sync

This commit is contained in:
Jacky 2024-07-26 17:22:01 +08:00
parent 1c1da92363
commit c9370a0562
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
7 changed files with 84 additions and 93 deletions

View file

@ -13,13 +13,13 @@ export const detailRender = (args: customRender) => {
return syncCertificateSuccess(args.text)
case 'Sync Certificate Error':
return syncCertificateError(args.text)
case 'Sync Rename Configuration Success':
case 'Rename Remote Config Success':
return syncRenameConfigSuccess(args.text)
case 'Sync Rename Configuration Error':
case 'Rename Remote Config Error':
return syncRenameConfigError(args.text)
case 'Sync Configuration Success':
case 'Sync Config Success':
return syncConfigSuccess(args.text)
case 'Sync Configuration Error':
case 'Sync Config Error':
return syncConfigError(args.text)
default:
return args.text

View file

@ -13,7 +13,7 @@ export interface StdCurdProps<T> extends StdTableProps<T> {
modalMask?: boolean
exportExcel?: boolean
importExcel?: boolean
disableTrash?: boolean
disableAdd?: boolean
onClickAdd?: () => void
@ -201,7 +201,7 @@ const localOverwriteParams = reactive(props.overwriteParams ?? {})
@click="add"
>{{ $gettext('Add') }}</a>
<slot name="extra" />
<template v-if="!disableDelete">
<template v-if="!disableDelete && !disableTrash">
<a
v-if="!getParams.trash"
@click="getParams.trash = true"

View file

@ -33,6 +33,7 @@ const pageSize = computed({
v-model:pageSize="pageSize"
:disabled="loading"
:current="pagination.current_page"
show-size-changer
:size="size"
:total="pagination.total"
@change="change"

View file

@ -20,7 +20,6 @@ export interface StdTableProps<T = any> {
title?: string
mode?: string
rowKey?: string
api: Curd<T>
columns: Column[]
// eslint-disable-next-line @typescript-eslint/no-explicit-any

View file

@ -2,41 +2,8 @@
import { message } from 'ant-design-vue'
import StdCurd from '@/components/StdDesign/StdDataDisplay/StdCurd.vue'
import notification from '@/api/notification'
import type { Column } from '@/components/StdDesign/types'
import type { customRender } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
import { datetime, mask } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
import { NotificationType } from '@/constants'
import { useUserStore } from '@/pinia'
import { detailRender } from '@/components/Notification/detailRender'
const columns: Column[] = [{
title: () => $gettext('Type'),
dataIndex: 'type',
customRender: mask(NotificationType),
sortable: true,
pithy: true,
}, {
title: () => $gettext('Title'),
dataIndex: 'title',
customRender: (args: customRender) => {
return h('span', $gettext(args.text))
},
pithy: true,
}, {
title: () => $gettext('Details'),
dataIndex: 'details',
customRender: detailRender,
pithy: true,
}, {
title: () => $gettext('Created at'),
dataIndex: 'created_at',
sortable: true,
customRender: datetime,
pithy: true,
}, {
title: () => $gettext('Action'),
dataIndex: 'action',
}]
import notificationColumns from '@/views/notification/notificationColumns'
const { unreadCount } = storeToRefs(useUserStore())
@ -60,10 +27,11 @@ watch(unreadCount, () => {
<StdCurd
ref="curd"
:title="$gettext('Notification')"
:columns="columns"
:columns="notificationColumns"
:api="notification"
disabled-modify
disable-modify
disable-add
disable-trash
>
<template #extra>
<APopconfirm

View file

@ -0,0 +1,58 @@
import { Tag } from 'ant-design-vue'
import type { Column } from '@/components/StdDesign/types'
import type { customRender } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
import { datetime } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
import { NotificationTypeT } from '@/constants'
import { detailRender } from '@/components/Notification/detailRender'
const columns: Column[] = [{
title: () => $gettext('Type'),
dataIndex: 'type',
customRender: (args: customRender) => {
if (args.text === NotificationTypeT.Error) {
return <Tag color="error">
{ $gettext('Error') }
</Tag>
}
else if (args.text === NotificationTypeT.Warning) {
return <Tag color="warning">
{ $gettext('Warning') }
</Tag>
}
else if (args.text === NotificationTypeT.Info) {
return <Tag color="info">
{ $gettext('Info')}
</Tag>
}
else if (args.text === NotificationTypeT.Success) {
return <Tag color="success">
{ $gettext('Success') }
</Tag>
}
},
sortable: true,
pithy: true,
}, {
title: () => $gettext('Title'),
dataIndex: 'title',
customRender: (args: customRender) => {
return h('span', $gettext(args.text))
},
pithy: true,
}, {
title: () => $gettext('Details'),
dataIndex: 'details',
customRender: detailRender,
pithy: true,
}, {
title: () => $gettext('Created at'),
dataIndex: 'created_at',
sortable: true,
customRender: datetime,
pithy: true,
}, {
title: () => $gettext('Action'),
dataIndex: 'action',
}]
export default columns