keycloak-aplcache

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

10/3/2016 7:54:26 PM

Details

diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
index e848492..b262f65 100755
--- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
+++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
@@ -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");
diff --git a/themes/src/main/resources/theme/base/admin/resources/js/services.js b/themes/src/main/resources/theme/base/admin/resources/js/services.js
index a063143..236ad44 100755
--- a/themes/src/main/resources/theme/base/admin/resources/js/services.js
+++ b/themes/src/main/resources/theme/base/admin/resources/js/services.js
@@ -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',
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/user-list.html b/themes/src/main/resources/theme/base/admin/resources/partials/user-list.html
index f0cd97e..36510c5 100755
--- a/themes/src/main/resources/theme/base/admin/resources/partials/user-list.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/user-list.html
@@ -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>