Baremetals.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 } from '@/utils/utils'
  14. import DialogMixin from '@/mixins/dialog'
  15. import WindowsMixin from '@/mixins/windows'
  16. export default {
  17. name: 'BaremetalsList',
  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: true,
  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='PhysicalmachineSidePage' 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. },
  62. {
  63. field: 'spec',
  64. title: this.$t('network.text_268'),
  65. formatter: ({ cellValue, row }) => {
  66. const g = function (sz, prefix) {
  67. if (!prefix || prefix.length === 0) {
  68. prefix = ''
  69. }
  70. if (sz && sz > 0) {
  71. return `${prefix}${sizestr(sz, 'M', 1024)}`
  72. } else {
  73. return ''
  74. }
  75. }
  76. let cpu = ''
  77. if (cellValue.cpu && cellValue.cpu > 0) {
  78. cpu = `${cellValue.cpu}C`
  79. }
  80. const mem = g(cellValue.mem)
  81. let ssd = ''
  82. let hdd = ''
  83. if (cellValue.disk) {
  84. if (cellValue.disk.SSD) {
  85. ssd = 'SSD'
  86. for (const key in cellValue.disk.SSD) {
  87. ssd += `${g(cellValue.disk.SSD[key])}x${cellValue.disk.SSD[key]}`
  88. }
  89. }
  90. if (cellValue.disk.HDD) {
  91. hdd = 'HDD'
  92. for (const key in cellValue.disk.HDD) {
  93. hdd += `${g(key)}x${cellValue.disk.HDD[key]}`
  94. }
  95. }
  96. }
  97. let driver = ''
  98. if (cellValue && cellValue.driver && cellValue.driver !== 'Linux') {
  99. driver = 'RAID'
  100. }
  101. return `${cpu}${mem}${hdd}${ssd}${driver}`
  102. },
  103. },
  104. {
  105. field: 'sn',
  106. title: 'SN',
  107. },
  108. {
  109. field: 'guests',
  110. title: this.$t('network.text_704'),
  111. formatter: ({ cellValue, row }) => {
  112. return cellValue ? this.$t('network.text_705') : this.$t('network.text_706')
  113. },
  114. },
  115. {
  116. field: 'id',
  117. title: 'IPMI',
  118. slots: {
  119. default: ({ row }) => {
  120. return [<PasswordFetcher serverId={ row.id } resourceType='baremetals' />]
  121. },
  122. },
  123. },
  124. ],
  125. }
  126. },
  127. created () {
  128. this.list.fetchData()
  129. },
  130. }
  131. </script>