diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js index 9972eb11e7..bfbcee9c5b 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js @@ -697,6 +697,18 @@ module.config([ '$routeProvider', function($routeProvider) { }, controller : 'GroupRoleMappingCtrl' }) + .when('/realms/:realm/default-groups', { + templateUrl : resourceUrl + '/partials/default-groups.html', + resolve : { + realm : function(RealmLoader) { + return RealmLoader(); + }, + groups : function(GroupListLoader) { + return GroupListLoader(); + } + }, + controller : 'DefaultGroupsCtrl' + }) .when('/create/role/:realm/clients/:client', { @@ -1995,6 +2007,15 @@ module.directive('kcTabsGroup', function () { } }); +module.directive('kcTabsGroupList', function () { + return { + scope: true, + restrict: 'E', + replace: true, + templateUrl: resourceUrl + '/templates/kc-tabs-group-list.html' + } +}); + module.directive('kcTabsClient', function () { return { scope: true, diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/groups.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/groups.js index 811343beb5..6afcbbc8c3 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/groups.js +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/groups.js @@ -366,3 +366,63 @@ module.controller('GroupMembersCtrl', function($scope, realm, group, GroupMember }); +module.controller('DefaultGroupsCtrl', function($scope, $route, realm, groups, DefaultGroups, Notifications, $location, Dialog) { + $scope.realm = realm; + $scope.groupList = groups; + $scope.selectedGroup = null; + $scope.tree = []; + + DefaultGroups.query({realm: realm.realm}, function(data) { + $scope.defaultGroups = data; + + }); + + $scope.addDefaultGroup = function() { + if (!$scope.tree.currentNode) { + Notifications.error('Please select a group to add'); + return; + }; + + DefaultGroups.update({realm: realm.realm, groupId: $scope.tree.currentNode.id}, function() { + Notifications.success('Added default group'); + $route.reload(); + }); + + }; + + $scope.removeDefaultGroup = function() { + DefaultGroups.remove({realm: realm.realm, groupId: $scope.selectedGroup.id}, function() { + Notifications.success('Removed default group'); + $route.reload(); + }); + + }; + + var isLeaf = function(node) { + return node.id != "realm" && (!node.subGroups || node.subGroups.length == 0); + }; + + $scope.getGroupClass = function(node) { + if (node.id == "realm") { + return 'pficon pficon-users'; + } + if (isLeaf(node)) { + return 'normal'; + } + if (node.subGroups.length && node.collapsed) return 'collapsed'; + if (node.subGroups.length && !node.collapsed) return 'expanded'; + return 'collapsed'; + + } + + $scope.getSelectedClass = function(node) { + if (node.selected) { + return 'selected'; + } else if ($scope.cutNode && $scope.cutNode.id == node.id) { + return 'cut'; + } + return undefined; + } + +}); + diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js index 15e77a4357..3ca21832bd 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/services.js @@ -1559,4 +1559,15 @@ module.factory('UserGroupMapping', function($resource) { method : 'PUT' } }); -}); \ No newline at end of file +}); + +module.factory('DefaultGroups', function($resource) { + return $resource(authUrl + '/admin/realms/:realm/default-groups/:groupId', { + realm : '@realm', + groupId : '@groupId' + }, { + update : { + method : 'PUT' + } + }); +}); diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/default-groups.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/default-groups.html new file mode 100755 index 0000000000..bcfd547da4 --- /dev/null +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/default-groups.html @@ -0,0 +1,80 @@ +
+ + +
+
+ + +
+
+
+ + + + + + + + + + + +
+
+ + Newly created or registered users will automatically be added to these groups + +
+ +
+
+
+ + + +
+
+
+ + + + + + + + + + + +
+ +
+ + Select a group you want to add as a default. + +
+ +
+
+
+
+ +
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/group-list.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/group-list.html index 14acbaecba..ac8267cd43 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/group-list.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/group-list.html @@ -1,8 +1,5 @@
-

- User Groups - User groups -

+ diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/templates/kc-tabs-group-list.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/templates/kc-tabs-group-list.html new file mode 100755 index 0000000000..390dce3ee2 --- /dev/null +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/templates/kc-tabs-group-list.html @@ -0,0 +1,11 @@ +
+

+ User Groups +

+ + +
\ No newline at end of file