WhiteList.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <page-list
  3. :columns="columns"
  4. :group-actions="groupActions"
  5. :list="list"
  6. :single-actions="singleActions" />
  7. </template>
  8. <script>
  9. import * as R from 'ramda'
  10. import { getStatusTableColumn, getCopyWithContentTableColumn } from '@/utils/common/tableColumn'
  11. import WindowsMixin from '@/mixins/windows'
  12. import expectStatus from '@/constants/expectStatus'
  13. import { HYPERVISORS_MAP } from '@/constants'
  14. import { getNameFilter, getStatusFilter } from '@/utils/common/tableFilter'
  15. export default {
  16. name: 'RedisWhiteList',
  17. mixins: [WindowsMixin],
  18. props: {
  19. params: {
  20. type: Object,
  21. },
  22. data: {
  23. type: Object,
  24. },
  25. },
  26. data () {
  27. const steadyStatus = Object.values(expectStatus.redisACL).flat()
  28. return {
  29. steadyStatus,
  30. list: this.$list.createList(this, {
  31. id: 'RedisWhiteListForRedisSidePage',
  32. resource: 'elasticcacheacls',
  33. getParams: this.params,
  34. steadyStatus,
  35. filterOptions: {
  36. name: getNameFilter(),
  37. status: getStatusFilter('redisACL'),
  38. },
  39. }),
  40. columns: [
  41. getCopyWithContentTableColumn(),
  42. getStatusTableColumn({ statusModule: 'redisACL' }),
  43. {
  44. field: 'ip',
  45. title: 'IP',
  46. slots: {
  47. default: ({ row }) => {
  48. if (row.ip_list) {
  49. const ips = row.ip_list.split(',')
  50. return ips.map(ip => {
  51. return <div><a-tag>{ip}</a-tag></div>
  52. })
  53. }
  54. return ''
  55. },
  56. },
  57. },
  58. ],
  59. groupActions: [
  60. {
  61. label: this.$t('db.text_41'),
  62. permission: 'redis_elasticcacheacls_create',
  63. action: (obj) => {
  64. this.createDialog('RedisWhiteListFormDialog', {
  65. title: this.$t('db.text_41'),
  66. list: this.list,
  67. redisItem: this.data,
  68. allIPList: this.allIPList,
  69. })
  70. },
  71. meta: () => {
  72. const isHuawei = this.data.brand === 'Huawei'
  73. let tooltip = ''
  74. if (isHuawei) {
  75. tooltip = this.$t('db.text_321')
  76. } else if (this.list.total >= 4) {
  77. tooltip = this.$t('db.text_327')
  78. }
  79. if (this.data.brand === 'Qcloud') {
  80. tooltip = this.$t('db.text_355')
  81. }
  82. if ((this.data.brand === HYPERVISORS_MAP.aws.brand || this.data.brand === HYPERVISORS_MAP.azure.brand) && !tooltip) {
  83. tooltip = this.$t('db.text_384', [this.data.brand])
  84. }
  85. return {
  86. buttonType: 'primary',
  87. validate: !tooltip,
  88. tooltip: tooltip,
  89. }
  90. },
  91. },
  92. ],
  93. singleActions: [
  94. {
  95. label: this.$t('db.text_328'),
  96. permission: 'redis_elasticcacheacls_update',
  97. action: (obj) => {
  98. this.createDialog('RedisWhiteListFormDialog', {
  99. title: this.$t('db.text_328'),
  100. steadyStatus: this.steadyStatus,
  101. initialValues: {
  102. name: obj.name,
  103. ip_list: obj.ip_list,
  104. },
  105. allIPList: this.allIPList,
  106. data: [obj],
  107. list: this.list,
  108. columns: this.columns,
  109. redisItem: this.data,
  110. })
  111. },
  112. meta: () => {
  113. const isHuawei = this.data.brand === 'Huawei'
  114. return {
  115. validate: !isHuawei,
  116. tooltip: isHuawei ? this.$t('db.text_202') : null,
  117. }
  118. },
  119. },
  120. {
  121. label: this.$t('db.text_42'),
  122. permission: 'redis_elasticcacheacls_delete',
  123. action: (obj) => {
  124. this.createDialog('RedisWhiteListDeleteDialog', {
  125. data: [obj],
  126. columns: this.columns,
  127. title: this.$t('db.text_314'),
  128. list: this.list,
  129. })
  130. },
  131. meta: (obj) => {
  132. let tooltip = ''
  133. if (obj.name === 'default') {
  134. tooltip = this.$t('db.text_329')
  135. }
  136. return {
  137. validate: !tooltip,
  138. tooltip,
  139. }
  140. },
  141. },
  142. ],
  143. }
  144. },
  145. computed: {
  146. allIPList () {
  147. if (this.list && !R.isEmpty(this.list.data)) {
  148. let ipList = []
  149. Object.values(this.list.data).forEach(({ data }) => {
  150. if (data.ip_list && R.type(data.ip_list) === 'String' && !R.isEmpty(data.ip_list)) {
  151. ipList = [...ipList, ...data.ip_list.split(',')]
  152. }
  153. })
  154. return ipList
  155. }
  156. return []
  157. },
  158. },
  159. created () {
  160. this.list.fetchData()
  161. },
  162. }
  163. </script>