Skip to content

Commit

Permalink
VNF/UI: display the default passwords in notification area
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache committed Oct 16, 2023
1 parent f11a978 commit 21c2e30
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
3 changes: 3 additions & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,7 @@
"label.parentname": "Parent",
"label.passive": "Passive",
"label.password": "Password",
"label.password.default": "Default Password",
"label.password.reset.confirm": "Password has been reset to ",
"label.passwordenabled": "Password enabled",
"label.path": "Path",
Expand Down Expand Up @@ -3161,6 +3162,8 @@
"message.vm.state.stopping": "VM is being stopped.",
"message.vm.state.unknown": "VM state is unknown.",
"message.vnf.appliance.networks": "Please select networks for the new VNF appliance.",
"message.vnf.credentials.change": "Please change the password(s) of the VNF appliance immediately.",
"message.vnf.credentials.default": "The default credentials(s) of the VNF appliance",
"message.vnf.credentials.in.template.vnf.details": "Please find the default credentials for this VNF in the details of the VNF template.",
"message.vnf.error.deviceid.should.be.continuous": "The deviceid of selected VNF nics should be continuous.",
"message.vnf.error.network.is.already.used": "Network has been used by multiple nics of the new VNF appliance.",
Expand Down
6 changes: 3 additions & 3 deletions ui/src/components/view/DetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,19 @@ export default {
credentials.push(this.$t('label.username') + ' : ' + username)
}
if (password) {
credentials.push(this.$t('label.password') + ' : ' + password)
credentials.push(this.$t('label.password.default') + ' : ' + password)
}
if (webUsername) {
credentials.push('Web ' + this.$t('label.username') + ' : ' + webUsername)
}
if (webPassword) {
credentials.push('Web ' + this.$t('label.password') + ' : ' + webPassword)
credentials.push('Web ' + this.$t('label.password.default') + ' : ' + webPassword)
}
if (sshUsername) {
credentials.push('SSH ' + this.$t('label.username') + ' : ' + sshUsername)
}
if (sshPassword) {
credentials.push('SSH ' + this.$t('label.password') + ' : ' + sshPassword)
credentials.push('SSH ' + this.$t('label.password.default') + ' : ' + sshPassword)
}
const managementDeviceIds = []
Expand Down
52 changes: 34 additions & 18 deletions ui/src/views/compute/DeployVnfAppliance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,7 @@
</template>

<script>
import { ref, reactive, toRaw, nextTick, h } from 'vue'
import { Button } from 'ant-design-vue'
import { ref, reactive, toRaw, nextTick } from 'vue'
import { api } from '@/api'
import _ from 'lodash'
import { mixin, mixinDevice } from '@/utils/mixin.js'
Expand Down Expand Up @@ -2236,9 +2235,8 @@ export default {
createVnfAppData.bootintosetup = values.bootintosetup
}
const title = this.$t('label.launch.vm')
const title = this.$t('label.launch.vnf.appliance')
const description = values.name || ''
const password = this.$t('label.password')
createVnfAppData = Object.fromEntries(
Object.entries(createVnfAppData).filter(([key, value]) => value !== undefined))
Expand Down Expand Up @@ -2271,22 +2269,40 @@ export default {
successMethod: result => {
const vm = result.jobresult.virtualmachine
const name = vm.displayname || vm.name || vm.id
const username = vm.vnfdetails?.username || null
const password = vm.vnfdetails?.password || null
const sshUsername = vm.vnfdetails?.ssh_user || null
const sshPassword = vm.vnfdetails?.ssh_password || null
const webUsername = vm.vnfdetails?.web_user || null
const webPassword = vm.vnfdetails?.web_password || null
const credentials = []
if (username) {
credentials.push(this.$t('label.username') + ' : ' + username)
}
if (password) {
credentials.push(this.$t('label.password.default') + ' : ' + password)
}
if (webUsername) {
credentials.push('Web ' + this.$t('label.username') + ' : ' + webUsername)
}
if (webPassword) {
credentials.push('Web ' + this.$t('label.password.default') + ' : ' + webPassword)
}
if (sshUsername) {
credentials.push('SSH ' + this.$t('label.username') + ' : ' + sshUsername)
}
if (sshPassword) {
credentials.push('SSH ' + this.$t('label.password.default') + ' : ' + sshPassword)
}
if (vm.password) {
this.$notification.success({
message: password + ` ${this.$t('label.for')} ` + name,
description: vm.password,
btn: () => h(
Button,
{
type: 'primary',
size: 'small',
onClick: () => this.copyToClipboard(vm.password)
},
() => [this.$t('label.copy.password')]
),
duration: 0
})
credentials.push('New password : ' + vm.password)
}
credentials.push(this.$t('message.vnf.credentials.change'))
this.$notification.success({
message: `${this.$t('message.vnf.credentials.default')} ` + name,
description: (<span v-html={credentials.join('<br>')}></span>),
duration: 0
})
eventBus.emit('vm-refresh-data')
},
loadingMessage: `${title} ${this.$t('label.in.progress')}`,
Expand Down

0 comments on commit 21c2e30

Please sign in to comment.