diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/applications.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/applications.js index 323c06788d..9f7615d9c1 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/applications.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/applications.js @@ -329,18 +329,22 @@ module.controller('ApplicationDetailCtrl', function($scope, realm, application, }); -module.controller('ApplicationScopeMappingCtrl', function($scope, $http, realm, application, roles, applications, ApplicationRealmScopeMapping, ApplicationApplicationScopeMapping, ApplicationRole) { +module.controller('ApplicationScopeMappingCtrl', function($scope, $http, realm, application, applications, + ApplicationRealmScopeMapping, ApplicationApplicationScopeMapping, ApplicationRole, + ApplicationAvailableRealmScopeMapping, ApplicationAvailableApplicationScopeMapping, + ApplicationCompositeRealmScopeMapping, ApplicationCompositeApplicationScopeMapping) { $scope.realm = realm; $scope.application = application; - $scope.realmRoles = angular.copy(roles); $scope.selectedRealmRoles = []; $scope.selectedRealmMappings = []; $scope.realmMappings = []; $scope.applications = applications; $scope.applicationRoles = []; + $scope.applicationComposite = []; $scope.selectedApplicationRoles = []; $scope.selectedApplicationMappings = []; $scope.applicationMappings = []; + $scope.dummymodel = []; @@ -447,6 +451,88 @@ module.controller('ApplicationScopeMappingCtrl', function($scope, $http, realm, } }; + $scope.realmMappings = ApplicationRealmScopeMapping.query({realm : realm.realm, application : application.name}); + $scope.realmRoles = ApplicationAvailableRealmScopeMapping.query({realm : realm.realm, application : application.name}); + $scope.realmComposite = ApplicationCompositeRealmScopeMapping.query({realm : realm.realm, application : application.name}); + + $scope.addRealmRole = function() { + $http.post(authUrl + '/admin/realms/' + realm.realm + '/applications/' + application.name + '/scope-mappings/realm', + $scope.selectedRealmRoles).success(function() { + $scope.realmMappings = ApplicationRealmScopeMapping.query({realm : realm.realm, application : application.name}); + $scope.realmRoles = ApplicationAvailableRealmScopeMapping.query({realm : realm.realm, application : application.name}); + $scope.realmComposite = ApplicationCompositeRealmScopeMapping.query({realm : realm.realm, application : application.name}); + $scope.selectedRealmMappings = []; + $scope.selectRealmRoles = []; + if ($scope.targetApp) { + console.log('load available'); + $scope.applicationMappings = ApplicationApplicationScopeMapping.query({realm : realm.realm, application : application.name, targetApp : $scope.targetApp.name}); + $scope.applicationRoles = ApplicationAvailableApplicationScopeMapping.query({realm : realm.realm, application : application.name, targetApp : $scope.targetApp.name}); + $scope.applicationComposite = ApplicationCompositeApplicationScopeMapping.query({realm : realm.realm, application : application.name, targetApp : $scope.targetApp.name}); + $scope.selectedApplicationRoles = []; + $scope.selectedApplicationMappings = []; + } + }); + }; + + $scope.deleteRealmRole = function() { + $http.delete(authUrl + '/admin/realms/' + realm.realm + '/applications/' + application.name + '/scope-mappings/realm', + {data : $scope.selectedRealmMappings, headers : {"content-type" : "application/json"}}).success(function() { + $scope.realmMappings = ApplicationRealmScopeMapping.query({realm : realm.realm, application : application.name}); + $scope.realmRoles = ApplicationAvailableRealmScopeMapping.query({realm : realm.realm, application : application.name}); + $scope.realmComposite = ApplicationCompositeRealmScopeMapping.query({realm : realm.realm, application : application.name}); + $scope.selectedRealmMappings = []; + $scope.selectRealmRoles = []; + if ($scope.targetApp) { + console.log('load available'); + $scope.applicationMappings = ApplicationApplicationScopeMapping.query({realm : realm.realm, application : application.name, targetApp : $scope.targetApp.name}); + $scope.applicationRoles = ApplicationAvailableApplicationScopeMapping.query({realm : realm.realm, application : application.name, targetApp : $scope.targetApp.name}); + $scope.applicationComposite = ApplicationCompositeApplicationScopeMapping.query({realm : realm.realm, application : application.name, targetApp : $scope.targetApp.name}); + $scope.selectedApplicationRoles = []; + $scope.selectedApplicationMappings = []; + } + }); + }; + + $scope.addApplicationRole = function() { + $http.post(authUrl + '/admin/realms/' + realm.realm + '/applications/' + application.name + '/scope-mappings/applications/' + $scope.targetApp.name, + $scope.selectedApplicationRoles).success(function() { + $scope.applicationMappings = ApplicationRoleMapping.query({realm : realm.realm, userId : user.username, application : $scope.application.name}); + $scope.applicationRoles = AvailableApplicationRoleMapping.query({realm : realm.realm, userId : user.username, application : $scope.application.name}); + $scope.applicationComposite = CompositeApplicationRoleMapping.query({realm : realm.realm, userId : user.username, application : $scope.application.name}); + $scope.selectedApplicationRoles = []; + $scope.selectedApplicationMappings = []; + }); + }; + + $scope.deleteApplicationRole = function() { + $http.delete(authUrl + '/admin/realms/' + realm.realm + '/applications/' + application.name + '/scope-mappings/applications/' + $scope.targetApp.name, + {data : $scope.selectedApplicationMappings, headers : {"content-type" : "application/json"}}).success(function() { + $scope.applicationMappings = ApplicationRoleMapping.query({realm : realm.realm, userId : user.username, application : $scope.application.name}); + $scope.applicationRoles = AvailableApplicationRoleMapping.query({realm : realm.realm, userId : user.username, application : $scope.application.name}); + $scope.applicationComposite = CompositeApplicationRoleMapping.query({realm : realm.realm, userId : user.username, application : $scope.application.name}); + $scope.selectedApplicationRoles = []; + $scope.selectedApplicationMappings = []; + }); + }; + + + $scope.changeApplication = function() { + console.log('changeApplication'); + if ($scope.targetApp) { + console.log('load available'); + $scope.applicationMappings = ApplicationApplicationScopeMapping.query({realm : realm.realm, application : application.name, targetApp : $scope.targetApp.name}); + $scope.applicationRoles = ApplicationAvailableApplicationScopeMapping.query({realm : realm.realm, application : application.name, targetApp : $scope.targetApp.name}); + $scope.applicationComposite = ApplicationCompositeApplicationScopeMapping.query({realm : realm.realm, application : application.name, targetApp : $scope.targetApp.name}); + } else { + $scope.applicationRoles = null; + $scope.applicationMappings = null; + $scope.applicationComposite = null; + } + $scope.selectedApplicationRoles = []; + $scope.selectedApplicationMappings = []; + }; + + }); diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js index ac886e1192..ee05261fe5 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/users.js @@ -88,6 +88,8 @@ module.controller('UserRoleMappingCtrl', function($scope, $http, realm, user, ap $scope.applicationMappings = ApplicationRoleMapping.query({realm : realm.realm, userId : user.username, application : $scope.application.name}); } else { $scope.applicationRoles = null; + $scope.applicationMappings = null; + $scope.applicationComposite = null; } $scope.selectedApplicationRoles = []; $scope.selectedApplicationMappings = []; diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js index eaa77bb295..6d33070147 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/services.js @@ -282,6 +282,20 @@ module.factory('ApplicationRealmScopeMapping', function($resource) { }); }); +module.factory('ApplicationAvailableRealmScopeMapping', function($resource) { + return $resource(authUrl + '/admin/realms/:realm/applications/:application/scope-mappings/realm/available', { + realm : '@realm', + application : '@application' + }); +}); + +module.factory('ApplicationCompositeRealmScopeMapping', function($resource) { + return $resource(authUrl + '/admin/realms/:realm/applications/:application/scope-mappings/realm/composite', { + realm : '@realm', + application : '@application' + }); +}); + module.factory('ApplicationApplicationScopeMapping', function($resource) { return $resource(authUrl + '/admin/realms/:realm/applications/:application/scope-mappings/applications/:targetApp', { realm : '@realm', @@ -290,6 +304,22 @@ module.factory('ApplicationApplicationScopeMapping', function($resource) { }); }); +module.factory('ApplicationAvailableApplicationScopeMapping', function($resource) { + return $resource(authUrl + '/admin/realms/:realm/applications/:application/scope-mappings/applications/:targetApp/available', { + realm : '@realm', + application : '@application', + targetApp : '@targetApp' + }); +}); + +module.factory('ApplicationCompositeApplicationScopeMapping', function($resource) { + return $resource(authUrl + '/admin/realms/:realm/applications/:application/scope-mappings/applications/:targetApp/composite', { + realm : '@realm', + application : '@application', + targetApp : '@targetApp' + }); +}); + module.factory('RealmRoles', function($resource) { diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-scope-mappings.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-scope-mappings.html index d8f3f5f554..de2e30d2db 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-scope-mappings.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/application-scope-mappings.html @@ -49,6 +49,17 @@ ng-model="selectedRealmMappings" ng-options="r.name for r in realmMappings"> +
+ +