Delete action on lists

This commit is contained in:
Pedro Igor 2017-05-19 19:08:28 -03:00
parent 62ffab7239
commit d1d590b45c
9 changed files with 164 additions and 167 deletions

View file

@ -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: {

View file

@ -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 = "<p>This resource is referenced in some permissions:</p>";
msg += "<ul>";
for (i = 0; i < permissions.length; i++) {
msg+= "<li><strong>" + permissions[i].name + "</strong></li>";
}
msg += "</ul>";
msg += "<p>If you remove this resource, the permissions above will be affected and will not be associated with this resource anymore.</p>";
}
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 = "<p>This policy is being used by other policies:</p>";
msg += "<ul>";
for (i = 0; i < dependentPolicies.length; i++) {
msg+= "<li><strong>" + dependentPolicies[i].name + "</strong></li>";
}
msg += "</ul>";
msg += "<p>If you remove this policy, the policies above will be affected and will not be associated with this policy anymore.</p>";
}
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 = "<p>This resource is referenced in some policies:</p>";
msg += "<ul>";
for (i = 0; i < permissions.length; i++) {
msg+= "<li><strong>" + permissions[i].name + "</strong></li>";
}
msg += "</ul>";
msg += "<p>If you remove this resource, the policies above will be affected and will not be associated with this resource anymore.</p>";
}
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 = "<p>This scope is referenced in some permissions:</p>";
msg += "<ul>";
for (i = 0; i < permissions.length; i++) {
msg+= "<li><strong>" + permissions[i].name + "</strong></li>";
}
msg += "</ul>";
msg += "<p>If you remove this scope, the permissions above will be affected and will not be associated with this scope anymore.</p>";
}
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 = "<p>This scope is referenced in some policies:</p>";
msg += "<ul>";
for (i = 0; i < permissions.length; i++) {
msg+= "<li><strong>" + permissions[i].name + "</strong></li>";
}
msg += "</ul>";
msg += "<p>If you remove this scope, the policies above will be affected and will not be associated with this scope anymore.</p>";
}
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 = "<p>This policy is being used by other policies:</p>";
msg += "<ul>";
for (i = 0; i < dependentPolicies.length; i++) {
msg+= "<li><strong>" + dependentPolicies[i].name + "</strong></li>";
}
msg += "</ul>";
msg += "<p>If you remove this policy, the policies above will be affected and will not be associated with this policy anymore.</p>";
}
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());
}
}
});

View file

@ -67,7 +67,7 @@
</thead>
<tfoot data-ng-show="policies && (policies.length >= query.max || query.first > 0)">
<tr>
<td colspan="7">
<td colspan="8">
<div class="table-nav">
<button data-ng-click="firstPage()" class="first" ng-disabled="query.first == 0">{{:: 'first-page' | translate}}</button>
<button data-ng-click="previousPage()" class="prev" ng-disabled="query.first == 0">{{:: 'previous-page' | translate}}</button>
@ -87,9 +87,12 @@
<td ng-if="policy.details.loaded" class="kc-action-cell" data-ng-click="showDetails(policy);">
{{:: 'authz-hide-details' | translate}}
</td>
<td class="kc-action-cell" ng-click="delete(policy);">
{{:: 'delete' | translate}}
</td>
</tr>
<tr ng-if="policy.details && policy.details.loaded" ng-repeat-end="">
<td colspan="4">
<td colspan="5">
<div id="details">
<table class="table kc-authz-table-expanded table-striped">
<thead>

View file

@ -68,7 +68,7 @@
</thead>
<tfoot data-ng-show="policies && (policies.length >= query.max || query.first > 0)">
<tr>
<td colspan="7">
<td colspan="8">
<div class="table-nav">
<button data-ng-click="firstPage()" class="first" ng-disabled="query.first == 0">{{:: 'first-page' | translate}}</button>
<button data-ng-click="previousPage()" class="prev" ng-disabled="query.first == 0">{{:: 'previous-page' | translate}}</button>
@ -88,9 +88,12 @@
<td ng-if="policy.details.loaded" class="kc-action-cell" data-ng-click="showDetails(policy);">
{{:: 'authz-hide-details' | translate}}
</td>
<td class="kc-action-cell" ng-click="delete(policy);">
{{:: 'delete' | translate}}
</td>
</tr>
<tr ng-if="policy.details && policy.details.loaded" ng-repeat-end="">
<td colspan="4">
<td colspan="5">
<div id="details">
<table class="table kc-authz-table-expanded table-striped">
<thead>

