feat: add key type column for certificate list

This commit is contained in:
Jacky 2024-04-30 15:33:44 +08:00
parent f0dcd67004
commit 464e84a64f
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
4 changed files with 23 additions and 58 deletions

View file

@ -25,3 +25,14 @@ export enum NginxStatus {
Restarting,
Stopped,
}
export const PrivateKeyTypeMask = {
2048: 'RSA2048',
3072: 'RSA3072',
4096: 'RSA4096',
8192: 'RSA8192',
P256: 'EC256',
P384: 'EC384',
} as const
export const PrivateKeyTypeList = Object.entries(PrivateKeyTypeMask).map(([key, name]) => ({ key, name }))

View file

@ -4,11 +4,11 @@ import dayjs from 'dayjs'
import { CloudUploadOutlined, SafetyCertificateOutlined } from '@ant-design/icons-vue'
import { input } from '@/components/StdDesign/StdDataEntry'
import type { customRender } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
import { datetime } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
import { datetime, mask } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
import cert from '@/api/cert'
import type { Column, JSXElements } from '@/components/StdDesign/types'
import type { Cert } from '@/api/cert'
import { AutoCertState } from '@/constants'
import { AutoCertState, PrivateKeyTypeMask } from '@/constants'
import StdTable from '@/components/StdDesign/StdDataDisplay/StdTable.vue'
import WildcardCertificate from '@/views/certificate/WildcardCertificate.vue'
@ -57,6 +57,12 @@ const columns: Column[] = [{
},
sortable: true,
pithy: true,
}, {
title: () => $gettext('Key Type'),
dataIndex: 'key_type',
customRender: mask(PrivateKeyTypeMask),
sortable: true,
pithy: true,
}, {
title: () => $gettext('SSL Certificate Path'),
dataIndex: 'ssl_certificate_path',

View file

@ -4,6 +4,7 @@ import { message } from 'ant-design-vue'
import type { Cert } from '@/api/cert'
import ObtainCertLive from '@/views/domain/cert/components/ObtainCertLive.vue'
import DNSChallenge from '@/views/domain/cert/components/DNSChallenge.vue'
import { PrivateKeyTypeList } from '@/constants'
const emit = defineEmits<{
issued: [void]
@ -50,33 +51,6 @@ const issueCert = () => {
emit('issued')
})
}
const keyType = shallowRef([
{
key: '2048',
name: 'RSA2048',
},
{
key: '3072',
name: 'RSA3072',
},
{
key: '4096',
name: 'RSA4096',
},
{
key: '8192',
name: 'RAS8192',
},
{
key: 'P256',
name: 'EC256',
},
{
key: 'P384',
name: 'EC384',
},
])
</script>
<template>
@ -105,7 +79,7 @@ const keyType = shallowRef([
<AFormItem :label="$gettext('Key Type')">
<ASelect v-model:value="data.key_type">
<ASelectOption
v-for="t in keyType"
v-for="t in PrivateKeyTypeList"
:key="t.key"
:value="t.key"
>

View file

@ -4,6 +4,7 @@ import type { DnsChallenge } from '@/api/auto_cert'
import DNSChallenge from '@/views/domain/cert/components/DNSChallenge.vue'
import type { Cert } from '@/api/cert'
import ACMEUserSelector from '@/views/certificate/ACMEUserSelector.vue'
import { PrivateKeyTypeList } from '@/constants'
defineProps<{
hideNote?: boolean
@ -14,33 +15,6 @@ const no_server_name = inject('no_server_name')
// Provide by ObtainCert.vue
const data = inject('data') as Ref<DnsChallenge & Cert>
const keyType = shallowRef([
{
key: '2048',
name: 'RSA2048',
},
{
key: '3072',
name: 'RSA3072',
},
{
key: '4096',
name: 'RSA4096',
},
{
key: '8192',
name: 'RAS8192',
},
{
key: 'P256',
name: 'EC256',
},
{
key: 'P384',
name: 'EC384',
},
])
onMounted(() => {
if (!data.value.key_type)
data.value.key_type = '2048'
@ -106,7 +80,7 @@ onMounted(() => {
<AFormItem :label="$gettext('Key Type')">
<ASelect v-model:value="data.key_type">
<ASelectOption
v-for="t in keyType"
v-for="t in PrivateKeyTypeList"
:key="t.key"
:value="t.key"
>