Skip to content

Commit

Permalink
Merge pull request #93 from vrockai/KEYCLOAK-145
Browse files Browse the repository at this point in the history
KEYCLOAK-145 forms for realm/app default roles
  • Loading branch information
stianst committed Nov 8, 2013
2 parents 29a4031 + eb49ac4 commit a4e1e70
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 2 deletions.
12 changes: 12 additions & 0 deletions admin-ui/src/main/resources/META-INF/resources/admin/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module.config([ '$routeProvider', function($routeProvider) {
resolve : {
realm : function(RealmLoader) {
return {};
},
roles : function() {
return {};
}
},
controller : 'RealmDetailCtrl'
Expand All @@ -20,6 +23,9 @@ module.config([ '$routeProvider', function($routeProvider) {
resolve : {
realm : function(RealmLoader) {
return RealmLoader();
},
roles : function(RoleListLoader) {
return RoleListLoader();
}
},
controller : 'RealmDetailCtrl'
Expand Down Expand Up @@ -240,6 +246,9 @@ module.config([ '$routeProvider', function($routeProvider) {
},
application : function() {
return {};
},
roles : function() {
return {};
}
},
controller : 'ApplicationDetailCtrl'
Expand All @@ -255,6 +264,9 @@ module.config([ '$routeProvider', function($routeProvider) {
},
application : function(ApplicationLoader) {
return ApplicationLoader();
},
roles : function(ApplicationRoleListLoader) {
return ApplicationRoleListLoader();
}
},
controller : 'ApplicationDetailCtrl'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,16 @@ function randomString(len) {
return randomString;
}

function getAvailableRoles(roles, systemRoles){
var complement = [];

for (var i = 0; i < roles.length; i++){
var roleName = roles[i].name;

if (systemRoles.indexOf(roleName) < 0){
complement.push(roleName);
}
}

return complement;
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ module.controller('ApplicationListCtrl', function($scope, realm, applications, A
});
});

module.controller('ApplicationDetailCtrl', function($scope, realm, application, Application, $location, Dialog, Notifications) {
module.controller('ApplicationDetailCtrl', function($scope, realm, application, roles, Application, $location, Dialog, Notifications) {
console.log('ApplicationDetailCtrl');

$scope.realm = realm;
Expand All @@ -182,6 +182,17 @@ module.controller('ApplicationDetailCtrl', function($scope, realm, application,
$scope.application = {};
}

console.log(application);

var systemRoles = ["*", "KEYCLOAK_APPLICATION","KEYCLOAK_IDENTITY_REQUESTER"];
var availableRoles = getAvailableRoles(roles, systemRoles);

$scope.appDefaultRolesOptions = {
'multiple' : true,
'simple_tags' : true,
'tags' : availableRoles
};

$scope.$watch(function() {
return $location.path();
}, function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,20 @@ module.controller('RealmDropdownCtrl', function($scope, Realm, Current, Auth, $l
}
});

module.controller('RealmDetailCtrl', function($scope, Current, Realm, realm, $http, $location, Dialog, Notifications) {
module.controller('RealmDetailCtrl', function($scope, Current, Realm, realm, roles, $http, $location, Dialog, Notifications) {
$scope.createRealm = !realm.id;

console.log('RealmDetailCtrl');

var systemRoles = ["*", "KEYCLOAK_APPLICATION","KEYCLOAK_IDENTITY_REQUESTER"];
var availableRoles = getAvailableRoles(roles, systemRoles);

$scope.realmDefaultRolesOptions = {
'multiple' : true,
'simple_tags' : true,
'tags' : availableRoles
};

if ($scope.createRealm) {
$scope.realm = {
enabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ <h2 data-ng-hide="create"><span>{{application.name}}</span> Settings</h2>
</div>
</div>
</fieldset>
<fieldset>
<legend uncollapsed><span class="text">Default Roles</span></legend>
<div class="form-group">
<label for="default-roles" class="control-label two-lines">Default Application Roles</label>

<div class="controls">
<input id="default-roles" type="text" ui-select2="appDefaultRolesOptions" ng-model="application.defaultRoles" placeholder="Type a role and enter">
</div>
</div>
</fieldset>
<div class="form-actions" data-ng-show="create">
<button type="submit" data-ng-click="save()" data-ng-show="changed" class="primary">Save
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ <h2 data-ng-hide="createRealm"><span>{{realm.realm}}</span> General Settings</h2
<input ng-model="realm.cookieLoginAllowed" name="cookieLoginAllowed" id="cookieLoginAllowed" onoffswitch />
</div>
</fieldset>
<fieldset>
<legend uncollapsed><span class="text">Default Roles</span></legend>
<div class="form-group">
<label for="default-roles" class="control-label two-lines">Default Realm Roles</label>

<div class="controls">
<input id="default-roles" type="text" ui-select2="realmDefaultRolesOptions" ng-model="realm.defaultRoles" placeholder="Type a role and enter">
</div>
</div>
</fieldset>
<div class="form-actions" data-ng-show="createRealm">
<button type="submit" data-ng-click="save()" class="primary" data-ng-show="changed">Save
</button>
Expand Down

0 comments on commit a4e1e70

Please sign in to comment.