You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2016/03/02 23:20:05 UTC

[1/3] ambari git commit: AMBARI-15264. Ambari Admin: incorrect alerts on Roles page (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 06747adfd -> e347aef42


AMBARI-15264. Ambari Admin: incorrect alerts on Roles page (alexantonenko)


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

Branch: refs/heads/trunk
Commit: e347aef4236c8abd0f31ae37c27b36c65854ffde
Parents: 235e8e7
Author: Alex Antonenko <hi...@gmail.com>
Authored: Wed Mar 2 18:32:16 2016 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Mar 3 00:20:01 2016 +0200

----------------------------------------------------------------------
 .../controllers/clusters/UserAccessListCtrl.js  |  11 +-
 .../ui/admin-web/app/scripts/i18n.config.js     |   3 +-
 .../clusters/UserAccessListCtrl_test.js         | 198 ++++++++++++++++++-
 3 files changed, 207 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e347aef4/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/clusters/UserAccessListCtrl.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/clusters/UserAccessListCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/clusters/UserAccessListCtrl.js
index 17dac40..50a2dab 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/clusters/UserAccessListCtrl.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/clusters/UserAccessListCtrl.js
@@ -81,6 +81,12 @@ function($scope, $location, Cluster, $modal, $rootScope, $routeParams, Permissio
 
   // TODO change to PUT after it's available
   $scope.save = function(user) {
+    for (var i = $scope.roles.length; i--;) {
+      if ($scope.roles[i].permission_name === user.permission_name) {
+        user.permission_label = $scope.roles[i].permission_label;
+        break;
+      }
+    }
     Cluster.deletePrivilege(
     $routeParams.id,
     user.privilege_id
@@ -96,7 +102,10 @@ function($scope, $location, Cluster, $modal, $rootScope, $routeParams, Permissio
           principal_type: user.principal_type
         }}]
         ).then(function() {
-          Alert.success(user.principal_name + " changed to " + user.permission_label);
+          Alert.success($t('users.alerts.roleChanged', {
+            name: user.principal_name,
+            role: user.permission_label
+          }));
           $scope.loadUsers();
         })
         .catch(function(data) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e347aef4/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
index ce0ff41..e12e897 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
@@ -294,7 +294,8 @@ angular.module('ambariAdminConsole')
         'removeUserError': 'Removing from group error',
         'cannotAddUser': 'Cannot add user to group',
         'passwordChanged': 'Password changed.',
-        'cannotChangePassword': 'Cannot change password'
+        'cannotChangePassword': 'Cannot change password',
+        'roleChanged': '{{name}} changed to {{role}}'
       }
     },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e347aef4/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/clusters/UserAccessListCtrl_test.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/clusters/UserAccessListCtrl_test.js b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/clusters/UserAccessListCtrl_test.js
