Merge pull request #194 from patriot1burke/master

composite switch
This commit is contained in:
Bill Burke 2014-02-05 10:28:41 -05:00
commit 127ee40f23
7 changed files with 38 additions and 10 deletions

View file

@ -278,6 +278,8 @@ function roleControl($scope, realm, role, roles, applications,
if (!role.id) return;
$scope.compositeSwitch = role.composite;
$scope.compositeSwitchDisabled = role.composite;
$scope.realmRoles = angular.copy(roles);
$scope.selectedRealmRoles = [];
$scope.selectedRealmMappings = [];
@ -316,6 +318,7 @@ function roleControl($scope, realm, role, roles, applications,
});
$scope.addRealmRole = function() {
$scope.compositeSwitchDisabled=true;
$http.post('/auth/rest/admin/realms/' + realm.realm + '/roles-by-id/' + role.id + '/composites',
$scope.selectedRealmRoles).success(function() {
for (var i = 0; i < $scope.selectedRealmRoles.length; i++) {
@ -331,6 +334,7 @@ function roleControl($scope, realm, role, roles, applications,
};
$scope.deleteRealmRole = function() {
$scope.compositeSwitchDisabled=true;
$http.delete('/auth/rest/admin/realms/' + realm.realm + '/roles-by-id/' + role.id + '/composites',
{data : $scope.selectedRealmMappings, headers : {"content-type" : "application/json"}}).success(function() {
for (var i = 0; i < $scope.selectedRealmMappings.length; i++) {
@ -346,6 +350,7 @@ function roleControl($scope, realm, role, roles, applications,
};
$scope.addApplicationRole = function() {
$scope.compositeSwitchDisabled=true;
$http.post('/auth/rest/admin/realms/' + realm.realm + '/roles-by-id/' + role.id + '/composites',
$scope.selectedApplicationRoles).success(function() {
for (var i = 0; i < $scope.selectedApplicationRoles.length; i++) {
@ -361,6 +366,7 @@ function roleControl($scope, realm, role, roles, applications,
};
$scope.deleteApplicationRole = function() {
$scope.compositeSwitchDisabled=true;
$http.delete('/auth/rest/admin/realms/' + realm.realm + '/roles-by-id/' + role.id + '/composites',
{data : $scope.selectedApplicationMappings, headers : {"content-type" : "application/json"}}).success(function() {
for (var i = 0; i < $scope.selectedApplicationMappings.length; i++) {

View file

@ -52,6 +52,10 @@
required> -->
</div>
</div>
<div class="form-group clearfix block">
<label for="compositeSwitch" class="control-label">Composite Roles</label>
<input ng-model="compositeSwitch" name="compositeSwitch" id="compositeSwitch" ng-disabled="compositeSwitchDisabled" onoffswitch />
</div>
</fieldset>
<div class="form-actions" data-ng-show="create">
<button type="submit" kc-save class="primary" data-ng-show="changed">Save
@ -70,7 +74,7 @@
Delete
</button>
</div>
<fieldset data-ng-show="!create">
<fieldset data-ng-show="!create && (compositeSwitch || role.composite)">
<legend collapsed><span class="text">Composite Realm Roles</span> </legend>
<div class="form-group">
<div class="controls changing-selectors">
@ -98,7 +102,7 @@
</div>
</fieldset>
<fieldset ng-show="applications.length > 0 && !create">
<fieldset ng-show="applications.length > 0 && !create && (compositeSwitch || role.composite)">
<legend collapsed><span class="text">Composite Application Roles</span> </legend>
<div class="form-group input-select">
<label for="applications">Application</label>

View file

@ -27,7 +27,7 @@
<caption data-ng-show="roles && roles.length > 0" class="hidden">Table of realm roles</caption>
<thead>
<tr>
<th class="rcue-table-actions" colspan="2">
<th class="rcue-table-actions" colspan="3">
<div class="actions">
<a class="button" href="#/create/role/{{realm.realm}}/applications/{{application.name}}">Add Role</a>
<!-- <button class="remove disabled">Remove</button> -->
@ -35,7 +35,7 @@
</th>
</tr>
<tr data-ng-show="roles && roles.length > 5">
<th class="rcue-table-actions" colspan="2">
<th class="rcue-table-actions" colspan="3">
<div class="search-comp clearfix">
<input type="text" placeholder="Search..." class="search">
<button class="icon-search" tooltip-placement="right"
@ -47,12 +47,13 @@
</tr>
<tr>
<th>Role Name</th>
<th>Composite</th>
<th>Description</th>
</tr>
</thead>
<tfoot data-ng-show="roles && roles.length > 5"> <!-- todo -->
<tr>
<td colspan="2">
<td colspan="3">
<div class="table-nav">
<a href="#" class="first disabled">First page</a><a href="#" class="prev disabled">Previous
page</a><span><strong>1-8</strong> of <strong>10</strong></span><a href="#"
@ -65,6 +66,7 @@
<tbody>
<tr ng-repeat="role in roles">
<td><a href="#/realms/{{realm.realm}}/applications/{{application.name}}/roles/{{role.name}}">{{role.name}}</a></td>
<td>{{role.composite}}</td>
<td>{{role.description}}</td>
</tr>
</tbody>

View file

@ -47,6 +47,10 @@
<textarea rows="5" cols="50" id="description" name="description" data-ng-model="role.description"></textarea>
</div>
</div>
<div class="form-group clearfix block">
<label for="compositeSwitch" class="control-label">Composite Roles</label>
<input ng-model="compositeSwitch" name="compositeSwitch" id="compositeSwitch" ng-disabled="compositeSwitchDisabled" onoffswitch />
</div>
</fieldset>
<div class="form-actions" data-ng-show="create">
<button type="submit" kc-save class="primary" data-ng-show="changed">Save
@ -66,7 +70,7 @@
</button>
</div>
<fieldset data-ng-show="!create">
<fieldset data-ng-show="!create && (compositeSwitch || role.composite)">
<legend collapsed><span class="text">Composite Realm Roles</span> </legend>
<div class="form-group">
<div class="controls changing-selectors">
@ -94,7 +98,7 @@
</div>
</fieldset>
<fieldset ng-show="applications.length > 0 && !create">
<fieldset ng-show="applications.length > 0 && !create && (compositeSwitch || role.composite)">
<legend collapsed><span class="text">Composite Application Roles</span> </legend>
<div class="form-group input-select">
<label for="applications">Application</label>

View file

@ -27,7 +27,7 @@
<table data-ng-hide="!roles || roles.length == 0">
<thead>
<tr>
<th class="rcue-table-actions" colspan="2">
<th class="rcue-table-actions" colspan="3">
<div class="actions">
<a class="button" href="#/create/role/{{realm.realm}}">Add Role</a>
<!-- <button class="remove disabled">Remove</button> -->
@ -35,7 +35,7 @@
</th>
</tr>
<tr data-ng-show="roles && roles.length > 5">
<th class="rcue-table-actions" colspan="2">
<th class="rcue-table-actions" colspan="3">
<div class="search-comp clearfix">
<input type="text" placeholder="Search..." class="search">
<button class="icon-search" tooltip-placement="right"
@ -47,12 +47,13 @@
</tr>
<tr>
<th>Role Name</th>
<th>Composite</th>
<th>Description</th>
</tr>
</thead>
<tfoot data-ng-show="roles && roles.length > 5"> <!-- todo -->
<tr>
<td colspan="2">
<td colspan="3">
<div class="table-nav">
<a href="#" class="first disabled">First page</a><a href="#" class="prev disabled">Previous
page</a><span><strong>1-8</strong> of <strong>10</strong></span><a href="#"
@ -65,6 +66,7 @@
<tbody>
<tr ng-repeat="role in roles">
<td><a href="#/realms/{{realm.realm}}/roles/{{role.name}}">{{role.name}}</a></td>
<td>{{role.composite}}</td>
<td>{{role.description}}</td>
</tr>
</tbody>

View file

@ -12,6 +12,7 @@ public class RoleRepresentation {
protected String id;
protected String name;
protected String description;
protected boolean composite;
protected Composites composites;
public static class Composites {
@ -80,4 +81,12 @@ public class RoleRepresentation {
public String toString() {
return name;
}
public boolean isComposite() {
return composite;
}
public void setComposite(boolean composite) {
this.composite = composite;
}
}

View file

@ -51,6 +51,7 @@ public class ModelToRepresentation {
rep.setId(role.getId());
rep.setName(role.getName());
rep.setDescription(role.getDescription());
rep.setComposite(role.isComposite());
return rep;
}