Skip to content

Commit f26cbfe

Browse files
committed
Fix listing of resorces for ASG belonging to a project
1 parent a7c2a05 commit f26cbfe

4 files changed

Lines changed: 84 additions & 25 deletions

File tree

ui/src/views/compute/AutoScaleDownPolicyTab.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,14 @@ export default {
425425
methods: {
426426
fetchInitData () {
427427
this.loading = true
428-
api('listAutoScaleVmGroups', {
428+
const params = {
429429
listAll: true,
430430
id: this.resource.id
431-
}).then(response => {
431+
}
432+
if (this.resource.projectid) {
433+
params.projectid = this.resource.projectid
434+
}
435+
api('listAutoScaleVmGroups', params).then(response => {
432436
const lbruleid = response.listautoscalevmgroupsresponse?.autoscalevmgroup?.[0]?.lbruleid
433437
this.policies = response.listautoscalevmgroupsresponse?.autoscalevmgroup?.[0]?.scaledownpolicies
434438
if (this.selectedPolicyId) {
@@ -437,10 +441,14 @@ export default {
437441
this.policy = this.policies?.[0]
438442
this.selectedPolicyId = this.policy.id
439443
}
440-
api('listLoadBalancerRules', {
444+
const lbParams = {
441445
listAll: true,
442446
id: lbruleid
443-
}).then(response => {
447+
}
448+
if (this.resource.projectid) {
449+
lbParams.projectid = this.resource.projectid
450+
}
451+
api('listLoadBalancerRules', lbParams).then(response => {
444452
const networkid = response.listloadbalancerrulesresponse?.loadbalancerrule?.[0]?.networkid
445453
api('listNetworks', {
446454
listAll: true,
@@ -464,10 +472,14 @@ export default {
464472
},
465473
fetchData () {
466474
this.loading = true
467-
api('listAutoScalePolicies', {
475+
const params = {
468476
listAll: true,
469477
id: this.selectedPolicyId
470-
}).then(response => {
478+
}
479+
if (this.resource.projectid) {
480+
params.projectid = this.resource.projectid
481+
}
482+
api('listAutoScalePolicies', params).then(response => {
471483
this.policy = response.listautoscalepoliciesresponse?.autoscalepolicy[0]
472484
}).finally(() => {
473485
this.loading = false

ui/src/views/compute/AutoScaleLoadBalancing.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,16 @@ export default {
462462
this.lbRules = []
463463
this.stickinessPolicies = []
464464
465-
api('listLoadBalancerRules', {
465+
const params = {
466466
listAll: true,
467467
id: this.resource.lbruleid,
468468
page: this.page,
469469
pageSize: this.pageSize
470-
}).then(response => {
470+
}
471+
if (this.resource.projectid) {
472+
params.projectid = this.resource.projectid
473+
}
474+
api('listLoadBalancerRules', params).then(response => {
471475
this.lbRules = response.listloadbalancerrulesresponse.loadbalancerrule || []
472476
this.totalCount = response.listloadbalancerrulesresponse.count || 0
473477
}).then(() => {
@@ -519,10 +523,14 @@ export default {
519523
fetchAutoScaleVMgroups () {
520524
this.loading = true
521525
this.lbRules.forEach(rule => {
522-
api('listAutoScaleVmGroups', {
526+
const params = {
523527
listAll: true,
524528
lbruleid: rule.id
525-
}).then(response => {
529+
}
530+
if (this.resource.projectid) {
531+
params.projectid = this.resource.projectid
532+
}
533+
api('listAutoScaleVmGroups', params).then(response => {
526534
rule.autoscalevmgroup = response.listautoscalevmgroupsresponse?.autoscalevmgroup?.[0]
527535
}).finally(() => {
528536
this.loading = false

ui/src/views/compute/AutoScaleUpPolicyTab.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,14 @@ export default {
425425
methods: {
426426
fetchInitData () {
427427
this.loading = true
428-
api('listAutoScaleVmGroups', {
428+
const params = {
429429
listAll: true,
430430
id: this.resource.id
431-
}).then(response => {
431+
}
432+
if (this.resource.projectid) {
433+
params.projectid = this.resource.projectid
434+
}
435+
api('listAutoScaleVmGroups', params).then(response => {
432436
const lbruleid = response.listautoscalevmgroupsresponse?.autoscalevmgroup?.[0]?.lbruleid
433437
this.policies = response.listautoscalevmgroupsresponse?.autoscalevmgroup?.[0]?.scaleuppolicies
434438
if (this.selectedPolicyId) {
@@ -437,10 +441,14 @@ export default {
437441
this.policy = this.policies?.[0]
438442
this.selectedPolicyId = this.policy.id
439443
}
440-
api('listLoadBalancerRules', {
444+
const lbParams = {
441445
listAll: true,
442446
id: lbruleid
443-
}).then(response => {
447+
}
448+
if (this.resource.projectid) {
449+
lbParams.projectid = this.resource.projectid
450+
}
451+
api('listLoadBalancerRules', lbParams).then(response => {
444452
const networkid = response.listloadbalancerrulesresponse?.loadbalancerrule?.[0]?.networkid
445453
api('listNetworks', {
446454
listAll: true,
@@ -464,10 +472,14 @@ export default {
464472
},
465473
fetchData () {
466474
this.loading = true
467-
api('listAutoScalePolicies', {
475+
const params = {
468476
listAll: true,
469477
id: this.selectedPolicyId
470-
}).then(response => {
478+
}
479+
if (this.resource.projectid) {
480+
params.projectid = this.resource.projectid
481+
}
482+
api('listAutoScalePolicies', params).then(response => {
471483
this.policy = response.listautoscalepoliciesresponse?.autoscalepolicy[0]
472484
}).finally(() => {
473485
this.loading = false

ui/src/views/compute/AutoScaleVmProfile.vue

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<div class="form__label">
6363
<tooltip-label :title="$t('label.templatename')" :tooltip="createAutoScaleVmProfileApiParams.templateid.description"/>
6464
</div>
65-
{{ getTemplateName(templateid) }}
65+
{{ templateName || templateid }}
6666
</div>
6767
</div>
6868
<div class="form">
@@ -338,6 +338,7 @@ export default {
338338
autoscaleuserid: null,
339339
expungevmgraceperiod: null,
340340
templateid: null,
341+
templateName: null,
341342
serviceofferingid: null,
342343
userdata: null,
343344
userdataid: null,
@@ -422,6 +423,9 @@ export default {
422423
domainid: this.resource.domainid,
423424
account: this.resource.account
424425
}
426+
if (this.resource.projectid) {
427+
params.projectid = this.resource.projectid
428+
}
425429
if (isAdmin()) {
426430
params.templatefilter = 'all'
427431
} else {
@@ -436,6 +440,9 @@ export default {
436440
listall: 'true',
437441
issystem: 'false'
438442
}
443+
if (this.resource.projectid) {
444+
params.projectid = this.resource.projectid
445+
}
439446
if (isAdminOrDomainAdmin()) {
440447
params.isrecursive = 'true'
441448
}
@@ -446,15 +453,20 @@ export default {
446453
},
447454
fetchData () {
448455
this.loading = true
449-
api('listAutoScaleVmProfiles', {
456+
const params = {
450457
listAll: true,
451458
id: this.resource.vmprofileid
452-
}).then(response => {
459+
}
460+
if (this.resource.projectid) {
461+
params.projectid = this.resource.projectid
462+
}
463+
api('listAutoScaleVmProfiles', params).then(response => {
453464
this.profileid = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.id
454465
this.autoscaleuserid = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.autoscaleuserid
455466
this.expungevmgraceperiod = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.expungevmgraceperiod
456467
this.serviceofferingid = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.serviceofferingid
457468
this.templateid = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.templateid
469+
this.fetchTemplate(this.templateid)
458470
this.userdata = this.decodeUserData(decodeURIComponent(response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.userdata || ''))
459471
this.userdataid = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.userdataid
460472
this.userdataname = response.listautoscalevmprofilesresponse?.autoscalevmprofile?.[0]?.userdataname
@@ -468,13 +480,22 @@ export default {
468480
this.loading = false
469481
})
470482
},
471-
getTemplateName (templateid) {
472-
for (const template of this.templatesList) {
473-
if (template.id === templateid) {
474-
return template.name
475-
}
483+
fetchTemplate (templateid) {
484+
if (!templateid) return
485+
const params = {
486+
id: templateid,
487+
templatefilter: 'executable'
476488
}
477-
return ''
489+
if (this.resource.projectid) {
490+
params.projectid = this.resource.projectid
491+
}
492+
api('listTemplates', params).then(json => {
493+
if (json.listtemplatesresponse?.template?.[0]) {
494+
this.templateName = json.listtemplatesresponse.template[0].name
495+
} else {
496+
this.templateName = templateid
497+
}
498+
})
478499
},
479500
getServiceOfferingName (serviceofferingid) {
480501
for (const serviceoffering of this.serviceOfferingsList) {
@@ -576,16 +597,20 @@ export default {
576597
this.$pollJob({
577598
jobId: response.updateautoscalevmprofileresponse.jobid,
578599
successMethod: (result) => {
600+
this.fetchData()
579601
},
580602
errorMessage: this.$t('message.update.autoscale.vm.profile.failed'),
581603
errorMethod: () => {
604+
this.fetchData()
582605
}
583606
})
584607
}).finally(() => {
585608
this.loading = false
586609
})
587610
},
588611
updateAutoScaleVmProfile () {
612+
if (this.loading) return
613+
this.loading = true
589614
const params = {
590615
id: this.profileid,
591616
expungevmgraceperiod: this.expungevmgraceperiod,
@@ -604,6 +629,7 @@ export default {
604629
this.$pollJob({
605630
jobId: response.updateautoscalevmprofileresponse.jobid,
606631
successMethod: (result) => {
632+
this.closeModal()
607633
},
608634
errorMessage: this.$t('message.update.autoscale.vm.profile.failed'),
609635
errorMethod: () => {
@@ -618,6 +644,7 @@ export default {
618644
return decodedData.toString('utf-8')
619645
},
620646
closeModal () {
647+
this.fetchData()
621648
this.editProfileModalVisible = false
622649
}
623650
}

0 commit comments

Comments
 (0)