ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-6515 Change authentication call to asynchronous. (atkach)
Date Wed, 16 Jul 2014 18:07:45 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 442b7961c -> 38999bb17


AMBARI-6515 Change authentication call to asynchronous. (atkach)


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

Branch: refs/heads/trunk
Commit: 38999bb177a2445ed3dd6578550e6d9e1665909c
Parents: 442b796
Author: atkach <atkach@hortonworks.com>
Authored: Wed Jul 16 21:06:06 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Wed Jul 16 21:06:06 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/router.js           |  25 ++++---
 ambari-web/app/routes/installer.js | 122 ++++++++++++++++----------------
 ambari-web/app/routes/main.js      |  38 +++++-----
 3 files changed, 98 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/38999bb1/ambari-web/app/router.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js
index ef33669..1a01787 100644
--- a/ambari-web/app/router.js
+++ b/ambari-web/app/router.js
@@ -92,6 +92,8 @@ App.Router = Em.Router.extend({
   }.property('loggedIn'),
 
   getAuthenticated: function () {
+    var dfd = $.Deferred();
+    var self = this;
     var auth = App.db.getAuthenticated();
     var authResp = (auth && auth === true);
     if (authResp) {
@@ -100,11 +102,14 @@ App.Router = Em.Router.extend({
         sender: this,
         success: 'onAuthenticationSuccess',
         error: 'onAuthenticationError'
-      });
+      }).complete(function () {
+          dfd.resolve(self.get('loggedIn'));
+        });
     } else {
       this.set('loggedIn', false);
+      dfd.resolve(false);
     }