index 6f28aa5..8239653 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/clusters/UserAccessListCtrl_test.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/clusters/UserAccessListCtrl_test.js
@@ -20,17 +20,37 @@ describe('#Cluster', function () {
 
   describe('UserAccessListCtrl', function() {
 
-    var scope, ctrl, $t, $httpBackend;
+    var scope, ctrl, $t, $httpBackend, Cluster, deferred, Alert, mock;
 
     beforeEach(module('ambariAdminConsole', function () {}));
 
-    beforeEach(inject(function($rootScope, $controller, _$translate_, _$httpBackend_) {
+    beforeEach(inject(function($rootScope, $controller, _$translate_, _$httpBackend_, _Cluster_, _$q_, _Alert_) {
       scope = $rootScope.$new();
       $t = _$translate_.instant;
       $httpBackend = _$httpBackend_;
+      Cluster = _Cluster_;
+      Alert = _Alert_;
+      deferred = {
+        deletePrivilege: _$q_.defer(),
+        createPrivileges: _$q_.defer()
+      };
       ctrl = $controller('UserAccessListCtrl', {
         $scope: scope
       });
+      mock = {
+        Cluster: Cluster,
+        Alert: Alert,
+        scope: scope
+      };
+      spyOn(Cluster, 'deletePrivilege').andReturn(deferred.deletePrivilege.promise);
+      spyOn(Cluster, 'createPrivileges').andReturn(deferred.createPrivileges.promise);
+      spyOn(Alert, 'success').andCallFake(angular.noop);
+      spyOn(Alert, 'error').andCallFake(angular.noop);
+      spyOn(scope, 'loadRoles').andCallFake(angular.noop);
+      $httpBackend.expectGET(/\/api\/v1\/clusters\/\w+\/privileges/).respond(200, {
+        items: []
+      });
+      $httpBackend.flush();
     }));
 
     describe('#clearFilters()', function () {
@@ -207,7 +227,6 @@ describe('#Cluster', function () {
 
       cases.forEach(function (item) {
         it(item.title, function () {
-          $httpBackend.expectGET(/\/api\/v1\/clusters\/\w+\/privileges/).respond(200);
           scope.currentNameFilter = item.currentNameFilter;
           scope.currentRoleFilter = item.currentRoleFilter;
           scope.currentTypeFilter = item.currentTypeFilter;
@@ -218,6 +237,179 @@ describe('#Cluster', function () {
 
     });
 
+    describe('#save()', function () {
+
+      var user,
+        labelCases = [
+          {
+            roles: [],
+            label: '',
+            title: 'roles not loaded'
+          },
+          {
+            roles: [
+              {
+                permission_name: 'CLUSTER.OPERATOR',
+                permission_label: 'Cluster Operator'
+              },
+              {
+                permission_name: 'CLUSTER.ADMINISTRATOR',
+                permission_label: 'Cluster Administrator'
+              }
+            ],
+            label: '',
+            title: 'no roles match'
+          },
+          {
+            roles: [
+              {
+                permission_name: 'CLUSTER.USER',
+                permission_label: 'Cluster User'
+              },
+              {
+                permission_name: 'CLUSTER.OPERATOR',
+                permission_label: 'Cluster Operator'
+              },
+              {
+                permission_name: 'CLUSTER.ADMINISTRATOR',
+                permission_label: 'Cluster Administrator'
+              }
+            ],
+            label: 'Cluster User',
+            title: 'roles not loaded'
+          }
+        ],
+        deferredCases = [
+          {
+            success: ['deletePrivilege', 'createPrivileges'],
+            fail: [],
+            called: [
+              {
+                context: 'Cluster',
+                methodName: 'createPrivileges'
+              },
+              {
+                context: 'Alert',
+                methodName: 'success'
+              }
+            ],
+            notCalled: [
+              {
+                context: 'Alert',
+                methodName: 'error'
+              }
+            ],
+            title: 'all requests are successful'
+          },
+          {
+            success: ['deletePrivilege'],
+            fail: ['createPrivileges'],
+            called: [
+              {
+                context: 'Cluster',
+                methodName: 'createPrivileges'
+              },
+              {
+                context: 'Alert',
+                methodName: 'error'
+              }
+            ],
+            notCalled: [
+              {
+                context: 'Alert',
+                methodName: 'success'
+              }
+            ],
+            title: 'new role request failed'
+          },
+          {
+            success: [],
+            fail: ['deletePrivilege'],
+            called: [],
+            notCalled: [
+              {
+                context: 'Cluster',
+                methodName: 'createPrivileges'
+              },
+              {
+                context: 'Alert',
+                methodName: 'success'
+              },
+              {
+                context: 'Alert',
+                methodName: 'error'
+              }
+            ],
+            title: 'delete current role request failed'
+          }
+        ];
+
+      beforeEach(function () {
+        user = {
+          permission_name: 'CLUSTER.USER',
+          permission_label: ''
+        };
+      });
+
+      labelCases.forEach(function (item) {
+
+        it(item.title, function () {
+          scope.roles = item.roles;
+          scope.save(user);
+          expect(user.permission_label).toEqual(item.label);
+        });
+
+      });
+
+      deferredCases.forEach(function (item) {
+
+        describe(item.title, function () {
+
+          beforeEach(function () {
+            scope.roles = [];
+            scope.save(user);
+            item.success.forEach(function (method) {
+              deferred[method].resolve();
+            });
+            item.fail.forEach(function (method) {
+              deferred[method].reject({
+                data: {
+                  data: {}
+                }
+              });
+            });
+            $httpBackend.expectGET(/\/api\/v1\/clusters\/\w+\/privileges/).respond(200, {
+              items: []
+            });
+            scope.$digest();
+          });
+
+          it('Cluster.deletePrivileges', function () {
+            expect(Cluster.deletePrivilege).toHaveBeenCalled();
+          });
+
+          it('scope.loadRoles', function () {
+            expect(scope.loadRoles).toHaveBeenCalled();
+          });
+
+          item.called.forEach(function (method) {
+            it(method.context + '.' + method.methodName, function () {
+              expect(mock[method.context][method.methodName]).toHaveBeenCalled();
+            });
+          });
+
+          item.notCalled.forEach(function (method) {
+            it(method.context + '.' + method.methodName, function () {
+              expect(mock[method.context][method.methodName]).not.toHaveBeenCalled();
+            });
+          });
+
+        });
+
+      });
+
+    });
+
   });
 
 });


[3/3] ambari git commit: AMBARI-15261. Hide Admin Settings / Login Message features (alexantonenko)

Posted by al...@apache.org.
AMBARI-15261. Hide Admin Settings / Login Message features (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 9df2eb74e517c59c5c2149712b0198d52ce9cc1f
Parents: 06747ad
Author: Alex Antonenko <hi...@gmail.com>
Authored: Wed Mar 2 16:11:59 2016 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Mar 3 00:20:01 2016 +0200

----------------------------------------------------------------------
 ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js | 3 ++-
 .../src/main/resources/ui/admin-web/app/scripts/routes.js       | 5 +++++
 .../src/main/resources/ui/admin-web/app/views/leftNavbar.html   | 4 ++--
 3 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9df2eb74/ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js
index a0c0323..63aa4eb 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/app.js
@@ -29,7 +29,8 @@ angular.module('ambariAdminConsole', [
 	baseUrl: '/api/v1',
   testMode: (window.location.port == 8000),
   mockDataPrefix: 'assets/data/',
-  isLDAPConfigurationSupported: false
+  isLDAPConfigurationSupported: false,
+  isLoginActivitiesSupported: false
 })
 .config(['RestangularProvider', '$httpProvider', '$provide', function(RestangularProvider, $httpProvider, $provide) {
   // Config Ajax-module

http://git-wip-us.apache.org/repos/asf/ambari/blob/9df2eb74/ambari-admin/src/main/resources/ui/admin-web/app/scripts/routes.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/routes.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/routes.js
index 8901738..4fc4ea6 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/routes.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/routes.js
@@ -154,4 +154,9 @@ angular.module('ambariAdminConsole')
       e.preventDefault();
     }
   });
+  $rootScope.$on('$locationChangeStart', function (e, nextUrl) {
+    if ((/\/loginMessage$/.test(nextUrl) || /\/homeDirectory$/.test(nextUrl)) && !Settings.isLoginActivitiesSupported) {
+      e.preventDefault();
+    }
+  });
 }]);

http://git-wip-us.apache.org/repos/asf/ambari/blob/9df2eb74/ambari-admin/src/main/resources/ui/admin-web/app/views/leftNavbar.html
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/leftNavbar.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/leftNavbar.html
index 1646d7c..3bb89ba 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/views/leftNavbar.html
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/leftNavbar.html
@@ -105,12 +105,12 @@
     </div>
   </div>
 
-  <div class="panel panel-default">
+  <div class="panel panel-default" ng-show="settings.isLoginActivitiesSupported || settings.isLDAPConfigurationSupported">
     <div class="panel-heading"><span class="glyphicon glyphicon-cog"></span> {{'common.settings' | translate}}</div>
     <div class="panel-body">
       <ul class="nav nav-pills nav-stacked">
         <li ng-class="{active: isActive('authentication.main')}" ng-show="settings.isLDAPConfigurationSupported"><link-to route="authentication.main">{{'common.authentication' | translate}}</link-to></li>
-        <li ng-class="{active: isActive('loginActivities.loginMessage')}"><link-to route="loginActivities.loginMessage">{{'common.loginActivities.loginActivities' | translate}}</link-to></li>
+        <li ng-class="{active: isActive('loginActivities.loginMessage')}" ng-show="settings.isLoginActivitiesSupported"><link-to route="loginActivities.loginMessage">{{'common.loginActivities.loginActivities' | translate}}</link-to></li>
       </ul>
     </div>
   </div>


[2/3] ambari git commit: AMBARI-15263. Ambari Admin: redundant scrollbars in Contents section of Version page (alexantonenko)

Posted by al...@apache.org.
AMBARI-15263. Ambari Admin: redundant scrollbars in Contents section of Version page (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 235e8e7ed0947e6c4d7f243e3bee3b8f1d04c928
Parents: 9df2eb7
Author: Alex Antonenko <hi...@gmail.com>
Authored: Wed Mar 2 18:28:47 2016 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Mar 3 00:20:01 2016 +0200

----------------------------------------------------------------------
 ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/235e8e7e/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css b/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css
index bf4b610..e4db617 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css
@@ -1461,7 +1461,7 @@ thead.view-permission-header > tr > th {
 
 .register-version-form .contents-panel .version-contents-body {
     max-height: 150px;
-    overflow: scroll;
+    overflow: auto;
 }
 
 .register-version-form .repos-panel .remove-icon {