From b489b5828e2e17549d32e9fbf2165203f337d63e Mon Sep 17 00:00:00 2001 From: JoaoJandre <48719461+JoaoJandre@users.noreply.github.com> Date: Fri, 11 Feb 2022 16:30:56 -0300 Subject: [PATCH] [UI] Added account field to upload volume (#5914) * [UI] Added account field to upload volume * Add license Co-authored-by: dahn Co-authored-by: Joao Co-authored-by: dahn --- ui/src/config/section/storage.js | 8 +- ui/src/views/storage/UploadLocalVolume.vue | 89 +++++- ui/src/views/storage/UploadVolume.vue | 318 +++++++++++++++++++++ 3 files changed, 408 insertions(+), 7 deletions(-) create mode 100644 ui/src/views/storage/UploadVolume.vue diff --git a/ui/src/config/section/storage.js b/ui/src/config/section/storage.js index 9100104e7f4..9f73f8c5f3f 100644 --- a/ui/src/config/section/storage.js +++ b/ui/src/config/section/storage.js @@ -98,12 +98,8 @@ export default { docHelp: 'adminguide/storage.html#uploading-an-existing-volume-to-a-virtual-machine', label: 'label.upload.volume.from.url', listView: true, - args: ['url', 'name', 'zoneid', 'format', 'diskofferingid', 'checksum'], - mapping: { - format: { - options: ['RAW', 'VHD', 'VHDX', 'OVA', 'QCOW2'] - } - } + popup: true, + component: () => import('@/views/storage/UploadVolume.vue') }, { api: 'attachVolume', diff --git a/ui/src/views/storage/UploadLocalVolume.vue b/ui/src/views/storage/UploadLocalVolume.vue index 0e5df836fcc..dc13a6070ef 100644 --- a/ui/src/views/storage/UploadLocalVolume.vue +++ b/ui/src/views/storage/UploadLocalVolume.vue @@ -125,6 +125,39 @@ :placeholder="$t('label.volumechecksum.description')" /> + + + + + {{ opt.path || opt.name || opt.description }} + + + + + + + + {{ acc.name }} + + +
{{ this.$t('label.cancel') }} {{ this.$t('label.ok') }} @@ -150,11 +183,16 @@ export default { return { fileList: [], zones: [], + domainList: [], + accountList: [], offerings: [], offeringLoading: false, formats: ['RAW', 'VHD', 'VHDX', 'OVA', 'QCOW2'], zoneSelected: '', + domainId: null, + account: null, uploadParams: null, + domainLoading: false, loading: false, uploadPercentage: 0 } @@ -164,7 +202,7 @@ export default { this.apiParams = this.$getApiParams('getUploadParamsForVolume') }, created () { - this.listZones() + this.fetchData() }, methods: { listZones () { @@ -210,6 +248,54 @@ export default { this.fileList = [...this.fileList, file] return false }, + handleDomainChange (domain) { + this.domainId = domain + if ('listAccounts' in this.$store.getters.apis) { + this.fetchAccounts() + } + }, + handleAccountChange (acc) { + if (acc) { + this.account = acc.name + } else { + this.account = acc + } + }, + fetchData () { + this.listZones() + if ('listDomains' in this.$store.getters.apis) { + this.fetchDomains() + } + }, + fetchDomains () { + this.domainLoading = true + api('listDomains', { + listAll: true, + details: 'min' + }).then(response => { + this.domainList = response.listdomainsresponse.domain + + if (this.domainList[0]) { + this.handleDomainChange(null) + } + }).catch(error => { + this.$notifyError(error) + }).finally(() => { + this.domainLoading = false + }) + }, + fetchAccounts () { + api('listAccounts', { + domainid: this.domainId + }).then(response => { + this.accountList = response.listaccountsresponse.account || [] + if (this.accountList && this.accountList.length === 0) { + this.handleAccountChange(null) + } + }).catch(error => { + this.$notifyError(error) + }) + }, handleSubmit (e) { e.preventDefault() if (this.loading) return @@ -228,6 +314,7 @@ export default { } params[key] = input } + params.domainId = this.domainId this.loading = true api('getUploadParamsForVolume', params).then(json => { this.uploadParams = json.postuploadvolumeresponse?.getuploadparams || '' diff --git a/ui/src/views/storage/UploadVolume.vue b/ui/src/views/storage/UploadVolume.vue new file mode 100644 index 00000000000..79fbe0d2726 --- /dev/null +++ b/ui/src/views/storage/UploadVolume.vue @@ -0,0 +1,318 @@ +// 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. + + + + + +