Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEYCLOAK-145 forms for realm/app default roles #93

Merged
merged 1 commit into from
Nov 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -103,6 +103,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 @@ -143,6 +143,16 @@ <h2 data-ng-hide="createRealm"><span>{{realm.realm}}</span> General 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 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