Merge pull request #93 from vrockai/KEYCLOAK-145

KEYCLOAK-145 forms for realm/app default roles
This commit is contained in:
stianst 2013-11-08 03:51:57 -08:00
commit a4e1e709cf
6 changed files with 67 additions and 2 deletions

View file

@ -11,6 +11,9 @@ module.config([ '$routeProvider', function($routeProvider) {
resolve : {
realm : function(RealmLoader) {
return {};
},
roles : function() {
return {};
}
},
controller : 'RealmDetailCtrl'
@ -20,6 +23,9 @@ module.config([ '$routeProvider', function($routeProvider) {
resolve : {
realm : function(RealmLoader) {
return RealmLoader();
},
roles : function(RoleListLoader) {
return RoleListLoader();
}
},
controller : 'RealmDetailCtrl'
@ -240,6 +246,9 @@ module.config([ '$routeProvider', function($routeProvider) {
},
application : function() {
return {};
},
roles : function() {
return {};
}
},
controller : 'ApplicationDetailCtrl'
@ -255,6 +264,9 @@ module.config([ '$routeProvider', function($routeProvider) {
},
application : function(ApplicationLoader) {
return ApplicationLoader();
},
roles : function(ApplicationRoleListLoader) {
return ApplicationRoleListLoader();
}
},
controller : 'ApplicationDetailCtrl'

View file

@ -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;
}

View file

@ -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;
@ -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() {

View file

@ -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,

View file

@ -93,6 +93,16 @@
</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>

View file

@ -68,6 +68,16 @@
<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>