keycloak-memoizeit

Details

diff --git a/themes/src/main/resources/theme/base/admin/messages/admin-messages_en.properties b/themes/src/main/resources/theme/base/admin/messages/admin-messages_en.properties
index 2392c39..76c6d50 100644
--- a/themes/src/main/resources/theme/base/admin/messages/admin-messages_en.properties
+++ b/themes/src/main/resources/theme/base/admin/messages/admin-messages_en.properties
@@ -689,6 +689,8 @@ changed-users-sync-period=Changed Users Sync Period
 changed-users-sync-period.tooltip=Period for synchronization of changed or newly created provider users in seconds
 synchronize-changed-users=Synchronize changed users
 synchronize-all-users=Synchronize all users
+remove-imported-users=Remove imported
+unlink-users=Unlink users
 kerberos-realm=Kerberos Realm
 kerberos-realm.tooltip=Name of kerberos realm. For example FOO.ORG
 server-principal=Server Principal
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 35c78dd..4b47ff8 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
@@ -670,7 +670,7 @@ module.controller('UserFederationCtrl', function($scope, $location, $route, real
 });
 
 module.controller('GenericUserStorageCtrl', function($scope, $location, Notifications, $route, Dialog, realm,
-                                                     serverInfo, instance, providerId, Components, UserStorageSync) {
+                                                     serverInfo, instance, providerId, Components, UserStorageOperations) {
     console.log('GenericUserStorageCtrl');
     console.log('providerId: ' + providerId);
     $scope.create = !instance.providerId;
@@ -869,7 +869,7 @@ module.controller('GenericUserStorageCtrl', function($scope, $location, Notifica
     }
 
     function triggerSync(action) {
-        UserStorageSync.save({ action: action, realm: $scope.realm.realm, componentId: $scope.instance.id }, {}, function(syncResult) {
+        UserStorageOperations.sync.save({ action: action, realm: $scope.realm.realm, componentId: $scope.instance.id }, {}, function(syncResult) {
             $route.reload();
             Notifications.success("Sync of users finished successfully. " + syncResult.status);
         }, function() {
@@ -877,6 +877,24 @@ module.controller('GenericUserStorageCtrl', function($scope, $location, Notifica
             Notifications.error("Error during sync of users");
         });
     }
+    $scope.removeImportedUsers = function() {
+        UserStorageOperations.removeImportedUsers.save({ realm: $scope.realm.realm, componentId: $scope.instance.id }, {}, function(syncResult) {
+            $route.reload();
+            Notifications.success("Remove imported users finished successfully. ");
+        }, function() {
+            $route.reload();
+            Notifications.error("Error during remove");
+        });
+    };
+    $scope.unlinkUsers = function() {
+        UserStorageOperations.unlinkUsers.save({ realm: $scope.realm.realm, componentId: $scope.instance.id }, {}, function(syncResult) {
+            $route.reload();
+            Notifications.success("Unlink of users finished successfully. ");
+        }, function() {
+            $route.reload();
+            Notifications.error("Error during unlink");
+        });
+    };
 
 });
 
@@ -971,7 +989,7 @@ module.controller('UserGroupMembershipCtrl', function($scope, $route, realm, gro
 });
 
 module.controller('LDAPUserStorageCtrl', function($scope, $location, Notifications, $route, Dialog, realm,
-                                                     serverInfo, instance, Components, UserStorageSync, RealmLDAPConnectionTester) {
+                                                     serverInfo, instance, Components, UserStorageOperations, RealmLDAPConnectionTester) {
     console.log('LDAPUserStorageCtrl');
     var providerId = 'ldap';
     console.log('providerId: ' + providerId);
@@ -1247,9 +1265,10 @@ module.controller('LDAPUserStorageCtrl', function($scope, $location, Notificatio
         console.log('GenericCtrl: triggerChangedUsersSync');
         triggerSync('triggerChangedUsersSync');
     }
+    
 
     function triggerSync(action) {
-        UserStorageSync.save({ action: action, realm: $scope.realm.realm, componentId: $scope.instance.id }, {}, function(syncResult) {
+        UserStorageOperations.sync.save({ action: action, realm: $scope.realm.realm, componentId: $scope.instance.id }, {}, function(syncResult) {
             $route.reload();
             Notifications.success("Sync of users finished successfully. " + syncResult.status);
         }, function() {
@@ -1257,7 +1276,24 @@ module.controller('LDAPUserStorageCtrl', function($scope, $location, Notificatio
             Notifications.error("Error during sync of users");
         });
     }
-
+    $scope.removeImportedUsers = function() {
+        UserStorageOperations.removeImportedUsers.save({ realm: $scope.realm.realm, componentId: $scope.instance.id }, {}, function(syncResult) {
+            $route.reload();
+            Notifications.success("Remove imported users finished successfully. ");
+        }, function() {
+            $route.reload();
+            Notifications.error("Error during remove");
+        });
+    };
+    $scope.unlinkUsers = function() {
+        UserStorageOperations.unlinkUsers.save({ realm: $scope.realm.realm, componentId: $scope.instance.id }, {}, function(syncResult) {
+            $route.reload();
+            Notifications.success("Unlink of users finished successfully. ");
+        }, function() {
+            $route.reload();
+            Notifications.error("Error during unlink");
+        });
+    };
     var initConnectionTest = function(testAction, ldapConfig) {
         return {
             action: testAction,
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 fe28afb..fe09ebb 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
@@ -1687,13 +1687,24 @@ module.factory('Components', function($resource, ComponentUtils) {
     });
 });
 
-module.factory('UserStorageSync', function($resource) {
-    return $resource(authUrl + '/admin/realms/:realm/user-storage/:componentId/sync', {
+module.factory('UserStorageOperations', function($resource) {
+    var object = {}
+    object.sync = $resource(authUrl + '/admin/realms/:realm/user-storage/:componentId/sync', {
         realm : '@realm',
         componentId : '@componentId'
     });
+    object.removeImportedUsers = $resource(authUrl + '/admin/realms/:realm/user-storage/:componentId/remove-imported-users', {
+        realm : '@realm',
+        componentId : '@componentId'
+    });
+    object.unlinkUsers = $resource(authUrl + '/admin/realms/:realm/user-storage/:componentId/unlink-users', {
+        realm : '@realm',
+        componentId : '@componentId'
+    });
+    return object;
 });
 
+
 module.factory('ClientRegistrationPolicyProviders', function($resource) {
     return $resource(authUrl + '/admin/realms/:realm/client-registration-policy/providers', {
         realm : '@realm',
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/user-storage-generic.html b/themes/src/main/resources/theme/base/admin/resources/partials/user-storage-generic.html
index 7d0f5e9..0eacb0e 100755
--- a/themes/src/main/resources/theme/base/admin/resources/partials/user-storage-generic.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/user-storage-generic.html
@@ -229,6 +229,8 @@
                 <button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
                 <button class="btn btn-primary" data-ng-click="triggerChangedUsersSync()" data-ng-hide="changed || !showSync">{{:: 'synchronize-changed-users' | translate}}</button>
                 <button class="btn btn-primary" data-ng-click="triggerFullSync()" data-ng-hide="changed || !showSync">{{:: 'synchronize-all-users' | translate}}</button>
+                <button class="btn btn-primary" data-ng-click="removeImportedUsers()" data-ng-hide="changed">{{:: 'remove-imported-users' | translate}}</button>
+                <button class="btn btn-primary" data-ng-click="unlinkUsers()" data-ng-hide="changed">{{:: 'unlink-users' | translate}}</button>
             </div>
         </div>
     </form>
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/user-storage-ldap.html b/themes/src/main/resources/theme/base/admin/resources/partials/user-storage-ldap.html
index 485c85f..321d047 100755
--- a/themes/src/main/resources/theme/base/admin/resources/partials/user-storage-ldap.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/user-storage-ldap.html
@@ -462,6 +462,8 @@
                 <button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
                 <button class="btn btn-primary" data-ng-click="triggerChangedUsersSync()" data-ng-hide="changed">{{:: 'synchronize-changed-users' | translate}}</button>
                 <button class="btn btn-primary" data-ng-click="triggerFullSync()" data-ng-hide="changed">{{:: 'synchronize-all-users' | translate}}</button>
+                <button class="btn btn-primary" data-ng-click="removeImportedUsers()" data-ng-hide="changed">{{:: 'remove-imported-users' | translate}}</button>
+                <button class="btn btn-primary" data-ng-click="unlinkUsers()" data-ng-hide="changed">{{:: 'unlink-users' | translate}}</button>
             </div>
         </div>
     </form>