KEYCLOAK-5850: Del realm role broken on permissions & Users tabs.

This commit is contained in:
Stan Silvert 2017-11-15 14:12:03 -05:00 committed by Stian Thorgersen
parent f96c3312e2
commit dc05134e41
4 changed files with 28 additions and 14 deletions

View file

@ -2536,10 +2536,15 @@ getManageClientId = function(realm) {
} }
} }
module.controller('RealmRolePermissionsCtrl', function($scope, $http, $route, $location, realm, role, RoleManagementPermissions, Client, Notifications) { module.controller('RealmRolePermissionsCtrl', function($scope, $http, $route, $location, realm, role, RoleManagementPermissions, Client, Notifications, Dialog, RealmRoleRemover) {
console.log('RealmRolePermissionsCtrl'); console.log('RealmRolePermissionsCtrl');
$scope.role = role; $scope.role = role;
$scope.realm = realm; $scope.realm = realm;
$scope.remove = function() {
RealmRoleRemover.remove($scope.role, realm, Dialog, $location, Notifications);
};
RoleManagementPermissions.get({realm: realm.realm, role: role.id}, function(data) { RoleManagementPermissions.get({realm: realm.realm, role: role.id}, function(data) {
$scope.permissions = data; $scope.permissions = data;
$scope.$watch('permissions.enabled', function(newVal, oldVal) { $scope.$watch('permissions.enabled', function(newVal, oldVal) {

View file

@ -1433,7 +1433,7 @@ module.controller('RoleListCtrl', function($scope, $route, Dialog, Notifications
module.controller('RoleDetailCtrl', function($scope, realm, role, roles, clients, module.controller('RoleDetailCtrl', function($scope, realm, role, roles, clients,
Role, ClientRole, RoleById, RoleRealmComposites, RoleClientComposites, Role, ClientRole, RoleById, RoleRealmComposites, RoleClientComposites,
$http, $location, Dialog, Notifications) { $http, $location, Dialog, Notifications, RealmRoleRemover) {
$scope.realm = realm; $scope.realm = realm;
$scope.role = angular.copy(role); $scope.role = angular.copy(role);
$scope.create = !role.name; $scope.create = !role.name;
@ -1460,16 +1460,8 @@ module.controller('RoleDetailCtrl', function($scope, realm, role, roles, clients
} }
}; };
$scope.remove = function () { $scope.remove = function() {
Dialog.confirmDelete($scope.role.name, 'role', function () { RealmRoleRemover.remove($scope.role, realm, Dialog, $location, Notifications);
$scope.role.$remove({
realm: realm.realm,
role: $scope.role.id
}, function () {
$location.url("/realms/" + realm.realm + "/roles");
Notifications.success("The role has been deleted.");
});
});
}; };
$scope.cancel = function () { $scope.cancel = function () {

View file

@ -1,4 +1,4 @@
module.controller('RoleMembersCtrl', function($scope, realm, role, RoleMembership) { module.controller('RoleMembersCtrl', function($scope, realm, role, RoleMembership, Dialog, Notifications, $location, RealmRoleRemover) {
$scope.realm = realm; $scope.realm = realm;
$scope.page = 0; $scope.page = 0;
$scope.role = role; $scope.role = role;
@ -10,6 +10,9 @@ module.controller('RoleMembersCtrl', function($scope, realm, role, RoleMembershi
first : 0 first : 0
} }
$scope.remove = function() {
RealmRoleRemover.remove($scope.role, realm, Dialog, $location, Notifications);
};
$scope.firstPage = function() { $scope.firstPage = function() {
$scope.query.first = 0; $scope.query.first = 0;

View file

@ -461,6 +461,20 @@ module.service('LastFlowSelected', function() {
this.alias = null; this.alias = null;
}); });
module.service('RealmRoleRemover', function() {
this.remove = function (role, realm, Dialog, $location, Notifications) {
Dialog.confirmDelete(role.name, 'role', function () {
role.$remove({
realm: realm.realm,
role: role.id
}, function () {
$location.url("/realms/" + realm.realm + "/roles");
Notifications.success("The role has been deleted.");
});
});
};
});
module.factory('UserSessionStats', function($resource) { module.factory('UserSessionStats', function($resource) {
return $resource(authUrl + '/admin/realms/:realm/users/:user/session-stats', { return $resource(authUrl + '/admin/realms/:realm/users/:user/session-stats', {
realm : '@realm', realm : '@realm',