Repository: ambari Updated Branches: refs/heads/branch-2.5 ac1444db7 -> 07f30c550
AMBARI-19962 Clicking on the login button (or hitting page refresh) to seeing the dashboard takes a while on a 1000-node cluster. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/07f30c55 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/07f30c55 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/07f30c55 Branch: refs/heads/branch-2.5 Commit: 07f30c550f2d3f5c68f2f4898d0605bc4244600c Parents: ac1444d Author: Andrii Tkach <atk...@apache.org> Authored: Fri Feb 10 17:59:58 2017 +0200 Committer: Andrii Tkach <atk...@apache.org> Committed: Fri Feb 10 21:38:26 2017 +0200 ---------------------------------------------------------------------- ambari-web/app/router.js | 37 ++++++++++++++++++++++++++-------- ambari-web/app/utils/ajax/ajax.js | 2 +- 2 files changed, 30 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/07f30c55/ambari-web/app/router.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js index d367ce3..dfe19b5 100644 --- a/ambari-web/app/router.js +++ b/ambari-web/app/router.js @@ -256,16 +256,35 @@ App.Router = Em.Router.extend({ displayLoginName: Em.computed.truncate('loginName', 10, 10), + /** + * @type {$.ajax|null} + */ + clusterDataRequest: null, + + /** + * If request was already sent on login then use saved clusterDataRequest and don't make second call + * @returns {$.ajax} + */ + getClusterDataRequest: function() { + var clusterDataRequest = this.get('clusterDataRequest'); + if (clusterDataRequest) { + this.set('clusterDataRequest', null); + return clusterDataRequest; + } else { + return App.ajax.send({ + name: 'router.login.clusters', + sender: this, + success: 'onAuthenticationSuccess', + error: 'onAuthenticationError' + }); + } + }, + getAuthenticated: function () { var dfd = $.Deferred(); var self = this; var auth = App.db.getAuthenticated(); - App.ajax.send({ - name: 'router.login.clusters', - sender: this, - success: 'onAuthenticationSuccess', - error: 'onAuthenticationError' - }).complete(function (xhr) { + this.getClusterDataRequest().complete(function (xhr) { if (xhr.isResolved()) { // if server knows the user and user authenticated by UI if (auth) { @@ -535,12 +554,12 @@ App.Router = Em.Router.extend({ this.loginGetClustersSuccessCallback(self.get('clusterData'), {}, requestData); } else { - App.ajax.send({ + this.set('clusterDataRequest', App.ajax.send({ name: 'router.login.clusters', sender: self, data: requestData, success: 'loginGetClustersSuccessCallback' - }); + })); } }, @@ -584,6 +603,8 @@ App.Router = Em.Router.extend({ router.transitionToAdminView(); } } + // set cluster name and security type + App.router.get('clusterController').reloadSuccessCallback(clustersData); App.set('isPermissionDataLoaded', true); App.router.get('userSettingsController').dataLoading(); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/07f30c55/ambari-web/app/utils/ajax/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js index 2ea6113..8881d7a 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -2279,7 +2279,7 @@ var urls = { mock: '/data/users/privileges_{userName}.json' }, 'router.login.clusters': { - 'real': '/clusters?fields=Clusters/provisioning_state', + 'real': '/clusters?fields=Clusters/provisioning_state,Clusters/security_type', 'mock': '/data/clusters/info.json' }, 'router.login.message': {