[KEYCLOAK-4549] - Scope Permission Form is not showing saved resource
This commit is contained in:
parent
e7cd8d41c6
commit
45caea4dbd
2 changed files with 57 additions and 42 deletions
|
@ -1042,6 +1042,7 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.selectResource = function() {
|
$scope.selectResource = function() {
|
||||||
|
$scope.policy.config.scopes = null;
|
||||||
if ($scope.policy.config.resources) {
|
if ($scope.policy.config.resources) {
|
||||||
ResourceServerResource.scopes({
|
ResourceServerResource.scopes({
|
||||||
realm: $route.current.params.realm,
|
realm: $route.current.params.realm,
|
||||||
|
@ -1055,27 +1056,32 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
|
||||||
},
|
},
|
||||||
|
|
||||||
onInitUpdate : function(policy) {
|
onInitUpdate : function(policy) {
|
||||||
policy.config.resources = eval(policy.config.resources);
|
ResourceServerPolicy.resources({
|
||||||
|
realm : $route.current.params.realm,
|
||||||
if (policy.config.resources == null) {
|
client : client.id,
|
||||||
policy.config.resources = [];
|
id : policy.id
|
||||||
}
|
}, function(resources) {
|
||||||
|
if (resources.length > 0) {
|
||||||
if (policy.config.resources.length > 0) {
|
for (i = 0; i < resources.length; i++) {
|
||||||
|
ResourceServerResource.get({
|
||||||
|
realm: $route.current.params.realm,
|
||||||
|
client: client.id,
|
||||||
|
rsrid: resources[0]._id,
|
||||||
|
}, function (resource) {
|
||||||
ResourceServerResource.query({
|
ResourceServerResource.query({
|
||||||
realm: $route.current.params.realm,
|
realm: $route.current.params.realm,
|
||||||
client: client.id,
|
client: client.id,
|
||||||
_id: policy.config.resources[0],
|
_id: resource._id,
|
||||||
deep: false
|
deep: false
|
||||||
}, function (data) {
|
}, function (resource) {
|
||||||
data[0].text = data[0].name;
|
resource[0].text = resource[0].name;
|
||||||
$scope.policy.config.resources = data[0];
|
$scope.policy.config.resources = resource[0];
|
||||||
ResourceServerResource.scopes({
|
ResourceServerResource.scopes({
|
||||||
realm: $route.current.params.realm,
|
realm: $route.current.params.realm,
|
||||||
client: client.id,
|
client: client.id,
|
||||||
rsrid: policy.config.resources[0]
|
rsrid: resource[0]._id
|
||||||
}, function (data) {
|
}, function (scopes) {
|
||||||
$scope.policy.config.resources.scopes = data;
|
$scope.policy.config.resources.scopes = scopes;
|
||||||
});
|
});
|
||||||
ResourceServerPolicy.scopes({
|
ResourceServerPolicy.scopes({
|
||||||
realm: $route.current.params.realm,
|
realm: $route.current.params.realm,
|
||||||
|
@ -1088,8 +1094,10 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
policy.config.resources = null;
|
$scope.policy.config.resources = null;
|
||||||
ResourceServerPolicy.scopes({
|
ResourceServerPolicy.scopes({
|
||||||
realm : $route.current.params.realm,
|
realm : $route.current.params.realm,
|
||||||
client : client.id,
|
client : client.id,
|
||||||
|
@ -1102,6 +1110,7 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
policy.config.applyPolicies = [];
|
policy.config.applyPolicies = [];
|
||||||
ResourceServerPolicy.associatedPolicies({
|
ResourceServerPolicy.associatedPolicies({
|
||||||
|
@ -1119,12 +1128,14 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
|
||||||
onUpdate : function() {
|
onUpdate : function() {
|
||||||
if ($scope.policy.config.resources != null) {
|
if ($scope.policy.config.resources != null) {
|
||||||
$scope.policy.config.resources = JSON.stringify([$scope.policy.config.resources._id]);
|
$scope.policy.config.resources = JSON.stringify([$scope.policy.config.resources._id]);
|
||||||
|
} else {
|
||||||
|
$scope.policy.config.resources = JSON.stringify([""]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var scopes = [];
|
var scopes = [];
|
||||||
|
|
||||||
for (i = 0; i < $scope.policy.config.scopes.length; i++) {
|
for (i = 0; i < $scope.policy.config.scopes.length; i++) {
|
||||||
if ($scope.policy.config.resources == null) {
|
if ($scope.policy.config.scopes[i].id) {
|
||||||
scopes.push($scope.policy.config.scopes[i].id);
|
scopes.push($scope.policy.config.scopes[i].id);
|
||||||
} else {
|
} else {
|
||||||
scopes.push($scope.policy.config.scopes[i]);
|
scopes.push($scope.policy.config.scopes[i]);
|
||||||
|
@ -1237,8 +1248,12 @@ module.controller('ResourceServerPolicyUserDetailCtrl', function($scope, $route,
|
||||||
$scope.selectedUsers.push(user);
|
$scope.selectedUsers.push(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.removeFromList = function(list, index) {
|
$scope.removeFromList = function(list, user) {
|
||||||
list.splice(index, 1);
|
for (i = 0; i < angular.copy(list).length; i++) {
|
||||||
|
if (user == list[i]) {
|
||||||
|
list.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
<tr ng-repeat="user in selectedUsers | orderBy:'username'">
|
<tr ng-repeat="user in selectedUsers | orderBy:'username'">
|
||||||
<td>{{user.username}}</td>
|
<td>{{user.username}}</td>
|
||||||
<td class="kc-action-cell">
|
<td class="kc-action-cell">
|
||||||
<button class="btn btn-default btn-block btn-sm" ng-click="removeFromList(selectedUsers, $index);">{{:: 'remove' | translate}}</button>
|
<button class="btn btn-default btn-block btn-sm" ng-click="removeFromList(selectedUsers, user);">{{:: 'remove' | translate}}</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr data-ng-show="!selectedUsers.length">
|
<tr data-ng-show="!selectedUsers.length">
|
||||||
|
|
Loading…
Reference in a new issue