You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/03/25 18:52:07 UTC
[07/50] [abbrv] git commit: refs/heads/ui-multiple-pod-ranges -
CLOUDSTACK-1065: cloudstack UI - AWS Style Regions - implement region
switching action triggered by region dropdown on top menu.
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/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/918a7c74
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/918a7c74
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/918a7c74
Branch: refs/heads/ui-multiple-pod-ranges
Commit: 918a7c7481454e78a648389ed3173c0037fc715b
Parents: dbfd316
Author: Jessica Wang <je...@citrix.com>
Authored: Wed Mar 20 11:58:17 2013 -0700
Committer: Jessica Wang <je...@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/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/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/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/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;
}
});
};