cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [17/50] [abbrv] git commit: updated refs/heads/vmsync to 2ee8fd2
Date Tue, 09 Apr 2013 21:42:05 GMT
CLOUDSTACK-1065: cloudstack UI - AWS Style Regions - when switching region, set location without
parameters.


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

Branch: refs/heads/vmsync
Commit: b1ef74737af85997fa250ccbb53089ecb20a65eb
Parents: 265cf42
Author: Jessica Wang <jessica.wang@citrix.com>
Authored: Sun Apr 7 00:13:46 2013 -0700
Committer: Jessica Wang <jessica.wang@citrix.com>
Committed: Sun Apr 7 00:14:18 2013 -0700

----------------------------------------------------------------------
 ui/scripts/cloud.core.callbacks.js |   41 +++++++++++++++++-------------
 ui/scripts/cloudStack.js           |   14 +++++-----
 ui/scripts/sharedFunctions.js      |    2 +-
 ui/scripts/ui-custom/regions.js    |    4 +-
 4 files changed, 33 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b1ef7473/ui/scripts/cloud.core.callbacks.js
----------------------------------------------------------------------
diff --git a/ui/scripts/cloud.core.callbacks.js b/ui/scripts/cloud.core.callbacks.js
index 1a9e045..a081294 100644
--- a/ui/scripts/cloud.core.callbacks.js
+++ b/ui/scripts/cloud.core.callbacks.js
@@ -52,25 +52,31 @@ Below is a sample login attempt
 var clientApiUrl = "/client/api";
 var clientConsoleUrl   = "/client/console";
 
-$(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 = window.location.href.substring(0, window.location.href.indexOf('?'));

-	}
+$(document).ready(function() {
 	
-	/* 
-	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');		
+	var url = $.urlParam("loginUrl");
+	if (url != undefined && url != null && url.length > 0) {
+		url = unescape(clientApiUrl+"?"+url);
+		$.ajax({
+			url: url,
+			dataType: "json",
+			async: false,
+			success: function(json) {
+				g_loginResponse = json.loginresponse;
+			},
+			error: function() {
+				onLogoutCallback();
+				// This means the login failed.  You should redirect to your login page.
+			},
+			beforeSend: function(XMLHttpRequest) {
+				return true;
+			}
+		});
+	}
+	else if(window.name != null && window.name.indexOf("command=login") != -1) {	//from
region switching	  
+	  g_loginCmdText = window.name;		
 		$.ajax({
-			url: unescape(clientApiUrl + "?" + $.cookie('loginUrl')),
+			url: clientApiUrl + "?" + window.name,
 			dataType: "json",
 			async: false,
 			success: function(json) {
@@ -85,7 +91,6 @@ $(document).ready(function() {
 			}
 		});
 	}
-	
 });
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b1ef7473/ui/scripts/cloudStack.js
----------------------------------------------------------------------
diff --git a/ui/scripts/cloudStack.js b/ui/scripts/cloudStack.js
index 985627b..499cb83 100644
--- a/ui/scripts/cloudStack.js
+++ b/ui/scripts/cloudStack.js
@@ -251,12 +251,11 @@
           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});
+				g_loginCmdText = "command=login" + array1.join("") + "&response=json";				
 				
         $.ajax({
           type: "POST",
-          data: "command=login" + array1.join("") + "&response=json",					
+          data: g_loginCmdText,					
           dataType: "json",
           async: false,
           success: function(json) {			
@@ -386,7 +385,8 @@
 						g_timezoneoffset = null;
 						g_timezone = null;
 						g_supportELB = null;						
-						g_regionUrlParam = null;
+						g_loginCmdText = null;
+						window.name = '';
 						
 						$.cookie('JSESSIONID', null);
 						$.cookie('sessionKey', null);
@@ -398,8 +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.
 						}
@@ -466,7 +465,8 @@
 		
     document.title = 'CloudStack';
 
-    if ($.cookie('loginUrl') != null || $.urlParam('loginUrl') != 0) {
+    if ($.urlParam('loginUrl') != 0
+		||(window.name != null && window.name.indexOf("command=login") != -1)) {
       // SSO
       loginArgs.hideLoginScreen = true;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b1ef7473/ui/scripts/sharedFunctions.js
----------------------------------------------------------------------
diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js
index dbcb781..86fe7f6 100644
--- a/ui/scripts/sharedFunctions.js
+++ b/ui/scripts/sharedFunctions.js
@@ -20,7 +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_loginCmdText = null;
 var g_enableLogging = false;
 var g_timezoneoffset = null;
 var g_timezone = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b1ef7473/ui/scripts/ui-custom/regions.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/regions.js b/ui/scripts/ui-custom/regions.js
index 17bc86c..2f61dfd 100644
--- a/ui/scripts/ui-custom/regions.js
+++ b/ui/scripts/ui-custom/regions.js
@@ -89,8 +89,8 @@
       closeRegionSelector({
         complete: function() {
           $('#container').prepend($('<div>').addClass('loading-overlay'));
-          
-          document.location.href = url + g_regionUrlParam;
+          window.name = g_loginCmdText;
+          document.location.href = url;
         }
       });
     };


Mime
View raw message