mirror of https://github.com/apache/cloudstack.git
ui: fix form data double fetch/reset form data by ownership selection (#11705)
* ui: fix form data double fetch/reset form data by ownership selection Fixes #10832
This commit is contained in:
parent
f1f779a08d
commit
76e6de7f90
|
|
@ -2339,7 +2339,9 @@ export default {
|
||||||
this.owner.domainid = null
|
this.owner.domainid = null
|
||||||
this.owner.projectid = OwnerOptions.selectedProject
|
this.owner.projectid = OwnerOptions.selectedProject
|
||||||
}
|
}
|
||||||
|
if (OwnerOptions.initialized) {
|
||||||
this.resetData()
|
this.resetData()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fetchZones (zoneId, listZoneAllow) {
|
fetchZones (zoneId, listZoneAllow) {
|
||||||
this.zones = []
|
this.zones = []
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<a-form layout="vertical" >
|
<a-form layout="vertical" >
|
||||||
<a-form-item :label="$t('label.owner.type')">
|
<a-form-item :label="$t('label.owner.type')">
|
||||||
<a-select
|
<a-select
|
||||||
@change="changeDomain"
|
@change="changeAccountTypeOrDomain"
|
||||||
v-model:value="selectedAccountType"
|
v-model:value="selectedAccountType"
|
||||||
defaultValue="account"
|
defaultValue="account"
|
||||||
autoFocus
|
autoFocus
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :label="$t('label.domain')" required>
|
<a-form-item :label="$t('label.domain')" required>
|
||||||
<a-select
|
<a-select
|
||||||
@change="changeDomain"
|
@change="changeAccountTypeOrDomain"
|
||||||
v-model:value="selectedDomain"
|
v-model:value="selectedDomain"
|
||||||
showSearch
|
showSearch
|
||||||
optionFilterProp="label"
|
optionFilterProp="label"
|
||||||
|
|
@ -136,6 +136,7 @@ export default {
|
||||||
components: { ResourceIcon },
|
components: { ResourceIcon },
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
initialized: false,
|
||||||
domains: [],
|
domains: [],
|
||||||
accounts: [],
|
accounts: [],
|
||||||
projects: [],
|
projects: [],
|
||||||
|
|
@ -143,7 +144,8 @@ export default {
|
||||||
selectedDomain: null,
|
selectedDomain: null,
|
||||||
selectedAccount: null,
|
selectedAccount: null,
|
||||||
selectedProject: null,
|
selectedProject: null,
|
||||||
loading: false
|
loading: false,
|
||||||
|
requestToken: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -177,7 +179,7 @@ export default {
|
||||||
const domainIds = this.domains?.map(domain => domain.id)
|
const domainIds = this.domains?.map(domain => domain.id)
|
||||||
const ownerDomainId = this.$store.getters.project?.domainid || this.$store.getters.userInfo.domainid
|
const ownerDomainId = this.$store.getters.project?.domainid || this.$store.getters.userInfo.domainid
|
||||||
this.selectedDomain = domainIds?.includes(ownerDomainId) ? ownerDomainId : this.domains?.[0]?.id
|
this.selectedDomain = domainIds?.includes(ownerDomainId) ? ownerDomainId : this.domains?.[0]?.id
|
||||||
this.changeDomain()
|
this.fetchOwnerData()
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$notifyError(error)
|
this.$notifyError(error)
|
||||||
|
|
@ -186,8 +188,13 @@ export default {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
incrementAndGetRequestToken () {
|
||||||
|
this.requestToken += 1
|
||||||
|
return this.requestToken
|
||||||
|
},
|
||||||
fetchAccounts () {
|
fetchAccounts () {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
const currentToken = this.incrementAndGetRequestToken()
|
||||||
api('listAccounts', {
|
api('listAccounts', {
|
||||||
response: 'json',
|
response: 'json',
|
||||||
domainId: this.selectedDomain,
|
domainId: this.selectedDomain,
|
||||||
|
|
@ -196,6 +203,9 @@ export default {
|
||||||
isrecursive: false
|
isrecursive: false
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
if (currentToken !== this.requestToken) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.accounts = response.listaccountsresponse.account || []
|
this.accounts = response.listaccountsresponse.account || []
|
||||||
if (this.override?.accounts && this.accounts) {
|
if (this.override?.accounts && this.accounts) {
|
||||||
this.accounts = this.accounts.filter(item => this.override.accounts.has(item.name))
|
this.accounts = this.accounts.filter(item => this.override.accounts.has(item.name))
|
||||||
|
|
@ -214,10 +224,12 @@ export default {
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
this.initialized = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fetchProjects () {
|
fetchProjects () {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
const currentToken = this.incrementAndGetRequestToken()
|
||||||
api('listProjects', {
|
api('listProjects', {
|
||||||
response: 'json',
|
response: 'json',
|
||||||
domainId: this.selectedDomain,
|
domainId: this.selectedDomain,
|
||||||
|
|
@ -227,6 +239,9 @@ export default {
|
||||||
isrecursive: false
|
isrecursive: false
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
if (currentToken !== this.requestToken) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.projects = response.listprojectsresponse.project
|
this.projects = response.listprojectsresponse.project
|
||||||
if (this.override?.projects && this.projects) {
|
if (this.override?.projects && this.projects) {
|
||||||
this.projects = this.projects.filter(item => this.override.projects.has(item.id))
|
this.projects = this.projects.filter(item => this.override.projects.has(item.id))
|
||||||
|
|
@ -240,9 +255,14 @@ export default {
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
this.initialized = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
changeDomain () {
|
changeAccountTypeOrDomain () {
|
||||||
|
this.initialized = true
|
||||||
|
this.fetchOwnerData()
|
||||||
|
},
|
||||||
|
fetchOwnerData () {
|
||||||
if (this.selectedAccountType === 'Account') {
|
if (this.selectedAccountType === 'Account') {
|
||||||
this.fetchAccounts()
|
this.fetchAccounts()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,7 @@ export default {
|
||||||
this.owner.domainid = null
|
this.owner.domainid = null
|
||||||
this.owner.projectid = OwnerOptions.selectedProject
|
this.owner.projectid = OwnerOptions.selectedProject
|
||||||
}
|
}
|
||||||
if (isAdminOrDomainAdmin()) {
|
if (OwnerOptions.initialized && isAdminOrDomainAdmin()) {
|
||||||
this.updateVPCCheckAndFetchNetworkOfferingData()
|
this.updateVPCCheckAndFetchNetworkOfferingData()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,7 @@ export default {
|
||||||
this.owner.domainid = null
|
this.owner.domainid = null
|
||||||
this.owner.projectid = OwnerOptions.selectedProject
|
this.owner.projectid = OwnerOptions.selectedProject
|
||||||
}
|
}
|
||||||
if (isAdminOrDomainAdmin()) {
|
if (OwnerOptions.initialized && this.isAdminOrDomainAdmin()) {
|
||||||
this.updateVPCCheckAndFetchNetworkOfferingData()
|
this.updateVPCCheckAndFetchNetworkOfferingData()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -272,23 +272,21 @@ export default {
|
||||||
},
|
},
|
||||||
fetchOwnerOptions (OwnerOptions) {
|
fetchOwnerOptions (OwnerOptions) {
|
||||||
this.owner = {}
|
this.owner = {}
|
||||||
console.log('fetching owner')
|
|
||||||
if (OwnerOptions.selectedAccountType === 'Account') {
|
if (OwnerOptions.selectedAccountType === 'Account') {
|
||||||
if (!OwnerOptions.selectedAccount) {
|
if (!OwnerOptions.selectedAccount) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('fetched account')
|
|
||||||
this.owner.account = OwnerOptions.selectedAccount
|
this.owner.account = OwnerOptions.selectedAccount
|
||||||
this.owner.domainid = OwnerOptions.selectedDomain
|
this.owner.domainid = OwnerOptions.selectedDomain
|
||||||
} else if (OwnerOptions.selectedAccountType === 'Project') {
|
} else if (OwnerOptions.selectedAccountType === 'Project') {
|
||||||
if (!OwnerOptions.selectedProject) {
|
if (!OwnerOptions.selectedProject) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('fetched project')
|
|
||||||
this.owner.projectid = OwnerOptions.selectedProject
|
this.owner.projectid = OwnerOptions.selectedProject
|
||||||
}
|
}
|
||||||
console.log('fetched owner')
|
if (OwnerOptions.initialized) {
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fetchData () {
|
fetchData () {
|
||||||
this.minCpu = store.getters.features.sharedfsvmmincpucount
|
this.minCpu = store.getters.features.sharedfsvmmincpucount
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,9 @@ export default {
|
||||||
}
|
}
|
||||||
this.owner.projectid = OwnerOptions.selectedProject
|
this.owner.projectid = OwnerOptions.selectedProject
|
||||||
}
|
}
|
||||||
|
if (OwnerOptions.initialized) {
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fetchData () {
|
fetchData () {
|
||||||
if (this.createVolumeFromSnapshot) {
|
if (this.createVolumeFromSnapshot) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue