This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch 4.18
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.18 by this push:
new 11ff2d20e8f UI: fix templates/offerings are not listed in autoscale vm
profile when login as user (#7343)
11ff2d20e8f is described below
commit 11ff2d20e8f4869862bfd3886596dc084f4c6a9d
Author: Wei Zhou <[email protected]>
AuthorDate: Thu Mar 30 09:29:55 2023 +0200
UI: fix templates/offerings are not listed in autoscale vm profile when
login as user (#7343)
---
ui/src/views/compute/AutoScaleVmProfile.vue | 21 +++++++++++++++------
ui/src/views/compute/CreateAutoScaleVmGroup.vue | 2 +-
ui/src/views/compute/DeployVM.vue | 4 ++--
3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/ui/src/views/compute/AutoScaleVmProfile.vue
b/ui/src/views/compute/AutoScaleVmProfile.vue
index 531868239bd..b00a35f04dd 100644
--- a/ui/src/views/compute/AutoScaleVmProfile.vue
+++ b/ui/src/views/compute/AutoScaleVmProfile.vue
@@ -243,6 +243,7 @@
<script>
import { api } from '@/api'
+import { isAdmin, isAdminOrDomainAdmin } from '@/role'
import Status from '@/components/widgets/Status'
import TooltipButton from '@/components/widgets/TooltipButton'
import TooltipLabel from '@/components/widgets/TooltipLabel'
@@ -344,21 +345,29 @@ export default {
})
},
fetchTemplateData () {
- api('listTemplates', {
- templatefilter: 'all',
+ const params = {
listall: 'true',
domainid: this.resource.domainid,
account: this.resource.account
- }).then(json => {
+ }
+ if (isAdmin()) {
+ params.templatefilter = 'all'
+ } else {
+ params.templatefilter = 'executable'
+ }
+ api('listTemplates', params).then(json => {
this.templatesList = json.listtemplatesresponse?.template || []
})
},
fetchServiceOfferingData () {
- api('listServiceOfferings', {
+ const params = {
listall: 'true',
- isrecursive: 'true',
issystem: 'false'
- }).then(json => {
+ }
+ if (isAdminOrDomainAdmin()) {
+ params.isrecursive = 'true'
+ }
+ api('listServiceOfferings', params).then(json => {
this.serviceOfferingsList =
json.listserviceofferingsresponse?.serviceoffering || []
this.serviceOfferingsList = this.serviceOfferingsList.filter(offering
=> !offering.iscustomized)
})
diff --git a/ui/src/views/compute/CreateAutoScaleVmGroup.vue
b/ui/src/views/compute/CreateAutoScaleVmGroup.vue
index 4ad0e20120e..61087a0a3d7 100644
--- a/ui/src/views/compute/CreateAutoScaleVmGroup.vue
+++ b/ui/src/views/compute/CreateAutoScaleVmGroup.vue
@@ -1652,7 +1652,7 @@ export default {
if (this.templateId) {
apiName = 'listTemplates'
params.listall = true
- params.templatefilter = 'all'
+ params.templatefilter = this.isNormalAndDomainUser ? 'executable' :
'all'
params.id = this.templateId
} else if (this.networkId) {
params.listall = true
diff --git a/ui/src/views/compute/DeployVM.vue
b/ui/src/views/compute/DeployVM.vue
index 9190d8b0c96..b15fa8bcccf 100644
--- a/ui/src/views/compute/DeployVM.vue
+++ b/ui/src/views/compute/DeployVM.vue
@@ -1619,11 +1619,11 @@ export default {
if (this.templateId) {
apiName = 'listTemplates'
params.listall = true
- params.templatefilter = 'all'
+ params.templatefilter = this.isNormalAndDomainUser ? 'executable' :
'all'
params.id = this.templateId
} else if (this.isoId) {
params.listall = true
- params.isofilter = 'all'
+ params.isofilter = this.isNormalAndDomainUser ? 'executable' : 'all'
params.id = this.isoId
apiName = 'listIsos'
} else if (this.networkId) {