From 8ae3047e3d45c4fe64fed01d7e7dbe4a287cdacc Mon Sep 17 00:00:00 2001 From: nvazquez Date: Tue, 15 Aug 2023 22:45:36 -0300 Subject: [PATCH 1/3] UI: Add missing domain and account parameters to register template --- .../views/image/RegisterOrUploadTemplate.vue | 86 ++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/ui/src/views/image/RegisterOrUploadTemplate.vue b/ui/src/views/image/RegisterOrUploadTemplate.vue index 4ed33afce9af..03790df6e6ee 100644 --- a/ui/src/views/image/RegisterOrUploadTemplate.vue +++ b/ui/src/views/image/RegisterOrUploadTemplate.vue @@ -117,6 +117,47 @@ + + + + + + + + {{ opt.path || opt.name || opt.description }} + + + + + + + + + {{ acc.name }} + + + @@ -408,7 +449,12 @@ export default { allowed: false, allowDirectDownload: false, uploadParams: null, - currentForm: ['plus-outlined', 'PlusOutlined'].includes(this.action.currentAction.icon) ? 'Create' : 'Upload' + currentForm: ['plus-outlined', 'PlusOutlined'].includes(this.action.currentAction.icon) ? 'Create' : 'Upload', + domains: [], + accounts: [], + domainLoading: false, + domainid: null, + account: null } }, beforeCreate () { @@ -460,6 +506,7 @@ export default { this.fetchOsTypes() this.fetchUserData() this.fetchUserdataPolicy() + this.fetchDomains() if (Object.prototype.hasOwnProperty.call(store.getters.apis, 'listConfigurations')) { if (this.allowed && this.hyperXenServerShow) { this.fetchXenServerProvider() @@ -998,6 +1045,43 @@ export default { arrSelectReset.forEach(name => { this.form[name] = undefined }) + }, + fetchDomains () { + const params = {} + params.listAll = true + params.showicon = true + params.details = 'min' + this.domainLoading = true + api('listDomains', params).then(json => { + this.domains = json.listdomainsresponse.domain + }).finally(() => { + this.domainLoading = false + this.handleDomainChange(null) + }) + }, + handleDomainChange (domain) { + this.domainid = domain + this.form.account = null + this.account = null + if ('listAccounts' in this.$store.getters.apis) { + this.fetchAccounts() + } + }, + fetchAccounts () { + api('listAccounts', { + domainid: this.domainid + }).then(response => { + this.accounts = response.listaccountsresponse.account || [] + }).catch(error => { + this.$notifyError(error) + }) + }, + handleAccountChange (acc) { + if (acc) { + this.account = acc.name + } else { + this.account = acc + } } } } From 5c02acc2998a2cf044f12940dc658ddd9bb28415 Mon Sep 17 00:00:00 2001 From: nvazquez Date: Tue, 15 Aug 2023 22:51:40 -0300 Subject: [PATCH 2/3] Only display the domain if listDomains API is accessible --- ui/src/views/image/RegisterOrUploadTemplate.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/views/image/RegisterOrUploadTemplate.vue b/ui/src/views/image/RegisterOrUploadTemplate.vue index 03790df6e6ee..80103783664b 100644 --- a/ui/src/views/image/RegisterOrUploadTemplate.vue +++ b/ui/src/views/image/RegisterOrUploadTemplate.vue @@ -117,7 +117,7 @@ - + From 957704572da7be35661413122181e76aeba8d176 Mon Sep 17 00:00:00 2001 From: nvazquez Date: Wed, 16 Aug 2023 10:51:31 -0300 Subject: [PATCH 3/3] Add fields to Register ISO view --- ui/src/views/image/RegisterOrUploadIso.vue | 89 ++++++++++++++++++- .../views/image/RegisterOrUploadTemplate.vue | 4 +- 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/ui/src/views/image/RegisterOrUploadIso.vue b/ui/src/views/image/RegisterOrUploadIso.vue index c56dcd8aa7b6..6c34ec8972a7 100644 --- a/ui/src/views/image/RegisterOrUploadIso.vue +++ b/ui/src/views/image/RegisterOrUploadIso.vue @@ -97,6 +97,48 @@ + + + + + + + + {{ opt.path || opt.name || opt.description }} + + + + + + + + + {{ acc.name }} + + + + @@ -229,7 +271,12 @@ export default { allowed: false, uploadParams: null, uploadPercentage: 0, - currentForm: ['plus-outlined', 'PlusOutlined'].includes(this.action.currentAction.icon) ? 'Create' : 'Upload' + currentForm: ['plus-outlined', 'PlusOutlined'].includes(this.action.currentAction.icon) ? 'Create' : 'Upload', + domains: [], + accounts: [], + domainLoading: false, + domainid: null, + account: null } }, beforeCreate () { @@ -270,6 +317,9 @@ export default { this.fetchOsType() this.fetchUserData() this.fetchUserdataPolicy() + if ('listDomains' in this.$store.getters.apis) { + this.fetchDomains() + } }, fetchZoneData () { const params = {} @@ -478,6 +528,43 @@ export default { }).finally(() => { this.loading = false }) + }, + fetchDomains () { + const params = {} + params.listAll = true + params.showicon = true + params.details = 'min' + this.domainLoading = true + api('listDomains', params).then(json => { + this.domains = json.listdomainsresponse.domain + }).finally(() => { + this.domainLoading = false + this.handleDomainChange(null) + }) + }, + handleDomainChange (domain) { + this.domainid = domain + this.form.account = null + this.account = null + if ('listAccounts' in this.$store.getters.apis) { + this.fetchAccounts() + } + }, + fetchAccounts () { + api('listAccounts', { + domainid: this.domainid + }).then(response => { + this.accounts = response.listaccountsresponse.account || [] + }).catch(error => { + this.$notifyError(error) + }) + }, + handleAccountChange (acc) { + if (acc) { + this.account = acc.name + } else { + this.account = acc + } } } } diff --git a/ui/src/views/image/RegisterOrUploadTemplate.vue b/ui/src/views/image/RegisterOrUploadTemplate.vue index 80103783664b..c8558cb4d115 100644 --- a/ui/src/views/image/RegisterOrUploadTemplate.vue +++ b/ui/src/views/image/RegisterOrUploadTemplate.vue @@ -506,7 +506,9 @@ export default { this.fetchOsTypes() this.fetchUserData() this.fetchUserdataPolicy() - this.fetchDomains() + if ('listDomains' in this.$store.getters.apis) { + this.fetchDomains() + } if (Object.prototype.hasOwnProperty.call(store.getters.apis, 'listConfigurations')) { if (this.allowed && this.hyperXenServerShow) { this.fetchXenServerProvider()