Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/passman.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrantje <brantje@gmail.com>2017-02-21 22:52:48 +0300
committerbrantje <brantje@gmail.com>2017-02-22 20:02:55 +0300
commitce3528666436c6e9c54920c5c7855552b86eda8c (patch)
tree9b8f170981dd51b2daef1cc86ba17e19f5ca0bfa /js/app/directives
parent33d1a5db0144e95a79b81e502efeea06e05b6df9 (diff)
Fix for downloading files (Firefox and chrome). Fixes #259
Diffstat (limited to 'js/app/directives')
-rw-r--r--js/app/directives/credentialcounter.js2
-rw-r--r--js/app/directives/credentialtemplate.js26
2 files changed, 26 insertions, 2 deletions
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'));
}
};