View file

@ -57,29 +57,6 @@
</div>
</div>
</fieldset>
<fieldset class="border-top" data-ng-show="server.id">
<legend><span class="text">{{:: 'authz-export-settings' | translate}}</span>
<kc-tooltip>{{:: 'authz-export-settings.tooltip' | translate}}</kc-tooltip>
</legend>
<div class="form-group">
<label class="col-md-2 control-label" for="server.allowRemoteResourceManagement">{{:: 'authz-export-settings' | translate}}</label>
<div class="col-md-6">
<button data-ng-click="export()" class="btn btn-primary" data-ng-hide="settings">{{:: 'export' | translate}}</button>
<button data-ng-click="downloadSettings()" class="btn btn-primary" data-ng-show="settings">{{:: 'download' | translate}}</button>
<button data-ng-click="cancelExport()" class="btn btn-primary" data-ng-show="settings">{{:: 'cancel' | translate}}</button>
</div>
<kc-tooltip>{{:: 'authz-export-settings.tooltip' | translate}}</kc-tooltip>
</div>
<fieldset class="margin-top">
<div class="form-group" ng-show="settings">
<div class="col-sm-12">
<a class="btn btn-primary btn-lg" data-ng-click="download()" type="submit" ng-show="installation">{{:: 'download' | translate}}</a>
<textarea class="form-control" rows="20" kc-select-action="click">{{settings}}</textarea>
</div>
</div>
</fieldset>
</fieldset>
</form>
</div>

View file

@ -4,66 +4,15 @@
<li><a href="#/realms/{{realm.realm}}/clients">{{:: 'clients' | translate}}</a></li>
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}">{{client.clientId}}</a></li>
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'authz-authorization' | translate}}</a></li>
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'settings' | translate}}</a></li>
<li><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server">{{:: 'export-settings' | translate}}</a></li>
</ol>
<kc-tabs-resource-server></kc-tabs-resource-server>
<form class="form-horizontal" name="clientForm" novalidate>
<form class="form-horizontal" name="exportForm" novalidate>
<fieldset>
<div class="form-group">
<label for="import-file" class="col-sm-2 control-label">{{:: 'import' | translate}}</label>
<div class="col-md-6">
<div class="controls kc-button-input-file" data-ng-show="!importing">
<label for="import-file" class="btn btn-default">{{:: 'select-file' | translate}} <i class="pficon pficon-import"></i></label>
<input id="import-file" type="file" class="hidden" kc-on-read-file="onFileSelect($fileContent)">
</div>
<div class="col-md-6" data-ng-show="importing">
<input type="button" class="btn btn-default" data-ng-click="viewImportDetails()" value="{{:: 'view-details' | translate}}"/>
</div>
</div>
<kc-tooltip>{{:: 'authz-import-config.tooltip' | translate}}</kc-tooltip>
</div>
<div class="form-group">
<div class="col-md-10 col-md-offset-2" data-ng-show="importing">
<button class="btn btn-default" data-ng-click="import()" data-ng-disabled="!changed">Import</button>
<button kc-cancel data-ng-click="reset()">Cancel</button>
</div>
</div>
</fieldset>
<fieldset class="border-top" data-ng-hide="importing">
<div class="form-group">
<label class="col-md-2 control-label" for="server.policyEnforcementMode">{{:: 'authz-policy-enforcement-mode' | translate}}</label>
<div class="col-md-2">
<select class="form-control" id="server.policyEnforcementMode" data-ng-model="server.policyEnforcementMode">
<option value="ENFORCING">{{:: 'authz-policy-enforcement-mode-enforcing' | translate}}</option>
<option value="PERMISSIVE">{{:: 'authz-policy-enforcement-mode-permissive' | translate}}</option>
<option value="DISABLED">{{:: 'authz-policy-enforcement-mode-disabled' | translate}}</option>
</select>
</div>
<kc-tooltip>{{:: 'authz-policy-enforcement-mode.tooltip' | translate}}</kc-tooltip>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="server.allowRemoteResourceManagement">{{:: 'authz-remote-resource-management' | translate}}</label>
<div class="col-md-6">
<input ng-model="server.allowRemoteResourceManagement" id="server.allowRemoteResourceManagement" onoffswitch />
</div>
<kc-tooltip>{{:: 'authz-remote-resource-management.tooltip' | translate}}</kc-tooltip>
</div>
<div class="form-group" data-ng-show="access.manageAuthorization">
<div class="col-md-10 col-md-offset-2">
<button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
<button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
</div>
</div>
</fieldset>
<fieldset class="border-top" data-ng-show="server.id">
<legend><span class="text">{{:: 'authz-export-settings' | translate}}</span>
<kc-tooltip>{{:: 'authz-export-settings.tooltip' | translate}}</kc-tooltip>
</legend>
<div class="form-group">
<label class="col-md-2 control-label" for="server.allowRemoteResourceManagement">{{:: 'authz-export-settings' | translate}}</label>
<label class="col-md-2 control-label">{{:: 'authz-export-settings' | translate}}</label>
<div class="col-md-6">
<button data-ng-click="export()" class="btn btn-primary" data-ng-hide="settings">{{:: 'export' | translate}}</button>
<button data-ng-click="downloadSettings()" class="btn btn-primary" data-ng-show="settings">{{:: 'download' | translate}}</button>

