AMBARI-18476: Ambari UI changes to support PAM authentication (Sangeeta Ravindran via dili)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/745d1057 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/745d1057 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/745d1057 Branch: refs/heads/branch-feature-AMBARI-18901 Commit: 745d1057b04f1ecf8a089d437e49a1ef672c2090 Parents: 49d6d88 Author: Di Li <[email protected]> Authored: Wed Nov 16 13:03:29 2016 -0500 Committer: Di Li <[email protected]> Committed: Wed Nov 16 13:03:29 2016 -0500 ---------------------------------------------------------------------- .../main/resources/ui/admin-web/app/index.html | 1 + .../controllers/groups/GroupsEditCtrl.js | 5 ++- .../controllers/groups/GroupsListCtrl.js | 18 +++++----- .../scripts/controllers/users/UsersShowCtrl.js | 8 ++++- .../ui/admin-web/app/scripts/i18n.config.js | 1 + .../ui/admin-web/app/scripts/services/Group.js | 33 +++++++++++++++-- .../app/scripts/services/GroupConstants.js | 38 ++++++++++++++++++++ .../app/scripts/services/UserConstants.js | 4 +++ .../ui/admin-web/app/views/groups/edit.html | 8 ++--- .../ui/admin-web/app/views/groups/list.html | 2 +- .../ui/admin-web/app/views/users/show.html | 8 ++--- 11 files changed, 105 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/ambari-admin/src/main/resources/ui/admin-web/app/index.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/index.html b/ambari-admin/src/main/resources/ui/admin-web/app/index.html index b3f1bd1..ba16103 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/index.html +++ b/ambari-admin/src/main/resources/ui/admin-web/app/index.html @@ -159,6 +159,7 @@ <script src="scripts/services/Utility.js"></script> <script src="scripts/services/UserConstants.js"></script> <script src="scripts/services/User.js"></script> +<script src="scripts/services/GroupConstants.js"></script> <script src="scripts/services/Group.js"></script> <script src="scripts/services/RemoteCluster.js"></script> <script src="scripts/services/View.js"></script> http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/groups/GroupsEditCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/groups/GroupsEditCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/groups/GroupsEditCtrl.js index 2e7830b..aa6af2a 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/groups/GroupsEditCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/groups/GroupsEditCtrl.js @@ -18,7 +18,7 @@ 'use strict'; angular.module('ambariAdminConsole') -.controller('GroupsEditCtrl',['$scope', 'Group', '$routeParams', 'Cluster', 'View', 'Alert', 'ConfirmationModal', '$location', '$translate', function($scope, Group, $routeParams, Cluster, View, Alert, ConfirmationModal, $location, $translate) { +.controller('GroupsEditCtrl',['$scope', 'Group', '$routeParams', 'Cluster', 'View', 'Alert', 'ConfirmationModal', '$location', 'GroupConstants', '$translate', function($scope, Group, $routeParams, Cluster, View, Alert, ConfirmationModal, $location, GroupConstants, $translate) { var $t = $translate.instant; $scope.constants = { group: $t('common.group'), @@ -68,6 +68,7 @@ angular.module('ambariAdminConsole') function loadMembers(){ $scope.group.getMembers().then(function(members) { + $scope.group.groupTypeName = $t(GroupConstants.TYPES[$scope.group.group_type].LABEL_KEY); $scope.groupMembers = members; $scope.group.editingUsers = angular.copy($scope.groupMembers); }); @@ -78,6 +79,8 @@ angular.module('ambariAdminConsole') loadMembers(); }); + $scope.group.getGroupType(); + $scope.deleteGroup = function(group) { ConfirmationModal.show( $t('common.delete', { http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/groups/GroupsListCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/groups/GroupsListCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/groups/GroupsListCtrl.js index 1f86393..948b707 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/groups/GroupsListCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/groups/GroupsListCtrl.js @@ -18,7 +18,7 @@ 'use strict'; angular.module('ambariAdminConsole') -.controller('GroupsListCtrl',['$scope', 'Group', '$modal', 'ConfirmationModal', '$rootScope', '$translate', function($scope, Group, $modal, ConfirmationModal, $rootScope, $translate) { +.controller('GroupsListCtrl',['$scope', 'Group', '$modal', 'ConfirmationModal', '$rootScope', 'GroupConstants', '$translate', function($scope, Group, $modal, ConfirmationModal, $rootScope, GroupConstants, $translate) { var $t = $translate.instant; $scope.constants = { groups: $t('common.groups').toLowerCase() @@ -53,10 +53,10 @@ angular.module('ambariAdminConsole') currentPage: $scope.currentPage, groupsPerPage: $scope.groupsPerPage, searchString: $scope.currentNameFilter, - ldap_group: $scope.currentTypeFilter.value + group_type: $scope.currentTypeFilter.value }).then(function(groups) { $scope.totalGroups = groups.itemTotal; - $scope.groups = groups; + $scope.groups = groups.map(Group.makeGroup); $scope.tableInfo.total = groups.itemTotal; $scope.tableInfo.showed = groups.length; }) @@ -65,11 +65,13 @@ angular.module('ambariAdminConsole') }); } - $scope.typeFilterOptions = [ - {label: $t('common.all'), value:'*'}, - {label: $t('common.local'), value: false}, - {label: $t('common.ldap'), value:true} - ]; + $scope.typeFilterOptions = [{ label: $t('common.all'), value: '*'}] + .concat(Object.keys(GroupConstants.TYPES).map(function(key) { + return { + label: $t(GroupConstants.TYPES[key].LABEL_KEY), + value: GroupConstants.TYPES[key].VALUE + }; + })); $scope.currentTypeFilter = $scope.typeFilterOptions[0]; $scope.clearFilters = function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/users/UsersShowCtrl.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/users/UsersShowCtrl.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/users/UsersShowCtrl.js index f7ed7ee..3839876 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/users/UsersShowCtrl.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/users/UsersShowCtrl.js @@ -18,7 +18,7 @@ 'use strict'; angular.module('ambariAdminConsole') -.controller('UsersShowCtrl', ['$scope', '$routeParams', 'Cluster', 'User', 'View', '$modal', '$location', 'ConfirmationModal', 'Alert', 'Auth', 'getDifference', 'Group', '$q', '$translate', function($scope, $routeParams, Cluster, User, View, $modal, $location, ConfirmationModal, Alert, Auth, getDifference, Group, $q, $translate) { +.controller('UsersShowCtrl', ['$scope', '$routeParams', 'Cluster', 'User', 'View', '$modal', '$location', 'ConfirmationModal', 'Alert', 'Auth', 'getDifference', 'Group', '$q', 'UserConstants', '$translate', function($scope, $routeParams, Cluster, User, View, $modal, $location, ConfirmationModal, Alert, Auth, getDifference, Group, $q, UserConstants, $translate) { var $t = $translate.instant; @@ -82,6 +82,12 @@ angular.module('ambariAdminConsole') $scope.isGroupEditing = false; }; + $scope.getUserMembership = function(userType) { + if(userType) { + return $t(UserConstants.TYPES[userType].LABEL_KEY) + " " + $t('users.groupMembership'); + } + }; + $scope.cancelUpdate = function() { $scope.isGroupEditing = false; $scope.editingGroupsList = ''; http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/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 cd9b922..bcd3681 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 @@ -81,6 +81,7 @@ angular.module('ambariAdminConsole') 'remoteClusterDelConfirmation':'Are you sure you want to delete {{instanceType}} {{instanceName}}? This operation cannot be undone.', 'messageInstanceAffected':'The following View Instances are using this Remote Cluster for configuration, and will need to be reconfigured: {{viewInstance}}', 'local': 'Local', + 'pam': 'PAM', 'ldap': 'LDAP', 'jwt': 'JWT', 'warning': 'Warning', http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Group.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Group.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Group.js index 660306c..f52a7e5 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Group.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Group.js @@ -18,7 +18,8 @@ 'use strict'; angular.module('ambariAdminConsole') -.factory('Group', ['$http', '$q', 'Settings', function($http, $q, Settings) { +.factory('Group', ['$http', '$q', 'Settings', 'GroupConstants', '$translate', function($http, $q, Settings, GroupConstants, $translate) { + var $t = $translate.instant; function Group(item){ if(typeof item === 'string'){ this.group_name = item; @@ -47,6 +48,21 @@ angular.module('ambariAdminConsole') return deferred.promise; } + Group.prototype.getGroupType = function() { + var deferred = $q.defer(); + var self = this; + $http({ + method: 'GET', + url: Settings.baseUrl + '/groups/'+this.group_name + }). + success(function(data) { + self.group_type = data.Groups.group_type; + deferred.resolve(self.group_type); + }); + + return deferred.promise; + } + Group.prototype.save = function() { return $http({ method : 'POST', @@ -155,7 +171,7 @@ angular.module('ambariAdminConsole') + '&fields=*' + '&from='+ (params.currentPage-1)*params.groupsPerPage + '&page_size=' + params.groupsPerPage - + (params.ldap_group === '*' ? '' : '&Groups/ldap_group='+params.ldap_group) + + (params.group_type === '*' ? '' : '&Groups/group_type=' + params.group_type) ) .success(function(data) { var groups = []; @@ -188,5 +204,18 @@ angular.module('ambariAdminConsole') }); }; + /** + * Generate group info to display by response data from API. + * Generally this is a single point to manage all required and useful data + * needed to use as context for views/controllers. + * + * @param {Object} group - object from API response + * @returns {Object} + */ + Group.makeGroup = function(group) { + group.groupTypeName = $t(GroupConstants.TYPES[group.group_type].LABEL_KEY); + return group; + }; + return Group; }]); http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/GroupConstants.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/GroupConstants.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/GroupConstants.js new file mode 100644 index 0000000..42e8d73 --- /dev/null +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/GroupConstants.js @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict'; + +angular.module('ambariAdminConsole').constant('GroupConstants', { + /** + * Available group_types 'values' and 'labels' map. + */ + TYPES: { + LOCAL: { + VALUE: 'LOCAL', + LABEL_KEY: 'common.local' + }, + PAM: { + VALUE: 'PAM', + LABEL_KEY: 'common.pam' + }, + LDAP: { + VALUE: 'LDAP', + LABEL_KEY: 'common.ldap' + } + } +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/UserConstants.js ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/UserConstants.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/UserConstants.js index da63c6d..db0f32d 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/UserConstants.js +++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/UserConstants.js @@ -26,6 +26,10 @@ angular.module('ambariAdminConsole').constant('UserConstants', { VALUE: 'LOCAL', LABEL_KEY: 'common.local' }, + PAM: { + VALUE: 'PAM', + LABEL_KEY: 'common.pam' + }, LDAP: { VALUE: 'LDAP', LABEL_KEY: 'common.ldap' http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/ambari-admin/src/main/resources/ui/admin-web/app/views/groups/edit.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/groups/edit.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/groups/edit.html index 78a6884..e472ede8 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/views/groups/edit.html +++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/groups/edit.html @@ -22,7 +22,7 @@ <li class="active">{{group.group_name}}</li> </ol> <div class="pull-right top-margin-4"> - <div ng-switch="group.ldap_group"> + <div ng-switch="group.group_type != 'LOCAL'"> <button ng-switch-when="true" class="btn disabled deletegroup-btn deleteuser-btn" tooltip="{{'common.cannotDelete' | translate: '{term: constants.group}'}}">{{'common.delete' | translate: '{term: constants.group}'}}</button> <button ng-switch-when="false" class="btn btn-danger deletegroup-btn" ng-click="deleteGroup(group)">{{'common.delete' | translate: '{term: constants.group}'}}</button> </div> @@ -34,13 +34,13 @@ <div class="form-group"> <label for="" class="col-sm-2 control-label">{{'common.type' | translate}}</label> <div class="col-sm-10"> - <label for="" class="control-label">{{'common.' + (group.ldap_group ? 'ldap' : 'local') | translate}}</label> + <label for="" class="control-label">{{group.groupTypeName | translate}}</label> </div> </div> <div class="form-group"> - <label for="members" class="col-sm-2 control-label">{{'common.' + (group.ldap_group ? 'ldap' : 'local') | translate}} {{'groups.members' | translate}}</label> + <label for="members" class="col-sm-2 control-label">{{group.groupTypeName | translate}} {{'groups.members' | translate}}</label> <div class="col-sm-10"> - <editable-list items-source="group.editingUsers" resource-type="User" editable="!group.ldap_group"></editable-list> + <editable-list items-source="group.editingUsers" resource-type="User" editable="group.group_type == 'LOCAL'"></editable-list> </div> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/ambari-admin/src/main/resources/ui/admin-web/app/views/groups/list.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/groups/list.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/groups/list.html index b359ede..6be6fdd 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/views/groups/list.html +++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/groups/list.html @@ -53,7 +53,7 @@ <td class="col-sm-8"> <link-to route="groups.edit" class="link-to-group" id="{{group.group_name}}">{{group.group_name}}</link-to> </td> - <td class="col-sm-2">{{'common.' + (group.ldap_group ? 'ldap' : 'local') | translate}}</td> + <td class="col-sm-2">{{group.groupTypeName | translate}}</td> <td class="col-sm-2">{{'groups.membersPlural' | translate: '{n: group.members && group.members.length || 0}'}}</td> </tr> </tbody> http://git-wip-us.apache.org/repos/asf/ambari/blob/745d1057/ambari-admin/src/main/resources/ui/admin-web/app/views/users/show.html ---------------------------------------------------------------------- diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/users/show.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/users/show.html index e576b28..7abdf05 100644 --- a/ambari-admin/src/main/resources/ui/admin-web/app/views/users/show.html +++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/users/show.html @@ -23,7 +23,7 @@ <li class="active"><span class="glyphicon glyphicon-flash" ng-show="user.admin"></span>{{user.user_name}}</li> </ol> <div class="pull-right top-margin-4"> - <div ng-switch="isCurrentUser || user.ldap_user"> + <div ng-switch="isCurrentUser || user.user_type != 'LOCAL'"> <button class="btn deleteuser-btn disabled btn-default" ng-switch-when="true" tooltip="{{'common.cannotDelete' | translate: '{term: constants.user}'}}">{{'common.delete' | translate: '{term: constants.user}'}}</button> <button class="btn deleteuser-btn btn-danger" ng-switch-when="false" ng-click="deleteUser()">{{'common.delete' | translate: '{term: constants.user}'}}</button> </div> @@ -52,7 +52,7 @@ <div class="form-group"> <label for="password" class="col-sm-2 control-label">{{'users.password' | translate}}</label> <div class="col-sm-10"> - <div ng-switch="user.ldap_user"> + <div ng-switch="user.user_type != 'LOCAL'"> <button class="btn deleteuser-btn disabled btn-default" ng-switch-when="true" tooltip="{{'users.alerts.cannotChange' | translate: '{term: constants.password}'}}">{{'users.changePassword' | translate}}</button> <a href ng-click="openChangePwdDialog()" ng-switch-when="false" class="btn btn-default changepassword">{{'users.changePassword' | translate}}</a> </div> @@ -60,9 +60,9 @@ </div> </div> <div class="form-group"> - <label for="groups" class="col-sm-2 control-label">{{'common.' + (user.ldap_user ? 'ldap' : 'local') | translate}} {{'users.groupMembership' | translate}}</label> + <label for="groups" class="col-sm-2 control-label">{{getUserMembership(user.user_type)}}</label> <div class="col-sm-10"> - <editable-list items-source="editingGroupsList" resource-type="Group" editable="!user.ldap_user"></editable-list> + <editable-list items-source="editingGroupsList" resource-type="Group" editable="user.user_type == 'LOCAL'"></editable-list> </div> </div>
