Detail.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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="redis_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. // getExtTagColumn,
  17. } from '@/utils/common/detailColumn'
  18. import {
  19. getBrandTableColumn,
  20. getSwitchTableColumn,
  21. getBillingTypeTableColumn,
  22. } from '@/utils/common/tableColumn'
  23. import { sizestr, sizestrWithUnit } from '@/utils/utils'
  24. import WindowsMixin from '@/mixins/windows'
  25. export default {
  26. name: 'redisDetail',
  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: 'elasticcache', columns: () => this.columns, tipName: this.$t('dictionary.elasticcache') }),
  43. // getExtTagColumn({ onManager: this.onManager, resource: 'elasticcache', columns: () => this.columns, tipName: this.$t('dictionary.elasticcache') }),
  44. getBrandTableColumn(),
  45. getBillingTypeTableColumn(),
  46. {
  47. field: 'zone',
  48. hiddenField: 'region',
  49. title: this.$t('db.text_133'),
  50. slots: {
  51. default: ({ row }) => {
  52. if (!R.isNil(row.slave_zone_infos)) {
  53. const sl = row.slave_zone_infos.map(v => {
  54. return <div>{v.name}({this.$t('db.text_164')})</div>
  55. })
  56. return [<div>{row.zone ? row.zone + '(' + this.$t('db.text_165') + ')' : '-'}</div>, ...sl]
  57. }
  58. return row.zone || '-'
  59. },
  60. },
  61. },
  62. ],
  63. extraInfo: [
  64. {
  65. title: this.$t('db.text_166'),
  66. items: [
  67. {
  68. title: this.$t('db.text_112'),
  69. slots: {
  70. default: ({ row }) => {
  71. return `${row.engine || ''} ${row.engine_version || ''}`
  72. },
  73. },
  74. },
  75. {
  76. title: this.$t('db.text_271'),
  77. slots: {
  78. default: ({ row }) => {
  79. return NODE_TYPE[row.node_type]
  80. },
  81. },
  82. },
  83. {
  84. title: this.$t('db.text_272'),
  85. slots: {
  86. default: ({ row }) => {
  87. return PERFORMANCE_TYPE[row.performance_type] || '-'
  88. },
  89. },
  90. },
  91. {
  92. title: this.$t('db.text_167'),
  93. slots: {
  94. default: ({ row }) => {
  95. if (row.maintain_start_time && row.maintain_end_time) {
  96. return `${row.maintain_start_time}${row.maintain_end_time ? ' ~ ' + row.maintain_end_time : ''}`
  97. }
  98. return '-'
  99. },
  100. },
  101. },
  102. {
  103. field: 'instance_type',
  104. title: this.$t('db.text_168'),
  105. },
  106. {
  107. field: 'cpu_arch',
  108. title: 'CPU',
  109. slots: {
  110. default: ({ row }) => {
  111. return row.cpu_arch || '-'
  112. },
  113. },
  114. },
  115. {
  116. field: 'arch_type',
  117. title: this.$t('db.text_322'),
  118. },
  119. {
  120. field: 'capacity_mb',
  121. title: this.$t('db.text_132'),
  122. slots: {
  123. default: ({ row }) => {
  124. return sizestr(row.capacity_mb, 'M', 1024)
  125. },
  126. },
  127. },
  128. {
  129. field: 'connections',
  130. title: this.$t('db.max_connections'),
  131. slots: {
  132. default: ({ row }) => {
  133. return row.connections || '-'
  134. },
  135. },
  136. },
  137. {
  138. field: 'bandwidth',
  139. title: this.$t('db.max_ip_bandwidth'),
  140. slots: {
  141. default: ({ row }) => {
  142. return row.bandwidth ? sizestrWithUnit(row.bandwidth, 'M', 1024) + '/s' : '-'
  143. },
  144. },
  145. },
  146. ],
  147. hidden: () => this.$isScopedPolicyMenuHidden('redis_hidden_columns.db_info'),
  148. },
  149. {
  150. title: this.$t('db.text_171'),
  151. items: [
  152. {
  153. field: 'private_ip_addr',
  154. title: this.$t('db.text_172'),
  155. slots: {
  156. default: ({ row }) => {
  157. const pri = row.private_dns || row.private_ip_addr
  158. if (pri) {
  159. return `${pri}:${row.private_connect_port}`
  160. }
  161. return '-'
  162. },
  163. },
  164. },
  165. {
  166. field: 'public_ip_addr',
  167. title: this.$t('db.text_173'),
  168. slots: {
  169. default: ({ row }) => {
  170. const pub = row.public_dns || row.public_ip_addr
  171. const port = row.public_connect_port
  172. const btnTxt = pub ? this.$t('db.text_174') : this.$t('db.text_175')
  173. const isRunning = row.status === 'running'
  174. const notRunninTip = !isRunning ? this.$t('db.text_156') : null
  175. let RenderSwitchBtn = null
  176. if (isRunning) {
  177. RenderSwitchBtn = (<a-button type="link" onClick={() => this.handleSwitchPublicAddress(!pub)}>{btnTxt}</a-button>)
  178. } else {
  179. RenderSwitchBtn = (
  180. <a-tooltip placement='top' title={notRunninTip}>
  181. <a-button type="link" disabled>{btnTxt}</a-button>
  182. </a-tooltip>
  183. )
  184. }
  185. if (row.provider === 'Huawei' || row.provider === 'Qcloud') {
  186. RenderSwitchBtn = null
  187. }
  188. return (
  189. <div>
  190. {pub ? `${pub}:${port}` : '-' }
  191. {RenderSwitchBtn}
  192. </div>
  193. )
  194. },
  195. },
  196. },
  197. {
  198. field: 'vpc',
  199. title: 'VPC',
  200. slots: {
  201. default: ({ row }) => {
  202. return row.vpc || '-'
  203. },
  204. },
  205. },
  206. {
  207. field: 'network',
  208. title: this.$t('db.text_176'),
  209. slots: {
  210. default: ({ row }) => {
  211. return row.network || '-'
  212. },
  213. },
  214. },
  215. {
  216. field: 'auth_mode',
  217. title: this.$t('db.text_323'),
  218. slots: {
  219. default: ({ row }) => {
  220. return row.auth_mode === 'on' ? this.$t('db.text_324') : this.$t('db.text_325')
  221. },
  222. },
  223. },
  224. {
  225. field: 'secgroups',
  226. title: this.$t('compute.text_105'),
  227. slots: {
  228. default: ({ row }) => {
  229. if (!row.secgroups) return '-'
  230. return row.secgroups.map((item) => {
  231. return <list-body-cell-wrap copy hideField={true} field='name' row={item} message={item.name}>
  232. <side-page-trigger permission='secgroups_get' name='SecGroupSidePage' id={item.id} vm={this}>{ item.name }</side-page-trigger>
  233. </list-body-cell-wrap>
  234. })
  235. },
  236. },
  237. hidden: () => this.data.brand !== 'Qcloud',
  238. },
  239. ],
  240. hidden: () => this.$isScopedPolicyMenuHidden('redis_hidden_columns.connection_info'),
  241. },
  242. {
  243. title: this.$t('db.text_179'),
  244. items: [
  245. getSwitchTableColumn({
  246. field: 'disable_delete',
  247. title: this.$t('common.text00076'),
  248. change: val => {
  249. this.onManager('update', {
  250. id: this.data.id,
  251. managerArgs: {
  252. data: { disable_delete: val },
  253. },
  254. })
  255. },
  256. }),
  257. ],
  258. hidden: () => this.$isScopedPolicyMenuHidden('redis_hidden_columns.perform_action'),
  259. },
  260. ],
  261. }
  262. },
  263. methods: {
  264. async fetchSwitchPublic (bool) {
  265. if (bool) {
  266. return this.onManager('performAction', {
  267. steadyStatus: 'running',
  268. id: this.data.id,
  269. managerArgs: {
  270. action: 'allocate-public-connection',
  271. },
  272. })
  273. } else {
  274. return this.onManager('performAction', {
  275. steadyStatus: 'running',
  276. id: this.data.id,
  277. managerArgs: {
  278. action: 'release-public-connection',
  279. },
  280. })
  281. }
  282. },
  283. handleSwitchPublicAddress (bool) {
  284. const txts = {
  285. true: {
  286. title: this.$t('db.text_180'),
  287. content: this.$t('db.text_326'),
  288. },
  289. false: {
  290. title: this.$t('db.text_181'),
  291. content: this.$t('db.text_182'),
  292. },
  293. }
  294. this.createDialog('ConfirmDialog', {
  295. ...txts[`${bool}`],
  296. onOk: () => {
  297. return this.fetchSwitchPublic(bool)
  298. },
  299. })
  300. },
  301. },
  302. }
  303. </script>