sureshanaparti commented on a change in pull request #5812:
URL: https://github.com/apache/cloudstack/pull/5812#discussion_r777873680
##########
File path: ui/src/views/infra/HostAdd.vue
##########
@@ -309,66 +398,54 @@ export default {
},
handleSubmitForm () {
if (this.loading) return
- const requiredFields = document.querySelectorAll('.required-field')
+ this.form.validateFieldsAndScroll((err, values) => {
+ if (err) return
- requiredFields.forEach(field => {
- const input = field.querySelector('.ant-input')
- if (!input.value) {
-
input.parentNode.querySelector('.required-label').classList.add('required-label--error')
+ if (values.hostname.indexOf('http://') === -1) {
+ this.url = `http://${values.hostname}`
} else {
-
input.parentNode.querySelector('.required-label').classList.remove('required-label--error')
+ this.url = values.hostname
}
- })
-
- if (this.$el.querySelectorAll('.required-label--error').length > 0)
return
-
- if (this.selectedClusterHyperVisorType === 'VMware') {
- this.username = ''
- this.password = ''
- }
-
- if (this.hostname.indexOf('http://') === -1) {
- this.url = `http://${this.hostname}`
- } else {
- this.url = this.hostname
- }
-
- if (this.authMethod !== 'password') {
- this.password = ''
- }
-
- const args = {
- zoneid: this.zoneId,
- podid: this.podId,
- clusterid: this.clusterId,
- hypervisor: this.selectedClusterHyperVisorType,
- clustertype: this.selectedCluster.clustertype,
- hosttags: this.selectedTags.join(),
- username: this.username,
- password: this.password,
- url: this.url,
- agentusername: this.agentusername,
- agentpassword: this.agentpassword,
- agentport: this.agentport
- }
- Object.keys(args).forEach((key) => (args[key] == null) && delete
args[key])
- this.loading = true
- api('addHost', {}, 'POST', args).then(response => {
- const host = response.addhostresponse.host[0] || {}
- if (host.id && this.showDedicated) {
- this.dedicateHost(host.id)
+ const args = {
+ zoneid: values.zoneid,
+ podid: values.podid,
+ clusterid: values.clusterid,
+ hypervisor: this.selectedClusterHyperVisorType,
+ clustertype: this.selectedCluster.clustertype,
+ hosttags: values.hosttags ? values.hosttags.join() : null,
+ username: values.username,
+ password: this.authMethod !== 'password' ? '' : values.password,
+ url: this.url,
+ agentusername: values.agentusername,
+ agentpassword: values.agentpassword,
+ agentport: values.agentport
}
- this.parentFetchData()
- this.$parent.$parent.close()
- }).catch(error => {
- this.$notification.error({
- message: `${this.$t('label.error')} ${error.response.status}`,
- description: error.response.data.addhostresponse.errortext,
- duration: 0
- })
- }).finally(() => {
- this.loading = false
+ if (this.selectedClusterHyperVisorType === 'BareMetal') {
+ args.cpunumber = values.baremetalcpucores
+ args.cpuspeed = values.baremetalcpu
+ args.memory = values.baremetalmemory
+ args.hostmac = values.baremetalmac
+ }
+ Object.keys(args).forEach((key) => (args[key] == null) && delete
args[key])
+ this.loading = true
+ console.log(args)
+ // api('addHost', {}, 'POST', args).then(response => {
Review comment:
@utchoang can you remove the code in comments pls
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]