shared vault listing conversion to ciphers
This commit is contained in:
parent
3b71760f9e
commit
7c93c82d24
|
@ -74,7 +74,7 @@ angular
|
|||
|
||||
var key = null;
|
||||
if (encryptedCipher.OrganizationId) {
|
||||
key = cryptoService.getOrgKey(encryptedLogin.OrganizationId);
|
||||
key = cryptoService.getOrgKey(encryptedCipher.OrganizationId);
|
||||
}
|
||||
|
||||
var cipher = {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
.controller('vaultSharedController', function ($scope, apiService, cipherService, $analytics, $q, $localStorage,
|
||||
$uibModal, $filter, $rootScope, authService, cryptoService) {
|
||||
$scope.logins = [];
|
||||
$scope.ciphers = [];
|
||||
$scope.collections = [];
|
||||
$scope.loading = true;
|
||||
|
||||
|
@ -22,16 +22,16 @@
|
|||
}).$promise;
|
||||
|
||||
var cipherPromise = apiService.ciphers.listDetails({}, function (ciphers) {
|
||||
var decLogins = [];
|
||||
var decCiphers = [];
|
||||
|
||||
for (var i = 0; i < ciphers.Data.length; i++) {
|
||||
if (ciphers.Data[i].Type === 1) {
|
||||
var decLogin = cipherService.decryptLoginPreview(ciphers.Data[i]);
|
||||
decLogins.push(decLogin);
|
||||
var decCipher = cipherService.decryptCipherPreview(ciphers.Data[i]);
|
||||
decCiphers.push(decCipher);
|
||||
}
|
||||
}
|
||||
|
||||
if (decLogins.length) {
|
||||
if (decCiphers.length) {
|
||||
$scope.collections.push({
|
||||
id: null,
|
||||
name: 'Unassigned',
|
||||
|
@ -39,7 +39,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
$scope.logins = decLogins;
|
||||
$scope.ciphers = decCiphers;
|
||||
}).$promise;
|
||||
|
||||
$q.all([collectionPromise, cipherPromise]).then(function () {
|
||||
|
@ -49,29 +49,29 @@
|
|||
|
||||
$scope.clipboardError = function (e) {
|
||||
alert('Your web browser does not support easy clipboard copying. ' +
|
||||
'Edit the login and copy it manually instead.');
|
||||
'Edit the item and copy it manually instead.');
|
||||
};
|
||||
|
||||
$scope.attachments = function (login) {
|
||||
$scope.attachments = function (cipher) {
|
||||
authService.getUserProfile().then(function (profile) {
|
||||
return {
|
||||
isPremium: profile.premium,
|
||||
orgUseStorage: login.organizationId && !!profile.organizations[login.organizationId].maxStorageGb
|
||||
orgUseStorage: cipher.organizationId && !!profile.organizations[cipher.organizationId].maxStorageGb
|
||||
};
|
||||
}).then(function (perms) {
|
||||
if (login.organizationId && !perms.orgUseStorage) {
|
||||
if (cipher.organizationId && !perms.orgUseStorage) {
|
||||
$uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: 'app/views/paidOrgRequired.html',
|
||||
controller: 'paidOrgRequiredController',
|
||||
resolve: {
|
||||
orgId: function () { return login.organizationId; }
|
||||
orgId: function () { return cipher.organizationId; }
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!login.organizationId && !perms.isPremium) {
|
||||
if (!cipher.organizationId && !perms.isPremium) {
|
||||
$uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: 'app/views/premiumRequired.html',
|
||||
|
@ -80,7 +80,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (!login.organizationId && !cryptoService.getEncKey()) {
|
||||
if (!cipher.organizationId && !cryptoService.getEncKey()) {
|
||||
toastr.error('You cannot use this feature until you update your encryption key.', 'Feature Unavailable');
|
||||
return;
|
||||
}
|
||||
|
@ -90,12 +90,12 @@
|
|||
templateUrl: 'app/vault/views/vaultAttachments.html',
|
||||
controller: 'vaultAttachmentsController',
|
||||
resolve: {
|
||||
loginId: function () { return login.id; }
|
||||
loginId: function () { return cipher.id; }
|
||||
}
|
||||
});
|
||||
|
||||
attachmentModel.result.then(function (hasAttachments) {
|
||||
login.hasAttachments = hasAttachments;
|
||||
cipher.hasAttachments = hasAttachments;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -133,62 +133,62 @@
|
|||
}
|
||||
};
|
||||
|
||||
$scope.editLogin = function (login) {
|
||||
$scope.editCipher = function (cipher) {
|
||||
var editModel = $uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: 'app/vault/views/vaultEditLogin.html',
|
||||
controller: 'vaultEditLoginController',
|
||||
templateUrl: 'app/vault/views/vaultEditCipher.html',
|
||||
controller: 'vaultEditCipherController',
|
||||
resolve: {
|
||||
loginId: function () { return login.id; }
|
||||
cipherId: function () { return cipher.id; }
|
||||
}
|
||||
});
|
||||
|
||||
editModel.result.then(function (returnVal) {
|
||||
var rootLogin = findRootLogin(login) || {};
|
||||
var rootCipher = findRootCipher(cipher) || { meta: {} };
|
||||
|
||||
if (returnVal.action === 'edit') {
|
||||
login.folderId = rootLogin.folderId = returnVal.data.folderId;
|
||||
login.name = rootLogin.name = returnVal.data.name;
|
||||
login.username = rootLogin.username = returnVal.data.username;
|
||||
login.password = rootLogin.password = returnVal.data.password;
|
||||
login.favorite = rootLogin.favorite = returnVal.data.favorite;
|
||||
cipher.folderId = rootCipher.folderId = returnVal.data.folderId;
|
||||
cipher.name = rootCipher.name = returnVal.data.name;
|
||||
cipher.subTitle = rootCipher.subTitle = returnVal.data.login.username;
|
||||
cipher.meta.password = rootCipher.meta.password = returnVal.data.login.password;
|
||||
cipher.favorite = rootCipher.favorite = returnVal.data.favorite;
|
||||
}
|
||||
else if (returnVal.action === 'partialEdit') {
|
||||
login.folderId = rootLogin.folderId = returnVal.data.folderId;
|
||||
login.favorite = rootLogin.favorite = returnVal.data.favorite;
|
||||
cipher.folderId = rootCipher.folderId = returnVal.data.folderId;
|
||||
cipher.favorite = rootCipher.favorite = returnVal.data.favorite;
|
||||
}
|
||||
else if (returnVal.action === 'delete') {
|
||||
var index = $scope.logins.indexOf(login);
|
||||
var index = $scope.ciphers.indexOf(cipher);
|
||||
if (index > -1) {
|
||||
$scope.logins.splice(index, 1);
|
||||
$scope.ciphers.splice(index, 1);
|
||||
}
|
||||
|
||||
removeRootLogin(rootLogin);
|
||||
removeRootCipher(rootCipher);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.editCollections = function (login) {
|
||||
$scope.editCollections = function (cipher) {
|
||||
var modal = $uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: 'app/vault/views/vaultLoginCollections.html',
|
||||
controller: 'vaultLoginCollectionsController',
|
||||
resolve: {
|
||||
loginId: function () { return login.id; }
|
||||
loginId: function () { return cipher.id; }
|
||||
}
|
||||
});
|
||||
|
||||
modal.result.then(function (response) {
|
||||
if (response.collectionIds) {
|
||||
login.collectionIds = response.collectionIds;
|
||||
// TODO: if there are no collectionIds now, it is possible that the user no longer has access to this login
|
||||
// which means it should be removed by calling removeRootLogin(findRootLogin(login))
|
||||
cipher.collectionIds = response.collectionIds;
|
||||
// TODO: if there are no collectionIds now, it is possible that the user no longer has access to this cipher
|
||||
// which means it should be removed by calling removeRootCipher(findRootCipher(cipher))
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.removeLogin = function (login, collection) {
|
||||
if (!confirm('Are you sure you want to remove this login (' + login.name + ') from the ' +
|
||||
$scope.removeCipher = function (cipher, collection) {
|
||||
if (!confirm('Are you sure you want to remove this item (' + cipher.name + ') from the ' +
|
||||
'collection (' + collection.name + ') ?')) {
|
||||
return;
|
||||
}
|
||||
|
@ -197,34 +197,34 @@
|
|||
collectionIds: []
|
||||
};
|
||||
|
||||
for (var i = 0; i < login.collectionIds.length; i++) {
|
||||
if (login.collectionIds[i] !== collection.id) {
|
||||
request.collectionIds.push(login.collectionIds[i]);
|
||||
for (var i = 0; i < cipher.collectionIds.length; i++) {
|
||||
if (cipher.collectionIds[i] !== collection.id) {
|
||||
request.collectionIds.push(cipher.collectionIds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
apiService.ciphers.putCollections({ id: login.id }, request).$promise.then(function (response) {
|
||||
apiService.ciphers.putCollections({ id: cipher.id }, request).$promise.then(function (response) {
|
||||
$analytics.eventTrack('Removed From Collection');
|
||||
login.collectionIds = request.collectionIds;
|
||||
// TODO: if there are no collectionIds now, it is possible that the user no longer has access to this login
|
||||
// which means it should be removed by calling removeRootLogin(findRootLogin(login))
|
||||
cipher.collectionIds = request.collectionIds;
|
||||
// TODO: if there are no collectionIds now, it is possible that the user no longer has access to this cipher
|
||||
// which means it should be removed by calling removeRootCipher(findRootCipher(cipher))
|
||||
});
|
||||
};
|
||||
|
||||
function findRootLogin(login) {
|
||||
function findRootCipher(cipher) {
|
||||
if ($rootScope.vaultCiphers) {
|
||||
var rootLogins = $filter('filter')($rootScope.vaultCiphers, { id: login.id });
|
||||
if (rootLogins && rootLogins.length) {
|
||||
return rootLogins[0];
|
||||
var rootCiphers = $filter('filter')($rootScope.vaultCiphers, { id: cipher.id });
|
||||
if (rootCiphers && rootCiphers.length) {
|
||||
return rootCiphers[0];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function removeRootLogin(rootLogin) {
|
||||
if (rootLogin && rootLogin.id) {
|
||||
var index = $rootScope.vaultCiphers.indexOf(rootLogin);
|
||||
function removeRootCipher(rootCipher) {
|
||||
if (rootCipher && rootCipher.id) {
|
||||
var index = $rootScope.vaultCiphers.indexOf(rootCipher);
|
||||
if (index > -1) {
|
||||
$rootScope.vaultCiphers.splice(index, 1);
|
||||
}
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
Shared
|
||||
<small>
|
||||
<span ng-pluralize
|
||||
count="collections.length > 0 && logins.length ? collections.length - 1 : collections.length"
|
||||
count="collections.length > 0 && ciphers.length ? collections.length - 1 : collections.length"
|
||||
when="{'1': '{} collection', 'other': '{} collections'}"></span>,
|
||||
<span ng-pluralize count="logins.length" when="{'1': '{} login', 'other': '{} logins'}"></span>
|
||||
<span ng-pluralize count="ciphers.length" when="{'1': '{} item', 'other': '{} items'}"></span>
|
||||
</small>
|
||||
</h1>
|
||||
</section>
|
||||
<section class="content">
|
||||
<p ng-show="loading && !collections.length">Loading...</p>
|
||||
<div class="callout callout-default" style="background: #fff;" ng-show="!loading && !collections.length && !logins.length">
|
||||
<div class="callout callout-default" style="background: #fff;" ng-show="!loading && !collections.length && !ciphers.length">
|
||||
<h4>Nothing shared <i class="fa fa-frown-o"></i></h4>
|
||||
<p>
|
||||
You do not have any logins or collections being shared with you.
|
||||
You do not have any items or collections being shared with you.
|
||||
To start sharing, create an organization or ask an existing organization to invite you.
|
||||
</p>
|
||||
<a ui-sref="backend.user.settingsCreateOrg" class="btn btn-default btn-flat">
|
||||
|
@ -28,7 +28,7 @@
|
|||
<h3 class="box-title">
|
||||
<i class="fa" ng-class="{'fa-cubes': collection.id, 'fa-sitemap': !collection.id}"></i>
|
||||
{{collection.name}}
|
||||
<small ng-pluralize count="collectionLogins.length" when="{'1': '{} login', 'other': '{} logins'}"></small>
|
||||
<small ng-pluralize count="collectionCiphers.length" when="{'1': '{} item', 'other': '{} items'}"></small>
|
||||
</h3>
|
||||
<div class="box-tools">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse" title="Collapse/Expand"
|
||||
|
@ -37,20 +37,20 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body" ng-class="{'no-padding': collectionLogins.length}">
|
||||
<div ng-show="!collectionLogins.length && collection.id">
|
||||
<p>No logins in this collection.</p>
|
||||
<div class="box-body" ng-class="{'no-padding': collectionCiphers.length}">
|
||||
<div ng-show="!collectionCiphers.length && collection.id">
|
||||
<p>No items in this collection.</p>
|
||||
<p>
|
||||
Share a login to this collection by selecting <i class="fa fa-share-alt"></i> <b>Share</b> or
|
||||
<i class="fa fa-cubes"></i> <b>Collections</b> from the login's options (<i class="fa fa-cog"></i>) menu.
|
||||
Share an item to this collection by selecting <i class="fa fa-share-alt"></i> <b>Share</b> or
|
||||
<i class="fa fa-cubes"></i> <b>Collections</b> from the item's options (<i class="fa fa-cog"></i>) menu.
|
||||
</p>
|
||||
</div>
|
||||
<div ng-show="!collectionLogins.length && !collection.id">No unassigned logins.</div>
|
||||
<div class="table-responsive" ng-show="collectionLogins.length">
|
||||
<div ng-show="!collectionCiphers.length && !collection.id">No unassigned items.</div>
|
||||
<div class="table-responsive" ng-show="collectionCiphers.length">
|
||||
<table class="table table-striped table-hover table-vmiddle">
|
||||
<tbody>
|
||||
<tr ng-repeat="login in collectionLogins = (logins | filter: filterByCollection(collection) |
|
||||
orderBy: ['name', 'username']) track by login.id">
|
||||
<tr ng-repeat="cipher in collectionCiphers = (ciphers | filter: filterByCollection(collection) |
|
||||
orderBy: ['name', 'subTitle']) track by cipher.id">
|
||||
<td style="width: 70px;">
|
||||
<div class="btn-group" data-append-to="body">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
|
@ -58,28 +58,28 @@
|
|||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="#" stop-click ng-click="editLogin(login)">
|
||||
<a href="#" stop-click ng-click="editCipher(cipher)">
|
||||
<i class="fa fa-fw fa-pencil"></i> Edit
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" stop-click ng-click="attachments(login)">
|
||||
<a href="#" stop-click ng-click="attachments(cipher)">
|
||||
<i class="fa fa-fw fa-paperclip"></i> Attachments
|
||||
</a>
|
||||
</li>
|
||||
<li ng-show="login.edit">
|
||||
<a href="#" stop-click ng-click="editCollections(login)">
|
||||
<li ng-show="cipher.edit">
|
||||
<a href="#" stop-click ng-click="editCollections(cipher)">
|
||||
<i class="fa fa-fw fa-cubes"></i> Collections
|
||||
</a>
|
||||
</li>
|
||||
<li ng-show="login.password">
|
||||
<li ng-show="cipher.meta.password">
|
||||
<a href="#" stop-click ngclipboard ngclipboard-error="clipboardError(e)"
|
||||
data-clipboard-text="{{login.password}}">
|
||||
data-clipboard-text="{{cipher.meta.password}}">
|
||||
<i class="fa fa-fw fa-clipboard"></i> Copy Password
|
||||
</a>
|
||||
</li>
|
||||
<li ng-show="login.edit">
|
||||
<a href="#" stop-click ng-click="removeLogin(login, collection)"
|
||||
<li ng-show="cipher.edit">
|
||||
<a href="#" stop-click ng-click="removeCipher(cipher, collection)"
|
||||
ng-if="collection.id" class="text-red">
|
||||
<i class="fa fa-fw fa-remove"></i> Remove
|
||||
</a>
|
||||
|
@ -88,11 +88,11 @@
|
|||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" stop-click ng-click="editLogin(login)">{{login.name}}</a>
|
||||
<i class="fa fa-star text-muted" title="Favorite" ng-show="login.favorite"></i>
|
||||
<i class="fa fa-paperclip text-muted" title="Attachments" ng-if="login.hasAttachments"
|
||||
<a href="#" stop-click ng-click="editCipher(cipher)">{{cipher.name}}</a>
|
||||
<i class="fa fa-star text-muted" title="Favorite" ng-show="cipher.favorite"></i>
|
||||
<i class="fa fa-paperclip text-muted" title="Attachments" ng-if="cipher.hasAttachments"
|
||||
stop-prop></i><br />
|
||||
<div class="text-sm text-muted">{{login.username}}</div>
|
||||
<div class="text-sm text-muted">{{cipher.subTitle}}</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in New Issue