mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
Code refactoring
Flow first look
This commit is contained in:
parent
2f841524cb
commit
e6e0b02849
71 changed files with 2092 additions and 1836 deletions
|
|
@ -2,19 +2,18 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {trim, createCommand} from 'Common/Utils';
|
||||
import {trim} from 'Common/Utils';
|
||||
import {getNotification} from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Account',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsAccount'
|
||||
})
|
||||
class AccountPopupView extends AbstractViewNext
|
||||
|
|
@ -43,51 +42,51 @@ class AccountPopupView extends AbstractViewNext
|
|||
this.submitErrorAdditional = ko.observable('');
|
||||
|
||||
this.emailFocus = ko.observable(false);
|
||||
}
|
||||
|
||||
this.addAccountCommand = createCommand(() => {
|
||||
@command((self) => !self.submitRequest())
|
||||
addAccountCommand() {
|
||||
|
||||
this.emailError('' === trim(this.email()));
|
||||
this.passwordError('' === trim(this.password()));
|
||||
this.emailError('' === trim(this.email()));
|
||||
this.passwordError('' === trim(this.password()));
|
||||
|
||||
if (this.emailError() || this.passwordError())
|
||||
if (this.emailError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.accountSetup((result, data) => {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.accountSetup((result, data) => {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
if (data.Result)
|
||||
{
|
||||
if (data.Result)
|
||||
{
|
||||
getApp().accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(data.ErrorCode ? getNotification(data.ErrorCode) :
|
||||
getNotification(Notification.UnknownError));
|
||||
|
||||
if (data.ErrorMessageAdditional)
|
||||
{
|
||||
this.submitErrorAdditional(data.ErrorMessageAdditional);
|
||||
}
|
||||
}
|
||||
getApp().accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
this.submitErrorAdditional('');
|
||||
this.submitError(data.ErrorCode ? getNotification(data.ErrorCode) :
|
||||
getNotification(Notification.UnknownError));
|
||||
|
||||
if (data.ErrorMessageAdditional)
|
||||
{
|
||||
this.submitErrorAdditional(data.ErrorMessageAdditional);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
this.submitErrorAdditional('');
|
||||
}
|
||||
|
||||
}, this.email(), this.password(), this.isNew());
|
||||
}, this.email(), this.password(), this.isNew());
|
||||
|
||||
return true;
|
||||
|
||||
}, () => !this.submitRequest());
|
||||
return true;
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
|
|
@ -118,4 +117,4 @@ class AccountPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = AccountPopupView;
|
||||
export {AccountPopupView, AccountPopupView as default};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {trim, isUnd, createCommand} from 'Common/Utils';
|
||||
import {trim, isUnd} from 'Common/Utils';
|
||||
import {RAINLOOP_TRIAL_KEY} from 'Common/Consts';
|
||||
import {i18n, getNotification} from 'Common/Translator';
|
||||
|
||||
|
|
@ -11,12 +11,11 @@ import * as Settings from 'Storage/Settings';
|
|||
import Remote from 'Remote/Admin/Ajax';
|
||||
import LicenseStore from 'Stores/Admin/License';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Activate',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsActivate'
|
||||
})
|
||||
class ActivatePopupView extends AbstractViewNext
|
||||
|
|
@ -48,54 +47,54 @@ class ActivatePopupView extends AbstractViewNext
|
|||
this.licenseTrigger(!this.licenseTrigger());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.activateCommand = createCommand(() => {
|
||||
@command((self) => !self.activateProcess() && '' !== self.domain() && '' !== self.key() && !self.activationSuccessed())
|
||||
activateCommand() {
|
||||
|
||||
this.activateProcess(true);
|
||||
if (this.validateSubscriptionKey())
|
||||
{
|
||||
Remote.licensingActivate((sResult, oData) => {
|
||||
this.activateProcess(true);
|
||||
if (this.validateSubscriptionKey())
|
||||
{
|
||||
Remote.licensingActivate((sResult, oData) => {
|
||||
|
||||
this.activateProcess(false);
|
||||
if (StorageResultType.Success === sResult && oData.Result)
|
||||
this.activateProcess(false);
|
||||
if (StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
if (true === oData.Result)
|
||||
{
|
||||
if (true === oData.Result)
|
||||
{
|
||||
this.activationSuccessed(true);
|
||||
this.activateText(i18n('POPUPS_ACTIVATE/SUBS_KEY_ACTIVATED'));
|
||||
this.activateText.isError(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.activateText(oData.Result);
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.activateText(getNotification(oData.ErrorCode));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
this.activationSuccessed(true);
|
||||
this.activateText(i18n('POPUPS_ACTIVATE/SUBS_KEY_ACTIVATED'));
|
||||
this.activateText.isError(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.activateText(getNotification(Notification.UnknownError));
|
||||
this.activateText(oData.Result);
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.activateText(getNotification(oData.ErrorCode));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.activateText(getNotification(Notification.UnknownError));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
|
||||
}, this.domain(), this.key());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.activateProcess(false);
|
||||
this.activateText(i18n('POPUPS_ACTIVATE/ERROR_INVALID_SUBS_KEY'));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
|
||||
}, () => !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed());
|
||||
}, this.domain(), this.key());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.activateProcess(false);
|
||||
this.activateText(i18n('POPUPS_ACTIVATE/ERROR_INVALID_SUBS_KEY'));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
}
|
||||
|
||||
onShow(isTrial) {
|
||||
|
|
@ -127,4 +126,4 @@ class ActivatePopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = ActivatePopupView;
|
||||
export {ActivatePopupView, ActivatePopupView as default};
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import {trim, delegateRun, createCommand, log} from 'Common/Utils';
|
||||
import {trim, delegateRun, log} from 'Common/Utils';
|
||||
|
||||
import PgpStore from 'Stores/User/Pgp';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/AddOpenPgpKey',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsAddOpenPgpKey'
|
||||
})
|
||||
class AddOpenPgpKeyPopupView extends AbstractViewNext
|
||||
|
|
@ -28,80 +27,81 @@ class AddOpenPgpKeyPopupView extends AbstractViewNext
|
|||
this.key.error(false);
|
||||
this.key.errorMessage('');
|
||||
});
|
||||
}
|
||||
|
||||
this.addOpenPgpKeyCommand = createCommand(() => {
|
||||
@command()
|
||||
addOpenPgpKeyCommand() {
|
||||
|
||||
const
|
||||
reg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi,
|
||||
openpgpKeyring = PgpStore.openpgpKeyring;
|
||||
const
|
||||
reg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi,
|
||||
openpgpKeyring = PgpStore.openpgpKeyring;
|
||||
|
||||
let keyTrimmed = trim(this.key());
|
||||
let keyTrimmed = trim(this.key());
|
||||
|
||||
if (/[\n]/.test(keyTrimmed))
|
||||
if (/[\n]/.test(keyTrimmed))
|
||||
{
|
||||
keyTrimmed = keyTrimmed.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n');
|
||||
}
|
||||
|
||||
this.key.error('' === keyTrimmed);
|
||||
this.key.errorMessage('');
|
||||
|
||||
if (!openpgpKeyring || this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
let
|
||||
match = null,
|
||||
count = 30,
|
||||
done = false;
|
||||
|
||||
do
|
||||
{
|
||||
match = reg.exec(keyTrimmed);
|
||||
if (match && 0 < count)
|
||||
{
|
||||
keyTrimmed = keyTrimmed.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n');
|
||||
}
|
||||
|
||||
this.key.error('' === keyTrimmed);
|
||||
this.key.errorMessage('');
|
||||
|
||||
if (!openpgpKeyring || this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
let
|
||||
match = null,
|
||||
count = 30,
|
||||
done = false;
|
||||
|
||||
do
|
||||
{
|
||||
match = reg.exec(keyTrimmed);
|
||||
if (match && 0 < count)
|
||||
if (match[0] && match[1] && match[2] && match[1] === match[2])
|
||||
{
|
||||
if (match[0] && match[1] && match[2] && match[1] === match[2])
|
||||
let err = null;
|
||||
if ('PRIVATE' === match[1])
|
||||
{
|
||||
let err = null;
|
||||
if ('PRIVATE' === match[1])
|
||||
{
|
||||
err = openpgpKeyring.privateKeys.importKey(match[0]);
|
||||
}
|
||||
else if ('PUBLIC' === match[1])
|
||||
{
|
||||
err = openpgpKeyring.publicKeys.importKey(match[0]);
|
||||
}
|
||||
|
||||
if (err)
|
||||
{
|
||||
this.key.error(true);
|
||||
this.key.errorMessage(err && err[0] ? '' + err[0] : '');
|
||||
log(err);
|
||||
}
|
||||
err = openpgpKeyring.privateKeys.importKey(match[0]);
|
||||
}
|
||||
else if ('PUBLIC' === match[1])
|
||||
{
|
||||
err = openpgpKeyring.publicKeys.importKey(match[0]);
|
||||
}
|
||||
|
||||
count -= 1;
|
||||
done = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
done = true;
|
||||
if (err)
|
||||
{
|
||||
this.key.error(true);
|
||||
this.key.errorMessage(err && err[0] ? '' + err[0] : '');
|
||||
log(err);
|
||||
}
|
||||
}
|
||||
|
||||
count -= 1;
|
||||
done = false;
|
||||
}
|
||||
while (!done);
|
||||
|
||||
openpgpKeyring.store();
|
||||
|
||||
getApp().reloadOpenPgpKeys();
|
||||
|
||||
if (this.key.error())
|
||||
else
|
||||
{
|
||||
return false;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
while (!done);
|
||||
|
||||
delegateRun(this, 'cancelCommand');
|
||||
return true;
|
||||
});
|
||||
openpgpKeyring.store();
|
||||
|
||||
getApp().reloadOpenPgpKeys();
|
||||
|
||||
if (this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
delegateRun(this, 'cancelCommand');
|
||||
return true;
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
|
|
@ -119,4 +119,4 @@ class AddOpenPgpKeyPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = AddOpenPgpKeyPopupView;
|
||||
export {AddOpenPgpKeyPopupView, AddOpenPgpKeyPopupView as default};
|
||||
|
|
|
|||
|
|
@ -2,18 +2,17 @@
|
|||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {trim, createCommand} from 'Common/Utils';
|
||||
import {trim} from 'Common/Utils';
|
||||
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
|
||||
import {searchSubtractFormatDateHelper} from 'Common/Momentor';
|
||||
|
||||
import MessageStore from 'Stores/User/Message';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/AdvancedSearch',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsAdvancedSearch'
|
||||
})
|
||||
class AdvancedSearchPopupView extends AbstractViewNext
|
||||
|
|
@ -33,16 +32,6 @@ class AdvancedSearchPopupView extends AbstractViewNext
|
|||
this.starred = ko.observable(false);
|
||||
this.unseen = ko.observable(false);
|
||||
|
||||
this.searchCommand = createCommand(() => {
|
||||
const search = this.buildSearchString();
|
||||
if ('' !== search)
|
||||
{
|
||||
MessageStore.mainMessageListSearch(search);
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
});
|
||||
|
||||
this.selectedDates = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
return [
|
||||
|
|
@ -57,6 +46,17 @@ class AdvancedSearchPopupView extends AbstractViewNext
|
|||
});
|
||||
}
|
||||
|
||||
@command()
|
||||
searchCommand() {
|
||||
const search = this.buildSearchString();
|
||||
if ('' !== search)
|
||||
{
|
||||
MessageStore.mainMessageListSearch(search);
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
}
|
||||
|
||||
parseSearchStringValue(search) {
|
||||
const parts = (search || '').split(/[\s]+/g);
|
||||
_.each(parts, (part) => {
|
||||
|
|
@ -171,4 +171,4 @@ class AdvancedSearchPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = AdvancedSearchPopupView;
|
||||
export {AdvancedSearchPopupView, AdvancedSearchPopupView as default};
|
||||
|
|
|
|||
|
|
@ -6,12 +6,11 @@ import {KeyState} from 'Common/Enums';
|
|||
import {isFunc} from 'Common/Utils';
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Ask',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsAsk'
|
||||
})
|
||||
class AskPopupView extends AbstractViewNext
|
||||
|
|
@ -122,4 +121,4 @@ class AskPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = AskPopupView;
|
||||
export {AskPopupView, AskPopupView as default};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import {
|
|||
} from 'Common/Enums';
|
||||
|
||||
import {
|
||||
trim, isArray, isNormal, createCommand, delegateRun,
|
||||
trim, isArray, isNormal, delegateRun,
|
||||
isNonEmptyArray, clearBqSwitcher, replySubjectAdd,
|
||||
encodeHtml, noopFalse, inFocus, delegateRunOnDestroy,
|
||||
pInt, isUnd
|
||||
|
|
@ -46,12 +46,11 @@ import {ComposeAttachmentModel} from 'Model/ComposeAttachment';
|
|||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, ViewType, isPopupVisible, showScreenPopup, hideScreenPopup, routeOn, routeOff} from 'Knoin/Knoin';
|
||||
import {popup, command, isPopupVisible, showScreenPopup, hideScreenPopup, routeOn, routeOff} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Compose',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsCompose'
|
||||
})
|
||||
class ComposePopupView extends AbstractViewNext
|
||||
|
|
@ -311,199 +310,9 @@ class ComposePopupView extends AbstractViewNext
|
|||
|
||||
this.canBeSentOrSaved = ko.computed(() => !this.sending() && !this.saving());
|
||||
|
||||
this.deleteCommand = createCommand(() => {
|
||||
const PopupsAskViewModel = require('View/Popup/Ask');
|
||||
if (!isPopupVisible(PopupsAskViewModel) && this.modalVisibility())
|
||||
{
|
||||
showScreenPopup(PopupsAskViewModel, [i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), () => {
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
getApp().deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]);
|
||||
hideScreenPopup(ComposePopupView);
|
||||
}
|
||||
}]);
|
||||
}
|
||||
|
||||
}, () => this.isDraftFolderMessage());
|
||||
|
||||
this.sendMessageResponse = _.bind(this.sendMessageResponse, this);
|
||||
this.saveMessageResponse = _.bind(this.saveMessageResponse, this);
|
||||
|
||||
this.sendCommand = createCommand(() => {
|
||||
|
||||
const
|
||||
sTo = trim(this.to()),
|
||||
sCc = trim(this.cc()),
|
||||
sBcc = trim(this.bcc());
|
||||
let
|
||||
sSentFolder = FolderStore.sentFolder();
|
||||
|
||||
this.attachmentsInProcessError(false);
|
||||
this.attachmentsInErrorError(false);
|
||||
this.emptyToError(false);
|
||||
|
||||
if (0 < this.attachmentsInProcess().length)
|
||||
{
|
||||
this.attachmentsInProcessError(true);
|
||||
this.attachmentsPlace(true);
|
||||
}
|
||||
else if (0 < this.attachmentsInError().length)
|
||||
{
|
||||
this.attachmentsInErrorError(true);
|
||||
this.attachmentsPlace(true);
|
||||
}
|
||||
|
||||
if ('' === sTo && '' === sCc && '' === sBcc)
|
||||
{
|
||||
this.emptyToError(true);
|
||||
}
|
||||
|
||||
if (!this.emptyToError() && !this.attachmentsInErrorError() && !this.attachmentsInProcessError())
|
||||
{
|
||||
if (SettingsStore.replySameFolder())
|
||||
{
|
||||
if (isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && isNormal(this.aDraftInfo[2]) && 0 < this.aDraftInfo[2].length)
|
||||
{
|
||||
sSentFolder = this.aDraftInfo[2];
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.allowFolders)
|
||||
{
|
||||
sSentFolder = UNUSED_OPTION_VALUE;
|
||||
}
|
||||
|
||||
if ('' === sSentFolder)
|
||||
{
|
||||
showScreenPopup(require('View/Popup/FolderSystem'), [SetSystemFoldersNotification.Sent]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sendError(false);
|
||||
this.sending(true);
|
||||
|
||||
if (isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length)
|
||||
{
|
||||
const flagsCache = getMessageFlagsFromCache(this.aDraftInfo[2], this.aDraftInfo[1]);
|
||||
if (flagsCache)
|
||||
{
|
||||
if ('forward' === this.aDraftInfo[0])
|
||||
{
|
||||
flagsCache[3] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flagsCache[2] = true;
|
||||
}
|
||||
|
||||
setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], flagsCache);
|
||||
getApp().reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
setFolderHash(this.aDraftInfo[2], '');
|
||||
}
|
||||
}
|
||||
|
||||
sSentFolder = UNUSED_OPTION_VALUE === sSentFolder ? '' : sSentFolder;
|
||||
|
||||
setFolderHash(this.draftFolder(), '');
|
||||
setFolderHash(sSentFolder, '');
|
||||
|
||||
Remote.sendMessage(
|
||||
this.sendMessageResponse,
|
||||
this.currentIdentity() ? this.currentIdentity().id() : '',
|
||||
this.draftFolder(),
|
||||
this.draftUid(),
|
||||
sSentFolder,
|
||||
sTo,
|
||||
this.cc(),
|
||||
this.bcc(),
|
||||
this.replyTo(),
|
||||
this.subject(),
|
||||
this.oEditor ? this.oEditor.isHtml() : false,
|
||||
this.oEditor ? this.oEditor.getData(true) : '',
|
||||
this.prepearAttachmentsForSendOrSave(),
|
||||
this.aDraftInfo,
|
||||
this.sInReplyTo,
|
||||
this.sReferences,
|
||||
this.requestDsn(),
|
||||
this.requestReadReceipt(),
|
||||
this.markAsImportant()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}, this.canBeSentOrSaved);
|
||||
|
||||
this.saveCommand = createCommand(() => {
|
||||
|
||||
if (!this.allowFolders)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FolderStore.draftFolderNotEnabled())
|
||||
{
|
||||
showScreenPopup(require('View/Popup/FolderSystem'), [SetSystemFoldersNotification.Draft]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savedError(false);
|
||||
this.saving(true);
|
||||
|
||||
this.autosaveStart();
|
||||
|
||||
setFolderHash(FolderStore.draftFolder(), '');
|
||||
|
||||
Remote.saveMessage(
|
||||
this.saveMessageResponse,
|
||||
this.currentIdentity() ? this.currentIdentity().id() : '',
|
||||
this.draftFolder(),
|
||||
this.draftUid(),
|
||||
FolderStore.draftFolder(),
|
||||
this.to(),
|
||||
this.cc(),
|
||||
this.bcc(),
|
||||
this.replyTo(),
|
||||
this.subject(),
|
||||
this.oEditor ? this.oEditor.isHtml() : false,
|
||||
this.oEditor ? this.oEditor.getData(true) : '',
|
||||
this.prepearAttachmentsForSendOrSave(),
|
||||
this.aDraftInfo,
|
||||
this.sInReplyTo,
|
||||
this.sReferences,
|
||||
this.markAsImportant()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}, this.canBeSentOrSaved);
|
||||
|
||||
this.skipCommand = createCommand(() => {
|
||||
|
||||
this.bSkipNextHide = true;
|
||||
|
||||
if (this.modalVisibility() && !this.saving() && !this.sending() &&
|
||||
!FolderStore.draftFolderNotEnabled())
|
||||
{
|
||||
this.saveCommand();
|
||||
}
|
||||
|
||||
this.tryToClosePopup();
|
||||
|
||||
}, this.canBeSentOrSaved);
|
||||
|
||||
this.contactsCommand = createCommand(() => {
|
||||
|
||||
if (this.allowContacts)
|
||||
{
|
||||
this.skipCommand();
|
||||
_.delay(() => {
|
||||
showScreenPopup(require('View/Popup/Contacts'), [true, this.sLastFocusedField]);
|
||||
}, Magics.Time200ms);
|
||||
}
|
||||
|
||||
}, () => this.allowContacts);
|
||||
|
||||
Events.sub('interval.2m', () => {
|
||||
if (this.modalVisibility() && !FolderStore.draftFolderNotEnabled() && !this.isEmptyForm(false) &&
|
||||
!this.saving() && !this.sending() && !this.savedError())
|
||||
|
|
@ -519,37 +328,12 @@ class ComposePopupView extends AbstractViewNext
|
|||
this.dropboxEnabled = SocialStore.dropbox.enabled;
|
||||
this.dropboxApiKey = SocialStore.dropbox.apiKey;
|
||||
|
||||
this.dropboxCommand = createCommand(() => {
|
||||
|
||||
if (window.Dropbox)
|
||||
{
|
||||
window.Dropbox.choose({
|
||||
success: (files) => {
|
||||
if (files && files[0] && files[0].link)
|
||||
{
|
||||
this.addDropboxAttachment(files[0]);
|
||||
}
|
||||
},
|
||||
linkType: 'direct',
|
||||
multiselect: false
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}, () => this.dropboxEnabled());
|
||||
|
||||
this.driveEnabled = ko.observable(bXMLHttpRequestSupported &&
|
||||
!!Settings.settingsGet('AllowGoogleSocial') && !!Settings.settingsGet('AllowGoogleSocialDrive') &&
|
||||
!!Settings.settingsGet('GoogleClientID') && !!Settings.settingsGet('GoogleApiKey'));
|
||||
|
||||
this.driveVisible = ko.observable(false);
|
||||
|
||||
this.driveCommand = createCommand(() => {
|
||||
this.driveOpenPopup();
|
||||
return true;
|
||||
}, () => this.driveEnabled());
|
||||
|
||||
this.driveCallback = _.bind(this.driveCallback, this);
|
||||
|
||||
this.onMessageUploadAttachments = _.bind(this.onMessageUploadAttachments, this);
|
||||
|
|
@ -565,6 +349,219 @@ class ComposePopupView extends AbstractViewNext
|
|||
this.iTimer = 0;
|
||||
}
|
||||
|
||||
@command((self) => self.canBeSentOrSaved())
|
||||
sendCommand() {
|
||||
|
||||
const
|
||||
sTo = trim(this.to()),
|
||||
sCc = trim(this.cc()),
|
||||
sBcc = trim(this.bcc());
|
||||
let
|
||||
sSentFolder = FolderStore.sentFolder();
|
||||
|
||||
this.attachmentsInProcessError(false);
|
||||
this.attachmentsInErrorError(false);
|
||||
this.emptyToError(false);
|
||||
|
||||
if (0 < this.attachmentsInProcess().length)
|
||||
{
|
||||
this.attachmentsInProcessError(true);
|
||||
this.attachmentsPlace(true);
|
||||
}
|
||||
else if (0 < this.attachmentsInError().length)
|
||||
{
|
||||
this.attachmentsInErrorError(true);
|
||||
this.attachmentsPlace(true);
|
||||
}
|
||||
|
||||
if ('' === sTo && '' === sCc && '' === sBcc)
|
||||
{
|
||||
this.emptyToError(true);
|
||||
}
|
||||
|
||||
if (!this.emptyToError() && !this.attachmentsInErrorError() && !this.attachmentsInProcessError())
|
||||
{
|
||||
if (SettingsStore.replySameFolder())
|
||||
{
|
||||
if (isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && isNormal(this.aDraftInfo[2]) && 0 < this.aDraftInfo[2].length)
|
||||
{
|
||||
sSentFolder = this.aDraftInfo[2];
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.allowFolders)
|
||||
{
|
||||
sSentFolder = UNUSED_OPTION_VALUE;
|
||||
}
|
||||
|
||||
if ('' === sSentFolder)
|
||||
{
|
||||
showScreenPopup(require('View/Popup/FolderSystem'), [SetSystemFoldersNotification.Sent]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sendError(false);
|
||||
this.sending(true);
|
||||
|
||||
if (isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length)
|
||||
{
|
||||
const flagsCache = getMessageFlagsFromCache(this.aDraftInfo[2], this.aDraftInfo[1]);
|
||||
if (flagsCache)
|
||||
{
|
||||
if ('forward' === this.aDraftInfo[0])
|
||||
{
|
||||
flagsCache[3] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flagsCache[2] = true;
|
||||
}
|
||||
|
||||
setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], flagsCache);
|
||||
getApp().reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
setFolderHash(this.aDraftInfo[2], '');
|
||||
}
|
||||
}
|
||||
|
||||
sSentFolder = UNUSED_OPTION_VALUE === sSentFolder ? '' : sSentFolder;
|
||||
|
||||
setFolderHash(this.draftFolder(), '');
|
||||
setFolderHash(sSentFolder, '');
|
||||
|
||||
Remote.sendMessage(
|
||||
this.sendMessageResponse,
|
||||
this.currentIdentity() ? this.currentIdentity().id() : '',
|
||||
this.draftFolder(),
|
||||
this.draftUid(),
|
||||
sSentFolder,
|
||||
sTo,
|
||||
this.cc(),
|
||||
this.bcc(),
|
||||
this.replyTo(),
|
||||
this.subject(),
|
||||
this.oEditor ? this.oEditor.isHtml() : false,
|
||||
this.oEditor ? this.oEditor.getData(true) : '',
|
||||
this.prepearAttachmentsForSendOrSave(),
|
||||
this.aDraftInfo,
|
||||
this.sInReplyTo,
|
||||
this.sReferences,
|
||||
this.requestDsn(),
|
||||
this.requestReadReceipt(),
|
||||
this.markAsImportant()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@command((self) => self.canBeSentOrSaved())
|
||||
saveCommand() {
|
||||
|
||||
if (!this.allowFolders)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FolderStore.draftFolderNotEnabled())
|
||||
{
|
||||
showScreenPopup(require('View/Popup/FolderSystem'), [SetSystemFoldersNotification.Draft]);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savedError(false);
|
||||
this.saving(true);
|
||||
|
||||
this.autosaveStart();
|
||||
|
||||
setFolderHash(FolderStore.draftFolder(), '');
|
||||
|
||||
Remote.saveMessage(
|
||||
this.saveMessageResponse,
|
||||
this.currentIdentity() ? this.currentIdentity().id() : '',
|
||||
this.draftFolder(),
|
||||
this.draftUid(),
|
||||
FolderStore.draftFolder(),
|
||||
this.to(),
|
||||
this.cc(),
|
||||
this.bcc(),
|
||||
this.replyTo(),
|
||||
this.subject(),
|
||||
this.oEditor ? this.oEditor.isHtml() : false,
|
||||
this.oEditor ? this.oEditor.getData(true) : '',
|
||||
this.prepearAttachmentsForSendOrSave(),
|
||||
this.aDraftInfo,
|
||||
this.sInReplyTo,
|
||||
this.sReferences,
|
||||
this.markAsImportant()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@command((self) => self.isDraftFolderMessage())
|
||||
deleteCommand() {
|
||||
const PopupsAskViewModel = require('View/Popup/Ask');
|
||||
if (!isPopupVisible(PopupsAskViewModel) && this.modalVisibility())
|
||||
{
|
||||
showScreenPopup(PopupsAskViewModel, [i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), () => {
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
getApp().deleteMessagesFromFolderWithoutCheck(this.draftFolder(), [this.draftUid()]);
|
||||
hideScreenPopup(ComposePopupView);
|
||||
}
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
||||
@command((self) => self.canBeSentOrSaved())
|
||||
skipCommand() {
|
||||
|
||||
this.bSkipNextHide = true;
|
||||
|
||||
if (this.modalVisibility() && !this.saving() && !this.sending() &&
|
||||
!FolderStore.draftFolderNotEnabled())
|
||||
{
|
||||
this.saveCommand();
|
||||
}
|
||||
|
||||
this.tryToClosePopup();
|
||||
}
|
||||
|
||||
@command((self) => self.allowContacts)
|
||||
contactsCommand() {
|
||||
if (this.allowContacts)
|
||||
{
|
||||
this.skipCommand();
|
||||
_.delay(() => {
|
||||
showScreenPopup(require('View/Popup/Contacts'), [true, this.sLastFocusedField]);
|
||||
}, Magics.Time200ms);
|
||||
}
|
||||
}
|
||||
|
||||
@command((self) => self.dropboxEnabled())
|
||||
dropboxCommand() {
|
||||
if (window.Dropbox)
|
||||
{
|
||||
window.Dropbox.choose({
|
||||
success: (files) => {
|
||||
if (files && files[0] && files[0].link)
|
||||
{
|
||||
this.addDropboxAttachment(files[0]);
|
||||
}
|
||||
},
|
||||
linkType: 'direct',
|
||||
multiselect: false
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@command((self) => self.driveEnabled())
|
||||
driveCommand() {
|
||||
this.driveOpenPopup();
|
||||
return true;
|
||||
}
|
||||
|
||||
autosaveFunction() {
|
||||
if (this.modalVisibility() && !FolderStore.draftFolderNotEnabled() && !this.isEmptyForm(false) &&
|
||||
!this.saving() && !this.sending() && !this.savedError())
|
||||
|
|
@ -1991,4 +1988,4 @@ class ComposePopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = ComposePopupView;
|
||||
export {ComposePopupView, ComposePopupView as default};
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ import ko from 'ko';
|
|||
import key from 'key';
|
||||
|
||||
import {
|
||||
inArray, createCommand,
|
||||
pString, log, isUnd, trim,
|
||||
inArray, pString, log, isUnd, trim,
|
||||
defautOptionsAfterRender
|
||||
} from 'Common/Utils';
|
||||
|
||||
|
|
@ -17,14 +16,13 @@ import PgpStore from 'Stores/User/Pgp';
|
|||
|
||||
import {EmailModel} from 'Model/Email';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
const KEY_NAME_SUBSTR = -8;
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/ComposeOpenPgp',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsComposeOpenPgp'
|
||||
})
|
||||
class ComposeOpenPgpPopupView extends AbstractViewNext
|
||||
|
|
@ -92,210 +90,6 @@ class ComposeOpenPgpPopupView extends AbstractViewNext
|
|||
|
||||
this.resultCallback = null;
|
||||
|
||||
// commands
|
||||
this.doCommand = createCommand(() => {
|
||||
|
||||
let
|
||||
result = true,
|
||||
privateKey = null,
|
||||
aPublicKeys = [];
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
if (result && this.sign())
|
||||
{
|
||||
if (!this.signKey())
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||
result = false;
|
||||
}
|
||||
else if (!this.signKey().key)
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
||||
'EMAIL': this.signKey().email
|
||||
}));
|
||||
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
const privateKeys = this.signKey().key.getNativeKeys();
|
||||
privateKey = privateKeys[0] || null;
|
||||
|
||||
try
|
||||
{
|
||||
if (privateKey)
|
||||
{
|
||||
privateKey.decrypt(pString(this.password()));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
privateKey = null;
|
||||
}
|
||||
|
||||
if (!privateKey)
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result && this.encrypt())
|
||||
{
|
||||
if (0 === this.encryptKeys().length)
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND'));
|
||||
result = false;
|
||||
}
|
||||
else if (this.encryptKeys())
|
||||
{
|
||||
aPublicKeys = [];
|
||||
|
||||
_.each(this.encryptKeys(), (oKey) => {
|
||||
if (oKey && oKey.key)
|
||||
{
|
||||
aPublicKeys = aPublicKeys.concat(_.compact(_.flatten(oKey.key.getNativeKeys())));
|
||||
}
|
||||
else if (oKey && oKey.email)
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
||||
'EMAIL': oKey.email
|
||||
}));
|
||||
|
||||
result = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (result && (0 === aPublicKeys.length || this.encryptKeys().length !== aPublicKeys.length))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result && this.resultCallback)
|
||||
{
|
||||
_.delay(() => {
|
||||
|
||||
let pgpPromise = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (privateKey && 0 === aPublicKeys.length)
|
||||
{
|
||||
pgpPromise = PgpStore.openpgp.sign({
|
||||
data: this.text(),
|
||||
privateKeys: [privateKey]
|
||||
});
|
||||
}
|
||||
else if (privateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
pgpPromise = PgpStore.openpgp.encrypt({
|
||||
data: this.text(),
|
||||
publicKeys: aPublicKeys,
|
||||
privateKeys: [privateKey]
|
||||
});
|
||||
}
|
||||
else if (!privateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
pgpPromise = PgpStore.openpgp.encrypt({
|
||||
data: this.text(),
|
||||
publicKeys: aPublicKeys
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
log(e);
|
||||
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
}
|
||||
|
||||
if (pgpPromise)
|
||||
{
|
||||
try
|
||||
{
|
||||
pgpPromise.then((mData) => {
|
||||
this.resultCallback(mData.data);
|
||||
this.cancelCommand();
|
||||
}).catch((e) => {
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
this.submitRequest(false);
|
||||
|
||||
}, Magics.Time20ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}, () => !this.submitRequest() && (this.sign() || this.encrypt()));
|
||||
|
||||
this.selectCommand = createCommand(() => {
|
||||
|
||||
const
|
||||
keyId = this.selectedPrivateKey(),
|
||||
option = keyId ? _.find(this.privateKeysOptions(), (item) => item && keyId === item.id) : null;
|
||||
|
||||
if (option)
|
||||
{
|
||||
this.signKey({
|
||||
'empty': !option.key,
|
||||
'selected': ko.observable(!!option.key),
|
||||
'users': option.key.users,
|
||||
'hash': option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(),
|
||||
'key': option.key
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.addCommand = createCommand(() => {
|
||||
|
||||
const
|
||||
keyId = this.selectedPublicKey(),
|
||||
keys = this.encryptKeys(),
|
||||
option = keyId ? _.find(this.publicKeysOptions(), (item) => (item && keyId === item.id)) : null;
|
||||
|
||||
if (option)
|
||||
{
|
||||
keys.push({
|
||||
'empty': !option.key,
|
||||
'selected': ko.observable(!!option.key),
|
||||
'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== option.key.id),
|
||||
'users': option.key.users,
|
||||
'hash': option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(),
|
||||
'key': option.key
|
||||
});
|
||||
|
||||
this.encryptKeys(keys);
|
||||
}
|
||||
});
|
||||
|
||||
this.updateCommand = createCommand(() => {
|
||||
_.each(this.encryptKeys(), (oKey) => {
|
||||
oKey.removable(!this.sign() || !this.signKey() || this.signKey().key.id !== oKey.key.id);
|
||||
});
|
||||
});
|
||||
|
||||
this.selectedPrivateKey.subscribe((value) => {
|
||||
if (value)
|
||||
{
|
||||
|
|
@ -328,6 +122,211 @@ class ComposeOpenPgpPopupView extends AbstractViewNext
|
|||
this.deletePublickKey = _.bind(this.deletePublickKey, this);
|
||||
}
|
||||
|
||||
@command((self) => !self.submitRequest() && (self.sign() || self.encrypt()))
|
||||
doCommand() {
|
||||
|
||||
let
|
||||
result = true,
|
||||
privateKey = null,
|
||||
aPublicKeys = [];
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
if (result && this.sign())
|
||||
{
|
||||
if (!this.signKey())
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||
result = false;
|
||||
}
|
||||
else if (!this.signKey().key)
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
||||
'EMAIL': this.signKey().email
|
||||
}));
|
||||
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
const privateKeys = this.signKey().key.getNativeKeys();
|
||||
privateKey = privateKeys[0] || null;
|
||||
|
||||
try
|
||||
{
|
||||
if (privateKey)
|
||||
{
|
||||
privateKey.decrypt(pString(this.password()));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
privateKey = null;
|
||||
}
|
||||
|
||||
if (!privateKey)
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result && this.encrypt())
|
||||
{
|
||||
if (0 === this.encryptKeys().length)
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND'));
|
||||
result = false;
|
||||
}
|
||||
else if (this.encryptKeys())
|
||||
{
|
||||
aPublicKeys = [];
|
||||
|
||||
_.each(this.encryptKeys(), (oKey) => {
|
||||
if (oKey && oKey.key)
|
||||
{
|
||||
aPublicKeys = aPublicKeys.concat(_.compact(_.flatten(oKey.key.getNativeKeys())));
|
||||
}
|
||||
else if (oKey && oKey.email)
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
||||
'EMAIL': oKey.email
|
||||
}));
|
||||
|
||||
result = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (result && (0 === aPublicKeys.length || this.encryptKeys().length !== aPublicKeys.length))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result && this.resultCallback)
|
||||
{
|
||||
_.delay(() => {
|
||||
|
||||
let pgpPromise = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (privateKey && 0 === aPublicKeys.length)
|
||||
{
|
||||
pgpPromise = PgpStore.openpgp.sign({
|
||||
data: this.text(),
|
||||
privateKeys: [privateKey]
|
||||
});
|
||||
}
|
||||
else if (privateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
pgpPromise = PgpStore.openpgp.encrypt({
|
||||
data: this.text(),
|
||||
publicKeys: aPublicKeys,
|
||||
privateKeys: [privateKey]
|
||||
});
|
||||
}
|
||||
else if (!privateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
pgpPromise = PgpStore.openpgp.encrypt({
|
||||
data: this.text(),
|
||||
publicKeys: aPublicKeys
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
log(e);
|
||||
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
}
|
||||
|
||||
if (pgpPromise)
|
||||
{
|
||||
try
|
||||
{
|
||||
pgpPromise.then((mData) => {
|
||||
this.resultCallback(mData.data);
|
||||
this.cancelCommand();
|
||||
}).catch((e) => {
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
this.submitRequest(false);
|
||||
|
||||
}, Magics.Time20ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@command()
|
||||
selectCommand() {
|
||||
const
|
||||
keyId = this.selectedPrivateKey(),
|
||||
option = keyId ? _.find(this.privateKeysOptions(), (item) => item && keyId === item.id) : null;
|
||||
|
||||
if (option)
|
||||
{
|
||||
this.signKey({
|
||||
'empty': !option.key,
|
||||
'selected': ko.observable(!!option.key),
|
||||
'users': option.key.users,
|
||||
'hash': option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(),
|
||||
'key': option.key
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@command()
|
||||
addCommand() {
|
||||
|
||||
const
|
||||
keyId = this.selectedPublicKey(),
|
||||
keys = this.encryptKeys(),
|
||||
option = keyId ? _.find(this.publicKeysOptions(), (item) => (item && keyId === item.id)) : null;
|
||||
|
||||
if (option)
|
||||
{
|
||||
keys.push({
|
||||
'empty': !option.key,
|
||||
'selected': ko.observable(!!option.key),
|
||||
'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== option.key.id),
|
||||
'users': option.key.users,
|
||||
'hash': option.key.id.substr(KEY_NAME_SUBSTR).toUpperCase(),
|
||||
'key': option.key
|
||||
});
|
||||
|
||||
this.encryptKeys(keys);
|
||||
}
|
||||
}
|
||||
|
||||
@command()
|
||||
updateCommand() {
|
||||
_.each(this.encryptKeys(), (oKey) => {
|
||||
oKey.removable(!this.sign() || !this.signKey() || this.signKey().key.id !== oKey.key.id);
|
||||
});
|
||||
}
|
||||
|
||||
deletePublickKey(publicKey) {
|
||||
this.encryptKeys.remove(publicKey);
|
||||
}
|
||||
|
|
@ -459,4 +458,4 @@ class ComposeOpenPgpPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = ComposeOpenPgpPopupView;
|
||||
export {ComposeOpenPgpPopupView, ComposeOpenPgpPopupView as default};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import {
|
|||
|
||||
import {
|
||||
delegateRunOnDestroy, computedPagenatorHelper,
|
||||
inArray, trim, windowResizeCallback, createCommand,
|
||||
inArray, trim, windowResizeCallback,
|
||||
isNonEmptyArray, fakeMd5, pInt, isUnd
|
||||
} from 'Common/Utils';
|
||||
|
||||
|
|
@ -37,12 +37,11 @@ import {ContactPropertyModel} from 'Model/ContactProperty';
|
|||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, ViewType, showScreenPopup, hideScreenPopup, routeOn, routeOff} from 'Knoin/Knoin';
|
||||
import {popup, command, showScreenPopup, hideScreenPopup, routeOn, routeOff} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Contacts',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsContacts'
|
||||
})
|
||||
class ContactsPopupView extends AbstractViewNext
|
||||
|
|
@ -210,155 +209,6 @@ class ContactsPopupView extends AbstractViewNext
|
|||
|
||||
this.selector.on('onItemGetUid', (contact) => (contact ? contact.generateUid() : ''));
|
||||
|
||||
this.newCommand = createCommand(() => {
|
||||
this.populateViewContact(null);
|
||||
this.currentContact(null);
|
||||
});
|
||||
|
||||
this.deleteCommand = createCommand(() => {
|
||||
this.deleteSelectedContacts();
|
||||
this.emptySelection(true);
|
||||
}, () => 0 < this.contactsCheckedOrSelected().length);
|
||||
|
||||
this.newMessageCommand = createCommand(() => {
|
||||
|
||||
if (!Settings.capa(Capa.Composer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
let
|
||||
aE = [],
|
||||
toEmails = null,
|
||||
ccEmails = null,
|
||||
bccEmails = null;
|
||||
|
||||
const aC = this.contactsCheckedOrSelected();
|
||||
if (isNonEmptyArray(aC))
|
||||
{
|
||||
aE = _.map(aC, (oItem) => {
|
||||
if (oItem)
|
||||
{
|
||||
const
|
||||
data = oItem.getNameAndEmailHelper(),
|
||||
email = data ? new EmailModel(data[0], data[1]) : null;
|
||||
|
||||
if (email && email.validate())
|
||||
{
|
||||
return email;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
aE = _.compact(aE);
|
||||
}
|
||||
|
||||
if (isNonEmptyArray(aE))
|
||||
{
|
||||
this.bBackToCompose = false;
|
||||
|
||||
hideScreenPopup(require('View/Popup/Contacts'));
|
||||
|
||||
switch (this.sLastComposeFocusedField)
|
||||
{
|
||||
case 'cc':
|
||||
ccEmails = aE;
|
||||
break;
|
||||
case 'bcc':
|
||||
bccEmails = aE;
|
||||
break;
|
||||
case 'to':
|
||||
default:
|
||||
toEmails = aE;
|
||||
break;
|
||||
}
|
||||
|
||||
this.sLastComposeFocusedField = '';
|
||||
|
||||
_.delay(() => {
|
||||
showScreenPopup(require('View/Popup/Compose'), [ComposeType.Empty, null, toEmails, ccEmails, bccEmails]);
|
||||
}, Magics.Time200ms);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}, () => 0 < this.contactsCheckedOrSelected().length);
|
||||
|
||||
this.clearCommand = createCommand(() => {
|
||||
this.search('');
|
||||
});
|
||||
|
||||
this.saveCommand = createCommand(() => {
|
||||
|
||||
this.viewSaving(true);
|
||||
this.viewSaveTrigger(SaveSettingsStep.Animate);
|
||||
|
||||
const
|
||||
requestUid = fakeMd5(),
|
||||
properties = [];
|
||||
|
||||
_.each(this.viewProperties(), (oItem) => {
|
||||
if (oItem.type() && '' !== trim(oItem.value()))
|
||||
{
|
||||
properties.push([oItem.type(), oItem.value(), oItem.typeStr()]);
|
||||
}
|
||||
});
|
||||
|
||||
Remote.contactSave((sResult, oData) => {
|
||||
|
||||
let res = false;
|
||||
this.viewSaving(false);
|
||||
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result &&
|
||||
oData.Result.RequestUid === requestUid && 0 < pInt(oData.Result.ResultID))
|
||||
{
|
||||
if ('' === this.viewID())
|
||||
{
|
||||
this.viewID(pInt(oData.Result.ResultID));
|
||||
}
|
||||
|
||||
this.reloadContactList();
|
||||
res = true;
|
||||
}
|
||||
|
||||
_.delay(() => {
|
||||
this.viewSaveTrigger(res ? SaveSettingsStep.TrueResult : SaveSettingsStep.FalseResult);
|
||||
}, Magics.Time350ms);
|
||||
|
||||
if (res)
|
||||
{
|
||||
this.watchDirty(false);
|
||||
|
||||
_.delay(() => {
|
||||
this.viewSaveTrigger(SaveSettingsStep.Idle);
|
||||
}, Magics.Time1s);
|
||||
}
|
||||
|
||||
}, requestUid, this.viewID(), properties);
|
||||
|
||||
}, () => {
|
||||
const
|
||||
bV = this.viewHasNonEmptyRequaredProperties(),
|
||||
bReadOnly = this.viewReadOnly();
|
||||
return !this.viewSaving() && bV && !bReadOnly;
|
||||
});
|
||||
|
||||
this.syncCommand = createCommand(() => {
|
||||
|
||||
getApp().contactsSync((result, data) => {
|
||||
if (StorageResultType.Success !== result || !data || !data.Result)
|
||||
{
|
||||
window.alert(getNotification(
|
||||
data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError));
|
||||
}
|
||||
|
||||
this.reloadContactList(true);
|
||||
});
|
||||
|
||||
}, () => !this.contacts.syncing() && !this.contacts.importing());
|
||||
|
||||
this.bDropPageAfterDelete = false;
|
||||
|
||||
this.watchDirty = ko.observable(false);
|
||||
|
|
@ -378,6 +228,157 @@ class ContactsPopupView extends AbstractViewNext
|
|||
this.sDefaultKeyScope = KeyState.ContactList;
|
||||
}
|
||||
|
||||
@command()
|
||||
newCommand() {
|
||||
this.populateViewContact(null);
|
||||
this.currentContact(null);
|
||||
}
|
||||
|
||||
@command((self) => 0 < self.contactsCheckedOrSelected().length)
|
||||
deleteCommand() {
|
||||
this.deleteSelectedContacts();
|
||||
this.emptySelection(true);
|
||||
}
|
||||
|
||||
@command((self) => 0 < self.contactsCheckedOrSelected().length)
|
||||
newMessageCommand() {
|
||||
|
||||
if (!Settings.capa(Capa.Composer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
let
|
||||
aE = [],
|
||||
toEmails = null,
|
||||
ccEmails = null,
|
||||
bccEmails = null;
|
||||
|
||||
const aC = this.contactsCheckedOrSelected();
|
||||
if (isNonEmptyArray(aC))
|
||||
{
|
||||
aE = _.map(aC, (oItem) => {
|
||||
if (oItem)
|
||||
{
|
||||
const
|
||||
data = oItem.getNameAndEmailHelper(),
|
||||
email = data ? new EmailModel(data[0], data[1]) : null;
|
||||
|
||||
if (email && email.validate())
|
||||
{
|
||||
return email;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
aE = _.compact(aE);
|
||||
}
|
||||
|
||||
if (isNonEmptyArray(aE))
|
||||
{
|
||||
this.bBackToCompose = false;
|
||||
|
||||
hideScreenPopup(require('View/Popup/Contacts'));
|
||||
|
||||
switch (this.sLastComposeFocusedField)
|
||||
{
|
||||
case 'cc':
|
||||
ccEmails = aE;
|
||||
break;
|
||||
case 'bcc':
|
||||
bccEmails = aE;
|
||||
break;
|
||||
case 'to':
|
||||
default:
|
||||
toEmails = aE;
|
||||
break;
|
||||
}
|
||||
|
||||
this.sLastComposeFocusedField = '';
|
||||
|
||||
_.delay(() => {
|
||||
showScreenPopup(require('View/Popup/Compose'), [ComposeType.Empty, null, toEmails, ccEmails, bccEmails]);
|
||||
}, Magics.Time200ms);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@command()
|
||||
clearCommand() {
|
||||
this.search('');
|
||||
}
|
||||
|
||||
@command((self) => {
|
||||
const
|
||||
bV = self.viewHasNonEmptyRequaredProperties(),
|
||||
bReadOnly = self.viewReadOnly();
|
||||
return !self.viewSaving() && bV && !bReadOnly;
|
||||
})
|
||||
saveCommand() {
|
||||
|
||||
this.viewSaving(true);
|
||||
this.viewSaveTrigger(SaveSettingsStep.Animate);
|
||||
|
||||
const
|
||||
requestUid = fakeMd5(),
|
||||
properties = [];
|
||||
|
||||
_.each(this.viewProperties(), (oItem) => {
|
||||
if (oItem.type() && '' !== trim(oItem.value()))
|
||||
{
|
||||
properties.push([oItem.type(), oItem.value(), oItem.typeStr()]);
|
||||
}
|
||||
});
|
||||
|
||||
Remote.contactSave((sResult, oData) => {
|
||||
|
||||
let res = false;
|
||||
this.viewSaving(false);
|
||||
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result &&
|
||||
oData.Result.RequestUid === requestUid && 0 < pInt(oData.Result.ResultID))
|
||||
{
|
||||
if ('' === this.viewID())
|
||||
{
|
||||
this.viewID(pInt(oData.Result.ResultID));
|
||||
}
|
||||
|
||||
this.reloadContactList();
|
||||
res = true;
|
||||
}
|
||||
|
||||
_.delay(() => {
|
||||
this.viewSaveTrigger(res ? SaveSettingsStep.TrueResult : SaveSettingsStep.FalseResult);
|
||||
}, Magics.Time350ms);
|
||||
|
||||
if (res)
|
||||
{
|
||||
this.watchDirty(false);
|
||||
|
||||
_.delay(() => {
|
||||
this.viewSaveTrigger(SaveSettingsStep.Idle);
|
||||
}, Magics.Time1s);
|
||||
}
|
||||
|
||||
}, requestUid, this.viewID(), properties);
|
||||
}
|
||||
|
||||
@command((self) => !self.contacts.syncing() && !self.contacts.importing())
|
||||
syncCommand() {
|
||||
getApp().contactsSync((result, data) => {
|
||||
if (StorageResultType.Success !== result || !data || !data.Result)
|
||||
{
|
||||
window.alert(getNotification(
|
||||
data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError));
|
||||
}
|
||||
|
||||
this.reloadContactList(true);
|
||||
});
|
||||
}
|
||||
|
||||
getPropertyPlaceholder(type) {
|
||||
let result = '';
|
||||
switch (type)
|
||||
|
|
@ -722,4 +723,4 @@ class ContactsPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = ContactsPopupView;
|
||||
export {ContactsPopupView, ContactsPopupView as default};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import ko from 'ko';
|
|||
import {StorageResultType, ServerSecure, Ports, Notification} from 'Common/Enums';
|
||||
import {IMAP_DEFAULT_PORT, SIEVE_DEFAULT_PORT, SMTP_DEFAULT_PORT} from 'Common/Consts';
|
||||
import {bMobileDevice} from 'Common/Globals';
|
||||
import {createCommand, trim, pInt, pString} from 'Common/Utils';
|
||||
import {trim, pInt, pString} from 'Common/Utils';
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
import CapaAdminStore from 'Stores/Admin/Capa';
|
||||
|
|
@ -14,12 +14,11 @@ import Remote from 'Remote/Admin/Ajax';
|
|||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Domain',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsDomain'
|
||||
})
|
||||
class DomainPopupView extends AbstractViewNext
|
||||
|
|
@ -141,79 +140,6 @@ class DomainPopupView extends AbstractViewNext
|
|||
this.canBeTested = ko.computed(() => !this.testing() && this.domainIsComputed());
|
||||
this.canBeSaved = ko.computed(() => !this.saving() && this.domainIsComputed());
|
||||
|
||||
this.createOrAddCommand = createCommand(() => {
|
||||
this.saving(true);
|
||||
Remote.createOrUpdateDomain(
|
||||
_.bind(this.onDomainCreateOrSaveResponse, this),
|
||||
!this.edit(),
|
||||
this.name(),
|
||||
|
||||
this.imapServer(),
|
||||
pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
this.imapShortLogin(),
|
||||
|
||||
this.useSieve(),
|
||||
this.sieveAllowRaw(),
|
||||
this.sieveServer(),
|
||||
pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
||||
this.smtpServer(),
|
||||
pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpShortLogin(),
|
||||
this.smtpAuth(),
|
||||
this.smtpPhpMail(),
|
||||
|
||||
this.whiteList()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
this.testConnectionCommand = createCommand(() => {
|
||||
|
||||
this.page('main');
|
||||
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSieveError(false);
|
||||
this.testingSmtpError(false);
|
||||
this.testing(true);
|
||||
|
||||
Remote.testConnectionForDomain(
|
||||
_.bind(this.onTestConnectionResponse, this),
|
||||
this.name(),
|
||||
|
||||
this.imapServer(),
|
||||
pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
|
||||
this.useSieve(),
|
||||
this.sieveServer(),
|
||||
pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
||||
this.smtpServer(),
|
||||
pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpAuth(),
|
||||
this.smtpPhpMail()
|
||||
);
|
||||
}, this.canBeTested);
|
||||
|
||||
this.whiteListCommand = createCommand(() => {
|
||||
this.page('white-list');
|
||||
});
|
||||
|
||||
this.backCommand = createCommand(() => {
|
||||
this.page('main');
|
||||
});
|
||||
|
||||
this.sieveCommand = createCommand(() => {
|
||||
this.sieveSettings(!this.sieveSettings());
|
||||
this.clearTesting();
|
||||
});
|
||||
|
||||
this.page.subscribe(() => {
|
||||
this.sieveSettings(false);
|
||||
});
|
||||
|
|
@ -293,6 +219,84 @@ class DomainPopupView extends AbstractViewNext
|
|||
});
|
||||
}
|
||||
|
||||
@command((self) => self.canBeSaved())
|
||||
createOrAddCommand() {
|
||||
this.saving(true);
|
||||
Remote.createOrUpdateDomain(
|
||||
_.bind(this.onDomainCreateOrSaveResponse, this),
|
||||
!this.edit(),
|
||||
this.name(),
|
||||
|
||||
this.imapServer(),
|
||||
pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
this.imapShortLogin(),
|
||||
|
||||
this.useSieve(),
|
||||
this.sieveAllowRaw(),
|
||||
this.sieveServer(),
|
||||
pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
||||
this.smtpServer(),
|
||||
pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpShortLogin(),
|
||||
this.smtpAuth(),
|
||||
this.smtpPhpMail(),
|
||||
|
||||
this.whiteList()
|
||||
);
|
||||
}
|
||||
|
||||
@command((self) => self.canBeTested())
|
||||
testConnectionCommand() {
|
||||
|
||||
this.page('main');
|
||||
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSieveError(false);
|
||||
this.testingSmtpError(false);
|
||||
this.testing(true);
|
||||
|
||||
Remote.testConnectionForDomain(
|
||||
_.bind(this.onTestConnectionResponse, this),
|
||||
this.name(),
|
||||
|
||||
this.imapServer(),
|
||||
pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
|
||||
this.useSieve(),
|
||||
this.sieveServer(),
|
||||
pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
||||
this.smtpServer(),
|
||||
pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpAuth(),
|
||||
this.smtpPhpMail()
|
||||
);
|
||||
}
|
||||
|
||||
@command()
|
||||
whiteListCommand() {
|
||||
this.page('white-list');
|
||||
}
|
||||
|
||||
@command()
|
||||
backCommand() {
|
||||
this.page('main');
|
||||
}
|
||||
|
||||
@command()
|
||||
sieveCommand() {
|
||||
this.sieveSettings(!this.sieveSettings());
|
||||
this.clearTesting();
|
||||
}
|
||||
|
||||
onTestConnectionResponse(sResult, oData) {
|
||||
this.testing(false);
|
||||
if (StorageResultType.Success === sResult && oData.Result)
|
||||
|
|
@ -462,4 +466,4 @@ class DomainPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = DomainPopupView;
|
||||
export {DomainPopupView, DomainPopupView as default};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import ko from 'ko';
|
|||
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {bMobileDevice} from 'Common/Globals';
|
||||
import {createCommand} from 'Common/Utils';
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
import DomainStore from 'Stores/Admin/Domain';
|
||||
|
|
@ -13,12 +12,11 @@ import Remote from 'Remote/Admin/Ajax';
|
|||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/DomainAlias',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsDomainAlias'
|
||||
})
|
||||
class DomainAliasPopupView extends AbstractViewNext
|
||||
|
|
@ -42,18 +40,19 @@ class DomainAliasPopupView extends AbstractViewNext
|
|||
|
||||
this.canBeSaved = ko.computed(() => !this.saving() && '' !== this.name() && '' !== this.alias());
|
||||
|
||||
this.createCommand = createCommand(() => {
|
||||
this.saving(true);
|
||||
Remote.createDomainAlias(
|
||||
this.onDomainAliasCreateOrSaveResponse,
|
||||
this.name(),
|
||||
this.alias()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
this.onDomainAliasCreateOrSaveResponse = _.bind(this.onDomainAliasCreateOrSaveResponse, this);
|
||||
}
|
||||
|
||||
@command((self) => self.canBeSaved())
|
||||
createCommand() {
|
||||
this.saving(true);
|
||||
Remote.createDomainAlias(
|
||||
this.onDomainAliasCreateOrSaveResponse,
|
||||
this.name(),
|
||||
this.alias()
|
||||
);
|
||||
}
|
||||
|
||||
onDomainAliasCreateOrSaveResponse(result, data) {
|
||||
this.saving(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
|
|
@ -96,4 +95,4 @@ class DomainAliasPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = DomainAliasPopupView;
|
||||
export {DomainAliasPopupView, DomainAliasPopupView as default};
|
||||
|
|
|
|||
|
|
@ -4,18 +4,17 @@ import ko from 'ko';
|
|||
|
||||
import {FiltersAction, FilterConditionField, FilterConditionType} from 'Common/Enums';
|
||||
import {bMobileDevice} from 'Common/Globals';
|
||||
import {defautOptionsAfterRender, createCommand, delegateRun} from 'Common/Utils';
|
||||
import {defautOptionsAfterRender, delegateRun} from 'Common/Utils';
|
||||
import {i18n, initOnStartOrLangChange} from 'Common/Translator';
|
||||
|
||||
import FilterStore from 'Stores/User/Filter';
|
||||
import FolderStore from 'Stores/User/Folder';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Filter',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsFilter'
|
||||
})
|
||||
class FilterPopupView extends AbstractViewNext
|
||||
|
|
@ -43,34 +42,6 @@ class FilterPopupView extends AbstractViewNext
|
|||
}
|
||||
});
|
||||
|
||||
this.saveFilter = createCommand(() => {
|
||||
|
||||
if (this.filter())
|
||||
{
|
||||
if (FiltersAction.MoveTo === this.filter().actionType())
|
||||
{
|
||||
this.filter().actionValue(this.selectedFolderValue());
|
||||
}
|
||||
|
||||
if (!this.filter().verify())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.fTrueCallback)
|
||||
{
|
||||
this.fTrueCallback(this.filter());
|
||||
}
|
||||
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
delegateRun(this, 'closeCommand');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
this.actionTypeOptions = ko.observableArray([]);
|
||||
this.fieldOptions = ko.observableArray([]);
|
||||
this.typeOptions = ko.observableArray([]);
|
||||
|
|
@ -81,6 +52,35 @@ class FilterPopupView extends AbstractViewNext
|
|||
this.modules.subscribe(this.populateOptions, this);
|
||||
}
|
||||
|
||||
@command()
|
||||
saveFilterCommand() {
|
||||
|
||||
if (this.filter())
|
||||
{
|
||||
if (FiltersAction.MoveTo === this.filter().actionType())
|
||||
{
|
||||
this.filter().actionValue(this.selectedFolderValue());
|
||||
}
|
||||
|
||||
if (!this.filter().verify())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.fTrueCallback)
|
||||
{
|
||||
this.fTrueCallback(this.filter());
|
||||
}
|
||||
|
||||
if (this.modalVisibility())
|
||||
{
|
||||
delegateRun(this, 'closeCommand');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
populateOptions() {
|
||||
this.actionTypeOptions([]);
|
||||
|
||||
|
|
@ -191,4 +191,4 @@ class FilterPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = FilterPopupView;
|
||||
export {FilterPopupView, FilterPopupView as default};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {createCommand} from 'Common/Utils';
|
||||
import {i18n, getNotification} from 'Common/Translator';
|
||||
import {setFolderHash} from 'Common/Cache';
|
||||
|
||||
|
|
@ -12,12 +11,11 @@ import Remote from 'Remote/User/Ajax';
|
|||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/FolderClear',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsFolderClear'
|
||||
})
|
||||
class FolderClearPopupView extends AbstractViewNext
|
||||
|
|
@ -42,51 +40,51 @@ class FolderClearPopupView extends AbstractViewNext
|
|||
this.dangerDescHtml = ko.computed(
|
||||
() => i18n('POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1', {'FOLDER': this.folderNameForClear()})
|
||||
);
|
||||
}
|
||||
|
||||
this.clearCommand = createCommand(() => {
|
||||
@command((self) => {
|
||||
const
|
||||
folder = self.selectedFolder(),
|
||||
isClearing = self.clearingProcess();
|
||||
|
||||
const folderToClear = this.selectedFolder();
|
||||
if (folderToClear)
|
||||
{
|
||||
MessageStore.message(null);
|
||||
MessageStore.messageList([]);
|
||||
return !isClearing && null !== folder;
|
||||
})
|
||||
clearCommand() {
|
||||
|
||||
this.clearingProcess(true);
|
||||
const folderToClear = this.selectedFolder();
|
||||
if (folderToClear)
|
||||
{
|
||||
MessageStore.message(null);
|
||||
MessageStore.messageList([]);
|
||||
|
||||
folderToClear.messageCountAll(0);
|
||||
folderToClear.messageCountUnread(0);
|
||||
this.clearingProcess(true);
|
||||
|
||||
setFolderHash(folderToClear.fullNameRaw, '');
|
||||
folderToClear.messageCountAll(0);
|
||||
folderToClear.messageCountUnread(0);
|
||||
|
||||
Remote.folderClear((result, data) => {
|
||||
setFolderHash(folderToClear.fullNameRaw, '');
|
||||
|
||||
this.clearingProcess(false);
|
||||
if (StorageResultType.Success === result && data && data.Result)
|
||||
Remote.folderClear((result, data) => {
|
||||
|
||||
this.clearingProcess(false);
|
||||
if (StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
getApp().reloadMessageList(true);
|
||||
this.cancelCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data && data.ErrorCode)
|
||||
{
|
||||
getApp().reloadMessageList(true);
|
||||
this.cancelCommand();
|
||||
this.clearingError(getNotification(data.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data && data.ErrorCode)
|
||||
{
|
||||
this.clearingError(getNotification(data.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.clearingError(getNotification(Notification.MailServerError));
|
||||
}
|
||||
this.clearingError(getNotification(Notification.MailServerError));
|
||||
}
|
||||
}, folderToClear.fullNameRaw);
|
||||
}
|
||||
|
||||
}, () => {
|
||||
const
|
||||
folder = this.selectedFolder(),
|
||||
isClearing = this.clearingProcess();
|
||||
|
||||
return !isClearing && null !== folder;
|
||||
});
|
||||
}
|
||||
}, folderToClear.fullNameRaw);
|
||||
}
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
|
|
@ -103,4 +101,4 @@ class FolderClearPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = FolderClearPopupView;
|
||||
export {FolderClearPopupView, FolderClearPopupView as default};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import ko from 'ko';
|
|||
import {Notification} from 'Common/Enums';
|
||||
import {UNUSED_OPTION_VALUE} from 'Common/Consts';
|
||||
import {bMobileDevice} from 'Common/Globals';
|
||||
import {trim, createCommand, defautOptionsAfterRender, folderListOptionsBuilder} from 'Common/Utils';
|
||||
import {trim, defautOptionsAfterRender, folderListOptionsBuilder} from 'Common/Utils';
|
||||
|
||||
import FolderStore from 'Stores/User/Folder';
|
||||
|
||||
|
|
@ -12,12 +12,11 @@ import Promises from 'Promises/User/Ajax';
|
|||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/FolderCreate',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsFolderCreate'
|
||||
})
|
||||
class FolderCreateView extends AbstractViewNext
|
||||
|
|
@ -49,27 +48,26 @@ class FolderCreateView extends AbstractViewNext
|
|||
|
||||
});
|
||||
|
||||
// commands
|
||||
this.createFolder = createCommand(() => {
|
||||
|
||||
let parentFolderName = this.selectedParentValue();
|
||||
if ('' === parentFolderName && 1 < FolderStore.namespace.length)
|
||||
{
|
||||
parentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1);
|
||||
}
|
||||
|
||||
getApp().foldersPromisesActionHelper(
|
||||
Promises.folderCreate(this.folderName(), parentFolderName, FolderStore.foldersCreating),
|
||||
Notification.CantCreateFolder
|
||||
);
|
||||
|
||||
this.cancelCommand();
|
||||
|
||||
}, () => this.simpleFolderNameValidation(this.folderName()));
|
||||
|
||||
this.defautOptionsAfterRender = defautOptionsAfterRender;
|
||||
}
|
||||
|
||||
@command((self) => self.simpleFolderNameValidation(self.folderName()))
|
||||
createFolderCommand() {
|
||||
|
||||
let parentFolderName = this.selectedParentValue();
|
||||
if ('' === parentFolderName && 1 < FolderStore.namespace.length)
|
||||
{
|
||||
parentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1);
|
||||
}
|
||||
|
||||
getApp().foldersPromisesActionHelper(
|
||||
Promises.folderCreate(this.folderName(), parentFolderName, FolderStore.foldersCreating),
|
||||
Notification.CantCreateFolder
|
||||
);
|
||||
|
||||
this.cancelCommand();
|
||||
}
|
||||
|
||||
simpleFolderNameValidation(sName) {
|
||||
return (/^[^\\\/]+$/g).test(trim(sName));
|
||||
}
|
||||
|
|
@ -92,4 +90,4 @@ class FolderCreateView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = FolderCreateView;
|
||||
export {FolderCreateView, FolderCreateView as default};
|
||||
|
|
|
|||
|
|
@ -12,12 +12,11 @@ import FolderStore from 'Stores/User/Folder';
|
|||
import * as Settings from 'Storage/Settings';
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/FolderSystem',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsFolderSystem'
|
||||
})
|
||||
class FolderSystemPopupView extends AbstractViewNext
|
||||
|
|
@ -110,4 +109,4 @@ class FolderSystemPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = FolderSystemPopupView;
|
||||
export {FolderSystemPopupView, FolderSystemPopupView as default};
|
||||
|
|
|
|||
|
|
@ -3,19 +3,18 @@ import ko from 'ko';
|
|||
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {bMobileDevice} from 'Common/Globals';
|
||||
import {createCommand, trim, fakeMd5} from 'Common/Utils';
|
||||
import {trim, fakeMd5} from 'Common/Utils';
|
||||
import {getNotification} from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Identity',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsIdentity'
|
||||
})
|
||||
class IdentityPopupView extends AbstractViewNext
|
||||
|
|
@ -58,68 +57,68 @@ class IdentityPopupView extends AbstractViewNext
|
|||
this.showReplyTo(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.addOrEditIdentityCommand = createCommand(() => {
|
||||
@command((self) => !self.submitRequest())
|
||||
addOrEditIdentityCommand() {
|
||||
|
||||
if (this.signature && this.signature.__fetchEditorValue)
|
||||
if (this.signature && this.signature.__fetchEditorValue)
|
||||
{
|
||||
this.signature.__fetchEditorValue();
|
||||
}
|
||||
|
||||
if (!this.email.hasError())
|
||||
{
|
||||
this.email.hasError('' === trim(this.email()));
|
||||
}
|
||||
|
||||
if (this.email.hasError())
|
||||
{
|
||||
if (!this.owner())
|
||||
{
|
||||
this.signature.__fetchEditorValue();
|
||||
this.email.focused(true);
|
||||
}
|
||||
|
||||
if (!this.email.hasError())
|
||||
{
|
||||
this.email.hasError('' === trim(this.email()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.email.hasError())
|
||||
if (this.replyTo.hasError())
|
||||
{
|
||||
this.replyTo.focused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.bcc.hasError())
|
||||
{
|
||||
this.bcc.focused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.identityUpdate((result, data) => {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
{
|
||||
if (!this.owner())
|
||||
if (data.Result)
|
||||
{
|
||||
this.email.focused(true);
|
||||
getApp().accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.replyTo.hasError())
|
||||
{
|
||||
this.replyTo.focused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.bcc.hasError())
|
||||
{
|
||||
this.bcc.focused(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.identityUpdate((result, data) => {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
else if (data.ErrorCode)
|
||||
{
|
||||
if (data.Result)
|
||||
{
|
||||
getApp().accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (data.ErrorCode)
|
||||
{
|
||||
this.submitError(getNotification(data.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
this.submitError(getNotification(data.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this.id, this.email(), this.name(), this.replyTo(), this.bcc(), this.signature(), this.signatureInsertBefore());
|
||||
}, this.id, this.email(), this.name(), this.replyTo(), this.bcc(), this.signature(), this.signatureInsertBefore());
|
||||
|
||||
return true;
|
||||
|
||||
}, () => !this.submitRequest());
|
||||
return true;
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
|
|
@ -184,4 +183,4 @@ class IdentityPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = IdentityPopupView;
|
||||
export {IdentityPopupView, IdentityPopupView as default};
|
||||
|
|
|
|||
|
|
@ -4,12 +4,11 @@ import key from 'key';
|
|||
|
||||
import {KeyState, Magics} from 'Common/Enums';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/KeyboardShortcutsHelp',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsKeyboardShortcutsHelp'
|
||||
})
|
||||
class KeyboardShortcutsHelpPopupView extends AbstractViewNext
|
||||
|
|
@ -52,4 +51,4 @@ class KeyboardShortcutsHelpPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = KeyboardShortcutsHelpPopupView;
|
||||
export {KeyboardShortcutsHelpPopupView, KeyboardShortcutsHelpPopupView as default};
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ import ko from 'ko';
|
|||
|
||||
import {convertLangName} from 'Common/Utils';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
// import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Languages',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsLanguages'
|
||||
})
|
||||
class LanguagesPopupView extends AbstractViewNext
|
||||
|
|
@ -73,4 +73,4 @@ class LanguagesPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = LanguagesPopupView;
|
||||
export {LanguagesPopupView, LanguagesPopupView as default};
|
||||
|
|
|
|||
|
|
@ -4,15 +4,14 @@ import ko from 'ko';
|
|||
import key from 'key';
|
||||
import $ from '$';
|
||||
|
||||
import {createCommand, pString, log} from 'Common/Utils';
|
||||
import {pString, log} from 'Common/Utils';
|
||||
import {KeyState, Magics} from 'Common/Enums';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/MessageOpenPgp',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsMessageOpenPgp'
|
||||
})
|
||||
class MessageOpenPgpPopupView extends AbstractViewNext
|
||||
|
|
@ -33,60 +32,59 @@ class MessageOpenPgpPopupView extends AbstractViewNext
|
|||
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
// commands
|
||||
this.doCommand = createCommand(() => {
|
||||
this.sDefaultKeyScope = KeyState.PopupMessageOpenPGP;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
@command((self) => !self.submitRequest())
|
||||
doCommand() {
|
||||
|
||||
_.delay(() => {
|
||||
this.submitRequest(true);
|
||||
|
||||
let privateKey = null;
|
||||
_.delay(() => {
|
||||
|
||||
try
|
||||
let privateKey = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (this.resultCallback && this.selectedKey())
|
||||
{
|
||||
if (this.resultCallback && this.selectedKey())
|
||||
{
|
||||
const privateKeys = this.selectedKey().getNativeKeys();
|
||||
privateKey = privateKeys && privateKeys[0] ? privateKeys[0] : null;
|
||||
const privateKeys = this.selectedKey().getNativeKeys();
|
||||
privateKey = privateKeys && privateKeys[0] ? privateKeys[0] : null;
|
||||
|
||||
if (privateKey)
|
||||
if (privateKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
if (!privateKey.decrypt(pString(this.password())))
|
||||
{
|
||||
if (!privateKey.decrypt(pString(this.password())))
|
||||
{
|
||||
log('Error: Private key cannot be decrypted');
|
||||
privateKey = null;
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
log(e);
|
||||
log('Error: Private key cannot be decrypted');
|
||||
privateKey = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (e)
|
||||
{
|
||||
log('Error: Private key cannot be found');
|
||||
log(e);
|
||||
privateKey = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log('Error: Private key cannot be found');
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
log(e);
|
||||
privateKey = null;
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
log(e);
|
||||
privateKey = null;
|
||||
}
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitRequest(false);
|
||||
|
||||
this.cancelCommand();
|
||||
this.resultCallback(privateKey);
|
||||
this.cancelCommand();
|
||||
this.resultCallback(privateKey);
|
||||
|
||||
}, Magics.Time100ms);
|
||||
|
||||
}, () => !this.submitRequest());
|
||||
|
||||
this.sDefaultKeyScope = KeyState.PopupMessageOpenPGP;
|
||||
}, Magics.Time100ms);
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
|
|
@ -162,4 +160,4 @@ class MessageOpenPgpPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = MessageOpenPgpPopupView;
|
||||
export {MessageOpenPgpPopupView, MessageOpenPgpPopupView as default};
|
||||
|
|
|
|||
|
|
@ -3,18 +3,17 @@ import _ from '_';
|
|||
import ko from 'ko';
|
||||
|
||||
import {Magics} from 'Common/Enums';
|
||||
import {trim, log, createCommand, delegateRun, pInt} from 'Common/Utils';
|
||||
import {trim, log, delegateRun, pInt} from 'Common/Utils';
|
||||
|
||||
import PgpStore from 'Stores/User/Pgp';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/NewOpenPgpKey',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsNewOpenPgpKey'
|
||||
})
|
||||
class NewOpenPgpKeyPopupView extends AbstractViewNext
|
||||
|
|
@ -36,66 +35,67 @@ class NewOpenPgpKeyPopupView extends AbstractViewNext
|
|||
this.email.subscribe(() => {
|
||||
this.email.error(false);
|
||||
});
|
||||
}
|
||||
|
||||
this.generateOpenPgpKeyCommand = createCommand(() => {
|
||||
@command()
|
||||
generateOpenPgpKeyCommand() {
|
||||
|
||||
const
|
||||
userId = {},
|
||||
openpgpKeyring = PgpStore.openpgpKeyring;
|
||||
const
|
||||
userId = {},
|
||||
openpgpKeyring = PgpStore.openpgpKeyring;
|
||||
|
||||
this.email.error('' === trim(this.email()));
|
||||
if (!openpgpKeyring || this.email.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.email.error('' === trim(this.email()));
|
||||
if (!openpgpKeyring || this.email.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
userId.email = this.email();
|
||||
if ('' !== this.name())
|
||||
{
|
||||
userId.name = this.name();
|
||||
}
|
||||
userId.email = this.email();
|
||||
if ('' !== this.name())
|
||||
{
|
||||
userId.name = this.name();
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
this.submitError('');
|
||||
this.submitRequest(true);
|
||||
this.submitError('');
|
||||
|
||||
_.delay(() => {
|
||||
_.delay(() => {
|
||||
|
||||
try {
|
||||
try {
|
||||
|
||||
PgpStore.openpgp.generateKey({
|
||||
userIds: [userId],
|
||||
numBits: pInt(this.keyBitLength()),
|
||||
passphrase: trim(this.password())
|
||||
}).then((keyPair) => {
|
||||
PgpStore.openpgp.generateKey({
|
||||
userIds: [userId],
|
||||
numBits: pInt(this.keyBitLength()),
|
||||
passphrase: trim(this.password())
|
||||
}).then((keyPair) => {
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitRequest(false);
|
||||
|
||||
if (keyPair && keyPair.privateKeyArmored)
|
||||
{
|
||||
openpgpKeyring.privateKeys.importKey(keyPair.privateKeyArmored);
|
||||
openpgpKeyring.publicKeys.importKey(keyPair.publicKeyArmored);
|
||||
if (keyPair && keyPair.privateKeyArmored)
|
||||
{
|
||||
openpgpKeyring.privateKeys.importKey(keyPair.privateKeyArmored);
|
||||
openpgpKeyring.publicKeys.importKey(keyPair.publicKeyArmored);
|
||||
|
||||
openpgpKeyring.store();
|
||||
openpgpKeyring.store();
|
||||
|
||||
getApp().reloadOpenPgpKeys();
|
||||
delegateRun(this, 'cancelCommand');
|
||||
}
|
||||
getApp().reloadOpenPgpKeys();
|
||||
delegateRun(this, 'cancelCommand');
|
||||
}
|
||||
|
||||
}).catch((e) => {
|
||||
this.submitRequest(false);
|
||||
this.showError(e);
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}).catch((e) => {
|
||||
this.submitRequest(false);
|
||||
this.showError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.showError(e);
|
||||
}
|
||||
|
||||
}, Magics.Time100ms);
|
||||
}, Magics.Time100ms);
|
||||
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
showError(e) {
|
||||
|
|
@ -126,4 +126,4 @@ class NewOpenPgpKeyPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = NewOpenPgpKeyPopupView;
|
||||
export {NewOpenPgpKeyPopupView, NewOpenPgpKeyPopupView as default};
|
||||
|
|
|
|||
|
|
@ -4,17 +4,16 @@ import ko from 'ko';
|
|||
import key from 'key';
|
||||
|
||||
import {KeyState, Magics, StorageResultType, Notification} from 'Common/Enums';
|
||||
import {createCommand, isNonEmptyArray, delegateRun} from 'Common/Utils';
|
||||
import {isNonEmptyArray, delegateRun} from 'Common/Utils';
|
||||
import {getNotification, i18n} from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import {view, ViewType, isPopupVisible, showScreenPopup} from 'Knoin/Knoin';
|
||||
import {popup, command, isPopupVisible, showScreenPopup} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Plugin',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsPlugin'
|
||||
})
|
||||
class PluginPopupView extends AbstractViewNext
|
||||
|
|
@ -43,31 +42,31 @@ class PluginPopupView extends AbstractViewNext
|
|||
'content': () => `<pre>${this.readme()}</pre>`
|
||||
};
|
||||
|
||||
this.saveCommand = createCommand(() => {
|
||||
|
||||
const list = {};
|
||||
list.Name = this.name();
|
||||
|
||||
_.each(this.configures(), (oItem) => {
|
||||
let value = oItem.value();
|
||||
if (false === value || true === value)
|
||||
{
|
||||
value = value ? '1' : '0';
|
||||
}
|
||||
list['_' + oItem.Name] = value;
|
||||
});
|
||||
|
||||
this.saveError('');
|
||||
Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list);
|
||||
|
||||
}, this.hasConfiguration);
|
||||
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = KeyState.All;
|
||||
|
||||
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), Magics.Time200ms);
|
||||
}
|
||||
|
||||
@command((self) => self.hasConfiguration())
|
||||
saveCommand() {
|
||||
|
||||
const list = {};
|
||||
list.Name = this.name();
|
||||
|
||||
_.each(this.configures(), (oItem) => {
|
||||
let value = oItem.value();
|
||||
if (false === value || true === value)
|
||||
{
|
||||
value = value ? '1' : '0';
|
||||
}
|
||||
list['_' + oItem.Name] = value;
|
||||
});
|
||||
|
||||
this.saveError('');
|
||||
Remote.pluginSettingsUpdate(this.onPluginSettingsUpdateResponse, list);
|
||||
}
|
||||
|
||||
onPluginSettingsUpdateResponse(result, data) {
|
||||
if (StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
|
|
@ -138,4 +137,4 @@ class PluginPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = PluginPopupView;
|
||||
export {PluginPopupView, PluginPopupView as default};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {trim, isNormal, createCommand} from 'Common/Utils';
|
||||
import {trim, isNormal} from 'Common/Utils';
|
||||
import {getNotification} from 'Common/Translator';
|
||||
import {HtmlEditor} from 'Common/HtmlEditor';
|
||||
|
||||
|
|
@ -10,12 +10,11 @@ import Remote from 'Remote/User/Ajax';
|
|||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/Template',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsTemplate'
|
||||
})
|
||||
class TemplatePopupView extends AbstractViewNext
|
||||
|
|
@ -46,46 +45,46 @@ class TemplatePopupView extends AbstractViewNext
|
|||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
}
|
||||
|
||||
this.addTemplateCommand = createCommand(() => {
|
||||
@command((self) => !self.submitRequest())
|
||||
addTemplateCommand() {
|
||||
|
||||
this.populateBodyFromEditor();
|
||||
this.populateBodyFromEditor();
|
||||
|
||||
this.name.error('' === trim(this.name()));
|
||||
this.body.error('' === trim(this.body()) || ':HTML:' === trim(this.body()));
|
||||
this.name.error('' === trim(this.name()));
|
||||
this.body.error('' === trim(this.body()) || ':HTML:' === trim(this.body()));
|
||||
|
||||
if (this.name.error() || this.body.error())
|
||||
if (this.name.error() || this.body.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.templateSetup((result, data) => {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
{
|
||||
return false;
|
||||
if (data.Result)
|
||||
{
|
||||
getApp().templates();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (data.ErrorCode)
|
||||
{
|
||||
this.submitError(getNotification(data.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
}, this.id(), this.name(), this.body());
|
||||
|
||||
Remote.templateSetup((result, data) => {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
{
|
||||
if (data.Result)
|
||||
{
|
||||
getApp().templates();
|
||||
this.cancelCommand();
|
||||
}
|
||||
else if (data.ErrorCode)
|
||||
{
|
||||
this.submitError(getNotification(data.ErrorCode));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this.id(), this.name(), this.body());
|
||||
|
||||
return true;
|
||||
|
||||
}, () => !this.submitRequest());
|
||||
return true;
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
|
|
@ -183,4 +182,4 @@ class TemplatePopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = TemplatePopupView;
|
||||
export {TemplatePopupView, TemplatePopupView as default};
|
||||
|
|
|
|||
|
|
@ -14,12 +14,11 @@ import Remote from 'Remote/User/Ajax';
|
|||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, ViewType, showScreenPopup} from 'Knoin/Knoin';
|
||||
import {popup, showScreenPopup} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/TwoFactorConfiguration',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsTwoFactorConfiguration'
|
||||
})
|
||||
class TwoFactorConfigurationPopupView extends AbstractViewNext
|
||||
|
|
@ -214,4 +213,4 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = TwoFactorConfigurationPopupView;
|
||||
export {TwoFactorConfigurationPopupView, TwoFactorConfigurationPopupView as default};
|
||||
|
|
|
|||
|
|
@ -3,16 +3,14 @@ import ko from 'ko';
|
|||
|
||||
import {StorageResultType} from 'Common/Enums';
|
||||
import {bMobileDevice} from 'Common/Globals';
|
||||
import {createCommand} from 'Common/Utils';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup, command} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/TwoFactorTest',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsTwoFactorTest'
|
||||
})
|
||||
class TwoFactorTestPopupView extends AbstractViewNext
|
||||
|
|
@ -27,24 +25,23 @@ class TwoFactorTestPopupView extends AbstractViewNext
|
|||
this.koTestedTrigger = null;
|
||||
|
||||
this.testing = ko.observable(false);
|
||||
}
|
||||
|
||||
// commands
|
||||
this.testCode = createCommand(() => {
|
||||
@command((self) => '' !== self.code() && !self.testing())
|
||||
testCodeCommand() {
|
||||
|
||||
this.testing(true);
|
||||
Remote.testTwoFactor((result, data) => {
|
||||
this.testing(true);
|
||||
Remote.testTwoFactor((result, data) => {
|
||||
|
||||
this.testing(false);
|
||||
this.code.status(StorageResultType.Success === result && data && !!data.Result);
|
||||
this.testing(false);
|
||||
this.code.status(StorageResultType.Success === result && data && !!data.Result);
|
||||
|
||||
if (this.koTestedTrigger && this.code.status())
|
||||
{
|
||||
this.koTestedTrigger(true);
|
||||
}
|
||||
if (this.koTestedTrigger && this.code.status())
|
||||
{
|
||||
this.koTestedTrigger(true);
|
||||
}
|
||||
|
||||
}, this.code());
|
||||
|
||||
}, () => '' !== this.code() && !this.testing());
|
||||
}, this.code());
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
|
|
@ -70,4 +67,4 @@ class TwoFactorTestPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = TwoFactorTestPopupView;
|
||||
export {TwoFactorTestPopupView, TwoFactorTestPopupView as default};
|
||||
|
|
|
|||
|
|
@ -5,12 +5,11 @@ import key from 'key';
|
|||
import {KeyState} from 'Common/Enums';
|
||||
import {selectElement} from 'Common/Utils';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/ViewOpenPgpKey',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsTwoFactorTest'
|
||||
})
|
||||
class ViewOpenPgpKeyPopupView extends AbstractViewNext
|
||||
|
|
@ -53,4 +52,4 @@ class ViewOpenPgpKeyPopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = ViewOpenPgpKeyPopupView;
|
||||
export {ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default};
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@ import ko from 'ko';
|
|||
|
||||
import Promises from 'Promises/User/Ajax';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {popup} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
@popup({
|
||||
name: 'View/Popup/WelcomePage',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsWelcomePage'
|
||||
})
|
||||
class WelcomePagePopupView extends AbstractViewNext
|
||||
|
|
@ -45,4 +44,4 @@ class WelcomePagePopupView extends AbstractViewNext
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = WelcomePagePopupView;
|
||||
export {WelcomePagePopupView, WelcomePagePopupView as default};
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ import {
|
|||
import {
|
||||
inArray, isArray, isNonEmptyArray, trim, noop,
|
||||
windowResize, windowResizeCallback, inFocus,
|
||||
removeSelection, removeInFocus, mailToHelper,
|
||||
createCommand
|
||||
removeSelection, removeInFocus, mailToHelper
|
||||
} from 'Common/Utils';
|
||||
|
||||
import Audio from 'Common/Audio';
|
||||
|
|
@ -52,7 +51,7 @@ import Promises from 'Promises/User/Ajax';
|
|||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {view, command, ViewType, showScreenPopup} from 'Knoin/Knoin';
|
||||
import {view, command, ViewType, showScreenPopup, createCommand} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue