rafaelweingartner commented on a change in pull request #2456: 
[CLOUDSTACK-10293] Single view network ACL rules listing
URL: https://github.com/apache/cloudstack/pull/2456#discussion_r169043024
 
 

 ##########
 File path: ui/scripts/vpc.js
 ##########
 @@ -1333,35 +1321,65 @@
                                             $.ajax({
                                                 url: 
createURL('listNetworkACLs&aclid=' + args.context.aclLists[0].id),
                                                 success: function(json) {
-                                                    var items = 
json.listnetworkaclsresponse.networkacl.sort(function(a, b) {
-                                                        return a.number >= 
b.number;
-                                                    }).map(function(acl) {
-                                                        if 
(parseInt(acl.protocol)) { // protocol number
-                                                            acl.protocolnumber 
= acl.protocol;
-                                                            acl.protocol = 
"protocolnumber";
-                                                        }
-
-                                                        return acl;
-                                                    });
+                                                    var items = 
json.listnetworkaclsresponse.networkacl;
+
+                                                    if(items){
+                                                        items.sort(function(a, 
b) {
+                                                            return a.number >= 
b.number;
+                                                        }).map(function(acl) {
+                                                            if 
(parseInt(acl.protocol)) { // protocol number
+                                                                
acl.protocolnumber = acl.protocol;
+                                                                acl.protocol = 
"protocolnumber";
+                                                            }
+    
+                                                            return acl;
+                                                        });
+                                                    }
 
                                                     args.response.success({
                                                         data: items
-                                                        /* {
-                               cidrlist: '10.1.1.0/24',
-                               protocol: 'TCP',
-                               startport: 22, endport: 22,
-                               networkid: 0,
-                               traffictype: 'Egress'
-                               },
-                               {
-                               cidrlist: '10.2.1.0/24',
-                               protocol: 'UDP',
-                               startport: 56, endport: 72,
-                               networkid: 0,
-                               trafficType: 'Ingress'
-                               }
-                               ]*/
                                                     });
+                                                    
if(jQuery('#details-tab-aclRules').siblings('div.toolbar').children('div.add').size()
 === 0){
+                                                        var 
$addAclRuleDivButton = jQuery('<div>').addClass('button add');
+                                                        var 
$spanAddAclRuleButtonMessage = jQuery('<span>').html(_l('label.add.ACL'));
+                                                        
+                                                        
$addAclRuleDivButton.html($spanAddAclRuleButtonMessage);
+                                                        
$addAclRuleDivButton.click(function(){
+                                                               
cloudStack.dialog.createForm({
+                                                                        form: {
+                                                                     title: 
'label.add.rule',
+                                                                     desc: 
'Create a new ACL rule',
+                                                                     fields: 
aclRuleFields
+                                                                 },
+                                                                 after: 
function(argsLocal) {
+                                                                        var 
data = argsLocal.data;
+                                                                        
data.aclid = argsLocal.context.aclLists[0].id;
+                                                                        
if(data.protocol != 'icmp'){
+                                                                               
 data.icmpcode = undefined;
+                                                                               
 data.icmptype  = undefined;
+                                                                        }
+                                                                        
if(data.protocol != 'protocolnumber'){
+                                                                               
 data.protocolnumber = undefined;
+                                                                        }
+                                                                        
if(data.protocol === 'all'){
 
 Review comment:
   Yes, and they are in fact already performed there. The point is that if some 
of these combinations are sent to the server side, such as ICMP codes and TCP 
protocol, the server side will throw an exception. That is why I am cleaning up 
undesired information here (based on the protocol selected).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to