You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2016/12/01 18:20:46 UTC
ambari git commit: AMBARI-19052. Re-arrange "Role Based Access
Control" info table (akovalenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 63938e09c -> 63c0f2e58
AMBARI-19052. Re-arrange "Role Based Access Control" info table (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/63c0f2e5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/63c0f2e5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/63c0f2e5
Branch: refs/heads/trunk
Commit: 63c0f2e58fc09b709e890923752c4ccb04181180
Parents: 63938e0
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Thu Dec 1 19:22:02 2016 +0200
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Thu Dec 1 20:20:33 2016 +0200
----------------------------------------------------------------------
.../admin-web/app/scripts/services/Cluster.js | 51 --------------------
.../app/scripts/services/RoleDetailsModal.js | 31 +++++++-----
.../app/views/modals/RoleDetailsModal.html | 6 +--
3 files changed, 23 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/63c0f2e5/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js
index 02c231a..0f9b582 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Cluster.js
@@ -30,57 +30,6 @@ angular.module('ambariAdminConsole')
'CLUSTER.USER'
],
- orderedAuthorizations : [
- "SERVICE.VIEW_METRICS",
- "SERVICE.VIEW_STATUS_INFO",
- "SERVICE.VIEW_CONFIGS",
- "SERVICE.COMPARE_CONFIGS",
- "SERVICE.VIEW_ALERTS",
- "SERVICE.START_STOP",
- "SERVICE.DECOMMISSION_RECOMMISSION",
- "SERVICE.RUN_SERVICE_CHECK",
- "SERVICE.TOGGLE_MAINTENANCE",
- "SERVICE.RUN_CUSTOM_COMMAND",
- "SERVICE.MODIFY_CONFIGS",
- "SERVICE.MANAGE_CONFIG_GROUPS",
- "SERVICE.MOVE",
- "SERVICE.ENABLE_HA",
- "SERVICE.MANAGE_ALERTS",
- "SERVICE.TOGGLE_ALERTS",
- "SERVICE.ADD_DELETE_SERVICES",
- "SERVICE.VIEW_OPERATIONAL_LOGS",
- "HOST.VIEW_CONFIGS",
- "HOST.VIEW_METRICS",
- "HOST.VIEW_STATUS_INFO",
- "HOST.ADD_DELETE_COMPONENTS",
- "HOST.ADD_DELETE_HOSTS",
- "HOST.TOGGLE_MAINTENANCE",
- "CLUSTER.VIEW_ALERTS",
- "CLUSTER.VIEW_CONFIGS",
- "CLUSTER.VIEW_METRICS",
- "CLUSTER.VIEW_STACK_DETAILS",
- "CLUSTER.VIEW_STATUS_INFO",
- "CLUSTER.MANAGE_ALERTS",
- "CLUSTER.MANAGE_CONFIG_GROUPS",
- "CLUSTER.MANAGE_CREDENTIALS",
- "CLUSTER.MODIFY_CONFIGS",
- "CLUSTER.TOGGLE_ALERTS",
- "CLUSTER.TOGGLE_KERBEROS",
- "CLUSTER.UPGRADE_DOWNGRADE_STACK",
- "CLUSTER.RUN_CUSTOM_COMMAND",
- "AMBARI.ADD_DELETE_CLUSTERS",
- "AMBARI.ASSIGN_ROLES",
- "AMBARI.EDIT_STACK_REPOS",
- "AMBARI.MANAGE_GROUPS",
- "AMBARI.MANAGE_SETTINGS",
- "AMBARI.MANAGE_STACK_VERSIONS",
- "AMBARI.MANAGE_USERS",
- "AMBARI.MANAGE_VIEWS",
- "AMBARI.RENAME_CLUSTER",
- "AMBARI.RUN_CUSTOM_COMMAND",
- "SERVICE.SET_SERVICE_USERS_GROUPS"
- ],
-
orderedLevels: ['SERVICE', 'HOST', 'CLUSTER', 'AMBARI'],
ineditableRoles : ['VIEW.USER', 'AMBARI.ADMINISTRATOR'],
http://git-wip-us.apache.org/repos/asf/ambari/blob/63c0f2e5/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/RoleDetailsModal.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/RoleDetailsModal.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/RoleDetailsModal.js
index 5a14b33..06019c2 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/RoleDetailsModal.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/RoleDetailsModal.js
@@ -33,9 +33,9 @@ angular.module('ambariAdminConsole')
templateUrl: 'views/modals/RoleDetailsModal.html',
size: 'lg',
controller: function($scope, $modalInstance) {
+ var authorizationsOrder;
$scope.title = '';
$scope.orderedRoles = ['AMBARI.ADMINISTRATOR'].concat(Cluster.orderedRoles).reverse();
- $scope.orderedAuthorizations = Cluster.orderedAuthorizations;
$scope.orderedLevels = Cluster.orderedLevels;
$scope.authHash = {};
$scope.getLevelName = function (key) {
@@ -44,25 +44,34 @@ angular.module('ambariAdminConsole')
angular.forEach(roles, function (r) {
angular.forEach(r.authorizations, function (auth) {
var match = auth.authorization_id.match(/(\w+)\./),
- levelKey = match && match[1],
- isLevelDisplayed = $scope.orderedAuthorizations.some(function (item) {
- return !item.indexOf(levelKey);
- });
+ levelKey = match && match[1],
+ isLevelDisplayed = $scope.orderedLevels.indexOf(levelKey) !== -1;
if (isLevelDisplayed) {
if (!$scope.authHash[levelKey]) {
$scope.authHash[levelKey] = {};
}
if (!$scope.authHash[levelKey][auth.authorization_id]) {
- $scope.authHash[levelKey][auth.authorization_id] = auth.authorization_name;
+ $scope.authHash[levelKey][auth.authorization_id] = {
+ name: auth.authorization_name,
+ roles: {}
+ };
}
- if (!r.authHash) {
- r.authHash = {};
- }
- r.authHash[auth.authorization_id] = true;
+ $scope.authHash[levelKey][auth.authorization_id].roles[r.permission_name] = true;
}
});
});
- $scope.roles = roles.sort(function(a, b) {
+
+ // sort authorizations for each level by number of roles permissions
+ for (var level in $scope.authHash) {
+ if ($scope.authHash.hasOwnProperty(level)) {
+ authorizationsOrder = Object.keys($scope.authHash[level]).sort(function (a, b) {
+ return Object.keys($scope.authHash[level][b].roles).length - Object.keys($scope.authHash[level][a].roles).length;
+ });
+ $scope.authHash[level].order = authorizationsOrder;
+ }
+ }
+
+ $scope.roles = roles.sort(function (a, b) {
return $scope.orderedRoles.indexOf(a.permission_name) - $scope.orderedRoles.indexOf(b.permission_name);
});
$scope.ok = function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/63c0f2e5/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/RoleDetailsModal.html
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/RoleDetailsModal.html b/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/RoleDetailsModal.html
index 926bea9..942a733 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/RoleDetailsModal.html
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/modals/RoleDetailsModal.html
@@ -40,10 +40,10 @@
</div>
</div>
<div class="table-row-wrapper">
- <div class="table-row" ng-repeat="auth in orderedAuthorizations" ng-if="authHash[level][auth]">
- <div class="table-cell">{{authHash[level][auth]}}</div>
+ <div class="table-row" ng-repeat="auth_id in authHash[level].order">
+ <div class="table-cell">{{authHash[level][auth_id].name}}</div>
<div class="table-cell text-center" ng-repeat="role in roles">
- <i class="glyphicon glyphicon-ok green-icon" ng-show="role.authHash[auth]"></i>
+ <i class="glyphicon glyphicon-ok green-icon" ng-show="authHash[level][auth_id].roles[role.permission_name]"></i>
</div>
</div>
</div>