diff options
author | brantje <brantje@gmail.com> | 2017-02-21 22:52:48 +0300 |
---|---|---|
committer | brantje <brantje@gmail.com> | 2017-02-22 20:02:55 +0300 |
commit | ce3528666436c6e9c54920c5c7855552b86eda8c (patch) | |
tree | 9b8f170981dd51b2daef1cc86ba17e19f5ca0bfa /js/app | |
parent | 33d1a5db0144e95a79b81e502efeea06e05b6df9 (diff) |
Fix for downloading files (Firefox and chrome). Fixes #259
Diffstat (limited to 'js/app')
-rw-r--r-- | js/app/controllers/credential.js | 22 | ||||
-rw-r--r-- | js/app/directives/credentialcounter.js | 2 | ||||
-rw-r--r-- | js/app/directives/credentialtemplate.js | 26 |
3 files changed, 26 insertions, 24 deletions
diff --git a/js/app/controllers/credential.js b/js/app/controllers/credential.js index 308afe31..6515f908 100644 --- a/js/app/controllers/credential.js +++ b/js/app/controllers/credential.js @@ -409,27 +409,5 @@ $scope.delete_time = 0; }; - $scope.downloadFile = function (credential, file) { - var callback = function (result) { - var key = EncryptService.getSharedKeyFromCredential(credential); - - if (!result.hasOwnProperty('file_data')) { - NotificationService.showNotification($translate.instant('error.loading.file.perm'), 5000); - return; - - } - var file_data = EncryptService.decryptString(result.file_data, key); - download(file_data, escapeHTML(file.filename), file.mimetype); - - }; - - if (!credential.hasOwnProperty('acl')) { - FileService.getFile(file).then(callback); - } else { - ShareService.downloadSharedFile(credential, file).then(callback); - } - - }; - }]); }());
\ No newline at end of file diff --git a/js/app/directives/credentialcounter.js b/js/app/directives/credentialcounter.js index c637e848..06288467 100644 --- a/js/app/directives/credentialcounter.js +++ b/js/app/directives/credentialcounter.js @@ -45,7 +45,7 @@ function countCredentials() { var countedCredentials = 0; var total = 0; - if(!scope.vault.hasOwnProperty('credentials')){ + if(!scope.vault || !scope.vault.hasOwnProperty('credentials')){ return; } diff --git a/js/app/directives/credentialtemplate.js b/js/app/directives/credentialtemplate.js index 9b03db90..1ab98875 100644 --- a/js/app/directives/credentialtemplate.js +++ b/js/app/directives/credentialtemplate.js @@ -29,7 +29,8 @@ * # passwordGen */ angular.module('passmanApp') - .directive('credentialTemplate', [function () { + .directive('credentialTemplate', ['EncryptService', '$translate', 'FileService', 'ShareService', 'NotificationService', 'CredentialService', + function (EncryptService, $translate, FileService, ShareService, NotificationService, CredentialService) { return { templateUrl: 'views/partials/credential_template.html', replace: true, @@ -39,6 +40,29 @@ }, link: function (scope, element, attrs) { + scope.downloadFile = function (credential, file) { + console.log('hi') + var callback = function (result) { + console.log(EncryptService); + var key = CredentialService.getSharedKeyFromCredential(credential); + if (!result.hasOwnProperty('file_data')) { + NotificationService.showNotification($translate.instant('error.loading.file.perm'), 5000); + return; + + } + var file_data = EncryptService.decryptString(result.file_data, key); + download(file_data, escapeHTML(file.filename), file.mimetype); + + }; + + if (!credential.hasOwnProperty('acl')) { + FileService.getFile(file).then(callback); + } else { + ShareService.downloadSharedFile(credential, file).then(callback); + } + + }; + scope.showLabel = (attrs.hasOwnProperty('showLabel')); } }; |