cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessicaw...@apache.org
Subject [19/39] Format JS
Date Fri, 19 Jul 2013 17:01:32 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f766a9e5/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 89b9d6e..c2fca60 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -15,1134 +15,1318 @@
 // specific language governing permissions and limitations
 // under the License.
 
-(function($, cloudStack) { 
-
-  var zoneObjs, podObjs, clusterObjs, domainObjs, networkOfferingObjs, physicalNetworkObjs;
-  var selectedClusterObj, selectedZoneObj, selectedPublicNetworkObj, selectedManagementNetworkObj, selectedPhysicalNetworkObj, selectedGuestNetworkObj; 
-  var nspMap = {}; //from listNetworkServiceProviders API 
-	var nspHardcodingArray = []; //for service providers listView (hardcoding, not from listNetworkServiceProviders API) 
+(function($, cloudStack) {
+
+    var zoneObjs, podObjs, clusterObjs, domainObjs, networkOfferingObjs, physicalNetworkObjs;
+    var selectedClusterObj, selectedZoneObj, selectedPublicNetworkObj, selectedManagementNetworkObj, selectedPhysicalNetworkObj, selectedGuestNetworkObj;
+    var nspMap = {}; //from listNetworkServiceProviders API
+    var nspHardcodingArray = []; //for service providers listView (hardcoding, not from listNetworkServiceProviders API)
+
+    // Add router type to virtual router
+    // -- can be either Project, VPC, or System (standard)
+    var mapRouterType = function(index, router) {
+        var routerType = _l('label.menu.system');
+
+        if (router.projectid) routerType = _l('label.project');
+        if (router.vpcid) routerType = 'VPC';
+
+        return $.extend(router, {
+            routerType: routerType
+        });
+    };
+
+    cloudStack.publicIpRangeAccount = {
+        dialog: function(args) {
+            return function(args) {
+                var data = args.data ? args.data : {};
+                var fields = {
+                    account: {
+                        label: 'Account',
+                        defaultValue: data.account
+                    },
+                    domainid: {
+                        label: 'Domain',
+                        defaultValue: data.domainid,
+                        select: function(args) {
+                            $.ajax({
+                                url: createURL('listDomains'),
+                                data: {
+                                    listAll: true
+                                },
+                                success: function(json) {
+                                    args.response.success({
+                                        data: $.map(json.listdomainsresponse.domain, function(domain) {
+                                            return {
+                                                id: domain.id,
+                                                description: domain.path
+                                            };
+                                        })
+                                    });
+                                }
+                            });
+                        }
+                    }
+                };
+                var success = args.response.success;
 
-  // Add router type to virtual router
-  // -- can be either Project, VPC, or System (standard)
-  var mapRouterType = function(index, router) {
-    var routerType = _l('label.menu.system');
+                if (args.$item) { // Account data is read-only after creation
+                    $.ajax({
+                        url: createURL('listDomains'),
+                        data: {
+                            id: data.domainid,
+                            listAll: true
+                        },
+                        success: function(json) {
+                            var domain = json.listdomainsresponse.domain[0];
 
-    if (router.projectid) routerType = _l('label.project');
-    if (router.vpcid) routerType = 'VPC';
+                            cloudStack.dialog.notice({
+                                message: '<ul><li>' + _l('label.account') + ': ' + data.account + '</li>' + '<li>' + _l('label.domain') + ': ' + domain.path + '</li></ul>'
+                            });
+                        }
+                    });
+                } else {
+                    cloudStack.dialog.createForm({
+                        form: {
+                            title: 'label.add.account',
+                            desc: '(optional) Please specify an account to be associated with this IP range.',
+                            fields: fields
+                        },
+                        after: function(args) {
+                            var data = cloudStack.serializeForm(args.$form);
 
-    return $.extend(router, {
-      routerType: routerType
-    });
-  };
-	
-  cloudStack.publicIpRangeAccount = {
-    dialog: function(args) {      
-      return function(args) {
-        var data = args.data ? args.data : {};
-        var fields = {
-          account: { label: 'Account', defaultValue: data.account },
-          domainid: {
-            label: 'Domain',
-            defaultValue: data.domainid,
-            select: function(args) {
-              $.ajax({
-                url: createURL('listDomains'),
-                data: { listAll: true },
-                success: function(json) {
-                  args.response.success({
-                    data: $.map(json.listdomainsresponse.domain, function(domain) {
-                      return {
-                        id: domain.id,
-                        description: domain.path
-                      };
-                    })
-                  });
+                            success({
+                                data: data
+                            });
+                        }
+                    });
                 }
-              });
-            }
-          }
-        };
-        var success = args.response.success;
-        
-        if (args.$item) { // Account data is read-only after creation
-          $.ajax({
-            url: createURL('listDomains'),
-            data: { id: data.domainid, listAll: true },
+            };
+        }
+    };
+
+    var getTrafficType = function(physicalNetwork, typeID) {
+        var trafficType = {};
+
+        $.ajax({
+            url: createURL('listTrafficTypes'),
+            data: {
+                physicalnetworkid: physicalNetwork.id
+            },
+            async: false,
             success: function(json) {
-              var domain = json.listdomainsresponse.domain[0];
-              
-              cloudStack.dialog.notice({
-                message: '<ul><li>' + _l('label.account') + ': ' + data.account + '</li>' +
-                  '<li>' + _l('label.domain') + ': ' + domain.path + '</li></ul>'
-              });
+                trafficType = $.grep(
+                    json.listtraffictypesresponse.traffictype,
+                    function(trafficType) {
+                        return trafficType.traffictype == typeID;
+                    }
+                )[0];
             }
-          });
-        } else {
-          cloudStack.dialog.createForm({
-            form: {
-              title: 'label.add.account',
-              desc: '(optional) Please specify an account to be associated with this IP range.',
-              fields: fields
+        });
+
+        if (trafficType.xennetworklabel == null || trafficType.xennetworklabel == 0)
+            trafficType.xennetworklabel = dictionary['label.network.label.display.for.blank.value'];
+        if (trafficType.kvmnetworklabel == null || trafficType.kvmnetworklabel == 0)
+            trafficType.kvmnetworklabel = dictionary['label.network.label.display.for.blank.value'];
+        if (trafficType.vmwarenetworklabel == null || trafficType.vmwarenetworklabel == 0)
+            trafficType.vmwarenetworklabel = dictionary['label.network.label.display.for.blank.value'];
+        if (trafficType.ovmnetworklabel == null || trafficType.ovmnetworklabel == 0)
+            trafficType.ovmnetworklabel = dictionary['label.network.label.display.for.blank.value'];
+        if (trafficType.lxcnetworklabel == null || trafficType.lxcnetworklabel == 0)
+            trafficType.lxcnetworklabel = dictionary['label.network.label.display.for.blank.value'];
+
+        return trafficType;
+    };
+
+    var updateTrafficLabels = function(trafficType, labels, complete) {
+        var array1 = [];
+        if (labels.xennetworklabel != dictionary['label.network.label.display.for.blank.value'])
+            array1.push("&xennetworklabel=" + labels.xennetworklabel);
+        if (labels.kvmnetworklabel != dictionary['label.network.label.display.for.blank.value'])
+            array1.push("&kvmnetworklabel=" + labels.kvmnetworklabel);
+        if (labels.vmwarenetworklabel != dictionary['label.network.label.display.for.blank.value'])
+            array1.push("&vmwarenetworklabel=" + labels.vmwarenetworklabel);
+        if (labels.ovmnetworklabel != dictionary['label.network.label.display.for.blank.value'])
+            array1.push("&ovmnetworklabel=" + labels.ovmnetworklabel);
+        if (labels.lxcnetworklabel != dictionary['label.network.label.display.for.blank.value'])
+            array1.push("&lxcnetworklabel=" + labels.lxcnetworklabel);
+
+        $.ajax({
+            url: createURL('updateTrafficType' + array1.join("")),
+            data: {
+                id: trafficType.id
             },
-            after: function(args) {
-              var data = cloudStack.serializeForm(args.$form);
-              
-              success({ data: data });
+            success: function(json) {
+                var jobID = json.updatetraffictyperesponse.jobid;
+
+                cloudStack.ui.notifications.add({
+                        desc: 'Update traffic labels',
+                        poll: pollAsyncJobResult,
+                        section: 'System',
+                        _custom: {
+                            jobId: jobID
+                        }
+                    },
+                    complete ? complete : function() {}, {},
+                    function(data) {
+                        // Error
+                        cloudStack.dialog.notice({
+                            message: parseXMLHttpResponse(data)
+                        });
+                    }, {}
+                );
             }
-          });
-        }
-      };     
-    }
-  };
- 
-  var getTrafficType = function(physicalNetwork, typeID) {
-    var trafficType = {};
-
-    $.ajax({
-      url: createURL('listTrafficTypes'),
-      data: {
-        physicalnetworkid: physicalNetwork.id
-      },
-      async: false,
-      success: function(json) {
-        trafficType = $.grep(
-          json.listtraffictypesresponse.traffictype,
-          function(trafficType) {
-            return trafficType.traffictype == typeID;
-          }
-        )[0];
-      }
-    });
+        })
+    };
 
-    if(trafficType.xennetworklabel == null || trafficType.xennetworklabel == 0)
-      trafficType.xennetworklabel = dictionary['label.network.label.display.for.blank.value'];
-    if(trafficType.kvmnetworklabel == null || trafficType.kvmnetworklabel == 0)
-      trafficType.kvmnetworklabel = dictionary['label.network.label.display.for.blank.value'];
-    if(trafficType.vmwarenetworklabel == null || trafficType.vmwarenetworklabel == 0)
-      trafficType.vmwarenetworklabel = dictionary['label.network.label.display.for.blank.value'];
-    if(trafficType.ovmnetworklabel == null || trafficType.ovmnetworklabel == 0)
-      trafficType.ovmnetworklabel = dictionary['label.network.label.display.for.blank.value'];
-    if(trafficType.lxcnetworklabel == null || trafficType.lxcnetworklabel == 0)
-      trafficType.lxcnetworklabel = dictionary['label.network.label.display.for.blank.value'];
-
-    return trafficType;
-  };
-
-  var updateTrafficLabels = function(trafficType, labels, complete) {
-    var array1 = [];
-    if(labels.xennetworklabel != dictionary['label.network.label.display.for.blank.value'])
-      array1.push("&xennetworklabel=" + labels.xennetworklabel);
-    if(labels.kvmnetworklabel != dictionary['label.network.label.display.for.blank.value'])
-      array1.push("&kvmnetworklabel=" + labels.kvmnetworklabel);
-    if(labels.vmwarenetworklabel != dictionary['label.network.label.display.for.blank.value'])
-      array1.push("&vmwarenetworklabel=" + labels.vmwarenetworklabel);
-    if(labels.ovmnetworklabel != dictionary['label.network.label.display.for.blank.value'])
-      array1.push("&ovmnetworklabel=" + labels.ovmnetworklabel);
-    if(labels.lxcnetworklabel != dictionary['label.network.label.display.for.blank.value'])
-      array1.push("&lxcnetworklabel=" + labels.lxcnetworklabel);
-
-    $.ajax({
-      url: createURL('updateTrafficType' + array1.join("")),
-      data: {
-        id: trafficType.id       
-      },
-      success: function(json) {
-        var jobID = json.updatetraffictyperesponse.jobid;
-
-        cloudStack.ui.notifications.add(
-          {
-            desc: 'Update traffic labels',
-            poll: pollAsyncJobResult,
-            section: 'System',
-            _custom: { jobId: jobID }
-          },
-          complete ? complete : function() {}, {},
-          function(data) {
-            // Error
-            cloudStack.dialog.notice({ message: parseXMLHttpResponse(data) });
-          }, {}
-        );
-      }
-    })
-  };
-
-  function virtualRouterProviderActionFilter(args) { 	  
-    var allowedActions = [];    
-		var jsonObj = args.context.item; //args.context.item == nspMap["virtualRouter"]
-    if(jsonObj.state == "Enabled")
-      allowedActions.push("disable");
-    else if(jsonObj.state == "Disabled")
-      allowedActions.push("enable");
-    return allowedActions;
-  };
-
-  cloudStack.sections.system = {
-    title: 'label.menu.infrastructure',
-    id: 'system',
-
-    // System dashboard
-    dashboard: {
-      dataProvider: function(args) {
-        var dataFns = {
-          zoneCount: function(data) {              	  	
-            $.ajax({
-              url: createURL('listZones'),              
-              success: function(json) {
-                dataFns.podCount($.extend(data, {
-                  zoneCount: json.listzonesresponse.count ?
-                    json.listzonesresponse.count : 0,
-                  zones: json.listzonesresponse.zone
-                }));
-              }
-            });
-          },
+    function virtualRouterProviderActionFilter(args) {
+        var allowedActions = [];
+        var jsonObj = args.context.item; //args.context.item == nspMap["virtualRouter"]
+        if (jsonObj.state == "Enabled")
+            allowedActions.push("disable");
+        else if (jsonObj.state == "Disabled")
+            allowedActions.push("enable");
+        return allowedActions;
+    };
+
+    cloudStack.sections.system = {
+        title: 'label.menu.infrastructure',
+        id: 'system',
+
+        // System dashboard
+        dashboard: {
+            dataProvider: function(args) {
+                var dataFns = {
+                    zoneCount: function(data) {
+                        $.ajax({
+                            url: createURL('listZones'),
+                            success: function(json) {
+                                dataFns.podCount($.extend(data, {
+                                    zoneCount: json.listzonesresponse.count ? json.listzonesresponse.count : 0,
+                                    zones: json.listzonesresponse.zone
+                                }));
+                            }
+                        });
+                    },
 
-          podCount: function(data) {
-            $.ajax({
-              url: createURL('listPods'),
-							data: {
-							  page: 1,
-								pagesize: 1  //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
-							},
-              success: function(json) {
-                dataFns.clusterCount($.extend(data, {
-                  podCount: json.listpodsresponse.count ?
-                    json.listpodsresponse.count : 0
-                }));
-              }
-            });
-          },
+                    podCount: function(data) {
+                        $.ajax({
+                            url: createURL('listPods'),
+                            data: {
+                                page: 1,
+                                pagesize: 1 //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
+                            },
+                            success: function(json) {
+                                dataFns.clusterCount($.extend(data, {
+                                    podCount: json.listpodsresponse.count ? json.listpodsresponse.count : 0
+                                }));
+                            }
+                        });
+                    },
 
-          clusterCount: function(data) {
-            $.ajax({
-              url: createURL('listClusters'),
-							data: {
-							  page: 1,
-								pagesize: 1  //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
-							},
-              success: function(json) {                
-								dataFns.hostCount($.extend(data, {
-                  clusterCount: json.listclustersresponse.count ?
-                    json.listclustersresponse.count : 0
-                }));
-																
-								//comment the 4 lines above and uncomment the following 4 lines if listHosts API still responds slowly.
-								
-								/*
+                    clusterCount: function(data) {
+                        $.ajax({
+                            url: createURL('listClusters'),
+                            data: {
+                                page: 1,
+                                pagesize: 1 //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
+                            },
+                            success: function(json) {
+                                dataFns.hostCount($.extend(data, {
+                                    clusterCount: json.listclustersresponse.count ? json.listclustersresponse.count : 0
+                                }));
+
+                                //comment the 4 lines above and uncomment the following 4 lines if listHosts API still responds slowly.
+
+                                /*
 								dataFns.primaryStorageCount($.extend(data, {
                   clusterCount: json.listclustersresponse.count ?
                     json.listclustersresponse.count : 0
                 }));
 								*/
-              }
-            });
-          },
-
-          hostCount: function(data) {
-          	var data2= {
-              type: 'routing',
-							page: 1,
-							pagesize: 1  //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
-            };            
-            $.ajax({
-              url: createURL('listHosts'),
-              data: data2,
-              success: function(json) {
-                dataFns.primaryStorageCount($.extend(data, {
-                  hostCount: json.listhostsresponse.count ?
-                    json.listhostsresponse.count : 0
-                }));
-              }
-            });
-          },
+                            }
+                        });
+                    },
 
-          primaryStorageCount: function(data) {
-            var data2 = {
-              page: 1,
-              pagesize: 1  //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
-            };            
-            $.ajax({
-              url: createURL('listStoragePools'),
-	            data: data2,
-              success: function(json) {                
-		            dataFns.secondaryStorageCount($.extend(data, {
-                  primaryStorageCount: json.liststoragepoolsresponse.count ? json.liststoragepoolsresponse.count : 0
-                }));		
-              }
-            });
-          },
-
-          secondaryStorageCount: function(data) {
-            var data2 = {
-              type: 'SecondaryStorage',
-              page: 1,
-              pagesize: 1  //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
-            };            
-            $.ajax({
-              url: createURL('listImageStores'),
-              data: data2,
-              success: function(json) {
-                dataFns.systemVmCount($.extend(data, {
-                  secondaryStorageCount: json.listimagestoreresponse.imagestore ?
-                      json.listimagestoreresponse.count : 0
-                }));
-              }
-            });
-          },
+                    hostCount: function(data) {
+                        var data2 = {
+                            type: 'routing',
+                            page: 1,
+                            pagesize: 1 //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
+                        };
+                        $.ajax({
+                            url: createURL('listHosts'),
+                            data: data2,
+                            success: function(json) {
+                                dataFns.primaryStorageCount($.extend(data, {
+                                    hostCount: json.listhostsresponse.count ? json.listhostsresponse.count : 0
+                                }));
+                            }
+                        });
+                    },
 
-          systemVmCount: function(data) {
-            $.ajax({
-              url: createURL('listSystemVms'),
-							data: {
-							  page: 1,
-								pagesize: 1  //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
-							},
-              success: function(json) {
-                dataFns.virtualRouterCount($.extend(data, {
-                  systemVmCount: json.listsystemvmsresponse.count ?
-                    json.listsystemvmsresponse.count : 0
-                }));
-              }
-            });
-          },
-
-          virtualRouterCount: function(data) {
-            var data2 = {
-              projectid: -1,
-              page: 1,
-              pagesize: 1  //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
-            };            
-            $.ajax({
-              url: createURL('listRouters'),
-              data: data2,
-              success: function(json) {
-                var total1 = json.listroutersresponse.count ? json.listroutersresponse.count : 0;		
-                
-                var data3 = {
-                  listAll: true,
-                  page: 1,
-                  pagesize: 1  //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
-                };               
-								$.ajax({
-								  url: createURL('listRouters'),
-									data: data3,
-									success: function(json) {
-									  var total2 = json.listroutersresponse.count ? json.listroutersresponse.count : 0;		
-										dataFns.capacity($.extend(data, {
-											virtualRouterCount: (total1 + total2)
-										}));																	
-									}									
-								});										
-              }
-            });
-          },
+                    primaryStorageCount: function(data) {
+                        var data2 = {
+                            page: 1,
+                            pagesize: 1 //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
+                        };
+                        $.ajax({
+                            url: createURL('listStoragePools'),
+                            data: data2,
+                            success: function(json) {
+                                dataFns.secondaryStorageCount($.extend(data, {
+                                    primaryStorageCount: json.liststoragepoolsresponse.count ? json.liststoragepoolsresponse.count : 0
+                                }));
+                            }
+                        });
+                    },
 
-          capacity: function(data) {
-            if (data.zoneCount) {
-              $.ajax({
-                url: createURL('listCapacity'),
-                success: function(json) {
-                  var capacities = json.listcapacityresponse.capacity;
+                    secondaryStorageCount: function(data) {
+                        var data2 = {
+                            type: 'SecondaryStorage',
+                            page: 1,
+                            pagesize: 1 //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
+                        };
+                        $.ajax({
+                            url: createURL('listImageStores'),
+                            data: data2,
+                            success: function(json) {
+                                dataFns.systemVmCount($.extend(data, {
+                                    secondaryStorageCount: json.listimagestoreresponse.imagestore ? json.listimagestoreresponse.count : 0
+                                }));
+                            }
+                        });
+                    },
+
+                    systemVmCount: function(data) {
+                        $.ajax({
+                            url: createURL('listSystemVms'),
+                            data: {
+                                page: 1,
+                                pagesize: 1 //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
+                            },
+                            success: function(json) {
+                                dataFns.virtualRouterCount($.extend(data, {
+                                    systemVmCount: json.listsystemvmsresponse.count ? json.listsystemvmsresponse.count : 0
+                                }));
+                            }
+                        });
+                    },
+
+                    virtualRouterCount: function(data) {
+                        var data2 = {
+                            projectid: -1,
+                            page: 1,
+                            pagesize: 1 //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
+                        };
+                        $.ajax({
+                            url: createURL('listRouters'),
+                            data: data2,
+                            success: function(json) {
+                                var total1 = json.listroutersresponse.count ? json.listroutersresponse.count : 0;
+
+                                var data3 = {
+                                    listAll: true,
+                                    page: 1,
+                                    pagesize: 1 //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
+                                };
+                                $.ajax({
+                                    url: createURL('listRouters'),
+                                    data: data3,
+                                    success: function(json) {
+                                        var total2 = json.listroutersresponse.count ? json.listroutersresponse.count : 0;
+                                        dataFns.capacity($.extend(data, {
+                                            virtualRouterCount: (total1 + total2)
+                                        }));
+                                    }
+                                });
+                            }
+                        });
+                    },
+
+                    capacity: function(data) {
+                        if (data.zoneCount) {
+                            $.ajax({
+                                url: createURL('listCapacity'),
+                                success: function(json) {
+                                    var capacities = json.listcapacityresponse.capacity;
 
-                  var capacityTotal = function(id, converter) {
-                    var capacity = $.grep(capacities, function(capacity) {
-                      return capacity.type == id;
-                    })[0];
+                                    var capacityTotal = function(id, converter) {
+                                        var capacity = $.grep(capacities, function(capacity) {
+                                            return capacity.type == id;
+                                        })[0];
 
-                    var total = capacity ? capacity.capacitytotal : 0;
+                                        var total = capacity ? capacity.capacitytotal : 0;
+
+                                        if (converter) {
+                                            return converter(total);
+                                        }
+
+                                        return total;
+                                    };
 
-                    if (converter) {
-                      return converter(total);
+                                    complete($.extend(data, {
+                                        cpuCapacityTotal: capacityTotal(1, cloudStack.converters.convertHz),
+                                        memCapacityTotal: capacityTotal(0, cloudStack.converters.convertBytes),
+                                        storageCapacityTotal: capacityTotal(2, cloudStack.converters.convertBytes)
+                                    }));
+                                }
+                            });
+                        } else {
+                            complete($.extend(data, {
+                                cpuCapacityTotal: cloudStack.converters.convertHz(0),
+                                memCapacityTotal: cloudStack.converters.convertBytes(0),
+                                storageCapacityTotal: cloudStack.converters.convertBytes(0)
+                            }));
+                        }
                     }
+                };
 
-                    return total;
-                  };
+                var complete = function(data) {
+                    args.response.success({
+                        data: data
+                    });
+                };
 
-                  complete($.extend(data, {
-                    cpuCapacityTotal: capacityTotal(1, cloudStack.converters.convertHz),
-                    memCapacityTotal: capacityTotal(0, cloudStack.converters.convertBytes),
-                    storageCapacityTotal: capacityTotal(2, cloudStack.converters.convertBytes)
-                  }));
-                }
-              });
-            } else {
-              complete($.extend(data, {
-                cpuCapacityTotal: cloudStack.converters.convertHz(0),
-                memCapacityTotal: cloudStack.converters.convertBytes(0),
-                storageCapacityTotal: cloudStack.converters.convertBytes(0)
-              }));
+                dataFns.zoneCount({});
             }
-          }
-        };
-
-        var complete = function(data) {
-          args.response.success({
-            data: data
-          });
-        };
-       
-        dataFns.zoneCount({});  	
-      }
-    },
-
-    zoneDashboard: function(args) {
-      $.ajax({
-        url: createURL('listCapacity'),
-        data: { zoneid: args.context.zones[0].id },
-        success: function(json) {
-          var capacities = json.listcapacityresponse.capacity;
-          var data = {};
-
-          $(capacities).each(function() {
-            var capacity = this;
-
-            data[capacity.type] = {
-              used: cloudStack.converters.convertByType(capacity.type, capacity.capacityused),
-              total: cloudStack.converters.convertByType(capacity.type, capacity.capacitytotal),
-              percent: parseInt(capacity.percentused)
-            };
-          });
-
-          args.response.success({
-            data: data
-          });
-        }
-      });
-    },
-
-    // Network-as-a-service configuration
-    naas: {
-      providerListView: {
-        id: 'networkProviders',
-        fields: {
-          name: { label: 'label.name' },
-          state: {
-            label: 'label.state',
-            converter: function(str) {
-              // For localization
-              return str;
-            },
-            indicator: { 'Enabled': 'on', 'Disabled': 'off' }
-          }
-        },
-        dataProvider: function(args) {
-					refreshNspData();
-          args.response.success({
-            data: nspHardcodingArray
-          })
         },
 
-        detailView: function(args) {
-          return cloudStack.sections.system.naas.networkProviders.types[
-            args.context.networkProviders[0].id
-          ];
-        }
-      },
-      mainNetworks: {
-        'public': {
-          detailView: {
-            actions: {
-              edit: {
-                label: 'label.edit',
-                action: function(args) {
-                  var trafficType = getTrafficType(selectedPhysicalNetworkObj, 'Public');
-
-                  updateTrafficLabels(trafficType, args.data, function () {
-                    args.response.success();
-                  });
-                }
-              }
-            },
-            tabs: {
-              details: {
-                title: 'label.details',
-                fields: [
-                  {
-                    traffictype: { label: 'label.traffic.type' },
-                    broadcastdomaintype: { label: 'label.broadcast.domain.type' }
-                  },
-                  {
-                    xennetworklabel: { label: 'label.xen.traffic.label', isEditable: true },
-                    kvmnetworklabel: { label: 'label.kvm.traffic.label', isEditable: true },
-                    vmwarenetworklabel: { label: 'label.vmware.traffic.label', isEditable: true },
-                    ovmnetworklabel: { label: 'OVM traffic label',isEditable: true },
-                    lxcnetworklabel: { label: 'label.lxc.traffic.label',isEditable: true }
-                  }
-                ],
+        zoneDashboard: function(args) {
+            $.ajax({
+                url: createURL('listCapacity'),
+                data: {
+                    zoneid: args.context.zones[0].id
+                },
+                success: function(json) {
+                    var capacities = json.listcapacityresponse.capacity;
+                    var data = {};
 
-                dataProvider: function(args) {
-                  $.ajax({
-                    url: createURL("listNetworks&listAll=true&trafficType=Public&isSystem=true&zoneId="+selectedZoneObj.id),
-                    dataType: "json",
-                    async: false,
-                    success: function(json) {
-                      var trafficType = getTrafficType(selectedPhysicalNetworkObj, 'Public');
-                      var items = json.listnetworksresponse.network;
-
-                      selectedPublicNetworkObj = items[0];
-
-                      // Include traffic labels
-                      selectedPublicNetworkObj.xennetworklabel = trafficType.xennetworklabel;
-                      selectedPublicNetworkObj.kvmnetworklabel = trafficType.kvmnetworklabel;
-                      selectedPublicNetworkObj.vmwarenetworklabel = trafficType.vmwarenetworklabel;
-                      selectedPublicNetworkObj.ovmnetworklabel = trafficType.ovmnetworklabel;
-                      selectedPublicNetworkObj.lxcnetworklabel = trafficType.lxcnetworklabel;
-
-                      args.response.success({data: selectedPublicNetworkObj});
-                    }
-                  });
+                    $(capacities).each(function() {
+                        var capacity = this;
+
+                        data[capacity.type] = {
+                            used: cloudStack.converters.convertByType(capacity.type, capacity.capacityused),
+                            total: cloudStack.converters.convertByType(capacity.type, capacity.capacitytotal),
+                            percent: parseInt(capacity.percentused)
+                        };
+                    });
+
+                    args.response.success({
+                        data: data
+                    });
                 }
-              },
+            });
+        },
 
-              ipAddresses: {
-                title: 'label.ip.ranges',
-                custom: function(args) {
-                  return $('<div></div>').multiEdit({
-                    context: args.context,
-                    noSelect: true,
-                    fields: {
-                      'gateway': { edit: true, label: 'label.gateway' },
-                      'netmask': { edit: true, label: 'label.netmask' },
-                      'vlan': { edit: true, label: 'label.vlan', isOptional: true },
-                      'startip': { edit: true, label: 'label.start.IP' },
-                      'endip': { edit: true, label: 'label.end.IP' },
-                      'account': {
-                        label: 'label.account',
-                        custom: {
-                          buttonLabel: 'label.add.account',
-                          action: cloudStack.publicIpRangeAccount.dialog()
-                        }
-                      },
-                      'add-rule': { label: 'label.add', addButton: true }
+        // Network-as-a-service configuration
+        naas: {
+            providerListView: {
+                id: 'networkProviders',
+                fields: {
+                    name: {
+                        label: 'label.name'
                     },
-                    add: {
-                      label: 'label.add',
-                      action: function(args) {
-                        var array1 = [];
-                        array1.push("&zoneId=" + args.context.zones[0].id);
-
-                        if (args.data.vlan != null && args.data.vlan.length > 0)
-                          array1.push("&vlan=" + todb(args.data.vlan));
-                        else
-                          array1.push("&vlan=untagged");
-
-                        array1.push("&gateway=" + args.data.gateway);
-                        array1.push("&netmask=" + args.data.netmask);
-                        array1.push("&startip=" + args.data.startip);
-                        if(args.data.endip != null && args.data.endip.length > 0)
-                          array1.push("&endip=" + args.data.endip);
-
-                        if (args.data.account) {
-                          array1.push("&account=" + args.data.account.account);
-                          array1.push("&domainid=" + args.data.account.domainid);
+                    state: {
+                        label: 'label.state',
+                        converter: function(str) {
+                            // For localization
+                            return str;
+                        },
+                        indicator: {
+                            'Enabled': 'on',
+                            'Disabled': 'off'
                         }
+                    }
+                },
+                dataProvider: function(args) {
+                    refreshNspData();
+                    args.response.success({
+                        data: nspHardcodingArray
+                    })
+                },
 
-                        array1.push("&forVirtualNetwork=true");  //indicates this new IP range is for public network, not guest network
+                detailView: function(args) {
+                    return cloudStack.sections.system.naas.networkProviders.types[
+                        args.context.networkProviders[0].id
+                    ];
+                }
+            },
+            mainNetworks: {
+                'public': {
+                    detailView: {
+                        actions: {
+                            edit: {
+                                label: 'label.edit',
+                                action: function(args) {
+                                    var trafficType = getTrafficType(selectedPhysicalNetworkObj, 'Public');
 
-                        $.ajax({
-                          url: createURL("createVlanIpRange" + array1.join("")),
-                          dataType: "json",
-                          success: function(json) {
-                            var item = json.createvlaniprangeresponse.vlan;
-                            args.response.success({
-                              data: item,
-                              notification: {
-                                label: 'label.add.ip.range',
-                                poll: function(args) {
-                                  args.complete();
-                                }
-                              }
-                            });
-                          },
-                          error: function(XMLHttpResponse) {
-                            var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
-                            args.response.error(errorMsg);
-                          }
-                        });
-                      }
-                    },
-										actionPreFilter: function(args) {										  
-											var actionsToShow = ['destroy'];											
-											if(args.context.multiRule[0].domain == 'ROOT' && args.context.multiRule[0].account.account == 'system')  
-											  actionsToShow.push('addAccount');
-											else
-											  actionsToShow.push('releaseFromAccount');											
-											return actionsToShow;
-										},
-                    actions: {
-                      destroy: {
-                        label: 'label.remove.ip.range',
-                        action: function(args) {
-                          $.ajax({
-                            url: createURL('deleteVlanIpRange&id=' + args.context.multiRule[0].id),
-                            dataType: 'json',
-                            async: true,
-                            success: function(json) {
-                              args.response.success({
-                                notification: {
-                                  label: 'label.remove.ip.range',
-                                  poll: function(args) {
-                                    args.complete();
-                                  }
+                                    updateTrafficLabels(trafficType, args.data, function() {
+                                        args.response.success();
+                                    });
                                 }
-                              });
-                            },
-                            error: function(json) {
-                              args.response.error(parseXMLHttpResponse(json));
                             }
-                          });
-                        }
-                      },											
-											
-											releaseFromAccount: {
-                        label: 'Release from Account',
-                        action: function(args) {
-                          $.ajax({
-                            url: createURL('releasePublicIpRange'),
-                            data: {
-														  id: args.context.multiRule[0].id
-														},                            
-                            success: function(json) {
-                              args.response.success({
-                                notification: {
-                                  label: 'release from account',
-                                  poll: function(args) {
-                                    args.complete();
-                                  }
+                        },
+                        tabs: {
+                            details: {
+                                title: 'label.details',
+                                fields: [{
+                                    traffictype: {
+                                        label: 'label.traffic.type'
+                                    },
+                                    broadcastdomaintype: {
+                                        label: 'label.broadcast.domain.type'
+                                    }
+                                }, {
+                                    xennetworklabel: {
+                                        label: 'label.xen.traffic.label',
+                                        isEditable: true
+                                    },
+                                    kvmnetworklabel: {
+                                        label: 'label.kvm.traffic.label',
+                                        isEditable: true
+                                    },
+                                    vmwarenetworklabel: {
+                                        label: 'label.vmware.traffic.label',
+                                        isEditable: true
+                                    },
+                                    ovmnetworklabel: {
+                                        label: 'OVM traffic label',
+                                        isEditable: true
+                                    },
+                                    lxcnetworklabel: {
+                                        label: 'label.lxc.traffic.label',
+                                        isEditable: true
+                                    }
+                                }],
+
+                                dataProvider: function(args) {
+                                    $.ajax({
+                                        url: createURL("listNetworks&listAll=true&trafficType=Public&isSystem=true&zoneId=" + selectedZoneObj.id),
+                                        dataType: "json",
+                                        async: false,
+                                        success: function(json) {
+                                            var trafficType = getTrafficType(selectedPhysicalNetworkObj, 'Public');
+                                            var items = json.listnetworksresponse.network;
+
+                                            selectedPublicNetworkObj = items[0];
+
+                                            // Include traffic labels
+                                            selectedPublicNetworkObj.xennetworklabel = trafficType.xennetworklabel;
+                                            selectedPublicNetworkObj.kvmnetworklabel = trafficType.kvmnetworklabel;
+                                            selectedPublicNetworkObj.vmwarenetworklabel = trafficType.vmwarenetworklabel;
+                                            selectedPublicNetworkObj.ovmnetworklabel = trafficType.ovmnetworklabel;
+                                            selectedPublicNetworkObj.lxcnetworklabel = trafficType.lxcnetworklabel;
+
+                                            args.response.success({
+                                                data: selectedPublicNetworkObj
+                                            });
+                                        }
+                                    });
                                 }
-                              });
                             },
-                            error: function(json) {
-                              args.response.error(parseXMLHttpResponse(json));
-                            }
-                          });
-                        }
-                      },
-											
-											addAccount: {
-											  label: 'Add Account',												
-												createForm: {
-													title: 'Add Account',
-													fields: {
-														account: { label: 'Account' },
-														domainid: {
-															label: 'Domain',															
-															select: function(args) {
-																$.ajax({
-																	url: createURL('listDomains'),
-																	data: { listAll: true },
-																	success: function(json) {
-																		args.response.success({
-																			data: $.map(json.listdomainsresponse.domain, function(domain) {
-																				return {
-																					id: domain.id,
-																					description: domain.path
-																				};
-																			})
-																		});
-																	}
-																});
-															}
-														}
-													}
-												},												
-												action: function(args) {                          							
-												  var data = {
-														id: args.context.multiRule[0].id,
-														zoneid: args.context.multiRule[0].zoneid,
-														domainid: args.data.domainid,
-														account: args.data.account
-													};												
-                          $.ajax({
-                            url: createURL('dedicatePublicIpRange'),
-                            data: data,                        
-                            success: function(json) {
-                              args.response.success({
-                                notification: {
-                                  label: 'Add Account',
-                                  poll: function(args) {
-                                    args.complete();
-                                  }
+
+                            ipAddresses: {
+                                title: 'label.ip.ranges',
+                                custom: function(args) {
+                                    return $('<div></div>').multiEdit({
+                                        context: args.context,
+                                        noSelect: true,
+                                        fields: {
+                                            'gateway': {
+                                                edit: true,
+                                                label: 'label.gateway'
+                                            },
+                                            'netmask': {
+                                                edit: true,
+                                                label: 'label.netmask'
+                                            },
+                                            'vlan': {
+                                                edit: true,
+                                                label: 'label.vlan',
+                                                isOptional: true
+                                            },
+                                            'startip': {
+                                                edit: true,
+                                                label: 'label.start.IP'
+                                            },
+                                            'endip': {
+                                                edit: true,
+                                                label: 'label.end.IP'
+                                            },
+                                            'account': {
+                                                label: 'label.account',
+                                                custom: {
+                                                    buttonLabel: 'label.add.account',
+                                                    action: cloudStack.publicIpRangeAccount.dialog()
+                                                }
+                                            },
+                                            'add-rule': {
+                                                label: 'label.add',
+                                                addButton: true
+                                            }
+                                        },
+                                        add: {
+                                            label: 'label.add',
+                                            action: function(args) {
+                                                var array1 = [];
+                                                array1.push("&zoneId=" + args.context.zones[0].id);
+
+                                                if (args.data.vlan != null && args.data.vlan.length > 0)
+                                                    array1.push("&vlan=" + todb(args.data.vlan));
+                                                else
+                                                    array1.push("&vlan=untagged");
+
+                                                array1.push("&gateway=" + args.data.gateway);
+                                                array1.push("&netmask=" + args.data.netmask);
+                                                array1.push("&startip=" + args.data.startip);
+                                                if (args.data.endip != null && args.data.endip.length > 0)
+                                                    array1.push("&endip=" + args.data.endip);
+
+                                                if (args.data.account) {
+                                                    array1.push("&account=" + args.data.account.account);
+                                                    array1.push("&domainid=" + args.data.account.domainid);
+                                                }
+
+                                                array1.push("&forVirtualNetwork=true"); //indicates this new IP range is for public network, not guest network
+
+                                                $.ajax({
+                                                    url: createURL("createVlanIpRange" + array1.join("")),
+                                                    dataType: "json",
+                                                    success: function(json) {
+                                                        var item = json.createvlaniprangeresponse.vlan;
+                                                        args.response.success({
+                                                            data: item,
+                                                            notification: {
+                                                                label: 'label.add.ip.range',
+                                                                poll: function(args) {
+                                                                    args.complete();
+                                                                }
+                                                            }
+                                                        });
+                                                    },
+                                                    error: function(XMLHttpResponse) {
+                                                        var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                        args.response.error(errorMsg);
+                                                    }
+                                                });
+                                            }
+                                        },
+                                        actionPreFilter: function(args) {
+                                            var actionsToShow = ['destroy'];
+                                            if (args.context.multiRule[0].domain == 'ROOT' && args.context.multiRule[0].account.account == 'system')
+                                                actionsToShow.push('addAccount');
+                                            else
+                                                actionsToShow.push('releaseFromAccount');
+                                            return actionsToShow;
+                                        },
+                                        actions: {
+                                            destroy: {
+                                                label: 'label.remove.ip.range',
+                                                action: function(args) {
+                                                    $.ajax({
+                                                        url: createURL('deleteVlanIpRange&id=' + args.context.multiRule[0].id),
+                                                        dataType: 'json',
+                                                        async: true,
+                                                        success: function(json) {
+                                                            args.response.success({
+                                                                notification: {
+                                                                    label: 'label.remove.ip.range',
+                                                                    poll: function(args) {
+                                                                        args.complete();
+                                                                    }
+                                                                }
+                                                            });
+                                                        },
+                                                        error: function(json) {
+                                                            args.response.error(parseXMLHttpResponse(json));
+                                                        }
+                                                    });
+                                                }
+                                            },
+
+                                            releaseFromAccount: {
+                                                label: 'Release from Account',
+                                                action: function(args) {
+                                                    $.ajax({
+                                                        url: createURL('releasePublicIpRange'),
+                                                        data: {
+                                                            id: args.context.multiRule[0].id
+                                                        },
+                                                        success: function(json) {
+                                                            args.response.success({
+                                                                notification: {
+                                                                    label: 'release from account',
+                                                                    poll: function(args) {
+                                                                        args.complete();
+                                                                    }
+                                                                }
+                                                            });
+                                                        },
+                                                        error: function(json) {
+                                                            args.response.error(parseXMLHttpResponse(json));
+                                                        }
+                                                    });
+                                                }
+                                            },
+
+                                            addAccount: {
+                                                label: 'Add Account',
+                                                createForm: {
+                                                    title: 'Add Account',
+                                                    fields: {
+                                                        account: {
+                                                            label: 'Account'
+                                                        },
+                                                        domainid: {
+                                                            label: 'Domain',
+                                                            select: function(args) {
+                                                                $.ajax({
+                                                                    url: createURL('listDomains'),
+                                                                    data: {
+                                                                        listAll: true
+                                                                    },
+                                                                    success: function(json) {
+                                                                        args.response.success({
+                                                                            data: $.map(json.listdomainsresponse.domain, function(domain) {
+                                                                                return {
+                                                                                    id: domain.id,
+                                                                                    description: domain.path
+                                                                                };
+                                                                            })
+                                                                        });
+                                                                    }
+                                                                });
+                                                            }
+                                                        }
+                                                    }
+                                                },
+                                                action: function(args) {
+                                                    var data = {
+                                                        id: args.context.multiRule[0].id,
+                                                        zoneid: args.context.multiRule[0].zoneid,
+                                                        domainid: args.data.domainid,
+                                                        account: args.data.account
+                                                    };
+                                                    $.ajax({
+                                                        url: createURL('dedicatePublicIpRange'),
+                                                        data: data,
+                                                        success: function(json) {
+                                                            args.response.success({
+                                                                notification: {
+                                                                    label: 'Add Account',
+                                                                    poll: function(args) {
+                                                                        args.complete();
+                                                                    }
+                                                                }
+                                                            });
+                                                        },
+                                                        error: function(json) {
+                                                            args.response.error(parseXMLHttpResponse(json));
+                                                        }
+                                                    });
+                                                }
+                                            }
+
+                                        },
+                                        dataProvider: function(args) {
+                                            $.ajax({
+                                                url: createURL("listVlanIpRanges&zoneid=" + args.context.zones[0].id + "&networkId=" + selectedPublicNetworkObj.id),
+                                                dataType: "json",
+                                                success: function(json) {
+                                                    var items = json.listvlaniprangesresponse.vlaniprange;
+
+                                                    args.response.success({
+                                                        data: $.map(items, function(item) {
+                                                            return $.extend(item, {
+                                                                account: {
+                                                                    _buttonLabel: item.account,
+                                                                    account: item.account,
+                                                                    domainid: item.domainid
+                                                                }
+                                                            });
+                                                        })
+                                                    });
+                                                }
+                                            });
+                                        }
+                                    });
                                 }
-                              });
-                            },
-                            error: function(json) {
-                              args.response.error(parseXMLHttpResponse(json));
                             }
-                          });
-                        }
-											}	
-                      										
-                    },
-                    dataProvider: function(args) {
-                      $.ajax({
-                        url: createURL("listVlanIpRanges&zoneid=" + args.context.zones[0].id + "&networkId=" + selectedPublicNetworkObj.id),
-                        dataType: "json",
-                        success: function(json) {
-                          var items = json.listvlaniprangesresponse.vlaniprange;
-
-                          args.response.success({
-                            data: $.map(items, function(item) {
-                              return $.extend(item, {
-                                account: {
-                                  _buttonLabel: item.account,
-                                  account: item.account,
-                                  domainid: item.domainid
-                                }
-                              });
-                            })
-                          });
                         }
-                      });
-                    }
-                  });
-                }
-              }
-            }
-          }
-        },
-
-        'storage': {
-          detailView: {
-            actions: {
-              edit: {
-                label: 'label.edit',
-                action: function(args) {
-                  var trafficType = getTrafficType(selectedPhysicalNetworkObj, 'Storage');
-
-                  updateTrafficLabels(trafficType, args.data, function () {
-                    args.response.success();
-                  });
-                }
-              }
-            },
-            tabs: {
-              details: {
-                title: 'label.details',
-                fields: [
-                  {
-                    traffictype: { label: 'label.traffic.type' },
-                    broadcastdomaintype: { label: 'label.broadcast.domain.type' }
-                  },
-                  {
-                    xennetworklabel: { label: 'label.xen.traffic.label', isEditable: true },
-                    kvmnetworklabel: { label: 'label.kvm.traffic.label', isEditable: true },
-                    vmwarenetworklabel: { label: 'label.vmware.traffic.label', isEditable: true },
-                    ovmnetworklabel: { label: 'OVM traffic label', isEditable: true },
-                    lxcnetworklabel: { label: 'label.lxc.traffic.label', isEditable: true }
-                  }
-                ],
-
-                dataProvider: function(args) {
-                  $.ajax({
-                    url: createURL("listNetworks&listAll=true&trafficType=Storage&isSystem=true&zoneId="+selectedZoneObj.id),
-                    dataType: "json",
-                    async: false,
-                    success: function(json) {
-                      var items = json.listnetworksresponse.network;
-                      var trafficType = getTrafficType(selectedPhysicalNetworkObj, 'Storage');
-                      selectedPublicNetworkObj = items[0];
-
-                      selectedPublicNetworkObj.xennetworklabel = trafficType.xennetworklabel;
-                      selectedPublicNetworkObj.kvmnetworklabel = trafficType.kvmnetworklabel;
-                      selectedPublicNetworkObj.vmwarenetworklabel = trafficType.vmwarenetworklabel;
-                      selectedPublicNetworkObj.ovmnetworklabel = trafficType.ovmnetworklabel;
-
-                      args.response.success({data: selectedPublicNetworkObj});
                     }
-                  });
-                }
-              },
-
-              ipAddresses: {
-                title: 'label.ip.ranges',
-                custom: function(args) {
-                  return $('<div></div>').multiEdit({
-                    context: args.context,
-                    noSelect: true,
-                    fields: {
-											'podid': {
-											  label: 'label.pod',
-												select: function(args) {
-												  $.ajax({
-													  url: createURL("listPods&zoneid=" + selectedZoneObj.id),
-														dataType: "json",
-														success: function(json) {
-															var items = [];
-															var pods = json.listpodsresponse.pod;
-															$(pods).each(function(){
-															  items.push({name: this.id, description: this.name}); //should be "{id: this.id, description: this.name}" (to be consistent with dropdown in createFrom and edit mode) (Brian will fix widget later)
-															});
-															args.response.success({	data: items });
-														}
-													});
-												}
-											},
-                      'gateway': { edit: true, label: 'label.gateway' },
-                      'netmask': { edit: true, label: 'label.netmask' },
-                      'vlan': { edit: true, label: 'label.vlan', isOptional: true },
-                      'startip': { edit: true, label: 'label.start.IP' },
-                      'endip': { edit: true, label: 'label.end.IP' },
-                      'add-rule': { label: 'label.add', addButton: true }
-                    },
-                    add: {
-                      label: 'label.add',
-                      action: function(args) {
-                        var array1 = [];
-                        array1.push("&zoneId=" + args.context.zones[0].id);
-												array1.push("&podid=" + args.data.podid);
+                },
 
-												array1.push("&gateway=" + args.data.gateway);
+                'storage': {
+                    detailView: {
+                        actions: {
+                            edit: {
+                                label: 'label.edit',
+                                action: function(args) {
+                                    var trafficType = getTrafficType(selectedPhysicalNetworkObj, 'Storage');
 
-                        if (args.data.vlan != null && args.data.vlan.length > 0)
-                          array1.push("&vlan=" + todb(args.data.vlan));
+                                    updateTrafficLabels(trafficType, args.data, function() {
+                                        args.response.success();
+                                    });
+                                }
+                            }
+                        },
+                        tabs: {
+                            details: {
+                                title: 'label.details',
+                                fields: [{
+                                    traffictype: {
+                                        label: 'label.traffic.type'
+                                    },
+                                    broadcastdomaintype: {
+                                        label: 'label.broadcast.domain.type'
+                                    }
+                                }, {
+                                    xennetworklabel: {
+                                        label: 'label.xen.traffic.label',
+                                        isEditable: true
+                                    },
+                                    kvmnetworklabel: {
+                                        label: 'label.kvm.traffic.label',
+                                        isEditable: true
+                                    },
+                                    vmwarenetworklabel: {
+                                        label: 'label.vmware.traffic.label',
+                                        isEditable: true
+                                    },
+                                    ovmnetworklabel: {
+                                        label: 'OVM traffic label',
+                                        isEditable: true
+                                    },
+                                    lxcnetworklabel: {
+                                        label: 'label.lxc.traffic.label',
+                                        isEditable: true
+                                    }
+                                }],
 
-                        array1.push("&netmask=" + args.data.netmask);
-                        array1.push("&startip=" + args.data.startip);
-                        if(args.data.endip != null && args.data.endip.length > 0)
-                          array1.push("&endip=" + args.data.endip);
+                                dataProvider: function(args) {
+                                    $.ajax({
+                                        url: createURL("listNetworks&listAll=true&trafficType=Storage&isSystem=true&zoneId=" + selectedZoneObj.id),
+                                        dataType: "json",
+                                        async: false,
+                                        success: function(json) {
+                                            var items = json.listnetworksresponse.network;
+                                            var trafficType = getTrafficType(selectedPhysicalNetworkObj, 'Storage');
+                                            selectedPublicNetworkObj = items[0];
+
+                                            selectedPublicNetworkObj.xennetworklabel = trafficType.xennetworklabel;
+                                            selectedPublicNetworkObj.kvmnetworklabel = trafficType.kvmnetworklabel;
+                                            selectedPublicNetworkObj.vmwarenetworklabel = trafficType.vmwarenetworklabel;
+                                            selectedPublicNetworkObj.ovmnetworklabel = trafficType.ovmnetworklabel;
+
+                                            args.response.success({
+                                                data: selectedPublicNetworkObj
+                                            });
+                                        }
+                                    });
+                                }
+                            },
 
-                        $.ajax({
-                          url: createURL("createStorageNetworkIpRange" + array1.join("")),
-                          dataType: "json",
-                          success: function(json) {
-														args.response.success({
-															_custom: {
-																jobId: json.createstoragenetworkiprangeresponse.jobid
-															},
-															notification: {
-																label: 'label.add.ip.range',
-																poll: pollAsyncJobResult
-															}
-														});
-                          },
-                          error: function(XMLHttpResponse) {
-                            var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
-                            args.response.error(errorMsg);
-                          }
-                        });
-                      }
-                    },
-                    actions: {
-                      destroy: {
-                        label: 'label.delete',
-                        action: function(args) {
-                          $.ajax({
-                            url: createURL('deleteStorageNetworkIpRange&id=' + args.context.multiRule[0].id),
-                            dataType: 'json',
-                            async: true,
-                            success: function(json) {
-                              args.response.success({
-                                notification: {
-                                  label: 'label.remove.ip.range',
-                                  poll: function(args) {
-                                    args.complete();
-                                  }
+                            ipAddresses: {
+                                title: 'label.ip.ranges',
+                                custom: function(args) {
+                                    return $('<div></div>').multiEdit({
+                                        context: args.context,
+                                        noSelect: true,
+                                        fields: {
+                                            'podid': {
+                                                label: 'label.pod',
+                                                select: function(args) {
+                                                    $.ajax({
+                                                        url: createURL("listPods&zoneid=" + selectedZoneObj.id),
+                                                        dataType: "json",
+                                                        success: function(json) {
+                                                            var items = [];
+                                                            var pods = json.listpodsresponse.pod;
+                                                            $(pods).each(function() {
+                                                                items.push({
+                                                                    name: this.id,
+                                                                    description: this.name
+                                                                }); //should be "{id: this.id, description: this.name}" (to be consistent with dropdown in createFrom and edit mode) (Brian will fix widget later)
+                                                            });
+                                                            args.response.success({
+                                                                data: items
+                                                            });
+                                                        }
+                                                    });
+                                                }
+                                            },
+                                            'gateway': {
+                                                edit: true,
+                                                label: 'label.gateway'
+                                            },
+                                            'netmask': {
+                                                edit: true,
+                                                label: 'label.netmask'
+                                            },
+                                            'vlan': {
+                                                edit: true,
+                                                label: 'label.vlan',
+                                                isOptional: true
+                                            },
+                                            'startip': {
+                                                edit: true,
+                                                label: 'label.start.IP'
+                                            },
+                                            'endip': {
+                                                edit: true,
+                                                label: 'label.end.IP'
+                                            },
+                                            'add-rule': {
+                                                label: 'label.add',
+                                                addButton: true
+                                            }
+                                        },
+                                        add: {
+                                            label: 'label.add',
+                                            action: function(args) {
+                                                var array1 = [];
+                                                array1.push("&zoneId=" + args.context.zones[0].id);
+                                                array1.push("&podid=" + args.data.podid);
+
+                                                array1.push("&gateway=" + args.data.gateway);
+
+                                                if (args.data.vlan != null && args.data.vlan.length > 0)
+                                                    array1.push("&vlan=" + todb(args.data.vlan));
+
+                                                array1.push("&netmask=" + args.data.netmask);
+                                                array1.push("&startip=" + args.data.startip);
+                                                if (args.data.endip != null && args.data.endip.length > 0)
+                                                    array1.push("&endip=" + args.data.endip);
+
+                                                $.ajax({
+                                                    url: createURL("createStorageNetworkIpRange" + array1.join("")),
+                                                    dataType: "json",
+                                                    success: function(json) {
+                                                        args.response.success({
+                                                            _custom: {
+                                                                jobId: json.createstoragenetworkiprangeresponse.jobid
+                                                            },
+                                                            notification: {
+                                                                label: 'label.add.ip.range',
+                                                                poll: pollAsyncJobResult
+                                                            }
+                                                        });
+                                                    },
+                                                    error: function(XMLHttpResponse) {
+                                                        var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
+                                                        args.response.error(errorMsg);
+                                                    }
+                                                });
+                                            }
+                                        },
+                                        actions: {
+                                            destroy: {
+                                                label: 'label.delete',
+                                                action: function(args) {
+                                                    $.ajax({
+                                                        url: createURL('deleteStorageNetworkIpRange&id=' + args.context.multiRule[0].id),
+                                                        dataType: 'json',
+                                                        async: true,
+                                                        success: function(json) {
+                                                            args.response.success({
+                                                                notification: {
+                                                                    label: 'label.remove.ip.range',
+                                                                    poll: function(args) {
+                                                                        args.complete();
+                                                                    }
+                                                                }
+                                                            });
+                                                        }
+                                                    });
+                                                }
+                                            }
+                                        },
+                                        dataProvider: function(args) {
+                                            $.ajax({
+                                                url: createURL("listStorageNetworkIpRange&zoneid=" + args.context.zones[0].id + "&networkId=" + selectedPublicNetworkObj.id),
+                                                dataType: "json",
+                                                success: function(json) {
+                                                    var items = json.liststoragenetworkiprangeresponse.storagenetworkiprange;
+                                                    args.response.success({
+                                                        data: items
+                                                    });
+                                                }
+                                            });
+                                        }
+                                    });
                                 }
-                              });
                             }
-                          });
-                        }
-                      }
-                    },
-                    dataProvider: function(args) {
-                      $.ajax({
-                        url: createURL("listStorageNetworkIpRange&zoneid=" + args.context.zones[0].id + "&networkId=" + selectedPublicNetworkObj.id),
-                        dataType: "json",
-                        success: function(json) {
-                          var items = json.liststoragenetworkiprangeresponse.storagenetworkiprange;
-                          args.response.success({data: items});
                         }
-                      });
                     }
-                  });
-                }
-              }
-            }
-          }
-        },
+                },
 
-        'management': {
-          detailView: {
-            actions: {
-              edit: {
-                label: 'label.edit',
-                action: function(args) {
-                  var trafficType = getTrafficType(selectedPhysicalNetworkObj, 'Management');
-
-                  updateTrafficLabels(trafficType, args.data, function () {
-                    args.response.success();
-                  });
-                }
-              }
-            },
-            tabs: {
-              details: {
-                title: 'label.details',
-                fields: [
-                  {
-                    traffictype: { label: 'label.traffic.type' },
-                    broadcastdomaintype: { label: 'label.broadcast.domain.type' }
-                  },
-                  {
-                    xennetworklabel: { label: 'label.xen.traffic.label', isEditable: true },
-                    kvmnetworklabel: { label: 'label.kvm.traffic.label', isEditable: tr

<TRUNCATED>

Mime
View raw message