Fix to show Node name if present when adding ports to Subnet Gateway on the devices... 08/1008/2
authorlakshya <lakshya@cisco.com>
Mon, 26 Aug 2013 18:44:50 +0000 (11:44 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 26 Aug 2013 20:50:23 +0000 (20:50 +0000)
A minor change from Mac to MAC in nodes learnt popout.

Change-Id: I600a8437d757b72bdaf8f0e5d8ffa624a08c4d2b
Signed-off-by: lakshya <lakshya@cisco.com>
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/SubnetGatewayPortBean.java [new file with mode: 0644]
opendaylight/web/devices/src/main/resources/js/page.js

index 781242a969b0a0f5964a7223672e1b08a74f60fb..f6704775029d178233795e6afb075a4b1030892f 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.devices.web;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -145,7 +146,6 @@ public class Devices implements IDaylightWeb {
                         State portState = ((State) switchManager
                                 .getNodeConnectorProp(nodeConnector,
                                         State.StatePropName));
-
                         String nodeConnectorName = (ncName != null) ? ncName
                                 .getValue() : "";
                         nodeConnectorName += " (" + nodeConnector.getID() + ")";
@@ -416,7 +416,22 @@ public class Devices implements IDaylightWeb {
                     Map<String, String> subnet = new HashMap<String, String>();
                     subnet.put("name", conf.getName());
                     subnet.put("subnet", conf.getSubnet());
-                    subnet.put("json", gson.toJson(conf));
+                    List<SubnetGatewayPortBean> portsList = new ArrayList<SubnetGatewayPortBean>();
+                    Iterator<NodeConnector> itor = conf.getSubnetNodeConnectors().iterator();
+                    while(itor.hasNext()) {
+                        SubnetGatewayPortBean bean = new SubnetGatewayPortBean();
+                        NodeConnector nodeConnector = itor.next();
+                        String nodeName = getNodeDesc(nodeConnector.getNode().toString(), containerName);
+                        Name ncName = ((Name) switchManager.getNodeConnectorProp(nodeConnector, Name.NamePropName));
+                        String nodeConnectorName = (ncName != null) ? ncName.getValue() : "";
+                        nodeConnectorName += " (" + nodeConnector.getID() + ")";
+                        bean.setNodeName(nodeName);
+                        bean.setNodePortName(nodeConnectorName);
+                        bean.setNodeId(nodeConnector.getNode().toString());
+                        bean.setNodePortId(nodeConnector.getID().toString());
+                        portsList.add(bean);
+                    }
+                    subnet.put("nodePorts", gson.toJson(portsList));
                     subnets.add(subnet);
                 }
             }
diff --git a/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/SubnetGatewayPortBean.java b/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/SubnetGatewayPortBean.java
new file mode 100644 (file)
index 0000000..4124630
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.devices.web;
+
+public class SubnetGatewayPortBean {
+    private String nodeName;
+    private String nodeId;
+    private String nodePortId;
+    private String nodePortName;
+
+    public String getNodeName() {
+        return nodeName;
+    }
+    public void setNodeName(String nodeName) {
+        this.nodeName = nodeName;
+    }
+    public String getNodeId() {
+        return nodeId;
+    }
+    public void setNodeId(String nodeId) {
+        this.nodeId = nodeId;
+    }
+    public String getNodePortId() {
+        return nodePortId;
+    }
+    public void setNodePortId(String nodePortId) {
+        this.nodePortId = nodePortId;
+    }
+    public String getNodePortName() {
+        return nodePortName;
+    }
+    public void setNodePortName(String nodePortName) {
+        this.nodePortName = nodePortName;
+    }
+}
index 048c9e993eaecc9d17a96541f39f1591bdccd25d..b90e5cbfa03c786e504a78f0ce8a0a003a09d8ce 100644 (file)
@@ -351,7 +351,7 @@ one.f.switchmanager.nodesLearnt = {
                         },
                         {
                             property: 'mac',
-                            label: 'Mac',
+                            label: 'MAC',
                             sortable: true
                         },
                         {
@@ -714,7 +714,7 @@ one.f.switchmanager.subnetGatewayConfig = {
                             sortable: true
                         },
                         {
-                            property: 'json',
+                            property: 'nodePorts',
                             label: 'Node/Ports',
                             sortable: false
                         }
@@ -723,19 +723,20 @@ one.f.switchmanager.subnetGatewayConfig = {
                     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);
+                            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;
                         });
 
                     },