diff --git a/ui/src/views/network/AclListRulesTab.vue b/ui/src/views/network/AclListRulesTab.vue index 909d4f28feb..8219b0160bc 100644 --- a/ui/src/views/network/AclListRulesTab.vue +++ b/ui/src/views/network/AclListRulesTab.vue @@ -46,7 +46,7 @@
-
{{ $t('label.number') }}
+
{{ $t('label.rule.number') }}
{{ acl.number }}
@@ -136,7 +136,7 @@ - + @@ -167,12 +167,12 @@
-
+
- + - +
@@ -396,7 +396,7 @@ export default { setTimeout(() => { this.ruleForm.setFieldsValue({ number: acl.number, - cidr: acl.cidrlist, + cidrlist: acl.cidrlist, action: acl.action, protocol: acl.protocol, startport: acl.startport, @@ -406,6 +406,32 @@ export default { }) }, 200) }, + getDataFromForm (values) { + const data = { + cidrlist: values.cidrlist || '', + number: values.number || '', + protocol: values.protocol || '', + traffictype: values.traffictype || '', + action: values.action || '', + reason: values.reason || '' + } + + if (values.protocol === 'tcp' || values.protocol === 'udp' || values.protocol === 'protocolnumber') { + data.startport = values.startport || '' + data.endport = values.endport || '' + } + + if (values.protocol === 'icmp') { + data.icmptype = values.icmptype || -1 + data.icmpcode = values.icmpcode || -1 + } + + if (values.protocol === 'protocolnumber') { + data.protocol = values.protocolnumber + } + + return data + }, handleEditRule (e) { e.preventDefault() this.ruleForm.validateFields((err, values) => { @@ -413,18 +439,12 @@ export default { this.fetchLoading = true this.ruleModalVisible = false - api('updateNetworkACLItem', {}, 'POST', { - id: this.selectedAcl.id, - cidrlist: values.cidr, - number: values.number, - protocol: values.protocol, - traffictype: values.traffictype, - action: values.action, - reason: values.reason, - startport: values.startport, - endport: values.endport, - partialupgrade: false - }).then(response => { + + const data = this.getDataFromForm(values) + data.id = this.selectedAcl.id + data.partialupgrade = false + + api('updateNetworkACLItem', {}, 'POST', data).then(response => { this.$store.dispatch('AddAsyncJob', { title: this.$t('label.edit.acl.rule'), jobid: response.createnetworkaclresponse.jobid, @@ -515,29 +535,8 @@ export default { this.fetchLoading = true this.ruleModalVisible = false - const data = { - aclid: this.resource.id, - cidrlist: values.cidr || '', - number: values.number || '', - protocol: values.protocol || '', - traffictype: values.traffictype || '', - action: values.action || '', - reason: values.reason || '' - } - - if (values.protocol === 'tcp' || values.protocol === 'udp' || values.protocol === 'protocolnumber') { - data.startport = values.startport || '' - data.endport = values.endport || '' - } - - if (values.protocol === 'icmp') { - data.icmptype = values.icmptype || -1 - data.icmpcode = values.icmpcode || -1 - } - - if (values.protocol === 'protocolnumber') { - data.protocol = values.protocolnumber - } + const data = this.getDataFromForm(values) + data.aclid = this.resource.id api('createNetworkACL', {}, 'POST', data).then(() => { this.$notification.success({