mirror of
https://github.com/sismics/docs.git
synced 2024-11-25 15:17:57 +01:00
#18: Add/display group ACL in web UI
This commit is contained in:
parent
c1c2228937
commit
7be2e1b9e5
@ -207,7 +207,7 @@ public class DocumentDao {
|
||||
Map<String, Object> parameterMap = new HashMap<String, Object>();
|
||||
List<String> criteriaList = new ArrayList<String>();
|
||||
|
||||
StringBuilder sb = new StringBuilder("select d.DOC_ID_C c0, d.DOC_TITLE_C c1, d.DOC_DESCRIPTION_C c2, d.DOC_CREATEDATE_D c3, d.DOC_LANGUAGE_C c4, ");
|
||||
StringBuilder sb = new StringBuilder("select distinct d.DOC_ID_C c0, d.DOC_TITLE_C c1, d.DOC_DESCRIPTION_C c2, d.DOC_CREATEDATE_D c3, d.DOC_LANGUAGE_C c4, ");
|
||||
sb.append(" (select count(s.SHA_ID_C) from T_SHARE s, T_ACL ac where ac.ACL_SOURCEID_C = d.DOC_ID_C and ac.ACL_TARGETID_C = s.SHA_ID_C and ac.ACL_DELETEDATE_D is null and s.SHA_DELETEDATE_D is null) c5, ");
|
||||
sb.append(" (select count(f.FIL_ID_C) from T_FILE f where f.FIL_DELETEDATE_D is null and f.FIL_IDDOC_C = d.DOC_ID_C) c6 ");
|
||||
sb.append(" from T_DOCUMENT d ");
|
||||
|
@ -35,18 +35,21 @@ angular.module('docs').controller('DocumentViewPermissions', function ($scope, $
|
||||
if ($scope.acl.perm == 'READWRITE') {
|
||||
acls = [{
|
||||
source: $stateParams.id,
|
||||
username: $scope.acl.username,
|
||||
perm: 'READ'
|
||||
target: $scope.acl.target.name,
|
||||
perm: 'READ',
|
||||
type: $scope.acl.target.type
|
||||
}, {
|
||||
source: $stateParams.id,
|
||||
username: $scope.acl.username,
|
||||
perm: 'WRITE'
|
||||
target: $scope.acl.target.name,
|
||||
perm: 'WRITE',
|
||||
type: $scope.acl.target.type
|
||||
}];
|
||||
} else {
|
||||
acls = [{
|
||||
source: $stateParams.id,
|
||||
username: $scope.acl.username,
|
||||
perm: $scope.acl.perm
|
||||
target: $scope.acl.target.name,
|
||||
perm: $scope.acl.perm,
|
||||
type: $scope.acl.target.type
|
||||
}];
|
||||
}
|
||||
|
||||
@ -74,7 +77,20 @@ angular.module('docs').controller('DocumentViewPermissions', function ($scope, $
|
||||
.get({
|
||||
search: $viewValue
|
||||
}).then(function(data) {
|
||||
deferred.resolve(_.pluck(data.users, 'name'), true);
|
||||
var output = [];
|
||||
|
||||
// Add the type to use later
|
||||
output.push.apply(output, _.map(data.users, function(user) {
|
||||
user.type = 'USER';
|
||||
return user;
|
||||
}));
|
||||
output.push.apply(output, _.map(data.groups, function(group) {
|
||||
group.type = 'GROUP';
|
||||
return group;
|
||||
}));
|
||||
|
||||
// Send the data to the typeahead directive
|
||||
deferred.resolve(output, true);
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
15
docs-web/src/main/webapp/src/app/docs/directive/Acl.js
Normal file
15
docs-web/src/main/webapp/src/app/docs/directive/Acl.js
Normal file
@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* ACL directive.
|
||||
*/
|
||||
angular.module('docs').directive('acl', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: '<span ng-if="data.type"><em>{{ data.type == \'SHARE\' ? \'Shared\' : (data.type == \'USER\' ? \'User\' : \'Group\') }}</em> {{ data.name }}</span>',
|
||||
replace: true,
|
||||
scope: {
|
||||
data: '='
|
||||
}
|
||||
}
|
||||
});
|
@ -74,6 +74,7 @@
|
||||
<script src="app/docs/directive/AuditLog.js" type="text/javascript"></script>
|
||||
<script src="app/docs/directive/InlineEdit.js" type="text/javascript"></script>
|
||||
<script src="app/docs/directive/ImgError.js" type="text/javascript"></script>
|
||||
<script src="app/docs/directive/Acl.js" type="text/javascript"></script>
|
||||
<!-- endref -->
|
||||
</head>
|
||||
<body>
|
||||
|
@ -0,0 +1 @@
|
||||
<a tabindex="-1"><acl data="match.model"></acl></a>
|
@ -5,7 +5,7 @@
|
||||
</tr>
|
||||
|
||||
<tr ng-repeat="(id, acl) in acls">
|
||||
<td><em>{{ acl[0].type == 'SHARE' ? 'Shared' : 'User' }}</em> {{ acl[0].name }}</td>
|
||||
<td><acl data="acl[0]"></acl></td>
|
||||
<td>
|
||||
<span class="label label-default" style="margin-right: 6px;" ng-repeat="a in acl | orderBy: 'perm'">
|
||||
{{ a.perm }}
|
||||
@ -25,10 +25,16 @@
|
||||
<label class="col-sm-2 control-label" for="inputTarget">For</label>
|
||||
<div class="col-sm-3">
|
||||
<input required ng-maxlength="50" class="form-control" type="text" id="inputTarget"
|
||||
placeholder="Type a username" name="username" ng-model="acl.target" autocomplete="off"
|
||||
typeahead="username for username in getTargetAclTypeahead($viewValue) | filter: $viewValue"
|
||||
placeholder="Search a user or group" name="target" ng-model="acl.target" autocomplete="off"
|
||||
typeahead="target as target.name for target in getTargetAclTypeahead($viewValue) | filter: $viewValue"
|
||||
typeahead-template-url="partial/docs/directive.typeahead.acl.html"
|
||||
typeahead-wait-ms="200" />
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="btn btn-primary" ng-if="acl.target.type" ng-click="acl.target = null">
|
||||
<acl data="acl.target"></acl>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@ -43,7 +49,7 @@
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-primary" ng-disabled="!aclForm.$valid" ng-click="addAcl()">
|
||||
<button type="submit" class="btn btn-primary" ng-disabled="!acl.target.type" ng-click="addAcl()">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
Add
|
||||
</button>
|
||||
|
@ -109,6 +109,16 @@ public class TestAclResource extends BaseJerseyTest {
|
||||
.param("target", "aclGroup2")
|
||||
.param("type", "GROUP")), JsonObject.class);
|
||||
|
||||
// List all documents with acl2
|
||||
json = target().path("/document/list")
|
||||
.queryParam("sort_column", 3)
|
||||
.queryParam("asc", true)
|
||||
.request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, acl2Token)
|
||||
.get(JsonObject.class);
|
||||
JsonArray documents = json.getJsonArray("documents");
|
||||
Assert.assertEquals(1, documents.size());
|
||||
|
||||
// Get the document as acl1
|
||||
json = target().path("/document/" + document1Id).request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, acl1Token)
|
||||
|
Loading…
Reference in New Issue
Block a user