Merge pull request #293 from pgreyson/master

Bug fixes
diff --git a/web/ons-demo/RELEASE_NOTES.txt b/web/ons-demo/RELEASE_NOTES.txt
index 17e70fe..af084a2 100644
--- a/web/ons-demo/RELEASE_NOTES.txt
+++ b/web/ons-demo/RELEASE_NOTES.txt
@@ -17,3 +17,8 @@
 	2) if only the clicked controller is selected, selects all controllers again
 - Update configuration files to match test bed
 - Update sample JSON files from test bed
+
+** March 22, 2013 **
+- Workarounds for Chrome v25 rendering bugs
+- Fixed broken proxy functionality in restapi2.py
+- webui should now work when hosted from a different server than the controller (where it uses gui3.onlab.us:8080) and also when run from the same server (where it uses localhost:8080)
diff --git a/web/ons-demo/css/skin.default.css b/web/ons-demo/css/skin.default.css
index a04b0e0..6ff36ab 100644
--- a/web/ons-demo/css/skin.default.css
+++ b/web/ons-demo/css/skin.default.css
@@ -118,10 +118,12 @@
 .color11-selected .color11,
 .color12-selected .color12  {
 	opacity: 1;
+	pointer-events: auto;
 }
 
 .color0 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #222;
 	background-color: #222;
 	color: #444;
@@ -129,6 +131,7 @@
 
 .color1 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #EC0033;
 	background-color: #EC0033;
 }
@@ -141,36 +144,42 @@
 
 .color3 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #3714B0;
 	background-color: #3714B0;
 }
 
 .color4 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #B12C49;
 	background-color: #B12C49;
 }
 
 .color5 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #402C84;
 	background-color: #402C84;
 }
 
 .color6 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #990021;
 	background-color: #990021;
 }
 
 .color7 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #990021;
 	background-color: ;
 }
 
 .color8 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #A67900;
 	background-color: #A67900;
 }
@@ -183,18 +192,21 @@
 
 .color10 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #1F0772;
 	background-color: #1F0772;
 }
 
 .color11 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #F56E8B;
 	background-color: #F56E8B;
 }
 
 .color12 {
 	opacity: .2;
+	pointer-events: none;
 	fill: #6949D7;
 	background-color: #6949D7;
 }
diff --git a/web/ons-demo/js/app.js b/web/ons-demo/js/app.js
index 8980d02..9c58b45 100644
--- a/web/ons-demo/js/app.js
+++ b/web/ons-demo/js/app.js
@@ -93,10 +93,31 @@
 		rings[1].angles[i] = (range.min + range.max)/2;
 	});
 
-	// arrange core switches at equal increments
+	// find the association between core switches and aggregation switches
+	var aggregationSwitchMap = {};
+	model.aggregationSwitches.forEach(function (s, i) {
+		aggregationSwitchMap[s.dpid] = i + 1;
+	});
+
+	var coreSwitchMap = {};
+	model.coreSwitches.forEach(function (s, i) {
+		coreSwitchMap[s.dpid] = i + 1;
+	});
+
+	var coreLinks = {};
+	model.links.forEach(function (l) {
+		if (aggregationSwitchMap[l['src-switch']] && coreSwitchMap[l['dst-switch']]) {
+			coreLinks[l['dst-switch']] = aggregationSwitchMap[l['src-switch']] - 1;
+		}
+	});
+
+
+
+	// put core switches next to linked aggregation switches
 	k = 360 / rings[2].switches.length;
 	rings[2].switches.forEach(function (s, i) {
-		rings[2].angles[i] = k * i;
+//		rings[2].angles[i] = k * i;
+		rings[2].angles[i] = rings[1].angles[coreLinks[s.dpid]];
 	});
 
 	function ringEnter(data, i) {
@@ -276,9 +297,18 @@
 
 		// do it again in 1s
 		setTimeout(function () {
-			sync(svg)
+//			sync(svg)
 		}, 1000);
 	});
 }
 
