From: Andrew Kim Date: Mon, 26 Aug 2013 17:11:15 +0000 (+0000) Subject: Merge "Fixing a bug to show node name if present instead of node id while adding... X-Git-Tag: releasepom-0.1.0~175 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=b919fb3aefb42e1207d757e8bb6386e8251e479a;hp=d7206c0c4f8288f990efd279b4ad59bc6d5825ee Merge "Fixing a bug to show node name if present instead of node id while adding SPAN ports on the devices page." --- 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 15ad9e9887..781242a969 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 @@ -636,7 +636,7 @@ public class Devices implements IDaylightWeb { @RequestMapping(value = "/nodeports") @ResponseBody - public Map getNodePorts(HttpServletRequest request, + public List getNodePorts(HttpServletRequest request, @RequestParam(required = false) String container) { String containerName = (container == null) ? GlobalConstants.DEFAULT .toString() : container; @@ -647,18 +647,16 @@ public class Devices implements IDaylightWeb { return null; } - ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, containerName, this); if (switchManager == null) { return null; } - - Map nodes = new HashMap(); - Map port; + List nodeJsonBeans = new ArrayList(); for (Switch node : switchManager.getNetworkDevices()) { - port = new HashMap(); // new port + NodeJsonBean nodeJsonBean = new NodeJsonBean(); + List port = new ArrayList(); Set nodeConnectorSet = node.getNodeConnectors(); if (nodeConnectorSet != null) { @@ -666,15 +664,17 @@ public class Devices implements IDaylightWeb { String nodeConnectorName = ((Name) switchManager .getNodeConnectorProp(nodeConnector, Name.NamePropName)).getValue(); - port.put((Short) nodeConnector.getID(), nodeConnectorName + port.add(nodeConnectorName + "(" + nodeConnector.getID() + ")"); } } - - nodes.put(node.getNode().toString(), port); + nodeJsonBean.setNodeId(node.getNode().toString()); + nodeJsonBean.setNodeName(getNodeDesc(node.getNode().toString(), containerName)); + nodeJsonBean.setNodePorts(port); + nodeJsonBeans.add(nodeJsonBean); } - return nodes; + return nodeJsonBeans; } @RequestMapping(value = "/spanPorts/add", method = RequestMethod.GET) diff --git a/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/NodeJsonBean.java b/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/NodeJsonBean.java new file mode 100644 index 0000000000..0fd933a5ec --- /dev/null +++ b/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/NodeJsonBean.java @@ -0,0 +1,42 @@ +/* + * 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; + +import java.util.List; + +public class NodeJsonBean { + String nodeId; + String nodeName; + List nodePorts; + + public String getNodeId() { + return nodeId; + } + + public String getNodeName() { + return nodeName; + } + + public List getNodePorts() { + return nodePorts; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } + + public void setNodePorts(List port) { + this.nodePorts = port; + } + +} diff --git a/opendaylight/web/devices/src/main/resources/js/page.js b/opendaylight/web/devices/src/main/resources/js/page.js index 6916be6798..048c9e993e 100644 --- a/opendaylight/web/devices/src/main/resources/js/page.js +++ b/opendaylight/web/devices/src/main/resources/js/page.js @@ -1161,11 +1161,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); @@ -1182,10 +1182,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) { @@ -1196,15 +1200,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", "");