Fix Device Port Status 88/288/1
authorAndrew Kim <andrekim@cisco.com>
Fri, 3 May 2013 00:22:09 +0000 (17:22 -0700)
committerAndrew Kim <andrekim@cisco.com>
Fri, 3 May 2013 00:22:09 +0000 (17:22 -0700)
Signed-off-by: Andrew Kim <andrekim@cisco.com>
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Config.java
opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java
opendaylight/web/devices/src/main/resources/js/page.js

index dbb93fb..505cc61 100644 (file)
@@ -64,14 +64,6 @@ public class Config extends Property {
 
     @Override
     public String toString() {
-        StringBuffer ret = new StringBuffer();
-        if (this.configValue == 0) {
-            ret.append("Down");
-        } else if (this.configValue == 1) {
-            ret.append("Up");
-        } else {
-            ret.append("Undefined");
-        }
-        return ret.toString();
+        return "Config["+ReflectionToStringBuilder.toString(this)+"]";
     }
 }
index 7898f78..4c31dee 100644 (file)
@@ -88,7 +88,6 @@ public class Devices implements IDaylightWeb {
         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
                 .getInstance(ISwitchManager.class, containerName, this);
         List<Map<String, String>> nodeData = new ArrayList<Map<String, String>>();
-        Map<String, String> portListStatus = new HashMap<String, String>();
         for (Switch device : switchManager.getNetworkDevices()) {
             HashMap<String, String> nodeDatum = new HashMap<String, String>();
             Node node = device.getNode();
@@ -112,38 +111,38 @@ public class Devices implements IDaylightWeb {
             nodeDatum.put("mac",
                     HexEncode.bytesToHexString(device.getDataLayerAddress()));
             StringBuffer sb1 = new StringBuffer();
-            StringBuffer sb2 = new StringBuffer();
             Set<NodeConnector> nodeConnectorSet = device.getNodeConnectors();
-            String nodeConnectorName;
-            String nodeConnectorNumberToStr;
             if (nodeConnectorSet != null && nodeConnectorSet.size() > 0) {
                 Map<Short, String> portList = new HashMap<Short, String>();
                 for (NodeConnector nodeConnector : nodeConnectorSet) {
-                    nodeConnectorNumberToStr = nodeConnector.getID().toString();
+                    String nodeConnectorNumberToStr = nodeConnector.getID().toString();
                     Name ncName = ((Name) switchManager.getNodeConnectorProp(
                             nodeConnector, Name.NamePropName));
                     Config portStatus = ((Config) switchManager
                             .getNodeConnectorProp(nodeConnector,
                                     Config.ConfigPropName));
-                    nodeConnectorName = (ncName != null) ? ncName.getValue()
+                    
+                    String nodeConnectorName = (ncName != null) ? ncName.getValue()
                             : "";
+                    nodeConnectorName += " ("+nodeConnector.getID()+")";
+                    if (portStatus.getValue() == Config.ADMIN_UP) {
+                        nodeConnectorName = "<span style='color:green;'>"+nodeConnectorName+"</span>";
+                    } else if (portStatus.getValue() == Config.ADMIN_DOWN) {
+                        nodeConnectorName = "<span style='color:red;'>"+nodeConnectorName+"</span>";
+                    }
+                    
                     portList.put(Short.parseShort(nodeConnectorNumberToStr),
                             nodeConnectorName);
-                    portListStatus
-                            .put(nodeConnectorName, portStatus.toString());
                 }
 
-                Map<Short, String> sortedPortList = new TreeMap<Short, String>(
-                        portList);
+                Map<Short, String> sortedPortList = new TreeMap<Short, String>(portList);
 
                 for (Entry<Short, String> e : sortedPortList.entrySet()) {
-                    sb1.append(e.getValue() + "(" + e.getKey() + ")");
+                    sb1.append(e.getValue());
                     sb1.append("<br>");
-                    sb2.append(portListStatus.get(e.getValue()) + "<br>");
                 }
             }
             nodeDatum.put("ports", sb1.toString());
-            nodeDatum.put("portStatus", sb2.toString());
             nodeData.add(nodeDatum);
         }
         DevicesJsonBean result = new DevicesJsonBean();
index 29f03d5..96b16bf 100644 (file)
@@ -18,7 +18,7 @@ one.f.dashlet = {
        },
     staticRouteConfig : {
         id : 'staticRouteConfig',
-        name : 'Static route Configuration'
+        name : 'Static Route Configuration'
     },
     subnetGatewayConfig : {
         id : 'subnetGatewayConfig',
@@ -90,11 +90,10 @@ one.f.switchmanager.nodesLearnt = {
 
                one.f.switchmanager.nodesLearnt.ajax.main(url, function(content) {
                        var body = one.f.switchmanager.nodesLearnt.data.abridged(content);
-                       var $table = one.f.switchmanager.createTable(["Node Name", "Node ID", "Ports", "Port Status"], body);
+                       var $table = one.f.switchmanager.createTable(["Node Name", "Node ID", "Ports"], body);
                        $dashlet.append($table);
                });
        },
-
        ajax : {
                main : function(url, callback) {
                        $.getJSON(url, function(data) {
@@ -106,7 +105,7 @@ one.f.switchmanager.nodesLearnt = {
                initialize: {
                        updateNode: function(evt) {
                                var nodeId = decodeURIComponent(evt.target.id);
-                               var h3 = "Update node information";
+                               var h3 = "Update Node Information";
                    var footer = one.f.switchmanager.nodesLearnt.modal.footer.updateNode();
                    var $modal = one.lib.modal.spawn(one.f.switchmanager.nodesLearnt.id.modal.modal, h3, "", footer);
                    
@@ -130,7 +129,7 @@ one.f.switchmanager.nodesLearnt = {
                        }
                },
                body: {
-                       updateNode: function(nodeId, portStatus, switchDetails, tiers) {
+                       updateNode: function(nodeId, switchDetails, tiers) {
                                var $form = $(document.createElement('form'));
                                var $fieldset = $(document.createElement('fieldset'));
                                // node ID. not editable.
@@ -148,13 +147,6 @@ one.f.switchmanager.nodesLearnt = {
                                        $input.attr('value', switchDetails["nodeName"]);
                                }
                                $fieldset.append($label).append($input);
-                               // Port Status. not editable.
-                               var $label = one.lib.form.label("Port Status");
-                               var $input = one.lib.form.input("Port Status");
-                               $input.attr('id', one.f.switchmanager.nodesLearnt.id.modal.form.portStatus);
-                               $input.attr("disabled", true);
-                               $input.attr("value", portStatus);
-                               $fieldset.append($label).append($input);
                                // node tier
                                var $label = one.lib.form.label("Tier");
                                var $select = one.lib.form.select.create(tiers);
@@ -246,7 +238,6 @@ one.f.switchmanager.nodesLearnt = {
                                entry.push(aTag);
                                entry.push(value["nodeId"]);
                                entry.push(value["ports"]);
-                               entry.push(value["portStatus"]);
                                tr.entry = entry;
                                result.push(tr);
                        });
@@ -644,7 +635,8 @@ one.f.switchmanager.staticRouteConfig = {
                        var body = one.f.switchmanager.staticRouteConfig.data.staticRouteConfig(content);
                        // first column contains checkbox. no need for header
                        content.columnNames.splice(0,0," ");
-                       var $table = one.f.switchmanager.createTable(content.columnNames, body);
+                       var tableHeaders = ['', 'Name', 'Static Route', 'Next Hop Address'];
+                       var $table = one.f.switchmanager.createTable(tableHeaders, body);
                        $dashlet.append($table);
                });
        },
@@ -1017,4 +1009,4 @@ $('.dash .nav a', '#main').click(function() {
 // activate first tab on each dashlet
 $('.dash .nav').each(function(index, value) {
     $($(value).find('li')[0]).find('a').click();
-});
\ No newline at end of file
+});