import _ from 'lodash'
import {
getNameDescriptionTableColumn,
getEnabledTableColumn,
getStatusTableColumn,
getBrandTableColumn,
getPublicScopeTableColumn,
getProjectDomainTableColumn,
getRegionTableColumn,
getTimeTableColumn,
} from '@/utils/common/tableColumn'
import {
getNameFilter,
} from '@/utils/common/tableFilter'
import { sizestr } from '@/utils/utils'
import { STORAGE_TYPES, MEDIUM_TYPES } from '@Storage/constants'
export default {
computed: {
resourceProps () {
return {
list: this.$list.createList(this, {
id: 'DiskStoragesListForChangeBlockStorageDialog',
resource: 'storages',
getParams: {
server_id: this.selectedItemsGuestIds[0],
enabled: true,
filter: `id.notin(${this.selectedItemsStorageIds.join(',')})`,
},
filterOptions: {
id: {
label: this.$t('table.title.id'),
},
name: getNameFilter(),
},
}),
columns: [
getNameDescriptionTableColumn({
hideField: true,
addLock: true,
addBackup: true,
edit: false,
editDesc: false,
minWidth: 120,
slotCallback: row => {
return [
,
]
},
}),
getStatusTableColumn({
statusModule: 'blockstorage',
minWidth: 100,
}),
getEnabledTableColumn(),
{
field: 'capacity',
title: this.$t('storage.text_177'),
width: 180,
slots: {
default: ({ row }, h) => {
const capacity = sizestr(row.capacity, 'M', 1024)
const allowedBrands = ['VMware', 'OneCloud']
const actual_capacity_used = allowedBrands.includes(row.brand) ? sizestr(row.actual_capacity_used, 'M', 1024) : '-'
return [
{this.$t('storage.text_178', [actual_capacity_used])}
{this.$t('storage.text_180', [capacity])}
]
},
},
},
{
field: 'virtual_capacity',
title: this.$t('storage.text_43'),
width: 180,
slots: {
default: ({ row }, h) => {
const virtual_capacity = sizestr(row.virtual_capacity, 'M', 1024)
const used_capacity = sizestr(row.used_capacity, 'M', 1024)
return [
{this.$t('storage.text_181', [used_capacity])}
{this.$t('storage.text_180', [virtual_capacity])}
]
},
},
},
{
field: 'storage_type',
title: this.$t('storage.text_38'),
width: 100,
formatter: ({ row }) => {
return STORAGE_TYPES[row.storage_type] || row.storage_type
},
},
{
field: 'medium_type',
title: this.$t('storage.text_39'),
width: 120,
formatter: ({ row }) => {
return MEDIUM_TYPES[row.medium_type] || row.medium_type
},
},
getBrandTableColumn(),
{
field: 'schedtag',
title: this.$t('storage.text_45'),
width: 120,
slots: {
default: ({ row }) => {
const tags = _.sortBy(row.schedtags, ['default', 'name'])
if (!tags.length) {
return [
{ this.$t('storage.text_171') }
,
]
}
const list = tags.map(tag => {tag.name})
return [
{...list}
]
},
},
},
getPublicScopeTableColumn({ vm: this, resource: 'storages' }),
getProjectDomainTableColumn(),
getRegionTableColumn(),
getTimeTableColumn(),
],
}
},
},
methods: {},
}