-    return this.get('loggedIn');
+    return dfd.promise();
   },
 
   onAuthenticationSuccess: function (data) {
@@ -354,14 +359,16 @@ App.Router = Em.Router.extend({
        *  If the user is already logged in, redirect to where the user was previously
        */
       enter: function (router, context) {
-        if (router.getAuthenticated()) {
-          Ember.run.next(function () {
-            console.log(router.getLoginName() + ' already authenticated.  Redirecting...');
-            router.getSection(function (route) {
-              router.transitionTo(route, context);
+        router.getAuthenticated().done(function (loggedIn) {
+          if (loggedIn) {
+            Ember.run.next(function () {
+              console.log(router.getLoginName() + ' already authenticated.  Redirecting...');
+              router.getSection(function (route) {
+                router.transitionTo(route, context);
+              });
             });
-          });
-        }
+          }
+        });
       },
 
       connectOutlets: function (router, context) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/38999bb1/ambari-web/app/routes/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/installer.js b/ambari-web/app/routes/installer.js
index d4fda3c..ff02fe3 100644
--- a/ambari-web/app/routes/installer.js
+++ b/ambari-web/app/routes/installer.js
@@ -27,69 +27,71 @@ module.exports = Em.Route.extend({
 
     App.clusterStatus.set('wizardControllerName', App.router.get('installerController.name'));
 
-    if (router.getAuthenticated()) {
-      // check server/web client versions match
-      App.router.get('installerController').checkServerClientVersion().done(function () {
-
-        var name = 'Cluster Install Wizard';
-        $('title').text('Ambari - ' + name);
-
-        if (App.get('isAdmin')) {
-          router.get('mainController').stopPolling();
-          console.log('In installer with successful authenticated');
-          console.log('current step=' + router.get('installerController.currentStep'));
-          Ember.run.next(function () {
-            var installerController = router.get('installerController');
-
-            App.clusterStatus.updateFromServer().complete(function () {
-              var currentClusterStatus = App.clusterStatus.get('value');
-
-              if (currentClusterStatus) {
-                switch (currentClusterStatus.clusterState) {
-                  case 'CLUSTER_NOT_CREATED_1' :
-                    router.transitionTo('step' + installerController.get('currentStep'));
-                    break;
-                  case 'CLUSTER_DEPLOY_PREP_2' :
-                    installerController.setCurrentStep('8');
-                    App.db.data = currentClusterStatus.localdb;
-                    router.transitionTo('step' + installerController.get('currentStep'));
-                    break;
-                  case 'CLUSTER_INSTALLING_3' :
-                  case 'SERVICE_STARTING_3' :
-                    if (!installerController.get('isStep9')) {
-                      installerController.setCurrentStep('9');
-                    }
-                    router.transitionTo('step' + installerController.get('currentStep'));
-                    break;
-                  case 'CLUSTER_INSTALLED_4' :
-                    if (!installerController.get('isStep10')) {
-                      installerController.setCurrentStep('10');
-                    }
-                    App.db.data = currentClusterStatus.localdb;
-                    router.transitionTo('step' + installerController.get('currentStep'));
-                    break;
-                  case 'DEFAULT' :
-                  default:
-                    router.transitionTo('main.dashboard.index');
-                    break;
+    router.getAuthenticated().done(function (loggedIn) {
+      if (loggedIn) {
+        // check server/web client versions match
+        App.router.get('installerController').checkServerClientVersion().done(function ()
{
+
+          var name = 'Cluster Install Wizard';
+          $('title').text('Ambari - ' + name);
+
+          if (App.get('isAdmin')) {
+            router.get('mainController').stopPolling();
+            console.log('In installer with successful authenticated');
+            console.log('current step=' + router.get('installerController.currentStep'));
+            Ember.run.next(function () {
+              var installerController = router.get('installerController');
+
+              App.clusterStatus.updateFromServer().complete(function () {
+                var currentClusterStatus = App.clusterStatus.get('value');
+
+                if (currentClusterStatus) {
+                  switch (currentClusterStatus.clusterState) {
+                    case 'CLUSTER_NOT_CREATED_1' :
+                      router.transitionTo('step' + installerController.get('currentStep'));
+                      break;
+                    case 'CLUSTER_DEPLOY_PREP_2' :
+                      installerController.setCurrentStep('8');
+                      App.db.data = currentClusterStatus.localdb;
+                      router.transitionTo('step' + installerController.get('currentStep'));
+                      break;
+                    case 'CLUSTER_INSTALLING_3' :
+                    case 'SERVICE_STARTING_3' :
+                      if (!installerController.get('isStep9')) {
+                        installerController.setCurrentStep('9');
+                      }
+                      router.transitionTo('step' + installerController.get('currentStep'));
+                      break;
+                    case 'CLUSTER_INSTALLED_4' :
+                      if (!installerController.get('isStep10')) {
+                        installerController.setCurrentStep('10');
+                      }
+                      App.db.data = currentClusterStatus.localdb;
+                      router.transitionTo('step' + installerController.get('currentStep'));
+                      break;
+                    case 'DEFAULT' :
+                    default:
+                      router.transitionTo('main.dashboard.index');
+                      break;
+                  }
                 }
-              }
+              });
             });
-          });
-        } else {
-          Em.run.next(function () {
-            App.router.transitionTo('main.services');
-          });
-        }
+          } else {
+            Em.run.next(function () {
+              App.router.transitionTo('main.services');
+            });
+          }
 
-      });
-    } else {
-      console.log('In installer but its not authenticated');
-      console.log('value of authenticated is: ' + router.getAuthenticated());
-      Ember.run.next(function () {
-        router.transitionTo('login');
-      });
-    }
+        });
+      } else {
+        console.log('In installer but its not authenticated');
+        console.log('value of authenticated is: ' + router.getAuthenticated());
+        Ember.run.next(function () {
+          router.transitionTo('login');
+        });
+      }
+    });
   },
 
   routePath: function (router, event) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/38999bb1/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index 763d82a..12f4981 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -24,26 +24,28 @@ module.exports = Em.Route.extend({
   enter: function (router) {
     App.db.updateStorage();
     console.log('in /main:enter');
-    if (router.getAuthenticated()) {
-      App.router.get('mainAdminAccessController').loadShowJobsForUsers().done(function ()
{
-        App.router.get('clusterController').loadClusterName(false).done(function () {
-          if (App.get('testMode')) {
-            router.get('mainController').initialize();
-          } else {
-            App.router.get('mainController').checkServerClientVersion().done(function ()
{
-              App.router.get('clusterController').loadClientServerClockDistance().done(function
() {
-                router.get('mainController').initialize();
+    router.getAuthenticated().done(function (loggedIn) {
+      if (loggedIn) {
+        App.router.get('mainAdminAccessController').loadShowJobsForUsers().done(function
() {
+          App.router.get('clusterController').loadClusterName(false).done(function () {
+            if (App.get('testMode')) {
+              router.get('mainController').initialize();
+            } else {
+              App.router.get('mainController').checkServerClientVersion().done(function ()
{
+                App.router.get('clusterController').loadClientServerClockDistance().done(function
() {
+                  router.get('mainController').initialize();
+                });
               });
-            });
-          }
+            }
+          });
         });
-      });
-      // TODO: redirect to last known state
-    } else {
-      Em.run.next(function () {
-        router.transitionTo('login');
-      });
-    }
+        // TODO: redirect to last known state
+      } else {
+        Em.run.next(function () {
+          router.transitionTo('login');
+        });
+      }
+    });
   },
   /*
    routePath: function(router,event) {


Mime
View raw message