Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: make a newly added Network the default one #9708

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,7 @@
"label.maintenance": "Maintenance",
"label.majorsequence": "Major Sequence",
"label.make": "Make",
"label.make.default": "Make default",
"label.make.project.owner": "Make Account project owner",
"label.make.user.project.owner": "Make User project owner",
"label.makeredundant": "Make redundant",
Expand Down
32 changes: 30 additions & 2 deletions ui/src/views/network/NicsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
</a-select>
<p class="modal-form__label">{{ $t('label.publicip') }}:</p>
<a-input v-model:value="addNetworkData.ip"></a-input>
<br>
<a-checkbox v-model:checked="addNetworkData.makedefault">
{{ $t('label.make.default') }}
</a-checkbox>
<br>
</div>

<div :span="24" class="action-button">
Expand Down Expand Up @@ -248,13 +253,15 @@ export default {
data () {
return {
vm: {},
nic: {},
showAddNetworkModal: false,
showUpdateIpModal: false,
showSecondaryIpModal: false,
addNetworkData: {
allNetworks: [],
network: '',
ip: ''
ip: '',
makedefault: false
},
loadingNic: false,
editIpAddressNic: '',
Expand Down Expand Up @@ -332,6 +339,7 @@ export default {
this.showSecondaryIpModal = false
this.addNetworkData.network = ''
this.addNetworkData.ip = ''
this.addNetworkData.makedefault = false
this.editIpAddressValue = ''
this.newSecondaryIp = ''
},
Expand Down Expand Up @@ -368,7 +376,19 @@ export default {
this.$pollJob({
jobId: response.addnictovirtualmachineresponse.jobid,
successMessage: this.$t('message.success.add.network'),
successMethod: () => {
successMethod: async () => {
if (this.addNetworkData.makedefault) {
try {
this.nic = await this.getNic(params.networkid, params.virtualmachineid)
if (this.nic) {
this.setAsDefault(this.nic)
} else {
this.$notifyError('NIC data not found.')
}
} catch (error) {
this.$notifyError('Failed to fetch NIC data.')
}
}
this.loadingNic = false
this.closeModals()
},
Expand All @@ -390,6 +410,14 @@ export default {
this.loadingNic = false
})
},
getNic (networkid, virtualmachineid) {
const params = {}
params.virtualmachineid = virtualmachineid
params.networkid = networkid
return api('listNics', params).then(response => {
return response.listnicsresponse.nic[0]
})
},
setAsDefault (item) {
this.loadingNic = true
api('updateDefaultNicForVirtualMachine', {
Expand Down
Loading