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

collection user refactor

This commit is contained in:
Kyle Spearrin 2017-05-11 14:52:51 -04:00
parent bfae8e7def
commit 6bda5d5983
3 changed files with 23 additions and 22 deletions

View File

@ -10,18 +10,17 @@
$uibModalInstance.opened.then(function () { $uibModalInstance.opened.then(function () {
$scope.loading = false; $scope.loading = false;
apiService.collectionUsers.listCollection( apiService.collections.listUsers(
{ {
orgId: $state.params.orgId, orgId: $state.params.orgId,
collectionId: collection.id id: collection.id
}, },
function (userList) { function (userList) {
if (userList && userList.Data.length) { if (userList && userList.Data.length) {
var users = []; var users = [];
for (var i = 0; i < userList.Data.length; i++) { for (var i = 0; i < userList.Data.length; i++) {
users.push({ users.push({
id: userList.Data[i].Id, organizationUserId: userList.Data[i].OrganizationUserId,
userId: userList.Data[i].UserId,
name: userList.Data[i].Name, name: userList.Data[i].Name,
email: userList.Data[i].Email, email: userList.Data[i].Email,
type: userList.Data[i].Type, type: userList.Data[i].Type,
@ -41,16 +40,21 @@
return; return;
} }
apiService.collectionUsers.del({ orgId: $state.params.orgId, id: user.id }, null, function () { apiService.collections.delUser(
toastr.success(user.email + ' has been removed.', 'User Removed'); {
$analytics.eventTrack('Removed User From Collection'); orgId: $state.params.orgId,
var index = $scope.users.indexOf(user); id: collection.id,
if (index > -1) { orgUserId: user.organizationUserId
$scope.users.splice(index, 1); }, null, function () {
} toastr.success(user.email + ' has been removed.', 'User Removed');
}, function () { $analytics.eventTrack('Removed User From Collection');
toastr.error('Unable to remove user.', 'Error'); 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 () { $scope.close = function () {

View File

@ -22,12 +22,12 @@
<i class="fa fa-cog"></i> <span class="caret"></span> <i class="fa fa-cog"></i> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li ng-show="user.id"> <li ng-show="!user.accessAll">
<a href="javascript:void(0)" ng-click="remove(user)" class="text-red"> <a href="javascript:void(0)" ng-click="remove(user)" class="text-red">
<i class="fa fa-fw fa-remove"></i> Remove <i class="fa fa-fw fa-remove"></i> Remove
</a> </a>
</li> </li>
<li ng-show="!user.id"> <li ng-show="user.accessAll">
<a href="javascript:void(0)"> <a href="javascript:void(0)">
No options... No options...
</a> </a>

View File

@ -74,14 +74,11 @@
getDetails: { url: _apiUri + '/organizations/:orgId/collections/:id/details', method: 'GET', params: { id: '@id', orgId: '@orgId' } }, getDetails: { url: _apiUri + '/organizations/:orgId/collections/:id/details', method: 'GET', params: { id: '@id', orgId: '@orgId' } },
listMe: { url: _apiUri + '/collections', method: 'GET', params: {} }, listMe: { url: _apiUri + '/collections', method: 'GET', params: {} },
listOrganization: { method: 'GET', params: { orgId: '@orgId' } }, listOrganization: { method: 'GET', params: { orgId: '@orgId' } },
listUsers: { url: _apiUri + '/organizations/:orgId/collections/:id/users', method: 'GET', params: { id: '@id', orgId: '@orgId' } },
post: { method: 'POST', params: { orgId: '@orgId' } }, post: { method: 'POST', params: { orgId: '@orgId' } },
put: { method: 'POST', params: { id: '@id', orgId: '@orgId' } }, put: { method: 'POST', params: { id: '@id', orgId: '@orgId' } },
del: { url: _apiUri + '/organizations/:orgId/collections/:id/delete', method: 'POST', params: { id: '@id', orgId: '@orgId' } } del: { url: _apiUri + '/organizations/:orgId/collections/:id/delete', method: 'POST', params: { id: '@id', orgId: '@orgId' } },
}); delUser: { url: _apiUri + '/organizations/:orgId/collections/:id/delete-user/:orgUserId', method: 'POST', params: { id: '@id', orgId: '@orgId', orgUserId: '@orgUserId' } }
_service.collectionUsers = $resource(_apiUri + '/organizations/:orgId/collectionUsers/:id', {}, {
listCollection: { url: _apiUri + '/organizations/:orgId/collectionUsers/:collectionId', method: 'GET', params: { collectionId: '@collectionId', orgId: '@orgId' } },
del: { url: _apiUri + '/organizations/:orgId/collectionUsers/:id/delete', method: 'POST', params: { id: '@id', orgId: '@orgId' } }
}); });
_service.groups = $resource(_apiUri + '/organizations/:orgId/groups/:id', {}, { _service.groups = $resource(_apiUri + '/organizations/:orgId/groups/:id', {}, {