View file

@ -64,7 +64,7 @@
<th>{{:: 'type' | translate}}</th>
<th>{{:: 'authz-uri' | translate}}</th>
<th>{{:: 'authz-owner' | translate}}</th>
<th colspan="2">{{:: 'actions' | translate}}</th>
<th colspan="3">{{:: 'actions' | translate}}</th>
</tr>
</thead>
<tfoot data-ng-show="resources && (resources.length >= query.max || query.first > 0)">
@ -99,9 +99,12 @@
<td class="kc-action-cell" ng-click="createPolicy(resource);">
{{:: 'authz-create-permission' | translate}}
</td>
<td class="kc-action-cell" ng-click="delete(resource);">
{{:: 'delete' | translate}}
</td>
</tr>
<tr ng-if="resource.details && resource.details.loaded" ng-repeat-end="">
<td colspan="6">
<td colspan="7">
<div id="details">
<table class="table kc-authz-table-expanded table-striped">
<thead>

View file

@ -36,7 +36,7 @@
</tr>
<tr data-ng-hide="scopes.length == 0">
<th>{{:: 'name' | translate}}</th>
<th colspan="2">{{:: 'actions' | translate}}</th>
<th colspan="3">{{:: 'actions' | translate}}</th>
</tr>
</thead>
<tfoot data-ng-show="scopes && (scopes.length >= query.max || query.first > 0)">
@ -52,7 +52,7 @@
</tfoot>
<tbody>
<tr ng-repeat-start="scope in scopes | filter:search | orderBy:'name'">
<td><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/scope/{{scope.id}}">{{scope.name}}</a></td>
<td width="70%"><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/scope/{{scope.id}}">{{scope.name}}</a></td>
<td ng-if="!scope.details.loaded" class="kc-action-cell" data-ng-click="showDetails(scope);">
{{:: 'authz-show-details' | translate}}
</td>
@ -62,9 +62,12 @@
<td class="kc-action-cell" ng-click="createPolicy(scope);">
{{:: 'authz-create-permission' | translate}}
</td>
<td class="kc-action-cell" ng-click="delete(scope);">
{{:: 'delete' | translate}}
</td>
</tr>
<tr ng-if="scope.details && scope.details.loaded" ng-repeat-end="">
<td colspan="3">
<td colspan="4">
<div id="details">
<table class="table kc-authz-table-expanded table-striped">
<thead>

View file

@ -9,5 +9,6 @@
<li ng-class="{active: path[6] == 'policy'}" data-ng-hide="create"><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy">{{:: 'authz-policies' | translate}}</a></li>
<li ng-class="{active: path[6] == 'permission'}" data-ng-hide="create"><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/permission">{{:: 'authz-permissions' | translate}}</a></li>
<li ng-class="{active: path[6] == 'evaluate'}" data-ng-hide="create"><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/evaluate">{{:: 'authz-evaluate' | translate}}</a></li>
<li ng-class="{active: path[6] == 'export-settings'}" data-ng-hide="create"><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/export-settings">{{:: 'authz-export-settings' | translate}}</a></li>
</ul>
</div>