Fix flows detail 85/1185/1
authorAndrew Kim <andrekim@cisco.com>
Fri, 13 Sep 2013 22:32:44 +0000 (17:32 -0500)
committerAndrew Kim <andrekim@cisco.com>
Fri, 13 Sep 2013 22:32:44 +0000 (17:32 -0500)
- Fix flow with same names not correctly updating details table
  - Add extra check to differentiate between flows on different nodes
- Minor refactor in backend to consolidate Gson

Change-Id: Ifffa051d574a0a81af4de9472842ec82194dfb42
Signed-off-by: Andrew Kim <andrekim@cisco.com>
opendaylight/web/flows/src/main/java/org/opendaylight/controller/flows/web/Flows.java
opendaylight/web/flows/src/main/resources/js/page.js

index a96d3efcec698d80a243969fd2c1c3df9ee1e2cf..4cd71a37640ba2f303c04570eb9549c845a82816 100644 (file)
@@ -52,8 +52,11 @@ public class Flows implements IDaylightWeb {
     private static final String WEB_ID = "flows";
     private static final short WEB_ORDER = 2;
 
+    private final Gson gson;
+
     public Flows() {
         ServiceHelper.registerGlobalService(IDaylightWeb.class, this, null);
+        gson = new Gson();
     }
 
     @Override
@@ -246,8 +249,8 @@ public class Flows implements IDaylightWeb {
             return null;
         }
 
-        Gson gson = new Gson();
         FlowConfig flow = gson.fromJson(body, FlowConfig.class);
+
         Node node = Node.fromString(nodeId);
         flow.setNode(node);
         Status result = new Status(StatusCode.BADREQUEST, "Invalid request");
@@ -332,7 +335,6 @@ public class Flows implements IDaylightWeb {
             return "Forwarding Rules Manager is not available";
         }
 
-        Gson gson = new Gson();
         List<Map<String, String>> flowList = new ArrayList<Map<String, String>>();
         flowList = gson.fromJson(body, flowList.getClass());
         Status result = new Status(StatusCode.BADREQUEST, "Invalid request");
index a3d9422dfe109c461fac018ee9d33ba0ddd766e6..f3bbf7559b142b0375ea35e8d3f9c052152d284a 100644 (file)
@@ -420,9 +420,9 @@ one.f.flows = {
         var flows = one.f.flows.registry.flows;
         var flow;
         $(flows).each(function(index, value) {
-            if (value['name'] == id) {
-                flow = value;
-            }
+          if (value.name == id && value.nodeId == node) {
+            flow = value;
+          }
         });
         if (one.f.flows.registry.privilege === 'WRITE') {
             // remove button
@@ -1420,4 +1420,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
+});