index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <base-side-page
  3. @cancel="cancelSidePage"
  4. :title="$t('compute.text_111')"
  5. icon="res-host"
  6. :res-name="detailData.name"
  7. :current-tab="params.windowData.currentTab"
  8. :tabs="detailTabs"
  9. :loaded="loaded"
  10. @tab-change="handleTabChange">
  11. <template v-slot:actions>
  12. <actions :options="singleActions" :row="detailData" button-type="link" button-size="small" />
  13. </template>
  14. <component
  15. :is="params.windowData.currentTab"
  16. :res-id="data.id"
  17. :id="listId"
  18. :data="detailData"
  19. :hostInfo="detailData"
  20. :columns="columns"
  21. :on-manager="onManager"
  22. :refresh="refresh"
  23. :getParams="getParams"
  24. :probeHostDevices="probeHostDevices"
  25. taskResource="compute-tasks"
  26. @tab-change="handleTabChange" />
  27. </base-side-page>
  28. </template>
  29. <script>
  30. import * as R from 'ramda'
  31. import { hasPermission } from '@/utils/auth'
  32. import SidePageMixin from '@/mixins/sidePage'
  33. import WindowsMixin from '@/mixins/windows'
  34. import Actions from '@/components/PageList/Actions'
  35. import NetworkList from '@Compute/views/physicalmachine/sidepage/Network'
  36. import ServerRecovery from '@Compute/views/server-recovery/components/List'
  37. import GpuList from '@Compute/views/gpu/components/List'
  38. import BmcLog from '@Compute/views/physicalmachine/sidepage/BMCLog'
  39. import SingleActionsMixin from '../mixins/singleActions'
  40. import ColumnsMixin from '../mixins/columns'
  41. import HostDetail from './Detail'
  42. import Dashboard from './Dashboard'
  43. import StorageList from './Storage'
  44. import Monitor from './Monitor'
  45. import VminstanceList from './VminstanceList'
  46. import Dmesg from './Dmesg'
  47. export default {
  48. name: 'HostSidePage',
  49. components: {
  50. HostDetail,
  51. Dashboard,
  52. VminstanceList,
  53. NetworkList,
  54. StorageList,
  55. GpuList,
  56. ServerRecovery,
  57. Actions,
  58. Monitor,
  59. BmcLog,
  60. Dmesg,
  61. },
  62. mixins: [SidePageMixin, WindowsMixin, ColumnsMixin, SingleActionsMixin],
  63. computed: {
  64. detailTabs () {
  65. let vmListText = this.$t('compute.text_91')
  66. if (this.data && this.data.data && this.data.data.host_type === 'container') {
  67. vmListText = this.$t('compute.host.host_type.container.title')
  68. }
  69. let tabs = [
  70. { label: this.$t('compute.text_238'), key: 'host-detail' },
  71. { label: this.$t('compute.text_606'), key: 'dashboard' },
  72. { label: vmListText, key: 'vminstance-list' },
  73. { label: this.$t('compute.text_104'), key: 'network-list' },
  74. { label: this.$t('compute.text_99'), key: 'storage-list' },
  75. { label: this.$t('compute.text_113'), key: 'gpu-list' },
  76. { label: this.$t('compute.text_114'), key: 'server-recovery' },
  77. { label: this.$t('compute.text_608'), key: 'monitor' },
  78. { label: this.$t('table.title.task'), key: 'task-drawer' },
  79. { label: this.$t('compute.text_240'), key: 'event-drawer' },
  80. { label: this.$t('compute.dmesg_log'), key: 'dmesg' },
  81. ]
  82. if (!hasPermission({ key: 'baremetalnetworks_list' })) {
  83. tabs = R.remove(R.findIndex(R.propEq('key', 'network-list'))(tabs), 1, tabs)
  84. }
  85. if (!hasPermission({ key: 'hoststorages_list' })) {
  86. tabs = R.remove(R.findIndex(R.propEq('key', 'storage-list'))(tabs), 1, tabs)
  87. }
  88. if (this.data && this.data.data && this.data.data.is_baremetal) {
  89. tabs = R.insert(tabs.length - 1, { label: this.$t('compute.text_865'), key: 'bmc-log' }, tabs)
  90. }
  91. return tabs
  92. },
  93. probeHostDevices () {
  94. return this.data && this.data.data && (this.data.data.host_type === 'hypervisor' || this.data.data.host_type === 'container')
  95. },
  96. getParams () {
  97. if (this.params.windowData.currentTab === 'vminstance-list') {
  98. return {
  99. host: this.data.id,
  100. }
  101. } else if (this.params.windowData.currentTab === 'storage-list') {
  102. return {
  103. host_id: this.data.id,
  104. details: true,
  105. with_meta: true,
  106. limit: 20,
  107. }
  108. } else if (this.params.windowData.currentTab === 'server-recovery') {
  109. return {
  110. host: this.data.id,
  111. }
  112. } else if (this.params.windowData.currentTab === 'gpu-list') {
  113. return {
  114. host: this.data.id,
  115. // gpu: true,
  116. }
  117. } else if (this.params.windowData.currentTab === 'bmc-log') {
  118. return {
  119. host_id: this.data.id,
  120. }
  121. }
  122. return null
  123. },
  124. listId () {
  125. switch (this.params.windowData.currentTab) {
  126. case 'event-drawer':
  127. return 'EventListForHostSidePage'
  128. case 'vminstance-list':
  129. return 'VminstanceListForHostSidePage'
  130. case 'storage-list':
  131. return 'StorageListForHostSidePage'
  132. case 'gpu-list':
  133. return 'GpuListForHostSidePage'
  134. case 'server-recovery':
  135. return 'ServerRecoveryListForHostSidePage'
  136. default:
  137. return ''
  138. }
  139. },
  140. },
  141. }
  142. </script>