mirror of
https://github.com/moparisthebest/mail
synced 2024-11-23 01:12:19 -05:00
download attachment ui implemented (work in progress)
This commit is contained in:
parent
04cf299e1e
commit
c40c6b8f50
@ -2,14 +2,17 @@ define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var appController = require('js/app-controller'),
|
||||
download = require('js/util/download'),
|
||||
angular = require('angular'),
|
||||
crypto, keychain;
|
||||
emailDao, crypto, keychain;
|
||||
|
||||
//
|
||||
// Controller
|
||||
//
|
||||
|
||||
var ReadCtrl = function($scope) {
|
||||
|
||||
emailDao = appController._emailDao;
|
||||
crypto = appController._crypto;
|
||||
keychain = appController._keychain;
|
||||
|
||||
@ -74,6 +77,38 @@ define(function(require) {
|
||||
$scope.$apply();
|
||||
});
|
||||
}
|
||||
|
||||
$scope.download = function(attachment) {
|
||||
// download file to disk if content is available
|
||||
if (attachment.content) {
|
||||
saveToDisk(attachment);
|
||||
return;
|
||||
}
|
||||
|
||||
var folder = $scope.state.nav.currentFolder;
|
||||
var email = $scope.state.mailList.selected;
|
||||
|
||||
emailDao.getAttachment({
|
||||
path: folder.path,
|
||||
uid: email.uid,
|
||||
attachment: attachment
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
$scope.onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
saveToDisk(attachment);
|
||||
});
|
||||
|
||||
function saveToDisk(attachment) {
|
||||
download.createDownload({
|
||||
content: attachment.content,
|
||||
filename: attachment.filename,
|
||||
contentType: attachment.mimeType
|
||||
}, $scope.onError);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -862,6 +862,18 @@ define(function(require) {
|
||||
}, callback);
|
||||
};
|
||||
|
||||
EmailDAO.prototype.getAttachment = function(options, callback) {
|
||||
if (!this._account.online) {
|
||||
callback({
|
||||
errMsg: 'Client is currently offline!',
|
||||
code: 42
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this._imapClient.getAttachment(options, callback);
|
||||
};
|
||||
|
||||
EmailDAO.prototype.sendEncrypted = function(options, callback) {
|
||||
var self = this,
|
||||
email = options.email;
|
||||
|
@ -21,7 +21,19 @@
|
||||
</div>
|
||||
</div><!--/.headers-->
|
||||
|
||||
<div class="seperator-line"></div>
|
||||
<div ng-switch="state.mailList.selected.attachments !== undefined && state.mailList.selected.attachments.length > 0">
|
||||
<div ng-switch-when="true">
|
||||
<div class="attachments">
|
||||
<span ng-repeat="attachment in state.mailList.selected.attachments">
|
||||
<button ng-click="download(attachment)">{{attachment.filename}}</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-switch-default>
|
||||
<div class="seperator-line"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="body">
|
||||
<!-- Render lines of a text-email in divs for easier styling -->
|
||||
|
Loading…
Reference in New Issue
Block a user