From 75bee51ac192dc486c41edd354b2daef0e44a40f Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Thu, 9 Feb 2017 09:11:48 -0500 Subject: [PATCH] console remote imported/unlink users --- .../messages/admin-messages_en.properties | 2 + .../admin/resources/js/controllers/users.js | 46 +++++++++++++++++-- .../theme/base/admin/resources/js/services.js | 15 +++++- .../partials/user-storage-generic.html | 2 + .../resources/partials/user-storage-ldap.html | 2 + 5 files changed, 60 insertions(+), 7 deletions(-) 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 2392c39f76..76c6d5078e 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 35c78ddbf3..4b47ff82ea 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 fe28afbf63..fe09ebbe28 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 7d0f5e967a..0eacb0ea16 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 @@ + + 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 485c85fd15..321d047187 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 @@ + +