Cert.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <script setup lang="tsx">
  2. import {useGettext} from 'vue3-gettext'
  3. import {input} from '@/components/StdDataEntry'
  4. import {customRender, datetime} from '@/components/StdDataDisplay/StdTableTransformer'
  5. import {Badge} from 'ant-design-vue'
  6. import cert from '@/api/cert'
  7. import StdCurd from '@/components/StdDataDisplay/StdCurd.vue'
  8. import CodeEditor from '@/components/CodeEditor/CodeEditor.vue'
  9. import CertInfo from '@/views/domain/cert/CertInfo.vue'
  10. import {h} from 'vue'
  11. const {$gettext, interpolate} = useGettext()
  12. const columns = [{
  13. title: () => $gettext('Name'),
  14. dataIndex: 'name',
  15. sorter: true,
  16. pithy: true,
  17. customRender: (args: customRender) => {
  18. const {text, record} = args
  19. if (!text) {
  20. return h('div', record.domain)
  21. }
  22. return h('div', text)
  23. },
  24. edit: {
  25. type: input
  26. },
  27. search: true
  28. }, {
  29. title: () => $gettext('Config Name'),
  30. dataIndex: 'filename',
  31. sorter: true,
  32. pithy: true
  33. }, {
  34. title: () => $gettext('Auto Cert'),
  35. dataIndex: 'auto_cert',
  36. customRender: (args: customRender) => {
  37. const template: any = []
  38. const {text, column} = args
  39. if (text === true || text > 0) {
  40. template.push(<Badge status="success"/>)
  41. template.push($gettext('Enabled'))
  42. } else {
  43. template.push(<Badge status="warning"/>)
  44. template.push($gettext('Disabled'))
  45. }
  46. return h('div', template)
  47. },
  48. sorter: true,
  49. pithy: true
  50. }, {
  51. title: () => $gettext('SSL Certificate Path'),
  52. dataIndex: 'ssl_certificate_path',
  53. edit: {
  54. type: input
  55. },
  56. display: false
  57. }, {
  58. title: () => $gettext('SSL Certificate Key Path'),
  59. dataIndex: 'ssl_certificate_key_path',
  60. edit: {
  61. type: input
  62. },
  63. display: false
  64. }, {
  65. title: () => $gettext('Updated at'),
  66. dataIndex: 'updated_at',
  67. customRender: datetime,
  68. sorter: true,
  69. pithy: true
  70. }, {
  71. title: () => $gettext('Action'),
  72. dataIndex: 'action'
  73. }]
  74. </script>
  75. <template>
  76. <std-curd :title="$gettext('Certification')" :api="cert" :columns="columns"
  77. row-key="name"
  78. >
  79. <template #beforeEdit="{data}">
  80. <template v-if="data.auto_cert===1">
  81. <div style="margin-bottom: 15px">
  82. <a-alert
  83. :message="$gettext('Auto cert is enabled, please do not modify this certification.')"
  84. type="info"
  85. show-icon/>
  86. </div>
  87. <div v-if="!data.filename" style="margin-bottom: 15px">
  88. <a-alert
  89. :message="$gettext('This auto-cert item is invalid, please remove it.')"
  90. type="error"
  91. show-icon/>
  92. </div>
  93. <div v-else-if="!data.domains" style="margin-bottom: 15px">
  94. <a-alert
  95. :message="interpolate($gettext('Domains list is empty, try to reopen auto-cert for %{config}'), {config: data.filename})"
  96. type="error"
  97. show-icon/>
  98. </div>
  99. <div v-if="data.log" style="margin-bottom: 15px">
  100. <a-form layout="vertical">
  101. <a-form-item :label="$gettext('Auto-Cert Log')">
  102. <p>{{ data.log }}</p>
  103. </a-form-item>
  104. </a-form>
  105. </div>
  106. </template>
  107. <a-form layout="vertical" v-if="data.certificate_info">
  108. <a-form-item :label="$gettext('Certificate Status')">
  109. <cert-info :cert="data.certificate_info"/>
  110. </a-form-item>
  111. </a-form>
  112. </template>
  113. <template #edit="{data}">
  114. <a-form layout="vertical">
  115. <a-form-item :label="$gettext('SSL Certification Content')">
  116. <code-editor v-model:content="data.ssl_certification" default-height="200px"/>
  117. </a-form-item>
  118. <a-form-item :label="$gettext('SSL Certification Key Content')">
  119. <code-editor v-model:content="data.ssl_certification_key" default-height="200px"/>
  120. </a-form-item>
  121. </a-form>
  122. </template>
  123. </std-curd>
  124. </template>
  125. <style lang="less" scoped>
  126. </style>