mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 03:59:21 +03:00
Save attachments as ...
This commit is contained in:
parent
f5f067f1f3
commit
48b91fb957
20 changed files with 687 additions and 76 deletions
|
|
@ -59,47 +59,62 @@
|
|||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @param {string=} sCustomSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.attachmentDownload = function (sDownload)
|
||||
Links.prototype.attachmentDownload = function (sDownload, sCustomSpecSuffix)
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sSpecSuffix + '/Download/' + this.subQueryPrefix() + '/' + sDownload;
|
||||
sCustomSpecSuffix = Utils.isUnd(sCustomSpecSuffix) ? this.sSpecSuffix : sCustomSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + sCustomSpecSuffix + '/Download/' +
|
||||
this.subQueryPrefix() + '/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @param {string=} sCustomSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.attachmentPreview = function (sDownload)
|
||||
Links.prototype.attachmentPreview = function (sDownload, sCustomSpecSuffix)
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sSpecSuffix + '/View/' + this.subQueryPrefix() + '/' + sDownload;
|
||||
sCustomSpecSuffix = Utils.isUnd(sCustomSpecSuffix) ? this.sSpecSuffix : sCustomSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + sCustomSpecSuffix + '/View/' +
|
||||
this.subQueryPrefix() + '/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @param {string=} sCustomSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.attachmentThumbnailPreview = function (sDownload)
|
||||
Links.prototype.attachmentThumbnailPreview = function (sDownload, sCustomSpecSuffix)
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sSpecSuffix + '/ViewThumbnail/' + this.subQueryPrefix() + '/' + sDownload;
|
||||
sCustomSpecSuffix = Utils.isUnd(sCustomSpecSuffix) ? this.sSpecSuffix : sCustomSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + sCustomSpecSuffix + '/ViewThumbnail/' +
|
||||
this.subQueryPrefix() + '/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @param {string=} sCustomSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.attachmentPreviewAsPlain = function (sDownload)
|
||||
Links.prototype.attachmentPreviewAsPlain = function (sDownload, sCustomSpecSuffix)
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sSpecSuffix + '/ViewAsPlain/' + this.subQueryPrefix() + '/' + sDownload;
|
||||
sCustomSpecSuffix = Utils.isUnd(sCustomSpecSuffix) ? this.sSpecSuffix : sCustomSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + sCustomSpecSuffix + '/ViewAsPlain/' +
|
||||
this.subQueryPrefix() + '/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sDownload
|
||||
* @param {string=} sCustomSpecSuffix
|
||||
* @return {string}
|
||||
*/
|
||||
Links.prototype.attachmentFramed = function (sDownload)
|
||||
Links.prototype.attachmentFramed = function (sDownload, sCustomSpecSuffix)
|
||||
{
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + this.sSpecSuffix + '/FramedView/' + this.subQueryPrefix() + '/' + sDownload;
|
||||
sCustomSpecSuffix = Utils.isUnd(sCustomSpecSuffix) ? this.sSpecSuffix : sCustomSpecSuffix;
|
||||
return this.sServer + '/Raw/' + this.subQueryPrefix() + '/' + sCustomSpecSuffix + '/FramedView/' +
|
||||
this.subQueryPrefix() + '/' + sDownload;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@
|
|||
UserAjaxUserPromises.prototype.attachmentsActions = function (sAction, aHashes, fTrigger)
|
||||
{
|
||||
return this.postRequest('AttachmentsActions', fTrigger, {
|
||||
'Action': sAction,
|
||||
'Do': sAction,
|
||||
'Hashes': aHashes
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
|
|
@ -52,6 +53,8 @@
|
|||
|
||||
this.contactsIsAllowed = ko.observable(false);
|
||||
|
||||
this.attahcmentsActions = ko.observableArray([]);
|
||||
|
||||
this.devEmail = '';
|
||||
this.devPassword = '';
|
||||
}
|
||||
|
|
@ -67,6 +70,9 @@
|
|||
|
||||
this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed'));
|
||||
|
||||
var mAttahcmentsActions = Settings.settingsGet('AttahcmentsActions');
|
||||
this.attahcmentsActions(Utils.isNonEmptyArray(mAttahcmentsActions) ? mAttahcmentsActions : []);
|
||||
|
||||
this.devEmail = Settings.settingsGet('DevEmail');
|
||||
this.devPassword = Settings.settingsGet('DevPassword');
|
||||
};
|
||||
|
|
|
|||
|
|
@ -263,6 +263,14 @@ html.rl-no-preview-pane {
|
|||
}
|
||||
}
|
||||
|
||||
&.unselectedAttachmentsError {
|
||||
.attachmentItem {
|
||||
box-shadow: 0 1px 4px red;
|
||||
box-shadow: 0 1px 5px rgba(255, 0, 0, 0.4);
|
||||
box-shadow: 0 0 0 1px rgba(255, 0, 0, 0.2), 0 1px 5px rgba(255, 0, 0, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
.controls-handle {
|
||||
position: absolute;
|
||||
bottom: 5px;
|
||||
|
|
|
|||
|
|
@ -1440,7 +1440,7 @@
|
|||
{
|
||||
oScript = window.document.createElement('script');
|
||||
oScript.type = 'text/javascript';
|
||||
oScript.src = 'https://www.dropbox.com/static/api/1/dropins.js';
|
||||
oScript.src = 'https://www.dropbox.com/static/api/2/dropins.js';
|
||||
$(oScript).attr('id', 'dropboxjs').attr('data-app-key', self.dropboxApiKey());
|
||||
|
||||
window.document.body.appendChild(oScript);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
|
|
@ -19,9 +20,11 @@
|
|||
Events = require('Common/Events'),
|
||||
Translator = require('Common/Translator'),
|
||||
Audio = require('Common/Audio'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
Cache = require('Common/Cache'),
|
||||
|
||||
SocialStore = require('Stores/Social'),
|
||||
AppStore = require('Stores/User/App'),
|
||||
SettingsStore = require('Stores/User/Settings'),
|
||||
AccountStore = require('Stores/User/Account'),
|
||||
|
|
@ -62,6 +65,8 @@
|
|||
|
||||
this.pswp = null;
|
||||
|
||||
this.attahcmentsActions = AppStore.attahcmentsActions;
|
||||
|
||||
this.message = MessageStore.message;
|
||||
this.messageListChecked = MessageStore.messageListChecked;
|
||||
this.hasCheckedMessages = MessageStore.hasCheckedMessages;
|
||||
|
|
@ -80,12 +85,64 @@
|
|||
|
||||
this.messageListOfThreadsLoading = ko.observable(false).extend({'rateLimit': 1});
|
||||
|
||||
this.allowAttachmnetControls = ko.observable(false);
|
||||
this.highlightUnselectedAttachments = ko.observable(false).extend({'falseTimeout': 2000});
|
||||
|
||||
this.showAttachmnetControls = ko.observable(false);
|
||||
|
||||
this.allowAttachmnetControls = ko.computed(function () {
|
||||
return 0 < this.attahcmentsActions().length;
|
||||
}, this);
|
||||
|
||||
this.downloadAsZipAllowed = ko.computed(function () {
|
||||
return -1 < Utils.inArray('zip', this.attahcmentsActions());
|
||||
}, this);
|
||||
|
||||
this.downloadAsZipLoading = ko.observable(false);
|
||||
this.downloadAsZipError = ko.observable(false).extend({'falseTimeout': 7000});
|
||||
|
||||
this.saveToOwnCloudAllowed = ko.computed(function () {
|
||||
return -1 < Utils.inArray('owncloud', this.attahcmentsActions());
|
||||
}, this);
|
||||
|
||||
this.saveToOwnCloudLoading = ko.observable(false);
|
||||
this.saveToOwnCloudSuccess = ko.observable(false).extend({'falseTimeout': 2000});
|
||||
this.saveToOwnCloudError = ko.observable(false).extend({'falseTimeout': 7000});
|
||||
|
||||
this.saveToOwnCloudSuccess.subscribe(function (bV) {
|
||||
if (bV)
|
||||
{
|
||||
this.saveToOwnCloudError(false);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.saveToOwnCloudError.subscribe(function (bV) {
|
||||
if (bV)
|
||||
{
|
||||
this.saveToOwnCloudSuccess(false);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.saveToDropboxAllowed = ko.computed(function () {
|
||||
return -1 < Utils.inArray('dropbox', this.attahcmentsActions());
|
||||
}, this);
|
||||
|
||||
this.saveToDropboxLoading = ko.observable(false);
|
||||
this.saveToDropboxSuccess = ko.observable(false).extend({'falseTimeout': 2000});
|
||||
this.saveToDropboxError = ko.observable(false).extend({'falseTimeout': 7000});
|
||||
|
||||
this.saveToDropboxSuccess.subscribe(function (bV) {
|
||||
if (bV)
|
||||
{
|
||||
this.saveToDropboxError(false);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.saveToDropboxError.subscribe(function (bV) {
|
||||
if (bV)
|
||||
{
|
||||
this.saveToDropboxSuccess(false);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.showAttachmnetControls.subscribe(function (bV) {
|
||||
if (this.message())
|
||||
|
|
@ -203,6 +260,9 @@
|
|||
}
|
||||
}, this.messageVisibility);
|
||||
|
||||
this.dropboxEnabled = SocialStore.dropbox.enabled;
|
||||
this.dropboxApiKey = SocialStore.dropbox.apiKey;
|
||||
|
||||
// viewer
|
||||
|
||||
this.viewBodyTopValue = ko.observable(0);
|
||||
|
|
@ -475,6 +535,7 @@
|
|||
{
|
||||
var
|
||||
self = this,
|
||||
oScript = null,
|
||||
sErrorMessage = Translator.i18n('PREVIEW_POPUP/IMAGE_ERROR'),
|
||||
fCheckHeaderHeight = _.bind(this.checkHeaderHeight, this)
|
||||
;
|
||||
|
|
@ -503,6 +564,16 @@
|
|||
Utils.windowResize(250);
|
||||
});
|
||||
|
||||
if (this.dropboxEnabled() && this.dropboxApiKey() && !window.Dropbox)
|
||||
{
|
||||
oScript = window.document.createElement('script');
|
||||
oScript.type = 'text/javascript';
|
||||
oScript.src = 'https://www.dropbox.com/static/api/2/dropins.js';
|
||||
$(oScript).attr('id', 'dropboxjs').attr('data-app-key', self.dropboxApiKey());
|
||||
|
||||
window.document.body.appendChild(oScript);
|
||||
}
|
||||
|
||||
this.oHeaderDom = $('.messageItemHeader', oDom);
|
||||
this.oHeaderDom = this.oHeaderDom[0] ? this.oHeaderDom : null;
|
||||
|
||||
|
|
@ -943,28 +1014,109 @@
|
|||
|
||||
MessageViewMailBoxUserView.prototype.downloadAsZip = function ()
|
||||
{
|
||||
var aHashes = this.getAttachmentsHashes();
|
||||
var self = this, aHashes = this.getAttachmentsHashes();
|
||||
if (0 < aHashes.length)
|
||||
{
|
||||
Promises.attachmentsActions('Zip', aHashes, this.downloadAsZipLoading);
|
||||
Promises.attachmentsActions('Zip', aHashes, this.downloadAsZipLoading).then(function (oResult) {
|
||||
if (oResult && oResult.Result && oResult.Result.Files &&
|
||||
oResult.Result.Files[0] && oResult.Result.Files[0].Hash)
|
||||
{
|
||||
require('App/User').download(
|
||||
Links.attachmentDownload(oResult.Result.Files[0].Hash));
|
||||
}
|
||||
else
|
||||
{
|
||||
self.downloadAsZipError(true);
|
||||
}
|
||||
}).fail(function () {
|
||||
self.downloadAsZipError(true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.highlightUnselectedAttachments(true);
|
||||
}
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.saveToOwnCloud = function ()
|
||||
{
|
||||
var aHashes = this.getAttachmentsHashes();
|
||||
var self = this, aHashes = this.getAttachmentsHashes();
|
||||
if (0 < aHashes.length)
|
||||
{
|
||||
Promises.attachmentsActions('OwnCloud', aHashes, this.saveToOwnCloudLoading);
|
||||
Promises.attachmentsActions('OwnCloud', aHashes, this.saveToOwnCloudLoading).then(function (oResult) {
|
||||
if (oResult && oResult.Result)
|
||||
{
|
||||
self.saveToOwnCloudSuccess(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.saveToOwnCloudError(true);
|
||||
}
|
||||
}).fail(function () {
|
||||
self.saveToOwnCloudError(true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.highlightUnselectedAttachments(true);
|
||||
}
|
||||
};
|
||||
|
||||
MessageViewMailBoxUserView.prototype.saveToDropbox = function ()
|
||||
{
|
||||
var aHashes = this.getAttachmentsHashes();
|
||||
var self = this, aFiles = [], aHashes = this.getAttachmentsHashes();
|
||||
if (0 < aHashes.length)
|
||||
{
|
||||
Promises.attachmentsActions('Dropbox', aHashes, this.saveToDropboxLoading);
|
||||
if (window.Dropbox)
|
||||
{
|
||||
Promises.attachmentsActions('Dropbox', aHashes, this.saveToDropboxLoading).then(function (oResult) {
|
||||
if (oResult && oResult.Result && oResult.Result.Url && oResult.Result.ShortLife && oResult.Result.Files)
|
||||
{
|
||||
if (window.Dropbox && Utils.isArray(oResult.Result.Files))
|
||||
{
|
||||
_.each(oResult.Result.Files, function (oItem) {
|
||||
aFiles.push({
|
||||
'url': oResult.Result.Url +
|
||||
Links.attachmentDownload(oItem.Hash, oResult.Result.ShortLife),
|
||||
'filename': oItem.FileName
|
||||
});
|
||||
});
|
||||
|
||||
window.Dropbox.save({
|
||||
'files': aFiles,
|
||||
'progress': function () {
|
||||
self.saveToDropboxLoading(true);
|
||||
self.saveToDropboxError(false);
|
||||
self.saveToDropboxSuccess(false);
|
||||
},
|
||||
'cancel': function () {
|
||||
self.saveToDropboxSuccess(false);
|
||||
self.saveToDropboxError(false);
|
||||
self.saveToDropboxLoading(false);
|
||||
},
|
||||
'success': function () {
|
||||
self.saveToDropboxSuccess(true);
|
||||
self.saveToDropboxLoading(false);
|
||||
},
|
||||
'error': function () {
|
||||
self.saveToDropboxError(true);
|
||||
self.saveToDropboxLoading(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
self.saveToDropboxError(true);
|
||||
}
|
||||
}
|
||||
}).fail(function () {
|
||||
self.saveToDropboxError(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.highlightUnselectedAttachments(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue