From: lakshya Date: Mon, 26 Aug 2013 18:44:50 +0000 (-0700) Subject: Fix to show Node name if present when adding ports to Subnet Gateway on the devices... X-Git-Tag: releasepom-0.1.0~170 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=a07f4280955a0065133c48d05a14ecf32a3fdbeb Fix to show Node name if present when adding ports to Subnet Gateway on the devices tab. A minor change from Mac to MAC in nodes learnt popout. Change-Id: I600a8437d757b72bdaf8f0e5d8ffa624a08c4d2b Signed-off-by: lakshya --- diff --git a/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java b/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java index 781242a969..f670477502 100644 --- a/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java +++ b/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java @@ -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 subnet = new HashMap(); subnet.put("name", conf.getName()); subnet.put("subnet", conf.getSubnet()); - subnet.put("json", gson.toJson(conf)); + List portsList = new ArrayList(); + Iterator 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 index 0000000000..41246304b0 --- /dev/null +++ b/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/SubnetGatewayPortBean.java @@ -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; + } +} diff --git a/opendaylight/web/devices/src/main/resources/js/page.js b/opendaylight/web/devices/src/main/resources/js/page.js index 048c9e993e..b90e5cbfa0 100644 --- a/opendaylight/web/devices/src/main/resources/js/page.js +++ b/opendaylight/web/devices/src/main/resources/js/page.js @@ -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"] = ''; - var json = tableRow["json"]; - var subnetConfigObject = JSON.parse(json); + var json = tableRow["nodePorts"]; + var nodePorts = JSON.parse(json); var nodePortHtml = "
"; - $.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 += " "; - nodePortHtml += 'Delete'; nodePortHtml += "
"; }); nodePortHtml += "
"; - tableRow["json"] = nodePortHtml; + tableRow["nodePorts"] = nodePortHtml; }); },