Hosts.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <page-list
  3. :list="list"
  4. :columns="columns" />
  5. </template>
  6. <script>
  7. import PasswordFetcher from '@Compute/sections/PasswordFetcher'
  8. import {
  9. getEnabledTableColumn,
  10. getStatusTableColumn,
  11. getNameDescriptionTableColumn,
  12. } from '@/utils/common/tableColumn'
  13. import { sizestr, percentstr } from '@/utils/utils'
  14. import DialogMixin from '@/mixins/dialog'
  15. import WindowsMixin from '@/mixins/windows'
  16. export default {
  17. name: 'HostsList',
  18. mixins: [DialogMixin, WindowsMixin],
  19. props: {
  20. id: String,
  21. resId: {
  22. type: String,
  23. required: true,
  24. },
  25. },
  26. data () {
  27. return {
  28. list: this.$list.createList(this, {
  29. id: this.id,
  30. resource: 'hosts',
  31. getParams: {
  32. details: true,
  33. wire: this.resId,
  34. baremetal: false,
  35. },
  36. filterOptions: {
  37. name: {
  38. label: this.$t('network.text_21'),
  39. filter: true,
  40. formatter: val => {
  41. return `name.contains("${val}")`
  42. },
  43. },
  44. },
  45. }),
  46. columns: [
  47. getNameDescriptionTableColumn({
  48. edit: false,
  49. hideField: true,
  50. slotCallback: row => {
  51. return (
  52. <side-page-trigger permission='hosts_get' name='HostSidePage' id={ row.id } list={this.list} vm={this}>{ row.name }</side-page-trigger>
  53. )
  54. },
  55. }),
  56. getEnabledTableColumn(),
  57. getStatusTableColumn({ statusModule: 'server' }),
  58. {
  59. field: 'access_ip',
  60. title: 'IP',
  61. minWidth: 100,
  62. showOverflow: 'ellipsis',
  63. },
  64. getStatusTableColumn({ statusModule: 'host' }),
  65. {
  66. field: 'guests',
  67. title: '#VM',
  68. minWidth: 70,
  69. showOverflow: 'ellipsis',
  70. formatter: ({ cellValue, row }) => {
  71. if (typeof row.nonsystem_guests !== 'undefined') {
  72. return '' + row.nonsystem_guests
  73. } else if (typeof cellValue !== 'undefined') {
  74. return '' + cellValue
  75. }
  76. return '0'
  77. },
  78. },
  79. {
  80. field: 'cpu_count',
  81. title: 'CPU',
  82. minWidth: 80,
  83. showOverflow: 'ellipsis',
  84. formatter: ({ cellValue, row }) => {
  85. if (cellValue) {
  86. return '' + cellValue + '/' + percentstr(row.cpu_commit_rate)
  87. } else {
  88. return 'N/A'
  89. }
  90. },
  91. },
  92. {
  93. field: 'mem_size',
  94. title: this.$t('network.text_707'),
  95. minWidth: 100,
  96. showOverflow: 'ellipsis',
  97. formatter: ({ cellValue, row }) => {
  98. if (cellValue) {
  99. return sizestr(cellValue, 'M', 1024) + '/' + percentstr(row.mem_commit_rate)
  100. } else {
  101. return 'N/A'
  102. }
  103. },
  104. },
  105. {
  106. field: 'storage_size',
  107. title: this.$t('network.text_708'),
  108. minWidth: 70,
  109. showOverflow: 'ellipsis',
  110. formatter: ({ cellValue, row }) => {
  111. if (cellValue) {
  112. return sizestr(cellValue, 'M', 1024)
  113. } else {
  114. return 'N/A'
  115. }
  116. },
  117. },
  118. {
  119. field: 'sn',
  120. title: 'SN',
  121. minWidth: 100,
  122. showOverflow: 'ellipsis',
  123. },
  124. {
  125. field: 'id',
  126. title: 'IPMI',
  127. minWidth: 70,
  128. showOverflow: 'ellipsis',
  129. slots: {
  130. default: ({ cellValue, row }) => {
  131. if (!row.is_baremetal) {
  132. return '-'
  133. } else {
  134. return [<PasswordFetcher serverId={ row.id } resourceType='baremetals' />]
  135. }
  136. },
  137. },
  138. },
  139. {
  140. field: 'server_id',
  141. title: this.$t('network.text_709'),
  142. minWidth: 70,
  143. showOverflow: 'ellipsis',
  144. slots: {
  145. default: ({ cellValue, row }) => {
  146. if (!row.is_baremetal) {
  147. return '-'
  148. } else {
  149. return [<PasswordFetcher serverId={ row.id } resourceType='baremetals' />]
  150. }
  151. },
  152. },
  153. },
  154. ],
  155. }
  156. },
  157. created () {
  158. this.list.fetchData()
  159. },
  160. }
  161. </script>