102102 icon =" environment"
103103 shape =" circle"
104104 :disabled =" (!('addIpToNic' in $store.getters.apis) && !('addIpToNic' in $store.getters.apis))"
105- @click =" fetchSecondaryIPs (record.nic.id )" />
105+ @click =" onAcquireSecondaryIPAddress (record)" />
106106 </a-tooltip >
107107 <a-tooltip placement =" bottom" >
108108 <template slot="title">
220220 {{ $t('message.network.secondaryip') }}
221221 </p >
222222 <a-divider />
223- <a-input :placeholder =" $t('label.new.secondaryip.description')" v-model =" newSecondaryIp" autoFocus ></a-input >
223+ <div class =" modal-form" >
224+ <p class =" modal-form__label" >{{ $t('label.publicip') }}:</p >
225+ <a-select
226+ showSearch
227+ v-if =" editNicResource.type==='Shared'"
228+ v-model =" newSecondaryIp"
229+ :loading =" listIps.loading" >
230+ <a-select-option v-for =" ip in listIps.opts" :key =" ip.ipaddress" >
231+ {{ ip.ipaddress }}
232+ </a-select-option >
233+ </a-select >
234+ <a-input
235+ v-else
236+ :placeholder =" $t('label.new.secondaryip.description')"
237+ v-model =" newSecondaryIp" ></a-input >
238+ </div >
239+
224240 <div style =" margin-top : 10px ; display : flex ; justify-content :flex-end ;" >
225- <a-button @click =" submitSecondaryIP" type =" primary" style =" margin-right : 10px ;" >{{ $t('label.add.secondary.ip') }}</a-button >
241+ <a-button :disabled = " listIps.opts.length === 0 " @click =" submitSecondaryIP" type =" primary" style =" margin-right : 10px ;" >{{ $t('label.add.secondary.ip') }}</a-button >
226242 <a-button @click =" closeModals" >{{ $t('label.close') }}</a-button >
227243 </div >
228244
@@ -298,6 +314,7 @@ export default {
298314 loadingNic: false ,
299315 editIpAddressNic: ' ' ,
300316 editIpAddressValue: ' ' ,
317+ editNetworkId: ' ' ,
301318 secondaryIPs: [],
302319 selectedNicId: ' ' ,
303320 newSecondaryIp: ' ' ,
@@ -444,6 +461,15 @@ export default {
444461 this .fetchPublicIps (record .nic .networkid )
445462 }
446463 },
464+ onAcquireSecondaryIPAddress (record ) {
465+ if (record .nic .type === ' Shared' ) {
466+ this .editNicResource = record .nic
467+ this .editNetworkId = record .nic .networkid
468+ this .fetchPublicIps (record .nic .networkid )
469+ }
470+
471+ this .fetchSecondaryIPs (record .nic .id )
472+ },
447473 submitAddNetwork () {
448474 const params = {}
449475 params .virtualmachineid = this .vm .id
@@ -613,6 +639,9 @@ export default {
613639 }).catch (error => {
614640 this .$notifyError (error)
615641 this .loadingNic = false
642+ }).finally (() => {
643+ this .newSecondaryIp = null
644+ this .fetchPublicIps (this .editNetworkId )
616645 })
617646 },
618647 removeSecondaryIP (id ) {
@@ -625,6 +654,7 @@ export default {
625654 successMethod : () => {
626655 this .loadingNic = false
627656 this .fetchSecondaryIPs (this .selectedNicId )
657+ this .fetchPublicIps (this .editNetworkId )
628658 this .parentFetchData ()
629659 },
630660 errorMessage: this .$t (' message.error.remove.secondary.ipaddress' ),
0 commit comments