소스 검색

feat: add key type column for certificate list

Jacky 1 년 전
부모
커밋
464e84a64f

+ 11 - 0
app/src/constants/index.ts

@@ -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 }))

+ 8 - 2
app/src/views/certificate/Certificate.vue

@@ -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',

+ 2 - 28
app/src/views/certificate/WildcardCertificate.vue

@@ -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"
               >

+ 2 - 28
app/src/views/domain/cert/components/AutoCertStepOne.vue

@@ -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"
           >