mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
* add new vue 3 library & and 2.x (beta) * edit config files, settings, utils, store,... corresponding to Vue 3 * edit layout and config to suit the new library * fix header & side menu * components, autogenview * fix dashboard & compute * compute: fix form errors * storage: fix form & template by vue3 * networks: fix form & template by vue3 * image: fix form & template by vue3 * project: fix by vue3 library * user: fix by vue3 * iam: fix by vue3 * fix zoneWizard & tooltip click event * fix infra > physicalnetwork & visible modal * fix infra by vue3 & antdv 2x * fix offerings by vue3 * fix plugin by vue3 * fix form & action form * update the ant-design latest version * fix icon, style dark mode, menu * fix unittest * fix babel plugins not found * add name,ref missing & callback i18n not found * fix slot & info icon * fix unit test * fix tooltip label of form item * fix lint errors * using global app, globalProperties * add focus directive & edit the position of ctrl+Enter * upgrage Vue 3 version * fix main UT * fix build failed * using `optionFilterProp="label"' & fix build fail * fix UT with new code * fix icons of undefined * fix error run app * fix selectbox options * add vue version for clear storage * fix template * fix template of iprange form * fix warning test UT * fix conflit * fix build failed * fix error run app the first time after upgrade * fix auto-complete & watch object/array * fix error run application * fix error build * fix form, icon, template & locales * fix conflit & form * remove slot errors * fix error build & test UT * fix error template * Add licenses for missing files * add scroll to first errors * add scroll to first errors * fix select filter, tag event * add shallowRef async component are missing * fix css, upgrade vue-cropper version * fix css * fix vue 3 coding for new components * Remove unused components * fixes `this` not found in @/roles * fix redirect after login again when session expired error * fix openKeys menu & watch router * fixes * fix build failed * fixes * fixes ut * fixes * fixes eslint * fixes * fixes * fixes css * fix menu sidebar css * fix some css icon, images * fix build fail * fixes * fixes * fixes * fixes * fix publicip resource * fixes ut * fixes * fixes * fixes layout mode * fixes dropdown filter columns * fixes dashboard & hidden setting for normal user * fixes * fixes layout * fixes avatar * fixes * Add missing else * Fix query in routable paths Co-authored-by: davidjumani <dj.davidjumani1994@gmail.com>
270 lines
8.1 KiB
Vue
270 lines
8.1 KiB
Vue
// Licensed to the Apache Software Foundation (ASF) under one
|
|
// or more contributor license agreements. See the NOTICE file
|
|
// distributed with this work for additional information
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
// to you under the Apache License, Version 2.0 (the
|
|
// "License"); you may not use this file except in compliance
|
|
// with the License. You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing,
|
|
// software distributed under the License is distributed on an
|
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
// KIND, either express or implied. See the License for the
|
|
// specific language governing permissions and limitations
|
|
// under the License.
|
|
|
|
<template>
|
|
<div>
|
|
<a-input-search
|
|
class="top-spaced"
|
|
:placeholder="$t('label.search')"
|
|
v-model:value="searchQuery"
|
|
style="margin-bottom: 10px;"
|
|
@search="fetchStoragePools"
|
|
autoFocus />
|
|
<a-table
|
|
size="small"
|
|
style="overflow-y: auto"
|
|
:loading="loading"
|
|
:columns="columns"
|
|
:dataSource="storagePools"
|
|
:pagination="false"
|
|
:rowKey="record => record.id">
|
|
<template #suitabilityCustomTitle>
|
|
{{ $t('label.suitability') }}
|
|
<a-tooltip :title="$t('message.volume.state.primary.storage.suitability')" placement="top">
|
|
<info-circle-outlined class="table-tooltip-icon" />
|
|
</a-tooltip>
|
|
</template>
|
|
<template #name="{ record }">
|
|
{{ record.name }}
|
|
<a-tooltip v-if="record.name === $t('label.auto.assign')" :title="$t('message.migrate.volume.pool.auto.assign')" placement="top">
|
|
<info-circle-outlined class="table-tooltip-icon" />
|
|
</a-tooltip>
|
|
</template>
|
|
<template #suitability="{ record }">
|
|
<check-circle-two-tone
|
|
class="host-item__suitability-icon"
|
|
twoToneColor="#52c41a"
|
|
v-if="record.suitableformigration" />
|
|
<close-circle-two-tone
|
|
class="host-item__suitability-icon"
|
|
twoToneColor="#f5222d"
|
|
v-else />
|
|
</template>
|
|
<template #disksizetotal="{ record }">
|
|
<span v-if="record.disksizetotal">{{ $bytesToHumanReadableSize(record.disksizetotal) }}</span>
|
|
</template>
|
|
<template #disksizeused="{ record }">
|
|
<span v-if="record.disksizeused">{{ $bytesToHumanReadableSize(record.disksizeused) }}</span>
|
|
</template>
|
|
<template #disksizefree="{ record }">
|
|
<span v-if="record.disksizetotal && record.disksizeused">{{ $bytesToHumanReadableSize(record.disksizetotal * 1 - record.disksizeused * 1) }}</span>
|
|
</template>
|
|
<template #select="{ record }">
|
|
<a-tooltip placement="top" :title="record.state !== 'Up' ? $t('message.primary.storage.invalid.state') : ''">
|
|
<a-radio
|
|
:disabled="record.id !== -1 && record.state !== 'Up'"
|
|
@click="updateSelection(record)"
|
|
:checked="selectedStoragePool != null && record.id === selectedStoragePool.id">
|
|
</a-radio>
|
|
</a-tooltip>
|
|
</template>
|
|
</a-table>
|
|
<a-pagination
|
|
class="top-spaced"
|
|
size="small"
|
|
:current="page"
|
|
:pageSize="pageSize"
|
|
:total="totalCount"
|
|
:showTotal="total => `${$t('label.total')} ${total} ${$t('label.items')}`"
|
|
:pageSizeOptions="['10', '20', '40', '80', '100']"
|
|
@change="handleChangePage"
|
|
@showSizeChange="handleChangePageSize"
|
|
showSizeChanger>
|
|
<template #buildOptionText="props">
|
|
<span>{{ props.value }} / {{ $t('label.page') }}</span>
|
|
</template>
|
|
</a-pagination>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { api } from '@/api'
|
|
|
|
export default {
|
|
name: 'VolumeStoragePoolSelector',
|
|
props: {
|
|
resource: {
|
|
type: Object,
|
|
required: true
|
|
},
|
|
clusterId: {
|
|
type: String,
|
|
required: false,
|
|
default: null
|
|
},
|
|
suitabilityEnabled: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false
|
|
},
|
|
autoAssignAllowed: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false
|
|
},
|
|
isOpen: {
|
|
type: Boolean,
|
|
required: false
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
loading: false,
|
|
storagePools: [],
|
|
searchQuery: '',
|
|
totalCount: 0,
|
|
page: 1,
|
|
pageSize: 10,
|
|
selectedStoragePool: null,
|
|
columns: [
|
|
{
|
|
title: this.$t('label.storageid'),
|
|
slots: { customRender: 'name' }
|
|
},
|
|
{
|
|
title: this.$t('label.clusterid'),
|
|
dataIndex: 'clustername'
|
|
},
|
|
{
|
|
title: this.$t('label.podid'),
|
|
dataIndex: 'podname'
|
|
},
|
|
{
|
|
title: this.$t('label.disksizetotal'),
|
|
slots: { customRender: 'disksizetotal' }
|
|
},
|
|
{
|
|
title: this.$t('label.disksizeused'),
|
|
slots: { customRender: 'disksizeused' }
|
|
},
|
|
{
|
|
title: this.$t('label.disksizefree'),
|
|
slots: { customRender: 'disksizefree' }
|
|
},
|
|
{
|
|
title: this.$t('label.select'),
|
|
slots: { customRender: 'select' }
|
|
}
|
|
]
|
|
}
|
|
},
|
|
created () {
|
|
if (this.suitabilityEnabled) {
|
|
this.columns.splice(1, 0, { title: 'suitabilityCustomTitle', slots: 'suitability' })
|
|
}
|
|
this.preselectStoragePool()
|
|
this.fetchStoragePools()
|
|
},
|
|
watch: {
|
|
searchQuery (newValue, oldValue) {
|
|
if (newValue !== oldValue) {
|
|
this.page = 1
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
fetchStoragePools () {
|
|
this.loading = true
|
|
if (this.suitabilityEnabled) {
|
|
api('findStoragePoolsForMigration', {
|
|
id: this.resource.id,
|
|
keyword: this.searchQuery,
|
|
page: this.page,
|
|
pagesize: this.pageSize
|
|
}).then(response => {
|
|
this.storagePools = response.findstoragepoolsformigrationresponse.storagepool || []
|
|
this.totalCount = response.findstoragepoolsformigrationresponse.count
|
|
}).catch(error => {
|
|
this.$notifyError(error)
|
|
}).finally(() => {
|
|
this.handleStoragePoolsFetchComplete()
|
|
})
|
|
} else {
|
|
var params = {
|
|
zoneid: this.resource.zoneid,
|
|
keyword: this.searchQuery,
|
|
page: this.page,
|
|
pagesize: this.pageSize
|
|
}
|
|
if (this.clusterId) {
|
|
params.clusterid = this.clusterId
|
|
}
|
|
api('listStoragePools', params).then(response => {
|
|
this.storagePools = response.liststoragepoolsresponse.storagepool || []
|
|
this.totalCount = response.liststoragepoolsresponse.count
|
|
}).catch(error => {
|
|
this.$notifyError(error)
|
|
}).finally(() => {
|
|
this.handleStoragePoolsFetchComplete()
|
|
})
|
|
}
|
|
},
|
|
handleStoragePoolsFetchComplete () {
|
|
this.$emit('storagePoolsUpdated', this.storagePools)
|
|
this.addAutoAssignOption()
|
|
this.loading = false
|
|
},
|
|
addAutoAssignOption () {
|
|
if (this.autoAssignAllowed && this.page === 1) {
|
|
this.storagePools.unshift({ id: -1, name: this.$t('label.auto.assign'), clustername: '', podname: '' })
|
|
}
|
|
},
|
|
handleChangePage (page, pageSize) {
|
|
this.page = page
|
|
this.pageSize = pageSize
|
|
this.fetchStoragePools()
|
|
},
|
|
handleChangePageSize (currentPage, pageSize) {
|
|
this.page = currentPage
|
|
this.pageSize = pageSize
|
|
this.fetchStoragePools()
|
|
},
|
|
preselectStoragePool () {
|
|
if (this.resource && 'selectedstorageid' in this.resource) {
|
|
this.selectedStoragePool = { id: this.resource.selectedstorageid }
|
|
}
|
|
},
|
|
clearView () {
|
|
this.storagePools = []
|
|
this.searchQuery = ''
|
|
this.totalCount = 0
|
|
this.page = 1
|
|
this.pageSize = 10
|
|
this.selectedStoragePool = null
|
|
},
|
|
reset () {
|
|
this.clearView()
|
|
this.preselectStoragePool()
|
|
this.fetchStoragePools()
|
|
},
|
|
updateSelection (storagePool) {
|
|
this.selectedStoragePool = storagePool
|
|
this.$emit('select', this.selectedStoragePool)
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.top-spaced {
|
|
margin-top: 20px;
|
|
}
|
|
.table-tooltip-icon {
|
|
color: rgba(0,0,0,.45);
|
|
}
|
|
</style>
|