Merge pull request #93 from vrockai/KEYCLOAK-145
KEYCLOAK-145 forms for realm/app default roles
This commit is contained in:
commit
a4e1e709cf
6 changed files with 67 additions and 2 deletions
|
@ -11,6 +11,9 @@ module.config([ '$routeProvider', function($routeProvider) {
|
||||||
resolve : {
|
resolve : {
|
||||||
realm : function(RealmLoader) {
|
realm : function(RealmLoader) {
|
||||||
return {};
|
return {};
|
||||||
|
},
|
||||||
|
roles : function() {
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
controller : 'RealmDetailCtrl'
|
controller : 'RealmDetailCtrl'
|
||||||
|
@ -20,6 +23,9 @@ module.config([ '$routeProvider', function($routeProvider) {
|
||||||
resolve : {
|
resolve : {
|
||||||
realm : function(RealmLoader) {
|
realm : function(RealmLoader) {
|
||||||
return RealmLoader();
|
return RealmLoader();
|
||||||
|
},
|
||||||
|
roles : function(RoleListLoader) {
|
||||||
|
return RoleListLoader();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
controller : 'RealmDetailCtrl'
|
controller : 'RealmDetailCtrl'
|
||||||
|
@ -240,6 +246,9 @@ module.config([ '$routeProvider', function($routeProvider) {
|
||||||
},
|
},
|
||||||
application : function() {
|
application : function() {
|
||||||
return {};
|
return {};
|
||||||
|
},
|
||||||
|
roles : function() {
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
controller : 'ApplicationDetailCtrl'
|
controller : 'ApplicationDetailCtrl'
|
||||||
|
@ -255,6 +264,9 @@ module.config([ '$routeProvider', function($routeProvider) {
|
||||||
},
|
},
|
||||||
application : function(ApplicationLoader) {
|
application : function(ApplicationLoader) {
|
||||||
return ApplicationLoader();
|
return ApplicationLoader();
|
||||||
|
},
|
||||||
|
roles : function(ApplicationRoleListLoader) {
|
||||||
|
return ApplicationRoleListLoader();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
controller : 'ApplicationDetailCtrl'
|
controller : 'ApplicationDetailCtrl'
|
||||||
|
|
|
@ -21,3 +21,16 @@ function randomString(len) {
|
||||||
return randomString;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -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');
|
console.log('ApplicationDetailCtrl');
|
||||||
|
|
||||||
$scope.realm = realm;
|
$scope.realm = realm;
|
||||||
|
@ -182,6 +182,17 @@ module.controller('ApplicationDetailCtrl', function($scope, realm, application,
|
||||||
$scope.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() {
|
$scope.$watch(function() {
|
||||||
return $location.path();
|
return $location.path();
|
||||||
}, function() {
|
}, function() {
|
||||||
|
|
|
@ -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;
|
$scope.createRealm = !realm.id;
|
||||||
|
|
||||||
console.log('RealmDetailCtrl');
|
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) {
|
if ($scope.createRealm) {
|
||||||
$scope.realm = {
|
$scope.realm = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
|
@ -93,6 +93,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</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">
|
<div class="form-actions" data-ng-show="create">
|
||||||
<button type="submit" data-ng-click="save()" data-ng-show="changed" class="primary">Save
|
<button type="submit" data-ng-click="save()" data-ng-show="changed" class="primary">Save
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -68,6 +68,16 @@
|
||||||
<input ng-model="realm.cookieLoginAllowed" name="cookieLoginAllowed" id="cookieLoginAllowed" onoffswitch />
|
<input ng-model="realm.cookieLoginAllowed" name="cookieLoginAllowed" id="cookieLoginAllowed" onoffswitch />
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</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">
|
<div class="form-actions" data-ng-show="createRealm">
|
||||||
<button type="submit" data-ng-click="save()" class="primary" data-ng-show="changed">Save
|
<button type="submit" data-ng-click="save()" class="primary" data-ng-show="changed">Save
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Reference in a new issue