Detail.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <detail
  3. :on-manager="onManager"
  4. :data="data"
  5. :base-info="baseInfo"
  6. :extra-info="extraInfo"
  7. resource="elasticcaches"
  8. statusModule="redis"
  9. auto-hidden-columns-key="mongodb_hidden_columns" />
  10. </template>
  11. <script>
  12. import * as R from 'ramda'
  13. // import { NODE_TYPE, PERFORMANCE_TYPE } from '@DB/views/redis/constants'
  14. import {
  15. getUserTagColumn,
  16. } from '@/utils/common/detailColumn'
  17. import {
  18. getBrandTableColumn,
  19. getSwitchTableColumn,
  20. getBillingTypeTableColumn,
  21. } from '@/utils/common/tableColumn'
  22. import { sizestr } from '@/utils/utils'
  23. import WindowsMixin from '@/mixins/windows'
  24. import { categoryMap } from '../constants'
  25. export default {
  26. name: 'MongodbDetail',
  27. mixins: [WindowsMixin],
  28. props: {
  29. onManager: {
  30. type: Function,
  31. required: true,
  32. },
  33. data: {
  34. type: Object,
  35. required: true,
  36. },
  37. columns: Array,
  38. },
  39. data () {
  40. return {
  41. baseInfo: [
  42. getUserTagColumn({ onManager: this.onManager, resource: 'mongodb', columns: () => this.columns, tipName: this.$t('dictionary.mongodb') }),
  43. getBrandTableColumn(),
  44. getBillingTypeTableColumn(),
  45. {
  46. field: 'zone',
  47. hiddenField: 'region',
  48. title: this.$t('db.text_133'),
  49. slots: {
  50. default: ({ row }) => {
  51. if (!R.isNil(row.slave_zone_infos)) {
  52. const sl = row.slave_zone_infos.map(v => {
  53. return <div>{v.name}({this.$t('db.text_164')})</div>
  54. })
  55. return [<div>{row.zone ? row.zone + '(' + this.$t('db.text_165') + ')' : '-'}</div>, ...sl]
  56. }
  57. return row.zone || '-'
  58. },
  59. },
  60. },
  61. ],
  62. extraInfo: [
  63. {
  64. title: this.$t('db.text_166'),
  65. items: [
  66. {
  67. title: this.$t('db.text_377'),
  68. slots: {
  69. default: ({ row }) => {
  70. return `${row.engine || ''} ${row.engine_version || ''}`
  71. },
  72. },
  73. },
  74. {
  75. title: this.$t('db.text_119'),
  76. slots: {
  77. default: ({ row }) => {
  78. const { category } = row
  79. if (categoryMap[category]) {
  80. if (category === 'sharding') { // 分片
  81. return (categoryMap[row.category] + `(${this.$t('db.text_383', [row.replication_num || 0])})`)
  82. } else if (category === 'replicate') { // 集群
  83. return (categoryMap[row.category] + `(${this.$t('db.text_382', [row.replication_num || 0])})`)
  84. }
  85. }
  86. return '-'
  87. },
  88. },
  89. },
  90. {
  91. field: 'vcpu_count',
  92. title: 'CPU',
  93. slots: {
  94. default: ({ row }) => {
  95. return this.$t('db.text_125', [row.vcpu_count || 0])
  96. },
  97. },
  98. },
  99. {
  100. field: 'vmem_size_mb',
  101. title: this.$t('db.text_132'),
  102. slots: {
  103. default: ({ row }) => {
  104. return sizestr(row.vmem_size_mb, 'M', 1024)
  105. },
  106. },
  107. },
  108. {
  109. title: this.$t('cloudenv.text_6'),
  110. slots: {
  111. default: ({ row }) => {
  112. return sizestr(row.disk_size_mb, 'M', 1024)
  113. },
  114. },
  115. },
  116. {
  117. field: 'connections',
  118. title: this.$t('db.max_connections'),
  119. slots: {
  120. default: ({ row }) => {
  121. return row.connections || '-'
  122. },
  123. },
  124. },
  125. {
  126. field: 'iops',
  127. title: 'IOPS',
  128. slots: {
  129. default: ({ row }) => {
  130. return row.iops || '-'
  131. },
  132. },
  133. },
  134. ],
  135. hidden: () => this.$isScopedPolicyMenuHidden('mongodb_hidden_columns.db_info'),
  136. },
  137. {
  138. title: this.$t('db.text_171'),
  139. items: [
  140. {
  141. field: 'ip_addr',
  142. title: this.$t('db.text_152'),
  143. slots: {
  144. default: ({ row }) => {
  145. if (!row.ip_addr) return '-'
  146. const ret = row.ip_addr.split(';').map(ip => {
  147. return <list-body-cell-wrap hide-field copy row={{ ip: `${ip}:${row.port}` }} field="ip">{`${ip}:${row.port}`}</list-body-cell-wrap>
  148. })
  149. return ret
  150. },
  151. },
  152. },
  153. {
  154. field: 'vpc',
  155. title: 'VPC',
  156. slots: {
  157. default: ({ row }) => {
  158. return row.vpc || '-'
  159. },
  160. },
  161. },
  162. {
  163. field: 'network',
  164. title: this.$t('db.text_176'),
  165. slots: {
  166. default: ({ row }) => {
  167. return row.network || '-'
  168. },
  169. },
  170. },
  171. ],
  172. hidden: () => this.$isScopedPolicyMenuHidden('mongodb_hidden_columns.connection_info'),
  173. },
  174. {
  175. title: this.$t('db.text_179'),
  176. items: [
  177. getSwitchTableColumn({
  178. field: 'disable_delete',
  179. title: this.$t('common.text00076'),
  180. change: val => {
  181. this.onManager('update', {
  182. id: this.data.id,
  183. managerArgs: {
  184. data: { disable_delete: val },
  185. },
  186. })
  187. },
  188. }),
  189. ],
  190. hidden: () => this.$isScopedPolicyMenuHidden('mongodb_hidden_columns.perform_action'),
  191. },
  192. ],
  193. }
  194. },
  195. methods: {
  196. async fetchSwitchPublic (bool) {
  197. if (bool) {
  198. return this.onManager('performAction', {
  199. steadyStatus: 'running',
  200. id: this.data.id,
  201. managerArgs: {
  202. action: 'allocate-public-connection',
  203. },
  204. })
  205. } else {
  206. return this.onManager('performAction', {
  207. steadyStatus: 'running',
  208. id: this.data.id,
  209. managerArgs: {
  210. action: 'release-public-connection',
  211. },
  212. })
  213. }
  214. },
  215. handleSwitchPublicAddress (bool) {
  216. const txts = {
  217. true: {
  218. title: this.$t('db.text_180'),
  219. content: this.$t('db.text_326'),
  220. },
  221. false: {
  222. title: this.$t('db.text_181'),
  223. content: this.$t('db.text_182'),
  224. },
  225. }
  226. this.createDialog('ConfirmDialog', {
  227. ...txts[`${bool}`],
  228. onOk: () => {
  229. return this.fetchSwitchPublic(bool)
  230. },
  231. })
  232. },
  233. },
  234. }
  235. </script>