| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- <template>
- <base-side-page
- @cancel="cancelSidePage"
- ref="BaseSidePage"
- :title="$t('storage.text_37')"
- icon="res-blockstorage"
- :res-name="detailData.name"
- :tabs="detailTabs"
- :current-tab="params.windowData.currentTab"
- :loaded="loaded"
- @tab-change="handleTabChange">
- <template v-slot:actions>
- <actions
- :options="singleActions"
- :row="detailData"
- button-type="link"
- button-size="small" />
- </template>
- <component
- v-bind="hostListActions"
- :is="params.windowData.currentTab"
- :data="detailData"
- :resource="resource"
- :on-manager="onManager"
- :refresh="refresh"
- @refresh="refresh"
- :list="params.list"
- :getParams="getParams"
- :getColumns="getColumns"
- :columns="columns"
- :res-id="getParams.storage"
- :id="listId" />
- </base-side-page>
- </template>
- <script>
- import HostList from '@Compute/views/host/components/List'
- import DiskRecoveryList from '@Compute/views/disk-recovery/components/List'
- import CachedImages from '@Storage/views/blockstorage/sidepage/CachedImages'
- import { getStatusTableColumn, getCopyWithContentTableColumn, getProjectTableColumn, getTimeTableColumn } from '@/utils/common/tableColumn'
- import SidePageMixin from '@/mixins/sidePage'
- import WindowsMixin from '@/mixins/windows'
- import Actions from '@/components/PageList/Actions'
- import { STORAGE_TYPES } from '@Storage/constants/index.js'
- import SingleActionsMixin from '../mixins/singleActions'
- import ColumnsMixin from '../mixins/columns'
- import Detail from './Detail'
- import DiskList from './Disk'
- import Monitor from './Monitor'
- import SnapshotList from './Snapshot'
- export default {
- name: 'BlockStorageSidePage',
- components: {
- Actions,
- Detail,
- DiskList,
- DiskRecoveryList,
- HostList,
- Monitor,
- CachedImages,
- SnapshotList,
- },
- mixins: [SidePageMixin, WindowsMixin, ColumnsMixin, SingleActionsMixin],
- data () {
- return {
- detailTabs: [
- { label: this.$t('storage.text_81'), key: 'detail' },
- { label: this.$t('storage.text_50'), key: 'host-list' },
- { label: this.$t('storage.text_82'), key: 'disk-list' },
- { label: this.$t('compute.text_101'), key: 'snapshot-list' },
- { label: this.$t('storage.text_83'), key: 'disk-recovery-list' },
- { label: this.$t('storage.text_84'), key: 'cached-images' },
- { label: this.$t('compute.text_608'), key: 'monitor' },
- { label: this.$t('storage.text_85'), key: 'event-drawer' },
- ],
- }
- },
- computed: {
- getParams () {
- return {
- storage: this.data.id,
- details: true,
- }
- },
- getColumns () {
- if (this.params.windowData.currentTab === 'disk-recovery-list') {
- return [
- getCopyWithContentTableColumn({ field: 'name', title: this.$t('storage.text_40') }),
- getCopyWithContentTableColumn({ field: 'guest', title: this.$t('dictionary.server') }),
- {
- field: 'disk_type',
- title: this.$t('storage.text_86'),
- width: 70,
- formatter: ({ cellValue }) => {
- return cellValue === 'sys' ? this.$t('storage.text_87') : this.$t('storage.text_88')
- },
- },
- getStatusTableColumn({ statusModule: 'disk' }),
- getProjectTableColumn(),
- getTimeTableColumn({ field: 'auto_delete_at', title: this.$t('storage.text_89') }),
- ]
- }
- return null
- },
- isBlockStorage () {
- return ['rbd', 'slvm', 'nfs', 'gpfs'].includes(this.detailData.storage_type)
- },
- hostListActions () {
- const me = this
- return {
- // this = hostList
- frontGroupActions: function () {
- return [
- {
- label: this.$t('storage.text_66'),
- permission: 'storages_perform_storages',
- action: () => {
- this.createDialog('AssociatedHostDialog', {
- data: [me.detailData],
- columns: me.columns,
- title: this.$t('storage.text_66'),
- onManager: this.onManager,
- refresh: this.refresh,
- })
- },
- meta: () => {
- return {
- validate: me.isBlockStorage,
- tooltip: !me.isBlockStorage && this.$t('storage.text_67', [STORAGE_TYPES[me.detailData.storage_type] || me.detailData.storage_type]),
- }
- },
- },
- {
- label: this.$t('storage.text_90'),
- action: () => {
- this.createDialog('UnAssociatedHostDialog', {
- title: this.$t('storage.text_90'),
- data: this.list.selectedItems,
- columns: this.columns,
- list: this.list,
- resId: me.getParams.storage,
- })
- },
- meta: () => {
- return {
- validate: this.list.selectedItems.length > 0 && me.isBlockStorage,
- }
- },
- },
- ]
- },
- frontSingleActions: function () {
- return [
- {
- label: this.$t('storage.text_90'),
- action: (row) => {
- this.createDialog('UnAssociatedHostDialog', {
- title: this.$t('storage.text_90'),
- data: [row],
- columns: this.columns,
- list: this.list,
- resId: me.getParams.storage,
- })
- },
- meta: () => {
- return {
- validate: me.isBlockStorage,
- }
- },
- },
- ]
- },
- }
- },
- listId () {
- switch (this.params.windowData.currentTab) {
- case 'event-drawer':
- return 'EventListForBlockStorageSidePage'
- case 'host-list':
- return 'HostListForBlockStorageSidePage'
- case 'disk-list':
- return 'DiskListForBlockStorageSidePage'
- case 'disk-recovery-list':
- return 'DiskRecoveryListForBlockStorageSidePage'
- default:
- return ''
- }
- },
- },
- created () {
- if (this.params.tab) this.handleTabChange(this.params.tab)
- },
- }
- </script>
|