columns.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import i18n from '@/locales'
  2. import {
  3. getNameDescriptionTableColumn,
  4. getCopyWithContentTableColumn,
  5. getRegionTableColumn,
  6. getPublicScopeTableColumn,
  7. } from '@/utils/common/tableColumn'
  8. import {
  9. getReserveResourceColumn,
  10. } from '../utils/columns'
  11. export default {
  12. created () {
  13. const DEVICE_MAP = {
  14. '10de': 'nvidia',
  15. 1002: 'amd',
  16. }
  17. this.columns = [
  18. getNameDescriptionTableColumn({
  19. onManager: this.onManager,
  20. hideField: true,
  21. slotCallback: row => {
  22. return (
  23. <side-page-trigger onTrigger={ () => this.handleOpenSidepage(row, 'gpu-detail') }>{ row.name }</side-page-trigger>
  24. )
  25. },
  26. }),
  27. {
  28. field: 'dev_type',
  29. title: i18n.t('compute.text_481'),
  30. width: 120,
  31. showOverflow: 'ellipsis',
  32. },
  33. {
  34. field: 'model',
  35. title: i18n.t('compute.text_482'),
  36. minWidth: 120,
  37. showOverflow: 'ellipsis',
  38. slots: {
  39. default: ({ row }, h) => {
  40. const device = row.vendor_device_id.split(':')[0]
  41. if (!device) {
  42. return row.model
  43. }
  44. return [
  45. <div class='d-flex'>
  46. <span class='text-truncate'>{ row.model }</span>
  47. <icon class="ml-1" style="line-height: 24px" type={ DEVICE_MAP[device] } />
  48. </div>,
  49. ]
  50. },
  51. },
  52. formatter: ({ row }) => {
  53. const device = row.vendor_device_id.split(':')[0]
  54. if (!device) {
  55. return row.model
  56. }
  57. return row.model
  58. },
  59. },
  60. {
  61. field: 'vendor_device_id',
  62. title: 'PCI ID',
  63. width: 120,
  64. showOverflow: 'ellipsis',
  65. slots: {
  66. default: ({ row }, h) => {
  67. if (row.vendor_device_id) {
  68. if (row.vendor_device_id === '0000:0000') {
  69. return row.vendor_device_id
  70. } else {
  71. const url = 'https://admin.pci-ids.ucw.cz/read/PC/' + row.vendor_device_id.replace(':', '/')
  72. return [
  73. <list-body-cell-wrap copy hideField={true} field='vendor_device_id' row={row} message={row.vendor_device_id}>
  74. <div class='d-flex'>
  75. <span class='text-truncate'>{ row.vendor_device_id }</span>
  76. <a href={ url } target="pciid"><a-icon type="link" /></a>
  77. </div>
  78. </list-body-cell-wrap>,
  79. ]
  80. }
  81. }
  82. },
  83. },
  84. formatter: ({ row }) => {
  85. return row.vendor_device_id
  86. },
  87. },
  88. {
  89. field: 'addr',
  90. title: 'PCI ADDR',
  91. width: 100,
  92. showOverflow: 'ellipsis',
  93. formatter: function ({ row }) {
  94. if (row.addr >= 0) {
  95. return row.addr
  96. }
  97. return '-'
  98. },
  99. },
  100. {
  101. field: 'device_path',
  102. title: i18n.t('compute.isolated_devices.device_path.title'),
  103. width: 120,
  104. showOverflow: 'ellipsis',
  105. slots: {
  106. default: ({ row }, h) => {
  107. const ret = []
  108. if (row.device_path) {
  109. ret.push(
  110. [
  111. <list-body-cell-wrap copy hideField={true} field='device_path' row={row} message={row.device_path}>
  112. {row.device_path}
  113. </list-body-cell-wrap>,
  114. ],
  115. )
  116. }
  117. return ret
  118. },
  119. },
  120. formatter: ({ row }) => {
  121. return row.device_path
  122. },
  123. },
  124. {
  125. field: 'numa_node',
  126. title: 'NUMA',
  127. width: 80,
  128. formatter: function ({ row }) {
  129. if (row.numa_node >= 0) {
  130. return row.numa_node
  131. }
  132. return '-'
  133. },
  134. },
  135. {
  136. field: 'guest',
  137. title: this.$t('compute.associated_instances'),
  138. minWidth: 100,
  139. showOverflow: 'ellipsis',
  140. slots: {
  141. default: ({ row }, h) => {
  142. if (this.isPreLoad && !row.guest) return [<data-loading />]
  143. return [
  144. <div class='text-truncate'>
  145. <list-body-cell-wrap copy={true} row={row} field="guest" onManager={this.onManager} hideField={ true }>
  146. <side-page-trigger onTrigger={ () => this.handleOpenSidepage(row, 'associated-instances') }>{ row.guest }</side-page-trigger>
  147. </list-body-cell-wrap>
  148. {row.guest_status ? <status status={ row.guest_status } statusModule='server'/> : ''}
  149. </div>,
  150. ]
  151. },
  152. },
  153. formatter: ({ row }) => {
  154. return row.guest || '-'
  155. },
  156. },
  157. getCopyWithContentTableColumn({
  158. field: 'host',
  159. title: i18n.t('compute.text_484'),
  160. hideField: true,
  161. slotCallback: row => {
  162. if (this.isPreLoad && !(row.host && row.host_id)) return [<data-loading />]
  163. return row.host || row.host_id
  164. },
  165. }),
  166. getReserveResourceColumn(),
  167. getPublicScopeTableColumn({ resource: 'isolated_devices', vm: this, title: this.$t('compute.text_113') }),
  168. getRegionTableColumn({ vm: this }),
  169. ]
  170. },
  171. }