mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
es5 -> es2015 (last stage)
Signature plugin fixes Add view decorator A large number of fixes
This commit is contained in:
parent
e88c193334
commit
17669b7be0
6
.cmds
6
.cmds
|
@ -3,10 +3,10 @@
|
|||
tx pull -a
|
||||
|
||||
# dependencies checker
|
||||
npm-check --skip-unused
|
||||
npm-check --skip-unused --save-exact
|
||||
|
||||
# dependencies locker
|
||||
npm shrinkwrap --dev
|
||||
|
||||
# js code validation
|
||||
gulp v
|
||||
# webpack
|
||||
webpack --color --watch
|
||||
|
|
10
.eslintrc.js
10
.eslintrc.js
|
@ -4,6 +4,7 @@ module.exports = {
|
|||
'ecmaFeatures': {
|
||||
'modules': true
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
'parserOptions': {
|
||||
'ecmaVersion': 6,
|
||||
'sourceType': 'module'
|
||||
|
@ -11,8 +12,7 @@ module.exports = {
|
|||
'env': {
|
||||
'node': true,
|
||||
'commonjs': true,
|
||||
'es6': true,
|
||||
'browser': true
|
||||
'es6': true
|
||||
},
|
||||
'globals': {
|
||||
'RL_COMMUNITY': true,
|
||||
|
@ -84,7 +84,7 @@ module.exports = {
|
|||
'no-implicit-coercion': [2, {'allow': ['!!', '+']}],
|
||||
'no-implicit-globals': 2,
|
||||
'no-implied-eval': 2,
|
||||
// 'no-invalid-this': 2,
|
||||
'no-invalid-this': 2,
|
||||
'no-iterator': 2,
|
||||
'no-labels': 2,
|
||||
'no-lone-blocks': 2,
|
||||
|
@ -263,9 +263,9 @@ module.exports = {
|
|||
'no-useless-computed-key': 2,
|
||||
'no-useless-constructor': 2,
|
||||
'no-useless-rename': 2,
|
||||
// 'no-var': 2,
|
||||
'no-var': 2,
|
||||
// 'object-shorthand': 2,
|
||||
// 'prefer-arrow-callback': 2,
|
||||
'prefer-arrow-callback': 2,
|
||||
'prefer-const': 2,
|
||||
// 'prefer-reflect': 2,
|
||||
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,6 +13,7 @@
|
|||
/rainloop/v/0.0.0/static/css/*.css
|
||||
/rainloop/v/0.0.0/static/js/*.js
|
||||
/rainloop/v/0.0.0/static/js/**/*.js
|
||||
!/rainloop/v/0.0.0/static/js/min/.gitempty
|
||||
/rainloop/v/0.0.0/app/localization/moment/*
|
||||
!/rainloop/v/0.0.0/app/localization/moment/.gitempty
|
||||
/node_modules
|
||||
|
|
12
.travis.yml
12
.travis.yml
|
@ -5,9 +5,9 @@ php:
|
|||
- '5.5'
|
||||
- '5.6'
|
||||
- '7.0'
|
||||
before_script:
|
||||
- sudo apt-get install -y build-essential libssl-dev
|
||||
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
|
||||
- nvm install 4.4.5
|
||||
- nvm use 4.4.5
|
||||
- npm install -g eslint
|
||||
#before_script:
|
||||
# - sudo apt-get install -y build-essential libssl-dev
|
||||
# - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
|
||||
# - nvm install 4.4.5
|
||||
# - nvm use 4.4.5
|
||||
# - npm install -g eslint babel-eslint
|
||||
|
|
46
README.md
46
README.md
|
@ -1,23 +1,23 @@
|
|||
RainLoop Webmail [![Build Status](https://travis-ci.org/RainLoop/rainloop-webmail.svg?branch=master)](https://travis-ci.org/RainLoop/rainloop-webmail)
|
||||
==================
|
||||
|
||||
Simple, modern & fast web-based email client.
|
||||
|
||||
Modest system requirements, decent performance, simple installation and upgrade, no database required - all these make RainLoop Webmail a perfect choice for your email solution.
|
||||
|
||||
For more information about the product, check [rainloop.net](http://www.rainloop.net/).
|
||||
|
||||
Information about installing the product, check the [documentation page](http://www.rainloop.net/docs/installation/).
|
||||
|
||||
## Attention
|
||||
|
||||
This is **NOT** a stable version of RainLoop Webmail.
|
||||
It's not recommended to use in production environment.
|
||||
|
||||
## License
|
||||
|
||||
**RainLoop Webmail (Community edition)** is released under
|
||||
**GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (AGPL)**.
|
||||
http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
Copyright (c) 2016 Rainloop Team
|
||||
RainLoop Webmail [![Build Status](https://travis-ci.org/RainLoop/rainloop-webmail.svg?branch=master)](https://travis-ci.org/RainLoop/rainloop-webmail) [![devDependency Status](https://david-dm.org/RainLoop/rainloop-webmail/dev-status.svg)](https://david-dm.org/RainLoop/rainloop-webmail?type=dev)
|
||||
==================
|
||||
|
||||
Simple, modern & fast web-based email client.
|
||||
|
||||
Modest system requirements, decent performance, simple installation and upgrade, no database required - all these make RainLoop Webmail a perfect choice for your email solution.
|
||||
|
||||
For more information about the product, check [rainloop.net](http://www.rainloop.net/).
|
||||
|
||||
Information about installing the product, check the [documentation page](http://www.rainloop.net/docs/installation/).
|
||||
|
||||
## Attention
|
||||
|
||||
This is **NOT** a stable version of RainLoop Webmail.
|
||||
It's not recommended to use in production environment.
|
||||
|
||||
## License
|
||||
|
||||
**RainLoop Webmail (Community edition)** is released under
|
||||
**GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (AGPL)**.
|
||||
http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
Copyright (c) 2016 Rainloop Team
|
||||
|
|
253
dev/App/User.js
253
dev/App/User.js
|
@ -7,7 +7,7 @@ import Tinycon from 'Tinycon';
|
|||
|
||||
import {
|
||||
noop, trim, log, has, isArray, inArray, isUnd, isNormal, isPosNumeric, isNonEmptyArray,
|
||||
pInt, pString, delegateRunOnDestroy, mailToHelper, windowResize
|
||||
pInt, pString, delegateRunOnDestroy, mailToHelper, windowResize, jassl
|
||||
} from 'Common/Utils';
|
||||
|
||||
import {
|
||||
|
@ -241,33 +241,33 @@ class AppUser extends AbstractApp
|
|||
sTrashFolder = FolderStore.trashFolder(),
|
||||
sSpamFolder = FolderStore.spamFolder();
|
||||
|
||||
_.each(this.moveCache, (oItem) => {
|
||||
_.each(this.moveCache, (item) => {
|
||||
|
||||
var
|
||||
bSpam = sSpamFolder === oItem.To,
|
||||
bTrash = sTrashFolder === oItem.To,
|
||||
bHam = !bSpam && sSpamFolder === oItem.From && Cache.getFolderInboxName() === oItem.To;
|
||||
const
|
||||
isSpam = sSpamFolder === item.To,
|
||||
isTrash = sTrashFolder === item.To,
|
||||
isHam = !isSpam && sSpamFolder === item.From && Cache.getFolderInboxName() === item.To;
|
||||
|
||||
Remote.messagesMove(this.moveOrDeleteResponseHelper, oItem.From, oItem.To, oItem.Uid,
|
||||
bSpam ? 'SPAM' : (bHam ? 'HAM' : ''), bSpam || bTrash);
|
||||
Remote.messagesMove(this.moveOrDeleteResponseHelper, item.From, item.To, item.Uid,
|
||||
isSpam ? 'SPAM' : (isHam ? 'HAM' : ''), isSpam || isTrash);
|
||||
});
|
||||
|
||||
this.moveCache = {};
|
||||
}
|
||||
|
||||
messagesMoveHelper(sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForMove) {
|
||||
messagesMoveHelper(fromFolderFullNameRaw, toFolderFullNameRaw, uidsForMove) {
|
||||
|
||||
var sH = '$$' + sFromFolderFullNameRaw + '$$' + sToFolderFullNameRaw + '$$';
|
||||
if (!this.moveCache[sH])
|
||||
const hash = '$$' + fromFolderFullNameRaw + '$$' + toFolderFullNameRaw + '$$';
|
||||
if (!this.moveCache[hash])
|
||||
{
|
||||
this.moveCache[sH] = {
|
||||
From: sFromFolderFullNameRaw,
|
||||
To: sToFolderFullNameRaw,
|
||||
this.moveCache[hash] = {
|
||||
From: fromFolderFullNameRaw,
|
||||
To: toFolderFullNameRaw,
|
||||
Uid: []
|
||||
};
|
||||
}
|
||||
|
||||
this.moveCache[sH].Uid = _.union(this.moveCache[sH].Uid, aUidForMove);
|
||||
this.moveCache[hash].Uid = _.union(this.moveCache[hash].Uid, uidsForMove);
|
||||
this.messagesMoveTrigger();
|
||||
}
|
||||
|
||||
|
@ -451,20 +451,20 @@ class AppUser extends AbstractApp
|
|||
|
||||
if (PgpStore.capaOpenPGP())
|
||||
{
|
||||
var
|
||||
aKeys = [],
|
||||
oEmail = new EmailModel(),
|
||||
oOpenpgpKeyring = PgpStore.openpgpKeyring,
|
||||
oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.getAllKeys() : [];
|
||||
const
|
||||
keys = [],
|
||||
email = new EmailModel(),
|
||||
openpgpKeyring = PgpStore.openpgpKeyring,
|
||||
openpgpKeys = openpgpKeyring ? openpgpKeyring.getAllKeys() : [];
|
||||
|
||||
_.each(oOpenpgpKeys, (oItem, iIndex) => {
|
||||
_.each(openpgpKeys, (oItem, iIndex) => {
|
||||
if (oItem && oItem.primaryKey)
|
||||
{
|
||||
var
|
||||
const
|
||||
aEmails = [],
|
||||
aUsers = [],
|
||||
oPrimaryUser = oItem.getPrimaryUser(),
|
||||
sUser = (oPrimaryUser && oPrimaryUser.user) ? oPrimaryUser.user.userId.userid :
|
||||
primaryUser = oItem.getPrimaryUser(),
|
||||
user = (primaryUser && primaryUser.user) ? primaryUser.user.userId.userid :
|
||||
(oItem.users && oItem.users[0] ? oItem.users[0].userId.userid : '');
|
||||
|
||||
if (oItem.users)
|
||||
|
@ -472,11 +472,11 @@ class AppUser extends AbstractApp
|
|||
_.each(oItem.users, (item) => {
|
||||
if (item.userId)
|
||||
{
|
||||
oEmail.clear();
|
||||
oEmail.mailsoParse(item.userId.userid);
|
||||
if (oEmail.validate())
|
||||
email.clear();
|
||||
email.mailsoParse(item.userId.userid);
|
||||
if (email.validate())
|
||||
{
|
||||
aEmails.push(oEmail.email);
|
||||
aEmails.push(email.email);
|
||||
aUsers.push(item.userId.userid);
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ class AppUser extends AbstractApp
|
|||
|
||||
if (aEmails.length)
|
||||
{
|
||||
aKeys.push(new OpenPgpKeyModel(
|
||||
keys.push(new OpenPgpKeyModel(
|
||||
iIndex,
|
||||
oItem.primaryKey.getFingerprint(),
|
||||
oItem.primaryKey.getKeyId().toHex().toLowerCase(),
|
||||
|
@ -496,14 +496,14 @@ class AppUser extends AbstractApp
|
|||
aEmails,
|
||||
oItem.isPrivate(),
|
||||
oItem.armor(),
|
||||
sUser)
|
||||
user)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
delegateRunOnDestroy(PgpStore.openpgpkeys());
|
||||
PgpStore.openpgpkeys(aKeys);
|
||||
PgpStore.openpgpkeys(keys);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -549,10 +549,11 @@ class AppUser extends AbstractApp
|
|||
|
||||
if (StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
var
|
||||
const
|
||||
aCounts = {},
|
||||
sParentEmail = Settings.settingsGet('ParentEmail'),
|
||||
sAccountEmail = AccountStore.email();
|
||||
let
|
||||
sParentEmail = Settings.settingsGet('ParentEmail');
|
||||
|
||||
sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail;
|
||||
|
||||
|
@ -735,14 +736,15 @@ class AppUser extends AbstractApp
|
|||
const utc = Momentor.momentNowUnix();
|
||||
_.each(oData.Result.List, (oItem) => {
|
||||
|
||||
var
|
||||
sHash = Cache.getFolderHash(oItem.Folder),
|
||||
oFolder = Cache.getFolderFromCacheList(oItem.Folder),
|
||||
bUnreadCountChange = false;
|
||||
const
|
||||
hash = Cache.getFolderHash(oItem.Folder),
|
||||
folder = Cache.getFolderFromCacheList(oItem.Folder);
|
||||
let
|
||||
unreadCountChange = false;
|
||||
|
||||
if (oFolder)
|
||||
if (folder)
|
||||
{
|
||||
oFolder.interval = utc;
|
||||
folder.interval = utc;
|
||||
|
||||
if (oItem.Hash)
|
||||
{
|
||||
|
@ -751,39 +753,39 @@ class AppUser extends AbstractApp
|
|||
|
||||
if (isNormal(oItem.MessageCount))
|
||||
{
|
||||
oFolder.messageCountAll(oItem.MessageCount);
|
||||
folder.messageCountAll(oItem.MessageCount);
|
||||
}
|
||||
|
||||
if (isNormal(oItem.MessageUnseenCount))
|
||||
{
|
||||
if (pInt(oFolder.messageCountUnread()) !== pInt(oItem.MessageUnseenCount))
|
||||
if (pInt(folder.messageCountUnread()) !== pInt(oItem.MessageUnseenCount))
|
||||
{
|
||||
bUnreadCountChange = true;
|
||||
unreadCountChange = true;
|
||||
}
|
||||
|
||||
oFolder.messageCountUnread(oItem.MessageUnseenCount);
|
||||
folder.messageCountUnread(oItem.MessageUnseenCount);
|
||||
}
|
||||
|
||||
if (bUnreadCountChange)
|
||||
if (unreadCountChange)
|
||||
{
|
||||
Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw);
|
||||
Cache.clearMessageFlagsFromCacheByFolder(folder.fullNameRaw);
|
||||
}
|
||||
|
||||
if (oItem.Hash !== sHash || '' === sHash)
|
||||
if (oItem.Hash !== hash || '' === hash)
|
||||
{
|
||||
if (oFolder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
|
||||
if (folder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
|
||||
{
|
||||
this.reloadMessageList();
|
||||
}
|
||||
}
|
||||
else if (bUnreadCountChange)
|
||||
else if (unreadCountChange)
|
||||
{
|
||||
if (oFolder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
|
||||
if (folder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
|
||||
{
|
||||
const aList = MessageStore.messageList();
|
||||
if (isNonEmptyArray(aList))
|
||||
{
|
||||
this.folderInformation(oFolder.fullNameRaw, aList);
|
||||
this.folderInformation(folder.fullNameRaw, aList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -804,76 +806,76 @@ class AppUser extends AbstractApp
|
|||
* @param {string} sFolderFullNameRaw
|
||||
* @param {string|bool} mUid
|
||||
* @param {number} iSetAction
|
||||
* @param {Array=} aMessages = null
|
||||
* @param {Array=} messages = null
|
||||
*/
|
||||
messageListAction(sFolderFullNameRaw, mUid, iSetAction, aMessages) {
|
||||
messageListAction(sFolderFullNameRaw, mUid, iSetAction, messages) {
|
||||
|
||||
var
|
||||
oFolder = null,
|
||||
aRootUids = [],
|
||||
iAlreadyUnread = 0;
|
||||
let
|
||||
folder = null,
|
||||
alreadyUnread = 0,
|
||||
rootUids = [];
|
||||
|
||||
if (isUnd(aMessages))
|
||||
if (isUnd(messages) || !messages)
|
||||
{
|
||||
aMessages = MessageStore.messageListChecked();
|
||||
messages = MessageStore.messageListChecked();
|
||||
}
|
||||
|
||||
aRootUids = _.uniq(_.compact(_.map(aMessages, (oMessage) => (oMessage && oMessage.uid ? oMessage.uid : null))));
|
||||
rootUids = _.uniq(_.compact(_.map(messages, (oMessage) => (oMessage && oMessage.uid ? oMessage.uid : null))));
|
||||
|
||||
if ('' !== sFolderFullNameRaw && 0 < aRootUids.length)
|
||||
if ('' !== sFolderFullNameRaw && 0 < rootUids.length)
|
||||
{
|
||||
switch (iSetAction)
|
||||
{
|
||||
case MessageSetAction.SetSeen:
|
||||
|
||||
_.each(aRootUids, (sSubUid) => {
|
||||
iAlreadyUnread += Cache.storeMessageFlagsToCacheBySetAction(
|
||||
_.each(rootUids, (sSubUid) => {
|
||||
alreadyUnread += Cache.storeMessageFlagsToCacheBySetAction(
|
||||
sFolderFullNameRaw, sSubUid, iSetAction);
|
||||
});
|
||||
|
||||
oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (oFolder)
|
||||
folder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (folder)
|
||||
{
|
||||
oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread);
|
||||
folder.messageCountUnread(folder.messageCountUnread() - alreadyUnread);
|
||||
}
|
||||
|
||||
Remote.messageSetSeen(noop, sFolderFullNameRaw, aRootUids, true);
|
||||
Remote.messageSetSeen(noop, sFolderFullNameRaw, rootUids, true);
|
||||
break;
|
||||
|
||||
case MessageSetAction.UnsetSeen:
|
||||
|
||||
_.each(aRootUids, (sSubUid) => {
|
||||
iAlreadyUnread += Cache.storeMessageFlagsToCacheBySetAction(
|
||||
_.each(rootUids, (sSubUid) => {
|
||||
alreadyUnread += Cache.storeMessageFlagsToCacheBySetAction(
|
||||
sFolderFullNameRaw, sSubUid, iSetAction);
|
||||
});
|
||||
|
||||
oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (oFolder)
|
||||
folder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (folder)
|
||||
{
|
||||
oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread + aRootUids.length);
|
||||
folder.messageCountUnread(folder.messageCountUnread() - alreadyUnread + rootUids.length);
|
||||
}
|
||||
|
||||
Remote.messageSetSeen(noop, sFolderFullNameRaw, aRootUids, false);
|
||||
Remote.messageSetSeen(noop, sFolderFullNameRaw, rootUids, false);
|
||||
break;
|
||||
|
||||
case MessageSetAction.SetFlag:
|
||||
|
||||
_.each(aRootUids, (sSubUid) => {
|
||||
_.each(rootUids, (sSubUid) => {
|
||||
Cache.storeMessageFlagsToCacheBySetAction(
|
||||
sFolderFullNameRaw, sSubUid, iSetAction);
|
||||
});
|
||||
|
||||
Remote.messageSetFlagged(noop, sFolderFullNameRaw, aRootUids, true);
|
||||
Remote.messageSetFlagged(noop, sFolderFullNameRaw, rootUids, true);
|
||||
break;
|
||||
|
||||
case MessageSetAction.UnsetFlag:
|
||||
|
||||
_.each(aRootUids, (sSubUid) => {
|
||||
_.each(rootUids, (sSubUid) => {
|
||||
Cache.storeMessageFlagsToCacheBySetAction(
|
||||
sFolderFullNameRaw, sSubUid, iSetAction);
|
||||
});
|
||||
|
||||
Remote.messageSetFlagged(noop, sFolderFullNameRaw, aRootUids, false);
|
||||
Remote.messageSetFlagged(noop, sFolderFullNameRaw, rootUids, false);
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
|
@ -985,12 +987,13 @@ class AppUser extends AbstractApp
|
|||
|
||||
initHorizontalLayoutResizer(sClientSideKeyName) {
|
||||
|
||||
var
|
||||
iMinHeight = 200,
|
||||
iMaxHeight = 500,
|
||||
let
|
||||
oTop = null,
|
||||
oBottom = null,
|
||||
oBottom = null;
|
||||
|
||||
const
|
||||
minHeight = 200,
|
||||
maxHeight = 500,
|
||||
fSetHeight = (height) => {
|
||||
if (height)
|
||||
{
|
||||
|
@ -1009,9 +1012,7 @@ class AppUser extends AbstractApp
|
|||
fResizeCreateFunction = (event) => {
|
||||
if (event && event.target)
|
||||
{
|
||||
var oResizableHandle = $(event.target).find('.ui-resizable-handle');
|
||||
|
||||
oResizableHandle
|
||||
$(event.target).find('.ui-resizable-handle')
|
||||
.on('mousedown', () => {
|
||||
$html.addClass('rl-resizer');
|
||||
})
|
||||
|
@ -1043,8 +1044,8 @@ class AppUser extends AbstractApp
|
|||
|
||||
oOptions = {
|
||||
helper: 'ui-resizable-helper-h',
|
||||
minHeight: iMinHeight,
|
||||
maxHeight: iMaxHeight,
|
||||
minHeight: minHeight,
|
||||
maxHeight: maxHeight,
|
||||
handles: 's',
|
||||
create: fResizeCreateFunction,
|
||||
resize: fResizeResizeFunction,
|
||||
|
@ -1078,7 +1079,7 @@ class AppUser extends AbstractApp
|
|||
}
|
||||
|
||||
const iHeight = pInt(Local.get(sClientSideKeyName)) || 300;
|
||||
fSetHeight(iHeight > iMinHeight ? iHeight : iMinHeight);
|
||||
fSetHeight(iHeight > minHeight ? iHeight : minHeight);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1091,11 +1092,11 @@ class AppUser extends AbstractApp
|
|||
|
||||
initVerticalLayoutResizer(sClientSideKeyName) {
|
||||
|
||||
var
|
||||
iDisabledWidth = 60,
|
||||
iMinWidth = 155,
|
||||
oLeft = $('#rl-left'),
|
||||
oRight = $('#rl-right'),
|
||||
const
|
||||
disabledWidth = 60,
|
||||
minWidth = 155,
|
||||
lLeft = $('#rl-left'),
|
||||
right = $('#rl-right'),
|
||||
|
||||
mLeftWidth = Local.get(sClientSideKeyName) || null,
|
||||
|
||||
|
@ -1106,11 +1107,11 @@ class AppUser extends AbstractApp
|
|||
|
||||
$html.removeClass('rl-resizer');
|
||||
|
||||
oLeft.css({
|
||||
lLeft.css({
|
||||
width: '' + iWidth + 'px'
|
||||
});
|
||||
|
||||
oRight.css({
|
||||
right.css({
|
||||
left: '' + iWidth + 'px'
|
||||
});
|
||||
}
|
||||
|
@ -1119,14 +1120,14 @@ class AppUser extends AbstractApp
|
|||
fDisable = (bDisable) => {
|
||||
if (bDisable)
|
||||
{
|
||||
oLeft.resizable('disable');
|
||||
fSetWidth(iDisabledWidth);
|
||||
lLeft.resizable('disable');
|
||||
fSetWidth(disabledWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
oLeft.resizable('enable');
|
||||
var iWidth = pInt(Local.get(sClientSideKeyName)) || iMinWidth;
|
||||
fSetWidth(iWidth > iMinWidth ? iWidth : iMinWidth);
|
||||
lLeft.resizable('enable');
|
||||
const width = pInt(Local.get(sClientSideKeyName)) || minWidth;
|
||||
fSetWidth(width > minWidth ? width : minWidth);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1156,11 +1157,11 @@ class AppUser extends AbstractApp
|
|||
|
||||
leftPanelWidth(oObject.size.width);
|
||||
|
||||
oRight.css({
|
||||
right.css({
|
||||
left: '' + oObject.size.width + 'px'
|
||||
});
|
||||
|
||||
oLeft.css({
|
||||
lLeft.css({
|
||||
position: '',
|
||||
top: '',
|
||||
left: '',
|
||||
|
@ -1171,12 +1172,12 @@ class AppUser extends AbstractApp
|
|||
|
||||
if (null !== mLeftWidth)
|
||||
{
|
||||
fSetWidth(mLeftWidth > iMinWidth ? mLeftWidth : iMinWidth);
|
||||
fSetWidth(mLeftWidth > minWidth ? mLeftWidth : minWidth);
|
||||
}
|
||||
|
||||
oLeft.resizable({
|
||||
lLeft.resizable({
|
||||
helper: 'ui-resizable-helper-w',
|
||||
minWidth: iMinWidth,
|
||||
minWidth: minWidth,
|
||||
maxWidth: 350,
|
||||
handles: 'e',
|
||||
create: fResizeCreateFunction,
|
||||
|
@ -1229,7 +1230,7 @@ class AppUser extends AbstractApp
|
|||
setHash(Links.root(), true);
|
||||
routeOff();
|
||||
|
||||
_.defer(function() {
|
||||
_.defer(() => {
|
||||
window.location.href = customLoginLink;
|
||||
});
|
||||
}
|
||||
|
@ -1253,13 +1254,15 @@ class AppUser extends AbstractApp
|
|||
require('Stores/User/Account').populate();
|
||||
require('Stores/User/Contact').populate();
|
||||
|
||||
var
|
||||
sJsHash = Settings.appSettingsGet('jsHash'),
|
||||
sStartupUrl = pString(Settings.settingsGet('StartupUrl')),
|
||||
iContactsSyncInterval = pInt(Settings.settingsGet('ContactsSyncInterval')),
|
||||
bGoogle = Settings.settingsGet('AllowGoogleSocial'),
|
||||
bFacebook = Settings.settingsGet('AllowFacebookSocial'),
|
||||
bTwitter = Settings.settingsGet('AllowTwitterSocial');
|
||||
let
|
||||
contactsSyncInterval = pInt(Settings.settingsGet('ContactsSyncInterval'));
|
||||
|
||||
const
|
||||
jsHash = Settings.appSettingsGet('jsHash'),
|
||||
startupUrl = pString(Settings.settingsGet('StartupUrl')),
|
||||
allowGoogle = Settings.settingsGet('AllowGoogleSocial'),
|
||||
allowFacebook = Settings.settingsGet('AllowFacebookSocial'),
|
||||
allowTwitter = Settings.settingsGet('AllowTwitterSocial');
|
||||
|
||||
if (progressJs)
|
||||
{
|
||||
|
@ -1294,14 +1297,14 @@ class AppUser extends AbstractApp
|
|||
|
||||
if (value)
|
||||
{
|
||||
if ('' !== sStartupUrl)
|
||||
if ('' !== startupUrl)
|
||||
{
|
||||
routeOff();
|
||||
setHash(Links.root(sStartupUrl), true);
|
||||
setHash(Links.root(startupUrl), true);
|
||||
routeOn();
|
||||
}
|
||||
|
||||
if (window.jassl && window.crypto && window.crypto.getRandomValues && Settings.capa(Capa.OpenPGP))
|
||||
if (jassl && window.crypto && window.crypto.getRandomValues && Settings.capa(Capa.OpenPGP))
|
||||
{
|
||||
const openpgpCallback = (openpgp) => {
|
||||
|
||||
|
@ -1333,7 +1336,7 @@ class AppUser extends AbstractApp
|
|||
}
|
||||
else
|
||||
{
|
||||
window.jassl(Links.openPgpJs()).then(() => {
|
||||
jassl(Links.openPgpJs()).then(() => {
|
||||
if (window.openpgp)
|
||||
{
|
||||
openpgpCallback(window.openpgp);
|
||||
|
@ -1352,7 +1355,7 @@ class AppUser extends AbstractApp
|
|||
// false ? AboutUserScreen : null
|
||||
]);
|
||||
|
||||
if (bGoogle || bFacebook || bTwitter)
|
||||
if (allowGoogle || allowFacebook || allowTwitter)
|
||||
{
|
||||
this.socialUsers(true);
|
||||
}
|
||||
|
@ -1370,13 +1373,13 @@ class AppUser extends AbstractApp
|
|||
Events.sub('interval.15m', () => this.quota());
|
||||
Events.sub('interval.20m', () => this.foldersReload());
|
||||
|
||||
iContactsSyncInterval = 5 <= iContactsSyncInterval ? iContactsSyncInterval : 20;
|
||||
iContactsSyncInterval = 320 >= iContactsSyncInterval ? iContactsSyncInterval : 320;
|
||||
contactsSyncInterval = 5 <= contactsSyncInterval ? contactsSyncInterval : 20;
|
||||
contactsSyncInterval = 320 >= contactsSyncInterval ? contactsSyncInterval : 320;
|
||||
|
||||
_.delay(() => this.contactsSync(), 10000);
|
||||
_.delay(() => this.folderInformationMultiply(true), 2000);
|
||||
|
||||
window.setInterval(() => this.contactsSync(), iContactsSyncInterval * 60000 + 5000);
|
||||
window.setInterval(() => this.contactsSync(), contactsSyncInterval * 60000 + 5000);
|
||||
|
||||
this.accountsAndIdentities(true);
|
||||
|
||||
|
@ -1451,25 +1454,25 @@ class AppUser extends AbstractApp
|
|||
this.bootstartLoginScreen();
|
||||
}
|
||||
|
||||
if (bGoogle)
|
||||
if (allowGoogle)
|
||||
{
|
||||
window['rl_' + sJsHash + '_google_service'] = () => {
|
||||
window['rl_' + jsHash + '_google_service'] = () => {
|
||||
SocialStore.google.loading(true);
|
||||
this.socialUsers();
|
||||
};
|
||||
}
|
||||
|
||||
if (bFacebook)
|
||||
if (allowFacebook)
|
||||
{
|
||||
window['rl_' + sJsHash + '_facebook_service'] = () => {
|
||||
window['rl_' + jsHash + '_facebook_service'] = () => {
|
||||
SocialStore.facebook.loading(true);
|
||||
this.socialUsers();
|
||||
};
|
||||
}
|
||||
|
||||
if (bTwitter)
|
||||
if (allowTwitter)
|
||||
{
|
||||
window['rl_' + sJsHash + '_twitter_service'] = () => {
|
||||
window['rl_' + jsHash + '_twitter_service'] = () => {
|
||||
SocialStore.twitter.loading(true);
|
||||
this.socialUsers();
|
||||
};
|
||||
|
|
|
@ -39,7 +39,6 @@ class Audio
|
|||
if (this.supported)
|
||||
{
|
||||
$(this.player).on('ended error', () => this.stop());
|
||||
|
||||
Events.sub('audio.api.stop', () => this.stop());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
/* global RL_ES6 */
|
||||
|
||||
import window from 'window';
|
||||
import progressJs from 'progressJs';
|
||||
import Promise from 'Promise';
|
||||
|
||||
import STYLES_CSS from 'Styles/@Boot.css';
|
||||
import LAYOUT_HTML from 'Html/Layout.html';
|
||||
|
||||
import {jassl} from 'Common/Jassl';
|
||||
import {getHash, setHash, clearHash} from 'Storage/RainLoop';
|
||||
|
||||
let RL_APP_DATA_STORAGE = null;
|
||||
|
@ -64,7 +64,7 @@ class Q2 extends Q1 { constructor() { super() } }
|
|||
*/
|
||||
function getComputedStyle(id, name)
|
||||
{
|
||||
var element = window.document.getElementById(id);
|
||||
const element = window.document.getElementById(id);
|
||||
return element.currentStyle ? element.currentStyle[name] :
|
||||
(window.getComputedStyle ? window.getComputedStyle(element, null).getPropertyValue(name) : null);
|
||||
}
|
||||
|
@ -94,14 +94,11 @@ function includeLayout()
|
|||
{
|
||||
const app = window.document.getElementById('rl-app');
|
||||
|
||||
if (STYLES_CSS)
|
||||
{
|
||||
includeStyle(STYLES_CSS);
|
||||
}
|
||||
require('style-loader!Styles/@Boot.css');
|
||||
|
||||
if (app && LAYOUT_HTML)
|
||||
if (app)
|
||||
{
|
||||
app.innerHTML = LAYOUT_HTML.replace(/[\r\n\t]+/g, '');
|
||||
app.innerHTML = require('Html/Layout.html').replace(/[\r\n\t]+/g, '');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -223,7 +220,7 @@ function runApp()
|
|||
{
|
||||
const appData = window.__rlah_data();
|
||||
|
||||
if (window.jassl && progressJs && appData && appData.TemplatesLink && appData.LangLink &&
|
||||
if (jassl && progressJs && appData && appData.TemplatesLink && appData.LangLink &&
|
||||
appData.StaticLibJsLink && appData.StaticAppJsLink && appData.StaticAppJsNextLink && appData.StaticEditorJsLink)
|
||||
{
|
||||
const p = progressJs;
|
||||
|
@ -232,7 +229,7 @@ function runApp()
|
|||
p.start().set(5);
|
||||
|
||||
const
|
||||
libs = window.jassl(appData.StaticLibJsLink).then(() => {
|
||||
libs = jassl(appData.StaticLibJsLink).then(() => {
|
||||
if (window.$)
|
||||
{
|
||||
window.$('#rl-check').remove();
|
||||
|
@ -247,18 +244,18 @@ function runApp()
|
|||
}
|
||||
}),
|
||||
common = Promise.all([
|
||||
window.jassl(appData.TemplatesLink),
|
||||
window.jassl(appData.LangLink)
|
||||
jassl(appData.TemplatesLink),
|
||||
jassl(appData.LangLink)
|
||||
]);
|
||||
|
||||
Promise.all([libs, common])
|
||||
.then(() => {
|
||||
p.set(30);
|
||||
return window.jassl(useJsNextBundle ? appData.StaticAppJsNextLink : appData.StaticAppJsLink);
|
||||
return jassl(useJsNextBundle ? appData.StaticAppJsNextLink : appData.StaticAppJsLink);
|
||||
})
|
||||
.then(() => {
|
||||
p.set(50);
|
||||
return appData.PluginsLink ? window.jassl(appData.PluginsLink) : window.Promise.resolve();
|
||||
return appData.PluginsLink ? jassl(appData.PluginsLink) : window.Promise.resolve();
|
||||
})
|
||||
.then(() => {
|
||||
p.set(70);
|
||||
|
@ -268,7 +265,7 @@ function runApp()
|
|||
runMainBoot(true);
|
||||
throw e;
|
||||
})
|
||||
.then(() => window.jassl(appData.StaticEditorJsLink))
|
||||
.then(() => jassl(appData.StaticEditorJsLink))
|
||||
.then(() => {
|
||||
if (window.CKEDITOR && window.__initEditor) {
|
||||
window.__initEditor();
|
||||
|
@ -320,7 +317,7 @@ window.__runBoot = function() {
|
|||
window.document.location.replace('./?/NoCookie');
|
||||
}
|
||||
|
||||
const root = document.documentElement;
|
||||
const root = window.document.documentElement;
|
||||
if ('none' !== getComputedStyle('rl-check', 'display'))
|
||||
{
|
||||
root.className += ' no-css';
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
|
@ -167,9 +169,7 @@ let bAllowPdfPreview = !bMobileDevice;
|
|||
|
||||
if (bAllowPdfPreview && window.navigator && window.navigator.mimeTypes)
|
||||
{
|
||||
bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function(oType) {
|
||||
return oType && 'application/pdf' === oType.type;
|
||||
});
|
||||
bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, (type) => type && 'application/pdf' === type.type);
|
||||
|
||||
if (!bAllowPdfPreview)
|
||||
{
|
||||
|
@ -203,33 +203,29 @@ export const keyScopeReal = ko.observable(KeyState.All);
|
|||
export const keyScopeFake = ko.observable(KeyState.All);
|
||||
|
||||
export const keyScope = ko.computed({
|
||||
owner: this,
|
||||
read: () => keyScopeFake(),
|
||||
write: function(sValue) {
|
||||
write: (value) => {
|
||||
|
||||
if (KeyState.Menu !== sValue)
|
||||
if (KeyState.Menu !== value)
|
||||
{
|
||||
if (KeyState.Compose === sValue)
|
||||
if (KeyState.Compose === value)
|
||||
{
|
||||
// disableKeyFilter
|
||||
key.filter = function() {
|
||||
return useKeyboardShortcuts();
|
||||
};
|
||||
key.filter = () => useKeyboardShortcuts();
|
||||
}
|
||||
else
|
||||
{
|
||||
// restoreKeyFilter
|
||||
key.filter = function(event) {
|
||||
key.filter = (event) => {
|
||||
|
||||
if (useKeyboardShortcuts())
|
||||
{
|
||||
var
|
||||
oElement = event.target || event.srcElement,
|
||||
sTagName = oElement ? oElement.tagName : '';
|
||||
const
|
||||
el = event.target || event.srcElement,
|
||||
tagName = el ? el.tagName.toUpperCase() : '';
|
||||
|
||||
sTagName = sTagName.toUpperCase();
|
||||
return !('INPUT' === sTagName || 'SELECT' === sTagName || 'TEXTAREA' === sTagName ||
|
||||
(oElement && 'DIV' === sTagName && ('editorHtmlArea' === oElement.className || 'true' === '' + oElement.contentEditable))
|
||||
return !('INPUT' === tagName || 'SELECT' === tagName || 'TEXTAREA' === tagName ||
|
||||
(el && 'DIV' === tagName && ('editorHtmlArea' === el.className || 'true' === '' + el.contentEditable))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -237,24 +233,24 @@ export const keyScope = ko.computed({
|
|||
};
|
||||
}
|
||||
|
||||
keyScopeFake(sValue);
|
||||
keyScopeFake(value);
|
||||
if (dropdownVisibility())
|
||||
{
|
||||
sValue = KeyState.Menu;
|
||||
value = KeyState.Menu;
|
||||
}
|
||||
}
|
||||
|
||||
keyScopeReal(sValue);
|
||||
keyScopeReal(value);
|
||||
}
|
||||
});
|
||||
|
||||
keyScopeReal.subscribe(function(sValue) {
|
||||
keyScopeReal.subscribe((value) => {
|
||||
// window.console.log('keyScope=' + sValue); // DEBUG
|
||||
key.setScope(sValue);
|
||||
key.setScope(value);
|
||||
});
|
||||
|
||||
dropdownVisibility.subscribe(function(bValue) {
|
||||
if (bValue)
|
||||
dropdownVisibility.subscribe((value) => {
|
||||
if (value)
|
||||
{
|
||||
keyScope(KeyState.Menu);
|
||||
}
|
||||
|
|
|
@ -87,20 +87,11 @@ class HtmlEditor
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
* @returns {string}
|
||||
*/
|
||||
clearSignatureSigns(text) {
|
||||
return text.replace(/(\u200C|\u0002)/g, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean=} wrapIsHtml = false
|
||||
* @param {boolean=} clearSignatureSigns = false
|
||||
* @returns {string}
|
||||
*/
|
||||
getData(wrapIsHtml = false, clearSignatureSigns = false) {
|
||||
getData(wrapIsHtml = false) {
|
||||
|
||||
let result = '';
|
||||
if (this.editor)
|
||||
|
@ -119,11 +110,6 @@ class HtmlEditor
|
|||
}
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
if (clearSignatureSigns)
|
||||
{
|
||||
result = this.clearSignatureSigns(result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -131,11 +117,10 @@ class HtmlEditor
|
|||
|
||||
/**
|
||||
* @param {boolean=} wrapIsHtml = false
|
||||
* @param {boolean=} clearSignatureSigns = false
|
||||
* @returns {string}
|
||||
*/
|
||||
getDataWithHtmlMark(wrapIsHtml = false, clearSignatureSigns = false) {
|
||||
return (this.isHtml() ? ':HTML:' : '') + this.getData(wrapIsHtml, clearSignatureSigns);
|
||||
getDataWithHtmlMark(wrapIsHtml = false) {
|
||||
return (this.isHtml() ? ':HTML:' : '') + this.getData(wrapIsHtml);
|
||||
}
|
||||
|
||||
modeToggle(plain, resize) {
|
||||
|
@ -149,12 +134,9 @@ class HtmlEditor
|
|||
this.editor.setMode('wysiwyg');
|
||||
}
|
||||
}
|
||||
else
|
||||
else if ('wysiwyg' === this.editor.mode)
|
||||
{
|
||||
if ('wysiwyg' === this.editor.mode)
|
||||
{
|
||||
this.editor.setMode('plain');
|
||||
}
|
||||
this.editor.setMode('plain');
|
||||
}
|
||||
}
|
||||
catch (e) {} // eslint-disable-line no-empty
|
||||
|
@ -302,7 +284,7 @@ class HtmlEditor
|
|||
if (file && window.FileReader && event.data.dataTransfer.id &&
|
||||
file.type && file.type.match(/^image/i))
|
||||
{
|
||||
var
|
||||
const
|
||||
id = event.data.dataTransfer.id,
|
||||
imageId = `[img=${id}]`,
|
||||
reader = new window.FileReader();
|
||||
|
|
54
dev/Common/Jassl.js
Normal file
54
dev/Common/Jassl.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
|
||||
import window from 'window';
|
||||
import Promise from 'Promise';
|
||||
|
||||
// let rainloopCaches = window.caches && window.caches.open ? window.caches : null;
|
||||
|
||||
/**
|
||||
* @param {src} src
|
||||
* @param {boolean} async = false
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export function jassl(src, async = false) {
|
||||
|
||||
if (!Promise || !Promise.all)
|
||||
{
|
||||
throw new Error('Promises are not available your environment.');
|
||||
}
|
||||
|
||||
if (!src)
|
||||
{
|
||||
throw new Error('src should not be empty.');
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
const element = window.document.createElement('script');
|
||||
|
||||
element.onload = () => {
|
||||
resolve(src);
|
||||
};
|
||||
|
||||
element.onerror = () => {
|
||||
reject(new Error(src));
|
||||
};
|
||||
|
||||
element.async = true === async;
|
||||
element.src = src;
|
||||
|
||||
window.document.body.appendChild(element);
|
||||
})/* .then((s) => {
|
||||
|
||||
const found = s && rainloopCaches ? s.match(/rainloop\/v\/([^\/]+)\/static\//) : null;
|
||||
if (found && found[1])
|
||||
{
|
||||
rainloopCaches.open('rainloop-offline-' + found[1]).then(
|
||||
(cache) => cache.add(s)
|
||||
).catch(() => {
|
||||
rainloopCaches = null;
|
||||
});
|
||||
}
|
||||
|
||||
return s;
|
||||
})*/;
|
||||
}
|
|
@ -125,9 +125,10 @@ export function format(timeStampInUTC, formatStr)
|
|||
*/
|
||||
export function momentToNode(element)
|
||||
{
|
||||
var
|
||||
let
|
||||
key = '',
|
||||
time = 0,
|
||||
time = 0;
|
||||
const
|
||||
$el = $(element);
|
||||
|
||||
time = $el.data('moment-time');
|
||||
|
|
|
@ -159,14 +159,16 @@ class Selector
|
|||
|
||||
this.list.subscribe((aItems) => {
|
||||
|
||||
var
|
||||
oTemp = null,
|
||||
bGetNext = false,
|
||||
aUids = [],
|
||||
mNextFocused = mFocused,
|
||||
bChecked = false,
|
||||
bSelected = false,
|
||||
iLen = 0;
|
||||
let
|
||||
temp = null,
|
||||
getNext = false,
|
||||
isNextFocused = mFocused,
|
||||
isChecked = false,
|
||||
isSelected = false,
|
||||
len = 0;
|
||||
|
||||
const
|
||||
uids = [];
|
||||
|
||||
this.selectedItemUseCallback = false;
|
||||
|
||||
|
@ -175,37 +177,37 @@ class Selector
|
|||
|
||||
if (isArray(aItems))
|
||||
{
|
||||
iLen = aCheckedCache.length;
|
||||
len = aCheckedCache.length;
|
||||
|
||||
_.each(aItems, (oItem) => {
|
||||
_.each(aItems, (item) => {
|
||||
|
||||
var sUid = this.getItemUid(oItem);
|
||||
aUids.push(sUid);
|
||||
const uid = this.getItemUid(item);
|
||||
uids.push(uid);
|
||||
|
||||
if (null !== mFocused && mFocused === sUid)
|
||||
if (null !== mFocused && mFocused === uid)
|
||||
{
|
||||
this.focusedItem(oItem);
|
||||
this.focusedItem(item);
|
||||
mFocused = null;
|
||||
}
|
||||
|
||||
if (0 < iLen && -1 < inArray(sUid, aCheckedCache))
|
||||
if (0 < len && -1 < inArray(uid, aCheckedCache))
|
||||
{
|
||||
bChecked = true;
|
||||
oItem.checked(true);
|
||||
iLen -= 1;
|
||||
isChecked = true;
|
||||
item.checked(true);
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
if (!bChecked && null !== mSelected && mSelected === sUid)
|
||||
if (!isChecked && null !== mSelected && mSelected === uid)
|
||||
{
|
||||
bSelected = true;
|
||||
this.selectedItem(oItem);
|
||||
isSelected = true;
|
||||
this.selectedItem(item);
|
||||
mSelected = null;
|
||||
}
|
||||
});
|
||||
|
||||
this.selectedItemUseCallback = true;
|
||||
|
||||
if (!bChecked && !bSelected && this.autoSelect())
|
||||
if (!isChecked && !isSelected && this.autoSelect())
|
||||
{
|
||||
if (this.focusedItem())
|
||||
{
|
||||
|
@ -213,53 +215,53 @@ class Selector
|
|||
}
|
||||
else if (0 < aItems.length)
|
||||
{
|
||||
if (null !== mNextFocused)
|
||||
if (null !== isNextFocused)
|
||||
{
|
||||
bGetNext = false;
|
||||
mNextFocused = _.find(aCache, (sUid) => {
|
||||
if (bGetNext && -1 < inArray(sUid, aUids))
|
||||
getNext = false;
|
||||
isNextFocused = _.find(aCache, (sUid) => {
|
||||
if (getNext && -1 < inArray(sUid, uids))
|
||||
{
|
||||
return sUid;
|
||||
}
|
||||
else if (mNextFocused === sUid)
|
||||
else if (isNextFocused === sUid)
|
||||
{
|
||||
bGetNext = true;
|
||||
getNext = true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (mNextFocused)
|
||||
if (isNextFocused)
|
||||
{
|
||||
oTemp = _.find(aItems, (oItem) => mNextFocused === this.getItemUid(oItem));
|
||||
temp = _.find(aItems, (oItem) => isNextFocused === this.getItemUid(oItem));
|
||||
}
|
||||
}
|
||||
|
||||
this.selectedItem(oTemp || null);
|
||||
this.selectedItem(temp || null);
|
||||
this.focusedItem(this.selectedItem());
|
||||
}
|
||||
}
|
||||
|
||||
if ((0 !== this.iSelectNextHelper || 0 !== this.iFocusedNextHelper) && 0 < aItems.length && !this.focusedItem())
|
||||
{
|
||||
oTemp = null;
|
||||
temp = null;
|
||||
if (0 !== this.iFocusedNextHelper)
|
||||
{
|
||||
oTemp = aItems[-1 === this.iFocusedNextHelper ? aItems.length - 1 : 0] || null;
|
||||
temp = aItems[-1 === this.iFocusedNextHelper ? aItems.length - 1 : 0] || null;
|
||||
}
|
||||
|
||||
if (!oTemp && 0 !== this.iSelectNextHelper)
|
||||
if (!temp && 0 !== this.iSelectNextHelper)
|
||||
{
|
||||
oTemp = aItems[-1 === this.iSelectNextHelper ? aItems.length - 1 : 0] || null;
|
||||
temp = aItems[-1 === this.iSelectNextHelper ? aItems.length - 1 : 0] || null;
|
||||
}
|
||||
|
||||
if (oTemp)
|
||||
if (temp)
|
||||
{
|
||||
if (0 !== this.iSelectNextHelper)
|
||||
{
|
||||
this.selectedItem(oTemp || null);
|
||||
this.selectedItem(temp || null);
|
||||
}
|
||||
|
||||
this.focusedItem(oTemp || null);
|
||||
this.focusedItem(temp || null);
|
||||
|
||||
this.scrollToFocused();
|
||||
|
||||
|
@ -288,12 +290,9 @@ class Selector
|
|||
(this.oCallbacks.onItemSelect || noop)(item || null);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (item)
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
(this.oCallbacks.onItemSelect || noop)(item);
|
||||
}
|
||||
(this.oCallbacks.onItemSelect || noop)(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,62 +445,64 @@ class Selector
|
|||
*/
|
||||
newSelectPosition(iEventKeyCode, bShiftKey, bForceSelect) {
|
||||
|
||||
var
|
||||
iIndex = 0,
|
||||
iPageStep = 10,
|
||||
bNext = false,
|
||||
bStop = false,
|
||||
oResult = null,
|
||||
aList = this.list(),
|
||||
iListLen = aList ? aList.length : 0,
|
||||
oFocused = this.focusedItem();
|
||||
let
|
||||
index = 0,
|
||||
isNext = false,
|
||||
isStop = false,
|
||||
result = null;
|
||||
|
||||
if (0 < iListLen)
|
||||
const
|
||||
pageStep = 10,
|
||||
list = this.list(),
|
||||
listLen = list ? list.length : 0,
|
||||
focused = this.focusedItem();
|
||||
|
||||
if (0 < listLen)
|
||||
{
|
||||
if (!oFocused)
|
||||
if (!focused)
|
||||
{
|
||||
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Insert === iEventKeyCode ||
|
||||
EventKeyCode.Space === iEventKeyCode || EventKeyCode.Home === iEventKeyCode ||
|
||||
EventKeyCode.PageUp === iEventKeyCode)
|
||||
{
|
||||
oResult = aList[0];
|
||||
result = list[0];
|
||||
}
|
||||
else if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.End === iEventKeyCode ||
|
||||
EventKeyCode.PageDown === iEventKeyCode)
|
||||
{
|
||||
oResult = aList[aList.length - 1];
|
||||
result = list[list.length - 1];
|
||||
}
|
||||
}
|
||||
else if (oFocused)
|
||||
else if (focused)
|
||||
{
|
||||
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode ||
|
||||
EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||
{
|
||||
_.each(aList, (item) => {
|
||||
if (!bStop)
|
||||
_.each(list, (item) => {
|
||||
if (!isStop)
|
||||
{
|
||||
switch (iEventKeyCode)
|
||||
{
|
||||
case EventKeyCode.Up:
|
||||
if (oFocused === item)
|
||||
if (focused === item)
|
||||
{
|
||||
bStop = true;
|
||||
isStop = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
oResult = item;
|
||||
result = item;
|
||||
}
|
||||
break;
|
||||
case EventKeyCode.Down:
|
||||
case EventKeyCode.Insert:
|
||||
if (bNext)
|
||||
if (isNext)
|
||||
{
|
||||
oResult = item;
|
||||
bStop = true;
|
||||
result = item;
|
||||
isStop = true;
|
||||
}
|
||||
else if (oFocused === item)
|
||||
else if (focused === item)
|
||||
{
|
||||
bNext = true;
|
||||
isNext = true;
|
||||
}
|
||||
break;
|
||||
// no default
|
||||
|
@ -509,7 +510,7 @@ class Selector
|
|||
}
|
||||
});
|
||||
|
||||
if (!oResult && (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode))
|
||||
if (!result && (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode))
|
||||
{
|
||||
this.doUpUpOrDownDown(EventKeyCode.Up === iEventKeyCode);
|
||||
}
|
||||
|
@ -518,35 +519,35 @@ class Selector
|
|||
{
|
||||
if (EventKeyCode.Home === iEventKeyCode)
|
||||
{
|
||||
oResult = aList[0];
|
||||
result = list[0];
|
||||
}
|
||||
else if (EventKeyCode.End === iEventKeyCode)
|
||||
{
|
||||
oResult = aList[aList.length - 1];
|
||||
result = list[list.length - 1];
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.PageDown === iEventKeyCode)
|
||||
{
|
||||
for (; iIndex < iListLen; iIndex++)
|
||||
for (; index < listLen; index++)
|
||||
{
|
||||
if (oFocused === aList[iIndex])
|
||||
if (focused === list[index])
|
||||
{
|
||||
iIndex += iPageStep;
|
||||
iIndex = iListLen - 1 < iIndex ? iListLen - 1 : iIndex;
|
||||
oResult = aList[iIndex];
|
||||
index += pageStep;
|
||||
index = listLen - 1 < index ? listLen - 1 : index;
|
||||
result = list[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.PageUp === iEventKeyCode)
|
||||
{
|
||||
for (iIndex = iListLen; 0 <= iIndex; iIndex--)
|
||||
for (index = listLen; 0 <= index; index--)
|
||||
{
|
||||
if (oFocused === aList[iIndex])
|
||||
if (focused === list[index])
|
||||
{
|
||||
iIndex -= iPageStep;
|
||||
iIndex = 0 > iIndex ? 0 : iIndex;
|
||||
oResult = aList[iIndex];
|
||||
index -= pageStep;
|
||||
index = 0 > index ? 0 : index;
|
||||
result = list[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -554,45 +555,45 @@ class Selector
|
|||
}
|
||||
}
|
||||
|
||||
if (oResult)
|
||||
if (result)
|
||||
{
|
||||
this.focusedItem(oResult);
|
||||
this.focusedItem(result);
|
||||
|
||||
if (oFocused)
|
||||
if (focused)
|
||||
{
|
||||
if (bShiftKey)
|
||||
{
|
||||
if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode)
|
||||
{
|
||||
oFocused.checked(!oFocused.checked());
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
}
|
||||
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||
{
|
||||
oFocused.checked(!oFocused.checked());
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
}
|
||||
|
||||
if ((this.autoSelect() || !!bForceSelect) &&
|
||||
!this.isListChecked() && EventKeyCode.Space !== iEventKeyCode)
|
||||
{
|
||||
this.selectedItem(oResult);
|
||||
this.selectedItem(result);
|
||||
}
|
||||
|
||||
this.scrollToFocused();
|
||||
}
|
||||
else if (oFocused)
|
||||
else if (focused)
|
||||
{
|
||||
if (bShiftKey && (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode))
|
||||
{
|
||||
oFocused.checked(!oFocused.checked());
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||
{
|
||||
oFocused.checked(!oFocused.checked());
|
||||
focused.checked(!focused.checked());
|
||||
}
|
||||
|
||||
this.focusedItem(oFocused);
|
||||
this.focusedItem(focused);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import ko from 'ko';
|
|||
import {$win, $div, dropdownVisibility, data as GlobalsData} from 'Common/Globals';
|
||||
import {ComposeType, EventKeyCode, SaveSettingsStep, FolderType} from 'Common/Enums';
|
||||
import {Mime} from 'Common/Mime';
|
||||
import {jassl} from 'Common/Jassl';
|
||||
|
||||
import Autolinker from 'Autolinker';
|
||||
|
||||
|
@ -22,7 +23,7 @@ const noop = () => {}; // eslint-disable-line no-empty-function
|
|||
const noopTrue = () => true;
|
||||
const noopFalse = () => false;
|
||||
|
||||
export {trim, inArray, isArray, isObject, isFunc, isUnd, isNull, has, bind, noop, noopTrue, noopFalse};
|
||||
export {trim, inArray, isArray, isObject, isFunc, isUnd, isNull, has, bind, noop, noopTrue, noopFalse, jassl};
|
||||
|
||||
/**
|
||||
* @param {Function} func
|
||||
|
@ -490,7 +491,7 @@ export function killCtrlACtrlS(event)
|
|||
* @param {(Function|boolean|null)=} fCanExecute = true
|
||||
* @returns {Function}
|
||||
*/
|
||||
export function createCommand(context, fExecute, fCanExecute = true)
|
||||
export function createCommandLegacy(context, fExecute, fCanExecute = true)
|
||||
{
|
||||
let fResult = null;
|
||||
const fNonEmpty = (...args) => {
|
||||
|
@ -516,6 +517,16 @@ export function createCommand(context, fExecute, fCanExecute = true)
|
|||
return fResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} fExecute
|
||||
* @param {(Function|boolean|null)=} fCanExecute = true
|
||||
* @returns {Function}
|
||||
*/
|
||||
export function createCommand(fExecute, fCanExecute = true)
|
||||
{
|
||||
return createCommandLegacy(null, fExecute, fCanExecute);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} theme
|
||||
* @returns {string}
|
||||
|
@ -609,12 +620,13 @@ export function clearBqSwitcher(body)
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string} title
|
||||
* @param {object} messageData
|
||||
* @param {Object} body
|
||||
* @param {boolean} isHtml
|
||||
* @param {boolean} print
|
||||
* @returns {void}
|
||||
*/
|
||||
export function previewMessage(title, body, isHtml, print)
|
||||
export function previewMessage({title, subject, date, fromCreds, toCreds, toLabel}, body, isHtml, print)
|
||||
{
|
||||
const
|
||||
win = window.open(''),
|
||||
|
@ -626,81 +638,16 @@ export function previewMessage(title, body, isHtml, print)
|
|||
|
||||
const html = bodyClone ? bodyClone.html() : '';
|
||||
|
||||
title = encodeHtml(title);
|
||||
|
||||
doc.write(`<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="user-scalable=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="robots" content="noindex, nofollow, noodp" />
|
||||
<title>${title}</title>
|
||||
<style>
|
||||
html, body {
|
||||
background-color: #fff;
|
||||
font-size: 13px;
|
||||
font-family: arial, sans-serif;
|
||||
}
|
||||
|
||||
a {color: blue; text-decoration: underline}
|
||||
a:visited {color: #609}
|
||||
a:active {color: red}
|
||||
blockquote {border-left: 2px solid black; margin: 0; padding: 0px 10px}
|
||||
|
||||
pre {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
background: #fff;
|
||||
border: none;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
body.html pre {
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
body.plain {
|
||||
|
||||
padding: 15px;
|
||||
white-space: pre-wrap;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
}
|
||||
|
||||
body.plain pre {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
background: #fff;
|
||||
border: none;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
body.plain blockquote {
|
||||
border-left: 2px solid blue;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
body.plain blockquote blockquote {
|
||||
border-left: 2px solid green;
|
||||
color: green;
|
||||
}
|
||||
|
||||
body.plain blockquote blockquote blockquote {
|
||||
border-left: 2px solid red;
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="${bodyClass}">${html}</body>
|
||||
</html>`);
|
||||
doc.write(require('Html/PreviewMessage.html')
|
||||
.replace('{{title}}', encodeHtml(title))
|
||||
.replace('{{subject}}', encodeHtml(subject))
|
||||
.replace('{{date}}', encodeHtml(date))
|
||||
.replace('{{fromCreds}}', encodeHtml(fromCreds))
|
||||
.replace('{{toCreds}}', encodeHtml(toCreds))
|
||||
.replace('{{toLabel}}', encodeHtml(toLabel))
|
||||
.replace('{{bodyClass}}', bodyClass)
|
||||
.replace('{{html}}', html)
|
||||
);
|
||||
|
||||
doc.close();
|
||||
|
||||
|
@ -851,7 +798,6 @@ export function htmlToPlain(html)
|
|||
convertLinks = (...args) => (args && 1 < args.length ? trim(args[1]) : '');
|
||||
|
||||
text = html
|
||||
.replace(/\u0002([\s\S]*)\u0002/gm, '\u200C$1\u200C')
|
||||
.replace(/<p[^>]*><\/p>/gi, '')
|
||||
.replace(/<pre[^>]*>([\s\S\r\n\t]*)<\/pre>/gmi, convertPre)
|
||||
.replace(/[\s]+/gm, ' ')
|
||||
|
@ -1003,7 +949,6 @@ export function plainToHtml(plain, findEmailAndLinksInText = false)
|
|||
.replace(/>/g, '>').replace(/</g, '<')
|
||||
.replace(/~~~blockquote~~~[\s]*/g, '<blockquote>')
|
||||
.replace(/[\s]*~~~\/blockquote~~~/g, '</blockquote>')
|
||||
.replace(/\u200C([\s\S]*)\u200C/g, '\u0002$1\u0002')
|
||||
.replace(/\n/g, '<br />');
|
||||
|
||||
return findEmailAndLinksInText ? findEmailAndLinks(plain) : plain;
|
||||
|
@ -1520,7 +1465,7 @@ export function mimeContentType(fileName)
|
|||
*/
|
||||
export function resizeAndCrop(url, value, fCallback)
|
||||
{
|
||||
const img = new Image();
|
||||
const img = new window.Image();
|
||||
img.onload = function() {
|
||||
|
||||
let
|
||||
|
|
|
@ -29,15 +29,11 @@ class AbstractInput extends AbstractComponent
|
|||
this.classForTrigger = ko.observable('');
|
||||
|
||||
this.className = ko.computed(() => {
|
||||
|
||||
var
|
||||
const
|
||||
size = ko.unwrap(this.size),
|
||||
suffixValue = this.trigger ?
|
||||
' ' + trim('settings-saved-trigger-input ' + this.classForTrigger()) : '';
|
||||
|
||||
suffixValue = this.trigger ? ' ' + trim('settings-saved-trigger-input ' + this.classForTrigger()) : '';
|
||||
return (0 < size ? 'span' + size : '') + suffixValue;
|
||||
|
||||
}, this);
|
||||
});
|
||||
|
||||
if (!isUnd(params.width) && params.element)
|
||||
{
|
||||
|
|
10
dev/External/Opentip.js
vendored
10
dev/External/Opentip.js
vendored
|
@ -1,7 +1,9 @@
|
|||
|
||||
var
|
||||
window = require('window'),
|
||||
Opentip = window.Opentip;
|
||||
import window from 'window';
|
||||
|
||||
const Opentip = window.Opentip || {};
|
||||
|
||||
Opentip.styles = Opentip.styles || {};
|
||||
|
||||
Opentip.styles.rainloop = {
|
||||
|
||||
|
@ -41,4 +43,4 @@ Opentip.styles.rainloopErrorTip = {
|
|||
'className': 'rainloopErrorTip'
|
||||
};
|
||||
|
||||
module.exports = Opentip;
|
||||
export {Opentip, Opentip as default};
|
||||
|
|
1118
dev/External/ko.js
vendored
1118
dev/External/ko.js
vendored
File diff suppressed because it is too large
Load diff
7
dev/Helper/Apps/Admin.js
Normal file
7
dev/Helper/Apps/Admin.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
/**
|
||||
* @returns {AppAdmin}
|
||||
*/
|
||||
export function getApp() {
|
||||
return require('App/Admin').default;
|
||||
}
|
7
dev/Helper/Apps/User.js
Normal file
7
dev/Helper/Apps/User.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
|
||||
/**
|
||||
* @returns {AppUser}
|
||||
*/
|
||||
export function getApp() {
|
||||
return require('App/User').default;
|
||||
}
|
114
dev/Html/PreviewMessage.html
Normal file
114
dev/Html/PreviewMessage.html
Normal file
|
@ -0,0 +1,114 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="user-scalable=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="robots" content="noindex, nofollow, noodp" />
|
||||
<title>{{title}}</title>
|
||||
<style>
|
||||
html, body {
|
||||
background-color: #fff;
|
||||
font-size: 13px;
|
||||
font-family: arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
a {color: blue; text-decoration: underline}
|
||||
a:visited {color: #609}
|
||||
a:active {color: red}
|
||||
blockquote {border-left: 2px solid black; margin: 0; padding: 0px 10px}
|
||||
|
||||
pre {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
background: #fff;
|
||||
border: none;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.body-wrp {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.body-wrp.html pre {
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.body-wrp.plain {
|
||||
padding: 15px;
|
||||
white-space: pre-wrap;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
}
|
||||
|
||||
.body-wrp.plain pre {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
background: #fff;
|
||||
border: none;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.body-wrp.plain blockquote {
|
||||
border-left: 2px solid blue;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.body-wrp.plain blockquote blockquote {
|
||||
border-left: 2px solid green;
|
||||
color: green;
|
||||
}
|
||||
|
||||
.body-wrp.plain blockquote blockquote blockquote {
|
||||
border-left: 2px solid red;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.rl-previre-subject {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
padding: 15px;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.rl-previre-creds-from, .rl-previre-creds-to {
|
||||
font-size: 12px;
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
.rl-previre-creds-from {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.rl-previre-creds-to {
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.rl-previre-date {
|
||||
float: right;
|
||||
font-size: 12px;
|
||||
padding: 10px 15px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<div class="rl-previre-subject">{{subject}}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="rl-previre-date">{{date}}</div>
|
||||
<div class="rl-previre-creds-from">{{fromCreds}}</div>
|
||||
<div class="rl-previre-creds-to">{{toLabel}}: {{toCreds}}</div>
|
||||
</div>
|
||||
<div class="body-wrp {{bodyClass}}">{{html}}</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,123 +0,0 @@
|
|||
|
||||
var
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Globals = require('Common/Globals');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string=} sPosition = ''
|
||||
* @param {string=} sTemplate = ''
|
||||
*/
|
||||
function AbstractView(sPosition, sTemplate)
|
||||
{
|
||||
this.bDisabeCloseOnEsc = false;
|
||||
this.sPosition = Utils.pString(sPosition);
|
||||
this.sTemplate = Utils.pString(sTemplate);
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.None;
|
||||
this.sCurrentKeyScope = this.sDefaultKeyScope;
|
||||
|
||||
this.viewModelVisibility = ko.observable(false);
|
||||
this.modalVisibility = ko.observable(false).extend({'rateLimit': 0});
|
||||
|
||||
this.viewModelName = '';
|
||||
this.viewModelNames = [];
|
||||
this.viewModelDom = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
AbstractView.prototype.bDisabeCloseOnEsc = false;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
AbstractView.prototype.sPosition = '';
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
AbstractView.prototype.sTemplate = '';
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
AbstractView.prototype.sDefaultKeyScope = Enums.KeyState.None;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
AbstractView.prototype.sCurrentKeyScope = Enums.KeyState.None;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
AbstractView.prototype.viewModelName = '';
|
||||
|
||||
/**
|
||||
* @type {Array}
|
||||
*/
|
||||
AbstractView.prototype.viewModelNames = [];
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
AbstractView.prototype.viewModelDom = null;
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
AbstractView.prototype.viewModelTemplate = function()
|
||||
{
|
||||
return this.sTemplate;
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
AbstractView.prototype.viewModelPosition = function()
|
||||
{
|
||||
return this.sPosition;
|
||||
};
|
||||
|
||||
AbstractView.prototype.cancelCommand = Utils.noop;
|
||||
AbstractView.prototype.closeCommand = Utils.noop;
|
||||
|
||||
AbstractView.prototype.storeAndSetKeyScope = function()
|
||||
{
|
||||
this.sCurrentKeyScope = Globals.keyScope();
|
||||
Globals.keyScope(this.sDefaultKeyScope);
|
||||
};
|
||||
|
||||
AbstractView.prototype.restoreKeyScope = function()
|
||||
{
|
||||
Globals.keyScope(this.sCurrentKeyScope);
|
||||
};
|
||||
|
||||
AbstractView.prototype.registerPopupKeyDown = function()
|
||||
{
|
||||
var self = this;
|
||||
|
||||
Globals.$win.on('keydown', function(oEvent) {
|
||||
if (oEvent && self.modalVisibility && self.modalVisibility())
|
||||
{
|
||||
if (!this.bDisabeCloseOnEsc && Enums.EventKeyCode.Esc === oEvent.keyCode)
|
||||
{
|
||||
Utils.delegateRun(self, 'cancelCommand');
|
||||
return false;
|
||||
}
|
||||
else if (Enums.EventKeyCode.Backspace === oEvent.keyCode && !Utils.inFocus())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = AbstractView;
|
64
dev/Knoin/AbstractViewNext.js
Normal file
64
dev/Knoin/AbstractViewNext.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {delegateRun, inFocus} from 'Common/Utils';
|
||||
import {KeyState, EventKeyCode} from 'Common/Enums';
|
||||
import {$win, keyScope} from 'Common/Globals';
|
||||
|
||||
class AbstractViewNext
|
||||
{
|
||||
constructor() {
|
||||
this.bDisabeCloseOnEsc = false;
|
||||
this.sDefaultKeyScope = KeyState.None;
|
||||
this.sCurrentKeyScope = this.sDefaultKeyScope;
|
||||
|
||||
this.viewModelVisibility = ko.observable(false);
|
||||
this.modalVisibility = ko.observable(false).extend({rateLimit: 0});
|
||||
|
||||
this.viewModelName = '';
|
||||
this.viewModelNames = [];
|
||||
this.viewModelDom = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
storeAndSetKeyScope() {
|
||||
this.sCurrentKeyScope = keyScope();
|
||||
keyScope(this.sDefaultKeyScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
restoreKeyScope() {
|
||||
keyScope(this.sCurrentKeyScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
registerPopupKeyDown() {
|
||||
$win.on('keydown', (event) => {
|
||||
if (event && this.modalVisibility && this.modalVisibility())
|
||||
{
|
||||
if (!this.bDisabeCloseOnEsc && EventKeyCode.Esc === event.keyCode)
|
||||
{
|
||||
delegateRun(this, 'cancelCommand');
|
||||
return false;
|
||||
}
|
||||
else if (EventKeyCode.Backspace === event.keyCode && !inFocus())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
cancelCommand() {} // eslint-disable-line no-empty-function
|
||||
closeCommand() {} // eslint-disable-line no-empty-function
|
||||
}
|
||||
|
||||
export {AbstractViewNext, AbstractViewNext as default};
|
|
@ -9,7 +9,7 @@ import {runHook} from 'Common/Plugins';
|
|||
import {$html, aViewModels as VIEW_MODELS, popupVisibilityNames} from 'Common/Globals';
|
||||
|
||||
import {
|
||||
isFunc, isArray, isUnd, pString, log,
|
||||
isArray, isUnd, pString, log,
|
||||
createCommand, delegateRun, isNonEmptyArray
|
||||
} from 'Common/Utils';
|
||||
|
||||
|
@ -19,6 +19,13 @@ let
|
|||
|
||||
const SCREENS = {};
|
||||
|
||||
export const ViewType = {
|
||||
Popup: 'Popups',
|
||||
Left: 'Left',
|
||||
Right: 'Right',
|
||||
Center: 'Center'
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
|
@ -28,40 +35,6 @@ export function hideLoading()
|
|||
$('#rl-loading').hide().remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} context
|
||||
* @returns {void}
|
||||
*/
|
||||
export function constructorEnd(context)
|
||||
{
|
||||
if (isFunc(context.__constructor_end))
|
||||
{
|
||||
context.__constructor_end();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string|Array} name
|
||||
* @param {Function} ViewModelClass
|
||||
* @returns {void}
|
||||
*/
|
||||
export function extendAsViewModel(name, ViewModelClass)
|
||||
{
|
||||
if (ViewModelClass)
|
||||
{
|
||||
if (isArray(name))
|
||||
{
|
||||
ViewModelClass.__names = name;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewModelClass.__names = [name];
|
||||
}
|
||||
|
||||
ViewModelClass.__name = ViewModelClass.__names[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} SettingsViewModelClass
|
||||
* @param {string} template
|
||||
|
@ -161,8 +134,8 @@ export function buildViewModel(ViewModelClass, vmScreen)
|
|||
let vmDom = null;
|
||||
const
|
||||
vm = new ViewModelClass(vmScreen),
|
||||
position = vm.viewModelPosition(),
|
||||
vmPlace = $('#rl-content #rl-' + position.toLowerCase());
|
||||
position = ViewModelClass.__type || '',
|
||||
vmPlace = position ? $('#rl-content #rl-' + position.toLowerCase()) : null;
|
||||
|
||||
ViewModelClass.__builded = true;
|
||||
ViewModelClass.__vm = vm;
|
||||
|
@ -172,18 +145,20 @@ export function buildViewModel(ViewModelClass, vmScreen)
|
|||
|
||||
vm.viewModelName = ViewModelClass.__name;
|
||||
vm.viewModelNames = ViewModelClass.__names;
|
||||
vm.viewModelTemplateID = ViewModelClass.__templateID;
|
||||
vm.viewModelPosition = ViewModelClass.__type;
|
||||
|
||||
if (vmPlace && 1 === vmPlace.length)
|
||||
{
|
||||
vmDom = $('<div></div>').addClass('rl-view-model').addClass('RL-' + vm.viewModelTemplate()).hide();
|
||||
vmDom = $('<div></div>').addClass('rl-view-model').addClass('RL-' + vm.viewModelTemplateID).hide();
|
||||
vmDom.appendTo(vmPlace);
|
||||
|
||||
vm.viewModelDom = vmDom;
|
||||
ViewModelClass.__dom = vmDom;
|
||||
|
||||
if ('Popups' === position)
|
||||
if (ViewType.Popup === position)
|
||||
{
|
||||
vm.cancelCommand = vm.closeCommand = createCommand(vm, () => {
|
||||
vm.cancelCommand = vm.closeCommand = createCommand(() => {
|
||||
hideScreenPopup(ViewModelClass);
|
||||
});
|
||||
|
||||
|
@ -229,11 +204,11 @@ export function buildViewModel(ViewModelClass, vmScreen)
|
|||
|
||||
ko.applyBindingAccessorsToNode(vmDom[0], {
|
||||
translatorInit: true,
|
||||
template: () => ({name: vm.viewModelTemplate()})
|
||||
template: () => ({name: vm.viewModelTemplateID})
|
||||
}, vm);
|
||||
|
||||
delegateRun(vm, 'onBuild', [vmDom]);
|
||||
if (vm && 'Popups' === position)
|
||||
if (vm && ViewType.Popup === position)
|
||||
{
|
||||
vm.registerPopupKeyDown();
|
||||
}
|
||||
|
@ -273,6 +248,23 @@ export function showScreenPopup(ViewModelClassToShow, params = [])
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} ViewModelClassToShow
|
||||
* @returns {void}
|
||||
*/
|
||||
export function warmUpScreenPopup(ViewModelClassToShow)
|
||||
{
|
||||
if (ViewModelClassToShow)
|
||||
{
|
||||
buildViewModel(ViewModelClassToShow);
|
||||
|
||||
if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom)
|
||||
{
|
||||
delegateRun(ViewModelClassToShow.__vm, 'onWarmUp');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} ViewModelClassToShow
|
||||
* @returns {boolean}
|
||||
|
@ -345,7 +337,7 @@ export function screenOnRoute(screenName, subPart)
|
|||
if (isNonEmptyArray(currentScreen.viewModels()))
|
||||
{
|
||||
_.each(currentScreen.viewModels(), (ViewModelClass) => {
|
||||
if (ViewModelClass.__vm && ViewModelClass.__dom && 'Popups' !== ViewModelClass.__vm.viewModelPosition())
|
||||
if (ViewModelClass.__vm && ViewModelClass.__dom && ViewType.Popup !== ViewModelClass.__vm.viewModelPosition)
|
||||
{
|
||||
ViewModelClass.__dom.hide();
|
||||
ViewModelClass.__vm.viewModelVisibility(false);
|
||||
|
@ -380,7 +372,7 @@ export function screenOnRoute(screenName, subPart)
|
|||
{
|
||||
_.each(currentScreen.viewModels(), (ViewModelClass) => {
|
||||
|
||||
if (ViewModelClass.__vm && ViewModelClass.__dom && 'Popups' !== ViewModelClass.__vm.viewModelPosition())
|
||||
if (ViewModelClass.__vm && ViewModelClass.__dom && ViewType.Popup !== ViewModelClass.__vm.viewModelPosition)
|
||||
{
|
||||
delegateRun(ViewModelClass.__vm, 'onBeforeShow');
|
||||
|
||||
|
@ -486,3 +478,41 @@ export function setHash(hash, silence = false, replace = false)
|
|||
hasher.setHash(hash);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} params
|
||||
* @returns {void}
|
||||
*/
|
||||
function viewDecorator({name, type, templateID})
|
||||
{
|
||||
return (target) => {
|
||||
if (target)
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
if (isArray(name))
|
||||
{
|
||||
target.__names = name;
|
||||
}
|
||||
else
|
||||
{
|
||||
target.__names = [name];
|
||||
}
|
||||
|
||||
target.__name = target.__names[0];
|
||||
}
|
||||
|
||||
if (type)
|
||||
{
|
||||
target.__type = type;
|
||||
}
|
||||
|
||||
if (templateID)
|
||||
{
|
||||
target.__templateID = templateID;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export {viewDecorator, viewDecorator as view, viewDecorator as viewModel};
|
||||
|
|
|
@ -218,10 +218,10 @@ class EmailModel
|
|||
return false;
|
||||
}
|
||||
|
||||
var
|
||||
substr = function(str, start, len) {
|
||||
const
|
||||
substr = (str, start, len) => {
|
||||
str = pString(str);
|
||||
var end = str.length;
|
||||
let end = str.length;
|
||||
|
||||
if (0 > start)
|
||||
{
|
||||
|
@ -233,7 +233,7 @@ class EmailModel
|
|||
return start >= str.length || 0 > start || start > end ? false : str.slice(start, end);
|
||||
},
|
||||
|
||||
substrReplace = function(str, replace, start, length) {
|
||||
substrReplace = (str, replace, start, length) => {
|
||||
str = pString(str);
|
||||
if (0 > start)
|
||||
{
|
||||
|
@ -246,8 +246,9 @@ class EmailModel
|
|||
length = length + str.length - start;
|
||||
}
|
||||
return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length);
|
||||
},
|
||||
};
|
||||
|
||||
let
|
||||
$sName = '',
|
||||
$sEmail = '',
|
||||
$sComment = '',
|
||||
|
|
|
@ -190,9 +190,7 @@ class FilterModel extends AbstractModel
|
|||
Enabled: this.enabled() ? '1' : '0',
|
||||
Name: this.name(),
|
||||
ConditionsType: this.conditionsType(),
|
||||
Conditions: _.map(this.conditions(), function(oItem) {
|
||||
return oItem.toJson();
|
||||
}),
|
||||
Conditions: _.map(this.conditions(), (item) => item.toJson()),
|
||||
|
||||
ActionValue: this.actionValue(),
|
||||
ActionValueSecond: this.actionValueSecond(),
|
||||
|
@ -257,7 +255,8 @@ class FilterModel extends AbstractModel
|
|||
}
|
||||
|
||||
cloneSelf() {
|
||||
var filter = new FilterModel();
|
||||
|
||||
const filter = new FilterModel();
|
||||
|
||||
filter.id = this.id;
|
||||
|
||||
|
|
|
@ -19,30 +19,30 @@ class FilterConditionModel extends AbstractModel
|
|||
this.valueSecond = ko.observable('');
|
||||
this.valueSecond.error = ko.observable(false);
|
||||
|
||||
this.template = ko.computed(function() {
|
||||
this.template = ko.computed(() => {
|
||||
|
||||
var sTemplate = '';
|
||||
let template = '';
|
||||
switch (this.field())
|
||||
{
|
||||
case FilterConditionField.Size:
|
||||
sTemplate = 'SettingsFiltersConditionSize';
|
||||
template = 'SettingsFiltersConditionSize';
|
||||
break;
|
||||
case FilterConditionField.Header:
|
||||
sTemplate = 'SettingsFiltersConditionMore';
|
||||
template = 'SettingsFiltersConditionMore';
|
||||
break;
|
||||
default:
|
||||
sTemplate = 'SettingsFiltersConditionDefault';
|
||||
template = 'SettingsFiltersConditionDefault';
|
||||
break;
|
||||
}
|
||||
|
||||
return sTemplate;
|
||||
return template;
|
||||
|
||||
}, this);
|
||||
|
||||
this.field.subscribe(function() {
|
||||
this.field.subscribe(() => {
|
||||
this.value('');
|
||||
this.valueSecond('');
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.regDisposables([this.template]);
|
||||
}
|
||||
|
|
|
@ -64,9 +64,9 @@ class FolderModel extends AbstractModel
|
|||
|
||||
this.isInbox = ko.computed(() => FolderType.Inbox === this.type());
|
||||
|
||||
this.hasSubScribedSubfolders = ko.computed(function() {
|
||||
return !!_.find(this.subFolders(), (oFolder) => (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder());
|
||||
}, this);
|
||||
this.hasSubScribedSubfolders = ko.computed(
|
||||
() => !!_.find(this.subFolders(), (oFolder) => (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder())
|
||||
);
|
||||
|
||||
this.canBeEdited = ko.computed(() => FolderType.User === this.type() && this.existen && this.selectable);
|
||||
|
||||
|
@ -236,9 +236,9 @@ class FolderModel extends AbstractModel
|
|||
|
||||
this.hasUnreadMessages = ko.computed(() => 0 < this.messageCountUnread() && '' !== this.printableUnreadCount());
|
||||
|
||||
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(function() {
|
||||
return !!_.find(this.subFolders(), (folder) => folder.hasUnreadMessages() || folder.hasSubScribedUnreadMessagesSubfolders());
|
||||
}, this);
|
||||
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(
|
||||
() => !!_.find(this.subFolders(), (folder) => folder.hasUnreadMessages() || folder.hasSubScribedUnreadMessagesSubfolders())
|
||||
);
|
||||
|
||||
// subscribe
|
||||
this.name.subscribe((value) => {
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
import _ from '_';
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
import moment from 'moment';
|
||||
import classnames from 'classnames';
|
||||
|
||||
import {MessagePriority, SignedVerifyStatus} from 'Common/Enums';
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
import {
|
||||
pInt, inArray, isArray, isUnd, trim,
|
||||
|
@ -455,73 +458,24 @@ class MessageModel extends AbstractModel
|
|||
* @return string
|
||||
*/
|
||||
lineAsCss() {
|
||||
const result = [];
|
||||
if (this.deleted())
|
||||
{
|
||||
result.push('deleted');
|
||||
}
|
||||
if (this.deletedMark())
|
||||
{
|
||||
result.push('deleted-mark');
|
||||
}
|
||||
if (this.selected())
|
||||
{
|
||||
result.push('selected');
|
||||
}
|
||||
if (this.checked())
|
||||
{
|
||||
result.push('checked');
|
||||
}
|
||||
if (this.flagged())
|
||||
{
|
||||
result.push('flagged');
|
||||
}
|
||||
if (this.unseen())
|
||||
{
|
||||
result.push('unseen');
|
||||
}
|
||||
if (this.answered())
|
||||
{
|
||||
result.push('answered');
|
||||
}
|
||||
if (this.forwarded())
|
||||
{
|
||||
result.push('forwarded');
|
||||
}
|
||||
if (this.focused())
|
||||
{
|
||||
result.push('focused');
|
||||
}
|
||||
if (this.isImportant())
|
||||
{
|
||||
result.push('important');
|
||||
}
|
||||
if (this.hasAttachments())
|
||||
{
|
||||
result.push('withAttachments');
|
||||
}
|
||||
if (this.newForAnimation())
|
||||
{
|
||||
result.push('new');
|
||||
}
|
||||
if ('' === this.subject())
|
||||
{
|
||||
result.push('emptySubject');
|
||||
}
|
||||
// if (1 < this.threadsLen())
|
||||
// {
|
||||
// result.push('hasChildrenMessage');
|
||||
// }
|
||||
if (this.hasUnseenSubMessage())
|
||||
{
|
||||
result.push('hasUnseenSubMessage');
|
||||
}
|
||||
if (this.hasFlaggedSubMessage())
|
||||
{
|
||||
result.push('hasFlaggedSubMessage');
|
||||
}
|
||||
|
||||
return result.join(' ');
|
||||
return classnames({
|
||||
'deleted': this.deleted(),
|
||||
'deleted-mark': this.deletedMark(),
|
||||
'selected': this.selected(),
|
||||
'checked': this.checked(),
|
||||
'flagged': this.flagged(),
|
||||
'unseen': this.unseen(),
|
||||
'answered': this.answered(),
|
||||
'forwarded': this.forwarded(),
|
||||
'focused': this.focused(),
|
||||
'important': this.isImportant(),
|
||||
'withAttachments': this.hasAttachments(),
|
||||
'new': this.newForAnimation(),
|
||||
'emptySubject': '' === this.subject(),
|
||||
// 'hasChildrenMessage': 1 < this.threadsLen(),
|
||||
'hasUnseenSubMessage': this.hasUnseenSubMessage(),
|
||||
'hasFlaggedSubMessage': this.hasFlaggedSubMessage()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -680,7 +634,19 @@ class MessageModel extends AbstractModel
|
|||
*/
|
||||
viewPopupMessage(print = false) {
|
||||
this.showLazyExternalImagesInBody();
|
||||
previewMessage(this.subject(), this.body, this.isHtml(), print);
|
||||
|
||||
const
|
||||
timeStampInUTC = this.dateTimeStampInUTC() || 0,
|
||||
m = 0 < timeStampInUTC ? moment.unix(timeStampInUTC) : null;
|
||||
|
||||
previewMessage({
|
||||
title: this.subject(),
|
||||
subject: this.subject(),
|
||||
date: m ? m.format('LLL') : '',
|
||||
fromCreds: this.fromToLine(false),
|
||||
toLabel: i18n('MESSAGE/LABEL_TO'),
|
||||
toCreds: this.toToLine(false)
|
||||
}, this.body, this.isHtml(), print);
|
||||
}
|
||||
|
||||
printMessage() {
|
||||
|
@ -770,7 +736,7 @@ class MessageModel extends AbstractModel
|
|||
if (this.body)
|
||||
{
|
||||
$('.lazy.lazy-inited[data-original]', this.body).each(function() {
|
||||
$(this).attr('src', $(this).attr('data-original')).removeAttr('data-original');
|
||||
$(this).attr('src', $(this).attr('data-original')).removeAttr('data-original'); // eslint-disable-line no-invalid-this
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -781,26 +747,28 @@ class MessageModel extends AbstractModel
|
|||
this.hasImages(false);
|
||||
this.body.data('rl-has-images', false);
|
||||
|
||||
var sAttr = this.proxy ? 'data-x-additional-src' : 'data-x-src';
|
||||
$('[' + sAttr + ']', this.body).each(function() {
|
||||
if (lazy && $(this).is('img'))
|
||||
let attr = this.proxy ? 'data-x-additional-src' : 'data-x-src';
|
||||
$('[' + attr + ']', this.body).each(function() {
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
if (lazy && $this.is('img'))
|
||||
{
|
||||
$(this)
|
||||
$this
|
||||
.addClass('lazy')
|
||||
.attr('data-original', $(this).attr(sAttr))
|
||||
.removeAttr(sAttr);
|
||||
.attr('data-original', $this.attr(attr))
|
||||
.removeAttr(attr);
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).attr('src', $(this).attr(sAttr)).removeAttr(sAttr);
|
||||
$this.attr('src', $this.attr(attr)).removeAttr(attr);
|
||||
}
|
||||
});
|
||||
|
||||
sAttr = this.proxy ? 'data-x-additional-style-url' : 'data-x-style-url';
|
||||
$('[' + sAttr + ']', this.body).each(function() {
|
||||
var sStyle = trim($(this).attr('style'));
|
||||
sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; ');
|
||||
$(this).attr('style', sStyle + $(this).attr(sAttr)).removeAttr(sAttr);
|
||||
attr = this.proxy ? 'data-x-additional-style-url' : 'data-x-style-url';
|
||||
$('[' + attr + ']', this.body).each(function() {
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
let style = trim($this.attr('style'));
|
||||
style = '' === style ? '' : (';' === style.substr(-1) ? style + ' ' : style + '; ');
|
||||
$this.attr('style', style + $this.attr(attr)).removeAttr(attr);
|
||||
});
|
||||
|
||||
if (lazy)
|
||||
|
@ -824,43 +792,47 @@ class MessageModel extends AbstractModel
|
|||
{
|
||||
this.body.data('rl-init-internal-images', true);
|
||||
|
||||
var self = this;
|
||||
const self = this;
|
||||
|
||||
$('[data-x-src-cid]', this.body).each(function() {
|
||||
const attachment = self.findAttachmentByCid($(this).attr('data-x-src-cid'));
|
||||
const
|
||||
$this = $(this), // eslint-disable-line no-invalid-this
|
||||
attachment = self.findAttachmentByCid($this.attr('data-x-src-cid'));
|
||||
|
||||
if (attachment && attachment.download)
|
||||
{
|
||||
if (lazy && $(this).is('img'))
|
||||
if (lazy && $this.is('img'))
|
||||
{
|
||||
$(this)
|
||||
$this
|
||||
.addClass('lazy')
|
||||
.attr('data-original', attachment.linkPreview());
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).attr('src', attachment.linkPreview());
|
||||
$this.attr('src', attachment.linkPreview());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-x-src-location]', this.body).each(function() {
|
||||
let attachment = self.findAttachmentByContentLocation($(this).attr('data-x-src-location'));
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
let attachment = self.findAttachmentByContentLocation($this.attr('data-x-src-location'));
|
||||
if (!attachment)
|
||||
{
|
||||
attachment = self.findAttachmentByCid($(this).attr('data-x-src-location'));
|
||||
attachment = self.findAttachmentByCid($this.attr('data-x-src-location'));
|
||||
}
|
||||
|
||||
if (attachment && attachment.download)
|
||||
{
|
||||
if (lazy && $(this).is('img'))
|
||||
if (lazy && $this.is('img'))
|
||||
{
|
||||
$(this)
|
||||
$this
|
||||
.addClass('lazy')
|
||||
.attr('data-original', attachment.linkPreview());
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).attr('src', attachment.linkPreview());
|
||||
$this.attr('src', attachment.linkPreview());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -869,16 +841,19 @@ class MessageModel extends AbstractModel
|
|||
let
|
||||
style = '',
|
||||
name = '';
|
||||
const attachment = self.findAttachmentByCid($(this).attr('data-x-style-cid'));
|
||||
|
||||
const
|
||||
$this = $(this), // eslint-disable-line no-invalid-this
|
||||
attachment = self.findAttachmentByCid($this.attr('data-x-style-cid'));
|
||||
|
||||
if (attachment && attachment.linkPreview)
|
||||
{
|
||||
name = $(this).attr('data-x-style-cid-name');
|
||||
name = $this.attr('data-x-style-cid-name');
|
||||
if ('' !== name)
|
||||
{
|
||||
style = trim($(this).attr('style'));
|
||||
style = trim($this.attr('style'));
|
||||
style = '' === style ? '' : (';' === style.substr(-1) ? style + ' ' : style + '; ');
|
||||
$(this).attr('style', style + name + ': url(\'' + attachment.linkPreview() + '\')');
|
||||
$this.attr('style', style + name + ': url(\'' + attachment.linkPreview() + '\')');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,223 +1,213 @@
|
|||
|
||||
var
|
||||
$ = require('$'),
|
||||
_ = require('_'),
|
||||
Promise = require('Promise'),
|
||||
import $ from '$';
|
||||
import Promise from 'Promise';
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
Plugins = require('Common/Plugins'),
|
||||
import {ajax} from 'Common/Links';
|
||||
import {microtime, isUnd, isNormal, pString, pInt, inArray} from 'Common/Utils';
|
||||
import {DEFAULT_AJAX_TIMEOUT, TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT} from 'Common/Consts';
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {data as GlobalsData} from 'Common/Globals';
|
||||
import * as Plugins from 'Common/Plugins';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
import {AbstractBasicPromises} from 'Promises/AbstractBasic';
|
||||
|
||||
AbstractBasicPromises = require('Promises/AbstractBasic');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AbstractAjaxPromises()
|
||||
class AbstractAjaxPromises extends AbstractBasicPromises
|
||||
{
|
||||
AbstractBasicPromises.call(this);
|
||||
|
||||
this.clear();
|
||||
}
|
||||
|
||||
_.extend(AbstractAjaxPromises.prototype, AbstractBasicPromises.prototype);
|
||||
|
||||
AbstractAjaxPromises.prototype.oRequests = {};
|
||||
|
||||
AbstractAjaxPromises.prototype.clear = function()
|
||||
{
|
||||
this.oRequests = {};
|
||||
};
|
||||
|
||||
AbstractAjaxPromises.prototype.abort = function(sAction, bClearOnly)
|
||||
{
|
||||
if (this.oRequests[sAction])
|
||||
{
|
||||
if (!bClearOnly && this.oRequests[sAction].abort)
|
||||
{
|
||||
this.oRequests[sAction].__aborted__ = true;
|
||||
this.oRequests[sAction].abort();
|
||||
}
|
||||
|
||||
this.oRequests[sAction] = null;
|
||||
delete this.oRequests[sAction];
|
||||
constructor() {
|
||||
super();
|
||||
this.oRequests = {};
|
||||
this.clear();
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
clear() {
|
||||
this.oRequests = {};
|
||||
}
|
||||
|
||||
AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut, oParameters, sAdditionalGetString, fTrigger)
|
||||
{
|
||||
var self = this;
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
||||
var iStart = Utils.microtime();
|
||||
|
||||
iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : Consts.DEFAULT_AJAX_TIMEOUT;
|
||||
sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString);
|
||||
|
||||
if (bPost)
|
||||
abort(sAction, bClearOnly) {
|
||||
if (this.oRequests[sAction])
|
||||
{
|
||||
oParameters.XToken = Settings.appSettingsGet('token');
|
||||
if (!bClearOnly && this.oRequests[sAction].abort)
|
||||
{
|
||||
this.oRequests[sAction].__aborted__ = true;
|
||||
this.oRequests[sAction].abort();
|
||||
}
|
||||
|
||||
this.oRequests[sAction] = null;
|
||||
delete this.oRequests[sAction];
|
||||
}
|
||||
|
||||
Plugins.runHook('ajax-default-request', [sAction, oParameters, sAdditionalGetString]);
|
||||
return this;
|
||||
}
|
||||
|
||||
self.setTrigger(fTrigger, true);
|
||||
ajaxRequest(action, isPost, timeOut, params, additionalGetString, fTrigger) {
|
||||
|
||||
var oH = $.ajax({
|
||||
type: bPost ? 'POST' : 'GET',
|
||||
url: Links.ajax(sAdditionalGetString),
|
||||
async: true,
|
||||
dataType: 'json',
|
||||
data: bPost ? (oParameters || {}) : {},
|
||||
timeout: iTimeOut,
|
||||
global: true
|
||||
}).always(function(oData, sTextStatus) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
var
|
||||
bCached = false,
|
||||
oErrorData = null;
|
||||
const start = microtime();
|
||||
|
||||
if (oData && oData.Time)
|
||||
timeOut = isNormal(timeOut) ? timeOut : DEFAULT_AJAX_TIMEOUT;
|
||||
additionalGetString = isUnd(additionalGetString) ? '' : pString(additionalGetString);
|
||||
|
||||
if (isPost)
|
||||
{
|
||||
bCached = Utils.pInt(oData.Time) > Utils.microtime() - iStart;
|
||||
params.XToken = Settings.appSettingsGet('token');
|
||||
}
|
||||
|
||||
// backward capability
|
||||
var sType = '';
|
||||
switch (true)
|
||||
{
|
||||
case 'success' === sTextStatus && oData && oData.Result && sAction === oData.Action:
|
||||
sType = Enums.StorageResultType.Success;
|
||||
break;
|
||||
case 'abort' === sTextStatus && (!oData || !oData.__aborted__):
|
||||
sType = Enums.StorageResultType.Abort;
|
||||
break;
|
||||
default:
|
||||
sType = Enums.StorageResultType.Error;
|
||||
break;
|
||||
}
|
||||
Plugins.runHook('ajax-default-request', [action, params, additionalGetString]);
|
||||
|
||||
Plugins.runHook('ajax-default-response', [sAction,
|
||||
Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oParameters]);
|
||||
this.setTrigger(fTrigger, true);
|
||||
|
||||
if ('success' === sTextStatus)
|
||||
{
|
||||
if (oData && oData.Result && sAction === oData.Action)
|
||||
const oH = $.ajax({
|
||||
type: isPost ? 'POST' : 'GET',
|
||||
url: ajax(additionalGetString),
|
||||
async: true,
|
||||
dataType: 'json',
|
||||
data: isPost ? (params || {}) : {},
|
||||
timeout: timeOut,
|
||||
global: true
|
||||
}).always((data, textStatus) => {
|
||||
|
||||
let
|
||||
isCached = false,
|
||||
errorData = null;
|
||||
|
||||
if (data && data.Time)
|
||||
{
|
||||
oData.__cached__ = bCached;
|
||||
resolve(oData);
|
||||
isCached = pInt(data.Time) > microtime() - start;
|
||||
}
|
||||
else if (oData && oData.Action)
|
||||
|
||||
// backward capability
|
||||
let type = '';
|
||||
switch (true)
|
||||
{
|
||||
oErrorData = oData;
|
||||
reject(oData.ErrorCode ? oData.ErrorCode : Enums.Notification.AjaxFalse);
|
||||
case 'success' === textStatus && data && data.Result && action === data.Action:
|
||||
type = StorageResultType.Success;
|
||||
break;
|
||||
case 'abort' === textStatus && (!data || !data.__aborted__):
|
||||
type = StorageResultType.Abort;
|
||||
break;
|
||||
default:
|
||||
type = StorageResultType.Error;
|
||||
break;
|
||||
}
|
||||
|
||||
Plugins.runHook('ajax-default-response', [
|
||||
action, StorageResultType.Success === type ? data : null, type, isCached, params
|
||||
]);
|
||||
|
||||
if ('success' === textStatus)
|
||||
{
|
||||
if (data && data.Result && action === data.Action)
|
||||
{
|
||||
data.__cached__ = isCached;
|
||||
resolve(data);
|
||||
}
|
||||
else if (data && data.Action)
|
||||
{
|
||||
errorData = data;
|
||||
reject(data.ErrorCode ? data.ErrorCode : Notification.AjaxFalse);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorData = data;
|
||||
reject(Notification.AjaxParse);
|
||||
}
|
||||
}
|
||||
else if ('timeout' === textStatus)
|
||||
{
|
||||
errorData = data;
|
||||
reject(Notification.AjaxTimeout);
|
||||
}
|
||||
else if ('abort' === textStatus)
|
||||
{
|
||||
if (!data || !data.__aborted__)
|
||||
{
|
||||
reject(Notification.AjaxAbort);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oErrorData = oData;
|
||||
reject(Enums.Notification.AjaxParse);
|
||||
}
|
||||
}
|
||||
else if ('timeout' === sTextStatus)
|
||||
{
|
||||
oErrorData = oData;
|
||||
reject(Enums.Notification.AjaxTimeout);
|
||||
}
|
||||
else if ('abort' === sTextStatus)
|
||||
{
|
||||
if (!oData || !oData.__aborted__)
|
||||
{
|
||||
reject(Enums.Notification.AjaxAbort);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oErrorData = oData;
|
||||
reject(Enums.Notification.AjaxParse);
|
||||
}
|
||||
|
||||
if (self.oRequests[sAction])
|
||||
{
|
||||
self.oRequests[sAction] = null;
|
||||
delete self.oRequests[sAction];
|
||||
}
|
||||
|
||||
self.setTrigger(fTrigger, false);
|
||||
|
||||
if (oErrorData)
|
||||
{
|
||||
if (-1 < Utils.inArray(oErrorData.ErrorCode, [
|
||||
Enums.Notification.AuthError, Enums.Notification.AccessError,
|
||||
Enums.Notification.ConnectionError, Enums.Notification.DomainNotAllowed, Enums.Notification.AccountNotAllowed,
|
||||
Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError
|
||||
]))
|
||||
{
|
||||
Globals.data.iAjaxErrorCount += 1;
|
||||
errorData = data;
|
||||
reject(Notification.AjaxParse);
|
||||
}
|
||||
|
||||
if (Enums.Notification.InvalidToken === oErrorData.ErrorCode)
|
||||
if (this.oRequests[action])
|
||||
{
|
||||
Globals.data.iTokenErrorCount += 1;
|
||||
this.oRequests[action] = null;
|
||||
delete this.oRequests[action];
|
||||
}
|
||||
|
||||
if (Consts.TOKEN_ERROR_LIMIT < Globals.data.iTokenErrorCount)
|
||||
this.setTrigger(fTrigger, false);
|
||||
|
||||
if (errorData)
|
||||
{
|
||||
if (Globals.data.__APP__ && Globals.data.__APP__.loginAndLogoutReload)
|
||||
if (-1 < inArray(errorData.ErrorCode, [
|
||||
Notification.AuthError, Notification.AccessError,
|
||||
Notification.ConnectionError, Notification.DomainNotAllowed, Notification.AccountNotAllowed,
|
||||
Notification.MailServerError, Notification.UnknownNotification, Notification.UnknownError
|
||||
]))
|
||||
{
|
||||
Globals.data.__APP__.loginAndLogoutReload(false, true);
|
||||
GlobalsData.iAjaxErrorCount += 1;
|
||||
}
|
||||
|
||||
if (Notification.InvalidToken === errorData.ErrorCode)
|
||||
{
|
||||
GlobalsData.iTokenErrorCount += 1;
|
||||
}
|
||||
|
||||
if (TOKEN_ERROR_LIMIT < GlobalsData.iTokenErrorCount)
|
||||
{
|
||||
if (GlobalsData.__APP__ && GlobalsData.__APP__.loginAndLogoutReload)
|
||||
{
|
||||
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (errorData.ClearAuth || errorData.Logout || AJAX_ERROR_LIMIT < GlobalsData.iAjaxErrorCount)
|
||||
{
|
||||
if (GlobalsData.__APP__ && GlobalsData.__APP__.clearClientSideToken)
|
||||
{
|
||||
GlobalsData.__APP__.clearClientSideToken();
|
||||
}
|
||||
|
||||
if (GlobalsData.__APP__ && !errorData.ClearAuth && GlobalsData.__APP__.loginAndLogoutReload)
|
||||
{
|
||||
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oErrorData.ClearAuth || oErrorData.Logout || Consts.AJAX_ERROR_LIMIT < Globals.data.iAjaxErrorCount)
|
||||
});
|
||||
|
||||
if (oH)
|
||||
{
|
||||
if (this.oRequests[action])
|
||||
{
|
||||
if (Globals.data.__APP__ && Globals.data.__APP__.clearClientSideToken)
|
||||
{
|
||||
Globals.data.__APP__.clearClientSideToken();
|
||||
}
|
||||
|
||||
if (Globals.data.__APP__ && !oErrorData.ClearAuth && Globals.data.__APP__.loginAndLogoutReload)
|
||||
{
|
||||
Globals.data.__APP__.loginAndLogoutReload(false, true);
|
||||
}
|
||||
this.oRequests[action] = null;
|
||||
delete this.oRequests[action];
|
||||
}
|
||||
}
|
||||
|
||||
this.oRequests[action] = oH;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (oH)
|
||||
{
|
||||
if (self.oRequests[sAction])
|
||||
{
|
||||
self.oRequests[sAction] = null;
|
||||
delete self.oRequests[sAction];
|
||||
}
|
||||
getRequest(sAction, fTrigger, sAdditionalGetString, iTimeOut) {
|
||||
|
||||
self.oRequests[sAction] = oH;
|
||||
}
|
||||
});
|
||||
};
|
||||
sAdditionalGetString = isUnd(sAdditionalGetString) ? '' : pString(sAdditionalGetString);
|
||||
sAdditionalGetString = sAction + '/' + sAdditionalGetString;
|
||||
|
||||
AbstractAjaxPromises.prototype.getRequest = function(sAction, fTrigger, sAdditionalGetString, iTimeOut)
|
||||
{
|
||||
sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString);
|
||||
sAdditionalGetString = sAction + '/' + sAdditionalGetString;
|
||||
return this.ajaxRequest(sAction, false, iTimeOut, null, sAdditionalGetString, fTrigger);
|
||||
}
|
||||
|
||||
return this.ajaxRequest(sAction, false, iTimeOut, null, sAdditionalGetString, fTrigger);
|
||||
};
|
||||
postRequest(action, fTrigger, params, timeOut) {
|
||||
|
||||
AbstractAjaxPromises.prototype.postRequest = function(action, fTrigger, params, timeOut)
|
||||
{
|
||||
params = params || {};
|
||||
params.Action = action;
|
||||
params = params || {};
|
||||
params.Action = action;
|
||||
|
||||
return this.ajaxRequest(action, true, timeOut, params, '', fTrigger);
|
||||
};
|
||||
return this.ajaxRequest(action, true, timeOut, params, '', fTrigger);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AbstractAjaxPromises;
|
||||
export {AbstractAjaxPromises, AbstractAjaxPromises as default};
|
||||
|
|
|
@ -1,45 +1,39 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
Promise = require('Promise'),
|
||||
import _ from '_';
|
||||
import Promise from 'Promise';
|
||||
import {isArray} from 'Common/Utils';
|
||||
|
||||
Utils = require('Common/Utils');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AbstractBasicPromises()
|
||||
class AbstractBasicPromises
|
||||
{
|
||||
this.oPromisesStack = {};
|
||||
constructor() {
|
||||
this.oPromisesStack = {};
|
||||
}
|
||||
|
||||
func(fFunc) {
|
||||
fFunc();
|
||||
return this;
|
||||
}
|
||||
|
||||
fastResolve(mData) {
|
||||
return Promise.resolve(mData);
|
||||
}
|
||||
|
||||
fastReject(mData) {
|
||||
return Promise.reject(mData);
|
||||
}
|
||||
|
||||
setTrigger(trigger, value) {
|
||||
if (trigger)
|
||||
{
|
||||
value = !!value;
|
||||
_.each(isArray(trigger) ? trigger : [trigger], (fTrigger) => {
|
||||
if (fTrigger)
|
||||
{
|
||||
fTrigger(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AbstractBasicPromises.prototype.func = function(fFunc)
|
||||
{
|
||||
fFunc();
|
||||
return this;
|
||||
};
|
||||
|
||||
AbstractBasicPromises.prototype.fastResolve = function(mData)
|
||||
{
|
||||
return Promise.resolve(mData);
|
||||
};
|
||||
|
||||
AbstractBasicPromises.prototype.fastReject = function(mData)
|
||||
{
|
||||
return Promise.reject(mData);
|
||||
};
|
||||
|
||||
AbstractBasicPromises.prototype.setTrigger = function(mTrigger, bValue)
|
||||
{
|
||||
if (mTrigger)
|
||||
{
|
||||
_.each(Utils.isArray(mTrigger) ? mTrigger : [mTrigger], function(fTrigger) {
|
||||
if (fTrigger)
|
||||
{
|
||||
fTrigger(!!bValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = AbstractBasicPromises;
|
||||
export {AbstractBasicPromises, AbstractBasicPromises as default};
|
||||
|
|
|
@ -1,78 +1,64 @@
|
|||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
import window from 'window';
|
||||
|
||||
PromisesPopulator = require('Promises/User/Populator'),
|
||||
AbstractAjaxPromises = require('Promises/AbstractAjax');
|
||||
import PromisesPopulator from 'Promises/User/Populator';
|
||||
import {AbstractAjaxPromises} from 'Promises/AbstractAjax';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractAjaxPromises
|
||||
*/
|
||||
function UserAjaxUserPromises()
|
||||
class UserAjaxUserPromises extends AbstractAjaxPromises
|
||||
{
|
||||
AbstractAjaxPromises.call(this);
|
||||
}
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
_.extend(UserAjaxUserPromises.prototype, AbstractAjaxPromises.prototype);
|
||||
this.foldersTimeout = 0;
|
||||
}
|
||||
|
||||
UserAjaxUserPromises.prototype.foldersReload = function(fTrigger)
|
||||
{
|
||||
return this.abort('Folders')
|
||||
.postRequest('Folders', fTrigger).then(function(oData) {
|
||||
PromisesPopulator.foldersList(oData.Result);
|
||||
PromisesPopulator.foldersAdditionalParameters(oData.Result);
|
||||
foldersReload(fTrigger) {
|
||||
return this.abort('Folders').postRequest('Folders', fTrigger).then((data) => {
|
||||
PromisesPopulator.foldersList(data.Result);
|
||||
PromisesPopulator.foldersAdditionalParameters(data.Result);
|
||||
return true;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
UserAjaxUserPromises.prototype.foldersTimeout = 0;
|
||||
UserAjaxUserPromises.prototype.foldersReloadWithTimeout = function(fTrigger)
|
||||
{
|
||||
this.setTrigger(fTrigger, true);
|
||||
foldersReloadWithTimeout(fTrigger) {
|
||||
this.setTrigger(fTrigger, true);
|
||||
|
||||
var self = this;
|
||||
window.clearTimeout(this.foldersTimeout);
|
||||
this.foldersTimeout = window.setTimeout(function() {
|
||||
self.foldersReload(fTrigger);
|
||||
}, 500);
|
||||
};
|
||||
window.clearTimeout(this.foldersTimeout);
|
||||
this.foldersTimeout = window.setTimeout(() => {
|
||||
this.foldersReload(fTrigger);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
UserAjaxUserPromises.prototype.folderDelete = function(sFolderFullNameRaw, fTrigger)
|
||||
{
|
||||
return this.postRequest('FolderDelete', fTrigger, {
|
||||
'Folder': sFolderFullNameRaw
|
||||
});
|
||||
};
|
||||
folderDelete(sFolderFullNameRaw, fTrigger) {
|
||||
return this.postRequest('FolderDelete', fTrigger, {
|
||||
'Folder': sFolderFullNameRaw
|
||||
});
|
||||
}
|
||||
|
||||
UserAjaxUserPromises.prototype.folderCreate = function(sNewFolderName, sParentName, fTrigger)
|
||||
{
|
||||
return this.postRequest('FolderCreate', fTrigger, {
|
||||
'Folder': sNewFolderName,
|
||||
'Parent': sParentName
|
||||
});
|
||||
};
|
||||
folderCreate(sNewFolderName, sParentName, fTrigger) {
|
||||
return this.postRequest('FolderCreate', fTrigger, {
|
||||
'Folder': sNewFolderName,
|
||||
'Parent': sParentName
|
||||
});
|
||||
}
|
||||
|
||||
UserAjaxUserPromises.prototype.folderRename = function(sPrevFolderFullNameRaw, sNewFolderName, fTrigger)
|
||||
{
|
||||
return this.postRequest('FolderRename', fTrigger, {
|
||||
'Folder': sPrevFolderFullNameRaw,
|
||||
'NewFolderName': sNewFolderName
|
||||
});
|
||||
};
|
||||
folderRename(sPrevFolderFullNameRaw, sNewFolderName, fTrigger) {
|
||||
return this.postRequest('FolderRename', fTrigger, {
|
||||
'Folder': sPrevFolderFullNameRaw,
|
||||
'NewFolderName': sNewFolderName
|
||||
});
|
||||
}
|
||||
|
||||
UserAjaxUserPromises.prototype.attachmentsActions = function(sAction, aHashes, fTrigger)
|
||||
{
|
||||
return this.postRequest('AttachmentsActions', fTrigger, {
|
||||
'Do': sAction,
|
||||
'Hashes': aHashes
|
||||
});
|
||||
};
|
||||
attachmentsActions(sAction, aHashes, fTrigger) {
|
||||
return this.postRequest('AttachmentsActions', fTrigger, {
|
||||
'Do': sAction,
|
||||
'Hashes': aHashes
|
||||
});
|
||||
}
|
||||
|
||||
UserAjaxUserPromises.prototype.welcomeClose = function()
|
||||
{
|
||||
return this.postRequest('WelcomeClose');
|
||||
};
|
||||
welcomeClose() {
|
||||
return this.postRequest('WelcomeClose');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new UserAjaxUserPromises();
|
||||
|
|
|
@ -1,197 +1,183 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
import _ from '_';
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Cache = require('Common/Cache'),
|
||||
import {UNUSED_OPTION_VALUE} from 'Common/Consts';
|
||||
import {isArray, isNormal, pInt, isUnd, noop} from 'Common/Utils';
|
||||
import {ClientSideKeyName, ServerFolderType} from 'Common/Enums';
|
||||
import * as Cache from 'Common/Cache';
|
||||
|
||||
AppStore = require('Stores/User/App'),
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
import * as Settings from 'Storage/Settings';
|
||||
import * as Local from 'Storage/Client';
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Local = require('Storage/Client'),
|
||||
import AppStore from 'Stores/User/App';
|
||||
import FolderStore from 'Stores/User/Folder';
|
||||
|
||||
FolderModel = require('Model/Folder').default,
|
||||
import {FolderModel} from 'Model/Folder';
|
||||
import {AbstractBasicPromises} from 'Promises/AbstractBasic';
|
||||
|
||||
AbstractBasicPromises = require('Promises/AbstractBasic');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PromisesUserPopulator()
|
||||
class PromisesUserPopulator extends AbstractBasicPromises
|
||||
{
|
||||
AbstractBasicPromises.call(this);
|
||||
}
|
||||
/**
|
||||
* @param {string} sFullNameHash
|
||||
* @param {Array?} expandedFolders
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isFolderExpanded(sFullNameHash, expandedFolders) {
|
||||
return expandedFolders && isArray(expandedFolders) && -1 !== _.indexOf(expandedFolders, sFullNameHash);
|
||||
}
|
||||
|
||||
_.extend(PromisesUserPopulator.prototype, AbstractBasicPromises.prototype);
|
||||
/**
|
||||
* @param {string} sFolderFullNameRaw
|
||||
* @returns {string}
|
||||
*/
|
||||
normalizeFolder(sFolderFullNameRaw) {
|
||||
return ('' === sFolderFullNameRaw || UNUSED_OPTION_VALUE === sFolderFullNameRaw ||
|
||||
null !== Cache.getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sFullNameHash
|
||||
* @param {Array?} expandedFolders
|
||||
* @returns {boolean}
|
||||
*/
|
||||
PromisesUserPopulator.prototype.isFolderExpanded = function(sFullNameHash, expandedFolders)
|
||||
{
|
||||
return expandedFolders && Utils.isArray(expandedFolders) && -1 !== _.indexOf(expandedFolders, sFullNameHash);
|
||||
};
|
||||
/**
|
||||
* @param {string} sNamespace
|
||||
* @param {Array} aFolders
|
||||
* @param {Array?} expandedFolders
|
||||
* @returns {Array}
|
||||
*/
|
||||
folderResponseParseRec(sNamespace, aFolders, expandedFolders) {
|
||||
|
||||
/**
|
||||
* @param {string} sFolderFullNameRaw
|
||||
* @returns {string}
|
||||
*/
|
||||
PromisesUserPopulator.prototype.normalizeFolder = function(sFolderFullNameRaw)
|
||||
{
|
||||
return ('' === sFolderFullNameRaw || Consts.UNUSED_OPTION_VALUE === sFolderFullNameRaw ||
|
||||
null !== Cache.getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : '';
|
||||
};
|
||||
const
|
||||
bDisplaySpecSetting = FolderStore.displaySpecSetting(),
|
||||
aList = [];
|
||||
|
||||
/**
|
||||
* @param {string} sNamespace
|
||||
* @param {Array} aFolders
|
||||
* @param {Array?} expandedFolders
|
||||
* @returns {Array}
|
||||
*/
|
||||
PromisesUserPopulator.prototype.folderResponseParseRec = function(sNamespace, aFolders, expandedFolders)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
bDisplaySpecSetting = FolderStore.displaySpecSetting(),
|
||||
aList = [];
|
||||
|
||||
_.each(aFolders, function(oFolder) {
|
||||
if (oFolder)
|
||||
{
|
||||
var oCacheFolder = Cache.getFolderFromCacheList(oFolder.FullNameRaw);
|
||||
if (!oCacheFolder)
|
||||
_.each(aFolders, (oFolder) => {
|
||||
if (oFolder)
|
||||
{
|
||||
oCacheFolder = FolderModel.newInstanceFromJson(oFolder);
|
||||
let oCacheFolder = Cache.getFolderFromCacheList(oFolder.FullNameRaw);
|
||||
if (!oCacheFolder)
|
||||
{
|
||||
oCacheFolder = FolderModel.newInstanceFromJson(oFolder);
|
||||
if (oCacheFolder)
|
||||
{
|
||||
Cache.setFolderToCacheList(oFolder.FullNameRaw, oCacheFolder);
|
||||
Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, oFolder.FullNameRaw, oCacheFolder);
|
||||
}
|
||||
}
|
||||
|
||||
if (oCacheFolder)
|
||||
{
|
||||
Cache.setFolderToCacheList(oFolder.FullNameRaw, oCacheFolder);
|
||||
Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, oFolder.FullNameRaw, oCacheFolder);
|
||||
if (bDisplaySpecSetting)
|
||||
{
|
||||
oCacheFolder.checkable(!!oFolder.Checkable);
|
||||
}
|
||||
else
|
||||
{
|
||||
oCacheFolder.checkable(true);
|
||||
}
|
||||
|
||||
oCacheFolder.collapsed(!this.isFolderExpanded(oCacheFolder.fullNameHash, expandedFolders));
|
||||
|
||||
if (oFolder.Extended)
|
||||
{
|
||||
if (oFolder.Extended.Hash)
|
||||
{
|
||||
Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash);
|
||||
}
|
||||
|
||||
if (isNormal(oFolder.Extended.MessageCount))
|
||||
{
|
||||
oCacheFolder.messageCountAll(oFolder.Extended.MessageCount);
|
||||
}
|
||||
|
||||
if (isNormal(oFolder.Extended.MessageUnseenCount))
|
||||
{
|
||||
oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount);
|
||||
}
|
||||
}
|
||||
|
||||
if (oFolder.SubFolders && 'Collection/FolderCollection' === oFolder.SubFolders['@Object'] &&
|
||||
oFolder.SubFolders['@Collection'] && isArray(oFolder.SubFolders['@Collection']))
|
||||
{
|
||||
oCacheFolder.subFolders(
|
||||
this.folderResponseParseRec(sNamespace, oFolder.SubFolders['@Collection'], expandedFolders));
|
||||
}
|
||||
|
||||
aList.push(oCacheFolder);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (oCacheFolder)
|
||||
return aList;
|
||||
}
|
||||
|
||||
foldersList(oData) {
|
||||
if (oData && 'Collection/FolderCollection' === oData['@Object'] &&
|
||||
oData['@Collection'] && isArray(oData['@Collection']))
|
||||
{
|
||||
const
|
||||
expandedFolders = Local.get(ClientSideKeyName.ExpandedFolders),
|
||||
cnt = pInt(oData.CountRec);
|
||||
|
||||
let limit = pInt(Settings.appSettingsGet('folderSpecLimit'));
|
||||
limit = 100 < limit ? 100 : (10 > limit ? 10 : limit);
|
||||
|
||||
FolderStore.displaySpecSetting(0 >= cnt || limit < cnt);
|
||||
|
||||
FolderStore.folderList(this.folderResponseParseRec(
|
||||
isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'], expandedFolders)); // @todo optimization required
|
||||
}
|
||||
}
|
||||
|
||||
foldersAdditionalParameters(oData) {
|
||||
if (oData && oData && 'Collection/FolderCollection' === oData['@Object'] &&
|
||||
oData['@Collection'] && isArray(oData['@Collection']))
|
||||
{
|
||||
if (!isUnd(oData.Namespace))
|
||||
{
|
||||
if (bDisplaySpecSetting)
|
||||
{
|
||||
oCacheFolder.checkable(!!oFolder.Checkable);
|
||||
}
|
||||
else
|
||||
{
|
||||
oCacheFolder.checkable(true);
|
||||
}
|
||||
|
||||
oCacheFolder.collapsed(!self.isFolderExpanded(oCacheFolder.fullNameHash, expandedFolders));
|
||||
|
||||
if (oFolder.Extended)
|
||||
{
|
||||
if (oFolder.Extended.Hash)
|
||||
{
|
||||
Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash);
|
||||
}
|
||||
|
||||
if (Utils.isNormal(oFolder.Extended.MessageCount))
|
||||
{
|
||||
oCacheFolder.messageCountAll(oFolder.Extended.MessageCount);
|
||||
}
|
||||
|
||||
if (Utils.isNormal(oFolder.Extended.MessageUnseenCount))
|
||||
{
|
||||
oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount);
|
||||
}
|
||||
}
|
||||
|
||||
if (oFolder.SubFolders && 'Collection/FolderCollection' === oFolder.SubFolders['@Object'] &&
|
||||
oFolder.SubFolders['@Collection'] && Utils.isArray(oFolder.SubFolders['@Collection']))
|
||||
{
|
||||
oCacheFolder.subFolders(
|
||||
self.folderResponseParseRec(sNamespace, oFolder.SubFolders['@Collection'], expandedFolders));
|
||||
}
|
||||
|
||||
aList.push(oCacheFolder);
|
||||
FolderStore.namespace = oData.Namespace;
|
||||
}
|
||||
|
||||
AppStore.threadsAllowed(!!Settings.appSettingsGet('useImapThread') && oData.IsThreadsSupported && true);
|
||||
|
||||
FolderStore.folderList.optimized(!!oData.Optimized);
|
||||
|
||||
let update = false;
|
||||
|
||||
if (oData.SystemFolders && '' === '' +
|
||||
Settings.settingsGet('SentFolder') +
|
||||
Settings.settingsGet('DraftFolder') +
|
||||
Settings.settingsGet('SpamFolder') +
|
||||
Settings.settingsGet('TrashFolder') +
|
||||
Settings.settingsGet('ArchiveFolder') +
|
||||
Settings.settingsGet('NullFolder'))
|
||||
{
|
||||
Settings.settingsSet('SentFolder', oData.SystemFolders[ServerFolderType.SENT] || null);
|
||||
Settings.settingsSet('DraftFolder', oData.SystemFolders[ServerFolderType.DRAFTS] || null);
|
||||
Settings.settingsSet('SpamFolder', oData.SystemFolders[ServerFolderType.JUNK] || null);
|
||||
Settings.settingsSet('TrashFolder', oData.SystemFolders[ServerFolderType.TRASH] || null);
|
||||
Settings.settingsSet('ArchiveFolder', oData.SystemFolders[ServerFolderType.ALL] || null);
|
||||
|
||||
update = true;
|
||||
}
|
||||
|
||||
FolderStore.sentFolder(this.normalizeFolder(Settings.settingsGet('SentFolder')));
|
||||
FolderStore.draftFolder(this.normalizeFolder(Settings.settingsGet('DraftFolder')));
|
||||
FolderStore.spamFolder(this.normalizeFolder(Settings.settingsGet('SpamFolder')));
|
||||
FolderStore.trashFolder(this.normalizeFolder(Settings.settingsGet('TrashFolder')));
|
||||
FolderStore.archiveFolder(this.normalizeFolder(Settings.settingsGet('ArchiveFolder')));
|
||||
|
||||
if (update)
|
||||
{
|
||||
require('Remote/User/Ajax').saveSystemFolders(noop, {
|
||||
SentFolder: FolderStore.sentFolder(),
|
||||
DraftFolder: FolderStore.draftFolder(),
|
||||
SpamFolder: FolderStore.spamFolder(),
|
||||
TrashFolder: FolderStore.trashFolder(),
|
||||
ArchiveFolder: FolderStore.archiveFolder(),
|
||||
NullFolder: 'NullFolder'
|
||||
});
|
||||
}
|
||||
|
||||
Local.set(ClientSideKeyName.FoldersLashHash, oData.FoldersHash);
|
||||
}
|
||||
});
|
||||
|
||||
return aList;
|
||||
};
|
||||
|
||||
PromisesUserPopulator.prototype.foldersList = function(oData)
|
||||
{
|
||||
if (oData && 'Collection/FolderCollection' === oData['@Object'] &&
|
||||
oData['@Collection'] && Utils.isArray(oData['@Collection']))
|
||||
{
|
||||
var
|
||||
expandedFolders = Local.get(Enums.ClientSideKeyName.ExpandedFolders),
|
||||
iLimit = Utils.pInt(Settings.appSettingsGet('folderSpecLimit')),
|
||||
iC = Utils.pInt(oData.CountRec);
|
||||
|
||||
iLimit = 100 < iLimit ? 100 : (10 > iLimit ? 10 : iLimit);
|
||||
|
||||
FolderStore.displaySpecSetting(0 >= iC || iLimit < iC);
|
||||
|
||||
FolderStore.folderList(this.folderResponseParseRec(
|
||||
Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'], expandedFolders)); // @todo optimization required
|
||||
}
|
||||
};
|
||||
|
||||
PromisesUserPopulator.prototype.foldersAdditionalParameters = function(oData)
|
||||
{
|
||||
if (oData && oData && 'Collection/FolderCollection' === oData['@Object'] &&
|
||||
oData['@Collection'] && Utils.isArray(oData['@Collection']))
|
||||
{
|
||||
if (!Utils.isUnd(oData.Namespace))
|
||||
{
|
||||
FolderStore.namespace = oData.Namespace;
|
||||
}
|
||||
|
||||
AppStore.threadsAllowed(!!Settings.appSettingsGet('useImapThread') && oData.IsThreadsSupported && true);
|
||||
|
||||
FolderStore.folderList.optimized(!!oData.Optimized);
|
||||
|
||||
var bUpdate = false;
|
||||
|
||||
if (oData.SystemFolders && '' === '' +
|
||||
Settings.settingsGet('SentFolder') +
|
||||
Settings.settingsGet('DraftFolder') +
|
||||
Settings.settingsGet('SpamFolder') +
|
||||
Settings.settingsGet('TrashFolder') +
|
||||
Settings.settingsGet('ArchiveFolder') +
|
||||
Settings.settingsGet('NullFolder'))
|
||||
{
|
||||
Settings.settingsSet('SentFolder', oData.SystemFolders[Enums.ServerFolderType.SENT] || null);
|
||||
Settings.settingsSet('DraftFolder', oData.SystemFolders[Enums.ServerFolderType.DRAFTS] || null);
|
||||
Settings.settingsSet('SpamFolder', oData.SystemFolders[Enums.ServerFolderType.JUNK] || null);
|
||||
Settings.settingsSet('TrashFolder', oData.SystemFolders[Enums.ServerFolderType.TRASH] || null);
|
||||
Settings.settingsSet('ArchiveFolder', oData.SystemFolders[Enums.ServerFolderType.ALL] || null);
|
||||
|
||||
bUpdate = true;
|
||||
}
|
||||
|
||||
FolderStore.sentFolder(this.normalizeFolder(Settings.settingsGet('SentFolder')));
|
||||
FolderStore.draftFolder(this.normalizeFolder(Settings.settingsGet('DraftFolder')));
|
||||
FolderStore.spamFolder(this.normalizeFolder(Settings.settingsGet('SpamFolder')));
|
||||
FolderStore.trashFolder(this.normalizeFolder(Settings.settingsGet('TrashFolder')));
|
||||
FolderStore.archiveFolder(this.normalizeFolder(Settings.settingsGet('ArchiveFolder')));
|
||||
|
||||
if (bUpdate)
|
||||
{
|
||||
require('Remote/User/Ajax').saveSystemFolders(Utils.noop, {
|
||||
SentFolder: FolderStore.sentFolder(),
|
||||
DraftFolder: FolderStore.draftFolder(),
|
||||
SpamFolder: FolderStore.spamFolder(),
|
||||
TrashFolder: FolderStore.trashFolder(),
|
||||
ArchiveFolder: FolderStore.archiveFolder(),
|
||||
NullFolder: 'NullFolder'
|
||||
});
|
||||
}
|
||||
|
||||
Local.set(Enums.ClientSideKeyName.FoldersLashHash, oData.FoldersHash);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = new PromisesUserPopulator();
|
||||
|
|
|
@ -1,301 +1,286 @@
|
|||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Plugins = require('Common/Plugins'),
|
||||
Links = require('Common/Links'),
|
||||
import {TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT, DEFAULT_AJAX_TIMEOUT} from 'Common/Consts';
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {inArray, pInt, pString, isUnd} from 'Common/Utils';
|
||||
import {data as GlobalsData} from 'Common/Globals';
|
||||
import {ajax} from 'Common/Links';
|
||||
import {runHook} from 'Common/Plugins';
|
||||
|
||||
Settings = require('Storage/Settings');
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AbstractAjaxRemote()
|
||||
class AbstractAjaxRemote
|
||||
{
|
||||
this.oRequests = {};
|
||||
}
|
||||
constructor() {
|
||||
this.oRequests = {};
|
||||
}
|
||||
|
||||
AbstractAjaxRemote.prototype.oRequests = {};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sRequestAction
|
||||
* @param {string} sType
|
||||
* @param {?AjaxJsonDefaultResponse} oData
|
||||
* @param {boolean} bCached
|
||||
* @param {*=} oRequestParameters
|
||||
*/
|
||||
AbstractAjaxRemote.prototype.defaultResponse = function(fCallback, sRequestAction, sType, oData, bCached, oRequestParameters)
|
||||
{
|
||||
var
|
||||
fCall = function() {
|
||||
if (Enums.StorageResultType.Success !== sType && Globals.data.bUnload)
|
||||
{
|
||||
sType = Enums.StorageResultType.Unload;
|
||||
}
|
||||
|
||||
if (Enums.StorageResultType.Success === sType && oData && !oData.Result)
|
||||
{
|
||||
if (oData && -1 < Utils.inArray(oData.ErrorCode, [
|
||||
Enums.Notification.AuthError, Enums.Notification.AccessError,
|
||||
Enums.Notification.ConnectionError, Enums.Notification.DomainNotAllowed, Enums.Notification.AccountNotAllowed,
|
||||
Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError
|
||||
]))
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sRequestAction
|
||||
* @param {string} sType
|
||||
* @param {?AjaxJsonDefaultResponse} oData
|
||||
* @param {boolean} bCached
|
||||
* @param {*=} oRequestParameters
|
||||
*/
|
||||
defaultResponse(fCallback, sRequestAction, sType, oData, bCached, oRequestParameters) {
|
||||
const
|
||||
fCall = () => {
|
||||
if (StorageResultType.Success !== sType && GlobalsData.bUnload)
|
||||
{
|
||||
Globals.data.iAjaxErrorCount += 1;
|
||||
sType = StorageResultType.Unload;
|
||||
}
|
||||
|
||||
if (oData && Enums.Notification.InvalidToken === oData.ErrorCode)
|
||||
if (StorageResultType.Success === sType && oData && !oData.Result)
|
||||
{
|
||||
Globals.data.iTokenErrorCount += 1;
|
||||
}
|
||||
|
||||
if (Consts.TOKEN_ERROR_LIMIT < Globals.data.iTokenErrorCount)
|
||||
{
|
||||
if (Globals.data.__APP__ && Globals.data.__APP__.loginAndLogoutReload)
|
||||
if (oData && -1 < inArray(oData.ErrorCode, [
|
||||
Notification.AuthError, Notification.AccessError,
|
||||
Notification.ConnectionError, Notification.DomainNotAllowed, Notification.AccountNotAllowed,
|
||||
Notification.MailServerError, Notification.UnknownNotification, Notification.UnknownError
|
||||
]))
|
||||
{
|
||||
Globals.data.__APP__.loginAndLogoutReload(false, true);
|
||||
GlobalsData.iAjaxErrorCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (oData.ClearAuth || oData.Logout || Consts.AJAX_ERROR_LIMIT < Globals.data.iAjaxErrorCount)
|
||||
{
|
||||
if (Globals.data.__APP__ && Globals.data.__APP__.clearClientSideToken)
|
||||
if (oData && Notification.InvalidToken === oData.ErrorCode)
|
||||
{
|
||||
Globals.data.__APP__.clearClientSideToken();
|
||||
GlobalsData.iTokenErrorCount += 1;
|
||||
}
|
||||
|
||||
if (!oData.ClearAuth && Globals.data.__APP__.loginAndLogoutReload)
|
||||
if (TOKEN_ERROR_LIMIT < GlobalsData.iTokenErrorCount)
|
||||
{
|
||||
if (GlobalsData.__APP__ && GlobalsData.__APP__.loginAndLogoutReload)
|
||||
{
|
||||
Globals.data.__APP__.loginAndLogoutReload(false, true);
|
||||
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (oData.ClearAuth || oData.Logout || AJAX_ERROR_LIMIT < GlobalsData.iAjaxErrorCount)
|
||||
{
|
||||
if (GlobalsData.__APP__ && GlobalsData.__APP__.clearClientSideToken)
|
||||
{
|
||||
GlobalsData.__APP__.clearClientSideToken();
|
||||
|
||||
if (!oData.ClearAuth && GlobalsData.__APP__.loginAndLogoutReload)
|
||||
{
|
||||
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Enums.StorageResultType.Success === sType && oData && oData.Result)
|
||||
{
|
||||
Globals.data.iAjaxErrorCount = 0;
|
||||
Globals.data.iTokenErrorCount = 0;
|
||||
}
|
||||
|
||||
Plugins.runHook('ajax-default-response', [sRequestAction, Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]);
|
||||
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback(
|
||||
sType,
|
||||
Enums.StorageResultType.Success === sType ? oData : null,
|
||||
bCached,
|
||||
sRequestAction,
|
||||
oRequestParameters
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
switch (sType)
|
||||
{
|
||||
case 'success':
|
||||
sType = Enums.StorageResultType.Success;
|
||||
break;
|
||||
case 'abort':
|
||||
sType = Enums.StorageResultType.Abort;
|
||||
break;
|
||||
default:
|
||||
sType = Enums.StorageResultType.Error;
|
||||
break;
|
||||
}
|
||||
|
||||
if (Enums.StorageResultType.Error === sType)
|
||||
{
|
||||
_.delay(fCall, 300);
|
||||
}
|
||||
else
|
||||
{
|
||||
fCall();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fResultCallback
|
||||
* @param {Object} oParameters
|
||||
* @param {?number=} iTimeOut = 20000
|
||||
* @param {string=} sGetAdd = ''
|
||||
* @param {Array=} aAbortActions = []
|
||||
* @returns {jQuery.jqXHR}
|
||||
*/
|
||||
AbstractAjaxRemote.prototype.ajaxRequest = function(fResultCallback, oParameters, iTimeOut, sGetAdd, aAbortActions)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
bPost = '' === sGetAdd,
|
||||
oHeaders = {},
|
||||
iStart = (new window.Date()).getTime(),
|
||||
sAction = '';
|
||||
|
||||
oParameters = oParameters || {};
|
||||
iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : 20000;
|
||||
sGetAdd = Utils.isUnd(sGetAdd) ? '' : Utils.pString(sGetAdd);
|
||||
aAbortActions = Utils.isArray(aAbortActions) ? aAbortActions : [];
|
||||
|
||||
sAction = oParameters.Action || '';
|
||||
|
||||
if (sAction && 0 < aAbortActions.length)
|
||||
{
|
||||
_.each(aAbortActions, function(sActionToAbort) {
|
||||
if (self.oRequests[sActionToAbort])
|
||||
{
|
||||
self.oRequests[sActionToAbort].__aborted = true;
|
||||
if (self.oRequests[sActionToAbort].abort)
|
||||
else if (StorageResultType.Success === sType && oData && oData.Result)
|
||||
{
|
||||
self.oRequests[sActionToAbort].abort();
|
||||
GlobalsData.iAjaxErrorCount = 0;
|
||||
GlobalsData.iTokenErrorCount = 0;
|
||||
}
|
||||
self.oRequests[sActionToAbort] = null;
|
||||
|
||||
runHook('ajax-default-response', [sRequestAction, StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]);
|
||||
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback(
|
||||
sType,
|
||||
StorageResultType.Success === sType ? oData : null,
|
||||
bCached,
|
||||
sRequestAction,
|
||||
oRequestParameters
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
switch (sType)
|
||||
{
|
||||
case 'success':
|
||||
sType = StorageResultType.Success;
|
||||
break;
|
||||
case 'abort':
|
||||
sType = StorageResultType.Abort;
|
||||
break;
|
||||
default:
|
||||
sType = StorageResultType.Error;
|
||||
break;
|
||||
}
|
||||
|
||||
if (StorageResultType.Error === sType)
|
||||
{
|
||||
_.delay(fCall, 300);
|
||||
}
|
||||
else
|
||||
{
|
||||
fCall();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fResultCallback
|
||||
* @param {Object} oParameters
|
||||
* @param {?number=} iTimeOut = 20000
|
||||
* @param {string=} sGetAdd = ''
|
||||
* @param {Array=} aAbortActions = []
|
||||
* @returns {jQuery.jqXHR}
|
||||
*/
|
||||
ajaxRequest(fResultCallback, params, iTimeOut = 20000, sGetAdd = '', abortActions = []) {
|
||||
const
|
||||
isPost = '' === sGetAdd,
|
||||
headers = {},
|
||||
start = (new window.Date()).getTime();
|
||||
|
||||
let
|
||||
action = '';
|
||||
|
||||
params = params || {};
|
||||
action = params.Action || '';
|
||||
|
||||
if (action && 0 < abortActions.length)
|
||||
{
|
||||
_.each(abortActions, (actionToAbort) => {
|
||||
if (this.oRequests[actionToAbort])
|
||||
{
|
||||
this.oRequests[actionToAbort].__aborted = true;
|
||||
if (this.oRequests[actionToAbort].abort)
|
||||
{
|
||||
this.oRequests[actionToAbort].abort();
|
||||
}
|
||||
this.oRequests[actionToAbort] = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (isPost)
|
||||
{
|
||||
params.XToken = Settings.appSettingsGet('token');
|
||||
}
|
||||
|
||||
const oDefAjax = $.ajax({
|
||||
type: isPost ? 'POST' : 'GET',
|
||||
url: ajax(sGetAdd),
|
||||
async: true,
|
||||
dataType: 'json',
|
||||
data: isPost ? params : {},
|
||||
headers: headers,
|
||||
timeout: iTimeOut,
|
||||
global: true
|
||||
});
|
||||
|
||||
oDefAjax.always((oData, sType) => {
|
||||
|
||||
let cached = false;
|
||||
if (oData && oData.Time)
|
||||
{
|
||||
cached = pInt(oData.Time) > (new window.Date()).getTime() - start;
|
||||
}
|
||||
|
||||
if (action && this.oRequests[action])
|
||||
{
|
||||
if (this.oRequests[action].__aborted)
|
||||
{
|
||||
sType = 'abort';
|
||||
}
|
||||
|
||||
this.oRequests[action] = null;
|
||||
}
|
||||
|
||||
this.defaultResponse(fResultCallback, action, sType, oData, cached, params);
|
||||
});
|
||||
|
||||
if (action && 0 < abortActions.length && -1 < inArray(action, abortActions))
|
||||
{
|
||||
if (this.oRequests[action])
|
||||
{
|
||||
this.oRequests[action].__aborted = true;
|
||||
if (this.oRequests[action].abort)
|
||||
{
|
||||
this.oRequests[action].abort();
|
||||
}
|
||||
this.oRequests[action] = null;
|
||||
}
|
||||
|
||||
this.oRequests[action] = oDefAjax;
|
||||
}
|
||||
|
||||
return oDefAjax;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sAction
|
||||
* @param {Object=} oParameters
|
||||
* @param {?number=} iTimeout
|
||||
* @param {string=} sGetAdd = ''
|
||||
* @param {Array=} aAbortActions = []
|
||||
*/
|
||||
defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions) {
|
||||
oParameters = oParameters || {};
|
||||
oParameters.Action = sAction;
|
||||
|
||||
sGetAdd = pString(sGetAdd);
|
||||
|
||||
runHook('ajax-default-request', [sAction, oParameters, sGetAdd]);
|
||||
|
||||
return this.ajaxRequest(fCallback, oParameters,
|
||||
isUnd(iTimeout) ? DEFAULT_AJAX_TIMEOUT : pInt(iTimeout), sGetAdd, aAbortActions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
noop(fCallback) {
|
||||
this.defaultRequest(fCallback, 'Noop');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sMessage
|
||||
* @param {string} sFileName
|
||||
* @param {number} iLineNo
|
||||
* @param {string} sLocation
|
||||
* @param {string} sHtmlCapa
|
||||
* @param {number} iTime
|
||||
*/
|
||||
jsError(fCallback, sMessage, sFileName, iLineNo, sLocation, sHtmlCapa, iTime) {
|
||||
this.defaultRequest(fCallback, 'JsError', {
|
||||
'Message': sMessage,
|
||||
'FileName': sFileName,
|
||||
'LineNo': iLineNo,
|
||||
'Location': sLocation,
|
||||
'HtmlCapa': sHtmlCapa,
|
||||
'TimeOnPage': iTime
|
||||
});
|
||||
}
|
||||
|
||||
if (bPost)
|
||||
{
|
||||
oParameters.XToken = Settings.appSettingsGet('token');
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sType
|
||||
* @param {Array=} mData = null
|
||||
* @param {boolean=} bIsError = false
|
||||
*/
|
||||
jsInfo(fCallback, sType, mData, bIsError = false) {
|
||||
this.defaultRequest(fCallback, 'JsInfo', {
|
||||
'Type': sType,
|
||||
'Data': mData,
|
||||
'IsError': bIsError ? '1' : '0'
|
||||
});
|
||||
}
|
||||
|
||||
var oDefAjax = $.ajax({
|
||||
type: bPost ? 'POST' : 'GET',
|
||||
url: Links.ajax(sGetAdd),
|
||||
async: true,
|
||||
dataType: 'json',
|
||||
data: bPost ? oParameters : {},
|
||||
headers: oHeaders,
|
||||
timeout: iTimeOut,
|
||||
global: true
|
||||
});
|
||||
|
||||
oDefAjax.always(function(oData, sType) {
|
||||
|
||||
var bCached = false;
|
||||
if (oData && oData.Time)
|
||||
{
|
||||
bCached = Utils.pInt(oData.Time) > (new window.Date()).getTime() - iStart;
|
||||
}
|
||||
|
||||
if (sAction && self.oRequests[sAction])
|
||||
{
|
||||
if (self.oRequests[sAction].__aborted)
|
||||
{
|
||||
sType = 'abort';
|
||||
}
|
||||
|
||||
self.oRequests[sAction] = null;
|
||||
}
|
||||
|
||||
self.defaultResponse(fResultCallback, sAction, sType, oData, bCached, oParameters);
|
||||
});
|
||||
|
||||
if (sAction && 0 < aAbortActions.length && -1 < Utils.inArray(sAction, aAbortActions))
|
||||
{
|
||||
if (this.oRequests[sAction])
|
||||
{
|
||||
this.oRequests[sAction].__aborted = true;
|
||||
if (this.oRequests[sAction].abort)
|
||||
{
|
||||
this.oRequests[sAction].abort();
|
||||
}
|
||||
this.oRequests[sAction] = null;
|
||||
}
|
||||
|
||||
this.oRequests[sAction] = oDefAjax;
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
getPublicKey(fCallback) {
|
||||
this.defaultRequest(fCallback, 'GetPublicKey');
|
||||
}
|
||||
|
||||
return oDefAjax;
|
||||
};
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sVersion
|
||||
*/
|
||||
jsVersion(fCallback, sVersion) {
|
||||
this.defaultRequest(fCallback, 'Version', {
|
||||
'Version': sVersion
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sAction
|
||||
* @param {Object=} oParameters
|
||||
* @param {?number=} iTimeout
|
||||
* @param {string=} sGetAdd = ''
|
||||
* @param {Array=} aAbortActions = []
|
||||
*/
|
||||
AbstractAjaxRemote.prototype.defaultRequest = function(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions)
|
||||
{
|
||||
oParameters = oParameters || {};
|
||||
oParameters.Action = sAction;
|
||||
|
||||
sGetAdd = Utils.pString(sGetAdd);
|
||||
|
||||
Plugins.runHook('ajax-default-request', [sAction, oParameters, sGetAdd]);
|
||||
|
||||
return this.ajaxRequest(fCallback, oParameters,
|
||||
Utils.isUnd(iTimeout) ? Consts.DEFAULT_AJAX_TIMEOUT : Utils.pInt(iTimeout), sGetAdd, aAbortActions);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
AbstractAjaxRemote.prototype.noop = function(fCallback)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'Noop');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sMessage
|
||||
* @param {string} sFileName
|
||||
* @param {number} iLineNo
|
||||
* @param {string} sLocation
|
||||
* @param {string} sHtmlCapa
|
||||
* @param {number} iTime
|
||||
*/
|
||||
AbstractAjaxRemote.prototype.jsError = function(fCallback, sMessage, sFileName, iLineNo, sLocation, sHtmlCapa, iTime)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'JsError', {
|
||||
'Message': sMessage,
|
||||
'FileName': sFileName,
|
||||
'LineNo': iLineNo,
|
||||
'Location': sLocation,
|
||||
'HtmlCapa': sHtmlCapa,
|
||||
'TimeOnPage': iTime
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sType
|
||||
* @param {Array=} mData = null
|
||||
* @param {boolean=} bIsError = false
|
||||
*/
|
||||
AbstractAjaxRemote.prototype.jsInfo = function(fCallback, sType, mData, bIsError)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'JsInfo', {
|
||||
'Type': sType,
|
||||
'Data': mData,
|
||||
'IsError': (Utils.isUnd(bIsError) ? false : !!bIsError) ? '1' : '0'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
AbstractAjaxRemote.prototype.getPublicKey = function(fCallback)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'GetPublicKey');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sVersion
|
||||
*/
|
||||
AbstractAjaxRemote.prototype.jsVersion = function(fCallback, sVersion)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'Version', {
|
||||
'Version': sVersion
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = AbstractAjaxRemote;
|
||||
export {AbstractAjaxRemote, AbstractAjaxRemote as default};
|
||||
|
|
|
@ -1,316 +1,282 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
import {AbstractAjaxRemote} from 'Remote/AbstractAjax';
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
AbstractAjaxRemote = require('Remote/AbstractAjax');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractAjaxRemote
|
||||
*/
|
||||
function RemoteAdminAjax()
|
||||
class RemoteAdminAjax extends AbstractAjaxRemote
|
||||
{
|
||||
AbstractAjaxRemote.call(this);
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.oRequests = {};
|
||||
this.oRequests = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sLogin
|
||||
* @param {string} sPassword
|
||||
*/
|
||||
adminLogin(fCallback, sLogin, sPassword) {
|
||||
this.defaultRequest(fCallback, 'AdminLogin', {
|
||||
'Login': sLogin,
|
||||
'Password': sPassword
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
adminLogout(fCallback) {
|
||||
this.defaultRequest(fCallback, 'AdminLogout');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {?} oData
|
||||
*/
|
||||
saveAdminConfig(fCallback, oData) {
|
||||
this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @param {?Function} valueFn
|
||||
* @param {?Function} fn
|
||||
*/
|
||||
saveAdminConfigHelper(key, valueFn, fn) {
|
||||
return (value) => {
|
||||
const data = {};
|
||||
data[key] = valueFn ? valueFn(value) : value;
|
||||
this.saveAdminConfig(fn || null, data);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {boolean=} bIncludeAliases = true
|
||||
*/
|
||||
domainList(fCallback, bIncludeAliases = true) {
|
||||
this.defaultRequest(fCallback, 'AdminDomainList', {
|
||||
'IncludeAliases': bIncludeAliases ? '1' : '0'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
pluginList(fCallback) {
|
||||
this.defaultRequest(fCallback, 'AdminPluginList');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
packagesList(fCallback) {
|
||||
this.defaultRequest(fCallback, 'AdminPackagesList');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
coreData(fCallback) {
|
||||
this.defaultRequest(fCallback, 'AdminCoreData');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
updateCoreData(fCallback) {
|
||||
this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Object} oPackage
|
||||
*/
|
||||
packageInstall(fCallback, oPackage) {
|
||||
this.defaultRequest(fCallback, 'AdminPackageInstall', {
|
||||
'Id': oPackage.id,
|
||||
'Type': oPackage.type,
|
||||
'File': oPackage.file
|
||||
}, 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Object} oPackage
|
||||
*/
|
||||
packageDelete(fCallback, oPackage) {
|
||||
this.defaultRequest(fCallback, 'AdminPackageDelete', {
|
||||
'Id': oPackage.id
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
*/
|
||||
domain(fCallback, sName) {
|
||||
this.defaultRequest(fCallback, 'AdminDomainLoad', {
|
||||
'Name': sName
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
*/
|
||||
plugin(fCallback, sName) {
|
||||
this.defaultRequest(fCallback, 'AdminPluginLoad', {
|
||||
'Name': sName
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
*/
|
||||
domainDelete(fCallback, sName) {
|
||||
this.defaultRequest(fCallback, 'AdminDomainDelete', {
|
||||
'Name': sName
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
* @param {boolean} bDisabled
|
||||
*/
|
||||
domainDisable(fCallback, sName, bDisabled) {
|
||||
return this.defaultRequest(fCallback, 'AdminDomainDisable', {
|
||||
Name: sName,
|
||||
Disabled: bDisabled ? '1' : '0'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Object} oConfig
|
||||
*/
|
||||
pluginSettingsUpdate(fCallback, oConfig) {
|
||||
return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {boolean} bForce
|
||||
*/
|
||||
licensing(fCallback, bForce) {
|
||||
return this.defaultRequest(fCallback, 'AdminLicensing', {
|
||||
Force: bForce ? '1' : '0'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sDomain
|
||||
* @param {string} sKey
|
||||
*/
|
||||
licensingActivate(fCallback, sDomain, sKey) {
|
||||
return this.defaultRequest(fCallback, 'AdminLicensingActivate', {
|
||||
Domain: sDomain,
|
||||
Key: sKey
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
* @param {boolean} bDisabled
|
||||
*/
|
||||
pluginDisable(fCallback, sName, bDisabled) {
|
||||
return this.defaultRequest(fCallback, 'AdminPluginDisable', {
|
||||
Name: sName,
|
||||
Disabled: bDisabled ? '1' : '0'
|
||||
});
|
||||
}
|
||||
|
||||
createDomainAlias(fCallback, sName, sAlias) {
|
||||
this.defaultRequest(fCallback, 'AdminDomainAliasSave', {
|
||||
Name: sName,
|
||||
Alias: sAlias
|
||||
});
|
||||
}
|
||||
|
||||
createOrUpdateDomain(fCallback,
|
||||
bCreate, sName,
|
||||
sIncHost, iIncPort, sIncSecure, bIncShortLogin,
|
||||
bUseSieve, sSieveAllowRaw, sSieveHost, iSievePort, sSieveSecure,
|
||||
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, bOutPhpMail,
|
||||
sWhiteList
|
||||
) {
|
||||
this.defaultRequest(fCallback, 'AdminDomainSave', {
|
||||
'Create': bCreate ? '1' : '0',
|
||||
'Name': sName,
|
||||
|
||||
'IncHost': sIncHost,
|
||||
'IncPort': iIncPort,
|
||||
'IncSecure': sIncSecure,
|
||||
'IncShortLogin': bIncShortLogin ? '1' : '0',
|
||||
|
||||
'UseSieve': bUseSieve ? '1' : '0',
|
||||
'SieveAllowRaw': sSieveAllowRaw ? '1' : '0',
|
||||
'SieveHost': sSieveHost,
|
||||
'SievePort': iSievePort,
|
||||
'SieveSecure': sSieveSecure,
|
||||
|
||||
'OutHost': sOutHost,
|
||||
'OutPort': iOutPort,
|
||||
'OutSecure': sOutSecure,
|
||||
'OutShortLogin': bOutShortLogin ? '1' : '0',
|
||||
'OutAuth': bOutAuth ? '1' : '0',
|
||||
'OutUsePhpMail': bOutPhpMail ? '1' : '0',
|
||||
|
||||
'WhiteList': sWhiteList
|
||||
});
|
||||
}
|
||||
|
||||
testConnectionForDomain(fCallback, sName,
|
||||
sIncHost, iIncPort, sIncSecure,
|
||||
bUseSieve, sSieveHost, iSievePort, sSieveSecure,
|
||||
sOutHost, iOutPort, sOutSecure, bOutAuth, bOutPhpMail
|
||||
) {
|
||||
this.defaultRequest(fCallback, 'AdminDomainTest', {
|
||||
'Name': sName,
|
||||
'IncHost': sIncHost,
|
||||
'IncPort': iIncPort,
|
||||
'IncSecure': sIncSecure,
|
||||
'UseSieve': bUseSieve ? '1' : '0',
|
||||
'SieveHost': sSieveHost,
|
||||
'SievePort': iSievePort,
|
||||
'SieveSecure': sSieveSecure,
|
||||
'OutHost': sOutHost,
|
||||
'OutPort': iOutPort,
|
||||
'OutSecure': sOutSecure,
|
||||
'OutAuth': bOutAuth ? '1' : '0',
|
||||
'OutUsePhpMail': bOutPhpMail ? '1' : '0'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {?} oData
|
||||
*/
|
||||
testContacts(fCallback, oData) {
|
||||
this.defaultRequest(fCallback, 'AdminContactsTest', oData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {?} oData
|
||||
*/
|
||||
saveNewAdminPassword(fCallback, oData) {
|
||||
this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
adminPing(fCallback) {
|
||||
this.defaultRequest(fCallback, 'AdminPing');
|
||||
}
|
||||
}
|
||||
|
||||
_.extend(RemoteAdminAjax.prototype, AbstractAjaxRemote.prototype);
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sLogin
|
||||
* @param {string} sPassword
|
||||
*/
|
||||
RemoteAdminAjax.prototype.adminLogin = function(fCallback, sLogin, sPassword)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminLogin', {
|
||||
'Login': sLogin,
|
||||
'Password': sPassword
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
RemoteAdminAjax.prototype.adminLogout = function(fCallback)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminLogout');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {?} oData
|
||||
*/
|
||||
RemoteAdminAjax.prototype.saveAdminConfig = function(fCallback, oData)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @param {?Function} valueFn
|
||||
* @param {?Function} fn
|
||||
*/
|
||||
RemoteAdminAjax.prototype.saveAdminConfigHelper = function(key, valueFn, fn)
|
||||
{
|
||||
var self = this;
|
||||
return function(value) {
|
||||
var data = {};
|
||||
data[key] = valueFn ? valueFn(value) : value;
|
||||
self.saveAdminConfig(fn || null, data);
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {boolean=} bIncludeAliases = true
|
||||
*/
|
||||
RemoteAdminAjax.prototype.domainList = function(fCallback, bIncludeAliases)
|
||||
{
|
||||
bIncludeAliases = Utils.isUnd(bIncludeAliases) ? true : bIncludeAliases;
|
||||
this.defaultRequest(fCallback, 'AdminDomainList', {
|
||||
'IncludeAliases': bIncludeAliases ? '1' : '0'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
RemoteAdminAjax.prototype.pluginList = function(fCallback)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminPluginList');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
RemoteAdminAjax.prototype.packagesList = function(fCallback)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminPackagesList');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
RemoteAdminAjax.prototype.coreData = function(fCallback)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminCoreData');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
RemoteAdminAjax.prototype.updateCoreData = function(fCallback)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Object} oPackage
|
||||
*/
|
||||
RemoteAdminAjax.prototype.packageInstall = function(fCallback, oPackage)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminPackageInstall', {
|
||||
'Id': oPackage.id,
|
||||
'Type': oPackage.type,
|
||||
'File': oPackage.file
|
||||
}, 60000);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Object} oPackage
|
||||
*/
|
||||
RemoteAdminAjax.prototype.packageDelete = function(fCallback, oPackage)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminPackageDelete', {
|
||||
'Id': oPackage.id
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
*/
|
||||
RemoteAdminAjax.prototype.domain = function(fCallback, sName)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminDomainLoad', {
|
||||
'Name': sName
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
*/
|
||||
RemoteAdminAjax.prototype.plugin = function(fCallback, sName)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminPluginLoad', {
|
||||
'Name': sName
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
*/
|
||||
RemoteAdminAjax.prototype.domainDelete = function(fCallback, sName)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminDomainDelete', {
|
||||
'Name': sName
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
* @param {boolean} bDisabled
|
||||
*/
|
||||
RemoteAdminAjax.prototype.domainDisable = function(fCallback, sName, bDisabled)
|
||||
{
|
||||
return this.defaultRequest(fCallback, 'AdminDomainDisable', {
|
||||
Name: sName,
|
||||
Disabled: bDisabled ? '1' : '0'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Object} oConfig
|
||||
*/
|
||||
RemoteAdminAjax.prototype.pluginSettingsUpdate = function(fCallback, oConfig)
|
||||
{
|
||||
return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {boolean} bForce
|
||||
*/
|
||||
RemoteAdminAjax.prototype.licensing = function(fCallback, bForce)
|
||||
{
|
||||
return this.defaultRequest(fCallback, 'AdminLicensing', {
|
||||
Force: bForce ? '1' : '0'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sDomain
|
||||
* @param {string} sKey
|
||||
*/
|
||||
RemoteAdminAjax.prototype.licensingActivate = function(fCallback, sDomain, sKey)
|
||||
{
|
||||
return this.defaultRequest(fCallback, 'AdminLicensingActivate', {
|
||||
Domain: sDomain,
|
||||
Key: sKey
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
* @param {boolean} bDisabled
|
||||
*/
|
||||
RemoteAdminAjax.prototype.pluginDisable = function(fCallback, sName, bDisabled)
|
||||
{
|
||||
return this.defaultRequest(fCallback, 'AdminPluginDisable', {
|
||||
Name: sName,
|
||||
Disabled: bDisabled ? '1' : '0'
|
||||
});
|
||||
};
|
||||
|
||||
RemoteAdminAjax.prototype.createDomainAlias = function(fCallback, sName, sAlias)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminDomainAliasSave', {
|
||||
Name: sName,
|
||||
Alias: sAlias
|
||||
});
|
||||
};
|
||||
|
||||
RemoteAdminAjax.prototype.createOrUpdateDomain = function(fCallback,
|
||||
bCreate, sName,
|
||||
sIncHost, iIncPort, sIncSecure, bIncShortLogin,
|
||||
bUseSieve, sSieveAllowRaw, sSieveHost, iSievePort, sSieveSecure,
|
||||
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, bOutPhpMail,
|
||||
sWhiteList)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminDomainSave', {
|
||||
'Create': bCreate ? '1' : '0',
|
||||
'Name': sName,
|
||||
|
||||
'IncHost': sIncHost,
|
||||
'IncPort': iIncPort,
|
||||
'IncSecure': sIncSecure,
|
||||
'IncShortLogin': bIncShortLogin ? '1' : '0',
|
||||
|
||||
'UseSieve': bUseSieve ? '1' : '0',
|
||||
'SieveAllowRaw': sSieveAllowRaw ? '1' : '0',
|
||||
'SieveHost': sSieveHost,
|
||||
'SievePort': iSievePort,
|
||||
'SieveSecure': sSieveSecure,
|
||||
|
||||
'OutHost': sOutHost,
|
||||
'OutPort': iOutPort,
|
||||
'OutSecure': sOutSecure,
|
||||
'OutShortLogin': bOutShortLogin ? '1' : '0',
|
||||
'OutAuth': bOutAuth ? '1' : '0',
|
||||
'OutUsePhpMail': bOutPhpMail ? '1' : '0',
|
||||
|
||||
'WhiteList': sWhiteList
|
||||
});
|
||||
};
|
||||
|
||||
RemoteAdminAjax.prototype.testConnectionForDomain = function(fCallback, sName,
|
||||
sIncHost, iIncPort, sIncSecure,
|
||||
bUseSieve, sSieveHost, iSievePort, sSieveSecure,
|
||||
sOutHost, iOutPort, sOutSecure, bOutAuth, bOutPhpMail)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminDomainTest', {
|
||||
'Name': sName,
|
||||
'IncHost': sIncHost,
|
||||
'IncPort': iIncPort,
|
||||
'IncSecure': sIncSecure,
|
||||
'UseSieve': bUseSieve ? '1' : '0',
|
||||
'SieveHost': sSieveHost,
|
||||
'SievePort': iSievePort,
|
||||
'SieveSecure': sSieveSecure,
|
||||
'OutHost': sOutHost,
|
||||
'OutPort': iOutPort,
|
||||
'OutSecure': sOutSecure,
|
||||
'OutAuth': bOutAuth ? '1' : '0',
|
||||
'OutUsePhpMail': bOutPhpMail ? '1' : '0'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {?} oData
|
||||
*/
|
||||
RemoteAdminAjax.prototype.testContacts = function(fCallback, oData)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminContactsTest', oData);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {?} oData
|
||||
*/
|
||||
RemoteAdminAjax.prototype.saveNewAdminPassword = function(fCallback, oData)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
RemoteAdminAjax.prototype.adminPing = function(fCallback)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'AdminPing');
|
||||
};
|
||||
|
||||
module.exports = new RemoteAdminAjax();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -37,16 +37,15 @@ class AbstractSettingsScreen extends AbstractScreen
|
|||
}
|
||||
}
|
||||
|
||||
onRoute(sSubName) {
|
||||
var
|
||||
self = this,
|
||||
oSettingsScreen = null,
|
||||
onRoute(subName) {
|
||||
let
|
||||
settingsScreen = null,
|
||||
RoutedSettingsViewModel = null,
|
||||
oViewModelPlace = null,
|
||||
oViewModelDom = null;
|
||||
viewModelPlace = null,
|
||||
viewModelDom = null;
|
||||
|
||||
RoutedSettingsViewModel = _.find(VIEW_MODELS.settings,
|
||||
(SettingsViewModel) => SettingsViewModel && SettingsViewModel.__rlSettingsData && sSubName === SettingsViewModel.__rlSettingsData.Route
|
||||
(SettingsViewModel) => SettingsViewModel && SettingsViewModel.__rlSettingsData && subName === SettingsViewModel.__rlSettingsData.Route
|
||||
);
|
||||
|
||||
if (RoutedSettingsViewModel)
|
||||
|
@ -67,32 +66,32 @@ class AbstractSettingsScreen extends AbstractScreen
|
|||
{
|
||||
if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
|
||||
{
|
||||
oSettingsScreen = RoutedSettingsViewModel.__vm;
|
||||
settingsScreen = RoutedSettingsViewModel.__vm;
|
||||
}
|
||||
else
|
||||
{
|
||||
oViewModelPlace = this.oViewModelPlace;
|
||||
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
||||
viewModelPlace = this.oViewModelPlace;
|
||||
if (viewModelPlace && 1 === viewModelPlace.length)
|
||||
{
|
||||
oSettingsScreen = new RoutedSettingsViewModel();
|
||||
settingsScreen = new RoutedSettingsViewModel();
|
||||
|
||||
oViewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
|
||||
oViewModelDom.appendTo(oViewModelPlace);
|
||||
viewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
|
||||
viewModelDom.appendTo(viewModelPlace);
|
||||
|
||||
oSettingsScreen.viewModelDom = oViewModelDom;
|
||||
settingsScreen.viewModelDom = viewModelDom;
|
||||
|
||||
oSettingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData;
|
||||
settingsScreen.__rlSettingsData = RoutedSettingsViewModel.__rlSettingsData;
|
||||
|
||||
RoutedSettingsViewModel.__dom = oViewModelDom;
|
||||
RoutedSettingsViewModel.__dom = viewModelDom;
|
||||
RoutedSettingsViewModel.__builded = true;
|
||||
RoutedSettingsViewModel.__vm = oSettingsScreen;
|
||||
RoutedSettingsViewModel.__vm = settingsScreen;
|
||||
|
||||
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
|
||||
ko.applyBindingAccessorsToNode(viewModelDom[0], {
|
||||
translatorInit: true,
|
||||
template: () => ({name: RoutedSettingsViewModel.__rlSettingsData.Template})
|
||||
}, oSettingsScreen);
|
||||
}, settingsScreen);
|
||||
|
||||
delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
|
||||
delegateRun(settingsScreen, 'onBuild', [viewModelDom]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -100,29 +99,29 @@ class AbstractSettingsScreen extends AbstractScreen
|
|||
}
|
||||
}
|
||||
|
||||
if (oSettingsScreen)
|
||||
if (settingsScreen)
|
||||
{
|
||||
_.defer(function() {
|
||||
_.defer(() => {
|
||||
// hide
|
||||
if (self.oCurrentSubScreen)
|
||||
if (this.oCurrentSubScreen)
|
||||
{
|
||||
delegateRun(self.oCurrentSubScreen, 'onHide');
|
||||
self.oCurrentSubScreen.viewModelDom.hide();
|
||||
delegateRun(this.oCurrentSubScreen, 'onHide');
|
||||
this.oCurrentSubScreen.viewModelDom.hide();
|
||||
}
|
||||
// --
|
||||
|
||||
self.oCurrentSubScreen = oSettingsScreen;
|
||||
this.oCurrentSubScreen = settingsScreen;
|
||||
|
||||
// show
|
||||
if (self.oCurrentSubScreen)
|
||||
if (this.oCurrentSubScreen)
|
||||
{
|
||||
delegateRun(self.oCurrentSubScreen, 'onBeforeShow');
|
||||
self.oCurrentSubScreen.viewModelDom.show();
|
||||
delegateRun(self.oCurrentSubScreen, 'onShow');
|
||||
delegateRun(self.oCurrentSubScreen, 'onShowWithDelay', [], 200);
|
||||
delegateRun(this.oCurrentSubScreen, 'onBeforeShow');
|
||||
this.oCurrentSubScreen.viewModelDom.show();
|
||||
delegateRun(this.oCurrentSubScreen, 'onShow');
|
||||
delegateRun(this.oCurrentSubScreen, 'onShowWithDelay', [], 200);
|
||||
|
||||
_.each(self.menu(), (oItem) => {
|
||||
oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route);
|
||||
_.each(this.menu(), (item) => {
|
||||
item.selected(settingsScreen && settingsScreen.__rlSettingsData && item.route === settingsScreen.__rlSettingsData.Route);
|
||||
});
|
||||
|
||||
$('#rl-content .b-settings .b-content .content').scrollTop(0);
|
||||
|
@ -166,22 +165,23 @@ class AbstractSettingsScreen extends AbstractScreen
|
|||
}
|
||||
|
||||
routes() {
|
||||
var
|
||||
const
|
||||
DefaultViewModel = _.find(VIEW_MODELS.settings,
|
||||
(SettingsViewModel) => SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData.IsDefault),
|
||||
(SettingsViewModel) => SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData.IsDefault
|
||||
),
|
||||
defaultRoute = DefaultViewModel && DefaultViewModel.__rlSettingsData ? DefaultViewModel.__rlSettingsData.Route : 'general',
|
||||
oRules = {
|
||||
rules = {
|
||||
subname: /^(.*)$/,
|
||||
normalize_: (oRequest, oVals) => {
|
||||
oVals.subname = isUnd(oVals.subname) ? defaultRoute : pString(oVals.subname);
|
||||
return [oVals.subname];
|
||||
normalize_: (rquest, vals) => {
|
||||
vals.subname = isUnd(vals.subname) ? defaultRoute : pString(vals.subname);
|
||||
return [vals.subname];
|
||||
}
|
||||
};
|
||||
|
||||
return [
|
||||
['{subname}/', oRules],
|
||||
['{subname}', oRules],
|
||||
['', oRules]
|
||||
['{subname}/', rules],
|
||||
['{subname}', rules],
|
||||
['', rules]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
|
||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
||||
import App from 'App/Admin';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
import {LoginAdminView} from 'View/Admin/Login';
|
||||
|
||||
class LoginAdminScreen extends AbstractScreen
|
||||
{
|
||||
constructor() {
|
||||
super('login', [
|
||||
require('View/Admin/Login')
|
||||
LoginAdminView
|
||||
]);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
App.setWindowTitle('');
|
||||
getApp().setWindowTitle('');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
import {addSettingsViewModel} from 'Knoin/Knoin';
|
||||
import {runSettingsViewModelHooks} from 'Common/Plugins';
|
||||
|
||||
import {AbstractSettingsScreen} from 'Screen/AbstractSettings';
|
||||
import App from 'App/Admin';
|
||||
|
||||
import {GeneralAdminSettings} from 'Settings/Admin/General';
|
||||
import {LoginAdminSettings} from 'Settings/Admin/Login';
|
||||
|
@ -15,12 +16,17 @@ import {PluginsAdminSettings} from 'Settings/Admin/Plugins';
|
|||
import {PackagesAdminSettings} from 'Settings/Admin/Packages';
|
||||
import {AboutAdminSettings} from 'Settings/Admin/About';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
import {MenuSettingsAdminView} from 'View/Admin/Settings/Menu';
|
||||
import {PaneSettingsAdminView} from 'View/Admin/Settings/Pane';
|
||||
|
||||
class SettingsAdminScreen extends AbstractSettingsScreen
|
||||
{
|
||||
constructor() {
|
||||
super([
|
||||
require('View/Admin/Settings/Menu'),
|
||||
require('View/Admin/Settings/Pane')
|
||||
MenuSettingsAdminView,
|
||||
PaneSettingsAdminView
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -81,7 +87,7 @@ class SettingsAdminScreen extends AbstractSettingsScreen
|
|||
}
|
||||
|
||||
onShow() {
|
||||
App.setWindowTitle('');
|
||||
getApp().setWindowTitle('');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
|
||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
||||
import App from 'App/User';
|
||||
|
||||
import {AboutUserView} from 'View/User/About';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
class AboutUserScreen extends AbstractScreen
|
||||
{
|
||||
constructor() {
|
||||
super('about', [
|
||||
require('View/User/About')
|
||||
]);
|
||||
super('about', [AboutUserView]);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
App.setWindowTitle('RainLoop');
|
||||
getApp().setWindowTitle('RainLoop');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
|
||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
||||
import App from 'App/User';
|
||||
|
||||
import {LoginUserView} from 'View/User/Login';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
class LoginUserScreen extends AbstractScreen
|
||||
{
|
||||
constructor() {
|
||||
super('login', [
|
||||
require('View/User/Login')
|
||||
]);
|
||||
super('login', [LoginUserView]);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
App.setWindowTitle('');
|
||||
getApp().setWindowTitle('');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,17 +16,25 @@ import SettingsStore from 'Stores/User/Settings';
|
|||
import FolderStore from 'Stores/User/Folder';
|
||||
import MessageStore from 'Stores/User/Message';
|
||||
|
||||
import {SystemDropDownMailBoxUserView} from 'View/User/MailBox/SystemDropDown';
|
||||
import {FolderListMailBoxUserView} from 'View/User/MailBox/FolderList';
|
||||
import {MessageListMailBoxUserView} from 'View/User/MailBox/MessageList';
|
||||
import {MessageViewMailBoxUserView} from 'View/User/MailBox/MessageView';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {warmUpScreenPopup} from 'Knoin/Knoin';
|
||||
|
||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
||||
import App from 'App/User';
|
||||
|
||||
class MailBoxUserScreen extends AbstractScreen
|
||||
{
|
||||
constructor() {
|
||||
super('mailbox', [
|
||||
require('View/User/MailBox/SystemDropDown'),
|
||||
require('View/User/MailBox/FolderList'),
|
||||
require('View/User/MailBox/MessageList'),
|
||||
require('View/User/MailBox/MessageView')
|
||||
SystemDropDownMailBoxUserView,
|
||||
FolderListMailBoxUserView,
|
||||
MessageListMailBoxUserView,
|
||||
MessageViewMailBoxUserView
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -42,7 +50,7 @@ class MailBoxUserScreen extends AbstractScreen
|
|||
foldersInboxUnreadCount = 0;
|
||||
}
|
||||
|
||||
App.setWindowTitle(('' === email ? '' : '' + (0 < foldersInboxUnreadCount ? '(' + foldersInboxUnreadCount + ') ' : ' ') + email + ' - ') + i18n('TITLES/MAILBOX'));
|
||||
getApp().setWindowTitle(('' === email ? '' : '' + (0 < foldersInboxUnreadCount ? '(' + foldersInboxUnreadCount + ') ' : ' ') + email + ' - ') + i18n('TITLES/MAILBOX'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,6 +81,7 @@ class MailBoxUserScreen extends AbstractScreen
|
|||
* @param {string} folderHash
|
||||
* @param {number} page
|
||||
* @param {string} search
|
||||
* @returns {void}
|
||||
*/
|
||||
onRoute(folderHash, page, search) {
|
||||
let threadUid = folderHash.replace(/^(.+)~([\d]+)$/, '$2');
|
||||
|
@ -91,7 +100,7 @@ class MailBoxUserScreen extends AbstractScreen
|
|||
MessageStore.messageListSearch(search);
|
||||
MessageStore.messageListThreadUid(threadUid);
|
||||
|
||||
App.reloadMessageList();
|
||||
getApp().reloadMessageList();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,9 +113,8 @@ class MailBoxUserScreen extends AbstractScreen
|
|||
MessageStore.messageList.subscribe(windowResizeCallback);
|
||||
MessageStore.message.subscribe(windowResizeCallback);
|
||||
|
||||
_.delay(() => {
|
||||
SettingsStore.layout.valueHasMutated();
|
||||
}, Magics.Time50ms);
|
||||
_.delay(() => SettingsStore.layout.valueHasMutated(), Magics.Time50ms);
|
||||
_.delay(() => warmUpScreenPopup(require('View/Popup/Compose')), Magics.Time500ms);
|
||||
|
||||
Events.sub('mailbox.inbox-unread-count', (count) => {
|
||||
FolderStore.foldersInboxUnreadCount(count);
|
||||
|
@ -130,7 +138,7 @@ class MailBoxUserScreen extends AbstractScreen
|
|||
if (!bMobileDevice && !Settings.appSettingsGet('mobile'))
|
||||
{
|
||||
_.defer(() => {
|
||||
App.initHorizontalLayoutResizer(ClientSideKeyName.MessageListSize);
|
||||
getApp().initHorizontalLayoutResizer(ClientSideKeyName.MessageListSize);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +147,7 @@ class MailBoxUserScreen extends AbstractScreen
|
|||
* @returns {Array}
|
||||
*/
|
||||
routes() {
|
||||
var
|
||||
const
|
||||
inboxFolderName = getFolderInboxName(),
|
||||
fNormS = (request, vals) => {
|
||||
vals[0] = pString(vals[0]);
|
||||
|
|
|
@ -11,7 +11,6 @@ import * as Settings from 'Storage/Settings';
|
|||
import {addSettingsViewModel} from 'Knoin/Knoin';
|
||||
|
||||
import {AbstractSettingsScreen} from 'Screen/AbstractSettings';
|
||||
import App from 'App/User';
|
||||
|
||||
import {GeneralUserSettings} from 'Settings/User/General';
|
||||
import {ContactsUserSettings} from 'Settings/User/Contacts';
|
||||
|
@ -25,13 +24,19 @@ import {FoldersUserSettings} from 'Settings/User/Folders';
|
|||
import {ThemesUserSettings} from 'Settings/User/Themes';
|
||||
import {OpenPgpUserSettings} from 'Settings/User/OpenPgp';
|
||||
|
||||
import {SystemDropDownSettingsUserView} from 'View/User/Settings/SystemDropDown';
|
||||
import {MenuSettingsUserView} from 'View/User/Settings/Menu';
|
||||
import {PaneSettingsUserView} from 'View/User/Settings/Pane';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
class SettingsUserScreen extends AbstractSettingsScreen
|
||||
{
|
||||
constructor() {
|
||||
super([
|
||||
require('View/User/Settings/SystemDropDown'),
|
||||
require('View/User/Settings/Menu'),
|
||||
require('View/User/Settings/Pane')
|
||||
SystemDropDownSettingsUserView,
|
||||
MenuSettingsUserView,
|
||||
PaneSettingsUserView
|
||||
]);
|
||||
|
||||
initOnStartOrLangChange(() => {
|
||||
|
@ -144,7 +149,7 @@ class SettingsUserScreen extends AbstractSettingsScreen
|
|||
|
||||
setSettingsTitle() {
|
||||
const sEmail = AccountStore.email();
|
||||
App.setWindowTitle(('' === sEmail ? '' : sEmail + ' - ') + this.sSettingsTitle);
|
||||
getApp().setWindowTitle(('' === sEmail ? '' : sEmail + ' - ') + this.sSettingsTitle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
dev/Settings/.gitignore
vendored
2
dev/Settings/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
/Admin/Prem/**
|
||||
/Admin/_Prem/**
|
|
@ -1,11 +1,15 @@
|
|||
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
import ko from 'ko';
|
||||
|
||||
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
|
||||
import {appSettingsGet, settingsGet} from 'Storage/Settings';
|
||||
|
||||
import CoreStore from 'Stores/Admin/Core';
|
||||
import AppStore from 'Stores/Admin/App';
|
||||
import CoreStore from 'Stores/Admin/Core';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
class AboutAdminSettings
|
||||
{
|
||||
|
@ -71,14 +75,14 @@ class AboutAdminSettings
|
|||
onBuild() {
|
||||
if (this.access() && !this.community)
|
||||
{
|
||||
require('App/Admin').default.reloadCoreData();
|
||||
getApp().reloadCoreData();
|
||||
}
|
||||
}
|
||||
|
||||
updateCoreData() {
|
||||
if (!this.coreUpdating() && !this.community)
|
||||
{
|
||||
require('App/Admin').default.updateCoreData();
|
||||
getApp().updateCoreData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
|
|
|
@ -91,11 +91,11 @@ class ContactsAdminSettings
|
|||
}
|
||||
}).extend({notify: 'always'});
|
||||
|
||||
this.contactsType.subscribe(function() {
|
||||
this.contactsType.subscribe(() => {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.pdoDsn = ko.observable(settingsGet('ContactsPdoDsn'));
|
||||
this.pdoUser = ko.observable(settingsGet('ContactsPdoUser'));
|
||||
|
@ -111,7 +111,7 @@ class ContactsAdminSettings
|
|||
this.testContactsError = ko.observable(false);
|
||||
this.testContactsErrorMessage = ko.observable('');
|
||||
|
||||
this.testContactsCommand = createCommand(this, () => {
|
||||
this.testContactsCommand = createCommand(() => {
|
||||
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
|
|
|
@ -8,6 +8,8 @@ import {showScreenPopup} from 'Knoin/Knoin';
|
|||
import DomainStore from 'Stores/Admin/Domain';
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
class DomainsAdminSettings
|
||||
{
|
||||
constructor() {
|
||||
|
@ -42,15 +44,15 @@ class DomainsAdminSettings
|
|||
onBuild(oDom) {
|
||||
const self = this;
|
||||
oDom
|
||||
.on('click', '.b-admin-domains-list-table .e-item .e-action', function() {
|
||||
const domainItem = ko.dataFor(this);
|
||||
.on('click', '.b-admin-domains-list-table .e-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||
const domainItem = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (domainItem)
|
||||
{
|
||||
Remote.domain(self.onDomainLoadRequest, domainItem.name);
|
||||
}
|
||||
});
|
||||
|
||||
require('App/Admin').default.reloadDomainList();
|
||||
getApp().reloadDomainList();
|
||||
}
|
||||
|
||||
onDomainLoadRequest(sResult, oData) {
|
||||
|
@ -61,7 +63,7 @@ class DomainsAdminSettings
|
|||
}
|
||||
|
||||
onDomainListChangeRequest() {
|
||||
require('App/Admin').default.reloadDomainList();
|
||||
getApp().reloadDomainList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,16 +5,16 @@ import ko from 'ko';
|
|||
import {settingsSaveHelperSimpleFunction, boolToAjax, trim} from 'Common/Utils';
|
||||
import {settingsGet} from 'Storage/Settings';
|
||||
|
||||
import AppAdminStore from 'Stores/Admin/App';
|
||||
import AppStore from 'Stores/Admin/App';
|
||||
|
||||
class LoginAdminSettings
|
||||
{
|
||||
constructor() {
|
||||
this.determineUserLanguage = AppAdminStore.determineUserLanguage;
|
||||
this.determineUserDomain = AppAdminStore.determineUserDomain;
|
||||
this.determineUserLanguage = AppStore.determineUserLanguage;
|
||||
this.determineUserDomain = AppStore.determineUserDomain;
|
||||
|
||||
this.defaultDomain = ko.observable(settingsGet('LoginDefaultDomain')).idleTrigger();
|
||||
this.allowLanguagesOnLogin = AppAdminStore.allowLanguagesOnLogin;
|
||||
this.allowLanguagesOnLogin = AppStore.allowLanguagesOnLogin;
|
||||
|
||||
this.dummy = ko.observable(false);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import {getNotification} from 'Common/Translator';
|
|||
import PackageStore from 'Stores/Admin/Package';
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
class PackagesAdminSettings
|
||||
{
|
||||
constructor() {
|
||||
|
@ -30,7 +32,7 @@ class PackagesAdminSettings
|
|||
}
|
||||
|
||||
onBuild() {
|
||||
require('App/Admin').default.reloadPackagesList();
|
||||
getApp().reloadPackagesList();
|
||||
}
|
||||
|
||||
requestHelper(packageToRequest, install) {
|
||||
|
@ -63,7 +65,7 @@ class PackagesAdminSettings
|
|||
}
|
||||
else
|
||||
{
|
||||
require('App/Admin').default.reloadPackagesList();
|
||||
getApp().reloadPackagesList();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
|
@ -14,6 +16,8 @@ import PluginStore from 'Stores/Admin/Plugin';
|
|||
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
class PluginsAdminSettings
|
||||
{
|
||||
constructor() {
|
||||
|
@ -40,17 +44,19 @@ class PluginsAdminSettings
|
|||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
|
||||
const self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.e-item .configure-plugin-action', function() {
|
||||
const plugin = ko.dataFor(this);
|
||||
.on('click', '.e-item .configure-plugin-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||
const plugin = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (plugin)
|
||||
{
|
||||
self.configurePlugin(plugin);
|
||||
}
|
||||
})
|
||||
.on('click', '.e-item .disabled-plugin', function() {
|
||||
const plugin = ko.dataFor(this);
|
||||
.on('click', '.e-item .disabled-plugin', function() { // eslint-disable-line prefer-arrow-callback
|
||||
const plugin = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (plugin)
|
||||
{
|
||||
self.disablePlugin(plugin);
|
||||
|
@ -66,7 +72,7 @@ class PluginsAdminSettings
|
|||
|
||||
onShow() {
|
||||
PluginStore.plugins.error('');
|
||||
require('App/Admin').default.reloadPluginList();
|
||||
getApp().reloadPluginList();
|
||||
}
|
||||
|
||||
onPluginLoadRequest(result, data) {
|
||||
|
@ -92,7 +98,7 @@ class PluginsAdminSettings
|
|||
}
|
||||
}
|
||||
|
||||
require('App/Admin').default.reloadPluginList();
|
||||
getApp().reloadPluginList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
105
dev/Settings/Admin/Prem/Branding.js
Normal file
105
dev/Settings/Admin/Prem/Branding.js
Normal file
|
@ -0,0 +1,105 @@
|
|||
|
||||
import _ from '_';
|
||||
import {settingsSaveHelperSimpleFunction, trim, boolToAjax} from 'Common/Utils';
|
||||
|
||||
import {BrandingAdminSettings} from 'Settings/Admin/Branding';
|
||||
|
||||
class BrandingPremAdminSettings extends BrandingAdminSettings
|
||||
{
|
||||
onBuild(oDom) {
|
||||
super.onBuild(oDom);
|
||||
|
||||
if (this.capa && this.capa() && !this.community)
|
||||
{
|
||||
_.delay(() => {
|
||||
const
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
f1 = settingsSaveHelperSimpleFunction(this.loginLogo.trigger, this),
|
||||
f2 = settingsSaveHelperSimpleFunction(this.loginDescription.trigger, this),
|
||||
f3 = settingsSaveHelperSimpleFunction(this.loginCss.trigger, this),
|
||||
f4 = settingsSaveHelperSimpleFunction(this.userLogo.trigger, this),
|
||||
f5 = settingsSaveHelperSimpleFunction(this.userLogoTitle.trigger, this),
|
||||
f6 = settingsSaveHelperSimpleFunction(this.loginBackground.trigger, this),
|
||||
f7 = settingsSaveHelperSimpleFunction(this.userCss.trigger, this),
|
||||
f8 = settingsSaveHelperSimpleFunction(this.welcomePageUrl.trigger, this),
|
||||
f9 = settingsSaveHelperSimpleFunction(this.welcomePageDisplay.trigger, this),
|
||||
f10 = settingsSaveHelperSimpleFunction(this.userLogoMessage.trigger, this),
|
||||
f11 = settingsSaveHelperSimpleFunction(this.userIframeMessage.trigger, this);
|
||||
|
||||
this.loginLogo.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f1, {
|
||||
'LoginLogo': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.loginDescription.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f2, {
|
||||
'LoginDescription': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.loginCss.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f3, {
|
||||
'LoginCss': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userLogo.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f4, {
|
||||
'UserLogo': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userLogoTitle.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f5, {
|
||||
'UserLogoTitle': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userLogoMessage.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f10, {
|
||||
'UserLogoMessage': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userIframeMessage.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f11, {
|
||||
'UserIframeMessage': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.loginBackground.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f6, {
|
||||
'LoginBackground': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userCss.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f7, {
|
||||
'UserCss': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.welcomePageUrl.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f8, {
|
||||
'WelcomePageUrl': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.welcomePageDisplay.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f9, {
|
||||
'WelcomePageDisplay': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.loginPowered.subscribe((value) => {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'LoginPowered': boolToAjax(value)
|
||||
});
|
||||
});
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {BrandingPremAdminSettings, BrandingPremAdminSettings as default};
|
71
dev/Settings/Admin/Prem/Licensing.js
Normal file
71
dev/Settings/Admin/Prem/Licensing.js
Normal file
|
@ -0,0 +1,71 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {settingsGet} from 'Storage/Settings';
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
|
||||
import LicenseStore from 'Stores/Admin/License';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
class LicensingPremAdminSettings
|
||||
{
|
||||
constructor() {
|
||||
this.licensing = LicenseStore.licensing;
|
||||
this.licensingProcess = LicenseStore.licensingProcess;
|
||||
this.licenseValid = LicenseStore.licenseValid;
|
||||
this.licenseExpired = LicenseStore.licenseExpired;
|
||||
this.licenseError = LicenseStore.licenseError;
|
||||
this.licenseTrigger = LicenseStore.licenseTrigger;
|
||||
|
||||
this.adminDomain = ko.observable('');
|
||||
this.subscriptionEnabled = ko.observable(!!settingsGet('SubscriptionEnabled'));
|
||||
|
||||
this.licenseTrigger.subscribe(() => {
|
||||
if (this.subscriptionEnabled())
|
||||
{
|
||||
getApp().reloadLicensing(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
if (this.subscriptionEnabled())
|
||||
{
|
||||
getApp().reloadLicensing(false);
|
||||
}
|
||||
}
|
||||
|
||||
onShow() {
|
||||
this.adminDomain(settingsGet('AdminDomain'));
|
||||
}
|
||||
|
||||
showActivationForm() {
|
||||
showScreenPopup(require('View/Popup/Activate'));
|
||||
}
|
||||
|
||||
showTrialForm() {
|
||||
showScreenPopup(require('View/Popup/Activate'), [true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
licenseIsUnlim() {
|
||||
return 1898625600 === this.licenseExpired() || 1898625700 === this.licenseExpired(); // eslint-disable-line no-magic-numbers
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
licenseExpiredMomentValue() {
|
||||
const
|
||||
moment = require('moment'),
|
||||
time = this.licenseExpired(),
|
||||
momentUnix = moment.unix(time);
|
||||
|
||||
return this.licenseIsUnlim() ? 'Never' : (time && (momentUnix.format('LL') + ' (' + momentUnix.from(moment()) + ')'));
|
||||
}
|
||||
}
|
||||
|
||||
export {LicensingPremAdminSettings, LicensingPremAdminSettings as default};
|
|
@ -77,7 +77,7 @@ class SecurityAdminSettings
|
|||
this.adminPasswordNewError(false);
|
||||
});
|
||||
|
||||
this.saveNewAdminPasswordCommand = createCommand(this, () => {
|
||||
this.saveNewAdminPasswordCommand = createCommand(() => {
|
||||
|
||||
if ('' === trim(this.adminLogin()))
|
||||
{
|
||||
|
|
|
@ -8,12 +8,14 @@ import {root} from 'Common/Links';
|
|||
|
||||
import {capa} from 'Storage/Settings';
|
||||
|
||||
import {showScreenPopup, routeOff, setHash} from 'Knoin/Knoin';
|
||||
|
||||
import AccountStore from 'Stores/User/Account';
|
||||
import IdentityStore from 'Stores/User/Identity';
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {showScreenPopup, routeOff, setHash} from 'Knoin/Knoin';
|
||||
|
||||
class AccountsUserSettings
|
||||
{
|
||||
constructor() {
|
||||
|
@ -66,7 +68,7 @@ class AccountsUserSettings
|
|||
{
|
||||
this.accounts.remove((account) => accountToRemove === account);
|
||||
|
||||
Remote.accountDelete(function(result, data) {
|
||||
Remote.accountDelete((result, data) => {
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Reload)
|
||||
{
|
||||
|
@ -78,7 +80,7 @@ class AccountsUserSettings
|
|||
}
|
||||
else
|
||||
{
|
||||
require('App/User').default.accountsAndIdentities();
|
||||
getApp().accountsAndIdentities();
|
||||
}
|
||||
|
||||
}, accountToRemove.email);
|
||||
|
@ -100,7 +102,7 @@ class AccountsUserSettings
|
|||
IdentityStore.identities.remove((oIdentity) => identityToRemove === oIdentity);
|
||||
|
||||
Remote.identityDelete(() => {
|
||||
require('App/User').default.accountsAndIdentities();
|
||||
getApp().accountsAndIdentities();
|
||||
}, identityToRemove.id);
|
||||
}
|
||||
}
|
||||
|
@ -112,18 +114,19 @@ class AccountsUserSettings
|
|||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
var self = this;
|
||||
|
||||
const self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.accounts-list .account-item .e-action', function() {
|
||||
const account = ko.dataFor(this);
|
||||
.on('click', '.accounts-list .account-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||
const account = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (account)
|
||||
{
|
||||
self.editAccount(account);
|
||||
}
|
||||
})
|
||||
.on('click', '.identities-list .identity-item .e-action', function() {
|
||||
const identity = ko.dataFor(this);
|
||||
.on('click', '.identities-list .identity-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||
const identity = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (identity)
|
||||
{
|
||||
self.editIdentity(identity);
|
||||
|
|
|
@ -8,6 +8,8 @@ import {getNotificationFromResponse, i18n} from 'Common/Translator';
|
|||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
class ChangePasswordUserSettings
|
||||
{
|
||||
constructor() {
|
||||
|
@ -41,7 +43,7 @@ class ChangePasswordUserSettings
|
|||
this.passwordMismatch(false);
|
||||
});
|
||||
|
||||
this.saveNewPasswordCommand = createCommand(this, () => {
|
||||
this.saveNewPasswordCommand = createCommand(() => {
|
||||
if (this.newPassword() !== this.newPassword2())
|
||||
{
|
||||
this.passwordMismatch(true);
|
||||
|
@ -90,7 +92,7 @@ class ChangePasswordUserSettings
|
|||
this.passwordUpdateSuccess(true);
|
||||
this.currentPassword.error(false);
|
||||
|
||||
require('App/User').default.setClientSideToken(data.Result);
|
||||
getApp().setClientSideToken(data.Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ class FiltersUserSettings
|
|||
this.filterForDeletion = ko.observable(null)
|
||||
.extend({falseTimeout: 3000}).extend({toggleSubscribeProperty: [this, 'deleteAccess']});
|
||||
|
||||
this.saveChanges = createCommand(this, () => {
|
||||
this.saveChanges = createCommand(() => {
|
||||
if (!this.filters.saving())
|
||||
{
|
||||
if (this.filterRaw.active() && '' === trim(this.filterRaw()))
|
||||
|
@ -187,11 +187,12 @@ class FiltersUserSettings
|
|||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
|
||||
const self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.filter-item .e-action', function() {
|
||||
const filter = ko.dataFor(this);
|
||||
.on('click', '.filter-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||
const filter = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (filter)
|
||||
{
|
||||
self.editFilter(filter);
|
||||
|
|
|
@ -10,13 +10,15 @@ import {removeFolderFromCacheList} from 'Common/Cache';
|
|||
import {appSettingsGet} from 'Storage/Settings';
|
||||
import * as Local from 'Storage/Client';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
|
||||
import FolderStore from 'Stores/User/Folder';
|
||||
|
||||
import Promises from 'Promises/User/Ajax';
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
|
||||
class FoldersUserSettings
|
||||
{
|
||||
constructor() {
|
||||
|
@ -61,7 +63,7 @@ class FoldersUserSettings
|
|||
{
|
||||
Local.set(ClientSideKeyName.FoldersLashHash, '');
|
||||
|
||||
require('App/User').default.foldersPromisesActionHelper(
|
||||
getApp().foldersPromisesActionHelper(
|
||||
Promises.folderRename(folder.fullNameRaw, nameToEdit, FolderStore.foldersRenaming),
|
||||
Notification.CantRenameFolder
|
||||
);
|
||||
|
@ -131,7 +133,7 @@ class FoldersUserSettings
|
|||
|
||||
FolderStore.folderList.remove(fRemoveFolder);
|
||||
|
||||
require('App/User').default.foldersPromisesActionHelper(
|
||||
getApp().foldersPromisesActionHelper(
|
||||
Promises.folderDelete(folderToRemove.fullNameRaw, FolderStore.foldersDeleting),
|
||||
Notification.CantDeleteFolder
|
||||
);
|
||||
|
|
|
@ -165,7 +165,7 @@ class GeneralUserSettings
|
|||
});
|
||||
});
|
||||
|
||||
this.layout.subscribe(function(value) {
|
||||
this.layout.subscribe((value) => {
|
||||
MessageStore.messageList([]);
|
||||
Remote.saveSettings(f2, {
|
||||
'Layout': value
|
||||
|
|
|
@ -5,10 +5,12 @@ import ko from 'ko';
|
|||
import {delegateRunOnDestroy} from 'Common/Utils';
|
||||
import {bIsHttps} from 'Common/Globals';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
|
||||
import PgpStore from 'Stores/User/Pgp';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
|
||||
class OpenPgpUserSettings
|
||||
{
|
||||
constructor() {
|
||||
|
@ -60,7 +62,7 @@ class OpenPgpUserSettings
|
|||
PgpStore.openpgpKeyring.store();
|
||||
}
|
||||
|
||||
require('App/User').default.reloadOpenPgpKeys();
|
||||
getApp().reloadOpenPgpKeys();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ import {createCommand} from 'Common/Utils';
|
|||
|
||||
import SocialStore from 'Stores/Social';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
class SocialUserSettings
|
||||
{
|
||||
constructor() {
|
||||
|
@ -28,43 +30,39 @@ class SocialUserSettings
|
|||
this.twitterLoggined = SocialStore.twitter.loggined;
|
||||
this.twitterUserName = SocialStore.twitter.userName;
|
||||
|
||||
this.connectGoogle = createCommand(this, () => {
|
||||
this.connectGoogle = createCommand(() => {
|
||||
if (!this.googleLoggined())
|
||||
{
|
||||
this.getApp().googleConnect();
|
||||
getApp().googleConnect();
|
||||
}
|
||||
}, () => !this.googleLoggined() && !this.googleActions());
|
||||
|
||||
this.disconnectGoogle = createCommand(this, () => {
|
||||
this.getApp().googleDisconnect();
|
||||
this.disconnectGoogle = createCommand(() => {
|
||||
getApp().googleDisconnect();
|
||||
});
|
||||
|
||||
this.connectFacebook = createCommand(this, () => {
|
||||
this.connectFacebook = createCommand(() => {
|
||||
if (!this.facebookLoggined())
|
||||
{
|
||||
this.getApp().facebookConnect();
|
||||
getApp().facebookConnect();
|
||||
}
|
||||
}, () => !this.facebookLoggined() && !this.facebookActions());
|
||||
|
||||
this.disconnectFacebook = createCommand(this, () => {
|
||||
this.getApp().facebookDisconnect();
|
||||
this.disconnectFacebook = createCommand(() => {
|
||||
getApp().facebookDisconnect();
|
||||
});
|
||||
|
||||
this.connectTwitter = createCommand(this, () => {
|
||||
this.connectTwitter = createCommand(() => {
|
||||
if (!this.twitterLoggined())
|
||||
{
|
||||
this.getApp().twitterConnect();
|
||||
getApp().twitterConnect();
|
||||
}
|
||||
}, () => !this.twitterLoggined() && !this.twitterActions());
|
||||
|
||||
this.disconnectTwitter = createCommand(this, () => {
|
||||
this.getApp().twitterDisconnect();
|
||||
this.disconnectTwitter = createCommand(() => {
|
||||
getApp().twitterDisconnect();
|
||||
});
|
||||
}
|
||||
|
||||
getApp() {
|
||||
return require('App/User').default;
|
||||
}
|
||||
}
|
||||
|
||||
export {SocialUserSettings, SocialUserSettings as default};
|
||||
|
|
|
@ -3,11 +3,13 @@ import ko from 'ko';
|
|||
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
|
||||
import TemplateStore from 'Stores/User/Template';
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
|
||||
class TemplatesUserSettings
|
||||
{
|
||||
constructor() {
|
||||
|
@ -55,19 +57,16 @@ class TemplatesUserSettings
|
|||
}
|
||||
|
||||
reloadTemplates() {
|
||||
this.getApp().templates();
|
||||
}
|
||||
|
||||
getApp() {
|
||||
return require('App/User').default;
|
||||
getApp().templates();
|
||||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
var self = this;
|
||||
|
||||
const self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.templates-list .template-item .e-action', function() {
|
||||
const template = ko.dataFor(this);
|
||||
.on('click', '.templates-list .template-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||
const template = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (template)
|
||||
{
|
||||
self.editTemplate(template);
|
||||
|
|
|
@ -11,9 +11,9 @@ class AbstractAppStore
|
|||
|
||||
this.interfaceAnimation = ko.observable(true);
|
||||
|
||||
this.interfaceAnimation.subscribe(function(bValue) {
|
||||
const bAnim = bMobileDevice || !bValue;
|
||||
$html.toggleClass('rl-anim', !bAnim).toggleClass('no-rl-anim', bAnim);
|
||||
this.interfaceAnimation.subscribe((value) => {
|
||||
const anim = bMobileDevice || !value;
|
||||
$html.toggleClass('rl-anim', !anim).toggleClass('no-rl-anim', anim);
|
||||
});
|
||||
|
||||
this.interfaceAnimation.valueHasMutated();
|
||||
|
|
|
@ -1,44 +1,39 @@
|
|||
|
||||
var
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
import {Capa} from 'Common/Enums';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
|
||||
Settings = require('Storage/Settings');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function CapaAdminStore()
|
||||
class CapaAdminStore
|
||||
{
|
||||
this.additionalAccounts = ko.observable(false);
|
||||
this.identities = ko.observable(false);
|
||||
this.gravatar = ko.observable(false);
|
||||
this.attachmentThumbnails = ko.observable(false);
|
||||
this.sieve = ko.observable(false);
|
||||
this.filters = ko.observable(false);
|
||||
this.themes = ko.observable(true);
|
||||
this.userBackground = ko.observable(false);
|
||||
this.openPGP = ko.observable(false);
|
||||
this.twoFactorAuth = ko.observable(false);
|
||||
this.twoFactorAuthForce = ko.observable(false);
|
||||
this.templates = ko.observable(false);
|
||||
constructor() {
|
||||
this.additionalAccounts = ko.observable(false);
|
||||
this.identities = ko.observable(false);
|
||||
this.gravatar = ko.observable(false);
|
||||
this.attachmentThumbnails = ko.observable(false);
|
||||
this.sieve = ko.observable(false);
|
||||
this.filters = ko.observable(false);
|
||||
this.themes = ko.observable(true);
|
||||
this.userBackground = ko.observable(false);
|
||||
this.openPGP = ko.observable(false);
|
||||
this.twoFactorAuth = ko.observable(false);
|
||||
this.twoFactorAuthForce = ko.observable(false);
|
||||
this.templates = ko.observable(false);
|
||||
}
|
||||
|
||||
populate() {
|
||||
this.additionalAccounts(Settings.capa(Capa.AdditionalAccounts));
|
||||
this.identities(Settings.capa(Capa.Identities));
|
||||
this.gravatar(Settings.capa(Capa.Gravatar));
|
||||
this.attachmentThumbnails(Settings.capa(Capa.AttachmentThumbnails));
|
||||
this.sieve(Settings.capa(Capa.Sieve));
|
||||
this.filters(Settings.capa(Capa.Filters));
|
||||
this.themes(Settings.capa(Capa.Themes));
|
||||
this.userBackground(Settings.capa(Capa.UserBackground));
|
||||
this.openPGP(Settings.capa(Capa.OpenPGP));
|
||||
this.twoFactorAuth(Settings.capa(Capa.TwoFactor));
|
||||
this.twoFactorAuthForce(Settings.capa(Capa.TwoFactorForce));
|
||||
this.templates(Settings.capa(Capa.Templates));
|
||||
}
|
||||
}
|
||||
|
||||
CapaAdminStore.prototype.populate = function()
|
||||
{
|
||||
this.additionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts));
|
||||
this.identities(Settings.capa(Enums.Capa.Identities));
|
||||
this.gravatar(Settings.capa(Enums.Capa.Gravatar));
|
||||
this.attachmentThumbnails(Settings.capa(Enums.Capa.AttachmentThumbnails));
|
||||
this.sieve(Settings.capa(Enums.Capa.Sieve));
|
||||
this.filters(Settings.capa(Enums.Capa.Filters));
|
||||
this.themes(Settings.capa(Enums.Capa.Themes));
|
||||
this.userBackground(Settings.capa(Enums.Capa.UserBackground));
|
||||
this.openPGP(Settings.capa(Enums.Capa.OpenPGP));
|
||||
this.twoFactorAuth(Settings.capa(Enums.Capa.TwoFactor));
|
||||
this.twoFactorAuthForce(Settings.capa(Enums.Capa.TwoFactorForce));
|
||||
this.templates(Settings.capa(Enums.Capa.Templates));
|
||||
};
|
||||
|
||||
module.exports = new CapaAdminStore();
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
|
||||
var ko = require('ko');
|
||||
import ko from 'ko';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function CoreAdminStore()
|
||||
class CoreAdminStore
|
||||
{
|
||||
this.coreReal = ko.observable(true);
|
||||
this.coreChannel = ko.observable('stable');
|
||||
this.coreType = ko.observable('stable');
|
||||
this.coreUpdatable = ko.observable(true);
|
||||
this.coreAccess = ko.observable(true);
|
||||
this.coreWarning = ko.observable(false);
|
||||
this.coreChecking = ko.observable(false).extend({'throttle': 100});
|
||||
this.coreUpdating = ko.observable(false).extend({'throttle': 100});
|
||||
this.coreVersion = ko.observable('');
|
||||
this.coreRemoteVersion = ko.observable('');
|
||||
this.coreRemoteRelease = ko.observable('');
|
||||
this.coreVersionCompare = ko.observable(-2);
|
||||
constructor() {
|
||||
this.coreReal = ko.observable(true);
|
||||
this.coreChannel = ko.observable('stable');
|
||||
this.coreType = ko.observable('stable');
|
||||
this.coreUpdatable = ko.observable(true);
|
||||
this.coreAccess = ko.observable(true);
|
||||
this.coreWarning = ko.observable(false);
|
||||
this.coreChecking = ko.observable(false).extend({throttle: 100});
|
||||
this.coreUpdating = ko.observable(false).extend({throttle: 100});
|
||||
this.coreVersion = ko.observable('');
|
||||
this.coreRemoteVersion = ko.observable('');
|
||||
this.coreRemoteRelease = ko.observable('');
|
||||
this.coreVersionCompare = ko.observable(-2);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new CoreAdminStore();
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
|
||||
var ko = require('ko');
|
||||
import ko from 'ko';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function DomainAdminStore()
|
||||
class DomainAdminStore
|
||||
{
|
||||
this.domains = ko.observableArray([]);
|
||||
this.domains.loading = ko.observable(false).extend({'throttle': 100});
|
||||
|
||||
this.domainsWithoutAliases = this.domains.filter(function(oItem) {
|
||||
return oItem && !oItem.alias;
|
||||
});
|
||||
constructor() {
|
||||
this.domains = ko.observableArray([]);
|
||||
this.domains.loading = ko.observable(false).extend({'throttle': 100});
|
||||
this.domainsWithoutAliases = this.domains.filter((item) => item && !item.alias);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new DomainAdminStore();
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
|
||||
var ko = require('ko');
|
||||
import ko from 'ko';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LicenseAdminStore()
|
||||
class LicenseAdminStore
|
||||
{
|
||||
this.licensing = ko.observable(false);
|
||||
this.licensingProcess = ko.observable(false);
|
||||
this.licenseValid = ko.observable(false);
|
||||
this.licenseExpired = ko.observable(0);
|
||||
this.licenseError = ko.observable('');
|
||||
constructor() {
|
||||
this.licensing = ko.observable(false);
|
||||
this.licensingProcess = ko.observable(false);
|
||||
this.licenseValid = ko.observable(false);
|
||||
this.licenseExpired = ko.observable(0);
|
||||
this.licenseError = ko.observable('');
|
||||
|
||||
this.licenseTrigger = ko.observable(false);
|
||||
this.licenseTrigger = ko.observable(false);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new LicenseAdminStore();
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
|
||||
var ko = require('ko');
|
||||
import ko from 'ko';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PackageAdminStore()
|
||||
class PackageAdminStore
|
||||
{
|
||||
this.packages = ko.observableArray([]);
|
||||
this.packages.loading = ko.observable(false).extend({'throttle': 100});
|
||||
constructor() {
|
||||
this.packages = ko.observableArray([]);
|
||||
this.packages.loading = ko.observable(false).extend({throttle: 100});
|
||||
|
||||
this.packagesReal = ko.observable(true);
|
||||
this.packagesMainUpdatable = ko.observable(true);
|
||||
this.packagesReal = ko.observable(true);
|
||||
this.packagesMainUpdatable = ko.observable(true);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new PackageAdminStore();
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
|
||||
var ko = require('ko');
|
||||
import ko from 'ko';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PluginAdminStore()
|
||||
class PluginAdminStore
|
||||
{
|
||||
this.plugins = ko.observableArray([]);
|
||||
this.plugins.loading = ko.observable(false).extend({'throttle': 100});
|
||||
this.plugins.error = ko.observable('');
|
||||
constructor() {
|
||||
this.plugins = ko.observableArray([]);
|
||||
this.plugins.loading = ko.observable(false).extend({throttle: 100});
|
||||
this.plugins.error = ko.observable('');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new PluginAdminStore();
|
||||
|
|
|
@ -1,45 +1,40 @@
|
|||
|
||||
var
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
import {isArray} from 'Common/Utils';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Settings = require('Storage/Settings');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LanguageStore()
|
||||
class LanguageStore
|
||||
{
|
||||
this.languages = ko.observableArray([]);
|
||||
this.languagesAdmin = ko.observableArray([]);
|
||||
constructor() {
|
||||
this.languages = ko.observableArray([]);
|
||||
this.languagesAdmin = ko.observableArray([]);
|
||||
|
||||
this.language = ko.observable('')
|
||||
.extend({'limitedList': this.languages})
|
||||
.extend({'reversible': true});
|
||||
this.language = ko.observable('')
|
||||
.extend({limitedList: this.languages})
|
||||
.extend({reversible: true});
|
||||
|
||||
this.languageAdmin = ko.observable('')
|
||||
.extend({'limitedList': this.languagesAdmin})
|
||||
.extend({'reversible': true});
|
||||
this.languageAdmin = ko.observable('')
|
||||
.extend({limitedList: this.languagesAdmin})
|
||||
.extend({reversible: true});
|
||||
|
||||
this.userLanguage = ko.observable('');
|
||||
this.userLanguageAdmin = ko.observable('');
|
||||
this.userLanguage = ko.observable('');
|
||||
this.userLanguageAdmin = ko.observable('');
|
||||
}
|
||||
|
||||
populate() {
|
||||
const
|
||||
aLanguages = Settings.appSettingsGet('languages'),
|
||||
aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin');
|
||||
|
||||
this.languages(isArray(aLanguages) ? aLanguages : []);
|
||||
this.languagesAdmin(isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
|
||||
|
||||
this.language(Settings.settingsGet('Language'));
|
||||
this.languageAdmin(Settings.settingsGet('LanguageAdmin'));
|
||||
|
||||
this.userLanguage(Settings.settingsGet('UserLanguage'));
|
||||
this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin'));
|
||||
}
|
||||
}
|
||||
|
||||
LanguageStore.prototype.populate = function()
|
||||
{
|
||||
var
|
||||
aLanguages = Settings.appSettingsGet('languages'),
|
||||
aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin');
|
||||
|
||||
this.languages(Utils.isArray(aLanguages) ? aLanguages : []);
|
||||
this.languagesAdmin(Utils.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
|
||||
|
||||
this.language(Settings.settingsGet('Language'));
|
||||
this.languageAdmin(Settings.settingsGet('LanguageAdmin'));
|
||||
|
||||
this.userLanguage(Settings.settingsGet('UserLanguage'));
|
||||
this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin'));
|
||||
};
|
||||
|
||||
module.exports = new LanguageStore();
|
||||
|
|
|
@ -1,103 +1,103 @@
|
|||
|
||||
var ko = require('ko');
|
||||
import window from 'window';
|
||||
import ko from 'ko';
|
||||
import $ from '$';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function SocialStore()
|
||||
class SocialStore
|
||||
{
|
||||
this.google = {};
|
||||
this.twitter = {};
|
||||
this.facebook = {};
|
||||
this.dropbox = {};
|
||||
constructor() {
|
||||
this.google = {};
|
||||
this.twitter = {};
|
||||
this.facebook = {};
|
||||
this.dropbox = {};
|
||||
|
||||
// Google
|
||||
this.google.enabled = ko.observable(false);
|
||||
// Google
|
||||
this.google.enabled = ko.observable(false);
|
||||
|
||||
this.google.clientID = ko.observable('');
|
||||
this.google.clientSecret = ko.observable('');
|
||||
this.google.apiKey = ko.observable('');
|
||||
this.google.clientID = ko.observable('');
|
||||
this.google.clientSecret = ko.observable('');
|
||||
this.google.apiKey = ko.observable('');
|
||||
|
||||
this.google.loading = ko.observable(false);
|
||||
this.google.userName = ko.observable('');
|
||||
this.google.loading = ko.observable(false);
|
||||
this.google.userName = ko.observable('');
|
||||
|
||||
this.google.loggined = ko.computed(function() {
|
||||
return '' !== this.google.userName();
|
||||
}, this);
|
||||
this.google.loggined = ko.computed(() => '' !== this.google.userName());
|
||||
|
||||
this.google.capa = {};
|
||||
this.google.capa.auth = ko.observable(false);
|
||||
this.google.capa.authFast = ko.observable(false);
|
||||
this.google.capa.drive = ko.observable(false);
|
||||
this.google.capa.preview = ko.observable(false);
|
||||
this.google.capa = {};
|
||||
this.google.capa.auth = ko.observable(false);
|
||||
this.google.capa.authFast = ko.observable(false);
|
||||
this.google.capa.drive = ko.observable(false);
|
||||
this.google.capa.preview = ko.observable(false);
|
||||
|
||||
this.google.require = {};
|
||||
this.google.require.clientSettings = ko.computed(function() {
|
||||
return this.google.enabled() && (this.google.capa.auth() || this.google.capa.drive());
|
||||
}, this);
|
||||
this.google.require = {};
|
||||
this.google.require.clientSettings = ko.computed(
|
||||
() => this.google.enabled() && (this.google.capa.auth() || this.google.capa.drive()));
|
||||
|
||||
this.google.require.apiKeySettings = ko.computed(function() {
|
||||
return this.google.enabled() && this.google.capa.drive();
|
||||
}, this);
|
||||
this.google.require.apiKeySettings = ko.computed(() => this.google.enabled() && this.google.capa.drive());
|
||||
|
||||
// Facebook
|
||||
this.facebook.enabled = ko.observable(false);
|
||||
this.facebook.appID = ko.observable('');
|
||||
this.facebook.appSecret = ko.observable('');
|
||||
this.facebook.loading = ko.observable(false);
|
||||
this.facebook.userName = ko.observable('');
|
||||
this.facebook.supported = ko.observable(false);
|
||||
// Facebook
|
||||
this.facebook.enabled = ko.observable(false);
|
||||
this.facebook.appID = ko.observable('');
|
||||
this.facebook.appSecret = ko.observable('');
|
||||
this.facebook.loading = ko.observable(false);
|
||||
this.facebook.userName = ko.observable('');
|
||||
this.facebook.supported = ko.observable(false);
|
||||
|
||||
this.facebook.loggined = ko.computed(function() {
|
||||
return '' !== this.facebook.userName();
|
||||
}, this);
|
||||
this.facebook.loggined = ko.computed(() => '' !== this.facebook.userName());
|
||||
|
||||
// Twitter
|
||||
this.twitter.enabled = ko.observable(false);
|
||||
this.twitter.consumerKey = ko.observable('');
|
||||
this.twitter.consumerSecret = ko.observable('');
|
||||
this.twitter.loading = ko.observable(false);
|
||||
this.twitter.userName = ko.observable('');
|
||||
// Twitter
|
||||
this.twitter.enabled = ko.observable(false);
|
||||
this.twitter.consumerKey = ko.observable('');
|
||||
this.twitter.consumerSecret = ko.observable('');
|
||||
this.twitter.loading = ko.observable(false);
|
||||
this.twitter.userName = ko.observable('');
|
||||
|
||||
this.twitter.loggined = ko.computed(function() {
|
||||
return '' !== this.twitter.userName();
|
||||
}, this);
|
||||
this.twitter.loggined = ko.computed(() => '' !== this.twitter.userName());
|
||||
|
||||
// Dropbox
|
||||
this.dropbox.enabled = ko.observable(false);
|
||||
this.dropbox.apiKey = ko.observable('');
|
||||
// Dropbox
|
||||
this.dropbox.enabled = ko.observable(false);
|
||||
this.dropbox.apiKey = ko.observable('');
|
||||
}
|
||||
|
||||
populate() {
|
||||
this.google.enabled(!!Settings.settingsGet('AllowGoogleSocial'));
|
||||
this.google.clientID(Settings.settingsGet('GoogleClientID'));
|
||||
this.google.clientSecret(Settings.settingsGet('GoogleClientSecret'));
|
||||
this.google.apiKey(Settings.settingsGet('GoogleApiKey'));
|
||||
|
||||
this.google.capa.auth(!!Settings.settingsGet('AllowGoogleSocialAuth'));
|
||||
this.google.capa.authFast(!!Settings.settingsGet('AllowGoogleSocialAuthFast'));
|
||||
this.google.capa.drive(!!Settings.settingsGet('AllowGoogleSocialDrive'));
|
||||
this.google.capa.preview(!!Settings.settingsGet('AllowGoogleSocialPreview'));
|
||||
|
||||
this.facebook.enabled(!!Settings.settingsGet('AllowFacebookSocial'));
|
||||
this.facebook.appID(Settings.settingsGet('FacebookAppID'));
|
||||
this.facebook.appSecret(Settings.settingsGet('FacebookAppSecret'));
|
||||
this.facebook.supported(!!Settings.settingsGet('SupportedFacebookSocial'));
|
||||
|
||||
this.twitter.enabled = ko.observable(!!Settings.settingsGet('AllowTwitterSocial'));
|
||||
this.twitter.consumerKey = ko.observable(Settings.settingsGet('TwitterConsumerKey'));
|
||||
this.twitter.consumerSecret = ko.observable(Settings.settingsGet('TwitterConsumerSecret'));
|
||||
|
||||
this.dropbox.enabled(!!Settings.settingsGet('AllowDropboxSocial'));
|
||||
this.dropbox.apiKey(Settings.settingsGet('DropboxApiKey'));
|
||||
}
|
||||
|
||||
appendDropbox() {
|
||||
if (!window.Dropbox && this.dropbox.enabled() && this.dropbox.apiKey())
|
||||
{
|
||||
if (!window.document.getElementById('dropboxjs'))
|
||||
{
|
||||
const script = window.document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = 'https://www.dropbox.com/static/api/2/dropins.js';
|
||||
$(script).attr('id', 'dropboxjs').attr('data-app-key', this.dropbox.apiKey());
|
||||
|
||||
window.document.body.appendChild(script);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SocialStore.prototype.google = {};
|
||||
SocialStore.prototype.twitter = {};
|
||||
SocialStore.prototype.facebook = {};
|
||||
SocialStore.prototype.dropbox = {};
|
||||
|
||||
SocialStore.prototype.populate = function()
|
||||
{
|
||||
var Settings = require('Storage/Settings');
|
||||
|
||||
this.google.enabled(!!Settings.settingsGet('AllowGoogleSocial'));
|
||||
this.google.clientID(Settings.settingsGet('GoogleClientID'));
|
||||
this.google.clientSecret(Settings.settingsGet('GoogleClientSecret'));
|
||||
this.google.apiKey(Settings.settingsGet('GoogleApiKey'));
|
||||
|
||||
this.google.capa.auth(!!Settings.settingsGet('AllowGoogleSocialAuth'));
|
||||
this.google.capa.authFast(!!Settings.settingsGet('AllowGoogleSocialAuthFast'));
|
||||
this.google.capa.drive(!!Settings.settingsGet('AllowGoogleSocialDrive'));
|
||||
this.google.capa.preview(!!Settings.settingsGet('AllowGoogleSocialPreview'));
|
||||
|
||||
this.facebook.enabled(!!Settings.settingsGet('AllowFacebookSocial'));
|
||||
this.facebook.appID(Settings.settingsGet('FacebookAppID'));
|
||||
this.facebook.appSecret(Settings.settingsGet('FacebookAppSecret'));
|
||||
this.facebook.supported(!!Settings.settingsGet('SupportedFacebookSocial'));
|
||||
|
||||
this.twitter.enabled = ko.observable(!!Settings.settingsGet('AllowTwitterSocial'));
|
||||
this.twitter.consumerKey = ko.observable(Settings.settingsGet('TwitterConsumerKey'));
|
||||
this.twitter.consumerSecret = ko.observable(Settings.settingsGet('TwitterConsumerSecret'));
|
||||
|
||||
this.dropbox.enabled(!!Settings.settingsGet('AllowDropboxSocial'));
|
||||
this.dropbox.apiKey(Settings.settingsGet('DropboxApiKey'));
|
||||
};
|
||||
|
||||
module.exports = new SocialStore();
|
||||
|
|
|
@ -1,32 +1,26 @@
|
|||
|
||||
var
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
import {isArray} from 'Common/Utils';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
|
||||
Settings = require('Storage/Settings');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function ThemeStore()
|
||||
class ThemeStore
|
||||
{
|
||||
this.themes = ko.observableArray([]);
|
||||
this.themeBackgroundName = ko.observable('');
|
||||
this.themeBackgroundHash = ko.observable('');
|
||||
constructor() {
|
||||
this.themes = ko.observableArray([]);
|
||||
this.themeBackgroundName = ko.observable('');
|
||||
this.themeBackgroundHash = ko.observable('');
|
||||
|
||||
this.theme = ko.observable('')
|
||||
.extend({'limitedList': this.themes});
|
||||
this.theme = ko.observable('').extend({limitedList: this.themes});
|
||||
}
|
||||
|
||||
populate() {
|
||||
const themes = Settings.appSettingsGet('themes');
|
||||
|
||||
this.themes(isArray(themes) ? themes : []);
|
||||
this.theme(Settings.settingsGet('Theme'));
|
||||
this.themeBackgroundName(Settings.settingsGet('UserBackgroundName'));
|
||||
this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash'));
|
||||
}
|
||||
}
|
||||
|
||||
ThemeStore.prototype.populate = function()
|
||||
{
|
||||
var aThemes = Settings.appSettingsGet('themes');
|
||||
|
||||
this.themes(Utils.isArray(aThemes) ? aThemes : []);
|
||||
this.theme(Settings.settingsGet('Theme'));
|
||||
this.themeBackgroundName(Settings.settingsGet('UserBackgroundName'));
|
||||
this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash'));
|
||||
};
|
||||
|
||||
module.exports = new ThemeStore();
|
||||
|
|
|
@ -1,64 +1,50 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
Settings = require('Storage/Settings');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AccountUserStore()
|
||||
class AccountUserStore
|
||||
{
|
||||
this.email = ko.observable('');
|
||||
this.parentEmail = ko.observable('');
|
||||
// this.incLogin = ko.observable('');
|
||||
// this.outLogin = ko.observable('');
|
||||
constructor() {
|
||||
this.email = ko.observable('');
|
||||
this.parentEmail = ko.observable('');
|
||||
|
||||
this.signature = ko.observable('');
|
||||
this.signature = ko.observable('');
|
||||
|
||||
this.accounts = ko.observableArray([]);
|
||||
this.accounts.loading = ko.observable(false).extend({'throttle': 100});
|
||||
this.accounts = ko.observableArray([]);
|
||||
this.accounts.loading = ko.observable(false).extend({throttle: 100});
|
||||
|
||||
this.computers();
|
||||
}
|
||||
this.computers();
|
||||
}
|
||||
|
||||
AccountUserStore.prototype.computers = function()
|
||||
{
|
||||
this.accountsEmails = ko.computed(function() {
|
||||
return _.compact(_.map(this.accounts(), function(oItem) {
|
||||
return oItem ? oItem.email : null;
|
||||
}));
|
||||
}, this);
|
||||
computers() {
|
||||
this.accountsEmails = ko.computed(
|
||||
() => _.compact(_.map(this.accounts(), (item) => (item ? item.email : null))));
|
||||
|
||||
this.accountsUnreadCount = ko.computed(function() {
|
||||
|
||||
var iResult = 0;
|
||||
|
||||
// _.each(this.accounts(), function(oItem) {
|
||||
// if (oItem)
|
||||
this.accountsUnreadCount = ko.computed(() => 0);
|
||||
// this.accountsUnreadCount = ko.computed(() => {
|
||||
// let result = 0;
|
||||
// _.each(this.accounts(), (item) => {
|
||||
// if (item)
|
||||
// {
|
||||
// iResult += oItem.count();
|
||||
// result += item.count();
|
||||
// }
|
||||
// });
|
||||
// return result;
|
||||
// });
|
||||
}
|
||||
|
||||
return iResult;
|
||||
populate() {
|
||||
this.email(Settings.settingsGet('Email'));
|
||||
this.parentEmail(Settings.settingsGet('ParentEmail'));
|
||||
}
|
||||
|
||||
}, this);
|
||||
};
|
||||
|
||||
AccountUserStore.prototype.populate = function()
|
||||
{
|
||||
this.email(Settings.settingsGet('Email'));
|
||||
this.parentEmail(Settings.settingsGet('ParentEmail'));
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
AccountUserStore.prototype.isRootAccount = function()
|
||||
{
|
||||
return '' === this.parentEmail();
|
||||
};
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isRootAccount() {
|
||||
return '' === this.parentEmail();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new AccountUserStore();
|
||||
|
|
|
@ -16,8 +16,7 @@ class AppUserStore extends AbstractAppStore
|
|||
|
||||
this.focusedState = ko.observable(Focused.None);
|
||||
|
||||
this.focusedState.subscribe(function(value) {
|
||||
|
||||
this.focusedState.subscribe((value) => {
|
||||
switch (value)
|
||||
{
|
||||
case Focused.MessageList:
|
||||
|
@ -32,8 +31,7 @@ class AppUserStore extends AbstractAppStore
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.projectHash = ko.observable('');
|
||||
this.threadsAllowed = ko.observable(false);
|
||||
|
|
|
@ -1,36 +1,32 @@
|
|||
|
||||
var
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
Settings = require('Storage/Settings');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function ContactUserStore()
|
||||
class ContactUserStore
|
||||
{
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.exportingVcf = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.exportingCsv = ko.observable(false).extend({'throttle': 200});
|
||||
constructor() {
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.syncing = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.exportingVcf = ko.observable(false).extend({'throttle': 200});
|
||||
this.contacts.exportingCsv = ko.observable(false).extend({'throttle': 200});
|
||||
|
||||
this.allowContactsSync = ko.observable(false);
|
||||
this.enableContactsSync = ko.observable(false);
|
||||
this.contactsSyncUrl = ko.observable('');
|
||||
this.contactsSyncUser = ko.observable('');
|
||||
this.contactsSyncPass = ko.observable('');
|
||||
this.allowContactsSync = ko.observable(false);
|
||||
this.enableContactsSync = ko.observable(false);
|
||||
this.contactsSyncUrl = ko.observable('');
|
||||
this.contactsSyncUser = ko.observable('');
|
||||
this.contactsSyncPass = ko.observable('');
|
||||
}
|
||||
|
||||
populate() {
|
||||
this.allowContactsSync(!!Settings.settingsGet('ContactsSyncIsAllowed'));
|
||||
this.enableContactsSync(!!Settings.settingsGet('EnableContactsSync'));
|
||||
|
||||
this.contactsSyncUrl(Settings.settingsGet('ContactsSyncUrl'));
|
||||
this.contactsSyncUser(Settings.settingsGet('ContactsSyncUser'));
|
||||
this.contactsSyncPass(Settings.settingsGet('ContactsSyncPassword'));
|
||||
}
|
||||
}
|
||||
|
||||
ContactUserStore.prototype.populate = function()
|
||||
{
|
||||
this.allowContactsSync(!!Settings.settingsGet('ContactsSyncIsAllowed'));
|
||||
this.enableContactsSync(!!Settings.settingsGet('EnableContactsSync'));
|
||||
|
||||
this.contactsSyncUrl(Settings.settingsGet('ContactsSyncUrl'));
|
||||
this.contactsSyncUser(Settings.settingsGet('ContactsSyncUser'));
|
||||
this.contactsSyncPass(Settings.settingsGet('ContactsSyncPassword'));
|
||||
};
|
||||
|
||||
module.exports = new ContactUserStore();
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
|
||||
var ko = require('ko');
|
||||
import ko from 'ko';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FilterUserStore()
|
||||
class FilterUserStore
|
||||
{
|
||||
this.capa = ko.observable('');
|
||||
this.modules = ko.observable({});
|
||||
constructor() {
|
||||
this.capa = ko.observable('');
|
||||
this.modules = ko.observable({});
|
||||
|
||||
this.filters = ko.observableArray([]);
|
||||
this.filters = ko.observableArray([]);
|
||||
|
||||
this.filters.loading = ko.observable(false).extend({throttle: 200});
|
||||
this.filters.saving = ko.observable(false).extend({throttle: 200});
|
||||
this.filters.loading = ko.observable(false).extend({throttle: 200});
|
||||
this.filters.saving = ko.observable(false).extend({throttle: 200});
|
||||
|
||||
this.raw = ko.observable('');
|
||||
this.raw = ko.observable('');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new FilterUserStore();
|
||||
|
|
|
@ -1,247 +1,223 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Utils = require('Common/Utils'),
|
||||
import {FolderType} from 'Common/Enums';
|
||||
import {UNUSED_OPTION_VALUE} from 'Common/Consts';
|
||||
import {isArray, folderListOptionsBuilder} from 'Common/Utils';
|
||||
import {getFolderInboxName, getFolderFromCacheList} from 'Common/Cache';
|
||||
|
||||
Cache = require('Common/Cache');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function FolderUserStore()
|
||||
class FolderUserStore
|
||||
{
|
||||
this.displaySpecSetting = ko.observable(true);
|
||||
constructor() {
|
||||
this.displaySpecSetting = ko.observable(true);
|
||||
|
||||
this.sentFolder = ko.observable('');
|
||||
this.draftFolder = ko.observable('');
|
||||
this.spamFolder = ko.observable('');
|
||||
this.trashFolder = ko.observable('');
|
||||
this.archiveFolder = ko.observable('');
|
||||
this.sentFolder = ko.observable('');
|
||||
this.draftFolder = ko.observable('');
|
||||
this.spamFolder = ko.observable('');
|
||||
this.trashFolder = ko.observable('');
|
||||
this.archiveFolder = ko.observable('');
|
||||
|
||||
this.namespace = '';
|
||||
this.namespace = '';
|
||||
|
||||
this.folderList = ko.observableArray([]);
|
||||
this.folderList.optimized = ko.observable(false);
|
||||
this.folderList.error = ko.observable('');
|
||||
this.folderList = ko.observableArray([]);
|
||||
this.folderList.optimized = ko.observable(false);
|
||||
this.folderList.error = ko.observable('');
|
||||
|
||||
this.foldersLoading = ko.observable(false);
|
||||
this.foldersCreating = ko.observable(false);
|
||||
this.foldersDeleting = ko.observable(false);
|
||||
this.foldersRenaming = ko.observable(false);
|
||||
this.foldersLoading = ko.observable(false);
|
||||
this.foldersCreating = ko.observable(false);
|
||||
this.foldersDeleting = ko.observable(false);
|
||||
this.foldersRenaming = ko.observable(false);
|
||||
|
||||
this.foldersInboxUnreadCount = ko.observable(0);
|
||||
this.foldersInboxUnreadCount = ko.observable(0);
|
||||
|
||||
this.currentFolder = ko.observable(null).extend({toggleSubscribe: [
|
||||
null,
|
||||
function(oPrev) {
|
||||
if (oPrev) {
|
||||
oPrev.selected(false);
|
||||
this.currentFolder = ko.observable(null).extend({toggleSubscribe: [
|
||||
null,
|
||||
(prev) => {
|
||||
if (prev) {
|
||||
prev.selected(false);
|
||||
}
|
||||
},
|
||||
(next) => {
|
||||
if (next) {
|
||||
next.selected(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
function(oNext) {
|
||||
if (oNext) {
|
||||
oNext.selected(true);
|
||||
}
|
||||
}
|
||||
]});
|
||||
]});
|
||||
|
||||
this.computers();
|
||||
this.subscribers();
|
||||
this.computers();
|
||||
this.subscribers();
|
||||
}
|
||||
|
||||
computers() {
|
||||
|
||||
this.draftFolderNotEnabled = ko.computed(
|
||||
() => ('' === this.draftFolder() || UNUSED_OPTION_VALUE === this.draftFolder())
|
||||
);
|
||||
|
||||
this.foldersListWithSingleInboxRootFolder = ko.computed(
|
||||
() => !_.find(this.folderList(), (folder) => (folder && !folder.isSystemFolder() && folder.visible()))
|
||||
);
|
||||
|
||||
this.currentFolderFullNameRaw = ko.computed(
|
||||
() => (this.currentFolder() ? this.currentFolder().fullNameRaw : '')
|
||||
);
|
||||
|
||||
this.currentFolderFullName = ko.computed(() => (this.currentFolder() ? this.currentFolder().fullName : ''));
|
||||
this.currentFolderFullNameHash = ko.computed(() => (this.currentFolder() ? this.currentFolder().fullNameHash : ''));
|
||||
|
||||
this.foldersChanging = ko.computed(() => {
|
||||
const
|
||||
loading = this.foldersLoading(),
|
||||
creating = this.foldersCreating(),
|
||||
deleting = this.foldersDeleting(),
|
||||
renaming = this.foldersRenaming();
|
||||
|
||||
return loading || creating || deleting || renaming;
|
||||
});
|
||||
|
||||
this.folderListSystemNames = ko.computed(() => {
|
||||
|
||||
const
|
||||
list = [getFolderInboxName()],
|
||||
folders = this.folderList(),
|
||||
sentFolder = this.sentFolder(),
|
||||
draftFolder = this.draftFolder(),
|
||||
spamFolder = this.spamFolder(),
|
||||
trashFolder = this.trashFolder(),
|
||||
archiveFolder = this.archiveFolder();
|
||||
|
||||
if (isArray(folders) && 0 < folders.length)
|
||||
{
|
||||
if ('' !== sentFolder && UNUSED_OPTION_VALUE !== sentFolder)
|
||||
{
|
||||
list.push(sentFolder);
|
||||
}
|
||||
if ('' !== draftFolder && UNUSED_OPTION_VALUE !== draftFolder)
|
||||
{
|
||||
list.push(draftFolder);
|
||||
}
|
||||
if ('' !== spamFolder && UNUSED_OPTION_VALUE !== spamFolder)
|
||||
{
|
||||
list.push(spamFolder);
|
||||
}
|
||||
if ('' !== trashFolder && UNUSED_OPTION_VALUE !== trashFolder)
|
||||
{
|
||||
list.push(trashFolder);
|
||||
}
|
||||
if ('' !== archiveFolder && UNUSED_OPTION_VALUE !== archiveFolder)
|
||||
{
|
||||
list.push(archiveFolder);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
});
|
||||
|
||||
this.folderListSystem = ko.computed(
|
||||
() => _.compact(_.map(this.folderListSystemNames(), (name) => getFolderFromCacheList(name)))
|
||||
);
|
||||
|
||||
this.folderMenuForMove = ko.computed(
|
||||
() => folderListOptionsBuilder(
|
||||
this.folderListSystem(), this.folderList(),
|
||||
[this.currentFolderFullNameRaw()], null, null, null, null, (item) => (item ? item.localName() : ''))
|
||||
);
|
||||
|
||||
this.folderMenuForFilters = ko.computed(
|
||||
() => folderListOptionsBuilder(
|
||||
this.folderListSystem(), this.folderList(),
|
||||
['INBOX'], [['', '']], null, null, null, (item) => (item ? item.localName() : ''))
|
||||
);
|
||||
}
|
||||
|
||||
subscribers() {
|
||||
const
|
||||
fRemoveSystemFolderType = (observable) => () => {
|
||||
const folder = getFolderFromCacheList(observable());
|
||||
if (folder)
|
||||
{
|
||||
folder.type(FolderType.User);
|
||||
}
|
||||
},
|
||||
fSetSystemFolderType = (type) => (value) => {
|
||||
const folder = getFolderFromCacheList(value);
|
||||
if (folder)
|
||||
{
|
||||
folder.type(type);
|
||||
}
|
||||
};
|
||||
|
||||
this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange');
|
||||
this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange');
|
||||
this.spamFolder.subscribe(fRemoveSystemFolderType(this.spamFolder), this, 'beforeChange');
|
||||
this.trashFolder.subscribe(fRemoveSystemFolderType(this.trashFolder), this, 'beforeChange');
|
||||
this.archiveFolder.subscribe(fRemoveSystemFolderType(this.archiveFolder), this, 'beforeChange');
|
||||
|
||||
this.sentFolder.subscribe(fSetSystemFolderType(FolderType.SentItems), this);
|
||||
this.draftFolder.subscribe(fSetSystemFolderType(FolderType.Draft), this);
|
||||
this.spamFolder.subscribe(fSetSystemFolderType(FolderType.Spam), this);
|
||||
this.trashFolder.subscribe(fSetSystemFolderType(FolderType.Trash), this);
|
||||
this.archiveFolder.subscribe(fSetSystemFolderType(FolderType.Archive), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Array}
|
||||
*/
|
||||
getNextFolderNames() {
|
||||
|
||||
const
|
||||
result = [],
|
||||
limit = 5,
|
||||
utc = require('Common/Momentor').momentNowUnix(),
|
||||
timeout = utc - 60 * 5,
|
||||
timeouts = [],
|
||||
inboxFolderName = getFolderInboxName(),
|
||||
fSearchFunction = (list) => {
|
||||
_.each(list, (folder) => {
|
||||
if (folder && inboxFolderName !== folder.fullNameRaw &&
|
||||
folder.selectable && folder.existen && timeout > folder.interval &&
|
||||
(folder.isSystemFolder() || (folder.subScribed() && folder.checkable()))
|
||||
)
|
||||
{
|
||||
timeouts.push([folder.interval, folder.fullNameRaw]);
|
||||
}
|
||||
|
||||
if (folder && 0 < folder.subFolders().length)
|
||||
{
|
||||
fSearchFunction(folder.subFolders());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
fSearchFunction(this.folderList());
|
||||
|
||||
timeouts.sort((a, b) => {
|
||||
if (a[0] < b[0])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (a[0] > b[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
_.find(timeouts, (aItem) => {
|
||||
const folder = getFolderFromCacheList(aItem[1]);
|
||||
if (folder)
|
||||
{
|
||||
folder.interval = utc;
|
||||
result.push(aItem[1]);
|
||||
}
|
||||
|
||||
return limit <= result.length;
|
||||
});
|
||||
|
||||
return _.uniq(result);
|
||||
}
|
||||
}
|
||||
|
||||
FolderUserStore.prototype.computers = function()
|
||||
{
|
||||
this.draftFolderNotEnabled = ko.computed(function() {
|
||||
return '' === this.draftFolder() || Consts.UNUSED_OPTION_VALUE === this.draftFolder();
|
||||
}, this);
|
||||
|
||||
this.foldersListWithSingleInboxRootFolder = ko.computed(function() {
|
||||
return !_.find(this.folderList(), function(oFolder) {
|
||||
return oFolder && !oFolder.isSystemFolder() && oFolder.visible();
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.currentFolderFullNameRaw = ko.computed(function() {
|
||||
return this.currentFolder() ? this.currentFolder().fullNameRaw : '';
|
||||
}, this);
|
||||
|
||||
this.currentFolderFullName = ko.computed(function() {
|
||||
return this.currentFolder() ? this.currentFolder().fullName : '';
|
||||
}, this);
|
||||
|
||||
this.currentFolderFullNameHash = ko.computed(function() {
|
||||
return this.currentFolder() ? this.currentFolder().fullNameHash : '';
|
||||
}, this);
|
||||
|
||||
this.foldersChanging = ko.computed(function() {
|
||||
var
|
||||
bLoading = this.foldersLoading(),
|
||||
bCreating = this.foldersCreating(),
|
||||
bDeleting = this.foldersDeleting(),
|
||||
bRenaming = this.foldersRenaming();
|
||||
return bLoading || bCreating || bDeleting || bRenaming;
|
||||
}, this);
|
||||
|
||||
this.folderListSystemNames = ko.computed(function() {
|
||||
|
||||
var
|
||||
aList = [Cache.getFolderInboxName()],
|
||||
aFolders = this.folderList(),
|
||||
sSentFolder = this.sentFolder(),
|
||||
sDraftFolder = this.draftFolder(),
|
||||
sSpamFolder = this.spamFolder(),
|
||||
sTrashFolder = this.trashFolder(),
|
||||
sArchiveFolder = this.archiveFolder();
|
||||
|
||||
if (Utils.isArray(aFolders) && 0 < aFolders.length)
|
||||
{
|
||||
if ('' !== sSentFolder && Consts.UNUSED_OPTION_VALUE !== sSentFolder)
|
||||
{
|
||||
aList.push(sSentFolder);
|
||||
}
|
||||
if ('' !== sDraftFolder && Consts.UNUSED_OPTION_VALUE !== sDraftFolder)
|
||||
{
|
||||
aList.push(sDraftFolder);
|
||||
}
|
||||
if ('' !== sSpamFolder && Consts.UNUSED_OPTION_VALUE !== sSpamFolder)
|
||||
{
|
||||
aList.push(sSpamFolder);
|
||||
}
|
||||
if ('' !== sTrashFolder && Consts.UNUSED_OPTION_VALUE !== sTrashFolder)
|
||||
{
|
||||
aList.push(sTrashFolder);
|
||||
}
|
||||
if ('' !== sArchiveFolder && Consts.UNUSED_OPTION_VALUE !== sArchiveFolder)
|
||||
{
|
||||
aList.push(sArchiveFolder);
|
||||
}
|
||||
}
|
||||
|
||||
return aList;
|
||||
|
||||
}, this);
|
||||
|
||||
this.folderListSystem = ko.computed(function() {
|
||||
return _.compact(_.map(this.folderListSystemNames(), function(sName) {
|
||||
return Cache.getFolderFromCacheList(sName);
|
||||
}));
|
||||
}, this);
|
||||
|
||||
this.folderMenuForMove = ko.computed(function() {
|
||||
return Utils.folderListOptionsBuilder(this.folderListSystem(), this.folderList(), [
|
||||
this.currentFolderFullNameRaw()
|
||||
], null, null, null, null, function(oItem) {
|
||||
return oItem ? oItem.localName() : '';
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.folderMenuForFilters = ko.computed(function() {
|
||||
return Utils.folderListOptionsBuilder(this.folderListSystem(), this.folderList(),
|
||||
['INBOX'], [['', '']], null, null, null, function(oItem) {
|
||||
return oItem ? oItem.localName() : '';
|
||||
}
|
||||
);
|
||||
}, this);
|
||||
};
|
||||
|
||||
FolderUserStore.prototype.subscribers = function()
|
||||
{
|
||||
var
|
||||
fRemoveSystemFolderType = function(observable) {
|
||||
return function() {
|
||||
var oFolder = Cache.getFolderFromCacheList(observable());
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.type(Enums.FolderType.User);
|
||||
}
|
||||
};
|
||||
},
|
||||
fSetSystemFolderType = function(iType) {
|
||||
return function(sValue) {
|
||||
var oFolder = Cache.getFolderFromCacheList(sValue);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.type(iType);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange');
|
||||
this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange');
|
||||
this.spamFolder.subscribe(fRemoveSystemFolderType(this.spamFolder), this, 'beforeChange');
|
||||
this.trashFolder.subscribe(fRemoveSystemFolderType(this.trashFolder), this, 'beforeChange');
|
||||
this.archiveFolder.subscribe(fRemoveSystemFolderType(this.archiveFolder), this, 'beforeChange');
|
||||
|
||||
this.sentFolder.subscribe(fSetSystemFolderType(Enums.FolderType.SentItems), this);
|
||||
this.draftFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Draft), this);
|
||||
this.spamFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Spam), this);
|
||||
this.trashFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Trash), this);
|
||||
this.archiveFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Archive), this);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Array}
|
||||
*/
|
||||
FolderUserStore.prototype.getNextFolderNames = function()
|
||||
{
|
||||
var
|
||||
aResult = [],
|
||||
iLimit = 5,
|
||||
iUtc = require('Common/Momentor').momentNowUnix(),
|
||||
iTimeout = iUtc - 60 * 5,
|
||||
aTimeouts = [],
|
||||
sInboxFolderName = Cache.getFolderInboxName(),
|
||||
fSearchFunction = function(aList) {
|
||||
_.each(aList, function(oFolder) {
|
||||
if (oFolder && sInboxFolderName !== oFolder.fullNameRaw &&
|
||||
oFolder.selectable && oFolder.existen &&
|
||||
iTimeout > oFolder.interval &&
|
||||
(oFolder.isSystemFolder() || (oFolder.subScribed() && oFolder.checkable()))
|
||||
)
|
||||
{
|
||||
aTimeouts.push([oFolder.interval, oFolder.fullNameRaw]);
|
||||
}
|
||||
|
||||
if (oFolder && 0 < oFolder.subFolders().length)
|
||||
{
|
||||
fSearchFunction(oFolder.subFolders());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
fSearchFunction(this.folderList());
|
||||
|
||||
aTimeouts.sort(function(a, b) {
|
||||
if (a[0] < b[0])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (a[0] > b[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
_.find(aTimeouts, function(aItem) {
|
||||
var oFolder = Cache.getFolderFromCacheList(aItem[1]);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
aResult.push(aItem[1]);
|
||||
}
|
||||
|
||||
return iLimit <= aResult.length;
|
||||
});
|
||||
|
||||
aResult = _.uniq(aResult);
|
||||
|
||||
return aResult;
|
||||
};
|
||||
|
||||
module.exports = new FolderUserStore();
|
||||
|
|
|
@ -8,7 +8,8 @@ class IdentityUserStore
|
|||
this.identities = ko.observableArray([]);
|
||||
this.identities.loading = ko.observable(false).extend({throttle: 100});
|
||||
|
||||
this.identitiesIDS = ko.computed(() => _.compact(_.map(this.identities(), (item) => (item ? item.id : null))));
|
||||
this.identitiesIDS = ko.computed(
|
||||
() => _.compact(_.map(this.identities(), (item) => (item ? item.id : null))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,220 +1,207 @@
|
|||
|
||||
var
|
||||
window = require('window'),
|
||||
ko = require('ko'),
|
||||
import window from 'window';
|
||||
import ko from 'ko';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Events = require('Common/Events'),
|
||||
Audio = require('Common/Audio'),
|
||||
import {DesktopNotification, Magics} from 'Common/Enums';
|
||||
import * as Events from 'Common/Events';
|
||||
import Audio from 'Common/Audio';
|
||||
|
||||
Settings = require('Storage/Settings');
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function NotificationUserStore()
|
||||
class NotificationUserStore
|
||||
{
|
||||
var self = this;
|
||||
constructor() {
|
||||
this.enableSoundNotification = ko.observable(false);
|
||||
this.soundNotificationIsSupported = ko.observable(false);
|
||||
|
||||
this.enableSoundNotification = ko.observable(false);
|
||||
this.soundNotificationIsSupported = ko.observable(false);
|
||||
this.allowDesktopNotification = ko.observable(false);
|
||||
|
||||
this.allowDesktopNotification = ko.observable(false);
|
||||
this.desktopNotificationPermissions = ko.computed(() => {
|
||||
|
||||
this.desktopNotificationPermissions = ko.computed(function() {
|
||||
this.allowDesktopNotification();
|
||||
|
||||
this.allowDesktopNotification();
|
||||
let result = DesktopNotification.NotSupported;
|
||||
|
||||
var
|
||||
NotificationClass = this.notificationClass(),
|
||||
iResult = Enums.DesktopNotification.NotSupported;
|
||||
|
||||
if (NotificationClass && NotificationClass.permission)
|
||||
{
|
||||
switch (NotificationClass.permission.toLowerCase())
|
||||
const NotificationClass = this.notificationClass();
|
||||
if (NotificationClass && NotificationClass.permission)
|
||||
{
|
||||
case 'granted':
|
||||
iResult = Enums.DesktopNotification.Allowed;
|
||||
break;
|
||||
case 'denied':
|
||||
iResult = Enums.DesktopNotification.Denied;
|
||||
break;
|
||||
case 'default':
|
||||
iResult = Enums.DesktopNotification.NotAllowed;
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
}
|
||||
else if (window.webkitNotifications && window.webkitNotifications.checkPermission)
|
||||
{
|
||||
iResult = window.webkitNotifications.checkPermission();
|
||||
}
|
||||
|
||||
return iResult;
|
||||
|
||||
}, this).extend({'notify': 'always'});
|
||||
|
||||
this.enableDesktopNotification = ko.computed({
|
||||
'owner': this,
|
||||
'read': function() {
|
||||
return this.allowDesktopNotification() &&
|
||||
Enums.DesktopNotification.Allowed === this.desktopNotificationPermissions();
|
||||
},
|
||||
'write': function(bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
var
|
||||
NotificationClass = this.notificationClass(),
|
||||
iPermission = this.desktopNotificationPermissions();
|
||||
|
||||
if (NotificationClass && Enums.DesktopNotification.Allowed === iPermission)
|
||||
switch (NotificationClass.permission.toLowerCase())
|
||||
{
|
||||
this.allowDesktopNotification(true);
|
||||
case 'granted':
|
||||
result = DesktopNotification.Allowed;
|
||||
break;
|
||||
case 'denied':
|
||||
result = DesktopNotification.Denied;
|
||||
break;
|
||||
case 'default':
|
||||
result = DesktopNotification.NotAllowed;
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
else if (NotificationClass && Enums.DesktopNotification.NotAllowed === iPermission)
|
||||
}
|
||||
else if (window.webkitNotifications && window.webkitNotifications.checkPermission)
|
||||
{
|
||||
result = window.webkitNotifications.checkPermission();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}).extend({notify: 'always'});
|
||||
|
||||
this.enableDesktopNotification = ko.computed({
|
||||
read: () => this.allowDesktopNotification() && DesktopNotification.Allowed === this.desktopNotificationPermissions(),
|
||||
write: (value) => {
|
||||
if (value)
|
||||
{
|
||||
NotificationClass.requestPermission(function() {
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
if (Enums.DesktopNotification.Allowed === self.desktopNotificationPermissions())
|
||||
{
|
||||
if (self.allowDesktopNotification())
|
||||
const
|
||||
NotificationClass = this.notificationClass(),
|
||||
permission = this.desktopNotificationPermissions();
|
||||
|
||||
if (NotificationClass && DesktopNotification.Allowed === permission)
|
||||
{
|
||||
this.allowDesktopNotification(true);
|
||||
}
|
||||
else if (NotificationClass && DesktopNotification.NotAllowed === permission)
|
||||
{
|
||||
NotificationClass.requestPermission(() => {
|
||||
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
|
||||
if (DesktopNotification.Allowed === this.desktopNotificationPermissions())
|
||||
{
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
if (this.allowDesktopNotification())
|
||||
{
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowDesktopNotification(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.allowDesktopNotification(true);
|
||||
if (this.allowDesktopNotification())
|
||||
{
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (self.allowDesktopNotification())
|
||||
{
|
||||
self.allowDesktopNotification(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allowDesktopNotification(false);
|
||||
}
|
||||
}
|
||||
}).extend({'notify': 'always'});
|
||||
}).extend({notify: 'always'});
|
||||
|
||||
if (!this.enableDesktopNotification.valueHasMutated)
|
||||
{
|
||||
this.enableDesktopNotification.valueHasMutated = function() {
|
||||
self.allowDesktopNotification.valueHasMutated();
|
||||
};
|
||||
if (!this.enableDesktopNotification.valueHasMutated)
|
||||
{
|
||||
this.enableDesktopNotification.valueHasMutated = () => {
|
||||
this.allowDesktopNotification.valueHasMutated();
|
||||
};
|
||||
}
|
||||
|
||||
this.computers();
|
||||
|
||||
this.initNotificationPlayer();
|
||||
}
|
||||
|
||||
this.computers();
|
||||
computers() {
|
||||
this.isDesktopNotificationSupported = ko.computed(
|
||||
() => DesktopNotification.NotSupported !== this.desktopNotificationPermissions()
|
||||
);
|
||||
|
||||
this.initNotificationPlayer();
|
||||
this.isDesktopNotificationDenied = ko.computed(
|
||||
() => DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
|
||||
DesktopNotification.Denied === this.desktopNotificationPermissions()
|
||||
);
|
||||
}
|
||||
|
||||
initNotificationPlayer() {
|
||||
if (Audio && Audio.supportedNotification)
|
||||
{
|
||||
this.soundNotificationIsSupported(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.enableSoundNotification(false);
|
||||
this.soundNotificationIsSupported(false);
|
||||
}
|
||||
}
|
||||
|
||||
playSoundNotification(skipSetting) {
|
||||
if (Audio && Audio.supportedNotification && (skipSetting ? true : this.enableSoundNotification()))
|
||||
{
|
||||
Audio.playNotification();
|
||||
}
|
||||
}
|
||||
|
||||
displayDesktopNotification(imageSrc, title, text, nessageData) {
|
||||
if (this.enableDesktopNotification())
|
||||
{
|
||||
const
|
||||
NotificationClass = this.notificationClass(),
|
||||
notification = NotificationClass ? new NotificationClass(title, {
|
||||
body: text,
|
||||
icon: imageSrc
|
||||
}) : null;
|
||||
|
||||
if (notification)
|
||||
{
|
||||
if (notification.show)
|
||||
{
|
||||
notification.show();
|
||||
}
|
||||
|
||||
if (nessageData)
|
||||
{
|
||||
notification.onclick = () => {
|
||||
|
||||
window.focus();
|
||||
|
||||
if (nessageData.Folder && nessageData.Uid)
|
||||
{
|
||||
Events.pub('mailbox.message.show', [nessageData.Folder, nessageData.Uid]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
window.setTimeout((function(localNotifications) {
|
||||
return () => {
|
||||
if (localNotifications.cancel)
|
||||
{
|
||||
localNotifications.cancel();
|
||||
}
|
||||
else if (localNotifications.close)
|
||||
{
|
||||
localNotifications.close();
|
||||
}
|
||||
};
|
||||
}(notification)), Magics.Time7s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
populate() {
|
||||
this.enableSoundNotification(!!Settings.settingsGet('SoundNotification'));
|
||||
this.enableDesktopNotification(!!Settings.settingsGet('DesktopNotifications'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {*|null}
|
||||
*/
|
||||
notificationClass() {
|
||||
return window.Notification && window.Notification.requestPermission ? window.Notification : null;
|
||||
}
|
||||
}
|
||||
|
||||
NotificationUserStore.prototype.computers = function()
|
||||
{
|
||||
this.isDesktopNotificationSupported = ko.computed(function() {
|
||||
return Enums.DesktopNotification.NotSupported !== this.desktopNotificationPermissions();
|
||||
}, this);
|
||||
|
||||
this.isDesktopNotificationDenied = ko.computed(function() {
|
||||
return Enums.DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
|
||||
Enums.DesktopNotification.Denied === this.desktopNotificationPermissions();
|
||||
}, this);
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.initNotificationPlayer = function()
|
||||
{
|
||||
if (Audio && Audio.supportedNotification)
|
||||
{
|
||||
this.soundNotificationIsSupported(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.enableSoundNotification(false);
|
||||
this.soundNotificationIsSupported(false);
|
||||
}
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.playSoundNotification = function(bSkipSetting)
|
||||
{
|
||||
if (Audio && Audio.supportedNotification && (bSkipSetting ? true : this.enableSoundNotification()))
|
||||
{
|
||||
Audio.playNotification();
|
||||
}
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.displayDesktopNotification = function(sImageSrc, sTitle, sText, oMessageData)
|
||||
{
|
||||
if (this.enableDesktopNotification())
|
||||
{
|
||||
var
|
||||
NotificationClass = this.notificationClass(),
|
||||
oNotification = NotificationClass ? new NotificationClass(sTitle, {
|
||||
'body': sText,
|
||||
'icon': sImageSrc
|
||||
}) : null;
|
||||
|
||||
if (oNotification)
|
||||
{
|
||||
if (oNotification.show)
|
||||
{
|
||||
oNotification.show();
|
||||
}
|
||||
|
||||
if (oMessageData)
|
||||
{
|
||||
oNotification.onclick = function() {
|
||||
|
||||
window.focus();
|
||||
|
||||
if (oMessageData.Folder && oMessageData.Uid)
|
||||
{
|
||||
Events.pub('mailbox.message.show', [oMessageData.Folder, oMessageData.Uid]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
window.setTimeout((function(oLocalNotifications) {
|
||||
return function() {
|
||||
if (oLocalNotifications.cancel)
|
||||
{
|
||||
oLocalNotifications.cancel();
|
||||
}
|
||||
else if (oLocalNotifications.close)
|
||||
{
|
||||
oLocalNotifications.close();
|
||||
}
|
||||
};
|
||||
}(oNotification)), Enums.Magics.Time7s);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
NotificationUserStore.prototype.populate = function()
|
||||
{
|
||||
this.enableSoundNotification(!!Settings.settingsGet('SoundNotification'));
|
||||
this.enableDesktopNotification(!!Settings.settingsGet('DesktopNotifications'));
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {*|null}
|
||||
*/
|
||||
NotificationUserStore.prototype.notificationClass = function()
|
||||
{
|
||||
return window.Notification && window.Notification.requestPermission ? window.Notification : null;
|
||||
};
|
||||
|
||||
module.exports = new NotificationUserStore();
|
||||
|
|
|
@ -1,485 +1,403 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
$ = require('$'),
|
||||
kn = require('Knoin/Knoin'),
|
||||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
Settings = require('Storage/Settings'),
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
|
||||
Utils = require('Common/Utils');
|
||||
import {i18n} from 'Common/Translator';
|
||||
import {log, isArray, isNonEmptyArray, pString, isUnd, trim} from 'Common/Utils';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PgpUserStore()
|
||||
class PgpUserStore
|
||||
{
|
||||
this.capaOpenPGP = ko.observable(false);
|
||||
constructor() {
|
||||
this.capaOpenPGP = ko.observable(false);
|
||||
|
||||
this.openpgp = null;
|
||||
this.openpgp = null;
|
||||
|
||||
this.openpgpkeys = ko.observableArray([]);
|
||||
this.openpgpKeyring = null;
|
||||
this.openpgpkeys = ko.observableArray([]);
|
||||
this.openpgpKeyring = null;
|
||||
|
||||
this.openpgpkeysPublic = this.openpgpkeys.filter(function(oItem) {
|
||||
return !!(oItem && !oItem.isPrivate);
|
||||
});
|
||||
|
||||
this.openpgpkeysPrivate = this.openpgpkeys.filter(function(oItem) {
|
||||
return !!(oItem && oItem.isPrivate);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
PgpUserStore.prototype.isSupported = function()
|
||||
{
|
||||
return !!this.openpgp;
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findKeyByHex = function(aKeys, sHash)
|
||||
{
|
||||
return _.find(aKeys, function(oItem) {
|
||||
return sHash && oItem && (sHash === oItem.id || -1 < oItem.ids.indexOf(sHash));
|
||||
});
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPublicKeyByHex = function(sHash)
|
||||
{
|
||||
return this.findKeyByHex(this.openpgpkeysPublic(), sHash);
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPrivateKeyByHex = function(sHash)
|
||||
{
|
||||
return this.findKeyByHex(this.openpgpkeysPrivate(), sHash);
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPublicKeysByEmail = function(sEmail)
|
||||
{
|
||||
return _.compact(_.flatten(_.map(this.openpgpkeysPublic(), function(oItem) {
|
||||
var oKey = oItem && -1 < oItem.emails.indexOf(sEmail) ? oItem : null;
|
||||
return oKey ? oKey.getNativeKeys() : [null];
|
||||
}), true));
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPublicKeysBySigningKeyIds = function(aSigningKeyIds)
|
||||
{
|
||||
var self = this;
|
||||
return _.compact(_.flatten(_.map(aSigningKeyIds, function(oId) {
|
||||
var oKey = oId && oId.toHex ? self.findPublicKeyByHex(oId.toHex()) : null;
|
||||
return oKey ? oKey.getNativeKeys() : [null];
|
||||
}), true));
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findPrivateKeysByEncryptionKeyIds = function(aEncryptionKeyIds, aRecipients, bReturnWrapKeys)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
aResult = Utils.isArray(aEncryptionKeyIds) ? _.compact(_.flatten(_.map(aEncryptionKeyIds, function(oId) {
|
||||
var oKey = oId && oId.toHex ? self.findPrivateKeyByHex(oId.toHex()) : null;
|
||||
return oKey ? (bReturnWrapKeys ? [oKey] : oKey.getNativeKeys()) : [null];
|
||||
}), true)) : [];
|
||||
|
||||
if (0 === aResult.length && Utils.isNonEmptyArray(aRecipients))
|
||||
{
|
||||
aResult = _.uniq(_.compact(_.flatten(_.map(aRecipients, function(sEmail) {
|
||||
var aKeys = sEmail ? self.findAllPrivateKeysByEmailNotNative(sEmail) : null;
|
||||
return aKeys ? (bReturnWrapKeys ? aKeys : _.flatten(_.map(aKeys, function(oKey) {
|
||||
return oKey.getNativeKeys();
|
||||
}), true)) : [null];
|
||||
}), true)), function(oKey) {return oKey.id;});
|
||||
this.openpgpkeysPublic = this.openpgpkeys.filter((item) => !!(item && !item.isPrivate));
|
||||
this.openpgpkeysPrivate = this.openpgpkeys.filter((item) => !!(item && item.isPrivate));
|
||||
}
|
||||
|
||||
return aResult;
|
||||
};
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isSupported() {
|
||||
return !!this.openpgp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findPublicKeyByEmailNotNative = function(sEmail)
|
||||
{
|
||||
return _.find(this.openpgpkeysPublic(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
findKeyByHex(keys, hash) {
|
||||
return _.find(keys, (item) => (hash && item && (hash === item.id || -1 < item.ids.indexOf(hash))));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findPrivateKeyByEmailNotNative = function(sEmail)
|
||||
{
|
||||
return _.find(this.openpgpkeysPrivate(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
findPublicKeyByHex(hash) {
|
||||
return this.findKeyByHex(this.openpgpkeysPublic(), hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findAllPublicKeysByEmailNotNative = function(sEmail)
|
||||
{
|
||||
return _.filter(this.openpgpkeysPublic(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
findPrivateKeyByHex(hash) {
|
||||
return this.findKeyByHex(this.openpgpkeysPrivate(), hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findAllPrivateKeysByEmailNotNative = function(sEmail)
|
||||
{
|
||||
return _.filter(this.openpgpkeysPrivate(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
}) || null;
|
||||
};
|
||||
findPublicKeysByEmail(email) {
|
||||
return _.compact(_.flatten(_.map(this.openpgpkeysPublic(), (item) => {
|
||||
const key = item && -1 < item.emails.indexOf(email) ? item : null;
|
||||
return key ? key.getNativeKeys() : [null];
|
||||
}), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sEmail
|
||||
* @param {string=} sPassword
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findPrivateKeyByEmail = function(sEmail, sPassword)
|
||||
{
|
||||
var
|
||||
oPrivateKey = null,
|
||||
oKey = _.find(this.openpgpkeysPrivate(), function(oItem) {
|
||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
||||
});
|
||||
findPublicKeysBySigningKeyIds(signingKeyIds) {
|
||||
return _.compact(_.flatten(_.map(signingKeyIds, (id) => {
|
||||
const key = id && id.toHex ? this.findPublicKeyByHex(id.toHex()) : null;
|
||||
return key ? key.getNativeKeys() : [null];
|
||||
}), true));
|
||||
}
|
||||
|
||||
if (oKey)
|
||||
{
|
||||
try
|
||||
findPrivateKeysByEncryptionKeyIds(encryptionKeyIds, recipients, returnWrapKeys) {
|
||||
let
|
||||
result = isArray(encryptionKeyIds) ? _.compact(_.flatten(_.map(encryptionKeyIds, (id) => {
|
||||
const key = id && id.toHex ? this.findPrivateKeyByHex(id.toHex()) : null;
|
||||
return key ? (returnWrapKeys ? [key] : key.getNativeKeys()) : [null];
|
||||
}), true)) : [];
|
||||
|
||||
if (0 === result.length && isNonEmptyArray(recipients))
|
||||
{
|
||||
oPrivateKey = oKey.getNativeKeys()[0] || null;
|
||||
if (oPrivateKey)
|
||||
result = _.uniq(_.compact(_.flatten(_.map(recipients, (sEmail) => {
|
||||
const keys = sEmail ? this.findAllPrivateKeysByEmailNotNative(sEmail) : null;
|
||||
return keys ? (returnWrapKeys ? keys : _.flatten(_.map(keys, (key) => key.getNativeKeys()), true)) : [null];
|
||||
}), true)), (key) => key.id);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @returns {?}
|
||||
*/
|
||||
findPublicKeyByEmailNotNative(email) {
|
||||
return _.find(this.openpgpkeysPublic(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @returns {?}
|
||||
*/
|
||||
findPrivateKeyByEmailNotNative(email) {
|
||||
return _.find(this.openpgpkeysPrivate(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @returns {?}
|
||||
*/
|
||||
findAllPublicKeysByEmailNotNative(email) {
|
||||
return _.filter(this.openpgpkeysPublic(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @returns {?}
|
||||
*/
|
||||
findAllPrivateKeysByEmailNotNative(email) {
|
||||
return _.filter(this.openpgpkeysPrivate(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @param {string=} password
|
||||
* @returns {?}
|
||||
*/
|
||||
findPrivateKeyByEmail(email, password) {
|
||||
|
||||
let privateKey = null;
|
||||
const key = _.find(this.openpgpkeysPrivate(), (item) => (item && -1 < item.emails.indexOf(email)));
|
||||
|
||||
if (key)
|
||||
{
|
||||
try
|
||||
{
|
||||
oPrivateKey.decrypt(Utils.pString(sPassword));
|
||||
privateKey = key.getNativeKeys()[0] || null;
|
||||
if (privateKey)
|
||||
{
|
||||
privateKey.decrypt(pString(password));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
privateKey = null;
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
oPrivateKey = null;
|
||||
}
|
||||
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
return oPrivateKey;
|
||||
};
|
||||
/**
|
||||
* @param {string=} password
|
||||
* @returns {?}
|
||||
*/
|
||||
findSelfPrivateKey(password) {
|
||||
return this.findPrivateKeyByEmail(require('Stores/User/Account').email(), password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string=} sPassword
|
||||
* @returns {?}
|
||||
*/
|
||||
PgpUserStore.prototype.findSelfPrivateKey = function(sPassword)
|
||||
{
|
||||
return this.findPrivateKeyByEmail(require('Stores/User/Account').email(), sPassword);
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallback)
|
||||
{
|
||||
if (oMessage && oMessage.getEncryptionKeyIds)
|
||||
{
|
||||
var self = this,
|
||||
aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true);
|
||||
|
||||
if (aPrivateKeys && 0 < aPrivateKeys.length)
|
||||
decryptMessage(message, recipients, fCallback) {
|
||||
if (message && message.getEncryptionKeyIds)
|
||||
{
|
||||
kn.showScreenPopup(require('View/Popup/MessageOpenPgp'), [function(oDecryptedKey) {
|
||||
const privateKeys = this.findPrivateKeysByEncryptionKeyIds(message.getEncryptionKeyIds(), recipients, true);
|
||||
if (privateKeys && 0 < privateKeys.length)
|
||||
{
|
||||
showScreenPopup(require('View/Popup/MessageOpenPgp'), [(decryptedKey) => {
|
||||
|
||||
if (oDecryptedKey)
|
||||
{
|
||||
oMessage.decrypt(oDecryptedKey).then(function(oDecryptedMessage) {
|
||||
var oPrivateKey = null;
|
||||
if (oDecryptedMessage)
|
||||
{
|
||||
oPrivateKey = self.findPrivateKeyByHex(oDecryptedKey.primaryKey.keyid.toHex());
|
||||
if (oPrivateKey)
|
||||
if (decryptedKey)
|
||||
{
|
||||
message.decrypt(decryptedKey).then((decryptedMessage) => {
|
||||
let privateKey = null;
|
||||
if (decryptedMessage)
|
||||
{
|
||||
self.verifyMessage(oDecryptedMessage, function(oValidKey, aSigningKeyIds) {
|
||||
fCallback(oPrivateKey, oDecryptedMessage, oValidKey || null, aSigningKeyIds || null);
|
||||
});
|
||||
privateKey = this.findPrivateKeyByHex(decryptedKey.primaryKey.keyid.toHex());
|
||||
if (privateKey)
|
||||
{
|
||||
this.verifyMessage(decryptedMessage, (oValidKey, aSigningKeyIds) => {
|
||||
fCallback(privateKey, decryptedMessage, oValidKey || null, aSigningKeyIds || null);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(privateKey, decryptedMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(oPrivateKey, oDecryptedMessage);
|
||||
fCallback(privateKey, decryptedMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(oPrivateKey, oDecryptedMessage);
|
||||
}
|
||||
|
||||
}, function() {
|
||||
fCallback(null, null);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(null, null);
|
||||
}
|
||||
|
||||
}, aPrivateKeys]);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fCallback(null, null);
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.findKeyExternal = function(sEmail, fCallback)
|
||||
{
|
||||
if (this.openpgp.HKP && Settings.appSettingsGet('openpgpPublicKeyServer'))
|
||||
{
|
||||
var oHkp = new this.openpgp.HKP(Settings.appSettingsGet('openpgpPublicKeyServer').replace(/\/$/, ''));
|
||||
oHkp.lookup({query: sEmail}).then(function(sKey) {
|
||||
fCallback(sKey);
|
||||
}, function() {
|
||||
fCallback(null);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
fCallback(null);
|
||||
}
|
||||
};
|
||||
|
||||
PgpUserStore.prototype.verifyMessage = function(oMessage, fCallback)
|
||||
{
|
||||
if (oMessage && oMessage.getSigningKeyIds)
|
||||
{
|
||||
var aSigningKeyIds = oMessage.getSigningKeyIds();
|
||||
if (aSigningKeyIds && 0 < aSigningKeyIds.length)
|
||||
{
|
||||
var aPublicKeys = this.findPublicKeysBySigningKeyIds(aSigningKeyIds);
|
||||
if (aPublicKeys && 0 < aPublicKeys.length)
|
||||
{
|
||||
try
|
||||
{
|
||||
var
|
||||
aResult = oMessage.verify(aPublicKeys),
|
||||
oValid = _.find(_.isArray(aResult) ? aResult : [], function(oItem) {
|
||||
return oItem && oItem.valid && oItem.keyid;
|
||||
}, () => {
|
||||
fCallback(null, null);
|
||||
});
|
||||
|
||||
if (oValid && oValid.keyid && oValid.keyid && oValid.keyid.toHex)
|
||||
{
|
||||
fCallback(this.findPublicKeyByHex(oValid.keyid.toHex()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
fCallback(null, aSigningKeyIds);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fCallback(null);
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} mDom
|
||||
*/
|
||||
PgpUserStore.prototype.controlsHelper = function(mDom, oVerControl, bSuccess, sTitle, sText)
|
||||
{
|
||||
if (bSuccess)
|
||||
{
|
||||
mDom.removeClass('error').addClass('success').attr('title', sTitle);
|
||||
oVerControl.removeClass('error').addClass('success').attr('title', sTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
mDom.removeClass('success').addClass('error').attr('title', sTitle);
|
||||
oVerControl.removeClass('success').addClass('error').attr('title', sTitle);
|
||||
}
|
||||
|
||||
if (!Utils.isUnd(sText))
|
||||
{
|
||||
mDom.text(Utils.trim(sText.replace(/(\u200C|\u0002)/g, '')));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
*/
|
||||
PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMessage, aRecipients)
|
||||
{
|
||||
return function() {
|
||||
|
||||
var
|
||||
message = null,
|
||||
$this = $(this);
|
||||
|
||||
if ($this.hasClass('success'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
message = store.openpgp.message.readArmored(sArmoredMessage);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
}
|
||||
|
||||
if (message && message.getText && message.verify && message.decrypt)
|
||||
{
|
||||
store.decryptMessage(message, aRecipients, function(oValidPrivateKey, oDecryptedMessage, oValidPublicKey, aSigningKeyIds) {
|
||||
|
||||
if (oDecryptedMessage)
|
||||
{
|
||||
if (oValidPublicKey)
|
||||
{
|
||||
store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': oValidPublicKey.user + ' (' + oValidPublicKey.id + ')'
|
||||
}), oDecryptedMessage.getText());
|
||||
}
|
||||
else if (oValidPrivateKey)
|
||||
{
|
||||
var
|
||||
aKeyIds = Utils.isNonEmptyArray(aSigningKeyIds) ? aSigningKeyIds : null,
|
||||
sAdditional = aKeyIds ? _.compact(_.map(aKeyIds, function(oItem) {
|
||||
return oItem && oItem.toHex ? oItem.toHex() : null;
|
||||
})).join(', ') : '';
|
||||
|
||||
store.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') +
|
||||
(sAdditional ? ' (' + sAdditional + ')' : ''),
|
||||
oDecryptedMessage.getText());
|
||||
}
|
||||
else
|
||||
{
|
||||
store.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
fCallback(null, null);
|
||||
}
|
||||
|
||||
}, privateKeys]);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fCallback(null, null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
verifyMessage(message, fCallback) {
|
||||
if (message && message.getSigningKeyIds)
|
||||
{
|
||||
const signingKeyIds = message.getSigningKeyIds();
|
||||
if (signingKeyIds && 0 < signingKeyIds.length)
|
||||
{
|
||||
const publicKeys = this.findPublicKeysBySigningKeyIds(signingKeyIds);
|
||||
if (publicKeys && 0 < publicKeys.length)
|
||||
{
|
||||
try
|
||||
{
|
||||
const
|
||||
result = message.verify(publicKeys),
|
||||
valid = _.find(_.isArray(result) ? result : [], (item) => (item && item.valid && item.keyid));
|
||||
|
||||
if (valid && valid.keyid && valid.keyid && valid.keyid.toHex)
|
||||
{
|
||||
fCallback(this.findPublicKeyByHex(valid.keyid.toHex()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
store.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
store.controlsHelper(mDom, $this, false, Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @static
|
||||
*/
|
||||
PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage)
|
||||
{
|
||||
return function() {
|
||||
|
||||
var
|
||||
message = null,
|
||||
$this = $(this);
|
||||
|
||||
if ($this.hasClass('success') || $this.hasClass('error'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
message = store.openpgp.cleartext.readArmored(sArmoredMessage);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
}
|
||||
|
||||
if (message && message.getText && message.verify)
|
||||
{
|
||||
store.verifyMessage(message, function(oValidKey, aSigningKeyIds) {
|
||||
if (oValidKey)
|
||||
{
|
||||
store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': oValidKey.user + ' (' + oValidKey.id + ')'
|
||||
}), message.getText());
|
||||
}
|
||||
else
|
||||
{
|
||||
var
|
||||
aKeyIds = Utils.isNonEmptyArray(aSigningKeyIds) ? aSigningKeyIds : null,
|
||||
sAdditional = aKeyIds ? _.compact(_.map(aKeyIds, function(oItem) {
|
||||
return oItem && oItem.toHex ? oItem.toHex() : null;
|
||||
})).join(', ') : '';
|
||||
|
||||
store.controlsHelper(mDom, $this, false,
|
||||
Translator.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') +
|
||||
(sAdditional ? ' (' + sAdditional + ')' : ''));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
store.controlsHelper(mDom, $this, false, Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} mDom
|
||||
* @param {MessageModel} oRainLoopMessage
|
||||
*/
|
||||
PgpUserStore.prototype.initMessageBodyControls = function(mDom, oRainLoopMessage)
|
||||
{
|
||||
if (mDom && !mDom.hasClass('inited'))
|
||||
{
|
||||
mDom.addClass('inited');
|
||||
|
||||
var
|
||||
bEncrypted = mDom.hasClass('encrypted'),
|
||||
bSigned = mDom.hasClass('signed'),
|
||||
oVerControl = null,
|
||||
aRecipients = oRainLoopMessage ? oRainLoopMessage.getEmails(['from', 'to', 'cc']) : [],
|
||||
sData = '';
|
||||
|
||||
if (bEncrypted || bSigned)
|
||||
{
|
||||
sData = mDom.text();
|
||||
mDom.data('openpgp-original', sData);
|
||||
|
||||
if (bEncrypted)
|
||||
{
|
||||
oVerControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||
.attr('title', Translator.i18n('MESSAGE/PGP_ENCRYPTED_MESSAGE_DESC'))
|
||||
.on('click', PgpUserStore.domControlEncryptedClickHelper(this, mDom, sData, aRecipients));
|
||||
fCallback(null, signingKeyIds);
|
||||
return false;
|
||||
}
|
||||
else if (bSigned)
|
||||
}
|
||||
|
||||
fCallback(null);
|
||||
return false;
|
||||
}
|
||||
|
||||
controlsHelper(dom, verControl, success, title, text) {
|
||||
if (success)
|
||||
{
|
||||
dom.removeClass('error').addClass('success').attr('title', title);
|
||||
verControl.removeClass('error').addClass('success').attr('title', title);
|
||||
}
|
||||
else
|
||||
{
|
||||
dom.removeClass('success').addClass('error').attr('title', title);
|
||||
verControl.removeClass('success').addClass('error').attr('title', title);
|
||||
}
|
||||
|
||||
if (!isUnd(text))
|
||||
{
|
||||
dom.text(trim(text));
|
||||
}
|
||||
}
|
||||
|
||||
static domControlEncryptedClickHelper(store, dom, armoredMessage, recipients) {
|
||||
|
||||
return function() {
|
||||
|
||||
let message = null;
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
|
||||
if ($this.hasClass('success'))
|
||||
{
|
||||
oVerControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||
.attr('title', Translator.i18n('MESSAGE/PGP_SIGNED_MESSAGE_DESC'))
|
||||
.on('click', PgpUserStore.domControlSignedClickHelper(this, mDom, sData));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (oVerControl)
|
||||
try
|
||||
{
|
||||
mDom.before(oVerControl).before('<div></div>');
|
||||
message = store.openpgp.message.readArmored(armoredMessage);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
log(e);
|
||||
}
|
||||
|
||||
if (message && message.getText && message.verify && message.decrypt)
|
||||
{
|
||||
store.decryptMessage(message, recipients, (validPrivateKey, decryptedMessage, validPublicKey, signingKeyIds) => {
|
||||
if (decryptedMessage)
|
||||
{
|
||||
if (validPublicKey)
|
||||
{
|
||||
store.controlsHelper(dom, $this, true, i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': validPublicKey.user + ' (' + validPublicKey.id + ')'
|
||||
}), decryptedMessage.getText());
|
||||
}
|
||||
else if (validPrivateKey)
|
||||
{
|
||||
const
|
||||
keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||
additional = keyIds ? _.compact(_.map(keyIds,
|
||||
(item) => (item && item.toHex ? item.toHex() : null))).join(', ') : '';
|
||||
|
||||
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') +
|
||||
(additional ? ' (' + additional + ')' : ''), decryptedMessage.getText());
|
||||
}
|
||||
else
|
||||
{
|
||||
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
static domControlSignedClickHelper(store, dom, armoredMessage) {
|
||||
|
||||
return function() {
|
||||
|
||||
let message = null;
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
|
||||
if ($this.hasClass('success') || $this.hasClass('error'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
message = store.openpgp.cleartext.readArmored(armoredMessage);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
log(e);
|
||||
}
|
||||
|
||||
if (message && message.getText && message.verify)
|
||||
{
|
||||
store.verifyMessage(message, (validKey, signingKeyIds) => {
|
||||
if (validKey)
|
||||
{
|
||||
store.controlsHelper(dom, $this, true, i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': validKey.user + ' (' + validKey.id + ')'
|
||||
}), message.getText());
|
||||
}
|
||||
else
|
||||
{
|
||||
const
|
||||
keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||
additional = keyIds ? _.compact(_.map(keyIds, (item) => (item && item.toHex ? item.toHex() : null))).join(', ') : '';
|
||||
|
||||
store.controlsHelper(dom, $this, false,
|
||||
i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') + (additional ? ' (' + additional + ')' : ''));
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} dom
|
||||
* @param {MessageModel} rainLoopMessage
|
||||
*/
|
||||
initMessageBodyControls(dom, rainLoopMessage) {
|
||||
if (dom && !dom.hasClass('inited'))
|
||||
{
|
||||
dom.addClass('inited');
|
||||
|
||||
const
|
||||
encrypted = dom.hasClass('encrypted'),
|
||||
signed = dom.hasClass('signed'),
|
||||
recipients = rainLoopMessage ? rainLoopMessage.getEmails(['from', 'to', 'cc']) : [];
|
||||
|
||||
let verControl = null;
|
||||
|
||||
if (encrypted || signed)
|
||||
{
|
||||
const domText = dom.text();
|
||||
dom.data('openpgp-original', domText);
|
||||
|
||||
if (encrypted)
|
||||
{
|
||||
verControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||
.attr('title', i18n('MESSAGE/PGP_ENCRYPTED_MESSAGE_DESC'))
|
||||
.on('click', PgpUserStore.domControlEncryptedClickHelper(this, dom, domText, recipients));
|
||||
}
|
||||
else if (signed)
|
||||
{
|
||||
verControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||
.attr('title', i18n('MESSAGE/PGP_SIGNED_MESSAGE_DESC'))
|
||||
.on('click', PgpUserStore.domControlSignedClickHelper(this, dom, domText));
|
||||
}
|
||||
|
||||
if (verControl)
|
||||
{
|
||||
dom.before(verControl).before('<div></div>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = new PgpUserStore();
|
||||
|
|
|
@ -1,35 +1,32 @@
|
|||
|
||||
var
|
||||
window = require('window'),
|
||||
ko = require('ko');
|
||||
import window from 'window';
|
||||
import ko from 'ko';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function QuotaUserStore()
|
||||
class QuotaUserStore
|
||||
{
|
||||
this.quota = ko.observable(0);
|
||||
this.usage = ko.observable(0);
|
||||
constructor() {
|
||||
this.quota = ko.observable(0);
|
||||
this.usage = ko.observable(0);
|
||||
|
||||
this.percentage = ko.computed(function() {
|
||||
this.percentage = ko.computed(() => {
|
||||
|
||||
var
|
||||
iQuota = this.quota(),
|
||||
iUsed = this.usage();
|
||||
const
|
||||
quota = this.quota(),
|
||||
usage = this.usage();
|
||||
|
||||
return 0 < iQuota ? window.Math.ceil((iUsed / iQuota) * 100) : 0;
|
||||
return 0 < quota ? window.Math.ceil((usage / quota) * 100) : 0;
|
||||
|
||||
}, this);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} quota
|
||||
* @param {number} usage
|
||||
*/
|
||||
populateData(quota, usage) {
|
||||
this.quota(quota * 1024);
|
||||
this.usage(usage * 1024);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} iQuota
|
||||
* @param {number} iUsage
|
||||
*/
|
||||
QuotaUserStore.prototype.populateData = function(iQuota, iUsage)
|
||||
{
|
||||
this.quota(iQuota * 1024);
|
||||
this.usage(iUsage * 1024);
|
||||
};
|
||||
|
||||
module.exports = new QuotaUserStore();
|
||||
|
|
|
@ -1,93 +1,81 @@
|
|||
|
||||
var
|
||||
window = require('window'),
|
||||
ko = require('ko'),
|
||||
import window from 'window';
|
||||
import ko from 'ko';
|
||||
|
||||
Consts = require('Common/Consts'),
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Events = require('Common/Events'),
|
||||
import {MESSAGES_PER_PAGE, MESSAGES_PER_PAGE_VALUES} from 'Common/Consts';
|
||||
import {Layout, EditorDefaultType, Magics} from 'Common/Enums';
|
||||
import {$html} from 'Common/Globals';
|
||||
import {pInt} from 'Common/Utils';
|
||||
import * as Events from 'Common/Events';
|
||||
|
||||
Settings = require('Storage/Settings');
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function SettingsUserStore()
|
||||
class SettingsUserStore
|
||||
{
|
||||
this.iAutoLogoutTimer = 0;
|
||||
constructor() {
|
||||
|
||||
this.layout = ko.observable(Enums.Layout.SidePreview)
|
||||
.extend({'limitedList': [
|
||||
Enums.Layout.SidePreview, Enums.Layout.BottomPreview, Enums.Layout.NoPreview
|
||||
]});
|
||||
this.iAutoLogoutTimer = 0;
|
||||
|
||||
this.editorDefaultType = ko.observable(Enums.EditorDefaultType.Html)
|
||||
.extend({'limitedList': [
|
||||
Enums.EditorDefaultType.Html, Enums.EditorDefaultType.Plain,
|
||||
Enums.EditorDefaultType.HtmlForced, Enums.EditorDefaultType.PlainForced
|
||||
]});
|
||||
this.layout = ko.observable(Layout.SidePreview)
|
||||
.extend({limitedList: [Layout.SidePreview, Layout.BottomPreview, Layout.NoPreview]});
|
||||
|
||||
this.messagesPerPage = ko.observable(Consts.MESSAGES_PER_PAGE)
|
||||
.extend({'limitedList': Consts.MESSAGES_PER_PAGE_VALUES});
|
||||
this.editorDefaultType = ko.observable(EditorDefaultType.Html)
|
||||
.extend({limitedList: [
|
||||
EditorDefaultType.Html, EditorDefaultType.Plain,
|
||||
EditorDefaultType.HtmlForced, EditorDefaultType.PlainForced
|
||||
]});
|
||||
|
||||
this.showImages = ko.observable(false);
|
||||
this.useCheckboxesInList = ko.observable(true);
|
||||
this.useThreads = ko.observable(false);
|
||||
this.replySameFolder = ko.observable(false);
|
||||
this.messagesPerPage = ko.observable(MESSAGES_PER_PAGE)
|
||||
.extend({limitedList: MESSAGES_PER_PAGE_VALUES});
|
||||
|
||||
this.autoLogout = ko.observable(30);
|
||||
this.showImages = ko.observable(false);
|
||||
this.useCheckboxesInList = ko.observable(true);
|
||||
this.useThreads = ko.observable(false);
|
||||
this.replySameFolder = ko.observable(false);
|
||||
|
||||
this.computers();
|
||||
this.subscribers();
|
||||
this.autoLogout = ko.observable(30);
|
||||
|
||||
this.computers();
|
||||
this.subscribers();
|
||||
}
|
||||
|
||||
computers() {
|
||||
this.usePreviewPane = ko.computed(() => Layout.NoPreview !== this.layout());
|
||||
}
|
||||
|
||||
subscribers() {
|
||||
this.layout.subscribe((nValue) => {
|
||||
$html.toggleClass('rl-no-preview-pane', Layout.NoPreview === nValue);
|
||||
$html.toggleClass('rl-side-preview-pane', Layout.SidePreview === nValue);
|
||||
$html.toggleClass('rl-bottom-preview-pane', Layout.BottomPreview === nValue);
|
||||
Events.pub('layout', [nValue]);
|
||||
});
|
||||
}
|
||||
|
||||
populate() {
|
||||
this.layout(pInt(Settings.settingsGet('Layout')));
|
||||
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
|
||||
|
||||
this.autoLogout(pInt(Settings.settingsGet('AutoLogout')));
|
||||
this.messagesPerPage(Settings.settingsGet('MPP'));
|
||||
|
||||
this.showImages(!!Settings.settingsGet('ShowImages'));
|
||||
this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList'));
|
||||
this.useThreads(!!Settings.settingsGet('UseThreads'));
|
||||
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
|
||||
|
||||
Events.sub('rl.auto-logout-refresh', () => {
|
||||
window.clearTimeout(this.iAutoLogoutTimer);
|
||||
if (0 < this.autoLogout() && !Settings.settingsGet('AccountSignMe'))
|
||||
{
|
||||
this.iAutoLogoutTimer = window.setTimeout(() => {
|
||||
Events.pub('rl.auto-logout');
|
||||
}, this.autoLogout() * Magics.Time1m);
|
||||
}
|
||||
});
|
||||
|
||||
Events.pub('rl.auto-logout-refresh');
|
||||
}
|
||||
}
|
||||
|
||||
SettingsUserStore.prototype.computers = function()
|
||||
{
|
||||
this.usePreviewPane = ko.computed(function() {
|
||||
return Enums.Layout.NoPreview !== this.layout();
|
||||
}, this);
|
||||
};
|
||||
|
||||
SettingsUserStore.prototype.subscribers = function()
|
||||
{
|
||||
this.layout.subscribe(function(nValue) {
|
||||
|
||||
Globals.$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === nValue);
|
||||
Globals.$html.toggleClass('rl-side-preview-pane', Enums.Layout.SidePreview === nValue);
|
||||
Globals.$html.toggleClass('rl-bottom-preview-pane', Enums.Layout.BottomPreview === nValue);
|
||||
|
||||
Events.pub('layout', [nValue]);
|
||||
});
|
||||
};
|
||||
|
||||
SettingsUserStore.prototype.populate = function()
|
||||
{
|
||||
this.layout(Utils.pInt(Settings.settingsGet('Layout')));
|
||||
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
|
||||
|
||||
this.autoLogout(Utils.pInt(Settings.settingsGet('AutoLogout')));
|
||||
this.messagesPerPage(Settings.settingsGet('MPP'));
|
||||
|
||||
this.showImages(!!Settings.settingsGet('ShowImages'));
|
||||
this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList'));
|
||||
this.useThreads(!!Settings.settingsGet('UseThreads'));
|
||||
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
|
||||
|
||||
var self = this;
|
||||
|
||||
Events.sub('rl.auto-logout-refresh', function() {
|
||||
window.clearTimeout(self.iAutoLogoutTimer);
|
||||
if (0 < self.autoLogout() && !Settings.settingsGet('AccountSignMe'))
|
||||
{
|
||||
self.iAutoLogoutTimer = window.setTimeout(function() {
|
||||
Events.pub('rl.auto-logout');
|
||||
}, self.autoLogout() * Enums.Magics.Time1m);
|
||||
}
|
||||
});
|
||||
|
||||
Events.pub('rl.auto-logout-refresh');
|
||||
};
|
||||
|
||||
module.exports = new SettingsUserStore();
|
||||
|
|
|
@ -1,33 +1,28 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko');
|
||||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
|
||||
// Remote = require('Remote/User/Ajax');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function TemplateUserStore()
|
||||
class TemplateUserStore
|
||||
{
|
||||
this.templates = ko.observableArray([]);
|
||||
this.templates.loading = ko.observable(false).extend({'throttle': 100});
|
||||
constructor() {
|
||||
this.templates = ko.observableArray([]);
|
||||
this.templates.loading = ko.observable(false).extend({throttle: 100});
|
||||
|
||||
this.templatesNames = ko.observableArray([]).extend({'throttle': 1000});
|
||||
this.templatesNames.skipFirst = true;
|
||||
this.templatesNames = ko.observableArray([]).extend({throttle: 1000});
|
||||
this.templatesNames.skipFirst = true;
|
||||
|
||||
this.subscribers();
|
||||
}
|
||||
this.subscribers();
|
||||
}
|
||||
|
||||
TemplateUserStore.prototype.subscribers = function()
|
||||
{
|
||||
this.templates.subscribe(function(aList) {
|
||||
this.templatesNames(_.compact(_.map(aList, function(oItem) {
|
||||
return oItem ? oItem.name : null;
|
||||
})));
|
||||
}, this);
|
||||
subscribers() {
|
||||
|
||||
// this.templatesNames.subscribe(function(aList) {
|
||||
this.templates.subscribe((list) => {
|
||||
this.templatesNames(_.compact(_.map(list, (item) => (item ? item.name : null))));
|
||||
});
|
||||
|
||||
// this.templatesNames.subscribe((aList) => {
|
||||
// if (this.templatesNames.skipFirst)
|
||||
// {
|
||||
// this.templatesNames.skipFirst = false;
|
||||
|
@ -36,7 +31,8 @@ TemplateUserStore.prototype.subscribers = function()
|
|||
// {
|
||||
// Remote.templatesSortOrder(null, aList);
|
||||
// }
|
||||
// }, this);
|
||||
};
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new TemplateUserStore();
|
||||
|
|
|
@ -45,10 +45,10 @@ html.no-css .thm-body {
|
|||
html.no-css .thm-loading {
|
||||
color: #333 !important;
|
||||
text-shadow: none !important;
|
||||
}
|
||||
|
||||
.e-spinner .e-bounce {
|
||||
display: none !important;
|
||||
}
|
||||
html.no-css .thm-loading .e-spinner .e-bounce {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
html.no-css .thm-login-desc .desc {
|
||||
|
|
|
@ -73,6 +73,15 @@ html {
|
|||
|
||||
html.rl-anim {
|
||||
|
||||
.rl-animated-visible {
|
||||
opacity: 1;
|
||||
.transition(opacity 0.5s linear);
|
||||
|
||||
&.rl-animated-hidden {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&.cssanimations.csstransitions.no-mobile .b-login-content .errorAnimated {
|
||||
animation: login-form-shake 400ms ease-in-out;
|
||||
}
|
||||
|
|
|
@ -93,3 +93,10 @@ svg-icon {
|
|||
.btn .btn-text {
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
.active-scale-transition {
|
||||
transition: transform .2s;
|
||||
&:active {
|
||||
transform: scale(.95);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,141 +1,131 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
import _ from '_';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
import {
|
||||
trim, createCommand,
|
||||
triggerAutocompleteInputChange
|
||||
} from 'Common/Utils';
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
import {StorageResultType, Notification, Magics} from 'Common/Enums';
|
||||
import {getNotification} from 'Common/Translator';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function LoginAdminView()
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
import {view, ViewType, routeOff} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
name: 'View/Admin/Login',
|
||||
type: ViewType.Center,
|
||||
templateID: 'AdminLogin'
|
||||
})
|
||||
class LoginAdminView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Center', 'AdminLogin');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.logoPowered = !!Settings.settingsGet('LoginPowered');
|
||||
this.logoPowered = !!Settings.settingsGet('LoginPowered');
|
||||
|
||||
this.mobile = !!Settings.appSettingsGet('mobile');
|
||||
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
||||
this.mobile = !!Settings.appSettingsGet('mobile');
|
||||
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
||||
|
||||
this.login = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.login = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
|
||||
this.loginError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
this.loginError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.loginErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.loginErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
|
||||
|
||||
this.loginFocus = ko.observable(false);
|
||||
this.loginFocus = ko.observable(false);
|
||||
|
||||
this.formHidden = ko.observable(false);
|
||||
this.formHidden = ko.observable(false);
|
||||
|
||||
this.formError = ko.computed(function() {
|
||||
return this.loginErrorAnimation() || this.passwordErrorAnimation();
|
||||
}, this);
|
||||
this.formError = ko.computed(() => this.loginErrorAnimation() || this.passwordErrorAnimation());
|
||||
|
||||
this.login.subscribe(function() {
|
||||
this.loginError(false);
|
||||
}, this);
|
||||
this.login.subscribe(() => this.loginError(false));
|
||||
|
||||
this.password.subscribe(function() {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
this.password.subscribe(() => this.passwordError(false));
|
||||
|
||||
this.loginError.subscribe(function(bV) {
|
||||
this.loginErrorAnimation(!!bV);
|
||||
}, this);
|
||||
this.loginError.subscribe((v) => this.loginErrorAnimation(!!v));
|
||||
|
||||
this.passwordError.subscribe(function(bV) {
|
||||
this.passwordErrorAnimation(!!bV);
|
||||
}, this);
|
||||
this.passwordError.subscribe((v) => {
|
||||
this.passwordErrorAnimation(!!v);
|
||||
});
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
|
||||
this.submitCommand = Utils.createCommand(this, function() {
|
||||
this.submitCommand = createCommand(() => {
|
||||
|
||||
Utils.triggerAutocompleteInputChange();
|
||||
triggerAutocompleteInputChange();
|
||||
|
||||
this.loginError(false);
|
||||
this.passwordError(false);
|
||||
this.loginError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.loginError('' === Utils.trim(this.login()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
this.loginError('' === trim(this.login()));
|
||||
this.passwordError('' === trim(this.password()));
|
||||
|
||||
if (this.loginError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.adminLogin(_.bind(function(sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
|
||||
if (this.loginError() || this.passwordError())
|
||||
{
|
||||
if (oData.Result)
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.adminLogin((sResult, oData) => {
|
||||
|
||||
if (StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
|
||||
{
|
||||
require('App/Admin').default.loginAndLogoutReload(true);
|
||||
if (oData.Result)
|
||||
{
|
||||
getApp().loginAndLogoutReload(true);
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.login(), this.password());
|
||||
}, this.login(), this.password());
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
}, function() {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
}, () => !this.submitRequest());
|
||||
}
|
||||
|
||||
kn.constructorEnd(this);
|
||||
onShow() {
|
||||
|
||||
routeOff();
|
||||
|
||||
_.delay(() => {
|
||||
this.loginFocus(true);
|
||||
}, Magics.Time100ms);
|
||||
}
|
||||
|
||||
onHide() {
|
||||
this.loginFocus(false);
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
triggerAutocompleteInputChange(true);
|
||||
}
|
||||
|
||||
submitForm() {
|
||||
this.submitCommand();
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Login', 'AdminLoginViewModel'], LoginAdminView);
|
||||
_.extend(LoginAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
LoginAdminView.prototype.onShow = function()
|
||||
{
|
||||
kn.routeOff();
|
||||
|
||||
_.delay(_.bind(function() {
|
||||
this.loginFocus(true);
|
||||
}, this), Enums.Magics.Time100ms);
|
||||
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.onHide = function()
|
||||
{
|
||||
this.loginFocus(false);
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.onBuild = function()
|
||||
{
|
||||
Utils.triggerAutocompleteInputChange(true);
|
||||
};
|
||||
|
||||
LoginAdminView.prototype.submitForm = function()
|
||||
{
|
||||
this.submitCommand();
|
||||
};
|
||||
|
||||
module.exports = LoginAdminView;
|
||||
export {LoginAdminView, LoginAdminView as default};
|
||||
|
|
|
@ -1,69 +1,66 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
key = require('key'),
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import key from 'key';
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Enums = require('Common/Enums'),
|
||||
import {leftPanelDisabled} from 'Common/Globals';
|
||||
import {Magics} from 'Common/Enums';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType, setHash} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {?} oScreen
|
||||
*
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function MenuSettingsAdminView(oScreen)
|
||||
@view({
|
||||
name: 'View/Admin/Settings/Menu',
|
||||
type: ViewType.Left,
|
||||
templateID: 'AdminMenu'
|
||||
})
|
||||
class MenuSettingsAdminView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Left', 'AdminMenu');
|
||||
/**
|
||||
* @param {?} screen
|
||||
*/
|
||||
constructor(screen) {
|
||||
|
||||
this.leftPanelDisabled = Globals.leftPanelDisabled;
|
||||
super();
|
||||
|
||||
this.menu = oScreen.menu;
|
||||
this.leftPanelDisabled = leftPanelDisabled;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
this.menu = screen.menu;
|
||||
}
|
||||
|
||||
link(route) {
|
||||
return '#/' + route;
|
||||
}
|
||||
|
||||
onBuild(dom) {
|
||||
|
||||
key('up, down', _.throttle((event, handler) => {
|
||||
|
||||
const
|
||||
up = handler && 'up' === handler.shortcut,
|
||||
$items = $('.b-admin-menu .e-item', dom);
|
||||
|
||||
if (event && $items.length)
|
||||
{
|
||||
let index = $items.index($items.filter('.selected'));
|
||||
if (up && 0 < index)
|
||||
{
|
||||
index -= 1;
|
||||
}
|
||||
else if (!up && index < $items.length - 1)
|
||||
{
|
||||
index += 1;
|
||||
}
|
||||
|
||||
const sH = $items.eq(index).attr('href');
|
||||
if (sH)
|
||||
{
|
||||
setHash(sH, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
}, Magics.Time200ms));
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Settings/Menu', 'AdminSettingsMenuViewModel'], MenuSettingsAdminView);
|
||||
_.extend(MenuSettingsAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
MenuSettingsAdminView.prototype.link = function(sRoute)
|
||||
{
|
||||
return '#/' + sRoute;
|
||||
};
|
||||
|
||||
MenuSettingsAdminView.prototype.onBuild = function(oDom)
|
||||
{
|
||||
key('up, down', _.throttle(function(event, handler) {
|
||||
|
||||
var
|
||||
sH = '',
|
||||
bUp = handler && 'up' === handler.shortcut,
|
||||
$items = $('.b-admin-menu .e-item', oDom);
|
||||
|
||||
if (event && $items.length)
|
||||
{
|
||||
var index = $items.index($items.filter('.selected'));
|
||||
if (bUp && 0 < index)
|
||||
{
|
||||
index -= 1;
|
||||
}
|
||||
else if (!bUp && index < $items.length - 1)
|
||||
{
|
||||
index += 1;
|
||||
}
|
||||
|
||||
sH = $items.eq(index).attr('href');
|
||||
if (sH)
|
||||
{
|
||||
kn.setHash(sH, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
}, Enums.Magics.Time200ms));
|
||||
};
|
||||
|
||||
module.exports = MenuSettingsAdminView;
|
||||
export {MenuSettingsAdminView, MenuSettingsAdminView as default};
|
||||
|
|
|
@ -1,51 +1,55 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
import ko from 'ko';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function PaneSettingsAdminView()
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import DomainStore from 'Stores/Admin/Domain';
|
||||
import PluginStore from 'Stores/Admin/Plugin';
|
||||
import PackageStore from 'Stores/Admin/Package';
|
||||
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
name: 'View/Admin/Settings/Pane',
|
||||
type: ViewType.Right,
|
||||
templateID: 'AdminPane'
|
||||
})
|
||||
class PaneSettingsAdminView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Right', 'AdminPane');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain'));
|
||||
this.version = ko.observable(Settings.appSettingsGet('version'));
|
||||
this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain'));
|
||||
this.version = ko.observable(Settings.appSettingsGet('version'));
|
||||
|
||||
this.capa = !!Settings.settingsGet('PremType');
|
||||
this.community = RL_COMMUNITY;
|
||||
this.capa = !!Settings.settingsGet('PremType');
|
||||
this.community = RL_COMMUNITY;
|
||||
|
||||
this.adminManLoading = ko.computed(function() {
|
||||
return '000' !== [
|
||||
require('Stores/Admin/Domain').domains.loading() ? '1' : '0',
|
||||
require('Stores/Admin/Plugin').plugins.loading() ? '1' : '0',
|
||||
require('Stores/Admin/Package').packages.loading() ? '1' : '0'
|
||||
].join('');
|
||||
}, this);
|
||||
this.adminManLoading = ko.computed(
|
||||
() => '000' !== [
|
||||
DomainStore.domains.loading() ? '1' : '0',
|
||||
PluginStore.plugins.loading() ? '1' : '0',
|
||||
PackageStore.packages.loading() ? '1' : '0'
|
||||
].join('')
|
||||
);
|
||||
|
||||
this.adminManLoadingVisibility = ko.computed(function() {
|
||||
return this.adminManLoading() ? 'visible' : 'hidden';
|
||||
}, this).extend({'rateLimit': 300});
|
||||
this.adminManLoadingVisibility = ko.computed(
|
||||
() => (this.adminManLoading() ? 'visible' : 'hidden')
|
||||
).extend({rateLimit: 300});
|
||||
}
|
||||
|
||||
kn.constructorEnd(this);
|
||||
logoutClick() {
|
||||
Remote.adminLogout(() => {
|
||||
getApp().loginAndLogoutReload(true, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Admin/Settings/Pane', 'AdminSettingsPaneViewModel'], PaneSettingsAdminView);
|
||||
_.extend(PaneSettingsAdminView.prototype, AbstractView.prototype);
|
||||
|
||||
PaneSettingsAdminView.prototype.logoutClick = function()
|
||||
{
|
||||
Remote.adminLogout(function() {
|
||||
require('App/Admin').default.loginAndLogoutReload(true, true);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = PaneSettingsAdminView;
|
||||
export {PaneSettingsAdminView, PaneSettingsAdminView as default};
|
||||
|
|
|
@ -1,128 +1,121 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {trim, createCommand} from 'Common/Utils';
|
||||
import {getNotification} from 'Common/Translator';
|
||||
|
||||
Remote = require('Remote/User/Ajax'),
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AccountPopupView()
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
name: 'View/Popup/Account',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsAccount'
|
||||
})
|
||||
class AccountPopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAccount');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.isNew = ko.observable(true);
|
||||
this.isNew = ko.observable(true);
|
||||
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
this.email = ko.observable('');
|
||||
this.password = ko.observable('');
|
||||
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
this.emailError = ko.observable(false);
|
||||
this.passwordError = ko.observable(false);
|
||||
|
||||
this.email.subscribe(function() {
|
||||
this.emailError(false);
|
||||
}, this);
|
||||
this.email.subscribe(() => {
|
||||
this.emailError(false);
|
||||
});
|
||||
|
||||
this.password.subscribe(function() {
|
||||
this.passwordError(false);
|
||||
}, this);
|
||||
this.password.subscribe(() => {
|
||||
this.passwordError(false);
|
||||
});
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
this.submitErrorAdditional = ko.observable('');
|
||||
this.submitRequest = ko.observable(false);
|
||||
this.submitError = ko.observable('');
|
||||
this.submitErrorAdditional = ko.observable('');
|
||||
|
||||
this.emailFocus = ko.observable(false);
|
||||
this.emailFocus = ko.observable(false);
|
||||
|
||||
this.addAccountCommand = Utils.createCommand(this, function() {
|
||||
this.addAccountCommand = createCommand(() => {
|
||||
|
||||
this.emailError('' === Utils.trim(this.email()));
|
||||
this.passwordError('' === Utils.trim(this.password()));
|
||||
this.emailError('' === trim(this.email()));
|
||||
this.passwordError('' === trim(this.password()));
|
||||
|
||||
if (this.emailError() || this.passwordError())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.accountSetup(_.bind(function(sResult, oData) {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
if (this.emailError() || this.passwordError())
|
||||
{
|
||||
if (oData.Result)
|
||||
return false;
|
||||
}
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.accountSetup((result, data) => {
|
||||
|
||||
this.submitRequest(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
{
|
||||
require('App/User').default.accountsAndIdentities();
|
||||
this.cancelCommand();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) :
|
||||
Translator.getNotification(Enums.Notification.UnknownError));
|
||||
|
||||
if (oData.ErrorMessageAdditional)
|
||||
{
|
||||
this.submitErrorAdditional(oData.ErrorMessageAdditional);
|
||||
}
|
||||
this.submitError(getNotification(Notification.UnknownError));
|
||||
this.submitErrorAdditional('');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
this.submitErrorAdditional('');
|
||||
}
|
||||
|
||||
}, this), this.email(), this.password(), this.isNew());
|
||||
}, this.email(), this.password(), this.isNew());
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
}, function() {
|
||||
return !this.submitRequest();
|
||||
});
|
||||
}, () => !this.submitRequest());
|
||||
}
|
||||
|
||||
kn.constructorEnd(this);
|
||||
clearPopup() {
|
||||
this.isNew(true);
|
||||
|
||||
this.email('');
|
||||
this.password('');
|
||||
|
||||
this.emailError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
this.submitErrorAdditional('');
|
||||
}
|
||||
|
||||
onShow(account) {
|
||||
this.clearPopup();
|
||||
if (account && account.canBeEdit())
|
||||
{
|
||||
this.isNew(false);
|
||||
this.email(account.email);
|
||||
}
|
||||
}
|
||||
|
||||
onShowWithDelay() {
|
||||
this.emailFocus(true);
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Account', 'View/Popup/AddAccount', 'PopupsAddAccountViewModel'], AccountPopupView);
|
||||
_.extend(AccountPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AccountPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.isNew(true);
|
||||
|
||||
this.email('');
|
||||
this.password('');
|
||||
|
||||
this.emailError(false);
|
||||
this.passwordError(false);
|
||||
|
||||
this.submitRequest(false);
|
||||
this.submitError('');
|
||||
this.submitErrorAdditional('');
|
||||
};
|
||||
|
||||
AccountPopupView.prototype.onShow = function(oAccount)
|
||||
{
|
||||
this.clearPopup();
|
||||
if (oAccount && oAccount.canBeEdit())
|
||||
{
|
||||
this.isNew(false);
|
||||
this.email(oAccount.email);
|
||||
}
|
||||
};
|
||||
|
||||
AccountPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.emailFocus(true);
|
||||
};
|
||||
|
||||
module.exports = AccountPopupView;
|
||||
|
|
|
@ -1,143 +1,130 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Consts = require('Common/Consts'),
|
||||
Translator = require('Common/Translator'),
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {trim, isUnd, createCommand} from 'Common/Utils';
|
||||
import {RAINLOOP_TRIAL_KEY} from 'Common/Consts';
|
||||
import {i18n, getNotification} from 'Common/Translator';
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
LicenseStore = require('Stores/Admin/License'),
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
import LicenseStore from 'Stores/Admin/License';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ActivatePopupView()
|
||||
@view({
|
||||
name: 'View/Popup/Activate',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsActivate'
|
||||
})
|
||||
class ActivatePopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsActivate');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
var self = this;
|
||||
this.domain = ko.observable('');
|
||||
this.key = ko.observable('');
|
||||
this.key.focus = ko.observable(false);
|
||||
this.activationSuccessed = ko.observable(false);
|
||||
|
||||
this.domain = ko.observable('');
|
||||
this.key = ko.observable('');
|
||||
this.key.focus = ko.observable(false);
|
||||
this.activationSuccessed = ko.observable(false);
|
||||
this.licenseTrigger = LicenseStore.licenseTrigger;
|
||||
|
||||
this.licenseTrigger = LicenseStore.licenseTrigger;
|
||||
this.activateProcess = ko.observable(false);
|
||||
this.activateText = ko.observable('');
|
||||
this.activateText.isError = ko.observable(false);
|
||||
|
||||
this.activateProcess = ko.observable(false);
|
||||
this.activateText = ko.observable('');
|
||||
this.activateText.isError = ko.observable(false);
|
||||
this.htmlDescription = ko.computed(() => i18n('POPUPS_ACTIVATE/HTML_DESC', {'DOMAIN': this.domain()}));
|
||||
|
||||
this.htmlDescription = ko.computed(function() {
|
||||
return Translator.i18n('POPUPS_ACTIVATE/HTML_DESC', {'DOMAIN': this.domain()});
|
||||
}, this);
|
||||
this.key.subscribe(() => {
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
});
|
||||
|
||||
this.key.subscribe(function() {
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
}, this);
|
||||
this.activationSuccessed.subscribe((value) => {
|
||||
if (value)
|
||||
{
|
||||
this.licenseTrigger(!this.licenseTrigger());
|
||||
}
|
||||
});
|
||||
|
||||
this.activationSuccessed.subscribe(function(bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
this.licenseTrigger(!this.licenseTrigger());
|
||||
}
|
||||
}, this);
|
||||
this.activateCommand = createCommand(() => {
|
||||
|
||||
this.activateCommand = Utils.createCommand(this, function() {
|
||||
this.activateProcess(true);
|
||||
if (this.validateSubscriptionKey())
|
||||
{
|
||||
Remote.licensingActivate((sResult, oData) => {
|
||||
|
||||
this.activateProcess(true);
|
||||
if (this.validateSubscriptionKey())
|
||||
{
|
||||
Remote.licensingActivate(function(sResult, oData) {
|
||||
|
||||
self.activateProcess(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
if (true === oData.Result)
|
||||
this.activateProcess(false);
|
||||
if (StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
self.activationSuccessed(true);
|
||||
self.activateText(Translator.i18n('POPUPS_ACTIVATE/SUBS_KEY_ACTIVATED'));
|
||||
self.activateText.isError(false);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.activateText(oData.Result);
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
this.activateText(getNotification(Notification.UnknownError));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
}
|
||||
else if (oData.ErrorCode)
|
||||
{
|
||||
self.activateText(Translator.getNotification(oData.ErrorCode));
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.activateText(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
self.activateText.isError(true);
|
||||
self.key.focus(true);
|
||||
}
|
||||
|
||||
}, this.domain(), this.key());
|
||||
}
|
||||
else
|
||||
}, 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());
|
||||
}
|
||||
|
||||
onShow(isTrial) {
|
||||
this.domain(Settings.settingsGet('AdminDomain'));
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
isTrial = isUnd(isTrial) ? false : !!isTrial;
|
||||
|
||||
this.key(isTrial ? RAINLOOP_TRIAL_KEY : '');
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
this.activationSuccessed(false);
|
||||
}
|
||||
}
|
||||
|
||||
onShowWithDelay() {
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
this.activateProcess(false);
|
||||
this.activateText(Translator.i18n('POPUPS_ACTIVATE/ERROR_INVALID_SUBS_KEY'));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
}
|
||||
|
||||
}, function() {
|
||||
return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed();
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
validateSubscriptionKey() {
|
||||
const value = this.key();
|
||||
return '' === value || RAINLOOP_TRIAL_KEY === value || !!(/^RL[\d]+-[A-Z0-9\-]+Z$/).test(trim(value));
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Activate', 'PopupsActivateViewModel'], ActivatePopupView);
|
||||
_.extend(ActivatePopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ActivatePopupView.prototype.onShow = function(bTrial)
|
||||
{
|
||||
this.domain(Settings.settingsGet('AdminDomain'));
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
bTrial = Utils.isUnd(bTrial) ? false : !!bTrial;
|
||||
|
||||
this.key(bTrial ? Consts.RAINLOOP_TRIAL_KEY : '');
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
this.activationSuccessed(false);
|
||||
}
|
||||
};
|
||||
|
||||
ActivatePopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (!this.activateProcess())
|
||||
{
|
||||
this.key.focus(true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
ActivatePopupView.prototype.validateSubscriptionKey = function()
|
||||
{
|
||||
var sValue = this.key();
|
||||
return '' === sValue || Consts.RAINLOOP_TRIAL_KEY === sValue || !!(/^RL[\d]+-[A-Z0-9\-]+Z$/).test(Utils.trim(sValue));
|
||||
};
|
||||
|
||||
module.exports = ActivatePopupView;
|
||||
|
|
|
@ -1,108 +1,122 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import ko from 'ko';
|
||||
import {trim, delegateRun, createCommand, log} from 'Common/Utils';
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
import PgpStore from 'Stores/User/Pgp';
|
||||
|
||||
PgpStore = require('Stores/User/Pgp'),
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AddOpenPgpKeyPopupView()
|
||||
@view({
|
||||
name: 'View/Popup/AddOpenPgpKey',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsAddOpenPgpKey'
|
||||
})
|
||||
class AddOpenPgpKeyPopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAddOpenPgpKey');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.key = ko.observable('');
|
||||
this.key.error = ko.observable(false);
|
||||
this.key.focus = ko.observable(false);
|
||||
this.key = ko.observable('');
|
||||
this.key.focus = ko.observable(false);
|
||||
this.key.error = ko.observable(false);
|
||||
this.key.errorMessage = ko.observable('');
|
||||
|
||||
this.key.subscribe(function() {
|
||||
this.key.error(false);
|
||||
}, this);
|
||||
this.key.subscribe(() => {
|
||||
this.key.error(false);
|
||||
this.key.errorMessage('');
|
||||
});
|
||||
|
||||
this.addOpenPgpKeyCommand = Utils.createCommand(this, function() {
|
||||
this.addOpenPgpKeyCommand = createCommand(() => {
|
||||
|
||||
var
|
||||
count = 30,
|
||||
keyTrimmed = Utils.trim(this.key()),
|
||||
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;
|
||||
|
||||
if (/[\n]/.test(keyTrimmed))
|
||||
{
|
||||
keyTrimmed = keyTrimmed.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n');
|
||||
}
|
||||
let keyTrimmed = trim(this.key());
|
||||
|
||||
this.key.error('' === keyTrimmed);
|
||||
|
||||
if (!openpgpKeyring || this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var done = false;
|
||||
|
||||
do
|
||||
{
|
||||
var match = reg.exec(keyTrimmed);
|
||||
if (match && 0 < count)
|
||||
if (/[\n]/.test(keyTrimmed))
|
||||
{
|
||||
if (match[0] && match[1] && match[2] && match[1] === match[2])
|
||||
{
|
||||
if ('PRIVATE' === match[1])
|
||||
{
|
||||
openpgpKeyring.privateKeys.importKey(match[0]);
|
||||
}
|
||||
else if ('PUBLIC' === match[1])
|
||||
{
|
||||
openpgpKeyring.publicKeys.importKey(match[0]);
|
||||
}
|
||||
}
|
||||
keyTrimmed = keyTrimmed.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n');
|
||||
}
|
||||
|
||||
count -= 1;
|
||||
this.key.error('' === keyTrimmed);
|
||||
this.key.errorMessage('');
|
||||
|
||||
if (!openpgpKeyring || this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
let
|
||||
match = null,
|
||||
count = 30,
|
||||
done = false;
|
||||
}
|
||||
else
|
||||
|
||||
do
|
||||
{
|
||||
done = true;
|
||||
match = reg.exec(keyTrimmed);
|
||||
if (match && 0 < count)
|
||||
{
|
||||
if (match[0] && match[1] && match[2] && match[1] === match[2])
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
count -= 1;
|
||||
done = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!done);
|
||||
while (!done);
|
||||
|
||||
openpgpKeyring.store();
|
||||
openpgpKeyring.store();
|
||||
|
||||
require('App/User').default.reloadOpenPgpKeys();
|
||||
Utils.delegateRun(this, 'cancelCommand');
|
||||
getApp().reloadOpenPgpKeys();
|
||||
|
||||
return true;
|
||||
});
|
||||
if (this.key.error())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
kn.constructorEnd(this);
|
||||
delegateRun(this, 'cancelCommand');
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
this.key('');
|
||||
this.key.error(false);
|
||||
this.key.errorMessage('');
|
||||
}
|
||||
|
||||
onShow() {
|
||||
this.clearPopup();
|
||||
}
|
||||
|
||||
onShowWithDelay() {
|
||||
this.key.focus(true);
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/AddOpenPgpKey', 'PopupsAddOpenPgpKeyViewModel'], AddOpenPgpKeyPopupView);
|
||||
_.extend(AddOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AddOpenPgpKeyPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.key('');
|
||||
this.key.error(false);
|
||||
};
|
||||
|
||||
AddOpenPgpKeyPopupView.prototype.onShow = function()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
AddOpenPgpKeyPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.key.focus(true);
|
||||
};
|
||||
|
||||
module.exports = AddOpenPgpKeyPopupView;
|
||||
|
|
|
@ -1,187 +1,174 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
import {trim, createCommand} from 'Common/Utils';
|
||||
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
|
||||
import {searchSubtractFormatDateHelper} from 'Common/Momentor';
|
||||
|
||||
MessageStore = require('Stores/User/Message'),
|
||||
import MessageStore from 'Stores/User/Message';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AdvancedSearchPopupView()
|
||||
@view({
|
||||
name: 'View/Popup/AdvancedSearch',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsAdvancedSearch'
|
||||
})
|
||||
class AdvancedSearchPopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAdvancedSearch');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.fromFocus = ko.observable(false);
|
||||
this.fromFocus = ko.observable(false);
|
||||
|
||||
this.from = ko.observable('');
|
||||
this.to = ko.observable('');
|
||||
this.subject = ko.observable('');
|
||||
this.text = ko.observable('');
|
||||
this.selectedDateValue = ko.observable(-1);
|
||||
this.from = ko.observable('');
|
||||
this.to = ko.observable('');
|
||||
this.subject = ko.observable('');
|
||||
this.text = ko.observable('');
|
||||
this.selectedDateValue = ko.observable(-1);
|
||||
|
||||
this.hasAttachment = ko.observable(false);
|
||||
this.starred = ko.observable(false);
|
||||
this.unseen = ko.observable(false);
|
||||
this.hasAttachment = ko.observable(false);
|
||||
this.starred = ko.observable(false);
|
||||
this.unseen = ko.observable(false);
|
||||
|
||||
this.searchCommand = Utils.createCommand(this, function() {
|
||||
this.searchCommand = createCommand(() => {
|
||||
const search = this.buildSearchString();
|
||||
if ('' !== search)
|
||||
{
|
||||
MessageStore.mainMessageListSearch(search);
|
||||
}
|
||||
|
||||
var sSearch = this.buildSearchString();
|
||||
if ('' !== sSearch)
|
||||
this.cancelCommand();
|
||||
});
|
||||
|
||||
this.selectedDates = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
return [
|
||||
{id: -1, name: i18n('SEARCH/LABEL_ADV_DATE_ALL')},
|
||||
{id: 3, name: i18n('SEARCH/LABEL_ADV_DATE_3_DAYS')},
|
||||
{id: 7, name: i18n('SEARCH/LABEL_ADV_DATE_7_DAYS')},
|
||||
{id: 30, name: i18n('SEARCH/LABEL_ADV_DATE_MONTH')},
|
||||
{id: 90, name: i18n('SEARCH/LABEL_ADV_DATE_3_MONTHS')},
|
||||
{id: 180, name: i18n('SEARCH/LABEL_ADV_DATE_6_MONTHS')},
|
||||
{id: 365, name: i18n('SEARCH/LABEL_ADV_DATE_YEAR')}
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
parseSearchStringValue(search) {
|
||||
const parts = (search || '').split(/[\s]+/g);
|
||||
_.each(parts, (part) => {
|
||||
switch (part)
|
||||
{
|
||||
case 'has:attachment':
|
||||
this.hasAttachment(true);
|
||||
break;
|
||||
case 'is:unseen,flagged':
|
||||
this.starred(true);
|
||||
/* falls through */
|
||||
case 'is:unseen':
|
||||
this.unseen(true);
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
buildSearchStringValue(value) {
|
||||
if (-1 < value.indexOf(' '))
|
||||
{
|
||||
MessageStore.mainMessageListSearch(sSearch);
|
||||
value = '"' + value + '"';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
buildSearchString() {
|
||||
const
|
||||
result = [],
|
||||
from_ = trim(this.from()),
|
||||
to = trim(this.to()),
|
||||
subject = trim(this.subject()),
|
||||
text = trim(this.text()),
|
||||
isPart = [],
|
||||
hasPart = [];
|
||||
|
||||
if (from_ && '' !== from_)
|
||||
{
|
||||
result.push('from:' + this.buildSearchStringValue(from_));
|
||||
}
|
||||
|
||||
this.cancelCommand();
|
||||
});
|
||||
if (to && '' !== to)
|
||||
{
|
||||
result.push('to:' + this.buildSearchStringValue(to));
|
||||
}
|
||||
|
||||
this.selectedDates = ko.computed(function() {
|
||||
Translator.trigger();
|
||||
return [
|
||||
{'id': -1, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_ALL')},
|
||||
{'id': 3, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_3_DAYS')},
|
||||
{'id': 7, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_7_DAYS')},
|
||||
{'id': 30, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_MONTH')},
|
||||
{'id': 90, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_3_MONTHS')},
|
||||
{'id': 180, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_6_MONTHS')},
|
||||
{'id': 365, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_YEAR')}
|
||||
];
|
||||
}, this);
|
||||
if (subject && '' !== subject)
|
||||
{
|
||||
result.push('subject:' + this.buildSearchStringValue(subject));
|
||||
}
|
||||
|
||||
kn.constructorEnd(this);
|
||||
if (this.hasAttachment())
|
||||
{
|
||||
hasPart.push('attachment');
|
||||
}
|
||||
|
||||
if (this.unseen())
|
||||
{
|
||||
isPart.push('unseen');
|
||||
}
|
||||
|
||||
if (this.starred())
|
||||
{
|
||||
isPart.push('flagged');
|
||||
}
|
||||
|
||||
if (0 < hasPart.length)
|
||||
{
|
||||
result.push('has:' + hasPart.join(','));
|
||||
}
|
||||
|
||||
if (0 < isPart.length)
|
||||
{
|
||||
result.push('is:' + isPart.join(','));
|
||||
}
|
||||
|
||||
if (-1 < this.selectedDateValue())
|
||||
{
|
||||
result.push('date:' + searchSubtractFormatDateHelper(this.selectedDateValue()) + '/');
|
||||
}
|
||||
|
||||
if (text && '' !== text)
|
||||
{
|
||||
result.push('text:' + this.buildSearchStringValue(text));
|
||||
}
|
||||
|
||||
return trim(result.join(' '));
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
this.from('');
|
||||
this.to('');
|
||||
this.subject('');
|
||||
this.text('');
|
||||
|
||||
this.selectedDateValue(-1);
|
||||
this.hasAttachment(false);
|
||||
this.starred(false);
|
||||
this.unseen(false);
|
||||
|
||||
this.fromFocus(true);
|
||||
}
|
||||
|
||||
onShow(search) {
|
||||
this.clearPopup();
|
||||
this.parseSearchStringValue(search);
|
||||
}
|
||||
|
||||
onShowWithDelay() {
|
||||
this.fromFocus(true);
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/AdvancedSearch', 'PopupsAdvancedSearchViewModel'], AdvancedSearchPopupView);
|
||||
_.extend(AdvancedSearchPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AdvancedSearchPopupView.prototype.parseSearchStringValue = function(search)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
parts = (search || '').split(/[\s]+/g);
|
||||
|
||||
_.each(parts, function(part) {
|
||||
switch (part)
|
||||
{
|
||||
case 'has:attachment':
|
||||
self.hasAttachment(true);
|
||||
break;
|
||||
case 'is:unseen,flagged':
|
||||
self.starred(true);
|
||||
/* falls through */
|
||||
case 'is:unseen':
|
||||
self.unseen(true);
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.buildSearchStringValue = function(sValue)
|
||||
{
|
||||
if (-1 < sValue.indexOf(' '))
|
||||
{
|
||||
sValue = '"' + sValue + '"';
|
||||
}
|
||||
|
||||
return sValue;
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.buildSearchString = function()
|
||||
{
|
||||
var
|
||||
aResult = [],
|
||||
sFrom = Utils.trim(this.from()),
|
||||
sTo = Utils.trim(this.to()),
|
||||
sSubject = Utils.trim(this.subject()),
|
||||
sText = Utils.trim(this.text()),
|
||||
aIs = [],
|
||||
aHas = [];
|
||||
|
||||
if (sFrom && '' !== sFrom)
|
||||
{
|
||||
aResult.push('from:' + this.buildSearchStringValue(sFrom));
|
||||
}
|
||||
|
||||
if (sTo && '' !== sTo)
|
||||
{
|
||||
aResult.push('to:' + this.buildSearchStringValue(sTo));
|
||||
}
|
||||
|
||||
if (sSubject && '' !== sSubject)
|
||||
{
|
||||
aResult.push('subject:' + this.buildSearchStringValue(sSubject));
|
||||
}
|
||||
|
||||
if (this.hasAttachment())
|
||||
{
|
||||
aHas.push('attachment');
|
||||
}
|
||||
|
||||
if (this.unseen())
|
||||
{
|
||||
aIs.push('unseen');
|
||||
}
|
||||
|
||||
if (this.starred())
|
||||
{
|
||||
aIs.push('flagged');
|
||||
}
|
||||
|
||||
if (0 < aHas.length)
|
||||
{
|
||||
aResult.push('has:' + aHas.join(','));
|
||||
}
|
||||
|
||||
if (0 < aIs.length)
|
||||
{
|
||||
aResult.push('is:' + aIs.join(','));
|
||||
}
|
||||
|
||||
if (-1 < this.selectedDateValue())
|
||||
{
|
||||
aResult.push('date:' + require('Common/Momentor').searchSubtractFormatDateHelper(this.selectedDateValue()) + '/');
|
||||
}
|
||||
|
||||
if (sText && '' !== sText)
|
||||
{
|
||||
aResult.push('text:' + this.buildSearchStringValue(sText));
|
||||
}
|
||||
|
||||
return Utils.trim(aResult.join(' '));
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.from('');
|
||||
this.to('');
|
||||
this.subject('');
|
||||
this.text('');
|
||||
|
||||
this.selectedDateValue(-1);
|
||||
this.hasAttachment(false);
|
||||
this.starred(false);
|
||||
this.unseen(false);
|
||||
|
||||
this.fromFocus(true);
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.onShow = function(search)
|
||||
{
|
||||
this.clearPopup();
|
||||
this.parseSearchStringValue(search);
|
||||
};
|
||||
|
||||
AdvancedSearchPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
this.fromFocus(true);
|
||||
};
|
||||
|
||||
module.exports = AdvancedSearchPopupView;
|
||||
|
|
|
@ -1,134 +1,125 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
import ko from 'ko';
|
||||
import key from 'key';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
import {KeyState} from 'Common/Enums';
|
||||
import {isFunc} from 'Common/Utils';
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function AskPopupView()
|
||||
@view({
|
||||
name: 'View/Popup/Ask',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsAsk'
|
||||
})
|
||||
class AskPopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsAsk');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.askDesc = ko.observable('');
|
||||
this.yesButton = ko.observable('');
|
||||
this.noButton = ko.observable('');
|
||||
this.askDesc = ko.observable('');
|
||||
this.yesButton = ko.observable('');
|
||||
this.noButton = ko.observable('');
|
||||
|
||||
this.yesFocus = ko.observable(false);
|
||||
this.noFocus = ko.observable(false);
|
||||
this.yesFocus = ko.observable(false);
|
||||
this.noFocus = ko.observable(false);
|
||||
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
|
||||
this.bFocusYesOnShow = true;
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Ask', 'PopupsAskViewModel'], AskPopupView);
|
||||
_.extend(AskPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
AskPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.askDesc('');
|
||||
this.yesButton(Translator.i18n('POPUPS_ASK/BUTTON_YES'));
|
||||
this.noButton(Translator.i18n('POPUPS_ASK/BUTTON_NO'));
|
||||
|
||||
this.yesFocus(false);
|
||||
this.noFocus(false);
|
||||
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
};
|
||||
|
||||
AskPopupView.prototype.yesClick = function()
|
||||
{
|
||||
this.cancelCommand();
|
||||
|
||||
if (Utils.isFunc(this.fYesAction))
|
||||
{
|
||||
this.fYesAction.call(null);
|
||||
}
|
||||
};
|
||||
|
||||
AskPopupView.prototype.noClick = function()
|
||||
{
|
||||
this.cancelCommand();
|
||||
|
||||
if (Utils.isFunc(this.fNoAction))
|
||||
{
|
||||
this.fNoAction.call(null);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sAskDesc
|
||||
* @param {Function=} fYesFunc
|
||||
* @param {Function=} fNoFunc
|
||||
* @param {string=} sYesButton
|
||||
* @param {string=} sNoButton
|
||||
* @param {boolean=} bFocusYesOnShow
|
||||
* @returns {void}
|
||||
*/
|
||||
AskPopupView.prototype.onShow = function(sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton, bFocusYesOnShow)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.fYesAction = fYesFunc || null;
|
||||
this.fNoAction = fNoFunc || null;
|
||||
|
||||
this.askDesc(sAskDesc || '');
|
||||
|
||||
if (sYesButton)
|
||||
{
|
||||
this.yesButton(sYesButton);
|
||||
this.bFocusYesOnShow = true;
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = KeyState.PopupAsk;
|
||||
}
|
||||
|
||||
if (sNoButton)
|
||||
{
|
||||
this.noButton(sNoButton);
|
||||
clearPopup() {
|
||||
this.askDesc('');
|
||||
this.yesButton(i18n('POPUPS_ASK/BUTTON_YES'));
|
||||
this.noButton(i18n('POPUPS_ASK/BUTTON_NO'));
|
||||
|
||||
this.yesFocus(false);
|
||||
this.noFocus(false);
|
||||
|
||||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
}
|
||||
|
||||
this.bFocusYesOnShow = Utils.isUnd(bFocusYesOnShow) ? true : !!bFocusYesOnShow;
|
||||
};
|
||||
yesClick() {
|
||||
this.cancelCommand();
|
||||
|
||||
AskPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (this.bFocusYesOnShow)
|
||||
{
|
||||
this.yesFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
AskPopupView.prototype.onBuild = function()
|
||||
{
|
||||
key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function() {
|
||||
if (this.yesFocus())
|
||||
if (isFunc(this.fYesAction))
|
||||
{
|
||||
this.noFocus(true);
|
||||
this.fYesAction.call(null);
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
noClick() {
|
||||
this.cancelCommand();
|
||||
|
||||
if (isFunc(this.fNoAction))
|
||||
{
|
||||
this.fNoAction.call(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sAskDesc
|
||||
* @param {Function=} fYesFunc
|
||||
* @param {Function=} fNoFunc
|
||||
* @param {string=} sYesButton
|
||||
* @param {string=} sNoButton
|
||||
* @param {boolean=} bFocusYesOnShow = true
|
||||
* @returns {void}
|
||||
*/
|
||||
onShow(askDesc, fYesFunc = null, fNoFunc = null, yesButton = '', noButton = '', isFocusYesOnShow = true) {
|
||||
|
||||
this.clearPopup();
|
||||
|
||||
this.fYesAction = fYesFunc || null;
|
||||
this.fNoAction = fNoFunc || null;
|
||||
|
||||
this.askDesc(askDesc || '');
|
||||
|
||||
if (yesButton)
|
||||
{
|
||||
this.yesButton(yesButton);
|
||||
}
|
||||
|
||||
if (noButton)
|
||||
{
|
||||
this.noButton(noButton);
|
||||
}
|
||||
|
||||
this.bFocusYesOnShow = !!isFocusYesOnShow;
|
||||
}
|
||||
|
||||
onShowWithDelay() {
|
||||
if (this.bFocusYesOnShow)
|
||||
{
|
||||
this.yesFocus(true);
|
||||
}
|
||||
return false;
|
||||
}, this));
|
||||
}
|
||||
|
||||
key('esc', Enums.KeyState.PopupAsk, _.bind(function() {
|
||||
this.noClick();
|
||||
return false;
|
||||
}, this));
|
||||
};
|
||||
onBuild() {
|
||||
key('tab, shift+tab, right, left', KeyState.PopupAsk, () => {
|
||||
if (this.yesFocus())
|
||||
{
|
||||
this.noFocus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.yesFocus(true);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
key('esc', KeyState.PopupAsk, () => {
|
||||
this.noClick();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AskPopupView;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,475 +1,460 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
key = require('key'),
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
import key from 'key';
|
||||
|
||||
Utils = require('Common/Utils'),
|
||||
Enums = require('Common/Enums'),
|
||||
Translator = require('Common/Translator'),
|
||||
import {
|
||||
inArray, createCommand,
|
||||
pString, log, isUnd, trim,
|
||||
defautOptionsAfterRender
|
||||
} from 'Common/Utils';
|
||||
|
||||
PgpStore = require('Stores/User/Pgp'),
|
||||
import {Magics, KeyState} from 'Common/Enums';
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
EmailModel = require('Model/Email').default,
|
||||
import PgpStore from 'Stores/User/Pgp';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {EmailModel} from 'Model/Email';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function ComposeOpenPgpPopupView()
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
@view({
|
||||
name: 'View/Popup/ComposeOpenPgp',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsComposeOpenPgp'
|
||||
})
|
||||
class ComposeOpenPgpPopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsComposeOpenPgp');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
var self = this;
|
||||
this.publicKeysOptionsCaption = i18n('PGP_NOTIFICATIONS/ADD_A_PUBLICK_KEY');
|
||||
this.privateKeysOptionsCaption = i18n('PGP_NOTIFICATIONS/SELECT_A_PRIVATE_KEY');
|
||||
|
||||
this.publicKeysOptionsCaption = Translator.i18n('PGP_NOTIFICATIONS/ADD_A_PUBLICK_KEY');
|
||||
this.privateKeysOptionsCaption = Translator.i18n('PGP_NOTIFICATIONS/SELECT_A_PRIVATE_KEY');
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.notification = ko.observable('');
|
||||
this.sign = ko.observable(false);
|
||||
this.encrypt = ko.observable(false);
|
||||
|
||||
this.sign = ko.observable(false);
|
||||
this.encrypt = ko.observable(false);
|
||||
this.password = ko.observable('');
|
||||
this.password.focus = ko.observable(false);
|
||||
this.buttonFocus = ko.observable(false);
|
||||
|
||||
this.password = ko.observable('');
|
||||
this.password.focus = ko.observable(false);
|
||||
this.buttonFocus = ko.observable(false);
|
||||
this.text = ko.observable('');
|
||||
this.selectedPrivateKey = ko.observable(null);
|
||||
this.selectedPublicKey = ko.observable(null);
|
||||
|
||||
this.text = ko.observable('');
|
||||
this.selectedPrivateKey = ko.observable(null);
|
||||
this.selectedPublicKey = ko.observable(null);
|
||||
this.signKey = ko.observable(null);
|
||||
this.encryptKeys = ko.observableArray([]);
|
||||
|
||||
this.signKey = ko.observable(null);
|
||||
this.encryptKeys = ko.observableArray([]);
|
||||
this.encryptKeysView = ko.computed(
|
||||
() => _.compact(_.map(this.encryptKeys(), (oKey) => (oKey ? oKey.key : null)))
|
||||
);
|
||||
|
||||
this.encryptKeysView = ko.computed(function() {
|
||||
return _.compact(_.map(this.encryptKeys(), function(oKey) {
|
||||
return oKey ? oKey.key : null;
|
||||
}));
|
||||
}, this);
|
||||
|
||||
this.privateKeysOptions = ko.computed(function() {
|
||||
return _.compact(_.flatten(_.map(PgpStore.openpgpkeysPrivate(), function(oKey, iIndex) {
|
||||
return self.signKey() && self.signKey().key.id === oKey.id ? null : _.map(oKey.users, function(sUser) {
|
||||
return {
|
||||
this.privateKeysOptions = ko.computed(() => {
|
||||
const opts = _.map(PgpStore.openpgpkeysPrivate(), (oKey, iIndex) => {
|
||||
if (this.signKey() && this.signKey().key.id === oKey.id)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _.map(oKey.users, (user) => ({
|
||||
'id': oKey.guid,
|
||||
'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + sUser,
|
||||
'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + user,
|
||||
'key': oKey,
|
||||
'class': iIndex % 2 ? 'odd' : 'even'
|
||||
};
|
||||
});
|
||||
}), true));
|
||||
});
|
||||
|
||||
this.publicKeysOptions = ko.computed(function() {
|
||||
return _.compact(_.flatten(_.map(PgpStore.openpgpkeysPublic(), function(oKey, iIndex) {
|
||||
return -1 < Utils.inArray(oKey, self.encryptKeysView()) ? null : _.map(oKey.users, function(sUser) {
|
||||
return {
|
||||
'id': oKey.guid,
|
||||
'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + sUser,
|
||||
'key': oKey,
|
||||
'class': iIndex % 2 ? 'odd' : 'even'
|
||||
};
|
||||
});
|
||||
}), true));
|
||||
});
|
||||
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
this.resultCallback = null;
|
||||
|
||||
// commands
|
||||
this.doCommand = Utils.createCommand(this, function() {
|
||||
|
||||
var
|
||||
bResult = true,
|
||||
oPrivateKey = null,
|
||||
aPublicKeys = [];
|
||||
|
||||
this.submitRequest(true);
|
||||
|
||||
if (bResult && this.sign())
|
||||
{
|
||||
if (!this.signKey())
|
||||
{
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||
bResult = false;
|
||||
}
|
||||
else if (!this.signKey().key)
|
||||
{
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
||||
'EMAIL': this.signKey().email
|
||||
}));
|
||||
});
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
return _.compact(_.flatten(opts, true));
|
||||
});
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
var aPrivateKeys = this.signKey().key.getNativeKeys();
|
||||
oPrivateKey = aPrivateKeys[0] || null;
|
||||
|
||||
try
|
||||
this.publicKeysOptions = ko.computed(() => {
|
||||
const opts = _.map(PgpStore.openpgpkeysPublic(), (oKey, index) => {
|
||||
if (-1 < inArray(oKey, this.encryptKeysView()))
|
||||
{
|
||||
if (oPrivateKey)
|
||||
{
|
||||
oPrivateKey.decrypt(Utils.pString(this.password()));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
oPrivateKey = null;
|
||||
return null;
|
||||
}
|
||||
return _.map(oKey.users, (user) => ({
|
||||
'id': oKey.guid,
|
||||
'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + user,
|
||||
'key': oKey,
|
||||
'class': index % 2 ? 'odd' : 'even'
|
||||
}));
|
||||
});
|
||||
return _.compact(_.flatten(opts, true));
|
||||
});
|
||||
|
||||
if (!oPrivateKey)
|
||||
{
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||
bResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.submitRequest = ko.observable(false);
|
||||
|
||||
if (bResult && this.encrypt())
|
||||
{
|
||||
if (0 === this.encryptKeys().length)
|
||||
{
|
||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND'));
|
||||
bResult = false;
|
||||
}
|
||||
else if (this.encryptKeys())
|
||||
{
|
||||
this.resultCallback = null;
|
||||
|
||||
// commands
|
||||
this.doCommand = createCommand(() => {
|
||||
|
||||
let
|
||||
result = true,
|
||||
privateKey = null,
|
||||
aPublicKeys = [];
|
||||
|
||||
_.each(this.encryptKeys(), function(oKey) {
|
||||
if (oKey && oKey.key)
|
||||
{
|
||||
aPublicKeys = aPublicKeys.concat(_.compact(_.flatten(oKey.key.getNativeKeys())));
|
||||
}
|
||||
else if (oKey && oKey.email)
|
||||
{
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
||||
'EMAIL': oKey.email
|
||||
}));
|
||||
this.submitRequest(true);
|
||||
|
||||
bResult = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (bResult && (0 === aPublicKeys.length || this.encryptKeys().length !== aPublicKeys.length))
|
||||
if (result && this.sign())
|
||||
{
|
||||
if (!this.signKey())
|
||||
{
|
||||
bResult = false;
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult && self.resultCallback)
|
||||
{
|
||||
_.delay(function() {
|
||||
|
||||
var oPromise = null;
|
||||
|
||||
try
|
||||
else if (!this.signKey().key)
|
||||
{
|
||||
if (oPrivateKey && 0 === aPublicKeys.length)
|
||||
{
|
||||
oPromise = PgpStore.openpgp.sign({
|
||||
data: self.text(),
|
||||
privateKeys: [oPrivateKey]
|
||||
});
|
||||
}
|
||||
else if (oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
oPromise = PgpStore.openpgp.encrypt({
|
||||
data: self.text(),
|
||||
publicKeys: aPublicKeys,
|
||||
privateKeys: [oPrivateKey]
|
||||
});
|
||||
}
|
||||
else if (!oPrivateKey && 0 < aPublicKeys.length)
|
||||
{
|
||||
oPromise = PgpStore.openpgp.encrypt({
|
||||
data: self.text(),
|
||||
publicKeys: aPublicKeys
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
Utils.log(e);
|
||||
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
||||
'EMAIL': this.signKey().email
|
||||
}));
|
||||
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (oPromise)
|
||||
if (result)
|
||||
{
|
||||
const privateKeys = this.signKey().key.getNativeKeys();
|
||||
privateKey = privateKeys[0] || null;
|
||||
|
||||
try
|
||||
{
|
||||
oPromise.then(function(mData) {
|
||||
|
||||
self.resultCallback(mData.data);
|
||||
self.cancelCommand();
|
||||
|
||||
}).then(null, function(e) {
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
'ERROR': '' + e
|
||||
}));
|
||||
});
|
||||
if (privateKey)
|
||||
{
|
||||
privateKey.decrypt(pString(this.password()));
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||
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
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
self.submitRequest(false);
|
||||
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
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
}, Enums.Magics.Time20ms);
|
||||
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(), (oItem) => oItem && keyId === oItem.id) : null;
|
||||
|
||||
if (option)
|
||||
{
|
||||
this.signKey({
|
||||
'empty': !option.key,
|
||||
'selected': ko.observable(!!option.key),
|
||||
'users': option.key.users,
|
||||
'hash': option.key.id.substr(-8).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(-8).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)
|
||||
{
|
||||
this.selectCommand();
|
||||
this.updateCommand();
|
||||
}
|
||||
});
|
||||
|
||||
this.selectedPublicKey.subscribe((value) => {
|
||||
if (value)
|
||||
{
|
||||
this.addCommand();
|
||||
}
|
||||
});
|
||||
|
||||
this.sDefaultKeyScope = KeyState.PopupComposeOpenPGP;
|
||||
|
||||
this.defautOptionsAfterRender = defautOptionsAfterRender;
|
||||
|
||||
this.addOptionClass = (domOption, item) => {
|
||||
|
||||
this.defautOptionsAfterRender(domOption, item);
|
||||
|
||||
if (item && !isUnd(item.class) && domOption)
|
||||
{
|
||||
$(domOption).addClass(item.class);
|
||||
}
|
||||
};
|
||||
|
||||
this.deletePublickKey = _.bind(this.deletePublickKey, this);
|
||||
}
|
||||
|
||||
deletePublickKey(publicKey) {
|
||||
this.encryptKeys.remove(publicKey);
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
this.notification('');
|
||||
|
||||
this.sign(false);
|
||||
this.encrypt(false);
|
||||
|
||||
this.password('');
|
||||
this.password.focus(false);
|
||||
this.buttonFocus(false);
|
||||
|
||||
this.signKey(null);
|
||||
this.encryptKeys([]);
|
||||
this.text('');
|
||||
|
||||
this.resultCallback = null;
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
key('tab,shift+tab', KeyState.PopupComposeOpenPGP, () => {
|
||||
switch (true)
|
||||
{
|
||||
case this.password.focus():
|
||||
this.buttonFocus(true);
|
||||
break;
|
||||
case this.buttonFocus():
|
||||
this.password.focus(true);
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
onHideWithDelay() {
|
||||
this.clearPopup();
|
||||
}
|
||||
|
||||
onShowWithDelay() {
|
||||
if (this.sign())
|
||||
{
|
||||
this.password.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.submitRequest(false);
|
||||
}
|
||||
|
||||
return bResult;
|
||||
|
||||
}, function() {
|
||||
return !this.submitRequest() && (this.sign() || this.encrypt());
|
||||
});
|
||||
|
||||
this.selectCommand = Utils.createCommand(this, function() {
|
||||
|
||||
var
|
||||
sKeyId = this.selectedPrivateKey(),
|
||||
oOption = sKeyId ? _.find(this.privateKeysOptions(), function(oItem) {
|
||||
return oItem && sKeyId === oItem.id;
|
||||
}) : null;
|
||||
|
||||
if (oOption)
|
||||
{
|
||||
this.signKey({
|
||||
'empty': !oOption.key,
|
||||
'selected': ko.observable(!!oOption.key),
|
||||
'users': oOption.key.users,
|
||||
'hash': oOption.key.id.substr(-8).toUpperCase(),
|
||||
'key': oOption.key
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.addCommand = Utils.createCommand(this, function() {
|
||||
|
||||
var
|
||||
sKeyId = this.selectedPublicKey(),
|
||||
aKeys = this.encryptKeys(),
|
||||
oOption = sKeyId ? _.find(this.publicKeysOptions(), function(oItem) {
|
||||
return oItem && sKeyId === oItem.id;
|
||||
}) : null;
|
||||
|
||||
if (oOption)
|
||||
{
|
||||
aKeys.push({
|
||||
'empty': !oOption.key,
|
||||
'selected': ko.observable(!!oOption.key),
|
||||
'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== oOption.key.id),
|
||||
'users': oOption.key.users,
|
||||
'hash': oOption.key.id.substr(-8).toUpperCase(),
|
||||
'key': oOption.key
|
||||
});
|
||||
|
||||
this.encryptKeys(aKeys);
|
||||
}
|
||||
});
|
||||
|
||||
this.updateCommand = Utils.createCommand(this, function() {
|
||||
_.each(this.encryptKeys(), function(oKey) {
|
||||
oKey.removable(!self.sign() || !self.signKey() || self.signKey().key.id !== oKey.key.id);
|
||||
});
|
||||
});
|
||||
|
||||
this.selectedPrivateKey.subscribe(function(sValue) {
|
||||
if (sValue)
|
||||
{
|
||||
this.selectCommand();
|
||||
this.updateCommand();
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.selectedPublicKey.subscribe(function(sValue) {
|
||||
if (sValue)
|
||||
{
|
||||
this.addCommand();
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP;
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
|
||||
this.addOptionClass = function(oDomOption, oItem) {
|
||||
|
||||
self.defautOptionsAfterRender(oDomOption, oItem);
|
||||
|
||||
if (oItem && !Utils.isUnd(oItem.class) && oDomOption)
|
||||
{
|
||||
$(oDomOption).addClass(oItem.class);
|
||||
}
|
||||
};
|
||||
|
||||
this.deletePublickKey = _.bind(this.deletePublickKey, this);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/ComposeOpenPgp', 'PopupsComposeOpenPgpViewModel'], ComposeOpenPgpPopupView);
|
||||
_.extend(ComposeOpenPgpPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.deletePublickKey = function(oKey)
|
||||
{
|
||||
this.encryptKeys.remove(oKey);
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.notification('');
|
||||
|
||||
this.sign(false);
|
||||
this.encrypt(false);
|
||||
|
||||
this.password('');
|
||||
this.password.focus(false);
|
||||
this.buttonFocus(false);
|
||||
|
||||
this.signKey(null);
|
||||
this.encryptKeys([]);
|
||||
this.text('');
|
||||
|
||||
this.resultCallback = null;
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onBuild = function()
|
||||
{
|
||||
key('tab,shift+tab', Enums.KeyState.PopupComposeOpenPGP, _.bind(function() {
|
||||
|
||||
switch (true)
|
||||
{
|
||||
case this.password.focus():
|
||||
this.buttonFocus(true);
|
||||
break;
|
||||
case this.buttonFocus():
|
||||
this.password.focus(true);
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}, this));
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onHideWithDelay = function()
|
||||
{
|
||||
this.clearPopup();
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (this.sign())
|
||||
{
|
||||
this.password.focus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buttonFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
ComposeOpenPgpPopupView.prototype.onShow = function(fCallback, sText, oIdentity, sTo, sCc, sBcc)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
var
|
||||
self = this,
|
||||
aRec = [],
|
||||
sEmail = '',
|
||||
oEmail = new EmailModel();
|
||||
|
||||
this.resultCallback = fCallback;
|
||||
|
||||
if ('' !== sTo)
|
||||
{
|
||||
aRec.push(sTo);
|
||||
}
|
||||
|
||||
if ('' !== sCc)
|
||||
{
|
||||
aRec.push(sCc);
|
||||
}
|
||||
|
||||
if ('' !== sBcc)
|
||||
{
|
||||
aRec.push(sBcc);
|
||||
}
|
||||
|
||||
aRec = aRec.join(', ').split(',');
|
||||
aRec = _.compact(_.map(aRec, function(sValue) {
|
||||
oEmail.clear();
|
||||
oEmail.mailsoParse(Utils.trim(sValue));
|
||||
return '' === oEmail.email ? false : oEmail.email;
|
||||
}));
|
||||
|
||||
if (oIdentity && oIdentity.email())
|
||||
{
|
||||
sEmail = oIdentity.email();
|
||||
aRec.unshift(sEmail);
|
||||
|
||||
var aKeys = PgpStore.findAllPrivateKeysByEmailNotNative(sEmail);
|
||||
if (aKeys && aKeys[0])
|
||||
{
|
||||
this.signKey({
|
||||
'users': aKeys[0].users || [sEmail],
|
||||
'hash': aKeys[0].id.substr(-8).toUpperCase(),
|
||||
'key': aKeys[0]
|
||||
});
|
||||
this.buttonFocus(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.signKey())
|
||||
{
|
||||
this.sign(true);
|
||||
}
|
||||
onShow(fCallback, sText, identity, sTo, sCc, sBcc) {
|
||||
|
||||
if (aRec && 0 < aRec.length)
|
||||
{
|
||||
this.encryptKeys(_.uniq(_.compact(_.flatten(_.map(aRec, function(sRecEmail) {
|
||||
var keys = PgpStore.findAllPublicKeysByEmailNotNative(sRecEmail);
|
||||
return keys ? _.map(keys, function(oKey) {
|
||||
return {
|
||||
'empty': !oKey,
|
||||
'selected': ko.observable(!!oKey),
|
||||
'removable': ko.observable(!self.sign() || !self.signKey() || self.signKey().key.id !== oKey.id),
|
||||
'users': oKey ? (oKey.users || [sRecEmail]) : [sRecEmail],
|
||||
'hash': oKey ? oKey.id.substr(-8).toUpperCase() : '',
|
||||
'key': oKey
|
||||
};
|
||||
}) : [];
|
||||
}), true)), function(oEncryptKey) {
|
||||
return oEncryptKey.hash;
|
||||
this.clearPopup();
|
||||
|
||||
let
|
||||
rec = [],
|
||||
emailLine = '';
|
||||
|
||||
const email = new EmailModel();
|
||||
|
||||
this.resultCallback = fCallback;
|
||||
|
||||
if ('' !== sTo)
|
||||
{
|
||||
rec.push(sTo);
|
||||
}
|
||||
|
||||
if ('' !== sCc)
|
||||
{
|
||||
rec.push(sCc);
|
||||
}
|
||||
|
||||
if ('' !== sBcc)
|
||||
{
|
||||
rec.push(sBcc);
|
||||
}
|
||||
|
||||
rec = rec.join(', ').split(',');
|
||||
rec = _.compact(_.map(rec, (value) => {
|
||||
email.clear();
|
||||
email.mailsoParse(trim(value));
|
||||
return '' === email.email ? false : email.email;
|
||||
}));
|
||||
|
||||
if (0 < this.encryptKeys().length)
|
||||
if (identity && identity.email())
|
||||
{
|
||||
this.encrypt(true);
|
||||
}
|
||||
}
|
||||
emailLine = identity.email();
|
||||
rec.unshift(emailLine);
|
||||
|
||||
this.text(sText);
|
||||
};
|
||||
const keys = PgpStore.findAllPrivateKeysByEmailNotNative(emailLine);
|
||||
if (keys && keys[0])
|
||||
{
|
||||
this.signKey({
|
||||
'users': keys[0].users || [emailLine],
|
||||
'hash': keys[0].id.substr(-8).toUpperCase(),
|
||||
'key': keys[0]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (this.signKey())
|
||||
{
|
||||
this.sign(true);
|
||||
}
|
||||
|
||||
if (rec && 0 < rec.length)
|
||||
{
|
||||
this.encryptKeys(_.uniq(_.compact(_.flatten(_.map(rec, (recEmail) => {
|
||||
const keys = PgpStore.findAllPublicKeysByEmailNotNative(recEmail);
|
||||
return keys ? _.map(keys, (oKey) => ({
|
||||
'empty': !oKey,
|
||||
'selected': ko.observable(!!oKey),
|
||||
'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== oKey.id),
|
||||
'users': oKey ? (oKey.users || [recEmail]) : [recEmail],
|
||||
'hash': oKey ? oKey.id.substr(-8).toUpperCase() : '',
|
||||
'key': oKey
|
||||
})) : [];
|
||||
}), true)), (encryptKey) => encryptKey.hash));
|
||||
|
||||
if (0 < this.encryptKeys().length)
|
||||
{
|
||||
this.encrypt(true);
|
||||
}
|
||||
}
|
||||
|
||||
this.text(sText);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ComposeOpenPgpPopupView;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,483 +1,465 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
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 {i18n} from 'Common/Translator';
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
import CapaAdminStore from 'Stores/Admin/Capa';
|
||||
|
||||
CapaAdminStore = require('Stores/Admin/Capa'),
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function DomainPopupView()
|
||||
@view({
|
||||
name: 'View/Popup/Domain',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsDomain'
|
||||
})
|
||||
class DomainPopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsDomain');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.edit = ko.observable(false);
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
this.page = ko.observable('main');
|
||||
this.sieveSettings = ko.observable(false);
|
||||
this.edit = ko.observable(false);
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
this.page = ko.observable('main');
|
||||
this.sieveSettings = ko.observable(false);
|
||||
|
||||
this.testing = ko.observable(false);
|
||||
this.testingDone = ko.observable(false);
|
||||
this.testingImapError = ko.observable(false);
|
||||
this.testingSieveError = ko.observable(false);
|
||||
this.testingSmtpError = ko.observable(false);
|
||||
this.testingImapErrorDesc = ko.observable('');
|
||||
this.testingSieveErrorDesc = ko.observable('');
|
||||
this.testingSmtpErrorDesc = ko.observable('');
|
||||
this.testing = ko.observable(false);
|
||||
this.testingDone = ko.observable(false);
|
||||
this.testingImapError = ko.observable(false);
|
||||
this.testingSieveError = ko.observable(false);
|
||||
this.testingSmtpError = ko.observable(false);
|
||||
this.testingImapErrorDesc = ko.observable('');
|
||||
this.testingSieveErrorDesc = ko.observable('');
|
||||
this.testingSmtpErrorDesc = ko.observable('');
|
||||
|
||||
this.testingImapError.subscribe(function(bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingImapErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.testingSieveError.subscribe(function(bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingSieveErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.testingSmtpError.subscribe(function(bValue) {
|
||||
if (!bValue)
|
||||
{
|
||||
this.testingSmtpErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.imapServerFocus = ko.observable(false);
|
||||
this.sieveServerFocus = ko.observable(false);
|
||||
this.smtpServerFocus = ko.observable(false);
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
|
||||
this.imapServer = ko.observable('');
|
||||
this.imapPort = ko.observable('' + Consts.IMAP_DEFAULT_PORT);
|
||||
this.imapSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.imapShortLogin = ko.observable(false);
|
||||
this.useSieve = ko.observable(false);
|
||||
this.sieveAllowRaw = ko.observable(false);
|
||||
this.sieveServer = ko.observable('');
|
||||
this.sievePort = ko.observable('' + Consts.SIEVE_DEFAULT_PORT);
|
||||
this.sieveSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.smtpServer = ko.observable('');
|
||||
this.smtpPort = ko.observable('' + Consts.SMTP_DEFAULT_PORT);
|
||||
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin = ko.observable(false);
|
||||
this.smtpAuth = ko.observable(true);
|
||||
this.smtpPhpMail = ko.observable(false);
|
||||
this.whiteList = ko.observable('');
|
||||
this.aliasName = ko.observable('');
|
||||
|
||||
this.enableSmartPorts = ko.observable(false);
|
||||
|
||||
this.allowSieve = ko.computed(function() {
|
||||
return CapaAdminStore.filters() && CapaAdminStore.sieve();
|
||||
}, this);
|
||||
|
||||
this.headerText = ko.computed(function() {
|
||||
|
||||
var
|
||||
sName = this.name(),
|
||||
sAliasName = this.aliasName(),
|
||||
sResult = '';
|
||||
|
||||
if (this.edit())
|
||||
{
|
||||
sResult = Translator.i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', {'NAME': sName});
|
||||
if (sAliasName)
|
||||
this.testingImapError.subscribe((value) => {
|
||||
if (!value)
|
||||
{
|
||||
sResult += ' ← ' + sAliasName;
|
||||
this.testingImapErrorDesc('');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = ('' === sName ? Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN') :
|
||||
Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', {'NAME': sName}));
|
||||
}
|
||||
});
|
||||
|
||||
return sResult;
|
||||
|
||||
}, this);
|
||||
|
||||
this.domainDesc = ko.computed(function() {
|
||||
var sName = this.name();
|
||||
return !this.edit() && sName ? Translator.i18n('POPUPS_DOMAIN/NEW_DOMAIN_DESC', {'NAME': '*@' + sName}) : '';
|
||||
}, this);
|
||||
|
||||
this.domainIsComputed = ko.computed(function() {
|
||||
|
||||
var
|
||||
bPhpMail = this.smtpPhpMail(),
|
||||
bAllowSieve = this.allowSieve(),
|
||||
bUseSieve = this.useSieve();
|
||||
|
||||
return '' !== this.name() &&
|
||||
'' !== this.imapServer() &&
|
||||
'' !== this.imapPort() &&
|
||||
(bAllowSieve && bUseSieve ? ('' !== this.sieveServer() && '' !== this.sievePort()) : true) &&
|
||||
(('' !== this.smtpServer() && '' !== this.smtpPort()) || bPhpMail);
|
||||
|
||||
}, this);
|
||||
|
||||
this.canBeTested = ko.computed(function() {
|
||||
return !this.testing() && this.domainIsComputed();
|
||||
}, this);
|
||||
|
||||
this.canBeSaved = ko.computed(function() {
|
||||
return !this.saving() && this.domainIsComputed();
|
||||
}, this);
|
||||
|
||||
this.createOrAddCommand = Utils.createCommand(this, function() {
|
||||
this.saving(true);
|
||||
Remote.createOrUpdateDomain(
|
||||
_.bind(this.onDomainCreateOrSaveResponse, this),
|
||||
!this.edit(),
|
||||
this.name(),
|
||||
|
||||
this.imapServer(),
|
||||
Utils.pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
this.imapShortLogin(),
|
||||
|
||||
this.useSieve(),
|
||||
this.sieveAllowRaw(),
|
||||
this.sieveServer(),
|
||||
Utils.pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
||||
this.smtpServer(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpShortLogin(),
|
||||
this.smtpAuth(),
|
||||
this.smtpPhpMail(),
|
||||
|
||||
this.whiteList()
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
this.testConnectionCommand = Utils.createCommand(this, function() {
|
||||
|
||||
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(),
|
||||
Utils.pInt(this.imapPort()),
|
||||
this.imapSecure(),
|
||||
|
||||
this.useSieve(),
|
||||
this.sieveServer(),
|
||||
Utils.pInt(this.sievePort()),
|
||||
this.sieveSecure(),
|
||||
|
||||
this.smtpServer(),
|
||||
Utils.pInt(this.smtpPort()),
|
||||
this.smtpSecure(),
|
||||
this.smtpAuth(),
|
||||
this.smtpPhpMail()
|
||||
);
|
||||
}, this.canBeTested);
|
||||
|
||||
this.whiteListCommand = Utils.createCommand(this, function() {
|
||||
this.page('white-list');
|
||||
});
|
||||
|
||||
this.backCommand = Utils.createCommand(this, function() {
|
||||
this.page('main');
|
||||
});
|
||||
|
||||
this.sieveCommand = Utils.createCommand(this, function() {
|
||||
this.sieveSettings(!this.sieveSettings());
|
||||
this.clearTesting();
|
||||
});
|
||||
|
||||
this.page.subscribe(function() {
|
||||
this.sieveSettings(false);
|
||||
}, this);
|
||||
|
||||
// smart form improvements
|
||||
this.imapServerFocus.subscribe(function(bValue) {
|
||||
if (bValue && '' !== this.name() && '' === this.imapServer())
|
||||
{
|
||||
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.sieveServerFocus.subscribe(function(bValue) {
|
||||
if (bValue && '' !== this.imapServer() && '' === this.sieveServer())
|
||||
{
|
||||
this.sieveServer(this.imapServer());
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.smtpServerFocus.subscribe(function(bValue) {
|
||||
if (bValue && '' !== this.imapServer() && '' === this.smtpServer())
|
||||
{
|
||||
this.smtpServer(this.imapServer().replace(/imap/ig, 'smtp'));
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.imapSecure.subscribe(function(sValue) {
|
||||
if (this.enableSmartPorts())
|
||||
{
|
||||
var iPort = Utils.pInt(this.imapPort());
|
||||
switch (Utils.pString(sValue))
|
||||
this.testingSieveError.subscribe((value) => {
|
||||
if (!value)
|
||||
{
|
||||
case '0':
|
||||
if (Enums.Ports.ImapSsl === iPort)
|
||||
{
|
||||
this.imapPort(Utils.pString(Enums.Ports.Imap));
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
if (Enums.Ports.Imap === iPort)
|
||||
{
|
||||
this.imapPort(Utils.pString(Enums.Ports.ImapSsl));
|
||||
}
|
||||
break;
|
||||
// no default
|
||||
this.testingSieveErrorDesc('');
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
});
|
||||
|
||||
this.smtpSecure.subscribe(function(sValue) {
|
||||
if (this.enableSmartPorts())
|
||||
{
|
||||
var iPort = Utils.pInt(this.smtpPort());
|
||||
switch (Utils.pString(sValue))
|
||||
this.testingSmtpError.subscribe((value) => {
|
||||
if (!value)
|
||||
{
|
||||
case '0':
|
||||
if (Enums.Ports.SmtpSsl === iPort || Enums.Ports.SmtpStartTls === iPort)
|
||||
{
|
||||
this.smtpPort(Utils.pString(Enums.Ports.Smtp));
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
if (Enums.Ports.Smtp === iPort || Enums.Ports.SmtpStartTls === iPort)
|
||||
{
|
||||
this.smtpPort(Utils.pString(Enums.Ports.SmtpSsl));
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
if (Enums.Ports.Smtp === iPort || Enums.Ports.SmtpSsl === iPort)
|
||||
{
|
||||
this.smtpPort(Utils.pString(Enums.Ports.SmtpStartTls));
|
||||
}
|
||||
break;
|
||||
// no default
|
||||
this.testingSmtpErrorDesc('');
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
});
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
this.imapServerFocus = ko.observable(false);
|
||||
this.sieveServerFocus = ko.observable(false);
|
||||
this.smtpServerFocus = ko.observable(false);
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Domain', 'PopupsDomainViewModel'], DomainPopupView);
|
||||
_.extend(DomainPopupView.prototype, AbstractView.prototype);
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
|
||||
DomainPopupView.prototype.onTestConnectionResponse = function(sResult, oData)
|
||||
{
|
||||
this.testing(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
var
|
||||
bImap = false,
|
||||
bSieve = false;
|
||||
this.imapServer = ko.observable('');
|
||||
this.imapPort = ko.observable('' + IMAP_DEFAULT_PORT);
|
||||
this.imapSecure = ko.observable(ServerSecure.None);
|
||||
this.imapShortLogin = ko.observable(false);
|
||||
this.useSieve = ko.observable(false);
|
||||
this.sieveAllowRaw = ko.observable(false);
|
||||
this.sieveServer = ko.observable('');
|
||||
this.sievePort = ko.observable('' + SIEVE_DEFAULT_PORT);
|
||||
this.sieveSecure = ko.observable(ServerSecure.None);
|
||||
this.smtpServer = ko.observable('');
|
||||
this.smtpPort = ko.observable('' + SMTP_DEFAULT_PORT);
|
||||
this.smtpSecure = ko.observable(ServerSecure.None);
|
||||
this.smtpShortLogin = ko.observable(false);
|
||||
this.smtpAuth = ko.observable(true);
|
||||
this.smtpPhpMail = ko.observable(false);
|
||||
this.whiteList = ko.observable('');
|
||||
this.aliasName = ko.observable('');
|
||||
|
||||
this.testingDone(true);
|
||||
this.testingImapError(true !== oData.Result.Imap);
|
||||
this.testingSieveError(true !== oData.Result.Sieve);
|
||||
this.testingSmtpError(true !== oData.Result.Smtp);
|
||||
this.enableSmartPorts = ko.observable(false);
|
||||
|
||||
if (this.testingImapError() && oData.Result.Imap)
|
||||
{
|
||||
bImap = true;
|
||||
this.testingImapErrorDesc('');
|
||||
this.testingImapErrorDesc(oData.Result.Imap);
|
||||
}
|
||||
this.allowSieve = ko.computed(() => CapaAdminStore.filters() && CapaAdminStore.sieve());
|
||||
|
||||
if (this.testingSieveError() && oData.Result.Sieve)
|
||||
{
|
||||
bSieve = true;
|
||||
this.testingSieveErrorDesc('');
|
||||
this.testingSieveErrorDesc(oData.Result.Sieve);
|
||||
}
|
||||
this.headerText = ko.computed(() => {
|
||||
|
||||
if (this.testingSmtpError() && oData.Result.Smtp)
|
||||
{
|
||||
this.testingSmtpErrorDesc('');
|
||||
this.testingSmtpErrorDesc(oData.Result.Smtp);
|
||||
}
|
||||
const
|
||||
name = this.name(),
|
||||
aliasName = this.aliasName();
|
||||
|
||||
if (this.sieveSettings())
|
||||
{
|
||||
if (!bSieve && bImap)
|
||||
let result = '';
|
||||
|
||||
if (this.edit())
|
||||
{
|
||||
this.sieveSettings(false);
|
||||
result = i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', {'NAME': name});
|
||||
if (aliasName)
|
||||
{
|
||||
result += ' ← ' + aliasName;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
result = ('' === name ? i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN') :
|
||||
i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', {'NAME': name}));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
});
|
||||
|
||||
this.domainDesc = ko.computed(() => {
|
||||
const name = this.name();
|
||||
return !this.edit() && name ? i18n('POPUPS_DOMAIN/NEW_DOMAIN_DESC', {'NAME': '*@' + name}) : '';
|
||||
});
|
||||
|
||||
this.domainIsComputed = ko.computed(() => {
|
||||
|
||||
const
|
||||
usePhpMail = this.smtpPhpMail(),
|
||||
allowSieve = this.allowSieve(),
|
||||
useSieve = this.useSieve();
|
||||
|
||||
return '' !== this.name() &&
|
||||
'' !== this.imapServer() &&
|
||||
'' !== this.imapPort() &&
|
||||
(allowSieve && useSieve ? ('' !== this.sieveServer() && '' !== this.sievePort()) : true) &&
|
||||
(('' !== this.smtpServer() && '' !== this.smtpPort()) || usePhpMail);
|
||||
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
// smart form improvements
|
||||
this.imapServerFocus.subscribe((value) => {
|
||||
if (value && '' !== this.name() && '' === this.imapServer())
|
||||
{
|
||||
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
|
||||
}
|
||||
});
|
||||
|
||||
this.sieveServerFocus.subscribe((value) => {
|
||||
if (value && '' !== this.imapServer() && '' === this.sieveServer())
|
||||
{
|
||||
this.sieveServer(this.imapServer());
|
||||
}
|
||||
});
|
||||
|
||||
this.smtpServerFocus.subscribe((value) => {
|
||||
if (value && '' !== this.imapServer() && '' === this.smtpServer())
|
||||
{
|
||||
this.smtpServer(this.imapServer().replace(/imap/ig, 'smtp'));
|
||||
}
|
||||
});
|
||||
|
||||
this.imapSecure.subscribe((value) => {
|
||||
if (this.enableSmartPorts())
|
||||
{
|
||||
const port = pInt(this.imapPort());
|
||||
switch (pString(value))
|
||||
{
|
||||
case '0':
|
||||
if (Ports.ImapSsl === port)
|
||||
{
|
||||
this.imapPort(pString(Ports.Imap));
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
if (Ports.Imap === port)
|
||||
{
|
||||
this.imapPort(pString(Ports.ImapSsl));
|
||||
}
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.smtpSecure.subscribe((value) => {
|
||||
if (this.enableSmartPorts())
|
||||
{
|
||||
const port = pInt(this.smtpPort());
|
||||
switch (pString(value))
|
||||
{
|
||||
case '0':
|
||||
if (Ports.SmtpSsl === port || Ports.SmtpStartTls === port)
|
||||
{
|
||||
this.smtpPort(pString(Ports.Smtp));
|
||||
}
|
||||
break;
|
||||
case '1':
|
||||
if (Ports.Smtp === port || Ports.SmtpStartTls === port)
|
||||
{
|
||||
this.smtpPort(pString(Ports.SmtpSsl));
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
if (Ports.Smtp === port || Ports.SmtpSsl === port)
|
||||
{
|
||||
this.smtpPort(pString(Ports.SmtpStartTls));
|
||||
}
|
||||
break;
|
||||
// no default
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onTestConnectionResponse(sResult, oData) {
|
||||
this.testing(false);
|
||||
if (StorageResultType.Success === sResult && oData.Result)
|
||||
{
|
||||
if (bSieve && !bImap)
|
||||
let
|
||||
bImap = false,
|
||||
bSieve = false;
|
||||
|
||||
this.testingDone(true);
|
||||
this.testingImapError(true !== oData.Result.Imap);
|
||||
this.testingSieveError(true !== oData.Result.Sieve);
|
||||
this.testingSmtpError(true !== oData.Result.Smtp);
|
||||
|
||||
if (this.testingImapError() && oData.Result.Imap)
|
||||
{
|
||||
bImap = true;
|
||||
this.testingImapErrorDesc('');
|
||||
this.testingImapErrorDesc(oData.Result.Imap);
|
||||
}
|
||||
|
||||
if (this.testingSieveError() && oData.Result.Sieve)
|
||||
{
|
||||
bSieve = true;
|
||||
this.testingSieveErrorDesc('');
|
||||
this.testingSieveErrorDesc(oData.Result.Sieve);
|
||||
}
|
||||
|
||||
if (this.testingSmtpError() && oData.Result.Smtp)
|
||||
{
|
||||
this.testingSmtpErrorDesc('');
|
||||
this.testingSmtpErrorDesc(oData.Result.Smtp);
|
||||
}
|
||||
|
||||
if (this.sieveSettings())
|
||||
{
|
||||
if (!bSieve && bImap)
|
||||
{
|
||||
this.sieveSettings(false);
|
||||
}
|
||||
}
|
||||
else if (bSieve && !bImap)
|
||||
{
|
||||
this.sieveSettings(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.testingImapError(true);
|
||||
this.testingSieveError(true);
|
||||
this.testingSmtpError(true);
|
||||
this.sieveSettings(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.testingImapError(true);
|
||||
this.testingSieveError(true);
|
||||
this.testingSmtpError(true);
|
||||
|
||||
onDomainCreateOrSaveResponse(sResult, oData) {
|
||||
this.saving(false);
|
||||
if (StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
getApp().reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError(i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError(i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
}
|
||||
|
||||
clearTesting() {
|
||||
this.testing(false);
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSieveError(false);
|
||||
this.testingSmtpError(false);
|
||||
}
|
||||
|
||||
onHide() {
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.onDomainCreateOrSaveResponse = function(sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
onShow(oDomain) {
|
||||
this.saving(false);
|
||||
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
|
||||
this.clearTesting();
|
||||
|
||||
this.clearForm();
|
||||
if (oDomain)
|
||||
{
|
||||
require('App/Admin').default.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
this.enableSmartPorts(false);
|
||||
|
||||
this.edit(true);
|
||||
|
||||
this.name(trim(oDomain.Name));
|
||||
this.imapServer(trim(oDomain.IncHost));
|
||||
this.imapPort('' + pInt(oDomain.IncPort));
|
||||
this.imapSecure(trim(oDomain.IncSecure));
|
||||
this.imapShortLogin(!!oDomain.IncShortLogin);
|
||||
this.useSieve(!!oDomain.UseSieve);
|
||||
this.sieveAllowRaw(!!oDomain.SieveAllowRaw);
|
||||
this.sieveServer(trim(oDomain.SieveHost));
|
||||
this.sievePort('' + pInt(oDomain.SievePort));
|
||||
this.sieveSecure(trim(oDomain.SieveSecure));
|
||||
this.smtpServer(trim(oDomain.OutHost));
|
||||
this.smtpPort('' + pInt(oDomain.OutPort));
|
||||
this.smtpSecure(trim(oDomain.OutSecure));
|
||||
this.smtpShortLogin(!!oDomain.OutShortLogin);
|
||||
this.smtpAuth(!!oDomain.OutAuth);
|
||||
this.smtpPhpMail(!!oDomain.OutUsePhpMail);
|
||||
this.whiteList(trim(oDomain.WhiteList));
|
||||
this.aliasName(trim(oDomain.AliasName));
|
||||
|
||||
this.enableSmartPorts(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
|
||||
onShowWithDelay() {
|
||||
if ('' === this.name() && !bMobileDevice)
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.clearTesting = function()
|
||||
{
|
||||
this.testing(false);
|
||||
this.testingDone(false);
|
||||
this.testingImapError(false);
|
||||
this.testingSieveError(false);
|
||||
this.testingSmtpError(false);
|
||||
};
|
||||
clearForm() {
|
||||
this.edit(false);
|
||||
|
||||
DomainPopupView.prototype.onHide = function()
|
||||
{
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
};
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
|
||||
DomainPopupView.prototype.onShow = function(oDomain)
|
||||
{
|
||||
this.saving(false);
|
||||
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
|
||||
this.clearTesting();
|
||||
|
||||
this.clearForm();
|
||||
if (oDomain)
|
||||
{
|
||||
this.enableSmartPorts(false);
|
||||
|
||||
this.edit(true);
|
||||
this.savingError('');
|
||||
|
||||
this.name(Utils.trim(oDomain.Name));
|
||||
this.imapServer(Utils.trim(oDomain.IncHost));
|
||||
this.imapPort('' + Utils.pInt(oDomain.IncPort));
|
||||
this.imapSecure(Utils.trim(oDomain.IncSecure));
|
||||
this.imapShortLogin(!!oDomain.IncShortLogin);
|
||||
this.useSieve(!!oDomain.UseSieve);
|
||||
this.sieveAllowRaw(!!oDomain.SieveAllowRaw);
|
||||
this.sieveServer(Utils.trim(oDomain.SieveHost));
|
||||
this.sievePort('' + Utils.pInt(oDomain.SievePort));
|
||||
this.sieveSecure(Utils.trim(oDomain.SieveSecure));
|
||||
this.smtpServer(Utils.trim(oDomain.OutHost));
|
||||
this.smtpPort('' + Utils.pInt(oDomain.OutPort));
|
||||
this.smtpSecure(Utils.trim(oDomain.OutSecure));
|
||||
this.smtpShortLogin(!!oDomain.OutShortLogin);
|
||||
this.smtpAuth(!!oDomain.OutAuth);
|
||||
this.smtpPhpMail(!!oDomain.OutUsePhpMail);
|
||||
this.whiteList(Utils.trim(oDomain.WhiteList));
|
||||
this.aliasName(Utils.trim(oDomain.AliasName));
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.imapServer('');
|
||||
this.imapPort('' + IMAP_DEFAULT_PORT);
|
||||
this.imapSecure(ServerSecure.None);
|
||||
this.imapShortLogin(false);
|
||||
|
||||
this.useSieve(false);
|
||||
this.sieveAllowRaw(false);
|
||||
this.sieveServer('');
|
||||
this.sievePort('' + SIEVE_DEFAULT_PORT);
|
||||
this.sieveSecure(ServerSecure.None);
|
||||
|
||||
this.smtpServer('');
|
||||
this.smtpPort('' + SMTP_DEFAULT_PORT);
|
||||
this.smtpSecure(ServerSecure.None);
|
||||
this.smtpShortLogin(false);
|
||||
this.smtpAuth(true);
|
||||
this.smtpPhpMail(false);
|
||||
|
||||
this.whiteList('');
|
||||
this.aliasName('');
|
||||
this.enableSmartPorts(true);
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if ('' === this.name() && !Globals.bMobile)
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
DomainPopupView.prototype.clearForm = function()
|
||||
{
|
||||
this.edit(false);
|
||||
|
||||
this.page('main');
|
||||
this.sieveSettings(false);
|
||||
|
||||
this.enableSmartPorts(false);
|
||||
|
||||
this.savingError('');
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.imapServer('');
|
||||
this.imapPort('' + Consts.IMAP_DEFAULT_PORT);
|
||||
this.imapSecure(Enums.ServerSecure.None);
|
||||
this.imapShortLogin(false);
|
||||
|
||||
this.useSieve(false);
|
||||
this.sieveAllowRaw(false);
|
||||
this.sieveServer('');
|
||||
this.sievePort('' + Consts.SIEVE_DEFAULT_PORT);
|
||||
this.sieveSecure(Enums.ServerSecure.None);
|
||||
|
||||
this.smtpServer('');
|
||||
this.smtpPort('' + Consts.SMTP_DEFAULT_PORT);
|
||||
this.smtpSecure(Enums.ServerSecure.None);
|
||||
this.smtpShortLogin(false);
|
||||
this.smtpAuth(true);
|
||||
this.smtpPhpMail(false);
|
||||
|
||||
this.whiteList('');
|
||||
this.aliasName('');
|
||||
this.enableSmartPorts(true);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = DomainPopupView;
|
||||
|
|
|
@ -1,110 +1,99 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {bMobileDevice} from 'Common/Globals';
|
||||
import {createCommand} from 'Common/Utils';
|
||||
import {i18n} from 'Common/Translator';
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
import DomainStore from 'Stores/Admin/Domain';
|
||||
|
||||
DomainStore = require('Stores/Admin/Domain'),
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
import {getApp} from 'Helper/Apps/Admin';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function DomainAliasPopupView()
|
||||
@view({
|
||||
name: 'View/Popup/DomainAlias',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsDomainAlias'
|
||||
})
|
||||
class DomainAliasPopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsDomainAlias');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
this.saving = ko.observable(false);
|
||||
this.savingError = ko.observable('');
|
||||
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
this.name = ko.observable('');
|
||||
this.name.focused = ko.observable(false);
|
||||
|
||||
this.alias = ko.observable('');
|
||||
this.alias = ko.observable('');
|
||||
|
||||
this.domains = DomainStore.domainsWithoutAliases;
|
||||
this.domains = DomainStore.domainsWithoutAliases;
|
||||
|
||||
this.domainsOptions = ko.computed(function() {
|
||||
return _.map(this.domains(), function(item) {
|
||||
return {
|
||||
optValue: item.name,
|
||||
optText: item.name
|
||||
};
|
||||
});
|
||||
}, this);
|
||||
|
||||
this.canBeSaved = ko.computed(function() {
|
||||
return !this.saving() && '' !== this.name() && '' !== this.alias();
|
||||
}, this);
|
||||
|
||||
this.createCommand = Utils.createCommand(this, function() {
|
||||
this.saving(true);
|
||||
Remote.createDomainAlias(
|
||||
_.bind(this.onDomainAliasCreateOrSaveResponse, this),
|
||||
this.name(),
|
||||
this.alias()
|
||||
this.domainsOptions = ko.computed(
|
||||
() => _.map(this.domains(), (item) => ({optValue: item.name, optText: item.name}))
|
||||
);
|
||||
}, this.canBeSaved);
|
||||
|
||||
kn.constructorEnd(this);
|
||||
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);
|
||||
}
|
||||
|
||||
onDomainAliasCreateOrSaveResponse(result, data) {
|
||||
this.saving(false);
|
||||
if (StorageResultType.Success === result && data)
|
||||
{
|
||||
if (data.Result)
|
||||
{
|
||||
getApp().reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Notification.DomainAlreadyExists === data.ErrorCode)
|
||||
{
|
||||
this.savingError(i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError(i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
}
|
||||
|
||||
onShow() {
|
||||
this.clearForm();
|
||||
}
|
||||
|
||||
onShowWithDelay() {
|
||||
if ('' === this.name() && !bMobileDevice)
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
}
|
||||
|
||||
clearForm() {
|
||||
this.saving(false);
|
||||
this.savingError('');
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.alias('');
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/DomainAlias', 'PopupsDomainAliasViewModel'], DomainAliasPopupView);
|
||||
_.extend(DomainAliasPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
DomainAliasPopupView.prototype.onDomainAliasCreateOrSaveResponse = function(sResult, oData)
|
||||
{
|
||||
this.saving(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (oData.Result)
|
||||
{
|
||||
require('App/Admin').default.reloadDomainList();
|
||||
this.closeCommand();
|
||||
}
|
||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.savingError(Translator.i18n('ERRORS/UNKNOWN_ERROR'));
|
||||
}
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.onShow = function()
|
||||
{
|
||||
this.clearForm();
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if ('' === this.name() && !Globals.bMobile)
|
||||
{
|
||||
this.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
DomainAliasPopupView.prototype.clearForm = function()
|
||||
{
|
||||
this.saving(false);
|
||||
this.savingError('');
|
||||
|
||||
this.name('');
|
||||
this.name.focused(false);
|
||||
|
||||
this.alias('');
|
||||
};
|
||||
|
||||
module.exports = DomainAliasPopupView;
|
||||
|
|
|
@ -1,202 +1,194 @@
|
|||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
import {FiltersAction, FilterConditionField, FilterConditionType} from 'Common/Enums';
|
||||
import {bMobileDevice} from 'Common/Globals';
|
||||
import {defautOptionsAfterRender, createCommand, delegateRun} from 'Common/Utils';
|
||||
import {i18n, initOnStartOrLangChange} from 'Common/Translator';
|
||||
|
||||
FilterStore = require('Stores/User/Filter'),
|
||||
FolderStore = require('Stores/User/Folder'),
|
||||
import FilterStore from 'Stores/User/Filter';
|
||||
import FolderStore from 'Stores/User/Folder';
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractView = require('Knoin/AbstractView');
|
||||
import {view, ViewType} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractView
|
||||
*/
|
||||
function FilterPopupView()
|
||||
@view({
|
||||
name: 'View/Popup/Filter',
|
||||
type: ViewType.Popup,
|
||||
templateID: 'PopupsFilter'
|
||||
})
|
||||
class FilterPopupView extends AbstractViewNext
|
||||
{
|
||||
AbstractView.call(this, 'Popups', 'PopupsFilter');
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.isNew = ko.observable(true);
|
||||
this.isNew = ko.observable(true);
|
||||
|
||||
this.modules = FilterStore.modules;
|
||||
this.modules = FilterStore.modules;
|
||||
|
||||
this.fTrueCallback = null;
|
||||
this.filter = ko.observable(null);
|
||||
this.fTrueCallback = null;
|
||||
this.filter = ko.observable(null);
|
||||
|
||||
this.allowMarkAsRead = ko.observable(false);
|
||||
this.allowMarkAsRead = ko.observable(false);
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
this.folderSelectList = FolderStore.folderMenuForFilters;
|
||||
this.selectedFolderValue = ko.observable('');
|
||||
this.defautOptionsAfterRender = defautOptionsAfterRender;
|
||||
this.folderSelectList = FolderStore.folderMenuForFilters;
|
||||
this.selectedFolderValue = ko.observable('');
|
||||
|
||||
this.selectedFolderValue.subscribe(function() {
|
||||
if (this.filter())
|
||||
this.selectedFolderValue.subscribe(() => {
|
||||
if (this.filter())
|
||||
{
|
||||
this.filter().actionValue.error(false);
|
||||
}
|
||||
});
|
||||
|
||||
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([]);
|
||||
this.typeOptionsSize = ko.observableArray([]);
|
||||
|
||||
initOnStartOrLangChange(_.bind(this.populateOptions, this));
|
||||
|
||||
this.modules.subscribe(this.populateOptions, this);
|
||||
}
|
||||
|
||||
populateOptions() {
|
||||
this.actionTypeOptions([]);
|
||||
|
||||
// this.actionTypeOptions.push({'id': FiltersAction.None,
|
||||
// 'name': i18n('POPUPS_FILTER/SELECT_ACTION_NONE')});
|
||||
|
||||
const modules = this.modules();
|
||||
if (modules)
|
||||
{
|
||||
this.filter().actionValue.error(false);
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.saveFilter = Utils.createCommand(this, function() {
|
||||
|
||||
if (this.filter())
|
||||
{
|
||||
if (Enums.FiltersAction.MoveTo === this.filter().actionType())
|
||||
if (modules.markasread)
|
||||
{
|
||||
this.filter().actionValue(this.selectedFolderValue());
|
||||
this.allowMarkAsRead(true);
|
||||
}
|
||||
|
||||
if (!this.filter().verify())
|
||||
if (modules.moveto)
|
||||
{
|
||||
return false;
|
||||
this.actionTypeOptions.push({'id': FiltersAction.MoveTo,
|
||||
'name': i18n('POPUPS_FILTER/SELECT_ACTION_MOVE_TO')});
|
||||
}
|
||||
|
||||
if (this.fTrueCallback)
|
||||
if (modules.redirect)
|
||||
{
|
||||
this.fTrueCallback(this.filter());
|
||||
this.actionTypeOptions.push({'id': FiltersAction.Forward,
|
||||
'name': i18n('POPUPS_FILTER/SELECT_ACTION_FORWARD_TO')});
|
||||
}
|
||||
|
||||
if (this.modalVisibility())
|
||||
if (modules.reject)
|
||||
{
|
||||
Utils.delegateRun(this, 'closeCommand');
|
||||
this.actionTypeOptions.push({'id': FiltersAction.Reject,
|
||||
'name': i18n('POPUPS_FILTER/SELECT_ACTION_REJECT')});
|
||||
}
|
||||
|
||||
if (modules.vacation)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': FiltersAction.Vacation,
|
||||
'name': i18n('POPUPS_FILTER/SELECT_ACTION_VACATION_MESSAGE')});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
this.actionTypeOptions.push({'id': FiltersAction.Discard,
|
||||
'name': i18n('POPUPS_FILTER/SELECT_ACTION_DISCARD')});
|
||||
|
||||
this.actionTypeOptions = ko.observableArray([]);
|
||||
this.fieldOptions = ko.observableArray([]);
|
||||
this.typeOptions = ko.observableArray([]);
|
||||
this.typeOptionsSize = ko.observableArray([]);
|
||||
this.fieldOptions([
|
||||
{'id': FilterConditionField.From, 'name': i18n('POPUPS_FILTER/SELECT_FIELD_FROM')},
|
||||
{'id': FilterConditionField.Recipient, 'name': i18n('POPUPS_FILTER/SELECT_FIELD_RECIPIENTS')},
|
||||
{'id': FilterConditionField.Subject, 'name': i18n('POPUPS_FILTER/SELECT_FIELD_SUBJECT')},
|
||||
{'id': FilterConditionField.Size, 'name': i18n('POPUPS_FILTER/SELECT_FIELD_SIZE')},
|
||||
{'id': FilterConditionField.Header, 'name': i18n('POPUPS_FILTER/SELECT_FIELD_HEADER')}
|
||||
]);
|
||||
|
||||
Translator.initOnStartOrLangChange(_.bind(this.populateOptions, this));
|
||||
this.typeOptions([
|
||||
{'id': FilterConditionType.Contains, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_CONTAINS')},
|
||||
{'id': FilterConditionType.NotContains, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_NOT_CONTAINS')},
|
||||
{'id': FilterConditionType.EqualTo, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_EQUAL_TO')},
|
||||
{'id': FilterConditionType.NotEqualTo, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_NOT_EQUAL_TO')}
|
||||
]);
|
||||
|
||||
this.modules.subscribe(this.populateOptions, this);
|
||||
if (modules && modules.regex)
|
||||
{
|
||||
this.typeOptions.push({'id': FilterConditionType.Regex, 'name': 'Regex'});
|
||||
}
|
||||
|
||||
kn.constructorEnd(this);
|
||||
this.typeOptionsSize([
|
||||
{'id': FilterConditionType.Over, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_OVER')},
|
||||
{'id': FilterConditionType.Under, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_UNDER')}
|
||||
]);
|
||||
}
|
||||
|
||||
removeCondition(oConditionToDelete) {
|
||||
if (this.filter())
|
||||
{
|
||||
this.filter().removeCondition(oConditionToDelete);
|
||||
}
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
this.isNew(true);
|
||||
|
||||
this.fTrueCallback = null;
|
||||
this.filter(null);
|
||||
}
|
||||
|
||||
onShow(oFilter, fTrueCallback, bEdit) {
|
||||
this.clearPopup();
|
||||
|
||||
this.fTrueCallback = fTrueCallback;
|
||||
this.filter(oFilter);
|
||||
|
||||
if (oFilter)
|
||||
{
|
||||
this.selectedFolderValue(oFilter.actionValue());
|
||||
}
|
||||
|
||||
this.isNew(!bEdit);
|
||||
|
||||
if (!bEdit && oFilter)
|
||||
{
|
||||
oFilter.name.focused(true);
|
||||
}
|
||||
}
|
||||
|
||||
onShowWithDelay() {
|
||||
if (this.isNew() && this.filter() && !bMobileDevice)
|
||||
{
|
||||
this.filter().name.focused(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kn.extendAsViewModel(['View/Popup/Filter', 'PopupsFilterViewModel'], FilterPopupView);
|
||||
_.extend(FilterPopupView.prototype, AbstractView.prototype);
|
||||
|
||||
FilterPopupView.prototype.populateOptions = function()
|
||||
{
|
||||
this.actionTypeOptions([]);
|
||||
|
||||
// this.actionTypeOptions.push({'id': Enums.FiltersAction.None,
|
||||
// 'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_NONE')});
|
||||
|
||||
var oModules = this.modules();
|
||||
if (oModules)
|
||||
{
|
||||
if (oModules.markasread)
|
||||
{
|
||||
this.allowMarkAsRead(true);
|
||||
}
|
||||
|
||||
if (oModules.moveto)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.MoveTo,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_MOVE_TO')});
|
||||
}
|
||||
|
||||
if (oModules.redirect)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Forward,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_FORWARD_TO')});
|
||||
}
|
||||
|
||||
if (oModules.reject)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Reject,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_REJECT')});
|
||||
}
|
||||
|
||||
if (oModules.vacation)
|
||||
{
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Vacation,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_VACATION_MESSAGE')});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Discard,
|
||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_DISCARD')});
|
||||
|
||||
this.fieldOptions([
|
||||
{'id': Enums.FilterConditionField.From, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_FROM')},
|
||||
{'id': Enums.FilterConditionField.Recipient, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_RECIPIENTS')},
|
||||
{'id': Enums.FilterConditionField.Subject, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SUBJECT')},
|
||||
{'id': Enums.FilterConditionField.Size, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SIZE')},
|
||||
{'id': Enums.FilterConditionField.Header, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_HEADER')}
|
||||
]);
|
||||
|
||||
this.typeOptions([
|
||||
{'id': Enums.FilterConditionType.Contains, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_CONTAINS')},
|
||||
{'id': Enums.FilterConditionType.NotContains, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_CONTAINS')},
|
||||
{'id': Enums.FilterConditionType.EqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_EQUAL_TO')},
|
||||
{'id': Enums.FilterConditionType.NotEqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_EQUAL_TO')}
|
||||
]);
|
||||
|
||||
if (oModules && oModules.regex)
|
||||
{
|
||||
this.typeOptions.push({'id': Enums.FilterConditionType.Regex, 'name': 'Regex'});
|
||||
}
|
||||
|
||||
this.typeOptionsSize([
|
||||
{'id': Enums.FilterConditionType.Over, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_OVER')},
|
||||
{'id': Enums.FilterConditionType.Under, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_UNDER')}
|
||||
]);
|
||||
};
|
||||
|
||||
FilterPopupView.prototype.removeCondition = function(oConditionToDelete)
|
||||
{
|
||||
if (this.filter())
|
||||
{
|
||||
this.filter().removeCondition(oConditionToDelete);
|
||||
}
|
||||
};
|
||||
|
||||
FilterPopupView.prototype.clearPopup = function()
|
||||
{
|
||||
this.isNew(true);
|
||||
|
||||
this.fTrueCallback = null;
|
||||
this.filter(null);
|
||||
};
|
||||
|
||||
FilterPopupView.prototype.onShow = function(oFilter, fTrueCallback, bEdit)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
this.fTrueCallback = fTrueCallback;
|
||||
this.filter(oFilter);
|
||||
|
||||
if (oFilter)
|
||||
{
|
||||
this.selectedFolderValue(oFilter.actionValue());
|
||||
}
|
||||
|
||||
this.isNew(!bEdit);
|
||||
|
||||
if (!bEdit && oFilter)
|
||||
{
|
||||
oFilter.name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
FilterPopupView.prototype.onShowWithDelay = function()
|
||||
{
|
||||
if (this.isNew() && this.filter() && !Globals.bMobile)
|
||||
{
|
||||
this.filter().name.focused(true);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = FilterPopupView;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue