Change 'Nodes Learnt' to 'Nodes Learned'
[controller.git] / opendaylight / web / devices / src / main / resources / js / page.js
index cf4d234d17d2f97967984be87b4e9805a5aea84e..37016860a790df5e02e1674178b318937544cc0c 100644 (file)
@@ -14,7 +14,7 @@ one.f = {};
 one.f.dashlet = {
     nodesLearnt : {
         id : 'nodesLearnt',
-        name : 'Nodes Learnt'
+        name : 'Nodes Learned'
     },
     staticRouteConfig : {
         id : 'staticRouteConfig',
@@ -74,6 +74,7 @@ one.f.switchmanager.nodesLearnt = {
         },
         modal: {
             modal: "one_f_switchmanager_nodesLearnt_id_modal_modal",
+            configure: "one_f_switchmanager_nodesLearnt_id_modal_configure",
             ports: "one_f_switchmanager_nodesLearnt_id_modal_ports",
             save: "one_f_switchmanager_nodesLearnt_id_modal_save",
             datagrid: "one_f_switchmanager_nodesLearnt_id_modal_datagrid",
@@ -137,7 +138,7 @@ one.f.switchmanager.nodesLearnt = {
                         h3 = 'Node Information';
                     }
                     
-                    var $modal = one.lib.modal.spawn(one.f.switchmanager.nodesLearnt.id.modal.modal, h3, "", footer);
+                    var $modal = one.lib.modal.spawn(one.f.switchmanager.nodesLearnt.id.modal.configure, h3, "", footer);
                     // bind save button
                     $('#' + one.f.switchmanager.nodesLearnt.id.modal.save, $modal).click(function() {
                         one.f.switchmanager.nodesLearnt.modal.save($modal);
@@ -149,7 +150,7 @@ one.f.switchmanager.nodesLearnt = {
                 });
             },
             popout: function() {
-                var h3 = "Nodes Learnt";
+                var h3 = "Nodes Learned";
                 var footer = one.f.switchmanager.nodesLearnt.modal.footer.popout();
                 var $modal = one.lib.modal.spawn(one.f.switchmanager.nodesLearnt.id.modal.modal, h3, "", footer);
                 var $body = one.f.switchmanager.nodesLearnt.modal.body.popout($modal);
@@ -350,7 +351,7 @@ one.f.switchmanager.nodesLearnt = {
                         },
                         {
                             property: 'mac',
-                            label: 'Mac',
+                            label: 'MAC',
                             sortable: true
                         },
                         {
@@ -448,7 +449,8 @@ one.f.switchmanager.subnetGatewayConfig = {
             addIPAddress: "one_f_switchmanager_subnetGatewayConfig_id_dashlet_addIP",
             addPorts: "one_f_switchmanager_subnetGatewayConfig_id_dashlet_addPorts",
             removeIPAddress: "one_f_switchmanager_subnetGatewayConfig_id_dashlet_removeIP",
-            datagrid: "one_f_switchmanager_subnetGatewayConfig_id_dashlet_datagrid"
+            datagrid: "one_f_switchmanager_subnetGatewayConfig_id_dashlet_datagrid",
+            selectAll: "one_f_switchmanager_subnetGatewayConfig_id_dashlet_selectAll"
         }, 
         modal: {
             modal: "one_f_switchmanager_subnetGatewayConfig_id_modal_modal",
@@ -495,11 +497,12 @@ one.f.switchmanager.subnetGatewayConfig = {
                         var url = one.f.switchmanager.rootUrl + "/subnetGateway/delete";
                         one.f.switchmanager.subnetGatewayConfig.ajax.main(url, requestData, function(response) {
                             if (response.status == true) {
-                                // refresh dashlet by passing dashlet div as param
-                                one.f.switchmanager.subnetGatewayConfig.dashlet($("#right-bottom .dashlet"));
+                                // refresh dashlet by passing dashlet div as param 
+                                one.lib.alert("Subnet Gateway(s) successfully removed");
                             } else {
-                                alert(response.message);
+                                one.lib.alert(response.message);
                             }
+                            one.f.switchmanager.subnetGatewayConfig.dashlet($("#right-bottom .dashlet"));
                         });
                     }
                 });
@@ -523,7 +526,25 @@ one.f.switchmanager.subnetGatewayConfig = {
                 }, "table-striped table-condensed");
             $dashlet.append($gridHTML);
             var dataSource = one.f.switchmanager.subnetGatewayConfig.data.devicesgrid(content);
-            $("#" + one.f.switchmanager.subnetGatewayConfig.id.dashlet.datagrid).datagrid({dataSource: dataSource});
+            $("#" + one.f.switchmanager.subnetGatewayConfig.id.dashlet.datagrid).datagrid({dataSource: dataSource})
+            .on("loaded", function() {
+                $("#"+one.f.switchmanager.subnetGatewayConfig.id.dashlet.selectAll).click(function() {
+                    $("#" + one.f.switchmanager.subnetGatewayConfig.id.dashlet.datagrid).find(':checkbox').prop('checked',
+                        $("#"+one.f.switchmanager.subnetGatewayConfig.id.dashlet.selectAll).is(':checked'));
+                });
+                $(".subnetGatewayConfig").click(function(){
+                    if (!$('.subnetGatewayConfig[type=checkbox]:not(:checked)').length) {
+                        $("#"+one.f.switchmanager.subnetGatewayConfig.id.dashlet.selectAll)
+                            .prop("checked",
+                          true);
+                    } else {
+                        $("#"+one.f.switchmanager.subnetGatewayConfig.id.dashlet.selectAll)
+                            .prop("checked",
+                         false);
+                    }
+                    event.stopPropagation();
+                });
+             });
         });
     },
     ajax : {
@@ -699,7 +720,8 @@ one.f.switchmanager.subnetGatewayConfig = {
                     columns: [
                         {
                             property: 'selector',
-                            label: ' ',
+                            label: "<input type='checkbox'  id='"
+                                +one.f.switchmanager.subnetGatewayConfig.id.dashlet.selectAll+"'/>",
                             sortable: false
                         },
                         {
@@ -713,7 +735,7 @@ one.f.switchmanager.subnetGatewayConfig = {
                             sortable: true
                         },
                         {
-                            property: 'json',
+                            property: 'nodePorts',
                             label: 'Node/Ports',
                             sortable: false
                         }
@@ -721,20 +743,22 @@ one.f.switchmanager.subnetGatewayConfig = {
                     data: data.nodeData,
                     formatter: function(items) {
                         $.each(items, function(index, tableRow) {
-                            tableRow["selector"] = '<input type="checkbox" id=' + tableRow["name"] + '></input>';
-                            var json = tableRow["json"];
-                            var subnetConfigObject = JSON.parse(json);
+                            tableRow["selector"] = '<input type="checkbox" class="subnetGatewayConfig" id=' 
+                                + tableRow["name"] + '></input>';
+                            var json = tableRow["nodePorts"];
+                            var nodePorts = JSON.parse(json);
                             var nodePortHtml = "<div>";
-                            $.each(subnetConfigObject.nodePorts, function(index, nodePort) {
-                                nodePortHtml += nodePort;
+                            $.each(nodePorts, function(index, nodePort) {
+                                var nodePortID = nodePort["nodeId"] + "/" + nodePort["nodePortId"]; 
+                                nodePortHtml += nodePort["nodeName"] + " / " + nodePort["nodePortName"];
                                 nodePortHtml += "&nbsp;";
-                                nodePortHtml += '<a href="#" id=' + encodeURIComponent(nodePort) + 
+                                nodePortHtml += '<a href="#" id=' + encodeURIComponent(nodePortID) + 
                                     ' gatewayName=' + tableRow["name"] + 
                                     ' onclick="javascript:one.f.switchmanager.subnetGatewayConfig.actions.deleteNodePort(this);">Delete</a>';
                                 nodePortHtml += "<br/>";
                             });
                             nodePortHtml += "</div>";
-                            tableRow["json"] = nodePortHtml;
+                            tableRow["nodePorts"] = nodePortHtml;
                         });
 
                     },
@@ -829,7 +853,8 @@ one.f.switchmanager.staticRouteConfig = {
         dashlet: {
             add: "one_f_switchmanager_staticRouteConfig_id_dashlet_add",
             remove: "one_f_switchmanager_staticRouteConfig_id_dashlet_remove",
-            datagrid: "one_f_switchmanager_staticRouteConfig_id_dashlet_datagrid"
+            datagrid: "one_f_switchmanager_staticRouteConfig_id_dashlet_datagrid",
+            selectAll: "one_f_switchmanager_staticRouteConfig_id_dashlet_selectAll"
         }, 
         modal: {
             modal: "one_f_switchmanager_staticRouteConfig_id_modal_modal",
@@ -873,11 +898,12 @@ one.f.switchmanager.staticRouteConfig = {
                         var url = one.f.switchmanager.rootUrl + "/staticRoute/delete";
                         one.f.switchmanager.staticRouteConfig.ajax.main(url, requestData, function(response) {
                             if (response.status == true) {
-                                // refresh dashlet by passing dashlet div as param
-                                one.f.switchmanager.staticRouteConfig.dashlet($("#left-bottom .dashlet"));
+                                // refresh dashlet by passing dashlet div as param 
+                                one.lib.alert("Static Routes(s) successfully removed");
                             } else {
-                                alert(response.message);
+                                one.lib.alert(response.message);
                             }
+                            one.f.switchmanager.staticRouteConfig.dashlet($("#left-bottom .dashlet"));
                         });
                     }
                 });
@@ -891,7 +917,25 @@ one.f.switchmanager.staticRouteConfig = {
                 }, "table-striped table-condensed");
             $dashlet.append($gridHTML);
             var dataSource = one.f.switchmanager.staticRouteConfig.data.staticRouteConfigGrid(content);
-            $("#" + one.f.switchmanager.staticRouteConfig.id.dashlet.datagrid).datagrid({dataSource: dataSource});
+            $("#" + one.f.switchmanager.staticRouteConfig.id.dashlet.datagrid).datagrid({dataSource: dataSource})
+            .on("loaded", function() {
+                $("#"+one.f.switchmanager.staticRouteConfig.id.dashlet.selectAll).click(function() {
+                    $("#" + one.f.switchmanager.staticRouteConfig.id.dashlet.datagrid).find(':checkbox').prop('checked',
+                        $("#"+one.f.switchmanager.staticRouteConfig.id.dashlet.selectAll).is(':checked'));
+                });
+                $(".staticRoute").click(function(){
+                    if (!$('.staticRoute[type=checkbox]:not(:checked)').length) {
+                        $("#"+one.f.switchmanager.staticRouteConfig.id.dashlet.selectAll)
+                            .prop("checked",
+                          true);
+                    } else {
+                        $("#"+one.f.switchmanager.staticRouteConfig.id.dashlet.selectAll)
+                            .prop("checked",
+                         false);
+                    }
+                    event.stopPropagation();
+                });
+             });
         });
     },
     // device ajax calls
@@ -979,7 +1023,8 @@ one.f.switchmanager.staticRouteConfig = {
                     columns: [
                         {
                             property: 'selector',
-                            label: ' ',
+                            label: "<input type='checkbox'  id='"
+                                +one.f.switchmanager.staticRouteConfig.id.dashlet.selectAll+"'/>",
                             sortable: false
                         },
                         {
@@ -1001,7 +1046,7 @@ one.f.switchmanager.staticRouteConfig = {
                     data: data.nodeData,
                     formatter: function(items) {
                         $.each(items, function(index, item) {
-                            item["selector"] = '<input type="checkbox" id=' + item["name"] + '></input>';
+                            item["selector"] = '<input type="checkbox" class="staticRoute" id=' + item["name"] + '></input>';
                         });
 
                     },
@@ -1035,7 +1080,8 @@ one.f.switchmanager.spanPortConfig = {
         dashlet: {
             add: "one_f_switchmanager_spanPortConfig_id_dashlet_add",
             remove: "one_f_switchmanager_spanPortConfig_id_dashlet_remove",
-            datagrid: "one_f_switchmanager_spanPortConfig_id_dashlet_datagrid"
+            datagrid: "one_f_switchmanager_spanPortConfig_id_dashlet_datagrid",
+            selectAllFlows: "one_f_switchmanager_spanPortConfig_id_dashlet_selectAllFlows"
         }, 
         modal: {
             modal: "one_f_switchmanager_spanPortConfig_id_modal_modal",
@@ -1085,10 +1131,11 @@ one.f.switchmanager.spanPortConfig = {
                         one.f.switchmanager.spanPortConfig.ajax.main(url, requestData, function(response) {
                             if (response.status == true) {
                                 // refresh dashlet by passing dashlet div as param
-                                one.f.switchmanager.spanPortConfig.dashlet($("#right-bottom .dashlet"));
+                                one.lib.alert("Span Port(s) successfully removed");
                             } else {
-                                alert(response.message);
+                                one.lib.alert(response.message);
                             }
+                            one.f.switchmanager.spanPortConfig.dashlet($("#right-bottom .dashlet"));
                         });
                     }
                 });
@@ -1102,10 +1149,25 @@ one.f.switchmanager.spanPortConfig = {
                 }, "table-striped table-condensed");
             $dashlet.append($gridHTML);
             var dataSource = one.f.switchmanager.spanPortConfig.data.spanPortConfigGrid(content);
-            $("#" + one.f.switchmanager.spanPortConfig.id.dashlet.datagrid).datagrid({dataSource: dataSource});
-
-
-
+            $("#" + one.f.switchmanager.spanPortConfig.id.dashlet.datagrid).datagrid({dataSource: dataSource})
+            .on("loaded", function() {
+                $("#"+one.f.switchmanager.spanPortConfig.id.dashlet.selectAll).click(function() {
+                    $("#" + one.f.switchmanager.spanPortConfig.id.dashlet.datagrid).find(':checkbox').prop('checked',
+                        $("#"+one.f.switchmanager.spanPortConfig.id.dashlet.selectAll).is(':checked'));
+                });
+                $(".spanPortConfig").click(function(){
+                    if (!$('.spanPortConfig[type=checkbox]:not(:checked)').length) {
+                        $("#"+one.f.switchmanager.spanPortConfig.id.dashlet.selectAll)
+                            .prop("checked",
+                          true);
+                    } else {
+                        $("#"+one.f.switchmanager.spanPortConfig.id.dashlet.selectAll)
+                            .prop("checked",
+                         false);
+                    }
+                    event.stopPropagation();
+                });
+             });
         });
     },
     // device ajax calls
@@ -1160,11 +1222,11 @@ one.f.switchmanager.spanPortConfig = {
             // bind onchange
             $select.change(function() {
                 // retrieve port value
-                var node = $(this).find('option:selected').attr('value');
-                one.f.switchmanager.spanPortConfig.registry['currentNode'] = node;
+                var nodeId = $(this).find('option:selected').attr('value');
+                one.f.switchmanager.spanPortConfig.registry['currentNode'] = nodeId;
                 var $ports = $('#' + one.f.switchmanager.spanPortConfig.id.modal.form.port);
-                var ports = nodeports[node];
-                one.lib.form.select.inject($ports, ports);
+                var ports = one.f.switchmanager.spanPortConfig.registry['nodePorts'][nodeId]
+                one.lib.form.select.inject($ports, ports); 
             });
 
             $fieldset.append($label).append($select);
@@ -1181,10 +1243,14 @@ one.f.switchmanager.spanPortConfig = {
         ajax: {
             nodes: function(callback) {
                 $.getJSON(one.f.switchmanager.rootUrl + "/nodeports", function(data) {
-                    var nodes = one.f.switchmanager.spanPortConfig.modal.data.nodes(data);
-                    var nodeports = data;
-                    one.f.switchmanager.spanPortConfig.registry['nodeports'] = nodeports;
-                    callback(nodes, nodeports);
+                    var nodes = {};
+                    var nodePorts = {};
+                    $(data).each(function(index, node) {
+                        nodes[node.nodeId] = node.nodeName;
+                        nodePorts[node.nodeId] = node.nodePorts;
+                    });
+                    one.f.switchmanager.spanPortConfig.registry['nodePorts'] = nodePorts;
+                    callback(nodes, nodePorts);
                 });
             },
             saveSpanPortConfig: function(requestData, callback) {
@@ -1195,15 +1261,6 @@ one.f.switchmanager.spanPortConfig = {
                 });
             }
         },
-        data : {
-            nodes : function(data) {
-                result = {};
-                $.each(data, function(key, value) {
-                    result[key] = key;
-                });
-                return result;
-            }
-        },
         footer : function() {
             var footer = [];
             var saveButton = one.lib.dashlet.button.single("Save", one.f.switchmanager.spanPortConfig.id.modal.save, "btn-success", "");
@@ -1219,7 +1276,8 @@ one.f.switchmanager.spanPortConfig = {
                     columns: [
                         {
                             property: 'selector',
-                            label: ' ',
+                            label: "<input type='checkbox'  id='"
+                                +one.f.switchmanager.spanPortConfig.id.dashlet.selectAll+"'/>",
                             sortable: false
                         },
                         {
@@ -1236,7 +1294,7 @@ one.f.switchmanager.spanPortConfig = {
                     data: data.nodeData,
                     formatter: function(items) {
                         $.each(items, function(index, item) {
-                            item["selector"] = '<input type="checkbox" spanPort=' + encodeURIComponent(item["json"]) + '></input>';
+                            item["selector"] = '<input type="checkbox" class="spanPortConfig" spanPort=' + encodeURIComponent(item["json"]) + '></input>';
                         });
                     },
                     delay: 0