1
0

envColumns.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import type { CustomRenderProps } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
  2. import type { Column, JSXElements } from '@/components/StdDesign/types'
  3. import { datetime } from '@/components/StdDesign/StdDataDisplay/StdTableTransformer'
  4. import { input, switcher } from '@/components/StdDesign/StdDataEntry'
  5. import { Badge, Tag } from 'ant-design-vue'
  6. import { h } from 'vue'
  7. const columns: Column[] = [{
  8. title: () => $gettext('Name'),
  9. dataIndex: 'name',
  10. sorter: true,
  11. pithy: true,
  12. edit: {
  13. type: input,
  14. },
  15. search: true,
  16. }, {
  17. title: () => $gettext('URL'),
  18. dataIndex: 'url',
  19. sorter: true,
  20. pithy: true,
  21. edit: {
  22. type: input,
  23. config: {
  24. placeholder: () => 'https://10.0.0.1:9000',
  25. },
  26. },
  27. }, {
  28. title: () => $gettext('Version'),
  29. dataIndex: 'version',
  30. pithy: true,
  31. }, {
  32. title: () => 'NodeSecret',
  33. dataIndex: 'token',
  34. sorter: true,
  35. hiddenInTable: true,
  36. edit: {
  37. type: input,
  38. },
  39. },
  40. // {
  41. // title: () => $gettext('OperationSync'),
  42. // dataIndex: 'operation_sync',
  43. // sorter: true,
  44. // pithy: true,
  45. // edit: {
  46. // type: antSwitch
  47. // },
  48. // extra: $gettext('Whether config api regex that will redo on this environment'),
  49. // customRender: (args: customRender) => {
  50. // const {operation_sync} = args.record
  51. // if (operation_sync) {
  52. // return h(Tag, {color: 'success'}, {default: ()=> h('span', $gettext('Yes'))})
  53. // } else {
  54. // return h(Tag, {color: 'default'}, {default: ()=> h('span', $gettext('No'))})
  55. // }
  56. // },
  57. // }, {
  58. // title: () => $gettext('SyncApiRegex'),
  59. // dataIndex: 'sync_api_regex',
  60. // sorter: true,
  61. // pithy: true,
  62. // display: false,
  63. // edit: {
  64. // type: textarea,
  65. // show: (data) => {
  66. // const {operation_sync} = data
  67. // return operation_sync
  68. // }
  69. // },
  70. // extra: $gettext('Such as Reload and Configs, regex can configure as `/api/nginx/reload|/api/nginx/test|/api/config/.+`, please see system api'),
  71. // },
  72. {
  73. title: () => $gettext('Status'),
  74. dataIndex: 'status',
  75. customRender: (args: CustomRenderProps) => {
  76. const template: JSXElements = []
  77. const { text } = args
  78. if (args.record.enabled) {
  79. if (text === true || text > 0) {
  80. template.push(<Badge status="success" />)
  81. template.push($gettext('Online'))
  82. }
  83. else {
  84. template.push(<Badge status="error" />)
  85. template.push($gettext('Offline'))
  86. }
  87. }
  88. else {
  89. template.push(<Badge status="default" />)
  90. template.push($gettext('Disabled'))
  91. }
  92. return h('div', template)
  93. },
  94. sorter: true,
  95. pithy: true,
  96. }, {
  97. title: () => $gettext('Enabled'),
  98. dataIndex: 'enabled',
  99. customRender: (args: CustomRenderProps) => {
  100. const template: JSXElements = []
  101. const { text } = args
  102. if (text === true || text > 0)
  103. template.push(<Tag color="green">{$gettext('Enabled')}</Tag>)
  104. else
  105. template.push(<Tag color="orange">{$gettext('Disabled')}</Tag>)
  106. return h('div', template)
  107. },
  108. edit: {
  109. type: switcher,
  110. },
  111. sorter: true,
  112. pithy: true,
  113. }, {
  114. title: () => $gettext('Updated at'),
  115. dataIndex: 'updated_at',
  116. customRender: datetime,
  117. sorter: true,
  118. pithy: true,
  119. }, {
  120. title: () => $gettext('Action'),
  121. dataIndex: 'action',
  122. }]
  123. export default columns