From e211da6e7181bea7a76e79108fc3cc1ebb9d3716 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 18 Feb 2022 14:33:24 +0100 Subject: [PATCH 1/2] UI: fix network list when assign vm to other accounts in project view --- ui/src/utils/request.js | 5 ++++- ui/src/views/compute/AssignInstance.vue | 20 ++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ui/src/utils/request.js b/ui/src/utils/request.js index 8176465281f3..56179f204d48 100644 --- a/ui/src/utils/request.js +++ b/ui/src/utils/request.js @@ -134,13 +134,16 @@ service.interceptors.request.use(config => { if (config && config.params) { config.params.response = 'json' const project = Vue.ls.get(CURRENT_PROJECT) - if (!config.params.projectid && project && project.id) { + if (!config.params.projectid && !config.params.ignoreproject && project && project.id) { if (config.params.command === 'listTags') { config.params.projectid = '-1' } else { config.params.projectid = project.id } } + if (config.params.ignoreproject !== undefined) { + config.params.ignoreproject = null + } } return config }, err) diff --git a/ui/src/views/compute/AssignInstance.vue b/ui/src/views/compute/AssignInstance.vue index 9341064b3fd5..0092b157d5d5 100644 --- a/ui/src/views/compute/AssignInstance.vue +++ b/ui/src/views/compute/AssignInstance.vue @@ -232,15 +232,19 @@ export default { }, fetchNetworks () { this.loading = true - api('listNetworks', { - response: 'json', + var params = { domainId: this.selectedDomain, listAll: true, isrecursive: false, - showicon: true, - account: this.selectedAccount, - projectid: this.selectedProject - }).then(response => { + showicon: true + } + if (this.selectedProject != null) { + params.projectid = this.selectedProject + } else { + params.account = this.selectedAccount + params.ignoreproject = true + } + api('listNetworks', params).then(response => { this.networks = response.listnetworksresponse.network }).catch(error => { this.$notifyError(error) @@ -250,15 +254,19 @@ export default { }, changeDomain () { this.selectedAccount = null + this.selectedProject = null + this.selectedNetwork = null this.fetchAccounts() this.fetchProjects() }, changeAccount () { this.selectedProject = null + this.selectedNetwork = null this.fetchNetworks() }, changeProject () { this.selectedAccount = null + this.selectedNetwork = null this.fetchNetworks() }, closeAction () { From 95ba60a941d454a1831c2366a38f9c3c9890d1ab Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 18 Feb 2022 19:46:11 +0100 Subject: [PATCH 2/2] PR#5009: return [] if empty result --- ui/src/views/compute/AssignInstance.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/src/views/compute/AssignInstance.vue b/ui/src/views/compute/AssignInstance.vue index 0092b157d5d5..762e71208910 100644 --- a/ui/src/views/compute/AssignInstance.vue +++ b/ui/src/views/compute/AssignInstance.vue @@ -187,7 +187,7 @@ export default { showicon: true, details: 'min' }).then(response => { - this.domains = response.listdomainsresponse.domain + this.domains = response.listdomainsresponse.domain || [] this.selectedDomain = this.domains[0].id this.fetchAccounts() this.fetchProjects() @@ -206,7 +206,7 @@ export default { state: 'Enabled', isrecursive: false }).then(response => { - this.accounts = response.listaccountsresponse.account + this.accounts = response.listaccountsresponse.account || [] }).catch(error => { this.$notifyError(error) }).finally(() => { @@ -223,7 +223,7 @@ export default { details: 'min', isrecursive: false }).then(response => { - this.projects = response.listprojectsresponse.project + this.projects = response.listprojectsresponse.project || [] }).catch(error => { this.$notifyError(error) }).finally(() => { @@ -245,7 +245,7 @@ export default { params.ignoreproject = true } api('listNetworks', params).then(response => { - this.networks = response.listnetworksresponse.network + this.networks = response.listnetworksresponse.network || [] }).catch(error => { this.$notifyError(error) }).finally(() => {