|
|
@ -1,5 +1,5 @@ |
|
|
|
import { useTranslation } from '../../../i18n.ts' |
|
|
|
import { Button, Form, Popconfirm, Divider, Space, Tooltip, Badge } from 'antd' |
|
|
|
import { Button, Form, Space, Tooltip, Badge, Divider } from 'antd' |
|
|
|
import { useAtom, useAtomValue } from 'jotai' |
|
|
|
import { |
|
|
|
deleteWebsiteDnsAccountAtom, |
|
|
@ -17,8 +17,10 @@ import { useStyle } from './style.ts' |
|
|
|
import { FilterOutlined } from '@ant-design/icons' |
|
|
|
import { getValueCount } from '@/utils' |
|
|
|
import { Table as ProTable } from '@/components/table' |
|
|
|
import {DNSTypeEnum, DNSTypes, syncDNSAtom} from "@/store/websites/dns.ts"; |
|
|
|
import {WebSite} from "@/types"; |
|
|
|
import { DNSTypeEnum, DNSTypes, syncDNSAtom } from '@/store/websites/dns.ts' |
|
|
|
import { WebSite } from '@/types' |
|
|
|
import Switch from '@/components/switch' |
|
|
|
import Popconfirm from '@/components/popconfirm' |
|
|
|
|
|
|
|
const i18nPrefix = 'websiteDnsAccounts.list' |
|
|
|
const getKeyColumn = (type: string, t) => { |
|
|
@ -28,14 +30,14 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
columns.push(...[ |
|
|
|
{ |
|
|
|
title: t('website.ssl.dns.columns.accessKey', 'Access Key'), |
|
|
|
dataIndex: 'accessKey', |
|
|
|
dataIndex: [ 'authorization', 'accessKey' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: t('website.ssl.dns.columns.secretKey', 'Secret Key'), |
|
|
|
dataIndex: 'secretKey', |
|
|
|
dataIndex: [ 'authorization', 'secretKey' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
@ -47,13 +49,13 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
columns.push(...[ |
|
|
|
{ |
|
|
|
title: t('website.ssl.dns.columns.secretID', 'Secret ID'), |
|
|
|
dataIndex: 'secretID', |
|
|
|
dataIndex: [ 'authorization', 'secretID' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
|
}, { |
|
|
|
title: t('website.ssl.dns.columns.secretKey', 'Secret Key'), |
|
|
|
dataIndex: 'secretKey', |
|
|
|
dataIndex: [ 'authorization', 'secretKey' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
@ -65,13 +67,13 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
columns.push(...[ |
|
|
|
{ |
|
|
|
title: t('website.ssl.dns.columns.apiId', 'ID'), |
|
|
|
dataIndex: 'apiId', |
|
|
|
dataIndex: [ 'authorization', 'apiId' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
|
}, { |
|
|
|
title: t('website.ssl.dns.columns.token', 'Token'), |
|
|
|
dataIndex: 'token', |
|
|
|
dataIndex: [ 'authorization', 'token' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
@ -83,13 +85,13 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
columns.push(...[ |
|
|
|
{ |
|
|
|
title: t('website.ssl.dns.columns.email', 'Email'), |
|
|
|
dataIndex: 'email', |
|
|
|
dataIndex: [ 'authorization', 'email' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
|
}, { |
|
|
|
title: t('website.ssl.dns.columns.apiKey', 'API ToKen'), |
|
|
|
dataIndex: 'apiKey', |
|
|
|
dataIndex: [ 'authorization', 'apiKey' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
@ -103,7 +105,7 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
case DNSTypeEnum.NameSilo: |
|
|
|
columns.push({ |
|
|
|
title: t('website.ssl.dns.columns.apiKey', 'API Key'), |
|
|
|
dataIndex: 'apiKey', |
|
|
|
dataIndex: [ 'authorization', 'apiKey' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
@ -112,7 +114,7 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
if (type === DNSTypeEnum.NameCheap) { |
|
|
|
columns.push({ |
|
|
|
title: t('website.ssl.dns.columns.apiUser', 'API User'), |
|
|
|
dataIndex: 'apiUser', |
|
|
|
dataIndex: [ 'authorization', 'apiUser' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
@ -120,7 +122,7 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
} else if (type === DNSTypeEnum.Godaddy) { |
|
|
|
columns.push({ |
|
|
|
title: t('website.ssl.dns.columns.apiSecret', 'API Secret'), |
|
|
|
dataIndex: 'apiSecret', |
|
|
|
dataIndex: [ 'authorization', 'apiSecret' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
@ -131,14 +133,14 @@ const getKeyColumn = (type: string, t) => { |
|
|
|
columns.push( |
|
|
|
{ |
|
|
|
title: t('website.ssl.dns.columns.apiUser', 'UserName'), |
|
|
|
dataIndex: 'apiUser', |
|
|
|
dataIndex: [ 'authorization', 'apiUser' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: t('website.ssl.dns.columns.token', 'Token'), |
|
|
|
dataIndex: 'token', |
|
|
|
dataIndex: [ 'authorization', 'token' ], |
|
|
|
formItemProps: { |
|
|
|
rules: [ { required: true, message: t('message.required') } ] |
|
|
|
} |
|
|
@ -181,6 +183,12 @@ const WebsiteDnsAccount = () => { |
|
|
|
title: t(`${i18nPrefix}.columns.name`, '名称'), |
|
|
|
dataIndex: 'name', |
|
|
|
valueType: 'text', |
|
|
|
width: 250, |
|
|
|
fieldProps: { |
|
|
|
style: { |
|
|
|
width: '100%' |
|
|
|
} |
|
|
|
}, |
|
|
|
formItemProps: { |
|
|
|
rules: [ |
|
|
|
{ required: true, message: t('message.required', '请输入') } |
|
|
@ -188,10 +196,26 @@ const WebsiteDnsAccount = () => { |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: t(`${i18nPrefix}.columns.name`, '标签'), |
|
|
|
dataIndex: 'tag', |
|
|
|
valueType: 'text', |
|
|
|
hideInForm: true, |
|
|
|
width: 200, |
|
|
|
fieldProps: { |
|
|
|
style: { |
|
|
|
width: '100%' |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: t(`${i18nPrefix}.columns.type`, '类型'), |
|
|
|
dataIndex: 'type', |
|
|
|
valueType: 'select', |
|
|
|
width: 200, |
|
|
|
fieldProps: { |
|
|
|
style: { |
|
|
|
width: '100%' |
|
|
|
}, |
|
|
|
options: DNSTypes |
|
|
|
}, |
|
|
|
formItemProps: { |
|
|
@ -212,10 +236,16 @@ const WebsiteDnsAccount = () => { |
|
|
|
{ |
|
|
|
title: t(`${i18nPrefix}.columns.status`, '状态'), |
|
|
|
dataIndex: 'status', |
|
|
|
valueType: 'switch', |
|
|
|
width: 200, |
|
|
|
render(_dom, record) { |
|
|
|
return <Switch size={'small'} value={record.status}/> |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: t(`${i18nPrefix}.columns.option`, '操作'), |
|
|
|
key: 'option', |
|
|
|
width: 300, |
|
|
|
valueType: 'option', |
|
|
|
fixed: 'right', |
|
|
|
render: (_, record) => [ |
|
|
@ -223,20 +253,24 @@ const WebsiteDnsAccount = () => { |
|
|
|
as={'a'} |
|
|
|
disabled={record.status === 2} |
|
|
|
onClick={() => { |
|
|
|
record.status = record.status > 0 |
|
|
|
if (typeof record.authorization === 'string') { |
|
|
|
record.authorization = JSON.parse(record.authorization) |
|
|
|
} |
|
|
|
form.setFieldsValue(record) |
|
|
|
setOpen(true) |
|
|
|
}}>{t('actions.edit')}</Action>, |
|
|
|
<Divider type={'vertical'}/>, |
|
|
|
<Popconfirm |
|
|
|
key={'sync_confirm'} |
|
|
|
disabled={isAsyncing || record.status === 2} |
|
|
|
onConfirm={() => { |
|
|
|
asyncDNS(record) |
|
|
|
}} |
|
|
|
title={t('message.deleteConfirm')}> |
|
|
|
<a key="del"> |
|
|
|
title={t('message.syncConfirm', '您确定要同步吗?')}> |
|
|
|
{t('actions.sync', '同步')} |
|
|
|
</a> |
|
|
|
</Popconfirm>, |
|
|
|
<Divider type={'vertical'}/>, |
|
|
|
<Popconfirm |
|
|
|
key={'del_confirm'} |
|
|
|
disabled={isDeleting} |
|
|
@ -244,9 +278,7 @@ const WebsiteDnsAccount = () => { |
|
|
|
deleteWebsiteDnsAccount([ record.id ]) |
|
|
|
}} |
|
|
|
title={t('message.deleteConfirm')}> |
|
|
|
<a key="del"> |
|
|
|
{t('actions.delete', '删除')} |
|
|
|
</a> |
|
|
|
</Popconfirm> |
|
|
|
] |
|
|
|
} |
|
|
@ -270,7 +302,19 @@ const WebsiteDnsAccount = () => { |
|
|
|
<ListPageLayout className={styles.container}> |
|
|
|
<ProTable |
|
|
|
rowKey="id" |
|
|
|
headerTitle={t(`${i18nPrefix}.title`, '账号管理管理')} |
|
|
|
headerTitle={ |
|
|
|
<Space> |
|
|
|
<Button key={'add'} |
|
|
|
onClick={() => { |
|
|
|
form.resetFields() |
|
|
|
form.setFieldsValue({ |
|
|
|
id: 0, |
|
|
|
}) |
|
|
|
setOpen(true) |
|
|
|
}} |
|
|
|
type={'primary'}>{t(`${i18nPrefix}.add`, '添加帐号')}</Button> |
|
|
|
</Space> |
|
|
|
} |
|
|
|
toolbar={{ |
|
|
|
search: { |
|
|
|
loading: isFetching && !!search?.title, |
|
|
@ -298,25 +342,17 @@ const WebsiteDnsAccount = () => { |
|
|
|
</Badge> |
|
|
|
</Tooltip>, |
|
|
|
<Divider type={'vertical'} key={'divider'}/>, |
|
|
|
<Button key={'add'} |
|
|
|
onClick={() => { |
|
|
|
form.resetFields() |
|
|
|
form.setFieldsValue({ |
|
|
|
id: 0, |
|
|
|
}) |
|
|
|
setOpen(true) |
|
|
|
}} |
|
|
|
type={'primary'}>{t(`${i18nPrefix}.add`, '添加')}</Button> |
|
|
|
] |
|
|
|
}} |
|
|
|
scroll={{ |
|
|
|
x: 2500, y: 'calc(100vh - 290px)' |
|
|
|
// x: 2500,
|
|
|
|
y: 'calc(100vh - 290px)' |
|
|
|
}} |
|
|
|
search={false} |
|
|
|
onRow={(record) => { |
|
|
|
return { |
|
|
|
className: cx({ |
|
|
|
'ant-table-row-selected': currentWebsiteDnsAccount?.id === record.id |
|
|
|
// 'ant-table-row-selected': currentWebsiteDnsAccount?.id === record.id
|
|
|
|
}), |
|
|
|
onClick: () => { |
|
|
|
setWebsiteDnsAccount(record) |
|
|
@ -375,9 +411,11 @@ const WebsiteDnsAccount = () => { |
|
|
|
//
|
|
|
|
// }}
|
|
|
|
onFinish={async (values) => { |
|
|
|
values.status = values.status ? 1 : 0 |
|
|
|
saveOrUpdate(values) |
|
|
|
}} |
|
|
|
columns={columns as ProFormColumnsType[]}/> |
|
|
|
|
|
|
|
<BetaSchemaForm |
|
|
|
title={t(`${i18nPrefix}.filter.title`, '账号管理高级查询')} |
|
|
|
grid={true} |
|
|
@ -438,6 +476,7 @@ const WebsiteDnsAccount = () => { |
|
|
|
|
|
|
|
}} |
|
|
|
columns={columns.filter(item => !item.hideInSearch) as ProFormColumnsType[]}/> |
|
|
|
|
|
|
|
</ListPageLayout> |
|
|
|
) |
|
|
|
} |
|
|
|