diff --git a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-app.js b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-app.js index ecb008de47..7c5e7fa176 100644 --- a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-app.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-app.js @@ -59,6 +59,23 @@ module.config(['$routeProvider', function ($routeProvider) { } }, controller: 'ResourceServerDetailCtrl' + }).when('/realms/:realm/clients/:client/authz/resource-server/export-settings', { + templateUrl: resourceUrl + '/partials/authz/resource-server-export-settings.html', + resolve: { + realm: function (RealmLoader) { + return RealmLoader(); + }, + client : function(ClientLoader) { + return ClientLoader(); + }, + clients: function (ClientListLoader) { + return ClientListLoader(); + }, + serverInfo: function (ServerInfoLoader) { + return ServerInfoLoader(); + } + }, + controller: 'ResourceServerDetailCtrl' }).when('/realms/:realm/clients/:client/authz/resource-server/evaluate', { templateUrl: resourceUrl + '/partials/authz/policy/resource-server-policy-evaluate.html', resolve: { diff --git a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js index 5d8d4629cf..e58a1b7d01 100644 --- a/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/authz/authz-controller.js @@ -79,7 +79,72 @@ module.controller('ResourceServerDetailCtrl', function($scope, $http, $route, $l }); }); -module.controller('ResourceServerResourceCtrl', function($scope, $http, $route, $location, realm, ResourceServer, ResourceServerResource, client) { +var Resources = { + delete: function(ResourceServerResource, realm, client, $scope, AuthzDialog, $location, Notifications, $route) { + ResourceServerResource.permissions({ + realm : realm, + client : client.id, + rsrid : $scope.resource._id + }, function (permissions) { + var msg = ""; + + if (permissions.length > 0 && !$scope.deleteConsent) { + msg = "
This resource is referenced in some permissions:
"; + msg += "If you remove this resource, the permissions above will be affected and will not be associated with this resource anymore.
"; + } + + AuthzDialog.confirmDeleteWithMsg($scope.resource.name, "Resource", msg, function() { + ResourceServerResource.delete({realm : realm, client : $scope.client.id, rsrid : $scope.resource._id}, null, function() { + $location.url("/realms/" + realm + "/clients/" + $scope.client.id + "/authz/resource-server/resource"); + $route.reload(); + Notifications.success("The resource has been deleted."); + }); + }); + }); + } +} + +var Policies = { + delete: function(service, realm, client, $scope, AuthzDialog, $location, Notifications, $route, isPermission) { + var msg = ""; + + service.dependentPolicies({ + realm : realm, + client : client.id, + id : $scope.policy.id + }, function (dependentPolicies) { + if (dependentPolicies.length > 0 && !$scope.deleteConsent) { + msg = "This policy is being used by other policies:
"; + msg += "If you remove this policy, the policies above will be affected and will not be associated with this policy anymore.
"; + } + + AuthzDialog.confirmDeleteWithMsg($scope.policy.name, isPermission ? "Permission" : "Policy", msg, function() { + service.delete({realm : realm, client : $scope.client.id, id : $scope.policy.id}, null, function() { + if (isPermission) { + $location.url("/realms/" + realm + "/clients/" + $scope.client.id + "/authz/resource-server/permission"); + Notifications.success("The permission has been deleted."); + } else { + $location.url("/realms/" + realm + "/clients/" + $scope.client.id + "/authz/resource-server/policy"); + Notifications.success("The policy has been deleted."); + } + $route.reload(); + }); + }); + }); + } +} + +module.controller('ResourceServerResourceCtrl', function($scope, $http, $route, $location, realm, ResourceServer, ResourceServerResource, client, AuthzDialog, Notifications) { $scope.realm = realm; $scope.client = client; @@ -171,6 +236,11 @@ module.controller('ResourceServerResourceCtrl', function($scope, $http, $route, } } }; + + $scope.delete = function(resource) { + $scope.resource = resource; + Resources.delete(ResourceServerResource, $route.current.params.realm, client, $scope, AuthzDialog, $location, Notifications, $route); + }; }); module.controller('ResourceServerResourceDetailCtrl', function($scope, $http, $route, $location, realm, ResourceServer, client, ResourceServerResource, ResourceServerScope, AuthzDialog, Notifications) { @@ -282,30 +352,7 @@ module.controller('ResourceServerResourceDetailCtrl', function($scope, $http, $r } $scope.remove = function() { - ResourceServerResource.permissions({ - realm : $route.current.params.realm, - client : client.id, - rsrid : $scope.resource._id - }, function (permissions) { - var msg = ""; - - if (permissions.length > 0 && !$scope.deleteConsent) { - msg = "This resource is referenced in some policies:
"; - msg += "If you remove this resource, the policies above will be affected and will not be associated with this resource anymore.
"; - } - - AuthzDialog.confirmDeleteWithMsg($scope.resource.name, "Resource", msg, function() { - ResourceServerResource.delete({realm : realm.realm, client : $scope.client.id, rsrid : $scope.resource._id}, null, function() { - $location.url("/realms/" + realm.realm + "/clients/" + $scope.client.id + "/authz/resource-server/resource"); - Notifications.success("The resource has been deleted."); - }); - }); - }); + Resources.delete(ResourceServerResource, $route.current.params.realm, client, $scope, AuthzDialog, $location, Notifications, $route); } $scope.reset = function() { @@ -335,7 +382,37 @@ module.controller('ResourceServerResourceDetailCtrl', function($scope, $http, $r } }); -module.controller('ResourceServerScopeCtrl', function($scope, $http, $route, $location, realm, ResourceServer, ResourceServerScope, client) { +var Scopes = { + delete: function(ResourceServerScope, realm, client, $scope, AuthzDialog, $location, Notifications, $route) { + ResourceServerScope.permissions({ + realm : realm, + client : client.id, + id : $scope.scope.id + }, function (permissions) { + var msg = ""; + + if (permissions.length > 0 && !$scope.deleteConsent) { + msg = "This scope is referenced in some permissions:
"; + msg += "If you remove this scope, the permissions above will be affected and will not be associated with this scope anymore.
"; + } + + AuthzDialog.confirmDeleteWithMsg($scope.scope.name, "Scope", msg, function() { + ResourceServerScope.delete({realm : realm, client : $scope.client.id, id : $scope.scope.id}, null, function() { + $location.url("/realms/" + realm + "/clients/" + $scope.client.id + "/authz/resource-server/scope"); + $route.reload(); + Notifications.success("The scope has been deleted."); + }); + }); + }); + } +} + +module.controller('ResourceServerScopeCtrl', function($scope, $http, $route, $location, realm, ResourceServer, ResourceServerScope,client, AuthzDialog, Notifications) { $scope.realm = realm; $scope.client = client; @@ -427,6 +504,11 @@ module.controller('ResourceServerScopeCtrl', function($scope, $http, $route, $lo } } }; + + $scope.delete = function(scope) { + $scope.scope = scope; + Scopes.delete(ResourceServerScope, $route.current.params.realm, client, $scope, AuthzDialog, $location, Notifications, $route); + }; }); module.controller('ResourceServerScopeDetailCtrl', function($scope, $http, $route, $location, realm, ResourceServer, client, ResourceServerScope, AuthzDialog, Notifications) { @@ -496,30 +578,7 @@ module.controller('ResourceServerScopeDetailCtrl', function($scope, $http, $rout } $scope.remove = function() { - ResourceServerScope.permissions({ - realm : $route.current.params.realm, - client : client.id, - id : $scope.scope.id - }, function (permissions) { - var msg = ""; - - if (permissions.length > 0 && !$scope.deleteConsent) { - msg = "This scope is referenced in some policies:
"; - msg += "If you remove this scope, the policies above will be affected and will not be associated with this scope anymore.
"; - } - - AuthzDialog.confirmDeleteWithMsg($scope.scope.name, "Scope", msg, function() { - ResourceServerScope.delete({realm : realm.realm, client : $scope.client.id, id : $scope.scope.id}, null, function() { - $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/scope"); - Notifications.success("The scope has been deleted."); - }); - }); - }); + Scopes.delete(ResourceServerScope, $route.current.params.realm, client, $scope, AuthzDialog, $location, Notifications, $route); } $scope.reset = function() { @@ -548,7 +607,7 @@ module.controller('ResourceServerScopeDetailCtrl', function($scope, $http, $rout } }); -module.controller('ResourceServerPolicyCtrl', function($scope, $http, $route, $location, realm, ResourceServer, ResourceServerPolicy, PolicyProvider, client) { +module.controller('ResourceServerPolicyCtrl', function($scope, $http, $route, $location, realm, ResourceServer, ResourceServerPolicy, PolicyProvider, client, AuthzDialog, Notifications) { $scope.realm = realm; $scope.client = client; $scope.policyProviders = []; @@ -644,9 +703,14 @@ module.controller('ResourceServerPolicyCtrl', function($scope, $http, $route, $l } } }; + + $scope.delete = function(policy) { + $scope.policy = policy; + Policies.delete(ResourceServerPolicy, $route.current.params.realm, client, $scope, AuthzDialog, $location, Notifications, $route, false); + }; }); -module.controller('ResourceServerPermissionCtrl', function($scope, $http, $route, $location, realm, ResourceServer, ResourceServerPermission, PolicyProvider, client) { +module.controller('ResourceServerPermissionCtrl', function($scope, $http, $route, $location, realm, ResourceServer, ResourceServerPermission, PolicyProvider, client, AuthzDialog, Notifications) { $scope.realm = realm; $scope.client = client; $scope.policyProviders = []; @@ -741,6 +805,11 @@ module.controller('ResourceServerPermissionCtrl', function($scope, $http, $route } } }; + + $scope.delete = function(policy) { + $scope.policy = policy; + Policies.delete(ResourceServerPermission, $route.current.params.realm, client, $scope, AuthzDialog, $location, Notifications, $route, true); + }; }); module.controller('ResourceServerPolicyDroolsDetailCtrl', function($scope, $http, $route, realm, client, PolicyController) { @@ -1979,35 +2048,7 @@ module.service("PolicyController", function($http, $route, $location, ResourceSe }); $scope.remove = function() { - var msg = ""; - - service.dependentPolicies({ - realm : $route.current.params.realm, - client : client.id, - id : $scope.policy.id - }, function (dependentPolicies) { - if (dependentPolicies.length > 0 && !$scope.deleteConsent) { - msg = "This policy is being used by other policies:
"; - msg += "If you remove this policy, the policies above will be affected and will not be associated with this policy anymore.
"; - } - - AuthzDialog.confirmDeleteWithMsg($scope.policy.name, "Policy", msg, function() { - service.delete({realm : $scope.realm.realm, client : $scope.client.id, id : $scope.policy.id}, null, function() { - if (delegate.isPermission()) { - $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/permission"); - Notifications.success("The permission has been deleted."); - } else { - $location.url("/realms/" + realm.realm + "/clients/" + client.id + "/authz/resource-server/policy"); - Notifications.success("The policy has been deleted."); - } - }); - }); - }); + Policies.delete(ResourceServerPolicy, $route.current.params.realm, client, $scope, AuthzDialog, $location, Notifications, $route, delegate.isPermission()); } } }); diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/resource-server-permission-list.html b/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/resource-server-permission-list.html index 2101643a56..7480ae84bb 100644 --- a/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/resource-server-permission-list.html +++ b/themes/src/main/resources/theme/base/admin/resources/partials/authz/permission/resource-server-permission-list.html @@ -67,7 +67,7 @@+ |
@@ -88,9 +88,12 @@
{{:: 'authz-hide-details' | translate}}
|
+
+ {{:: 'delete' | translate}}
+ |
| ||||||||||||||||||||||||||||||||||||||
+ |
|