|
73 | 73 | :filterOption="(input, option) => { |
74 | 74 | return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 |
75 | 75 | }" |
76 | | - :loading="zoneLoading" |
| 76 | + :loading="formPhysicalNetworkLoading" |
77 | 77 | :placeholder="this.$t('label.physicalnetworkid')" |
78 | 78 | @change="val => { this.handlePhysicalNetworkChange(this.formPhysicalNetworks[val]) }"> |
79 | 79 | <a-select-option v-for="(opt, optIndex) in this.formPhysicalNetworks" :key="optIndex"> |
@@ -469,57 +469,67 @@ export default { |
469 | 469 | this.fetchPhysicalNetworkData() |
470 | 470 | }, |
471 | 471 | fetchPhysicalNetworkData () { |
| 472 | + this.formSelectedPhysicalNetwork = {} |
| 473 | + this.formPhysicalNetworks = [] |
472 | 474 | if (this.physicalNetworks != null) { |
473 | 475 | this.formPhysicalNetworks = this.physicalNetworks |
474 | | - if (this.arrayHasItems(this.formPhysicalNetworks)) { |
475 | | - this.form.setFieldsValue({ |
476 | | - physicalnetworkid: 0 |
477 | | - }) |
478 | | - this.handlePhysicalNetworkChange(this.formPhysicalNetworks[0]) |
479 | | - } |
| 476 | + this.selectFirstPhysicalNetwork() |
480 | 477 | } else { |
481 | 478 | if (this.selectedZone === null || this.selectedZone === undefined) { |
482 | 479 | return |
483 | 480 | } |
484 | | - const params = {} |
485 | | - params.zoneid = this.selectedZone.id |
486 | | - this.formPhysicalNetworksLoading = true |
| 481 | + const promises = [] |
| 482 | + const params = { |
| 483 | + zoneid: this.selectedZone.id |
| 484 | + } |
| 485 | + this.formPhysicalNetworkLoading = true |
487 | 486 | api('listPhysicalNetworks', params).then(json => { |
488 | | - this.formPhysicalNetworks = [] |
489 | 487 | var networks = json.listphysicalnetworksresponse.physicalnetwork |
490 | 488 | if (this.arrayHasItems(networks)) { |
491 | | - for (const i in networks) { |
492 | | - this.addPhysicalNetworkForGuestTrafficType(networks[i]) |
| 489 | + for (const network of networks) { |
| 490 | + promises.push(this.addPhysicalNetworkForGuestTrafficType(network)) |
493 | 491 | } |
494 | 492 | } else { |
495 | 493 | this.formPhysicalNetworkLoading = false |
496 | 494 | } |
497 | 495 | }).finally(() => { |
| 496 | + if (this.arrayHasItems(promises)) { |
| 497 | + Promise.all(promises).catch(error => { |
| 498 | + this.$notifyError(error) |
| 499 | + }).finally(() => { |
| 500 | + this.formPhysicalNetworkLoading = false |
| 501 | + this.selectFirstPhysicalNetwork() |
| 502 | + }) |
| 503 | + } |
| 504 | + }) |
| 505 | + } |
| 506 | + }, |
| 507 | + selectFirstPhysicalNetwork () { |
| 508 | + if (this.arrayHasItems(this.formPhysicalNetworks)) { |
| 509 | + this.form.setFieldsValue({ |
| 510 | + physicalnetworkid: 0 |
498 | 511 | }) |
| 512 | + this.handlePhysicalNetworkChange(this.formPhysicalNetworks[0]) |
499 | 513 | } |
500 | 514 | }, |
501 | 515 | addPhysicalNetworkForGuestTrafficType (physicalNetwork) { |
502 | 516 | const params = {} |
503 | 517 | params.physicalnetworkid = physicalNetwork.id |
504 | | - api('listTrafficTypes', params).then(json => { |
505 | | - var trafficTypes = json.listtraffictypesresponse.traffictype |
506 | | - if (this.arrayHasItems(trafficTypes)) { |
507 | | - for (const i in trafficTypes) { |
508 | | - if (trafficTypes[i].traffictype === 'Guest') { |
509 | | - this.formPhysicalNetworks.push(physicalNetwork) |
510 | | - break |
| 518 | + return new Promise((resolve, reject) => { |
| 519 | + api('listTrafficTypes', params).then(json => { |
| 520 | + var trafficTypes = json.listtraffictypesresponse.traffictype |
| 521 | + if (this.arrayHasItems(trafficTypes)) { |
| 522 | + for (const type of trafficTypes) { |
| 523 | + if (type.traffictype === 'Guest') { |
| 524 | + this.formPhysicalNetworks.push(physicalNetwork) |
| 525 | + break |
| 526 | + } |
511 | 527 | } |
512 | 528 | } |
513 | | - } else { |
514 | | - this.formPhysicalNetworkLoading = false |
515 | | - } |
516 | | - }).finally(() => { |
517 | | - if (this.formPhysicalNetworks.length > 0 && this.isObjectEmpty(this.formSelectedPhysicalNetwork)) { |
518 | | - this.form.setFieldsValue({ |
519 | | - physicalnetworkid: 0 |
520 | | - }) |
521 | | - this.handlePhysicalNetworkChange(this.formPhysicalNetworks[0]) |
522 | | - } |
| 529 | + resolve() |
| 530 | + }).catch(error => { |
| 531 | + reject(error) |
| 532 | + }) |
523 | 533 | }) |
524 | 534 | }, |
525 | 535 | handlePhysicalNetworkChange (physicalNet) { |
|
0 commit comments