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

more logins to cipher renames

This commit is contained in:
Kyle Spearrin 2017-10-11 09:57:18 -04:00
parent 1f26ff5c80
commit 2963516d5c
7 changed files with 43 additions and 43 deletions

View File

@ -2,9 +2,9 @@
.module('bit.vault')
.controller('vaultAttachmentsController', function ($scope, apiService, $uibModalInstance, cryptoService, cipherService,
loginId, $analytics, validationService, toastr, $timeout, authService, $uibModal) {
cipherId, $analytics, validationService, toastr, $timeout, authService, $uibModal) {
$analytics.eventTrack('vaultAttachmentsController', { category: 'Modal' });
$scope.login = {};
$scope.cipher = {};
$scope.readOnly = true;
$scope.loading = true;
$scope.isPremium = true;
@ -13,11 +13,11 @@
authService.getUserProfile().then(function (profile) {
$scope.isPremium = profile.premium;
return apiService.ciphers.get({ id: loginId }).$promise;
return apiService.ciphers.get({ id: cipherId }).$promise;
}).then(function (cipher) {
$scope.login = cipherService.decryptLogin(cipher);
$scope.readOnly = !$scope.login.edit;
$scope.canUseAttachments = $scope.isPremium || $scope.login.organizationId;
$scope.cipher = cipherService.decryptCipher(cipher);
$scope.readOnly = !$scope.cipher.edit;
$scope.canUseAttachments = $scope.isPremium || $scope.cipher.organizationId;
$scope.loading = false;
}, function () {
$scope.loading = false;
@ -31,14 +31,14 @@
return;
}
$scope.savePromise = cipherService.encryptAttachmentFile(getKeyForLogin(), files[0]).then(function (encValue) {
$scope.savePromise = cipherService.encryptAttachmentFile(getKeyForCipher(), files[0]).then(function (encValue) {
var fd = new FormData();
var blob = new Blob([encValue.data], { type: 'application/octet-stream' });
fd.append('data', blob, encValue.fileName);
return apiService.ciphers.postAttachment({ id: loginId }, fd).$promise;
return apiService.ciphers.postAttachment({ id: cipherId }, fd).$promise;
}).then(function (response) {
$analytics.eventTrack('Added Attachment');
$scope.login = cipherService.decryptLogin(response);
$scope.cipher = cipherService.decryptCipher(response);
// reset file input
// ref: https://stackoverflow.com/a/20552042
@ -64,7 +64,7 @@
return;
}
cipherService.downloadAndDecryptAttachment(getKeyForLogin(), attachment, true).then(function (res) {
cipherService.downloadAndDecryptAttachment(getKeyForCipher(), attachment, true).then(function (res) {
$timeout(function () {
attachment.loading = false;
});
@ -75,9 +75,9 @@
});
};
function getKeyForLogin() {
if ($scope.login.organizationId) {
return cryptoService.getOrgKey($scope.login.organizationId);
function getKeyForCipher() {
if ($scope.cipher.organizationId) {
return cryptoService.getOrgKey($scope.cipher.organizationId);
}
return null;
@ -89,12 +89,12 @@
}
attachment.loading = true;
apiService.ciphers.delAttachment({ id: loginId, attachmentId: attachment.id }).$promise.then(function () {
apiService.ciphers.delAttachment({ id: cipherId, attachmentId: attachment.id }).$promise.then(function () {
attachment.loading = false;
$analytics.eventTrack('Deleted Attachment');
var index = $scope.login.attachments.indexOf(attachment);
var index = $scope.cipher.attachments.indexOf(attachment);
if (index > -1) {
$scope.login.attachments.splice(index, 1);
$scope.cipher.attachments.splice(index, 1);
}
}, function () {
toastr.error('Cannot delete attachment.');
@ -113,7 +113,7 @@
e.preventDefault();
closing = true;
$uibModalInstance.close(!!$scope.login.attachments && $scope.login.attachments.length > 0);
$uibModalInstance.close(!!$scope.cipher.attachments && $scope.cipher.attachments.length > 0);
});
$scope.showUpgrade = function () {

View File

@ -1,24 +1,24 @@
angular
.module('bit.vault')
.controller('vaultLoginCollectionsController', function ($scope, apiService, $uibModalInstance, cipherService,
loginId, $analytics) {
$analytics.eventTrack('vaultLoginCollectionsController', { category: 'Modal' });
$scope.login = {};
.controller('vaultCipherCollectionsController', function ($scope, apiService, $uibModalInstance, cipherService,
cipherId, $analytics) {
$analytics.eventTrack('vaultCipherCollectionsController', { category: 'Modal' });
$scope.cipher = {};
$scope.readOnly = false;
$scope.loadingLogin = true;
$scope.loadingCipher = true;
$scope.loadingCollections = true;
$scope.selectedCollections = {};
$scope.collections = [];
$uibModalInstance.opened.then(function () {
apiService.ciphers.getDetails({ id: loginId }).$promise.then(function (cipher) {
$scope.loadingLogin = false;
apiService.ciphers.getDetails({ id: cipherId }).$promise.then(function (cipher) {
$scope.loadingCipher = false;
$scope.readOnly = !cipher.Edit;
if (cipher.Edit && cipher.OrganizationId) {
if (cipher.Type === 1) {
$scope.login = cipherService.decryptLoginPreview(cipher);
$scope.cipher = cipherService.decryptCipherPreview(cipher);
}
var collections = {};
@ -105,9 +105,9 @@
}
}
$scope.submitPromise = apiService.ciphers.putCollections({ id: loginId }, request)
$scope.submitPromise = apiService.ciphers.putCollections({ id: cipherId }, request)
.$promise.then(function (response) {
$analytics.eventTrack('Edited Login Collections');
$analytics.eventTrack('Edited Cipher Collections');
$uibModalInstance.close({
action: 'collectionsEdit',
collectionIds: request.collectionIds

View File

@ -240,7 +240,7 @@
templateUrl: 'app/vault/views/vaultAttachments.html',
controller: 'vaultAttachmentsController',
resolve: {
loginId: function () { return cipher.id; }
cipherId: function () { return cipher.id; }
}
});
@ -325,10 +325,10 @@
$scope.collections = function (cipher) {
var modal = $uibModal.open({
animation: true,
templateUrl: 'app/vault/views/vaultLoginCollections.html',
controller: 'vaultLoginCollectionsController',
templateUrl: 'app/vault/views/vaultCipherCollections.html',
controller: 'vaultCipherCollectionsController',
resolve: {
loginId: function () { return cipher.id; }
cipherId: function () { return cipher.id; }
}
});

View File

@ -88,7 +88,7 @@
templateUrl: 'app/vault/views/vaultAttachments.html',
controller: 'vaultAttachmentsController',
resolve: {
loginId: function () { return cipher.id; }
cipherId: function () { return cipher.id; }
}
});
@ -169,10 +169,10 @@
$scope.editCollections = function (cipher) {
var modal = $uibModal.open({
animation: true,
templateUrl: 'app/vault/views/vaultLoginCollections.html',
controller: 'vaultLoginCollectionsController',
templateUrl: 'app/vault/views/vaultCipherCollections.html',
controller: 'vaultCipherCollectionsController',
resolve: {
loginId: function () { return cipher.id; }
cipherId: function () { return cipher.id; }
}
});

View File

@ -1,7 +1,7 @@
<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-paperclip"></i> Secure Attachments <small>{{login.name}}</small>
<i class="fa fa-paperclip"></i> Secure Attachments <small>{{cipher.name}}</small>
</h4>
</div>
<form name="form" ng-submit="form.$valid && save(form)" api-form="savePromise" autocomplete="off">
@ -9,13 +9,13 @@
<div ng-if="loading">
Loading...
</div>
<div ng-if="!loading && !login.attachments.length">
There are no attachments for this login.
<div ng-if="!loading && !cipher.attachments.length">
There are no attachments for this item.
</div>
<div class="table-responsive" ng-if="login.attachments.length" style="margin: 0;">
<div class="table-responsive" ng-if="cipher.attachments.length" style="margin: 0;">
<table class="table table-striped table-hover table-vmiddle" style="margin: 0;">
<tbody>
<tr ng-repeat="attachment in login.attachments | orderBy: ['fileName']">
<tr ng-repeat="attachment in cipher.attachments | orderBy: ['fileName']">
<td style="width: 70px;">
<div class="btn-group" data-append-to=".modal">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">

View File

@ -1,10 +1,10 @@
<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-cubes"></i> Collections <small>{{login.name}}</small></h4>
<h4 class="modal-title"><i class="fa fa-cubes"></i> Collections <small>{{cipher.name}}</small></h4>
</div>
<form name="form" ng-submit="form.$valid && submit()" api-form="submitPromise" autocomplete="off">
<div class="modal-body">
<p>Edit the collections that this login is being shared with.</p>
<p>Edit the collections that this item is being shared with.</p>
<div class="callout callout-danger validation-errors" ng-show="form.$errors">
<h4>Errors have occurred</h4>
<ul>

View File

@ -224,7 +224,7 @@
<script src="app/vault/vaultAddFolderController.js"></script>
<script src="app/vault/vaultShareCipherController.js"></script>
<script src="app/vault/vaultSharedController.js"></script>
<script src="app/vault/vaultLoginCollectionsController.js"></script>
<script src="app/vault/vaultCipherCollectionsController.js"></script>
<script src="app/vault/vaultMoveCiphersController.js"></script>
<script src="app/vault/vaultAttachmentsController.js"></script>