ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [34/37] git commit: AMBARI-7479. 'Manage Ambari' option is available for non-admin user after page reload (Ievgen Fialkovskyi via alejandro)
Date Wed, 24 Sep 2014 20:53:33 GMT
AMBARI-7479. 'Manage Ambari' option is available for non-admin user after page reload (Ievgen
Fialkovskyi via alejandro)


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

Branch: refs/heads/branch-alerts-dev
Commit: ddf92be12a7f874a291f67aabf23d28639b3ca60
Parents: 45ddf9f
Author: Alejandro Fernandez <afernandez@hortonworks.com>
Authored: Wed Sep 24 12:42:31 2014 -0700
Committer: Alejandro Fernandez <afernandez@hortonworks.com>
Committed: Wed Sep 24 12:46:45 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/mappers/users_mapper.js | 12 ++++++++++++
 ambari-web/app/models/user.js          |  1 +
 ambari-web/app/router.js               | 14 +++++++++++---
 3 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf92be1/ambari-web/app/mappers/users_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/users_mapper.js b/ambari-web/app/mappers/users_mapper.js
index 0f86ef6..00ac6c3 100644
--- a/ambari-web/app/mappers/users_mapper.js
+++ b/ambari-web/app/mappers/users_mapper.js
@@ -25,6 +25,7 @@ App.usersMapper = App.QuickDataMapper.create({
     user_name : 'Users.user_name',
     is_ldap: 'Users.ldap_user',
     admin: 'Users.admin',
+    operator: 'Users.operator',
     permissions: 'permissions'
   },
   map: function (json) {
@@ -37,6 +38,7 @@ App.usersMapper = App.QuickDataMapper.create({
           item.permissions = item.privileges.items.mapProperty('PrivilegeInfo.permission_name');
         }
         item.Users.admin = self.isAdmin(item.permissions);
+        item.Users.operator = self.isOperator(item.permissions);
         result.push(self.parseIt(item, self.config));
         App.store.loadMany(self.get('model'), result);
       }
@@ -49,6 +51,16 @@ App.usersMapper = App.QuickDataMapper.create({
    * @return {Boolean}
    **/
   isAdmin: function(permissionList) {
+    //TODO: Separate cluster operator from admin
     return permissionList.indexOf('AMBARI.ADMIN') > -1 || permissionList.indexOf('CLUSTER.OPERATE')
> -1;
+  },
+
+  /**
+   * Check if user is operator.
+   * @param {Array} permissionList
+   * @return {Boolean}
+   **/
+  isOperator: function(permissionList) {
+    return permissionList.indexOf('CLUSTER.OPERATE') > -1;
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf92be1/ambari-web/app/models/user.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/user.js b/ambari-web/app/models/user.js
index d8729e2..f51d07c 100644
--- a/ambari-web/app/models/user.js
+++ b/ambari-web/app/models/user.js
@@ -33,6 +33,7 @@ App.User = DS.Model.extend({
   }.property('isLdap'),
   auditItems:DS.hasMany('App.ServiceAudit'),
   admin: DS.attr('boolean'),
+  operator: DS.attr('boolean'),
   /**
    * List of permissions assigned to user
    *  Available permissions:

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf92be1/ambari-web/app/router.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js
index bbc06dd..997fd68 100644
--- a/ambari-web/app/router.js
+++ b/ambari-web/app/router.js
@@ -413,9 +413,17 @@ App.Router = Em.Router.extend({
    * initialize isAdmin if user is administrator
    */
   initAdmin: function(){
-    if(App.db && App.db.getUser() && App.db.getUser().admin) {
-      App.set('isAdmin', true);
-      console.log('Administrator logged in');
+    if (App.db) {
+      var user = App.db.getUser();
+      if (user) {
+        if (user.admin) {
+          App.set('isAdmin', true);
+          console.log('Administrator logged in');
+        }
+        if (user.operator) {
+          App.set('isOperator', true);
+        }
+      }
     }
   },
 


Mime
View raw message