Merge pull request #3281 from ssilvert/delte-multiple-users-updated

KEYCLOAK-3633: Unable to delete multiple users without re-entering search
This commit is contained in:
Stan Silvert 2016-10-03 18:54:26 -04:00 committed by GitHub
commit 90b5ad5bb3
3 changed files with 25 additions and 11 deletions

View file

@ -240,16 +240,17 @@ module.controller('UserOfflineSessionsCtrl', function($scope, $location, realm,
});
module.controller('UserListCtrl', function($scope, realm, User, UserImpersonation, BruteForce, Notifications, $route, Dialog) {
$scope.realm = realm;
$scope.page = 0;
$scope.query = {
realm: realm.realm,
max : 20,
first : 0
module.controller('UserListCtrl', function($scope, realm, User, UserSearchState, UserImpersonation, BruteForce, Notifications, $route, Dialog) {
$scope.init = function() {
$scope.realm = realm;
UserSearchState.query.realm = realm.realm;
$scope.query = UserSearchState.query;
if (!UserSearchState.isFirstSearch) $scope.searchQuery();
};
$scope.impersonate = function(userId) {
UserImpersonation.save({realm : realm.realm, user: userId}, function (data) {
if (data.sameRealm) {
@ -292,6 +293,7 @@ module.controller('UserListCtrl', function($scope, realm, User, UserImpersonatio
$scope.users = User.query($scope.query, function() {
$scope.searchLoaded = true;
$scope.lastSearch = $scope.query.search;
UserSearchState.isFirstSearch = false;
});
};
@ -302,6 +304,11 @@ module.controller('UserListCtrl', function($scope, realm, User, UserImpersonatio
userId : user.id
}, function() {
$route.reload();
if ($scope.users.length === 1 && $scope.query.first > 0) {
$scope.previousPage();
}
Notifications.success("The user has been deleted.");
}, function() {
Notifications.error("User couldn't be deleted");

View file

@ -346,6 +346,14 @@ module.factory('User', function($resource) {
});
});
module.service('UserSearchState', function() {
this.isFirstSearch = true;
this.query = {
max : 20,
first : 0
};
});
module.factory('UserFederationInstances', function($resource) {
return $resource(authUrl + '/admin/realms/:realm/user-federation/instances/:instance', {
realm : '@realm',

View file

@ -1,4 +1,4 @@
<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">
<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2" ng-init="init()">
<h1>{{:: 'users' | translate}}</h1>
<table class="table table-striped table-bordered">
@ -33,7 +33,6 @@
<th class="w-15">{{:: 'first-name' | translate}}</th>
<th colspan="{{access.impersonation == true ? '3' : '2'}}">{{:: 'actions' | translate}}</th>
</tr>
</tr>
</thead>
<tfoot data-ng-show="users && (users.length >= query.max || query.first > 0)">
<tr>