106106 </a-select >
107107 <p class =" modal-form__label" >{{ $t('label.publicip') }}:</p >
108108 <a-input v-model:value =" addNetworkData.ip" ></a-input >
109+ <br >
110+ <a-checkbox v-model:checked =" addNetworkData.makedefault" >
111+ {{ $t('label.make.default') }}
112+ </a-checkbox >
113+ <br >
109114 </div >
110115
111116 <div :span =" 24" class =" action-button" >
@@ -248,13 +253,15 @@ export default {
248253 data () {
249254 return {
250255 vm: {},
256+ nic: {},
251257 showAddNetworkModal: false ,
252258 showUpdateIpModal: false ,
253259 showSecondaryIpModal: false ,
254260 addNetworkData: {
255261 allNetworks: [],
256262 network: ' ' ,
257- ip: ' '
263+ ip: ' ' ,
264+ makedefault: false
258265 },
259266 loadingNic: false ,
260267 editIpAddressNic: ' ' ,
@@ -332,6 +339,7 @@ export default {
332339 this .showSecondaryIpModal = false
333340 this .addNetworkData .network = ' '
334341 this .addNetworkData .ip = ' '
342+ this .addNetworkData .makedefault = false
335343 this .editIpAddressValue = ' '
336344 this .newSecondaryIp = ' '
337345 },
@@ -368,7 +376,19 @@ export default {
368376 this .$pollJob ({
369377 jobId: response .addnictovirtualmachineresponse .jobid ,
370378 successMessage: this .$t (' message.success.add.network' ),
371- successMethod : () => {
379+ successMethod: async () => {
380+ if (this .addNetworkData .makedefault ) {
381+ try {
382+ this .nic = await this .getNic (params .networkid , params .virtualmachineid )
383+ if (this .nic ) {
384+ this .setAsDefault (this .nic )
385+ } else {
386+ this .$notifyError (' NIC data not found.' )
387+ }
388+ } catch (error) {
389+ this .$notifyError (' Failed to fetch NIC data.' )
390+ }
391+ }
372392 this .loadingNic = false
373393 this .closeModals ()
374394 },
@@ -390,6 +410,14 @@ export default {
390410 this .loadingNic = false
391411 })
392412 },
413+ getNic (networkid , virtualmachineid ) {
414+ const params = {}
415+ params .virtualmachineid = virtualmachineid
416+ params .networkid = networkid
417+ return api (' listNics' , params).then (response => {
418+ return response .listnicsresponse .nic [0 ]
419+ })
420+ },
393421 setAsDefault (item ) {
394422 this .loadingNic = true
395423 api (' updateDefaultNicForVirtualMachine' , {
0 commit comments