mirror of
https://github.com/nextcloud/passman.git
synced 2024-09-20 23:06:24 +08:00
Add hasPermission
This commit is contained in:
parent
23daf3a3ae
commit
0a9c097910
|
@ -89,7 +89,7 @@ angular.module('passmanApp')
|
|||
];
|
||||
console.log(SharingACL);
|
||||
var acl = new SharingACL(0);
|
||||
acl.addPermission(acl.permissions.HISTORY)
|
||||
|
||||
console.log(acl);
|
||||
$scope.inputSharedWith = [];
|
||||
$scope.selectedAccessLevel = '1';
|
||||
|
@ -98,17 +98,22 @@ angular.module('passmanApp')
|
|||
return ShareService.search($query)
|
||||
};
|
||||
|
||||
$scope.hasPermission = function(acl, permission){
|
||||
console.log(acl, permission)
|
||||
};
|
||||
|
||||
$scope.shareWith = function (shareWith, selectedAccessLevel) {
|
||||
//@TODO Improve this so we can add, edit and remove users and permissions.
|
||||
$scope.inputSharedWith = [];
|
||||
if (shareWith.length > 0) {
|
||||
for (var i = 0; i < shareWith.length; i++) {
|
||||
|
||||
var acl = new SharingACL(0);
|
||||
acl.addPermission(acl.permissions.READ | acl.permissions.WRITE | acl.permissions.FILES);
|
||||
var obj = {
|
||||
userId: shareWith[i].uid,
|
||||
displayName: shareWith[i].text,
|
||||
type: shareWith[i].type,
|
||||
accessLevel: selectedAccessLevel
|
||||
accessLevel: acl
|
||||
};
|
||||
if ($scope.share_settings.credentialSharedWithUserAndGroup.indexOf(obj) === -1) {
|
||||
$scope.share_settings.credentialSharedWithUserAndGroup.push(obj)
|
||||
|
|
|
@ -81,7 +81,7 @@ angular.module('views/partials/forms/settings/tool.html', []).run(['$templateCac
|
|||
angular.module('views/partials/forms/share_credential/basics.html', []).run(['$templateCache', function($templateCache) {
|
||||
'use strict';
|
||||
$templateCache.put('views/partials/forms/share_credential/basics.html',
|
||||
'<div class="row"><div class="col-xs-12 col-md-6"><div><table class="table sharing_table"><thead><tr><td><tags-input ng-model="inputSharedWith" replace-spaces-with-dashes="false" add-from-autocomplete-only="true" placeholder="Search users or groups..."><auto-complete source="searchUsers($query)" min-length="0" template="autocomplete-template"></auto-complete></tags-input></td><td><select ng-model="selectedAccessLevel"><option ng-repeat="lvl in accessLevels" value="{{lvl.value}}">{{lvl.label}}</option></select><button class="button" ng-click="shareWith(inputSharedWith, selectedAccessLevel)">+</button></td></tr></thead></table><div ng-if="share_settings.cypher_progress.done > 0">Cyphering...<div progress-bar="share_settings.cypher_progress.percent" index="share_settings.cypher_progress.done" total="share_settings.cypher_progress.total"></div></div></div></div><div class="col-xs-12 col-md-6"><table class="table"><thead><tr><td>User</td><td>Crypto time</td></tr></thead><tr ng-repeat="user in share_settings.cypher_progress.times"><td><i class="fa fa-user"></i> {{user.user}}</td><td>{{user.time}} s</td></tr></table>Total time spent cyphering: {{ calculate_total_time() }}</div></div><div class="row"><div class="col-xs-12 col-md-6"><table class="table shared_table" ng-show="share_settings.credentialSharedWithUserAndGroup.length > 0"><thead><tr><td>User / group</td><td>Access</td></tr></thead><tr ng-repeat="user in share_settings.credentialSharedWithUserAndGroup"><td><i class="fa fa-user" ng-if="user.type === \'user\'"></i> <i class="fa fa-group" ng-if="user.type === \'group\'"></i> {{user.userId}}</td><td>{{user.accessLevel}}</td></tr></table></div></div><script type="text/ng-template" id="autocomplete-template"><i class="fa fa-user" ng-if="data.type === \'user\'"></i>\n' +
|
||||
'<div class="row"><div class="col-xs-12 col-md-6"><div><table class="table sharing_table"><thead><tr><td><tags-input ng-model="inputSharedWith" replace-spaces-with-dashes="false" add-from-autocomplete-only="true" placeholder="Search users or groups..."><auto-complete source="searchUsers($query)" min-length="0" template="autocomplete-template"></auto-complete></tags-input></td><td><button class="button" ng-click="shareWith(inputSharedWith, selectedAccessLevel)">+</button></td></tr></thead></table><div ng-if="share_settings.cypher_progress.done > 0">Cyphering...<div progress-bar="share_settings.cypher_progress.percent" index="share_settings.cypher_progress.done" total="share_settings.cypher_progress.total"></div></div></div></div><div class="col-xs-12 col-md-6"><table class="table"><thead><tr><td>User</td><td>Crypto time</td></tr></thead><tr ng-repeat="user in share_settings.cypher_progress.times"><td><i class="fa fa-user"></i> {{user.user}}</td><td>{{user.time}} s</td></tr></table>Total time spent cyphering: {{ calculate_total_time() }}</div></div><div class="row"><div class="col-xs-12 col-md-6"><table class="table shared_table" ng-show="share_settings.credentialSharedWithUserAndGroup.length > 0"><thead><tr><td>User</td><td>Read</td><td>Write</td><td>Files</td><td>Revisions</td></tr></thead><tr ng-repeat="user in share_settings.credentialSharedWithUserAndGroup"><td><i class="fa fa-user" ng-if="user.type === \'user\'"></i> <i class="fa fa-group" ng-if="user.type === \'group\'"></i> {{user.userId}} {{user}}</td><td><input type="checkbox" ng-checked="hasPermission(user.acl, \'READ\')"></td><td><input type="checkbox"></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr></table></div></div><script type="text/ng-template" id="autocomplete-template"><i class="fa fa-user" ng-if="data.type === \'user\'"></i>\n' +
|
||||
' <i class="fa fa-group" ng-if="data.type === \'group\'"></i>\n' +
|
||||
' {{data.text}}</script>');
|
||||
}]);
|
||||
|
|
|
@ -16,12 +16,6 @@
|
|||
</td>
|
||||
|
||||
<td>
|
||||
<select ng-model="selectedAccessLevel">
|
||||
<option ng-repeat="lvl in accessLevels"
|
||||
value="{{lvl.value}}">
|
||||
{{lvl.label}}
|
||||
</option>
|
||||
</select>
|
||||
<button class="button"
|
||||
ng-click="shareWith(inputSharedWith, selectedAccessLevel)">
|
||||
+
|
||||
|
@ -62,8 +56,11 @@
|
|||
ng-show="share_settings.credentialSharedWithUserAndGroup.length > 0">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>User / group</td>
|
||||
<td>Access</td>
|
||||
<td>User</td>
|
||||
<td>Read</td>
|
||||
<td>Write</td>
|
||||
<td>Files</td>
|
||||
<td>Revisions</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr ng-repeat="user in share_settings.credentialSharedWithUserAndGroup">
|
||||
|
@ -71,8 +68,12 @@
|
|||
<i class="fa fa-user" ng-if="user.type === 'user'"></i>
|
||||
<i class="fa fa-group" ng-if="user.type === 'group'"></i>
|
||||
{{user.userId}}
|
||||
{{user}}
|
||||
</td>
|
||||
<td>{{user.accessLevel}}</td>
|
||||
<td><input type="checkbox" ng-checked="hasPermission(user.acl, 'READ')"> </td>
|
||||
<td><input type="checkbox"></td>
|
||||
<td><input type="checkbox"></td>
|
||||
<td><input type="checkbox"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue