index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <base-side-page
  3. @cancel="cancelSidePage"
  4. :title="$t('cloudenv.text_12')"
  5. icon="res-cloudaccount"
  6. :res-name="detailData.name"
  7. :actions="params.actions"
  8. :current-tab="params.windowData.currentTab"
  9. :tabs="detailTabs"
  10. :loaded="loaded"
  11. @tab-change="handleTabChange">
  12. <template v-slot:actions>
  13. <actions :options="singleActions" :row="detailData" button-type="link" button-size="small" />
  14. </template>
  15. <a-alert :message="$t('cloudenv.clouduser_desc')" class="mb-2" v-if="params.windowData.currentTab === 'clouduser-list'" />
  16. <component
  17. :is="params.windowData.currentTab"
  18. :data="detailData"
  19. :cloudaccount="detailData"
  20. :on-manager="onManager"
  21. :res-id="data.id"
  22. :id="listId"
  23. resource="cloudaccounts"
  24. :cloudaccount-list-refresh="params.options.refresh"
  25. :getParams="getParams"
  26. :columns="columns"
  27. taskResource="compute-tasks" />
  28. </base-side-page>
  29. </template>
  30. <script>
  31. import * as R from 'ramda'
  32. import CloudproviderList from '@Cloudenv/views/cloudprovider/components/List'
  33. import Usage from '@Cloudenv/sections/UsageSidepage'
  34. import CloudgroupList from '@Cloudenv/views/cloudgroup/components/List'
  35. import ClouduserList from '@Cloudenv/views/clouduser/components/List'
  36. import ExternalprojectList from '@Cloudenv/views/externalproject/components/List'
  37. import SamluserList from '@Cloudenv/views/samluser/components/List'
  38. import SidePageMixin from '@/mixins/sidePage'
  39. import WindowsMixin from '@/mixins/windows'
  40. import Actions from '@/components/PageList/Actions'
  41. import { findPlatform } from '@/utils/common/hypervisor'
  42. import HostList from './Host'
  43. import CloudaccountDetail from './Detail'
  44. import SingleActionsMixin from '../mixins/singleActions'
  45. import ColumnsMixin from '../mixins/columns'
  46. import ScheduledtasksList from './Schedule'
  47. export default {
  48. name: 'CloudaccountSidePage',
  49. components: {
  50. Actions,
  51. CloudaccountDetail,
  52. CloudproviderList,
  53. HostList,
  54. Usage,
  55. ClouduserList,
  56. CloudgroupList,
  57. ExternalprojectList,
  58. SamluserList,
  59. ScheduledtasksList,
  60. },
  61. mixins: [SidePageMixin, WindowsMixin, ColumnsMixin, SingleActionsMixin],
  62. computed: {
  63. detailTabs () {
  64. const data = this.detailData
  65. let platform = 'idc'
  66. if (data.provider) {
  67. platform = findPlatform(data.provider.toLowerCase(), 'provider')
  68. }
  69. const detailTabs = [
  70. { label: this.$t('cloudenv.text_237'), key: 'cloudaccount-detail' },
  71. { label: this.$t('cloudenv.text_319'), key: 'usage' },
  72. { label: this.$t('cloudenv.text_318'), key: 'cloudprovider-list' },
  73. { label: this.$t('cloudenv.text_386'), key: 'externalproject-list' },
  74. ]
  75. if (platform === 'idc' || platform === 'private') {
  76. detailTabs.splice(1, 0, { label: this.$t('cloudenv.text_101'), key: 'host-list' })
  77. }
  78. if ((this.$store.getters.capability.saml_auth_brands || []).includes(data.provider) && data.saml_auth) {
  79. detailTabs.splice(detailTabs.length - 1, 0, { label: this.$t('cloudaccount.sidepage.tab.samluser'), key: 'samluser-list' })
  80. }
  81. if ((this.$store.getters.capability.cloud_id_brands || []).includes(data.provider)) {
  82. detailTabs.splice(detailTabs.length - 1, 0, { label: this.$t('dictionary.clouduser'), key: 'clouduser-list' })
  83. detailTabs.splice(detailTabs.length - 1, 0, { label: this.$t('dictionary.cloudgroup'), key: 'cloudgroup-list' })
  84. }
  85. detailTabs.push({ label: this.$t('cloudenv.text_431'), key: 'scheduledtasks-list' })
  86. detailTabs.push({ label: this.$t('table.title.task'), key: 'task-drawer' })
  87. detailTabs.push({ label: this.$t('cloudenv.text_15'), key: 'event-drawer' })
  88. return detailTabs
  89. },
  90. getParams () {
  91. if (this.params.windowData.currentTab === 'cloudprovider-list') {
  92. return {
  93. detail: true,
  94. cloudaccount_id: this.data.id,
  95. }
  96. } else if (this.params.windowData.currentTab === 'host-list') {
  97. return {
  98. detail: true,
  99. account: this.data.id,
  100. baremetal: false,
  101. }
  102. } else if (this.params.windowData.currentTab === 'clouduser-list') {
  103. return {
  104. cloudaccount: this.data.id,
  105. }
  106. } else if (this.params.windowData.currentTab === 'cloudgroup-list') {
  107. return {
  108. cloudaccount: this.data.id,
  109. domain_id: this.data.data && this.data.data.domain_id,
  110. }
  111. } else if (this.params.windowData.currentTab === 'externalproject-list') {
  112. return () => {
  113. return {
  114. cloudaccount_id: this.data.id,
  115. }
  116. }
  117. } else if (this.params.windowData.currentTab === 'samluser-list') {
  118. return {
  119. cloudaccount: this.data.id,
  120. }
  121. } else if (this.params.windowData.currentTab === 'scheduledtasks-list') {
  122. return {
  123. label: this.data.id,
  124. resource_type: 'cloudaccount',
  125. account_id: this.data.id,
  126. }
  127. }
  128. return null
  129. },
  130. listId () {
  131. switch (this.params.windowData.currentTab) {
  132. case 'event-drawer':
  133. return 'EventListForCloudaccountSidePage'
  134. case 'cloudprovider-list':
  135. return 'CloudproviderListForCloudaccountSidePage'
  136. case 'externalproject-list':
  137. return 'ExternalprojectListForCloudaccountSidePage'
  138. case 'host-list':
  139. return 'HostListForCloudaccountSidePage'
  140. case 'clouduser-list':
  141. return 'ClouduserListForCloudaccountSidePage'
  142. case 'cloudgroup-list':
  143. return 'CloudgroupListForCloudaccountSidePage'
  144. case 'samluser-list':
  145. return 'SamluserListForCloudaccountSidePage'
  146. case 'scheduledtasks-list':
  147. return 'ScheduledtasksListForCloudaccountSidepage'
  148. default:
  149. return ''
  150. }
  151. },
  152. hiddenActions () {
  153. return this.params.hiddenActions || []
  154. },
  155. },
  156. created () {
  157. if (R.isNil(R.find(R.propEq('key', this.params.windowData.currentTab))(this.detailTabs))) {
  158. this.handleTabChange(this.detailTabs[0].key)
  159. }
  160. if (this.params.tab) {
  161. this.handleTabChange(this.params.tab)
  162. }
  163. },
  164. }
  165. </script>