cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [20/25] git commit: refs/heads/api_entity - CLOUDSTACK-1065: cloudstack UI - AWS Style Regions - implement region switching action triggered by region dropdown on top menu.
Date Thu, 21 Mar 2013 01:04:34 GMT
CLOUDSTACK-1065: cloudstack UI - AWS Style Regions - implement region switching action triggered
by region dropdown on top menu.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/918a7c74
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/918a7c74
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/918a7c74

Branch: refs/heads/api_entity
Commit: 918a7c7481454e78a648389ed3173c0037fc715b
Parents: dbfd316
Author: Jessica Wang <jessica.wang@citrix.com>
Authored: Wed Mar 20 11:58:17 2013 -0700
Committer: Jessica Wang <jessica.wang@citrix.com>
Committed: Wed Mar 20 11:58:57 2013 -0700

----------------------------------------------------------------------
 ui/scripts/cloud.core.callbacks.js |   25 +++++++++++++++++++------
 ui/scripts/cloudStack.js           |    9 +++++++--
 ui/scripts/sharedFunctions.js      |    1 +
 ui/scripts/ui-custom/regions.js    |    4 ++--
 4 files changed, 29 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/918a7c74/ui/scripts/cloud.core.callbacks.js
----------------------------------------------------------------------
diff --git a/ui/scripts/cloud.core.callbacks.js b/ui/scripts/cloud.core.callbacks.js
index 857c247..6384f9b 100644
--- a/ui/scripts/cloud.core.callbacks.js
+++ b/ui/scripts/cloud.core.callbacks.js
@@ -52,17 +52,29 @@ Below is a sample login attempt
 var clientApiUrl = "/client/api";
 var clientConsoleUrl   = "/client/console";
 
-$(document).ready(function() {
+$(document).ready(function() {		
+  /*
+	condition 1: If window.location.href contains parameter 'loginUrl', save the parameter's
value to a cookie, then reload the page without any URL parameter.
+	(After the page is reloaded without any URL parameter, it will fall in condition 2.) 
+	*/
+	if ($.urlParam('loginUrl') != 0) {	 
+		$.cookie('loginUrl', $.urlParam('loginUrl'), { expires: 1});
+	  document.location.href = '/client/';	
+	}
 	
-	var url = $.urlParam("loginUrl");
-	if (url != undefined && url != null && url.length > 0) {
-		url = unescape(clientApiUrl+"?"+url);
+	/* 
+	condition 2: If window.location.href does not contain parameter 'loginUrl' but cookie 'loginUrl'
exists, 
+	save the cookie's value to g_regionUrlParam (a global variable for switching regions), 
+	then call login API to set g_loginResponse (a global variable for single-sign-on).
+	*/
+	else if($.cookie('loginUrl') != null) {	  
+	  g_regionUrlParam = '?loginUrl=' + $.cookie('loginUrl');		
 		$.ajax({
-			url: url,
+			url: unescape(clientApiUrl + "?" + $.cookie('loginUrl')),
 			dataType: "json",
 			async: false,
 			success: function(json) {
-				g_loginResponse = json.loginresponse;
+				g_loginResponse = json.loginresponse;				
 			},
 			error: function() {
 				onLogoutCallback();
@@ -73,6 +85,7 @@ $(document).ready(function() {
 			}
 		});
 	}
+	
 });
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/918a7c74/ui/scripts/cloudStack.js
----------------------------------------------------------------------
diff --git a/ui/scripts/cloudStack.js b/ui/scripts/cloudStack.js
index f9b5a58..00b06ab 100644
--- a/ui/scripts/cloudStack.js
+++ b/ui/scripts/cloudStack.js
@@ -251,6 +251,9 @@
           array1.push("&domain=" + encodeURIComponent("/"));
         }
 
+				g_regionUrlParam = '?loginUrl=' + escape("command=login" + array1.join("") + "&response=json");
+				$.cookie('loginUrl', escape("command=login" + array1.join("") + "&response=json"),
{ expires: 1});
+				
         $.ajax({
           type: "POST",
           data: "command=login" + array1.join("") + "&response=json",					
@@ -382,8 +385,9 @@
 						g_domainid = null;	
 						g_timezoneoffset = null;
 						g_timezone = null;
-						g_supportELB = null;
-								
+						g_supportELB = null;						
+						g_regionUrlParam = null;
+						
 						$.cookie('JSESSIONID', null);
 						$.cookie('sessionKey', null);
 						$.cookie('username', null);
@@ -394,6 +398,7 @@
 						$.cookie('timezoneoffset', null);
 						$.cookie('timezone', null);
 						$.cookie('supportELB', null);
+						$.cookie('loginUrl', null);
 												
 						if(onLogoutCallback()) {	 //onLogoutCallback() will set g_loginResponse(single-sign-on
variable) to null, then bypassLoginCheck() will show login screen.
               document.location.reload(); //when onLogoutCallback() returns true, reload
the current document.

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/918a7c74/ui/scripts/sharedFunctions.js
----------------------------------------------------------------------
diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js
index 8bcdff9..dbcb781 100644
--- a/ui/scripts/sharedFunctions.js
+++ b/ui/scripts/sharedFunctions.js
@@ -20,6 +20,7 @@ var g_role = null; // roles - root, domain-admin, ro-admin, user
 var g_username = null;
 var g_account = null;
 var g_domainid = null;
+var g_regionUrlParam = null;
 var g_enableLogging = false;
 var g_timezoneoffset = null;
 var g_timezone = null;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/918a7c74/ui/scripts/ui-custom/regions.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/regions.js b/ui/scripts/ui-custom/regions.js
index ac52776..579cdce 100644
--- a/ui/scripts/ui-custom/regions.js
+++ b/ui/scripts/ui-custom/regions.js
@@ -81,8 +81,8 @@
       closeRegionSelector({
         complete: function() {
           $('#container').prepend($('<div>').addClass('loading-overlay'));
-
-          document.location.href = url;
+          
+          document.location.href = url + g_regionUrlParam;
         }
       });
     };


Mime
View raw message