|
93 | 93 | :filterOption="(input, option) => { |
94 | 94 | return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 |
95 | 95 | }" |
96 | | - :loading="zoneLoading" |
| 96 | + :loading="formPhysicalNetworkLoading" |
97 | 97 | :placeholder="this.$t('label.physicalnetworkid')" |
98 | 98 | @change="val => { this.handlePhysicalNetworkChange(this.formPhysicalNetworks[val]) }"> |
99 | 99 | <a-select-option v-for="(opt, optIndex) in this.formPhysicalNetworks" :key="optIndex"> |
@@ -542,57 +542,67 @@ export default { |
542 | 542 | this.fetchPhysicalNetworkData() |
543 | 543 | }, |
544 | 544 | fetchPhysicalNetworkData () { |
| 545 | + this.formSelectedPhysicalNetwork = {} |
| 546 | + this.formPhysicalNetworks = [] |
545 | 547 | if (this.physicalNetworks != null) { |
546 | 548 | this.formPhysicalNetworks = this.physicalNetworks |
547 | | - if (this.arrayHasItems(this.formPhysicalNetworks)) { |
548 | | - this.form.setFieldsValue({ |
549 | | - physicalnetworkid: 0 |
550 | | - }) |
551 | | - this.handlePhysicalNetworkChange(this.formPhysicalNetworks[0]) |
552 | | - } |
| 549 | + this.selectFirstPhysicalNetwork() |
553 | 550 | } else { |
554 | 551 | if (this.selectedZone === null || this.selectedZone === undefined) { |
555 | 552 | return |
556 | 553 | } |
557 | | - const params = {} |
558 | | - params.zoneid = this.selectedZone.id |
559 | | - this.formPhysicalNetworksLoading = true |
| 554 | + const promises = [] |
| 555 | + const params = { |
| 556 | + zoneid: this.selectedZone.id |
| 557 | + } |
| 558 | + this.formPhysicalNetworkLoading = true |
560 | 559 | api('listPhysicalNetworks', params).then(json => { |
561 | | - this.formPhysicalNetworks = [] |
562 | 560 | var networks = json.listphysicalnetworksresponse.physicalnetwork |
563 | 561 | if (this.arrayHasItems(networks)) { |
564 | | - for (const i in networks) { |
565 | | - this.addPhysicalNetworkForGuestTrafficType(networks[i]) |
| 562 | + for (const network of networks) { |
| 563 | + promises.push(this.addPhysicalNetworkForGuestTrafficType(network)) |
566 | 564 | } |
567 | 565 | } else { |
568 | 566 | this.formPhysicalNetworkLoading = false |
569 | 567 | } |
570 | 568 | }).finally(() => { |
| 569 | + if (this.arrayHasItems(promises)) { |
| 570 | + Promise.all(promises).catch(error => { |
| 571 | + this.$notifyError(error) |
| 572 | + }).finally(() => { |
| 573 | + this.formPhysicalNetworkLoading = false |
| 574 | + this.selectFirstPhysicalNetwork() |
| 575 | + }) |
| 576 | + } |
| 577 | + }) |
| 578 | + } |
| 579 | + }, |
| 580 | + selectFirstPhysicalNetwork () { |
| 581 | + if (this.arrayHasItems(this.formPhysicalNetworks)) { |
| 582 | + this.form.setFieldsValue({ |
| 583 | + physicalnetworkid: 0 |
571 | 584 | }) |
| 585 | + this.handlePhysicalNetworkChange(this.formPhysicalNetworks[0]) |
572 | 586 | } |
573 | 587 | }, |
574 | 588 | addPhysicalNetworkForGuestTrafficType (physicalNetwork) { |
575 | 589 | const params = {} |
576 | 590 | params.physicalnetworkid = physicalNetwork.id |
577 | | - api('listTrafficTypes', params).then(json => { |
578 | | - var trafficTypes = json.listtraffictypesresponse.traffictype |
579 | | - if (this.arrayHasItems(trafficTypes)) { |
580 | | - for (const i in trafficTypes) { |
581 | | - if (trafficTypes[i].traffictype === 'Guest') { |
582 | | - this.formPhysicalNetworks.push(physicalNetwork) |
583 | | - break |
| 591 | + return new Promise((resolve, reject) => { |
| 592 | + api('listTrafficTypes', params).then(json => { |
| 593 | + var trafficTypes = json.listtraffictypesresponse.traffictype |
| 594 | + if (this.arrayHasItems(trafficTypes)) { |
| 595 | + for (const type of trafficTypes) { |
| 596 | + if (type.traffictype === 'Guest') { |
| 597 | + this.formPhysicalNetworks.push(physicalNetwork) |
| 598 | + break |
| 599 | + } |
584 | 600 | } |
585 | 601 | } |
586 | | - } else { |
587 | | - this.formPhysicalNetworkLoading = false |
588 | | - } |
589 | | - }).finally(() => { |
590 | | - if (this.formPhysicalNetworks.length > 0 && this.isObjectEmpty(this.formSelectedPhysicalNetwork)) { |
591 | | - this.form.setFieldsValue({ |
592 | | - physicalnetworkid: 0 |
593 | | - }) |
594 | | - this.handlePhysicalNetworkChange(this.formPhysicalNetworks[0]) |
595 | | - } |
| 602 | + resolve() |
| 603 | + }).catch(error => { |
| 604 | + reject(error) |
| 605 | + }) |
596 | 606 | }) |
597 | 607 | }, |
598 | 608 | handlePhysicalNetworkChange (physicalNet) { |
|
0 commit comments