default groups ui
This commit is contained in:
parent
98958a2bc4
commit
1545593cde
6 changed files with 185 additions and 5 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -1559,4 +1559,15 @@ module.factory('UserGroupMapping', function($resource) {
|
|||
method : 'PUT'
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
module.factory('DefaultGroups', function($resource) {
|
||||
return $resource(authUrl + '/admin/realms/:realm/default-groups/:groupId', {
|
||||
realm : '@realm',
|
||||
groupId : '@groupId'
|
||||
}, {
|
||||
update : {
|
||||
method : 'PUT'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">
|
||||
<kc-tabs-group-list></kc-tabs-group-list>
|
||||
|
||||
<form class="form-horizontal" name="realmForm" novalidate>
|
||||
<div class="form-group" kc-read-only="!access.manageRealm">
|
||||
<label class="col-md-1 control-label" class="control-label"></label>
|
||||
|
||||
<div class="col-md-8" >
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="kc-table-actions" colspan="5">
|
||||
<div class="form-inline">
|
||||
<label class="control-label">Default Groups</label>
|
||||
<kc-tooltip>Newly created or registered users will automatically be added to these groups</kc-tooltip>
|
||||
|
||||
<div class="pull-right" data-ng-show="access.manageRealm">
|
||||
<button id="removeDefaultGroup" class="btn btn-default" ng-click="removeDefaultGroup()">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<select id="defaultGroups" class="form-control" size=5
|
||||
ng-model="selectedGroup"
|
||||
ng-options="r.path for r in defaultGroups">
|
||||
<option style="display:none" value="">select a type</option>
|
||||
</select>
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="kc-table-actions" colspan="5">
|
||||
|
||||
<div class="form-inline">
|
||||
<label class="control-label">Available Groups</label>
|
||||
<kc-tooltip>Select a group you want to add as a default.</kc-tooltip>
|
||||
|
||||
<div class="pull-right" data-ng-show="access.manageRealm">
|
||||
<button id="addDefaultGroup" class="btn btn-default" ng-click="addDefaultGroup()">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td> <div
|
||||
tree-id="tree"
|
||||
angular-treeview="true"
|
||||
tree-model="groupList"
|
||||
node-id="id"
|
||||
node-label="name"
|
||||
node-children="subGroups" >
|
||||
</div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<kc-menu></kc-menu>
|
|
@ -1,8 +1,5 @@
|
|||
<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">
|
||||
<h1>
|
||||
<span>User Groups</span>
|
||||
<kc-tooltip>User groups</kc-tooltip>
|
||||
</h1>
|
||||
<kc-tabs-group-list></kc-tabs-group-list>
|
||||
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<div data-ng-controller="GroupTabCtrl">
|
||||
<h1>
|
||||
<span>User Groups</span>
|
||||
</h1>
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<li ng-class="{active: path[2] == 'groups'}"><a href="#/realms/{{realm.realm}}/groups">Groups</a></li>
|
||||
<li ng-class="{active: path[2] == 'default-groups'}"><a href="#/realms/{{realm.realm}}/default-groups">Default Groups</a><kc-tooltip>Set of groups that new users will automatically join.</kc-tooltip>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
Loading…
Reference in a new issue