1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

Manage subvault users

This commit is contained in:
Kyle Spearrin 2017-04-03 12:26:43 -04:00
parent e00f033ffd
commit a81572914a
5 changed files with 129 additions and 4 deletions

View File

@ -39,6 +39,22 @@
});
};
$scope.users = function (subvault) {
var modal = $uibModal.open({
animation: true,
templateUrl: 'app/organization/views/organizationSubvaultsUsers.html',
controller: 'organizationSubvaultsUsersController',
size: 'lg',
resolve: {
subvault: function () { return subvault; }
}
});
modal.result.then(function () {
// nothing to do
});
};
$scope.delete = function (subvault) {
if (!confirm('Are you sure you want to delete this subvault (' + subvault.name + ')?')) {
return;
@ -56,10 +72,6 @@
});
};
$scope.users = function (subvault) {
};
function loadList() {
apiService.subvaults.listOrganization({ orgId: $state.params.orgId }, function (list) {
$scope.subvaults = cipherService.decryptSubvaults(list.Data, $state.params.orgId, true);

View File

@ -0,0 +1,56 @@
angular
.module('bit.organization')
.controller('organizationSubvaultsUsersController', function ($scope, $state, $uibModalInstance, apiService, cipherService,
$analytics, subvault, toastr) {
$scope.loading = true;
$scope.subvault = subvault;
$scope.users = [];
$uibModalInstance.opened.then(function () {
$scope.loading = false;
apiService.subvaultUsers.listSubvault(
{
orgId: $state.params.orgId,
subvaultId: subvault.id
},
function (userList) {
if (userList && userList.Data.length) {
var users = [];
for (var i = 0; i < userList.Data.length; i++) {
users.push({
id: userList.Data[i].Id,
userId: userList.Data[i].UserId,
name: userList.Data[i].Name,
email: userList.Data[i].Email,
type: userList.Data[i].Type,
status: userList.Data[i].Status,
readOnly: userList.Data[i].ReadOnly
});
}
$scope.users = users;
}
});
});
$scope.remove = function (user) {
if (!confirm('Are you sure you want to remove this user (' + user.email + ') from this ' +
'subvault (' + subvault.name + ')?')) {
return;
}
apiService.subvaultUsers.del({ orgId: $state.params.orgId, id: user.id }, null, function () {
toastr.success(user.email + ' has been removed.', 'User Removed');
var index = $scope.users.indexOf(user);
if (index > -1) {
$scope.users.splice(index, 1);
}
}, function () {
toastr.error('Unable to remove user.', 'Error');
});
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
});

View File

@ -0,0 +1,51 @@
<div class="modal-header">
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><i class="fa fa-users"></i> User Access <small>{{subvault.name}}</small></h4>
</div>
<div class="modal-body">
<div ng-show="loading && !users.length">
Loading...
</div>
<div ng-show="!loading && !users.length">
<p>No users.</p>
</div>
<div class="table-responsive" ng-show="users.length">
<table class="table table-striped table-hover table-vmiddle">
<tbody>
<tr ng-repeat="user in users | orderBy: ['email']">
<td style="width: 40px;">
<button type="button" class="btn btn-link btn-table" uib-tooltip="Remove User"
ng-click="remove(user)">
<i class="fa fa-lg fa-remove"></i>
</button>
</td>
<td style="width: 45px;">
<img src="//www.gravatar.com/avatar/{{user.email | gravatar}}.jpg?s=45&d=mm"
class="img-circle" alt="User Image">
</td>
<td>
<a href="javascript:void(0)" ng-click="edit(user.id)">{{user.email}}</a>
<div ng-if="user.name"><small class="text-muted">{{user.name}}</small></div>
</td>
<td style="width: 40px;" align="center">
<i class="fa fa-pencil-square-o" ng-show="!user.readOnly" uib-tooltip="Can Edit"></i>
</td>
<td style="width: 100px;">
{{user.type | enumName: 'OrgUserType'}}
</td>
<td style="width: 120px;">
<span class="label {{user.status | enumLabelClass: 'OrgUserStatus'}}">
{{user.status | enumName: 'OrgUserStatus'}}
</span>
</td>
</tr>
</tbody>
</table>
</div>
<h4>Add User</h4>
<p>Coming soon...</p>
<p>Navigate to a specific user from the "people" page to associate them to a subvault.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
</div>

View File

@ -61,6 +61,11 @@
del: { url: _apiUri + '/organizations/:orgId/subvaults/:id/delete', method: 'POST', params: { id: '@id', orgId: '@orgId' } }
});
_service.subvaultUsers = $resource(_apiUri + '/organizations/:orgId/subvaultUsers/:id', {}, {
listSubvault: { url: _apiUri + '/organizations/:orgId/subvaultUsers/:subvaultId', method: 'GET', params: { subvaultId: '@subvaultId', orgId: '@orgId' } },
del: { url: _apiUri + '/organizations/:orgId/subvaultUsers/:id/delete', method: 'POST', params: { id: '@id', orgId: '@orgId' } }
});
_service.accounts = $resource(_apiUri + '/accounts', {}, {
register: { url: _apiUri + '/accounts/register', method: 'POST', params: {} },
emailToken: { url: _apiUri + '/accounts/email-token', method: 'POST', params: {} },

View File

@ -131,6 +131,7 @@
<script src="app/organization/organizationSubvaultsController.js"></script>
<script src="app/organization/organizationSubvaultsAddController.js"></script>
<script src="app/organization/organizationSubvaultsEditController.js"></script>
<script src="app/organization/organizationSubvaultsUsersController.js"></script>
<script src="app/settings/settingsModule.js"></script>
<script src="app/settings/settingsController.js"></script>