ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject git commit: AMBARI-5084. On Access tab " Enable Jobs tab for non-admin users " doesn't work (alexantonenko)
Date Fri, 14 Mar 2014 15:23:19 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 69786453c -> 917807d0e


AMBARI-5084. On Access tab " Enable Jobs tab for non-admin users " doesn't work (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 917807d0e3d7db20d756f28dc2274e0ee50172f5
Parents: 6978645
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Fri Mar 14 17:05:02 2014 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Fri Mar 14 17:23:13 2014 +0200

----------------------------------------------------------------------
 .../controllers/global/cluster_controller.js    |  1 -
 .../controllers/main/admin/access_controller.js | 51 +++++++++++++++++---
 ambari-web/app/routes/main.js                   | 20 ++++----
 ambari-web/app/templates/main/admin/access.hbs  |  2 +-
 ambari-web/app/utils/db.js                      | 19 --------
 ambari-web/app/views/main/admin/access_view.js  |  5 +-
 ambari-web/app/views/main/menu.js               |  3 +-
 7 files changed, 58 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/917807d0/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index e2b678e..72eeae3 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -347,7 +347,6 @@ App.ClusterController = Em.Controller.extend({
       }, true);
       App.router.get('updateController').updateServiceMetric(function () {}, true);
     });
-
   },
   /**
    * json from serviceMetricsMapper on initial load

http://git-wip-us.apache.org/repos/asf/ambari/blob/917807d0/ambari-web/app/controllers/main/admin/access_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/access_controller.js b/ambari-web/app/controllers/main/admin/access_controller.js
index 452e660..6e0e2c3 100644
--- a/ambari-web/app/controllers/main/admin/access_controller.js
+++ b/ambari-web/app/controllers/main/admin/access_controller.js
@@ -18,20 +18,55 @@
 
 var App = require('app');
 
-App.MainAdminAccessController = Em.Controller.extend({
+App.MainAdminAccessController = Em.Controller.extend(App.UserPref, {
   name:'mainAdminAccessController',
 
+  /**
+   * Show jobs by default
+   * @type {bool}
+   */
   showJobs: true,
 
-  /* Handle Save button click event*/
+  /**
+   * User pref request should be sync
+   * @type {bool}
+   */
+  makeRequestAsync: false,
+
+  /**
+   * User pref key
+   * @type {string}
+   */
+  persistKey: 'showJobsForNonAdmin',
+
+  /**
+   * Handle Save button click event
+   */
   save: function() {
-    App.db.setShowJobsForNonAdmin(this.get('showJobs'));
-    App.clusterStatus.setClusterStatus({
-      localdb: App.db.data
+    this.postUserPref(this.get('persistKey'), this.get('showJobs'));
+  },
+
+  loadShowJobsForUsers: function () {
+    var dfd = $.Deferred();
+    this.getUserPref(this.get('persistKey')).done(function (value) {
+      dfd.resolve(value);
+    }).fail(function(value) {
+      dfd.resolve(value);
     });
+    return dfd.promise();
   },
 
-  loadData: function() {
-    this.set('showJobs',  App.db.getShowJobsForNonAdmin());
+  getUserPrefSuccessCallback: function (data) {
+    this.set('showJobs', data);
+    return data;
+  },
+
+  getUserPrefErrorCallback: function () {
+    if (App.get('isAdmin')) {
+      this.postUserPref(this.get('persistKey'), true);
+    }
+    this.set('showJobs', true);
+    return true;
   }
-});
+
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/917807d0/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index 0331551..f547cb1 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -25,17 +25,19 @@ module.exports = Em.Route.extend({
     App.db.updateStorage();
     console.log('in /main:enter');
     if (router.getAuthenticated()) {
-      App.router.get('clusterController').loadClusterName(false);
-      if(App.testMode){
-        router.get('mainController').initialize();
-      }else{
-        App.router.get('clusterController').loadClientServerClockDistance().done(function()
{
+      App.router.get('mainAdminAccessController').loadShowJobsForUsers().done(function()
{
+        App.router.get('clusterController').loadClusterName(false);
+        if(App.testMode) {
           router.get('mainController').initialize();
-        });
-      }
+        }else {
+          App.router.get('clusterController').loadClientServerClockDistance().done(function()
{
+            router.get('mainController').initialize();
+          });
+        }
+      });
       // TODO: redirect to last known state
     } else {
-      Ember.run.next(function () {
+      Em.run.next(function () {
         router.transitionTo('login');
       });
     }
@@ -120,7 +122,7 @@ module.exports = Em.Route.extend({
   jobs : Em.Route.extend({
     route : '/jobs',
     enter: function (router) {
-      if(!App.db.getShowJobsForNonAdmin() && !App.get('isAdmin')){
+      if(!App.router.get('mainAdminAccessController.showJobs') && !App.get('isAdmin')){
         Em.run.next(function () {
           router.transitionTo('main.dashboard');
         });

http://git-wip-us.apache.org/repos/asf/ambari/blob/917807d0/ambari-web/app/templates/main/admin/access.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/access.hbs b/ambari-web/app/templates/main/admin/access.hbs
index eda62c3..a4a870a 100644
--- a/ambari-web/app/templates/main/admin/access.hbs
+++ b/ambari-web/app/templates/main/admin/access.hbs
@@ -21,7 +21,7 @@
   </div>
   <div class="acces-values">
       <label>
-        {{view Ember.Checkbox checkedBinding="showJobs" class="checkbox"}}
+        {{view Ember.Checkbox checkedBinding="controller.showJobs" class="checkbox"}}
         {{t admin.access.showJobs}}
       </label>
   </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/917807d0/ambari-web/app/utils/db.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/db.js b/ambari-web/app/utils/db.js
index 9647bd0..c8cc976 100644
--- a/ambari-web/app/utils/db.js
+++ b/ambari-web/app/utils/db.js
@@ -27,9 +27,6 @@ var InitialData =  {
       'displayLength': {},
       'startIndex': {},
       'sortingConditions': {}
-    },
-    'access': {
-      'showJobsForNonAdmin': ''
     }
   },
 
@@ -179,13 +176,6 @@ App.db.setDisplayLength = function(name, displayLength) {
   localStorage.setObject('ambari', App.db.data);
 };
 
-App.db.setShowJobsForNonAdmin = function(showJobsForNonAdmin) {
-  console.log('TRACE: Entering db:setShowJobsForNonAdmin function');
-  App.db.data = localStorage.getObject('ambari');
-  App.db.data.app.access.showJobsForNonAdmin = showJobsForNonAdmin;
-  localStorage.setObject('ambari', App.db.data);
-};
-
 App.db.setStartIndex = function(name, startIndex) {
   console.log('TRACE: Entering db:setStartIndex function');
   App.db.data = localStorage.getObject('ambari');
@@ -564,15 +554,6 @@ App.db.getDisplayLength = function(name) {
   return null;
 };
 
-App.db.getShowJobsForNonAdmin = function() {
-  console.log('TRACE: Entering db:getShowJobsForNonAdmin function');
-  App.db.data = localStorage.getObject('ambari');
-  if (App.db.data.app.access && typeof (App.db.data.app.access.showJobsForNonAdmin)
==  "boolean") {
-    return App.db.data.app.access.showJobsForNonAdmin;
-  }
-  return true;
-};
-
 App.db.getStartIndex = function(name) {
   console.log('TRACE: Entering db:getStartIndex function');
   App.db.data = localStorage.getObject('ambari');

http://git-wip-us.apache.org/repos/asf/ambari/blob/917807d0/ambari-web/app/views/main/admin/access_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/access_view.js b/ambari-web/app/views/main/admin/access_view.js
index 12c0591..2fbf46e 100644
--- a/ambari-web/app/views/main/admin/access_view.js
+++ b/ambari-web/app/views/main/admin/access_view.js
@@ -19,8 +19,5 @@
 var App = require('app');
 
 App.MainAdminAccessView = Em.View.extend({
-  templateName: require('templates/main/admin/access'),
-  didInsertElement: function() {
-    this.get('controller').loadData();
-  }
+  templateName: require('templates/main/admin/access')
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/917807d0/ambari-web/app/views/main/menu.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/menu.js b/ambari-web/app/views/main/menu.js
index daf5468..e703324 100644
--- a/ambari-web/app/views/main/menu.js
+++ b/ambari-web/app/views/main/menu.js
@@ -39,7 +39,8 @@ App.MainMenuView = Em.CollectionView.extend({
 
     if (!App.get('isHadoop2Stack')) {
       result.push({ label:Em.I18n.t('menu.item.jobs'), routing:'apps'});
-    } else if( App.router.get('mainAdminController.isAccessAvailable') && App.supports.jobs
&& (App.db.getShowJobsForNonAdmin() || App.get('isAdmin'))) {
+    } else if( App.router.get('mainAdminController.isAccessAvailable') && App.supports.jobs
+      && (App.router.get('mainAdminAccessController.showJobs') || App.get('isAdmin')))
{
       result.push({ label:Em.I18n.t('menu.item.jobs'), routing:'jobs'});
     }
 


Mime
View raw message