-sync(createTopologyView());
\ No newline at end of file
+svg = createTopologyView();
+// workaround for Chrome v25 bug
+// if executed immediately, the view box transform logic doesn't work properly
+// fixed in Chrome v27
+setTimeout(function () {
+	// workaround for another Chrome v25 bug
+	// viewbox transform stuff doesn't work in combination with browser zoom
+	d3.select('#svg-container').style('zoom',  window.document.body.clientWidth/window.document.width);
+	sync(svg);
+}, 100);
diff --git a/web/ons-demo/js/model.js b/web/ons-demo/js/model.js
index 6577fea..1f90362 100644
--- a/web/ons-demo/js/model.js
+++ b/web/ons-demo/js/model.js
@@ -70,12 +70,12 @@
 }
 
 var proxyURLs = {
-	links: '/proxy/wm/core/topology/links/json',
-	switches: '/proxy/wm/core/topology/switches/all/json',
-	flows: '/proxy/wm/flow/getall/json',
-	activeControllers: '/proxy/wm/registry/controllers/json',
+	links: '/wm/core/topology/links/json?proxy',
+	switches: '/wm/core/topology/switches/all/json?proxy',
+	flows: '/wm/flow/getall/json?proxy',
+	activeControllers: '/wm/registry/controllers/json?proxy',
 	controllers: 'data/controllers.json',
-	mapping: '/proxy/wm/registry/switches/json',
+	mapping: '/wm/registry/switches/json?proxy',
 	configuration: 'data/configuration.json'
 }
 
diff --git a/web/restapi2.py b/web/restapi2.py
index ca6ad5c..c9952ac 100755
--- a/web/restapi2.py
+++ b/web/restapi2.py
@@ -53,15 +53,19 @@
 
   return response
 
-## PROXY API (allows development where the webui is served from someplace other than the ONOS_HOST)##
-#ONOS_HOST="http://gui3.onlab.us:8080"
-ONOS_HOST="http://localhost:8080" ;# for Amazon EC2
+## PROXY API (allows development where the webui is served from someplace other than the controller)##
+ONOS_GUI3_HOST="http://gui3.onlab.us:8080"
+ONOS_LOCAL_HOST="http://localhost:8080" ;# for Amazon EC2
 
 @app.route("/wm/core/topology/switches/all/json")
-@app.route("/proxy/wm/core/topology/switches/all/json")
 def switches():
+  if request.args.get('proxy') == None:
+    host = ONOS_LOCAL_HOST
+  else:
+    host = ONOS_GUI3_HOST
+
   try:
-    command = "curl -s %s/wm/core/topology/switches/all/json" % (ONOS_HOST)
+    command = "curl -s %s/wm/core/topology/switches/all/json" % (host)
     print command
     result = os.popen(command).read()
   except:
@@ -72,10 +76,14 @@
   return resp
 
 @app.route("/wm/core/topology/links/json")
-@app.route("/proxy/wm/core/topology/links/json")
 def links():
+  if request.args.get('proxy') == None:
+    host = ONOS_LOCAL_HOST
+  else:
+    host = ONOS_GUI3_HOST
+
   try:
-    command = "curl -s %s/wm/core/topology/links/json" % (ONOS_HOST)
+    command = "curl -s %s/wm/core/topology/links/json" % (host)
     print command
     result = os.popen(command).read()
   except:
@@ -86,10 +94,14 @@
   return resp
 
 @app.route("/wm/flow/getall/json")
-@app.route("/proxy/wm/flow/getall/json")
 def flows():
+  if request.args.get('proxy') == None:
+    host = ONOS_LOCAL_HOST
+  else:
+    host = ONOS_GUI3_HOST
+
   try:
-    command = "curl -s %s/wm/flow/getall/json" % (ONOS_HOST)
+    command = "curl -s %s/wm/flow/getall/json" % (host)
     print command
     result = os.popen(command).read()
   except:
@@ -100,10 +112,14 @@
   return resp
 
 @app.route("/wm/registry/controllers/json")
-@app.route("/proxy/wm/registry/controllers/json")
 def registry_controllers():
+  if request.args.get('proxy') == None:
+    host = ONOS_LOCAL_HOST
+  else:
+    host = ONOS_GUI3_HOST
+
   try:
-    command = "curl -s %s/wm/registry/controllers/json" % (ONOS_HOST)
+    command = "curl -s %s/wm/registry/controllers/json" % (host)
     print command
     result = os.popen(command).read()
   except:
@@ -114,10 +130,14 @@
   return resp
 
 @app.route("/wm/registry/switches/json")
-@app.route("/proxy/wm/registry/switches/json")
 def registry_switches():
+  if request.args.get('proxy') == None:
+    host = ONOS_LOCAL_HOST
+  else:
+    host = ONOS_GUI3_HOST
+
   try:
-    command = "curl -s %s/wm/registry/switches/json" % (ONOS_HOST)
+    command = "curl -s %s/wm/registry/switches/json" % (host)
     print command
     result = os.popen(command).read()
   except: