mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03: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
153 changed files with 21193 additions and 21115 deletions
6
.cmds
6
.cmds
|
|
@ -3,10 +3,10 @@
|
||||||
tx pull -a
|
tx pull -a
|
||||||
|
|
||||||
# dependencies checker
|
# dependencies checker
|
||||||
npm-check --skip-unused
|
npm-check --skip-unused --save-exact
|
||||||
|
|
||||||
# dependencies locker
|
# dependencies locker
|
||||||
npm shrinkwrap --dev
|
npm shrinkwrap --dev
|
||||||
|
|
||||||
# js code validation
|
# webpack
|
||||||
gulp v
|
webpack --color --watch
|
||||||
|
|
|
||||||
10
.eslintrc.js
10
.eslintrc.js
|
|
@ -4,6 +4,7 @@ module.exports = {
|
||||||
'ecmaFeatures': {
|
'ecmaFeatures': {
|
||||||
'modules': true
|
'modules': true
|
||||||
},
|
},
|
||||||
|
"parser": "babel-eslint",
|
||||||
'parserOptions': {
|
'parserOptions': {
|
||||||
'ecmaVersion': 6,
|
'ecmaVersion': 6,
|
||||||
'sourceType': 'module'
|
'sourceType': 'module'
|
||||||
|
|
@ -11,8 +12,7 @@ module.exports = {
|
||||||
'env': {
|
'env': {
|
||||||
'node': true,
|
'node': true,
|
||||||
'commonjs': true,
|
'commonjs': true,
|
||||||
'es6': true,
|
'es6': true
|
||||||
'browser': true
|
|
||||||
},
|
},
|
||||||
'globals': {
|
'globals': {
|
||||||
'RL_COMMUNITY': true,
|
'RL_COMMUNITY': true,
|
||||||
|
|
@ -84,7 +84,7 @@ module.exports = {
|
||||||
'no-implicit-coercion': [2, {'allow': ['!!', '+']}],
|
'no-implicit-coercion': [2, {'allow': ['!!', '+']}],
|
||||||
'no-implicit-globals': 2,
|
'no-implicit-globals': 2,
|
||||||
'no-implied-eval': 2,
|
'no-implied-eval': 2,
|
||||||
// 'no-invalid-this': 2,
|
'no-invalid-this': 2,
|
||||||
'no-iterator': 2,
|
'no-iterator': 2,
|
||||||
'no-labels': 2,
|
'no-labels': 2,
|
||||||
'no-lone-blocks': 2,
|
'no-lone-blocks': 2,
|
||||||
|
|
@ -263,9 +263,9 @@ module.exports = {
|
||||||
'no-useless-computed-key': 2,
|
'no-useless-computed-key': 2,
|
||||||
'no-useless-constructor': 2,
|
'no-useless-constructor': 2,
|
||||||
'no-useless-rename': 2,
|
'no-useless-rename': 2,
|
||||||
// 'no-var': 2,
|
'no-var': 2,
|
||||||
// 'object-shorthand': 2,
|
// 'object-shorthand': 2,
|
||||||
// 'prefer-arrow-callback': 2,
|
'prefer-arrow-callback': 2,
|
||||||
'prefer-const': 2,
|
'prefer-const': 2,
|
||||||
// 'prefer-reflect': 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/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/**/*.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/*
|
||||||
!/rainloop/v/0.0.0/app/localization/moment/.gitempty
|
!/rainloop/v/0.0.0/app/localization/moment/.gitempty
|
||||||
/node_modules
|
/node_modules
|
||||||
|
|
|
||||||
12
.travis.yml
12
.travis.yml
|
|
@ -5,9 +5,9 @@ php:
|
||||||
- '5.5'
|
- '5.5'
|
||||||
- '5.6'
|
- '5.6'
|
||||||
- '7.0'
|
- '7.0'
|
||||||
before_script:
|
#before_script:
|
||||||
- sudo apt-get install -y build-essential libssl-dev
|
# - sudo apt-get install -y build-essential libssl-dev
|
||||||
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
|
# - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
|
||||||
- nvm install 4.4.5
|
# - nvm install 4.4.5
|
||||||
- nvm use 4.4.5
|
# - nvm use 4.4.5
|
||||||
- npm install -g eslint
|
# - npm install -g eslint babel-eslint
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
RainLoop Webmail [](https://travis-ci.org/RainLoop/rainloop-webmail)
|
RainLoop Webmail [](https://travis-ci.org/RainLoop/rainloop-webmail) [](https://david-dm.org/RainLoop/rainloop-webmail?type=dev)
|
||||||
==================
|
==================
|
||||||
|
|
||||||
Simple, modern & fast web-based email client.
|
Simple, modern & fast web-based email client.
|
||||||
|
|
|
||||||
253
dev/App/User.js
253
dev/App/User.js
|
|
@ -7,7 +7,7 @@ import Tinycon from 'Tinycon';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
noop, trim, log, has, isArray, inArray, isUnd, isNormal, isPosNumeric, isNonEmptyArray,
|
noop, trim, log, has, isArray, inArray, isUnd, isNormal, isPosNumeric, isNonEmptyArray,
|
||||||
pInt, pString, delegateRunOnDestroy, mailToHelper, windowResize
|
pInt, pString, delegateRunOnDestroy, mailToHelper, windowResize, jassl
|
||||||
} from 'Common/Utils';
|
} from 'Common/Utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
@ -241,33 +241,33 @@ class AppUser extends AbstractApp
|
||||||
sTrashFolder = FolderStore.trashFolder(),
|
sTrashFolder = FolderStore.trashFolder(),
|
||||||
sSpamFolder = FolderStore.spamFolder();
|
sSpamFolder = FolderStore.spamFolder();
|
||||||
|
|
||||||
_.each(this.moveCache, (oItem) => {
|
_.each(this.moveCache, (item) => {
|
||||||
|
|
||||||
var
|
const
|
||||||
bSpam = sSpamFolder === oItem.To,
|
isSpam = sSpamFolder === item.To,
|
||||||
bTrash = sTrashFolder === oItem.To,
|
isTrash = sTrashFolder === item.To,
|
||||||
bHam = !bSpam && sSpamFolder === oItem.From && Cache.getFolderInboxName() === oItem.To;
|
isHam = !isSpam && sSpamFolder === item.From && Cache.getFolderInboxName() === item.To;
|
||||||
|
|
||||||
Remote.messagesMove(this.moveOrDeleteResponseHelper, oItem.From, oItem.To, oItem.Uid,
|
Remote.messagesMove(this.moveOrDeleteResponseHelper, item.From, item.To, item.Uid,
|
||||||
bSpam ? 'SPAM' : (bHam ? 'HAM' : ''), bSpam || bTrash);
|
isSpam ? 'SPAM' : (isHam ? 'HAM' : ''), isSpam || isTrash);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.moveCache = {};
|
this.moveCache = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
messagesMoveHelper(sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForMove) {
|
messagesMoveHelper(fromFolderFullNameRaw, toFolderFullNameRaw, uidsForMove) {
|
||||||
|
|
||||||
var sH = '$$' + sFromFolderFullNameRaw + '$$' + sToFolderFullNameRaw + '$$';
|
const hash = '$$' + fromFolderFullNameRaw + '$$' + toFolderFullNameRaw + '$$';
|
||||||
if (!this.moveCache[sH])
|
if (!this.moveCache[hash])
|
||||||
{
|
{
|
||||||
this.moveCache[sH] = {
|
this.moveCache[hash] = {
|
||||||
From: sFromFolderFullNameRaw,
|
From: fromFolderFullNameRaw,
|
||||||
To: sToFolderFullNameRaw,
|
To: toFolderFullNameRaw,
|
||||||
Uid: []
|
Uid: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
this.moveCache[sH].Uid = _.union(this.moveCache[sH].Uid, aUidForMove);
|
this.moveCache[hash].Uid = _.union(this.moveCache[hash].Uid, uidsForMove);
|
||||||
this.messagesMoveTrigger();
|
this.messagesMoveTrigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -451,20 +451,20 @@ class AppUser extends AbstractApp
|
||||||
|
|
||||||
if (PgpStore.capaOpenPGP())
|
if (PgpStore.capaOpenPGP())
|
||||||
{
|
{
|
||||||
var
|
const
|
||||||
aKeys = [],
|
keys = [],
|
||||||
oEmail = new EmailModel(),
|
email = new EmailModel(),
|
||||||
oOpenpgpKeyring = PgpStore.openpgpKeyring,
|
openpgpKeyring = PgpStore.openpgpKeyring,
|
||||||
oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.getAllKeys() : [];
|
openpgpKeys = openpgpKeyring ? openpgpKeyring.getAllKeys() : [];
|
||||||
|
|
||||||
_.each(oOpenpgpKeys, (oItem, iIndex) => {
|
_.each(openpgpKeys, (oItem, iIndex) => {
|
||||||
if (oItem && oItem.primaryKey)
|
if (oItem && oItem.primaryKey)
|
||||||
{
|
{
|
||||||
var
|
const
|
||||||
aEmails = [],
|
aEmails = [],
|
||||||
aUsers = [],
|
aUsers = [],
|
||||||
oPrimaryUser = oItem.getPrimaryUser(),
|
primaryUser = oItem.getPrimaryUser(),
|
||||||
sUser = (oPrimaryUser && oPrimaryUser.user) ? oPrimaryUser.user.userId.userid :
|
user = (primaryUser && primaryUser.user) ? primaryUser.user.userId.userid :
|
||||||
(oItem.users && oItem.users[0] ? oItem.users[0].userId.userid : '');
|
(oItem.users && oItem.users[0] ? oItem.users[0].userId.userid : '');
|
||||||
|
|
||||||
if (oItem.users)
|
if (oItem.users)
|
||||||
|
|
@ -472,11 +472,11 @@ class AppUser extends AbstractApp
|
||||||
_.each(oItem.users, (item) => {
|
_.each(oItem.users, (item) => {
|
||||||
if (item.userId)
|
if (item.userId)
|
||||||
{
|
{
|
||||||
oEmail.clear();
|
email.clear();
|
||||||
oEmail.mailsoParse(item.userId.userid);
|
email.mailsoParse(item.userId.userid);
|
||||||
if (oEmail.validate())
|
if (email.validate())
|
||||||
{
|
{
|
||||||
aEmails.push(oEmail.email);
|
aEmails.push(email.email);
|
||||||
aUsers.push(item.userId.userid);
|
aUsers.push(item.userId.userid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -485,7 +485,7 @@ class AppUser extends AbstractApp
|
||||||
|
|
||||||
if (aEmails.length)
|
if (aEmails.length)
|
||||||
{
|
{
|
||||||
aKeys.push(new OpenPgpKeyModel(
|
keys.push(new OpenPgpKeyModel(
|
||||||
iIndex,
|
iIndex,
|
||||||
oItem.primaryKey.getFingerprint(),
|
oItem.primaryKey.getFingerprint(),
|
||||||
oItem.primaryKey.getKeyId().toHex().toLowerCase(),
|
oItem.primaryKey.getKeyId().toHex().toLowerCase(),
|
||||||
|
|
@ -496,14 +496,14 @@ class AppUser extends AbstractApp
|
||||||
aEmails,
|
aEmails,
|
||||||
oItem.isPrivate(),
|
oItem.isPrivate(),
|
||||||
oItem.armor(),
|
oItem.armor(),
|
||||||
sUser)
|
user)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
delegateRunOnDestroy(PgpStore.openpgpkeys());
|
delegateRunOnDestroy(PgpStore.openpgpkeys());
|
||||||
PgpStore.openpgpkeys(aKeys);
|
PgpStore.openpgpkeys(keys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -549,10 +549,11 @@ class AppUser extends AbstractApp
|
||||||
|
|
||||||
if (StorageResultType.Success === sResult && oData.Result)
|
if (StorageResultType.Success === sResult && oData.Result)
|
||||||
{
|
{
|
||||||
var
|
const
|
||||||
aCounts = {},
|
aCounts = {},
|
||||||
sParentEmail = Settings.settingsGet('ParentEmail'),
|
|
||||||
sAccountEmail = AccountStore.email();
|
sAccountEmail = AccountStore.email();
|
||||||
|
let
|
||||||
|
sParentEmail = Settings.settingsGet('ParentEmail');
|
||||||
|
|
||||||
sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail;
|
sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail;
|
||||||
|
|
||||||
|
|
@ -735,14 +736,15 @@ class AppUser extends AbstractApp
|
||||||
const utc = Momentor.momentNowUnix();
|
const utc = Momentor.momentNowUnix();
|
||||||
_.each(oData.Result.List, (oItem) => {
|
_.each(oData.Result.List, (oItem) => {
|
||||||
|
|
||||||
var
|
const
|
||||||
sHash = Cache.getFolderHash(oItem.Folder),
|
hash = Cache.getFolderHash(oItem.Folder),
|
||||||
oFolder = Cache.getFolderFromCacheList(oItem.Folder),
|
folder = Cache.getFolderFromCacheList(oItem.Folder);
|
||||||
bUnreadCountChange = false;
|
let
|
||||||
|
unreadCountChange = false;
|
||||||
|
|
||||||
if (oFolder)
|
if (folder)
|
||||||
{
|
{
|
||||||
oFolder.interval = utc;
|
folder.interval = utc;
|
||||||
|
|
||||||
if (oItem.Hash)
|
if (oItem.Hash)
|
||||||
{
|
{
|
||||||
|
|
@ -751,39 +753,39 @@ class AppUser extends AbstractApp
|
||||||
|
|
||||||
if (isNormal(oItem.MessageCount))
|
if (isNormal(oItem.MessageCount))
|
||||||
{
|
{
|
||||||
oFolder.messageCountAll(oItem.MessageCount);
|
folder.messageCountAll(oItem.MessageCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNormal(oItem.MessageUnseenCount))
|
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();
|
this.reloadMessageList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (bUnreadCountChange)
|
else if (unreadCountChange)
|
||||||
{
|
{
|
||||||
if (oFolder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
|
if (folder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
|
||||||
{
|
{
|
||||||
const aList = MessageStore.messageList();
|
const aList = MessageStore.messageList();
|
||||||
if (isNonEmptyArray(aList))
|
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} sFolderFullNameRaw
|
||||||
* @param {string|bool} mUid
|
* @param {string|bool} mUid
|
||||||
* @param {number} iSetAction
|
* @param {number} iSetAction
|
||||||
* @param {Array=} aMessages = null
|
* @param {Array=} messages = null
|
||||||
*/
|
*/
|
||||||
messageListAction(sFolderFullNameRaw, mUid, iSetAction, aMessages) {
|
messageListAction(sFolderFullNameRaw, mUid, iSetAction, messages) {
|
||||||
|
|
||||||
var
|
let
|
||||||
oFolder = null,
|
folder = null,
|
||||||
aRootUids = [],
|
alreadyUnread = 0,
|
||||||
iAlreadyUnread = 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)
|
switch (iSetAction)
|
||||||
{
|
{
|
||||||
case MessageSetAction.SetSeen:
|
case MessageSetAction.SetSeen:
|
||||||
|
|
||||||
_.each(aRootUids, (sSubUid) => {
|
_.each(rootUids, (sSubUid) => {
|
||||||
iAlreadyUnread += Cache.storeMessageFlagsToCacheBySetAction(
|
alreadyUnread += Cache.storeMessageFlagsToCacheBySetAction(
|
||||||
sFolderFullNameRaw, sSubUid, iSetAction);
|
sFolderFullNameRaw, sSubUid, iSetAction);
|
||||||
});
|
});
|
||||||
|
|
||||||
oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
folder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||||
if (oFolder)
|
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;
|
break;
|
||||||
|
|
||||||
case MessageSetAction.UnsetSeen:
|
case MessageSetAction.UnsetSeen:
|
||||||
|
|
||||||
_.each(aRootUids, (sSubUid) => {
|
_.each(rootUids, (sSubUid) => {
|
||||||
iAlreadyUnread += Cache.storeMessageFlagsToCacheBySetAction(
|
alreadyUnread += Cache.storeMessageFlagsToCacheBySetAction(
|
||||||
sFolderFullNameRaw, sSubUid, iSetAction);
|
sFolderFullNameRaw, sSubUid, iSetAction);
|
||||||
});
|
});
|
||||||
|
|
||||||
oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
folder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
|
||||||
if (oFolder)
|
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;
|
break;
|
||||||
|
|
||||||
case MessageSetAction.SetFlag:
|
case MessageSetAction.SetFlag:
|
||||||
|
|
||||||
_.each(aRootUids, (sSubUid) => {
|
_.each(rootUids, (sSubUid) => {
|
||||||
Cache.storeMessageFlagsToCacheBySetAction(
|
Cache.storeMessageFlagsToCacheBySetAction(
|
||||||
sFolderFullNameRaw, sSubUid, iSetAction);
|
sFolderFullNameRaw, sSubUid, iSetAction);
|
||||||
});
|
});
|
||||||
|
|
||||||
Remote.messageSetFlagged(noop, sFolderFullNameRaw, aRootUids, true);
|
Remote.messageSetFlagged(noop, sFolderFullNameRaw, rootUids, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MessageSetAction.UnsetFlag:
|
case MessageSetAction.UnsetFlag:
|
||||||
|
|
||||||
_.each(aRootUids, (sSubUid) => {
|
_.each(rootUids, (sSubUid) => {
|
||||||
Cache.storeMessageFlagsToCacheBySetAction(
|
Cache.storeMessageFlagsToCacheBySetAction(
|
||||||
sFolderFullNameRaw, sSubUid, iSetAction);
|
sFolderFullNameRaw, sSubUid, iSetAction);
|
||||||
});
|
});
|
||||||
|
|
||||||
Remote.messageSetFlagged(noop, sFolderFullNameRaw, aRootUids, false);
|
Remote.messageSetFlagged(noop, sFolderFullNameRaw, rootUids, false);
|
||||||
break;
|
break;
|
||||||
// no default
|
// no default
|
||||||
}
|
}
|
||||||
|
|
@ -985,12 +987,13 @@ class AppUser extends AbstractApp
|
||||||
|
|
||||||
initHorizontalLayoutResizer(sClientSideKeyName) {
|
initHorizontalLayoutResizer(sClientSideKeyName) {
|
||||||
|
|
||||||
var
|
let
|
||||||
iMinHeight = 200,
|
|
||||||
iMaxHeight = 500,
|
|
||||||
oTop = null,
|
oTop = null,
|
||||||
oBottom = null,
|
oBottom = null;
|
||||||
|
|
||||||
|
const
|
||||||
|
minHeight = 200,
|
||||||
|
maxHeight = 500,
|
||||||
fSetHeight = (height) => {
|
fSetHeight = (height) => {
|
||||||
if (height)
|
if (height)
|
||||||
{
|
{
|
||||||
|
|
@ -1009,9 +1012,7 @@ class AppUser extends AbstractApp
|
||||||
fResizeCreateFunction = (event) => {
|
fResizeCreateFunction = (event) => {
|
||||||
if (event && event.target)
|
if (event && event.target)
|
||||||
{
|
{
|
||||||
var oResizableHandle = $(event.target).find('.ui-resizable-handle');
|
$(event.target).find('.ui-resizable-handle')
|
||||||
|
|
||||||
oResizableHandle
|
|
||||||
.on('mousedown', () => {
|
.on('mousedown', () => {
|
||||||
$html.addClass('rl-resizer');
|
$html.addClass('rl-resizer');
|
||||||
})
|
})
|
||||||
|
|
@ -1043,8 +1044,8 @@ class AppUser extends AbstractApp
|
||||||
|
|
||||||
oOptions = {
|
oOptions = {
|
||||||
helper: 'ui-resizable-helper-h',
|
helper: 'ui-resizable-helper-h',
|
||||||
minHeight: iMinHeight,
|
minHeight: minHeight,
|
||||||
maxHeight: iMaxHeight,
|
maxHeight: maxHeight,
|
||||||
handles: 's',
|
handles: 's',
|
||||||
create: fResizeCreateFunction,
|
create: fResizeCreateFunction,
|
||||||
resize: fResizeResizeFunction,
|
resize: fResizeResizeFunction,
|
||||||
|
|
@ -1078,7 +1079,7 @@ class AppUser extends AbstractApp
|
||||||
}
|
}
|
||||||
|
|
||||||
const iHeight = pInt(Local.get(sClientSideKeyName)) || 300;
|
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) {
|
initVerticalLayoutResizer(sClientSideKeyName) {
|
||||||
|
|
||||||
var
|
const
|
||||||
iDisabledWidth = 60,
|
disabledWidth = 60,
|
||||||
iMinWidth = 155,
|
minWidth = 155,
|
||||||
oLeft = $('#rl-left'),
|
lLeft = $('#rl-left'),
|
||||||
oRight = $('#rl-right'),
|
right = $('#rl-right'),
|
||||||
|
|
||||||
mLeftWidth = Local.get(sClientSideKeyName) || null,
|
mLeftWidth = Local.get(sClientSideKeyName) || null,
|
||||||
|
|
||||||
|
|
@ -1106,11 +1107,11 @@ class AppUser extends AbstractApp
|
||||||
|
|
||||||
$html.removeClass('rl-resizer');
|
$html.removeClass('rl-resizer');
|
||||||
|
|
||||||
oLeft.css({
|
lLeft.css({
|
||||||
width: '' + iWidth + 'px'
|
width: '' + iWidth + 'px'
|
||||||
});
|
});
|
||||||
|
|
||||||
oRight.css({
|
right.css({
|
||||||
left: '' + iWidth + 'px'
|
left: '' + iWidth + 'px'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1119,14 +1120,14 @@ class AppUser extends AbstractApp
|
||||||
fDisable = (bDisable) => {
|
fDisable = (bDisable) => {
|
||||||
if (bDisable)
|
if (bDisable)
|
||||||
{
|
{
|
||||||
oLeft.resizable('disable');
|
lLeft.resizable('disable');
|
||||||
fSetWidth(iDisabledWidth);
|
fSetWidth(disabledWidth);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oLeft.resizable('enable');
|
lLeft.resizable('enable');
|
||||||
var iWidth = pInt(Local.get(sClientSideKeyName)) || iMinWidth;
|
const width = pInt(Local.get(sClientSideKeyName)) || minWidth;
|
||||||
fSetWidth(iWidth > iMinWidth ? iWidth : iMinWidth);
|
fSetWidth(width > minWidth ? width : minWidth);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1156,11 +1157,11 @@ class AppUser extends AbstractApp
|
||||||
|
|
||||||
leftPanelWidth(oObject.size.width);
|
leftPanelWidth(oObject.size.width);
|
||||||
|
|
||||||
oRight.css({
|
right.css({
|
||||||
left: '' + oObject.size.width + 'px'
|
left: '' + oObject.size.width + 'px'
|
||||||
});
|
});
|
||||||
|
|
||||||
oLeft.css({
|
lLeft.css({
|
||||||
position: '',
|
position: '',
|
||||||
top: '',
|
top: '',
|
||||||
left: '',
|
left: '',
|
||||||
|
|
@ -1171,12 +1172,12 @@ class AppUser extends AbstractApp
|
||||||
|
|
||||||
if (null !== mLeftWidth)
|
if (null !== mLeftWidth)
|
||||||
{
|
{
|
||||||
fSetWidth(mLeftWidth > iMinWidth ? mLeftWidth : iMinWidth);
|
fSetWidth(mLeftWidth > minWidth ? mLeftWidth : minWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
oLeft.resizable({
|
lLeft.resizable({
|
||||||
helper: 'ui-resizable-helper-w',
|
helper: 'ui-resizable-helper-w',
|
||||||
minWidth: iMinWidth,
|
minWidth: minWidth,
|
||||||
maxWidth: 350,
|
maxWidth: 350,
|
||||||
handles: 'e',
|
handles: 'e',
|
||||||
create: fResizeCreateFunction,
|
create: fResizeCreateFunction,
|
||||||
|
|
@ -1229,7 +1230,7 @@ class AppUser extends AbstractApp
|
||||||
setHash(Links.root(), true);
|
setHash(Links.root(), true);
|
||||||
routeOff();
|
routeOff();
|
||||||
|
|
||||||
_.defer(function() {
|
_.defer(() => {
|
||||||
window.location.href = customLoginLink;
|
window.location.href = customLoginLink;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1253,13 +1254,15 @@ class AppUser extends AbstractApp
|
||||||
require('Stores/User/Account').populate();
|
require('Stores/User/Account').populate();
|
||||||
require('Stores/User/Contact').populate();
|
require('Stores/User/Contact').populate();
|
||||||
|
|
||||||
var
|
let
|
||||||
sJsHash = Settings.appSettingsGet('jsHash'),
|
contactsSyncInterval = pInt(Settings.settingsGet('ContactsSyncInterval'));
|
||||||
sStartupUrl = pString(Settings.settingsGet('StartupUrl')),
|
|
||||||
iContactsSyncInterval = pInt(Settings.settingsGet('ContactsSyncInterval')),
|
const
|
||||||
bGoogle = Settings.settingsGet('AllowGoogleSocial'),
|
jsHash = Settings.appSettingsGet('jsHash'),
|
||||||
bFacebook = Settings.settingsGet('AllowFacebookSocial'),
|
startupUrl = pString(Settings.settingsGet('StartupUrl')),
|
||||||
bTwitter = Settings.settingsGet('AllowTwitterSocial');
|
allowGoogle = Settings.settingsGet('AllowGoogleSocial'),
|
||||||
|
allowFacebook = Settings.settingsGet('AllowFacebookSocial'),
|
||||||
|
allowTwitter = Settings.settingsGet('AllowTwitterSocial');
|
||||||
|
|
||||||
if (progressJs)
|
if (progressJs)
|
||||||
{
|
{
|
||||||
|
|
@ -1294,14 +1297,14 @@ class AppUser extends AbstractApp
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
if ('' !== sStartupUrl)
|
if ('' !== startupUrl)
|
||||||
{
|
{
|
||||||
routeOff();
|
routeOff();
|
||||||
setHash(Links.root(sStartupUrl), true);
|
setHash(Links.root(startupUrl), true);
|
||||||
routeOn();
|
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) => {
|
const openpgpCallback = (openpgp) => {
|
||||||
|
|
||||||
|
|
@ -1333,7 +1336,7 @@ class AppUser extends AbstractApp
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.jassl(Links.openPgpJs()).then(() => {
|
jassl(Links.openPgpJs()).then(() => {
|
||||||
if (window.openpgp)
|
if (window.openpgp)
|
||||||
{
|
{
|
||||||
openpgpCallback(window.openpgp);
|
openpgpCallback(window.openpgp);
|
||||||
|
|
@ -1352,7 +1355,7 @@ class AppUser extends AbstractApp
|
||||||
// false ? AboutUserScreen : null
|
// false ? AboutUserScreen : null
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (bGoogle || bFacebook || bTwitter)
|
if (allowGoogle || allowFacebook || allowTwitter)
|
||||||
{
|
{
|
||||||
this.socialUsers(true);
|
this.socialUsers(true);
|
||||||
}
|
}
|
||||||
|
|
@ -1370,13 +1373,13 @@ class AppUser extends AbstractApp
|
||||||
Events.sub('interval.15m', () => this.quota());
|
Events.sub('interval.15m', () => this.quota());
|
||||||
Events.sub('interval.20m', () => this.foldersReload());
|
Events.sub('interval.20m', () => this.foldersReload());
|
||||||
|
|
||||||
iContactsSyncInterval = 5 <= iContactsSyncInterval ? iContactsSyncInterval : 20;
|
contactsSyncInterval = 5 <= contactsSyncInterval ? contactsSyncInterval : 20;
|
||||||
iContactsSyncInterval = 320 >= iContactsSyncInterval ? iContactsSyncInterval : 320;
|
contactsSyncInterval = 320 >= contactsSyncInterval ? contactsSyncInterval : 320;
|
||||||
|
|
||||||
_.delay(() => this.contactsSync(), 10000);
|
_.delay(() => this.contactsSync(), 10000);
|
||||||
_.delay(() => this.folderInformationMultiply(true), 2000);
|
_.delay(() => this.folderInformationMultiply(true), 2000);
|
||||||
|
|
||||||
window.setInterval(() => this.contactsSync(), iContactsSyncInterval * 60000 + 5000);
|
window.setInterval(() => this.contactsSync(), contactsSyncInterval * 60000 + 5000);
|
||||||
|
|
||||||
this.accountsAndIdentities(true);
|
this.accountsAndIdentities(true);
|
||||||
|
|
||||||
|
|
@ -1451,25 +1454,25 @@ class AppUser extends AbstractApp
|
||||||
this.bootstartLoginScreen();
|
this.bootstartLoginScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bGoogle)
|
if (allowGoogle)
|
||||||
{
|
{
|
||||||
window['rl_' + sJsHash + '_google_service'] = () => {
|
window['rl_' + jsHash + '_google_service'] = () => {
|
||||||
SocialStore.google.loading(true);
|
SocialStore.google.loading(true);
|
||||||
this.socialUsers();
|
this.socialUsers();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bFacebook)
|
if (allowFacebook)
|
||||||
{
|
{
|
||||||
window['rl_' + sJsHash + '_facebook_service'] = () => {
|
window['rl_' + jsHash + '_facebook_service'] = () => {
|
||||||
SocialStore.facebook.loading(true);
|
SocialStore.facebook.loading(true);
|
||||||
this.socialUsers();
|
this.socialUsers();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bTwitter)
|
if (allowTwitter)
|
||||||
{
|
{
|
||||||
window['rl_' + sJsHash + '_twitter_service'] = () => {
|
window['rl_' + jsHash + '_twitter_service'] = () => {
|
||||||
SocialStore.twitter.loading(true);
|
SocialStore.twitter.loading(true);
|
||||||
this.socialUsers();
|
this.socialUsers();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ class Audio
|
||||||
if (this.supported)
|
if (this.supported)
|
||||||
{
|
{
|
||||||
$(this.player).on('ended error', () => this.stop());
|
$(this.player).on('ended error', () => this.stop());
|
||||||
|
|
||||||
Events.sub('audio.api.stop', () => this.stop());
|
Events.sub('audio.api.stop', () => this.stop());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
|
/* global RL_ES6 */
|
||||||
|
|
||||||
import window from 'window';
|
import window from 'window';
|
||||||
import progressJs from 'progressJs';
|
import progressJs from 'progressJs';
|
||||||
import Promise from 'Promise';
|
import Promise from 'Promise';
|
||||||
|
|
||||||
import STYLES_CSS from 'Styles/@Boot.css';
|
import {jassl} from 'Common/Jassl';
|
||||||
import LAYOUT_HTML from 'Html/Layout.html';
|
|
||||||
|
|
||||||
import {getHash, setHash, clearHash} from 'Storage/RainLoop';
|
import {getHash, setHash, clearHash} from 'Storage/RainLoop';
|
||||||
|
|
||||||
let RL_APP_DATA_STORAGE = null;
|
let RL_APP_DATA_STORAGE = null;
|
||||||
|
|
@ -64,7 +64,7 @@ class Q2 extends Q1 { constructor() { super() } }
|
||||||
*/
|
*/
|
||||||
function getComputedStyle(id, name)
|
function getComputedStyle(id, name)
|
||||||
{
|
{
|
||||||
var element = window.document.getElementById(id);
|
const element = window.document.getElementById(id);
|
||||||
return element.currentStyle ? element.currentStyle[name] :
|
return element.currentStyle ? element.currentStyle[name] :
|
||||||
(window.getComputedStyle ? window.getComputedStyle(element, null).getPropertyValue(name) : null);
|
(window.getComputedStyle ? window.getComputedStyle(element, null).getPropertyValue(name) : null);
|
||||||
}
|
}
|
||||||
|
|
@ -94,14 +94,11 @@ function includeLayout()
|
||||||
{
|
{
|
||||||
const app = window.document.getElementById('rl-app');
|
const app = window.document.getElementById('rl-app');
|
||||||
|
|
||||||
if (STYLES_CSS)
|
require('style-loader!Styles/@Boot.css');
|
||||||
{
|
|
||||||
includeStyle(STYLES_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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -223,7 +220,7 @@ function runApp()
|
||||||
{
|
{
|
||||||
const appData = window.__rlah_data();
|
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)
|
appData.StaticLibJsLink && appData.StaticAppJsLink && appData.StaticAppJsNextLink && appData.StaticEditorJsLink)
|
||||||
{
|
{
|
||||||
const p = progressJs;
|
const p = progressJs;
|
||||||
|
|
@ -232,7 +229,7 @@ function runApp()
|
||||||
p.start().set(5);
|
p.start().set(5);
|
||||||
|
|
||||||
const
|
const
|
||||||
libs = window.jassl(appData.StaticLibJsLink).then(() => {
|
libs = jassl(appData.StaticLibJsLink).then(() => {
|
||||||
if (window.$)
|
if (window.$)
|
||||||
{
|
{
|
||||||
window.$('#rl-check').remove();
|
window.$('#rl-check').remove();
|
||||||
|
|
@ -247,18 +244,18 @@ function runApp()
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
common = Promise.all([
|
common = Promise.all([
|
||||||
window.jassl(appData.TemplatesLink),
|
jassl(appData.TemplatesLink),
|
||||||
window.jassl(appData.LangLink)
|
jassl(appData.LangLink)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Promise.all([libs, common])
|
Promise.all([libs, common])
|
||||||
.then(() => {
|
.then(() => {
|
||||||
p.set(30);
|
p.set(30);
|
||||||
return window.jassl(useJsNextBundle ? appData.StaticAppJsNextLink : appData.StaticAppJsLink);
|
return jassl(useJsNextBundle ? appData.StaticAppJsNextLink : appData.StaticAppJsLink);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
p.set(50);
|
p.set(50);
|
||||||
return appData.PluginsLink ? window.jassl(appData.PluginsLink) : window.Promise.resolve();
|
return appData.PluginsLink ? jassl(appData.PluginsLink) : window.Promise.resolve();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
p.set(70);
|
p.set(70);
|
||||||
|
|
@ -268,7 +265,7 @@ function runApp()
|
||||||
runMainBoot(true);
|
runMainBoot(true);
|
||||||
throw e;
|
throw e;
|
||||||
})
|
})
|
||||||
.then(() => window.jassl(appData.StaticEditorJsLink))
|
.then(() => jassl(appData.StaticEditorJsLink))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (window.CKEDITOR && window.__initEditor) {
|
if (window.CKEDITOR && window.__initEditor) {
|
||||||
window.__initEditor();
|
window.__initEditor();
|
||||||
|
|
@ -320,7 +317,7 @@ window.__runBoot = function() {
|
||||||
window.document.location.replace('./?/NoCookie');
|
window.document.location.replace('./?/NoCookie');
|
||||||
}
|
}
|
||||||
|
|
||||||
const root = document.documentElement;
|
const root = window.document.documentElement;
|
||||||
if ('none' !== getComputedStyle('rl-check', 'display'))
|
if ('none' !== getComputedStyle('rl-check', 'display'))
|
||||||
{
|
{
|
||||||
root.className += ' no-css';
|
root.className += ' no-css';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
/* global RL_COMMUNITY */
|
||||||
|
|
||||||
import window from 'window';
|
import window from 'window';
|
||||||
import _ from '_';
|
import _ from '_';
|
||||||
import $ from '$';
|
import $ from '$';
|
||||||
|
|
@ -167,9 +169,7 @@ let bAllowPdfPreview = !bMobileDevice;
|
||||||
|
|
||||||
if (bAllowPdfPreview && window.navigator && window.navigator.mimeTypes)
|
if (bAllowPdfPreview && window.navigator && window.navigator.mimeTypes)
|
||||||
{
|
{
|
||||||
bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function(oType) {
|
bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, (type) => type && 'application/pdf' === type.type);
|
||||||
return oType && 'application/pdf' === oType.type;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!bAllowPdfPreview)
|
if (!bAllowPdfPreview)
|
||||||
{
|
{
|
||||||
|
|
@ -203,33 +203,29 @@ export const keyScopeReal = ko.observable(KeyState.All);
|
||||||
export const keyScopeFake = ko.observable(KeyState.All);
|
export const keyScopeFake = ko.observable(KeyState.All);
|
||||||
|
|
||||||
export const keyScope = ko.computed({
|
export const keyScope = ko.computed({
|
||||||
owner: this,
|
|
||||||
read: () => keyScopeFake(),
|
read: () => keyScopeFake(),
|
||||||
write: function(sValue) {
|
write: (value) => {
|
||||||
|
|
||||||
if (KeyState.Menu !== sValue)
|
if (KeyState.Menu !== value)
|
||||||
{
|
{
|
||||||
if (KeyState.Compose === sValue)
|
if (KeyState.Compose === value)
|
||||||
{
|
{
|
||||||
// disableKeyFilter
|
// disableKeyFilter
|
||||||
key.filter = function() {
|
key.filter = () => useKeyboardShortcuts();
|
||||||
return useKeyboardShortcuts();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// restoreKeyFilter
|
// restoreKeyFilter
|
||||||
key.filter = function(event) {
|
key.filter = (event) => {
|
||||||
|
|
||||||
if (useKeyboardShortcuts())
|
if (useKeyboardShortcuts())
|
||||||
{
|
{
|
||||||
var
|
const
|
||||||
oElement = event.target || event.srcElement,
|
el = event.target || event.srcElement,
|
||||||
sTagName = oElement ? oElement.tagName : '';
|
tagName = el ? el.tagName.toUpperCase() : '';
|
||||||
|
|
||||||
sTagName = sTagName.toUpperCase();
|
return !('INPUT' === tagName || 'SELECT' === tagName || 'TEXTAREA' === tagName ||
|
||||||
return !('INPUT' === sTagName || 'SELECT' === sTagName || 'TEXTAREA' === sTagName ||
|
(el && 'DIV' === tagName && ('editorHtmlArea' === el.className || 'true' === '' + el.contentEditable))
|
||||||
(oElement && 'DIV' === sTagName && ('editorHtmlArea' === oElement.className || 'true' === '' + oElement.contentEditable))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,24 +233,24 @@ export const keyScope = ko.computed({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
keyScopeFake(sValue);
|
keyScopeFake(value);
|
||||||
if (dropdownVisibility())
|
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
|
// window.console.log('keyScope=' + sValue); // DEBUG
|
||||||
key.setScope(sValue);
|
key.setScope(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
dropdownVisibility.subscribe(function(bValue) {
|
dropdownVisibility.subscribe((value) => {
|
||||||
if (bValue)
|
if (value)
|
||||||
{
|
{
|
||||||
keyScope(KeyState.Menu);
|
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=} wrapIsHtml = false
|
||||||
* @param {boolean=} clearSignatureSigns = false
|
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
getData(wrapIsHtml = false, clearSignatureSigns = false) {
|
getData(wrapIsHtml = false) {
|
||||||
|
|
||||||
let result = '';
|
let result = '';
|
||||||
if (this.editor)
|
if (this.editor)
|
||||||
|
|
@ -119,11 +110,6 @@ class HtmlEditor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {} // eslint-disable-line no-empty
|
catch (e) {} // eslint-disable-line no-empty
|
||||||
|
|
||||||
if (clearSignatureSigns)
|
|
||||||
{
|
|
||||||
result = this.clearSignatureSigns(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -131,11 +117,10 @@ class HtmlEditor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {boolean=} wrapIsHtml = false
|
* @param {boolean=} wrapIsHtml = false
|
||||||
* @param {boolean=} clearSignatureSigns = false
|
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
getDataWithHtmlMark(wrapIsHtml = false, clearSignatureSigns = false) {
|
getDataWithHtmlMark(wrapIsHtml = false) {
|
||||||
return (this.isHtml() ? ':HTML:' : '') + this.getData(wrapIsHtml, clearSignatureSigns);
|
return (this.isHtml() ? ':HTML:' : '') + this.getData(wrapIsHtml);
|
||||||
}
|
}
|
||||||
|
|
||||||
modeToggle(plain, resize) {
|
modeToggle(plain, resize) {
|
||||||
|
|
@ -149,14 +134,11 @@ class HtmlEditor
|
||||||
this.editor.setMode('wysiwyg');
|
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
|
catch (e) {} // eslint-disable-line no-empty
|
||||||
|
|
||||||
if (resize)
|
if (resize)
|
||||||
|
|
@ -302,7 +284,7 @@ class HtmlEditor
|
||||||
if (file && window.FileReader && event.data.dataTransfer.id &&
|
if (file && window.FileReader && event.data.dataTransfer.id &&
|
||||||
file.type && file.type.match(/^image/i))
|
file.type && file.type.match(/^image/i))
|
||||||
{
|
{
|
||||||
var
|
const
|
||||||
id = event.data.dataTransfer.id,
|
id = event.data.dataTransfer.id,
|
||||||
imageId = `[img=${id}]`,
|
imageId = `[img=${id}]`,
|
||||||
reader = new window.FileReader();
|
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)
|
export function momentToNode(element)
|
||||||
{
|
{
|
||||||
var
|
let
|
||||||
key = '',
|
key = '',
|
||||||
time = 0,
|
time = 0;
|
||||||
|
const
|
||||||
$el = $(element);
|
$el = $(element);
|
||||||
|
|
||||||
time = $el.data('moment-time');
|
time = $el.data('moment-time');
|
||||||
|
|
|
||||||
|
|
@ -159,14 +159,16 @@ class Selector
|
||||||
|
|
||||||
this.list.subscribe((aItems) => {
|
this.list.subscribe((aItems) => {
|
||||||
|
|
||||||
var
|
let
|
||||||
oTemp = null,
|
temp = null,
|
||||||
bGetNext = false,
|
getNext = false,
|
||||||
aUids = [],
|
isNextFocused = mFocused,
|
||||||
mNextFocused = mFocused,
|
isChecked = false,
|
||||||
bChecked = false,
|
isSelected = false,
|
||||||
bSelected = false,
|
len = 0;
|
||||||
iLen = 0;
|
|
||||||
|
const
|
||||||
|
uids = [];
|
||||||
|
|
||||||
this.selectedItemUseCallback = false;
|
this.selectedItemUseCallback = false;
|
||||||
|
|
||||||
|
|
@ -175,37 +177,37 @@ class Selector
|
||||||
|
|
||||||
if (isArray(aItems))
|
if (isArray(aItems))
|
||||||
{
|
{
|
||||||
iLen = aCheckedCache.length;
|
len = aCheckedCache.length;
|
||||||
|
|
||||||
_.each(aItems, (oItem) => {
|
_.each(aItems, (item) => {
|
||||||
|
|
||||||
var sUid = this.getItemUid(oItem);
|
const uid = this.getItemUid(item);
|
||||||
aUids.push(sUid);
|
uids.push(uid);
|
||||||
|
|
||||||
if (null !== mFocused && mFocused === sUid)
|
if (null !== mFocused && mFocused === uid)
|
||||||
{
|
{
|
||||||
this.focusedItem(oItem);
|
this.focusedItem(item);
|
||||||
mFocused = null;
|
mFocused = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < iLen && -1 < inArray(sUid, aCheckedCache))
|
if (0 < len && -1 < inArray(uid, aCheckedCache))
|
||||||
{
|
{
|
||||||
bChecked = true;
|
isChecked = true;
|
||||||
oItem.checked(true);
|
item.checked(true);
|
||||||
iLen -= 1;
|
len -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bChecked && null !== mSelected && mSelected === sUid)
|
if (!isChecked && null !== mSelected && mSelected === uid)
|
||||||
{
|
{
|
||||||
bSelected = true;
|
isSelected = true;
|
||||||
this.selectedItem(oItem);
|
this.selectedItem(item);
|
||||||
mSelected = null;
|
mSelected = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.selectedItemUseCallback = true;
|
this.selectedItemUseCallback = true;
|
||||||
|
|
||||||
if (!bChecked && !bSelected && this.autoSelect())
|
if (!isChecked && !isSelected && this.autoSelect())
|
||||||
{
|
{
|
||||||
if (this.focusedItem())
|
if (this.focusedItem())
|
||||||
{
|
{
|
||||||
|
|
@ -213,53 +215,53 @@ class Selector
|
||||||
}
|
}
|
||||||
else if (0 < aItems.length)
|
else if (0 < aItems.length)
|
||||||
{
|
{
|
||||||
if (null !== mNextFocused)
|
if (null !== isNextFocused)
|
||||||
{
|
{
|
||||||
bGetNext = false;
|
getNext = false;
|
||||||
mNextFocused = _.find(aCache, (sUid) => {
|
isNextFocused = _.find(aCache, (sUid) => {
|
||||||
if (bGetNext && -1 < inArray(sUid, aUids))
|
if (getNext && -1 < inArray(sUid, uids))
|
||||||
{
|
{
|
||||||
return sUid;
|
return sUid;
|
||||||
}
|
}
|
||||||
else if (mNextFocused === sUid)
|
else if (isNextFocused === sUid)
|
||||||
{
|
{
|
||||||
bGetNext = true;
|
getNext = true;
|
||||||
}
|
}
|
||||||
return false;
|
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());
|
this.focusedItem(this.selectedItem());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((0 !== this.iSelectNextHelper || 0 !== this.iFocusedNextHelper) && 0 < aItems.length && !this.focusedItem())
|
if ((0 !== this.iSelectNextHelper || 0 !== this.iFocusedNextHelper) && 0 < aItems.length && !this.focusedItem())
|
||||||
{
|
{
|
||||||
oTemp = null;
|
temp = null;
|
||||||
if (0 !== this.iFocusedNextHelper)
|
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)
|
if (0 !== this.iSelectNextHelper)
|
||||||
{
|
{
|
||||||
this.selectedItem(oTemp || null);
|
this.selectedItem(temp || null);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.focusedItem(oTemp || null);
|
this.focusedItem(temp || null);
|
||||||
|
|
||||||
this.scrollToFocused();
|
this.scrollToFocused();
|
||||||
|
|
||||||
|
|
@ -288,14 +290,11 @@ class Selector
|
||||||
(this.oCallbacks.onItemSelect || noop)(item || null);
|
(this.oCallbacks.onItemSelect || noop)(item || null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (item)
|
||||||
{
|
|
||||||
if (item)
|
|
||||||
{
|
{
|
||||||
(this.oCallbacks.onItemSelect || noop)(item);
|
(this.oCallbacks.onItemSelect || noop)(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {boolean} forceSelect
|
* @param {boolean} forceSelect
|
||||||
|
|
@ -446,62 +445,64 @@ class Selector
|
||||||
*/
|
*/
|
||||||
newSelectPosition(iEventKeyCode, bShiftKey, bForceSelect) {
|
newSelectPosition(iEventKeyCode, bShiftKey, bForceSelect) {
|
||||||
|
|
||||||
var
|
let
|
||||||
iIndex = 0,
|
index = 0,
|
||||||
iPageStep = 10,
|
isNext = false,
|
||||||
bNext = false,
|
isStop = false,
|
||||||
bStop = false,
|
result = null;
|
||||||
oResult = null,
|
|
||||||
aList = this.list(),
|
|
||||||
iListLen = aList ? aList.length : 0,
|
|
||||||
oFocused = this.focusedItem();
|
|
||||||
|
|
||||||
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 ||
|
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Insert === iEventKeyCode ||
|
||||||
EventKeyCode.Space === iEventKeyCode || EventKeyCode.Home === iEventKeyCode ||
|
EventKeyCode.Space === iEventKeyCode || EventKeyCode.Home === iEventKeyCode ||
|
||||||
EventKeyCode.PageUp === iEventKeyCode)
|
EventKeyCode.PageUp === iEventKeyCode)
|
||||||
{
|
{
|
||||||
oResult = aList[0];
|
result = list[0];
|
||||||
}
|
}
|
||||||
else if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.End === iEventKeyCode ||
|
else if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.End === iEventKeyCode ||
|
||||||
EventKeyCode.PageDown === 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 ||
|
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode ||
|
||||||
EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||||
{
|
{
|
||||||
_.each(aList, (item) => {
|
_.each(list, (item) => {
|
||||||
if (!bStop)
|
if (!isStop)
|
||||||
{
|
{
|
||||||
switch (iEventKeyCode)
|
switch (iEventKeyCode)
|
||||||
{
|
{
|
||||||
case EventKeyCode.Up:
|
case EventKeyCode.Up:
|
||||||
if (oFocused === item)
|
if (focused === item)
|
||||||
{
|
{
|
||||||
bStop = true;
|
isStop = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oResult = item;
|
result = item;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EventKeyCode.Down:
|
case EventKeyCode.Down:
|
||||||
case EventKeyCode.Insert:
|
case EventKeyCode.Insert:
|
||||||
if (bNext)
|
if (isNext)
|
||||||
{
|
{
|
||||||
oResult = item;
|
result = item;
|
||||||
bStop = true;
|
isStop = true;
|
||||||
}
|
}
|
||||||
else if (oFocused === item)
|
else if (focused === item)
|
||||||
{
|
{
|
||||||
bNext = true;
|
isNext = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// no default
|
// 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);
|
this.doUpUpOrDownDown(EventKeyCode.Up === iEventKeyCode);
|
||||||
}
|
}
|
||||||
|
|
@ -518,35 +519,35 @@ class Selector
|
||||||
{
|
{
|
||||||
if (EventKeyCode.Home === iEventKeyCode)
|
if (EventKeyCode.Home === iEventKeyCode)
|
||||||
{
|
{
|
||||||
oResult = aList[0];
|
result = list[0];
|
||||||
}
|
}
|
||||||
else if (EventKeyCode.End === iEventKeyCode)
|
else if (EventKeyCode.End === iEventKeyCode)
|
||||||
{
|
{
|
||||||
oResult = aList[aList.length - 1];
|
result = list[list.length - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (EventKeyCode.PageDown === iEventKeyCode)
|
else if (EventKeyCode.PageDown === iEventKeyCode)
|
||||||
{
|
{
|
||||||
for (; iIndex < iListLen; iIndex++)
|
for (; index < listLen; index++)
|
||||||
{
|
{
|
||||||
if (oFocused === aList[iIndex])
|
if (focused === list[index])
|
||||||
{
|
{
|
||||||
iIndex += iPageStep;
|
index += pageStep;
|
||||||
iIndex = iListLen - 1 < iIndex ? iListLen - 1 : iIndex;
|
index = listLen - 1 < index ? listLen - 1 : index;
|
||||||
oResult = aList[iIndex];
|
result = list[index];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (EventKeyCode.PageUp === iEventKeyCode)
|
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;
|
index -= pageStep;
|
||||||
iIndex = 0 > iIndex ? 0 : iIndex;
|
index = 0 > index ? 0 : index;
|
||||||
oResult = aList[iIndex];
|
result = list[index];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -554,45 +555,45 @@ class Selector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oResult)
|
if (result)
|
||||||
{
|
{
|
||||||
this.focusedItem(oResult);
|
this.focusedItem(result);
|
||||||
|
|
||||||
if (oFocused)
|
if (focused)
|
||||||
{
|
{
|
||||||
if (bShiftKey)
|
if (bShiftKey)
|
||||||
{
|
{
|
||||||
if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode)
|
if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode)
|
||||||
{
|
{
|
||||||
oFocused.checked(!oFocused.checked());
|
focused.checked(!focused.checked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
||||||
{
|
{
|
||||||
oFocused.checked(!oFocused.checked());
|
focused.checked(!focused.checked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this.autoSelect() || !!bForceSelect) &&
|
if ((this.autoSelect() || !!bForceSelect) &&
|
||||||
!this.isListChecked() && EventKeyCode.Space !== iEventKeyCode)
|
!this.isListChecked() && EventKeyCode.Space !== iEventKeyCode)
|
||||||
{
|
{
|
||||||
this.selectedItem(oResult);
|
this.selectedItem(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scrollToFocused();
|
this.scrollToFocused();
|
||||||
}
|
}
|
||||||
else if (oFocused)
|
else if (focused)
|
||||||
{
|
{
|
||||||
if (bShiftKey && (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode))
|
if (bShiftKey && (EventKeyCode.Up === iEventKeyCode || EventKeyCode.Down === iEventKeyCode))
|
||||||
{
|
{
|
||||||
oFocused.checked(!oFocused.checked());
|
focused.checked(!focused.checked());
|
||||||
}
|
}
|
||||||
else if (EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
|
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 {$win, $div, dropdownVisibility, data as GlobalsData} from 'Common/Globals';
|
||||||
import {ComposeType, EventKeyCode, SaveSettingsStep, FolderType} from 'Common/Enums';
|
import {ComposeType, EventKeyCode, SaveSettingsStep, FolderType} from 'Common/Enums';
|
||||||
import {Mime} from 'Common/Mime';
|
import {Mime} from 'Common/Mime';
|
||||||
|
import {jassl} from 'Common/Jassl';
|
||||||
|
|
||||||
import Autolinker from 'Autolinker';
|
import Autolinker from 'Autolinker';
|
||||||
|
|
||||||
|
|
@ -22,7 +23,7 @@ const noop = () => {}; // eslint-disable-line no-empty-function
|
||||||
const noopTrue = () => true;
|
const noopTrue = () => true;
|
||||||
const noopFalse = () => false;
|
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
|
* @param {Function} func
|
||||||
|
|
@ -490,7 +491,7 @@ export function killCtrlACtrlS(event)
|
||||||
* @param {(Function|boolean|null)=} fCanExecute = true
|
* @param {(Function|boolean|null)=} fCanExecute = true
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function createCommand(context, fExecute, fCanExecute = true)
|
export function createCommandLegacy(context, fExecute, fCanExecute = true)
|
||||||
{
|
{
|
||||||
let fResult = null;
|
let fResult = null;
|
||||||
const fNonEmpty = (...args) => {
|
const fNonEmpty = (...args) => {
|
||||||
|
|
@ -516,6 +517,16 @@ export function createCommand(context, fExecute, fCanExecute = true)
|
||||||
return fResult;
|
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
|
* @param {string} theme
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
|
|
@ -609,12 +620,13 @@ export function clearBqSwitcher(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} title
|
* @param {object} messageData
|
||||||
* @param {Object} body
|
* @param {Object} body
|
||||||
* @param {boolean} isHtml
|
* @param {boolean} isHtml
|
||||||
* @param {boolean} print
|
* @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
|
const
|
||||||
win = window.open(''),
|
win = window.open(''),
|
||||||
|
|
@ -626,81 +638,16 @@ export function previewMessage(title, body, isHtml, print)
|
||||||
|
|
||||||
const html = bodyClone ? bodyClone.html() : '';
|
const html = bodyClone ? bodyClone.html() : '';
|
||||||
|
|
||||||
title = encodeHtml(title);
|
doc.write(require('Html/PreviewMessage.html')
|
||||||
|
.replace('{{title}}', encodeHtml(title))
|
||||||
doc.write(`<html>
|
.replace('{{subject}}', encodeHtml(subject))
|
||||||
<head>
|
.replace('{{date}}', encodeHtml(date))
|
||||||
<meta charset="utf-8" />
|
.replace('{{fromCreds}}', encodeHtml(fromCreds))
|
||||||
<meta name="viewport" content="user-scalable=no" />
|
.replace('{{toCreds}}', encodeHtml(toCreds))
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
.replace('{{toLabel}}', encodeHtml(toLabel))
|
||||||
<meta name="robots" content="noindex, nofollow, noodp" />
|
.replace('{{bodyClass}}', bodyClass)
|
||||||
<title>${title}</title>
|
.replace('{{html}}', html)
|
||||||
<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.close();
|
doc.close();
|
||||||
|
|
||||||
|
|
@ -851,7 +798,6 @@ export function htmlToPlain(html)
|
||||||
convertLinks = (...args) => (args && 1 < args.length ? trim(args[1]) : '');
|
convertLinks = (...args) => (args && 1 < args.length ? trim(args[1]) : '');
|
||||||
|
|
||||||
text = html
|
text = html
|
||||||
.replace(/\u0002([\s\S]*)\u0002/gm, '\u200C$1\u200C')
|
|
||||||
.replace(/<p[^>]*><\/p>/gi, '')
|
.replace(/<p[^>]*><\/p>/gi, '')
|
||||||
.replace(/<pre[^>]*>([\s\S\r\n\t]*)<\/pre>/gmi, convertPre)
|
.replace(/<pre[^>]*>([\s\S\r\n\t]*)<\/pre>/gmi, convertPre)
|
||||||
.replace(/[\s]+/gm, ' ')
|
.replace(/[\s]+/gm, ' ')
|
||||||
|
|
@ -1003,7 +949,6 @@ export function plainToHtml(plain, findEmailAndLinksInText = false)
|
||||||
.replace(/>/g, '>').replace(/</g, '<')
|
.replace(/>/g, '>').replace(/</g, '<')
|
||||||
.replace(/~~~blockquote~~~[\s]*/g, '<blockquote>')
|
.replace(/~~~blockquote~~~[\s]*/g, '<blockquote>')
|
||||||
.replace(/[\s]*~~~\/blockquote~~~/g, '</blockquote>')
|
.replace(/[\s]*~~~\/blockquote~~~/g, '</blockquote>')
|
||||||
.replace(/\u200C([\s\S]*)\u200C/g, '\u0002$1\u0002')
|
|
||||||
.replace(/\n/g, '<br />');
|
.replace(/\n/g, '<br />');
|
||||||
|
|
||||||
return findEmailAndLinksInText ? findEmailAndLinks(plain) : plain;
|
return findEmailAndLinksInText ? findEmailAndLinks(plain) : plain;
|
||||||
|
|
@ -1520,7 +1465,7 @@ export function mimeContentType(fileName)
|
||||||
*/
|
*/
|
||||||
export function resizeAndCrop(url, value, fCallback)
|
export function resizeAndCrop(url, value, fCallback)
|
||||||
{
|
{
|
||||||
const img = new Image();
|
const img = new window.Image();
|
||||||
img.onload = function() {
|
img.onload = function() {
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
|
||||||
|
|
@ -29,15 +29,11 @@ class AbstractInput extends AbstractComponent
|
||||||
this.classForTrigger = ko.observable('');
|
this.classForTrigger = ko.observable('');
|
||||||
|
|
||||||
this.className = ko.computed(() => {
|
this.className = ko.computed(() => {
|
||||||
|
const
|
||||||
var
|
|
||||||
size = ko.unwrap(this.size),
|
size = ko.unwrap(this.size),
|
||||||
suffixValue = this.trigger ?
|
suffixValue = this.trigger ? ' ' + trim('settings-saved-trigger-input ' + this.classForTrigger()) : '';
|
||||||
' ' + trim('settings-saved-trigger-input ' + this.classForTrigger()) : '';
|
|
||||||
|
|
||||||
return (0 < size ? 'span' + size : '') + suffixValue;
|
return (0 < size ? 'span' + size : '') + suffixValue;
|
||||||
|
});
|
||||||
}, this);
|
|
||||||
|
|
||||||
if (!isUnd(params.width) && params.element)
|
if (!isUnd(params.width) && params.element)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
10
dev/External/Opentip.js
vendored
10
dev/External/Opentip.js
vendored
|
|
@ -1,7 +1,9 @@
|
||||||
|
|
||||||
var
|
import window from 'window';
|
||||||
window = require('window'),
|
|
||||||
Opentip = window.Opentip;
|
const Opentip = window.Opentip || {};
|
||||||
|
|
||||||
|
Opentip.styles = Opentip.styles || {};
|
||||||
|
|
||||||
Opentip.styles.rainloop = {
|
Opentip.styles.rainloop = {
|
||||||
|
|
||||||
|
|
@ -41,4 +43,4 @@ Opentip.styles.rainloopErrorTip = {
|
||||||
'className': 'rainloopErrorTip'
|
'className': 'rainloopErrorTip'
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Opentip;
|
export {Opentip, Opentip as default};
|
||||||
|
|
|
||||||
1100
dev/External/ko.js
vendored
1100
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 {$html, aViewModels as VIEW_MODELS, popupVisibilityNames} from 'Common/Globals';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isFunc, isArray, isUnd, pString, log,
|
isArray, isUnd, pString, log,
|
||||||
createCommand, delegateRun, isNonEmptyArray
|
createCommand, delegateRun, isNonEmptyArray
|
||||||
} from 'Common/Utils';
|
} from 'Common/Utils';
|
||||||
|
|
||||||
|
|
@ -19,6 +19,13 @@ let
|
||||||
|
|
||||||
const SCREENS = {};
|
const SCREENS = {};
|
||||||
|
|
||||||
|
export const ViewType = {
|
||||||
|
Popup: 'Popups',
|
||||||
|
Left: 'Left',
|
||||||
|
Right: 'Right',
|
||||||
|
Center: 'Center'
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
@ -28,40 +35,6 @@ export function hideLoading()
|
||||||
$('#rl-loading').hide().remove();
|
$('#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 {Function} SettingsViewModelClass
|
||||||
* @param {string} template
|
* @param {string} template
|
||||||
|
|
@ -161,8 +134,8 @@ export function buildViewModel(ViewModelClass, vmScreen)
|
||||||
let vmDom = null;
|
let vmDom = null;
|
||||||
const
|
const
|
||||||
vm = new ViewModelClass(vmScreen),
|
vm = new ViewModelClass(vmScreen),
|
||||||
position = vm.viewModelPosition(),
|
position = ViewModelClass.__type || '',
|
||||||
vmPlace = $('#rl-content #rl-' + position.toLowerCase());
|
vmPlace = position ? $('#rl-content #rl-' + position.toLowerCase()) : null;
|
||||||
|
|
||||||
ViewModelClass.__builded = true;
|
ViewModelClass.__builded = true;
|
||||||
ViewModelClass.__vm = vm;
|
ViewModelClass.__vm = vm;
|
||||||
|
|
@ -172,18 +145,20 @@ export function buildViewModel(ViewModelClass, vmScreen)
|
||||||
|
|
||||||
vm.viewModelName = ViewModelClass.__name;
|
vm.viewModelName = ViewModelClass.__name;
|
||||||
vm.viewModelNames = ViewModelClass.__names;
|
vm.viewModelNames = ViewModelClass.__names;
|
||||||
|
vm.viewModelTemplateID = ViewModelClass.__templateID;
|
||||||
|
vm.viewModelPosition = ViewModelClass.__type;
|
||||||
|
|
||||||
if (vmPlace && 1 === vmPlace.length)
|
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);
|
vmDom.appendTo(vmPlace);
|
||||||
|
|
||||||
vm.viewModelDom = vmDom;
|
vm.viewModelDom = vmDom;
|
||||||
ViewModelClass.__dom = vmDom;
|
ViewModelClass.__dom = vmDom;
|
||||||
|
|
||||||
if ('Popups' === position)
|
if (ViewType.Popup === position)
|
||||||
{
|
{
|
||||||
vm.cancelCommand = vm.closeCommand = createCommand(vm, () => {
|
vm.cancelCommand = vm.closeCommand = createCommand(() => {
|
||||||
hideScreenPopup(ViewModelClass);
|
hideScreenPopup(ViewModelClass);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -229,11 +204,11 @@ export function buildViewModel(ViewModelClass, vmScreen)
|
||||||
|
|
||||||
ko.applyBindingAccessorsToNode(vmDom[0], {
|
ko.applyBindingAccessorsToNode(vmDom[0], {
|
||||||
translatorInit: true,
|
translatorInit: true,
|
||||||
template: () => ({name: vm.viewModelTemplate()})
|
template: () => ({name: vm.viewModelTemplateID})
|
||||||
}, vm);
|
}, vm);
|
||||||
|
|
||||||
delegateRun(vm, 'onBuild', [vmDom]);
|
delegateRun(vm, 'onBuild', [vmDom]);
|
||||||
if (vm && 'Popups' === position)
|
if (vm && ViewType.Popup === position)
|
||||||
{
|
{
|
||||||
vm.registerPopupKeyDown();
|
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
|
* @param {Function} ViewModelClassToShow
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
|
|
@ -345,7 +337,7 @@ export function screenOnRoute(screenName, subPart)
|
||||||
if (isNonEmptyArray(currentScreen.viewModels()))
|
if (isNonEmptyArray(currentScreen.viewModels()))
|
||||||
{
|
{
|
||||||
_.each(currentScreen.viewModels(), (ViewModelClass) => {
|
_.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.__dom.hide();
|
||||||
ViewModelClass.__vm.viewModelVisibility(false);
|
ViewModelClass.__vm.viewModelVisibility(false);
|
||||||
|
|
@ -380,7 +372,7 @@ export function screenOnRoute(screenName, subPart)
|
||||||
{
|
{
|
||||||
_.each(currentScreen.viewModels(), (ViewModelClass) => {
|
_.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');
|
delegateRun(ViewModelClass.__vm, 'onBeforeShow');
|
||||||
|
|
||||||
|
|
@ -486,3 +478,41 @@ export function setHash(hash, silence = false, replace = false)
|
||||||
hasher.setHash(hash);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var
|
const
|
||||||
substr = function(str, start, len) {
|
substr = (str, start, len) => {
|
||||||
str = pString(str);
|
str = pString(str);
|
||||||
var end = str.length;
|
let end = str.length;
|
||||||
|
|
||||||
if (0 > start)
|
if (0 > start)
|
||||||
{
|
{
|
||||||
|
|
@ -233,7 +233,7 @@ class EmailModel
|
||||||
return start >= str.length || 0 > start || start > end ? false : str.slice(start, end);
|
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);
|
str = pString(str);
|
||||||
if (0 > start)
|
if (0 > start)
|
||||||
{
|
{
|
||||||
|
|
@ -246,8 +246,9 @@ class EmailModel
|
||||||
length = length + str.length - start;
|
length = length + str.length - start;
|
||||||
}
|
}
|
||||||
return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length);
|
return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length);
|
||||||
},
|
};
|
||||||
|
|
||||||
|
let
|
||||||
$sName = '',
|
$sName = '',
|
||||||
$sEmail = '',
|
$sEmail = '',
|
||||||
$sComment = '',
|
$sComment = '',
|
||||||
|
|
|
||||||
|
|
@ -190,9 +190,7 @@ class FilterModel extends AbstractModel
|
||||||
Enabled: this.enabled() ? '1' : '0',
|
Enabled: this.enabled() ? '1' : '0',
|
||||||
Name: this.name(),
|
Name: this.name(),
|
||||||
ConditionsType: this.conditionsType(),
|
ConditionsType: this.conditionsType(),
|
||||||
Conditions: _.map(this.conditions(), function(oItem) {
|
Conditions: _.map(this.conditions(), (item) => item.toJson()),
|
||||||
return oItem.toJson();
|
|
||||||
}),
|
|
||||||
|
|
||||||
ActionValue: this.actionValue(),
|
ActionValue: this.actionValue(),
|
||||||
ActionValueSecond: this.actionValueSecond(),
|
ActionValueSecond: this.actionValueSecond(),
|
||||||
|
|
@ -257,7 +255,8 @@ class FilterModel extends AbstractModel
|
||||||
}
|
}
|
||||||
|
|
||||||
cloneSelf() {
|
cloneSelf() {
|
||||||
var filter = new FilterModel();
|
|
||||||
|
const filter = new FilterModel();
|
||||||
|
|
||||||
filter.id = this.id;
|
filter.id = this.id;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,30 +19,30 @@ class FilterConditionModel extends AbstractModel
|
||||||
this.valueSecond = ko.observable('');
|
this.valueSecond = ko.observable('');
|
||||||
this.valueSecond.error = ko.observable(false);
|
this.valueSecond.error = ko.observable(false);
|
||||||
|
|
||||||
this.template = ko.computed(function() {
|
this.template = ko.computed(() => {
|
||||||
|
|
||||||
var sTemplate = '';
|
let template = '';
|
||||||
switch (this.field())
|
switch (this.field())
|
||||||
{
|
{
|
||||||
case FilterConditionField.Size:
|
case FilterConditionField.Size:
|
||||||
sTemplate = 'SettingsFiltersConditionSize';
|
template = 'SettingsFiltersConditionSize';
|
||||||
break;
|
break;
|
||||||
case FilterConditionField.Header:
|
case FilterConditionField.Header:
|
||||||
sTemplate = 'SettingsFiltersConditionMore';
|
template = 'SettingsFiltersConditionMore';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sTemplate = 'SettingsFiltersConditionDefault';
|
template = 'SettingsFiltersConditionDefault';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sTemplate;
|
return template;
|
||||||
|
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
this.field.subscribe(function() {
|
this.field.subscribe(() => {
|
||||||
this.value('');
|
this.value('');
|
||||||
this.valueSecond('');
|
this.valueSecond('');
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.regDisposables([this.template]);
|
this.regDisposables([this.template]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,9 @@ class FolderModel extends AbstractModel
|
||||||
|
|
||||||
this.isInbox = ko.computed(() => FolderType.Inbox === this.type());
|
this.isInbox = ko.computed(() => FolderType.Inbox === this.type());
|
||||||
|
|
||||||
this.hasSubScribedSubfolders = ko.computed(function() {
|
this.hasSubScribedSubfolders = ko.computed(
|
||||||
return !!_.find(this.subFolders(), (oFolder) => (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder());
|
() => !!_.find(this.subFolders(), (oFolder) => (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder())
|
||||||
}, this);
|
);
|
||||||
|
|
||||||
this.canBeEdited = ko.computed(() => FolderType.User === this.type() && this.existen && this.selectable);
|
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.hasUnreadMessages = ko.computed(() => 0 < this.messageCountUnread() && '' !== this.printableUnreadCount());
|
||||||
|
|
||||||
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(function() {
|
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(
|
||||||
return !!_.find(this.subFolders(), (folder) => folder.hasUnreadMessages() || folder.hasSubScribedUnreadMessagesSubfolders());
|
() => !!_.find(this.subFolders(), (folder) => folder.hasUnreadMessages() || folder.hasSubScribedUnreadMessagesSubfolders())
|
||||||
}, this);
|
);
|
||||||
|
|
||||||
// subscribe
|
// subscribe
|
||||||
this.name.subscribe((value) => {
|
this.name.subscribe((value) => {
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,11 @@
|
||||||
import _ from '_';
|
import _ from '_';
|
||||||
import $ from '$';
|
import $ from '$';
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
import moment from 'moment';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
|
||||||
import {MessagePriority, SignedVerifyStatus} from 'Common/Enums';
|
import {MessagePriority, SignedVerifyStatus} from 'Common/Enums';
|
||||||
|
import {i18n} from 'Common/Translator';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
pInt, inArray, isArray, isUnd, trim,
|
pInt, inArray, isArray, isUnd, trim,
|
||||||
|
|
@ -455,73 +458,24 @@ class MessageModel extends AbstractModel
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
lineAsCss() {
|
lineAsCss() {
|
||||||
const result = [];
|
return classnames({
|
||||||
if (this.deleted())
|
'deleted': this.deleted(),
|
||||||
{
|
'deleted-mark': this.deletedMark(),
|
||||||
result.push('deleted');
|
'selected': this.selected(),
|
||||||
}
|
'checked': this.checked(),
|
||||||
if (this.deletedMark())
|
'flagged': this.flagged(),
|
||||||
{
|
'unseen': this.unseen(),
|
||||||
result.push('deleted-mark');
|
'answered': this.answered(),
|
||||||
}
|
'forwarded': this.forwarded(),
|
||||||
if (this.selected())
|
'focused': this.focused(),
|
||||||
{
|
'important': this.isImportant(),
|
||||||
result.push('selected');
|
'withAttachments': this.hasAttachments(),
|
||||||
}
|
'new': this.newForAnimation(),
|
||||||
if (this.checked())
|
'emptySubject': '' === this.subject(),
|
||||||
{
|
// 'hasChildrenMessage': 1 < this.threadsLen(),
|
||||||
result.push('checked');
|
'hasUnseenSubMessage': this.hasUnseenSubMessage(),
|
||||||
}
|
'hasFlaggedSubMessage': this.hasFlaggedSubMessage()
|
||||||
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(' ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -680,7 +634,19 @@ class MessageModel extends AbstractModel
|
||||||
*/
|
*/
|
||||||
viewPopupMessage(print = false) {
|
viewPopupMessage(print = false) {
|
||||||
this.showLazyExternalImagesInBody();
|
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() {
|
printMessage() {
|
||||||
|
|
@ -770,7 +736,7 @@ class MessageModel extends AbstractModel
|
||||||
if (this.body)
|
if (this.body)
|
||||||
{
|
{
|
||||||
$('.lazy.lazy-inited[data-original]', this.body).each(function() {
|
$('.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.hasImages(false);
|
||||||
this.body.data('rl-has-images', false);
|
this.body.data('rl-has-images', false);
|
||||||
|
|
||||||
var sAttr = this.proxy ? 'data-x-additional-src' : 'data-x-src';
|
let attr = this.proxy ? 'data-x-additional-src' : 'data-x-src';
|
||||||
$('[' + sAttr + ']', this.body).each(function() {
|
$('[' + attr + ']', this.body).each(function() {
|
||||||
if (lazy && $(this).is('img'))
|
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||||
|
if (lazy && $this.is('img'))
|
||||||
{
|
{
|
||||||
$(this)
|
$this
|
||||||
.addClass('lazy')
|
.addClass('lazy')
|
||||||
.attr('data-original', $(this).attr(sAttr))
|
.attr('data-original', $this.attr(attr))
|
||||||
.removeAttr(sAttr);
|
.removeAttr(attr);
|
||||||
}
|
}
|
||||||
else
|
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';
|
attr = this.proxy ? 'data-x-additional-style-url' : 'data-x-style-url';
|
||||||
$('[' + sAttr + ']', this.body).each(function() {
|
$('[' + attr + ']', this.body).each(function() {
|
||||||
var sStyle = trim($(this).attr('style'));
|
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||||
sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; ');
|
let style = trim($this.attr('style'));
|
||||||
$(this).attr('style', sStyle + $(this).attr(sAttr)).removeAttr(sAttr);
|
style = '' === style ? '' : (';' === style.substr(-1) ? style + ' ' : style + '; ');
|
||||||
|
$this.attr('style', style + $this.attr(attr)).removeAttr(attr);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (lazy)
|
if (lazy)
|
||||||
|
|
@ -824,43 +792,47 @@ class MessageModel extends AbstractModel
|
||||||
{
|
{
|
||||||
this.body.data('rl-init-internal-images', true);
|
this.body.data('rl-init-internal-images', true);
|
||||||
|
|
||||||
var self = this;
|
const self = this;
|
||||||
|
|
||||||
$('[data-x-src-cid]', this.body).each(function() {
|
$('[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 (attachment && attachment.download)
|
||||||
{
|
{
|
||||||
if (lazy && $(this).is('img'))
|
if (lazy && $this.is('img'))
|
||||||
{
|
{
|
||||||
$(this)
|
$this
|
||||||
.addClass('lazy')
|
.addClass('lazy')
|
||||||
.attr('data-original', attachment.linkPreview());
|
.attr('data-original', attachment.linkPreview());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$(this).attr('src', attachment.linkPreview());
|
$this.attr('src', attachment.linkPreview());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('[data-x-src-location]', this.body).each(function() {
|
$('[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)
|
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 (attachment && attachment.download)
|
||||||
{
|
{
|
||||||
if (lazy && $(this).is('img'))
|
if (lazy && $this.is('img'))
|
||||||
{
|
{
|
||||||
$(this)
|
$this
|
||||||
.addClass('lazy')
|
.addClass('lazy')
|
||||||
.attr('data-original', attachment.linkPreview());
|
.attr('data-original', attachment.linkPreview());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$(this).attr('src', attachment.linkPreview());
|
$this.attr('src', attachment.linkPreview());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -869,16 +841,19 @@ class MessageModel extends AbstractModel
|
||||||
let
|
let
|
||||||
style = '',
|
style = '',
|
||||||
name = '';
|
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)
|
if (attachment && attachment.linkPreview)
|
||||||
{
|
{
|
||||||
name = $(this).attr('data-x-style-cid-name');
|
name = $this.attr('data-x-style-cid-name');
|
||||||
if ('' !== name)
|
if ('' !== name)
|
||||||
{
|
{
|
||||||
style = trim($(this).attr('style'));
|
style = trim($this.attr('style'));
|
||||||
style = '' === style ? '' : (';' === style.substr(-1) ? style + ' ' : 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,41 +1,30 @@
|
||||||
|
|
||||||
var
|
import $ from '$';
|
||||||
$ = require('$'),
|
import Promise from 'Promise';
|
||||||
_ = require('_'),
|
|
||||||
Promise = require('Promise'),
|
|
||||||
|
|
||||||
Consts = require('Common/Consts'),
|
import {ajax} from 'Common/Links';
|
||||||
Enums = require('Common/Enums'),
|
import {microtime, isUnd, isNormal, pString, pInt, inArray} from 'Common/Utils';
|
||||||
Globals = require('Common/Globals'),
|
import {DEFAULT_AJAX_TIMEOUT, TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT} from 'Common/Consts';
|
||||||
Utils = require('Common/Utils'),
|
import {StorageResultType, Notification} from 'Common/Enums';
|
||||||
Links = require('Common/Links'),
|
import {data as GlobalsData} from 'Common/Globals';
|
||||||
Plugins = require('Common/Plugins'),
|
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');
|
class AbstractAjaxPromises extends AbstractBasicPromises
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AbstractAjaxPromises()
|
|
||||||
{
|
{
|
||||||
AbstractBasicPromises.call(this);
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.oRequests = {};
|
||||||
this.clear();
|
this.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
_.extend(AbstractAjaxPromises.prototype, AbstractBasicPromises.prototype);
|
clear() {
|
||||||
|
|
||||||
AbstractAjaxPromises.prototype.oRequests = {};
|
|
||||||
|
|
||||||
AbstractAjaxPromises.prototype.clear = function()
|
|
||||||
{
|
|
||||||
this.oRequests = {};
|
this.oRequests = {};
|
||||||
};
|
}
|
||||||
|
|
||||||
AbstractAjaxPromises.prototype.abort = function(sAction, bClearOnly)
|
abort(sAction, bClearOnly) {
|
||||||
{
|
|
||||||
if (this.oRequests[sAction])
|
if (this.oRequests[sAction])
|
||||||
{
|
{
|
||||||
if (!bClearOnly && this.oRequests[sAction].abort)
|
if (!bClearOnly && this.oRequests[sAction].abort)
|
||||||
|
|
@ -49,142 +38,142 @@ AbstractAjaxPromises.prototype.abort = function(sAction, bClearOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
oParameters.XToken = Settings.appSettingsGet('token');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugins.runHook('ajax-default-request', [sAction, oParameters, sAdditionalGetString]);
|
ajaxRequest(action, isPost, timeOut, params, additionalGetString, fTrigger) {
|
||||||
|
|
||||||
self.setTrigger(fTrigger, true);
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
var oH = $.ajax({
|
const start = microtime();
|
||||||
type: bPost ? 'POST' : 'GET',
|
|
||||||
url: Links.ajax(sAdditionalGetString),
|
timeOut = isNormal(timeOut) ? timeOut : DEFAULT_AJAX_TIMEOUT;
|
||||||
|
additionalGetString = isUnd(additionalGetString) ? '' : pString(additionalGetString);
|
||||||
|
|
||||||
|
if (isPost)
|
||||||
|
{
|
||||||
|
params.XToken = Settings.appSettingsGet('token');
|
||||||
|
}
|
||||||
|
|
||||||
|
Plugins.runHook('ajax-default-request', [action, params, additionalGetString]);
|
||||||
|
|
||||||
|
this.setTrigger(fTrigger, true);
|
||||||
|
|
||||||
|
const oH = $.ajax({
|
||||||
|
type: isPost ? 'POST' : 'GET',
|
||||||
|
url: ajax(additionalGetString),
|
||||||
async: true,
|
async: true,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: bPost ? (oParameters || {}) : {},
|
data: isPost ? (params || {}) : {},
|
||||||
timeout: iTimeOut,
|
timeout: timeOut,
|
||||||
global: true
|
global: true
|
||||||
}).always(function(oData, sTextStatus) {
|
}).always((data, textStatus) => {
|
||||||
|
|
||||||
var
|
let
|
||||||
bCached = false,
|
isCached = false,
|
||||||
oErrorData = null;
|
errorData = null;
|
||||||
|
|
||||||
if (oData && oData.Time)
|
if (data && data.Time)
|
||||||
{
|
{
|
||||||
bCached = Utils.pInt(oData.Time) > Utils.microtime() - iStart;
|
isCached = pInt(data.Time) > microtime() - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
// backward capability
|
// backward capability
|
||||||
var sType = '';
|
let type = '';
|
||||||
switch (true)
|
switch (true)
|
||||||
{
|
{
|
||||||
case 'success' === sTextStatus && oData && oData.Result && sAction === oData.Action:
|
case 'success' === textStatus && data && data.Result && action === data.Action:
|
||||||
sType = Enums.StorageResultType.Success;
|
type = StorageResultType.Success;
|
||||||
break;
|
break;
|
||||||
case 'abort' === sTextStatus && (!oData || !oData.__aborted__):
|
case 'abort' === textStatus && (!data || !data.__aborted__):
|
||||||
sType = Enums.StorageResultType.Abort;
|
type = StorageResultType.Abort;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sType = Enums.StorageResultType.Error;
|
type = StorageResultType.Error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugins.runHook('ajax-default-response', [sAction,
|
Plugins.runHook('ajax-default-response', [
|
||||||
Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oParameters]);
|
action, StorageResultType.Success === type ? data : null, type, isCached, params
|
||||||
|
]);
|
||||||
|
|
||||||
if ('success' === sTextStatus)
|
if ('success' === textStatus)
|
||||||
{
|
{
|
||||||
if (oData && oData.Result && sAction === oData.Action)
|
if (data && data.Result && action === data.Action)
|
||||||
{
|
{
|
||||||
oData.__cached__ = bCached;
|
data.__cached__ = isCached;
|
||||||
resolve(oData);
|
resolve(data);
|
||||||
}
|
}
|
||||||
else if (oData && oData.Action)
|
else if (data && data.Action)
|
||||||
{
|
{
|
||||||
oErrorData = oData;
|
errorData = data;
|
||||||
reject(oData.ErrorCode ? oData.ErrorCode : Enums.Notification.AjaxFalse);
|
reject(data.ErrorCode ? data.ErrorCode : Notification.AjaxFalse);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oErrorData = oData;
|
errorData = data;
|
||||||
reject(Enums.Notification.AjaxParse);
|
reject(Notification.AjaxParse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ('timeout' === sTextStatus)
|
else if ('timeout' === textStatus)
|
||||||
{
|
{
|
||||||
oErrorData = oData;
|
errorData = data;
|
||||||
reject(Enums.Notification.AjaxTimeout);
|
reject(Notification.AjaxTimeout);
|
||||||
}
|
}
|
||||||
else if ('abort' === sTextStatus)
|
else if ('abort' === textStatus)
|
||||||
{
|
{
|
||||||
if (!oData || !oData.__aborted__)
|
if (!data || !data.__aborted__)
|
||||||
{
|
{
|
||||||
reject(Enums.Notification.AjaxAbort);
|
reject(Notification.AjaxAbort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oErrorData = oData;
|
errorData = data;
|
||||||
reject(Enums.Notification.AjaxParse);
|
reject(Notification.AjaxParse);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.oRequests[sAction])
|
if (this.oRequests[action])
|
||||||
{
|
{
|
||||||
self.oRequests[sAction] = null;
|
this.oRequests[action] = null;
|
||||||
delete self.oRequests[sAction];
|
delete this.oRequests[action];
|
||||||
}
|
}
|
||||||
|
|
||||||
self.setTrigger(fTrigger, false);
|
this.setTrigger(fTrigger, false);
|
||||||
|
|
||||||
if (oErrorData)
|
if (errorData)
|
||||||
{
|
{
|
||||||
if (-1 < Utils.inArray(oErrorData.ErrorCode, [
|
if (-1 < inArray(errorData.ErrorCode, [
|
||||||
Enums.Notification.AuthError, Enums.Notification.AccessError,
|
Notification.AuthError, Notification.AccessError,
|
||||||
Enums.Notification.ConnectionError, Enums.Notification.DomainNotAllowed, Enums.Notification.AccountNotAllowed,
|
Notification.ConnectionError, Notification.DomainNotAllowed, Notification.AccountNotAllowed,
|
||||||
Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError
|
Notification.MailServerError, Notification.UnknownNotification, Notification.UnknownError
|
||||||
]))
|
]))
|
||||||
{
|
{
|
||||||
Globals.data.iAjaxErrorCount += 1;
|
GlobalsData.iAjaxErrorCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Enums.Notification.InvalidToken === oErrorData.ErrorCode)
|
if (Notification.InvalidToken === errorData.ErrorCode)
|
||||||
{
|
{
|
||||||
Globals.data.iTokenErrorCount += 1;
|
GlobalsData.iTokenErrorCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Consts.TOKEN_ERROR_LIMIT < Globals.data.iTokenErrorCount)
|
if (TOKEN_ERROR_LIMIT < GlobalsData.iTokenErrorCount)
|
||||||
{
|
{
|
||||||
if (Globals.data.__APP__ && Globals.data.__APP__.loginAndLogoutReload)
|
if (GlobalsData.__APP__ && GlobalsData.__APP__.loginAndLogoutReload)
|
||||||
{
|
{
|
||||||
Globals.data.__APP__.loginAndLogoutReload(false, true);
|
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oErrorData.ClearAuth || oErrorData.Logout || Consts.AJAX_ERROR_LIMIT < Globals.data.iAjaxErrorCount)
|
if (errorData.ClearAuth || errorData.Logout || AJAX_ERROR_LIMIT < GlobalsData.iAjaxErrorCount)
|
||||||
{
|
{
|
||||||
if (Globals.data.__APP__ && Globals.data.__APP__.clearClientSideToken)
|
if (GlobalsData.__APP__ && GlobalsData.__APP__.clearClientSideToken)
|
||||||
{
|
{
|
||||||
Globals.data.__APP__.clearClientSideToken();
|
GlobalsData.__APP__.clearClientSideToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Globals.data.__APP__ && !oErrorData.ClearAuth && Globals.data.__APP__.loginAndLogoutReload)
|
if (GlobalsData.__APP__ && !errorData.ClearAuth && GlobalsData.__APP__.loginAndLogoutReload)
|
||||||
{
|
{
|
||||||
Globals.data.__APP__.loginAndLogoutReload(false, true);
|
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -193,31 +182,32 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut,
|
||||||
|
|
||||||
if (oH)
|
if (oH)
|
||||||
{
|
{
|
||||||
if (self.oRequests[sAction])
|
if (this.oRequests[action])
|
||||||
{
|
{
|
||||||
self.oRequests[sAction] = null;
|
this.oRequests[action] = null;
|
||||||
delete self.oRequests[sAction];
|
delete this.oRequests[action];
|
||||||
}
|
}
|
||||||
|
|
||||||
self.oRequests[sAction] = oH;
|
this.oRequests[action] = oH;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
AbstractAjaxPromises.prototype.getRequest = function(sAction, fTrigger, sAdditionalGetString, iTimeOut)
|
getRequest(sAction, fTrigger, sAdditionalGetString, iTimeOut) {
|
||||||
{
|
|
||||||
sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString);
|
sAdditionalGetString = isUnd(sAdditionalGetString) ? '' : pString(sAdditionalGetString);
|
||||||
sAdditionalGetString = sAction + '/' + 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 = params || {};
|
||||||
params.Action = action;
|
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
|
import _ from '_';
|
||||||
_ = require('_'),
|
import Promise from 'Promise';
|
||||||
Promise = require('Promise'),
|
import {isArray} from 'Common/Utils';
|
||||||
|
|
||||||
Utils = require('Common/Utils');
|
class AbstractBasicPromises
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AbstractBasicPromises()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.oPromisesStack = {};
|
this.oPromisesStack = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractBasicPromises.prototype.func = function(fFunc)
|
func(fFunc) {
|
||||||
{
|
|
||||||
fFunc();
|
fFunc();
|
||||||
return this;
|
return this;
|
||||||
};
|
}
|
||||||
|
|
||||||
AbstractBasicPromises.prototype.fastResolve = function(mData)
|
fastResolve(mData) {
|
||||||
{
|
|
||||||
return Promise.resolve(mData);
|
return Promise.resolve(mData);
|
||||||
};
|
}
|
||||||
|
|
||||||
AbstractBasicPromises.prototype.fastReject = function(mData)
|
fastReject(mData) {
|
||||||
{
|
|
||||||
return Promise.reject(mData);
|
return Promise.reject(mData);
|
||||||
};
|
}
|
||||||
|
|
||||||
AbstractBasicPromises.prototype.setTrigger = function(mTrigger, bValue)
|
setTrigger(trigger, value) {
|
||||||
|
if (trigger)
|
||||||
{
|
{
|
||||||
if (mTrigger)
|
value = !!value;
|
||||||
{
|
_.each(isArray(trigger) ? trigger : [trigger], (fTrigger) => {
|
||||||
_.each(Utils.isArray(mTrigger) ? mTrigger : [mTrigger], function(fTrigger) {
|
|
||||||
if (fTrigger)
|
if (fTrigger)
|
||||||
{
|
{
|
||||||
fTrigger(!!bValue);
|
fTrigger(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = AbstractBasicPromises;
|
export {AbstractBasicPromises, AbstractBasicPromises as default};
|
||||||
|
|
|
||||||
|
|
@ -1,78 +1,64 @@
|
||||||
|
|
||||||
var
|
import window from 'window';
|
||||||
window = require('window'),
|
|
||||||
_ = require('_'),
|
|
||||||
|
|
||||||
PromisesPopulator = require('Promises/User/Populator'),
|
import PromisesPopulator from 'Promises/User/Populator';
|
||||||
AbstractAjaxPromises = require('Promises/AbstractAjax');
|
import {AbstractAjaxPromises} from 'Promises/AbstractAjax';
|
||||||
|
|
||||||
/**
|
class UserAjaxUserPromises extends AbstractAjaxPromises
|
||||||
* @constructor
|
|
||||||
* @extends AbstractAjaxPromises
|
|
||||||
*/
|
|
||||||
function UserAjaxUserPromises()
|
|
||||||
{
|
{
|
||||||
AbstractAjaxPromises.call(this);
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.foldersTimeout = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_.extend(UserAjaxUserPromises.prototype, AbstractAjaxPromises.prototype);
|
foldersReload(fTrigger) {
|
||||||
|
return this.abort('Folders').postRequest('Folders', fTrigger).then((data) => {
|
||||||
UserAjaxUserPromises.prototype.foldersReload = function(fTrigger)
|
PromisesPopulator.foldersList(data.Result);
|
||||||
{
|
PromisesPopulator.foldersAdditionalParameters(data.Result);
|
||||||
return this.abort('Folders')
|
|
||||||
.postRequest('Folders', fTrigger).then(function(oData) {
|
|
||||||
PromisesPopulator.foldersList(oData.Result);
|
|
||||||
PromisesPopulator.foldersAdditionalParameters(oData.Result);
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
UserAjaxUserPromises.prototype.foldersTimeout = 0;
|
foldersReloadWithTimeout(fTrigger) {
|
||||||
UserAjaxUserPromises.prototype.foldersReloadWithTimeout = function(fTrigger)
|
|
||||||
{
|
|
||||||
this.setTrigger(fTrigger, true);
|
this.setTrigger(fTrigger, true);
|
||||||
|
|
||||||
var self = this;
|
|
||||||
window.clearTimeout(this.foldersTimeout);
|
window.clearTimeout(this.foldersTimeout);
|
||||||
this.foldersTimeout = window.setTimeout(function() {
|
this.foldersTimeout = window.setTimeout(() => {
|
||||||
self.foldersReload(fTrigger);
|
this.foldersReload(fTrigger);
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
}
|
||||||
|
|
||||||
UserAjaxUserPromises.prototype.folderDelete = function(sFolderFullNameRaw, fTrigger)
|
folderDelete(sFolderFullNameRaw, fTrigger) {
|
||||||
{
|
|
||||||
return this.postRequest('FolderDelete', fTrigger, {
|
return this.postRequest('FolderDelete', fTrigger, {
|
||||||
'Folder': sFolderFullNameRaw
|
'Folder': sFolderFullNameRaw
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
UserAjaxUserPromises.prototype.folderCreate = function(sNewFolderName, sParentName, fTrigger)
|
folderCreate(sNewFolderName, sParentName, fTrigger) {
|
||||||
{
|
|
||||||
return this.postRequest('FolderCreate', fTrigger, {
|
return this.postRequest('FolderCreate', fTrigger, {
|
||||||
'Folder': sNewFolderName,
|
'Folder': sNewFolderName,
|
||||||
'Parent': sParentName
|
'Parent': sParentName
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
UserAjaxUserPromises.prototype.folderRename = function(sPrevFolderFullNameRaw, sNewFolderName, fTrigger)
|
folderRename(sPrevFolderFullNameRaw, sNewFolderName, fTrigger) {
|
||||||
{
|
|
||||||
return this.postRequest('FolderRename', fTrigger, {
|
return this.postRequest('FolderRename', fTrigger, {
|
||||||
'Folder': sPrevFolderFullNameRaw,
|
'Folder': sPrevFolderFullNameRaw,
|
||||||
'NewFolderName': sNewFolderName
|
'NewFolderName': sNewFolderName
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
UserAjaxUserPromises.prototype.attachmentsActions = function(sAction, aHashes, fTrigger)
|
attachmentsActions(sAction, aHashes, fTrigger) {
|
||||||
{
|
|
||||||
return this.postRequest('AttachmentsActions', fTrigger, {
|
return this.postRequest('AttachmentsActions', fTrigger, {
|
||||||
'Do': sAction,
|
'Do': sAction,
|
||||||
'Hashes': aHashes
|
'Hashes': aHashes
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
UserAjaxUserPromises.prototype.welcomeClose = function()
|
welcomeClose() {
|
||||||
{
|
|
||||||
return this.postRequest('WelcomeClose');
|
return this.postRequest('WelcomeClose');
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new UserAjaxUserPromises();
|
module.exports = new UserAjaxUserPromises();
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,39 @@
|
||||||
|
|
||||||
var
|
import _ from '_';
|
||||||
_ = require('_'),
|
|
||||||
|
|
||||||
Consts = require('Common/Consts'),
|
import {UNUSED_OPTION_VALUE} from 'Common/Consts';
|
||||||
Enums = require('Common/Enums'),
|
import {isArray, isNormal, pInt, isUnd, noop} from 'Common/Utils';
|
||||||
Utils = require('Common/Utils'),
|
import {ClientSideKeyName, ServerFolderType} from 'Common/Enums';
|
||||||
Cache = require('Common/Cache'),
|
import * as Cache from 'Common/Cache';
|
||||||
|
|
||||||
AppStore = require('Stores/User/App'),
|
import * as Settings from 'Storage/Settings';
|
||||||
FolderStore = require('Stores/User/Folder'),
|
import * as Local from 'Storage/Client';
|
||||||
|
|
||||||
Settings = require('Storage/Settings'),
|
import AppStore from 'Stores/User/App';
|
||||||
Local = require('Storage/Client'),
|
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');
|
class PromisesUserPopulator extends AbstractBasicPromises
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function PromisesUserPopulator()
|
|
||||||
{
|
{
|
||||||
AbstractBasicPromises.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
_.extend(PromisesUserPopulator.prototype, AbstractBasicPromises.prototype);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sFullNameHash
|
* @param {string} sFullNameHash
|
||||||
* @param {Array?} expandedFolders
|
* @param {Array?} expandedFolders
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
PromisesUserPopulator.prototype.isFolderExpanded = function(sFullNameHash, expandedFolders)
|
isFolderExpanded(sFullNameHash, expandedFolders) {
|
||||||
{
|
return expandedFolders && isArray(expandedFolders) && -1 !== _.indexOf(expandedFolders, sFullNameHash);
|
||||||
return expandedFolders && Utils.isArray(expandedFolders) && -1 !== _.indexOf(expandedFolders, sFullNameHash);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sFolderFullNameRaw
|
* @param {string} sFolderFullNameRaw
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
PromisesUserPopulator.prototype.normalizeFolder = function(sFolderFullNameRaw)
|
normalizeFolder(sFolderFullNameRaw) {
|
||||||
{
|
return ('' === sFolderFullNameRaw || UNUSED_OPTION_VALUE === sFolderFullNameRaw ||
|
||||||
return ('' === sFolderFullNameRaw || Consts.UNUSED_OPTION_VALUE === sFolderFullNameRaw ||
|
|
||||||
null !== Cache.getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : '';
|
null !== Cache.getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : '';
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sNamespace
|
* @param {string} sNamespace
|
||||||
|
|
@ -53,17 +41,16 @@ PromisesUserPopulator.prototype.normalizeFolder = function(sFolderFullNameRaw)
|
||||||
* @param {Array?} expandedFolders
|
* @param {Array?} expandedFolders
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
PromisesUserPopulator.prototype.folderResponseParseRec = function(sNamespace, aFolders, expandedFolders)
|
folderResponseParseRec(sNamespace, aFolders, expandedFolders) {
|
||||||
{
|
|
||||||
var
|
const
|
||||||
self = this,
|
|
||||||
bDisplaySpecSetting = FolderStore.displaySpecSetting(),
|
bDisplaySpecSetting = FolderStore.displaySpecSetting(),
|
||||||
aList = [];
|
aList = [];
|
||||||
|
|
||||||
_.each(aFolders, function(oFolder) {
|
_.each(aFolders, (oFolder) => {
|
||||||
if (oFolder)
|
if (oFolder)
|
||||||
{
|
{
|
||||||
var oCacheFolder = Cache.getFolderFromCacheList(oFolder.FullNameRaw);
|
let oCacheFolder = Cache.getFolderFromCacheList(oFolder.FullNameRaw);
|
||||||
if (!oCacheFolder)
|
if (!oCacheFolder)
|
||||||
{
|
{
|
||||||
oCacheFolder = FolderModel.newInstanceFromJson(oFolder);
|
oCacheFolder = FolderModel.newInstanceFromJson(oFolder);
|
||||||
|
|
@ -85,7 +72,7 @@ PromisesUserPopulator.prototype.folderResponseParseRec = function(sNamespace, aF
|
||||||
oCacheFolder.checkable(true);
|
oCacheFolder.checkable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
oCacheFolder.collapsed(!self.isFolderExpanded(oCacheFolder.fullNameHash, expandedFolders));
|
oCacheFolder.collapsed(!this.isFolderExpanded(oCacheFolder.fullNameHash, expandedFolders));
|
||||||
|
|
||||||
if (oFolder.Extended)
|
if (oFolder.Extended)
|
||||||
{
|
{
|
||||||
|
|
@ -94,22 +81,22 @@ PromisesUserPopulator.prototype.folderResponseParseRec = function(sNamespace, aF
|
||||||
Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash);
|
Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.isNormal(oFolder.Extended.MessageCount))
|
if (isNormal(oFolder.Extended.MessageCount))
|
||||||
{
|
{
|
||||||
oCacheFolder.messageCountAll(oFolder.Extended.MessageCount);
|
oCacheFolder.messageCountAll(oFolder.Extended.MessageCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.isNormal(oFolder.Extended.MessageUnseenCount))
|
if (isNormal(oFolder.Extended.MessageUnseenCount))
|
||||||
{
|
{
|
||||||
oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount);
|
oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oFolder.SubFolders && 'Collection/FolderCollection' === oFolder.SubFolders['@Object'] &&
|
if (oFolder.SubFolders && 'Collection/FolderCollection' === oFolder.SubFolders['@Object'] &&
|
||||||
oFolder.SubFolders['@Collection'] && Utils.isArray(oFolder.SubFolders['@Collection']))
|
oFolder.SubFolders['@Collection'] && isArray(oFolder.SubFolders['@Collection']))
|
||||||
{
|
{
|
||||||
oCacheFolder.subFolders(
|
oCacheFolder.subFolders(
|
||||||
self.folderResponseParseRec(sNamespace, oFolder.SubFolders['@Collection'], expandedFolders));
|
this.folderResponseParseRec(sNamespace, oFolder.SubFolders['@Collection'], expandedFolders));
|
||||||
}
|
}
|
||||||
|
|
||||||
aList.push(oCacheFolder);
|
aList.push(oCacheFolder);
|
||||||
|
|
@ -118,33 +105,31 @@ PromisesUserPopulator.prototype.folderResponseParseRec = function(sNamespace, aF
|
||||||
});
|
});
|
||||||
|
|
||||||
return aList;
|
return aList;
|
||||||
};
|
}
|
||||||
|
|
||||||
PromisesUserPopulator.prototype.foldersList = function(oData)
|
foldersList(oData) {
|
||||||
{
|
|
||||||
if (oData && 'Collection/FolderCollection' === oData['@Object'] &&
|
if (oData && 'Collection/FolderCollection' === oData['@Object'] &&
|
||||||
oData['@Collection'] && Utils.isArray(oData['@Collection']))
|
oData['@Collection'] && isArray(oData['@Collection']))
|
||||||
{
|
{
|
||||||
var
|
const
|
||||||
expandedFolders = Local.get(Enums.ClientSideKeyName.ExpandedFolders),
|
expandedFolders = Local.get(ClientSideKeyName.ExpandedFolders),
|
||||||
iLimit = Utils.pInt(Settings.appSettingsGet('folderSpecLimit')),
|
cnt = pInt(oData.CountRec);
|
||||||
iC = Utils.pInt(oData.CountRec);
|
|
||||||
|
|
||||||
iLimit = 100 < iLimit ? 100 : (10 > iLimit ? 10 : iLimit);
|
let limit = pInt(Settings.appSettingsGet('folderSpecLimit'));
|
||||||
|
limit = 100 < limit ? 100 : (10 > limit ? 10 : limit);
|
||||||
|
|
||||||
FolderStore.displaySpecSetting(0 >= iC || iLimit < iC);
|
FolderStore.displaySpecSetting(0 >= cnt || limit < cnt);
|
||||||
|
|
||||||
FolderStore.folderList(this.folderResponseParseRec(
|
FolderStore.folderList(this.folderResponseParseRec(
|
||||||
Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'], expandedFolders)); // @todo optimization required
|
isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'], expandedFolders)); // @todo optimization required
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
PromisesUserPopulator.prototype.foldersAdditionalParameters = function(oData)
|
foldersAdditionalParameters(oData) {
|
||||||
{
|
|
||||||
if (oData && oData && 'Collection/FolderCollection' === oData['@Object'] &&
|
if (oData && oData && 'Collection/FolderCollection' === oData['@Object'] &&
|
||||||
oData['@Collection'] && Utils.isArray(oData['@Collection']))
|
oData['@Collection'] && isArray(oData['@Collection']))
|
||||||
{
|
{
|
||||||
if (!Utils.isUnd(oData.Namespace))
|
if (!isUnd(oData.Namespace))
|
||||||
{
|
{
|
||||||
FolderStore.namespace = oData.Namespace;
|
FolderStore.namespace = oData.Namespace;
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +138,7 @@ PromisesUserPopulator.prototype.foldersAdditionalParameters = function(oData)
|
||||||
|
|
||||||
FolderStore.folderList.optimized(!!oData.Optimized);
|
FolderStore.folderList.optimized(!!oData.Optimized);
|
||||||
|
|
||||||
var bUpdate = false;
|
let update = false;
|
||||||
|
|
||||||
if (oData.SystemFolders && '' === '' +
|
if (oData.SystemFolders && '' === '' +
|
||||||
Settings.settingsGet('SentFolder') +
|
Settings.settingsGet('SentFolder') +
|
||||||
|
|
@ -163,13 +148,13 @@ PromisesUserPopulator.prototype.foldersAdditionalParameters = function(oData)
|
||||||
Settings.settingsGet('ArchiveFolder') +
|
Settings.settingsGet('ArchiveFolder') +
|
||||||
Settings.settingsGet('NullFolder'))
|
Settings.settingsGet('NullFolder'))
|
||||||
{
|
{
|
||||||
Settings.settingsSet('SentFolder', oData.SystemFolders[Enums.ServerFolderType.SENT] || null);
|
Settings.settingsSet('SentFolder', oData.SystemFolders[ServerFolderType.SENT] || null);
|
||||||
Settings.settingsSet('DraftFolder', oData.SystemFolders[Enums.ServerFolderType.DRAFTS] || null);
|
Settings.settingsSet('DraftFolder', oData.SystemFolders[ServerFolderType.DRAFTS] || null);
|
||||||
Settings.settingsSet('SpamFolder', oData.SystemFolders[Enums.ServerFolderType.JUNK] || null);
|
Settings.settingsSet('SpamFolder', oData.SystemFolders[ServerFolderType.JUNK] || null);
|
||||||
Settings.settingsSet('TrashFolder', oData.SystemFolders[Enums.ServerFolderType.TRASH] || null);
|
Settings.settingsSet('TrashFolder', oData.SystemFolders[ServerFolderType.TRASH] || null);
|
||||||
Settings.settingsSet('ArchiveFolder', oData.SystemFolders[Enums.ServerFolderType.ALL] || null);
|
Settings.settingsSet('ArchiveFolder', oData.SystemFolders[ServerFolderType.ALL] || null);
|
||||||
|
|
||||||
bUpdate = true;
|
update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderStore.sentFolder(this.normalizeFolder(Settings.settingsGet('SentFolder')));
|
FolderStore.sentFolder(this.normalizeFolder(Settings.settingsGet('SentFolder')));
|
||||||
|
|
@ -178,9 +163,9 @@ PromisesUserPopulator.prototype.foldersAdditionalParameters = function(oData)
|
||||||
FolderStore.trashFolder(this.normalizeFolder(Settings.settingsGet('TrashFolder')));
|
FolderStore.trashFolder(this.normalizeFolder(Settings.settingsGet('TrashFolder')));
|
||||||
FolderStore.archiveFolder(this.normalizeFolder(Settings.settingsGet('ArchiveFolder')));
|
FolderStore.archiveFolder(this.normalizeFolder(Settings.settingsGet('ArchiveFolder')));
|
||||||
|
|
||||||
if (bUpdate)
|
if (update)
|
||||||
{
|
{
|
||||||
require('Remote/User/Ajax').saveSystemFolders(Utils.noop, {
|
require('Remote/User/Ajax').saveSystemFolders(noop, {
|
||||||
SentFolder: FolderStore.sentFolder(),
|
SentFolder: FolderStore.sentFolder(),
|
||||||
DraftFolder: FolderStore.draftFolder(),
|
DraftFolder: FolderStore.draftFolder(),
|
||||||
SpamFolder: FolderStore.spamFolder(),
|
SpamFolder: FolderStore.spamFolder(),
|
||||||
|
|
@ -190,8 +175,9 @@ PromisesUserPopulator.prototype.foldersAdditionalParameters = function(oData)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Local.set(Enums.ClientSideKeyName.FoldersLashHash, oData.FoldersHash);
|
Local.set(ClientSideKeyName.FoldersLashHash, oData.FoldersHash);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = new PromisesUserPopulator();
|
module.exports = new PromisesUserPopulator();
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,23 @@
|
||||||
|
|
||||||
var
|
import window from 'window';
|
||||||
window = require('window'),
|
import _ from '_';
|
||||||
_ = require('_'),
|
import $ from '$';
|
||||||
$ = require('$'),
|
|
||||||
|
|
||||||
Consts = require('Common/Consts'),
|
import {TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT, DEFAULT_AJAX_TIMEOUT} from 'Common/Consts';
|
||||||
Enums = require('Common/Enums'),
|
import {StorageResultType, Notification} from 'Common/Enums';
|
||||||
Globals = require('Common/Globals'),
|
import {inArray, pInt, pString, isUnd} from 'Common/Utils';
|
||||||
Utils = require('Common/Utils'),
|
import {data as GlobalsData} from 'Common/Globals';
|
||||||
Plugins = require('Common/Plugins'),
|
import {ajax} from 'Common/Links';
|
||||||
Links = require('Common/Links'),
|
import {runHook} from 'Common/Plugins';
|
||||||
|
|
||||||
Settings = require('Storage/Settings');
|
import * as Settings from 'Storage/Settings';
|
||||||
|
|
||||||
/**
|
class AbstractAjaxRemote
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AbstractAjaxRemote()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.oRequests = {};
|
this.oRequests = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractAjaxRemote.prototype.oRequests = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sRequestAction
|
* @param {string} sRequestAction
|
||||||
|
|
@ -31,65 +26,64 @@ AbstractAjaxRemote.prototype.oRequests = {};
|
||||||
* @param {boolean} bCached
|
* @param {boolean} bCached
|
||||||
* @param {*=} oRequestParameters
|
* @param {*=} oRequestParameters
|
||||||
*/
|
*/
|
||||||
AbstractAjaxRemote.prototype.defaultResponse = function(fCallback, sRequestAction, sType, oData, bCached, oRequestParameters)
|
defaultResponse(fCallback, sRequestAction, sType, oData, bCached, oRequestParameters) {
|
||||||
|
const
|
||||||
|
fCall = () => {
|
||||||
|
if (StorageResultType.Success !== sType && GlobalsData.bUnload)
|
||||||
{
|
{
|
||||||
var
|
sType = StorageResultType.Unload;
|
||||||
fCall = function() {
|
|
||||||
if (Enums.StorageResultType.Success !== sType && Globals.data.bUnload)
|
|
||||||
{
|
|
||||||
sType = Enums.StorageResultType.Unload;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Enums.StorageResultType.Success === sType && oData && !oData.Result)
|
if (StorageResultType.Success === sType && oData && !oData.Result)
|
||||||
{
|
{
|
||||||
if (oData && -1 < Utils.inArray(oData.ErrorCode, [
|
if (oData && -1 < inArray(oData.ErrorCode, [
|
||||||
Enums.Notification.AuthError, Enums.Notification.AccessError,
|
Notification.AuthError, Notification.AccessError,
|
||||||
Enums.Notification.ConnectionError, Enums.Notification.DomainNotAllowed, Enums.Notification.AccountNotAllowed,
|
Notification.ConnectionError, Notification.DomainNotAllowed, Notification.AccountNotAllowed,
|
||||||
Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError
|
Notification.MailServerError, Notification.UnknownNotification, Notification.UnknownError
|
||||||
]))
|
]))
|
||||||
{
|
{
|
||||||
Globals.data.iAjaxErrorCount += 1;
|
GlobalsData.iAjaxErrorCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oData && Enums.Notification.InvalidToken === oData.ErrorCode)
|
if (oData && Notification.InvalidToken === oData.ErrorCode)
|
||||||
{
|
{
|
||||||
Globals.data.iTokenErrorCount += 1;
|
GlobalsData.iTokenErrorCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Consts.TOKEN_ERROR_LIMIT < Globals.data.iTokenErrorCount)
|
if (TOKEN_ERROR_LIMIT < GlobalsData.iTokenErrorCount)
|
||||||
{
|
{
|
||||||
if (Globals.data.__APP__ && Globals.data.__APP__.loginAndLogoutReload)
|
if (GlobalsData.__APP__ && GlobalsData.__APP__.loginAndLogoutReload)
|
||||||
{
|
{
|
||||||
Globals.data.__APP__.loginAndLogoutReload(false, true);
|
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oData.ClearAuth || oData.Logout || Consts.AJAX_ERROR_LIMIT < Globals.data.iAjaxErrorCount)
|
if (oData.ClearAuth || oData.Logout || AJAX_ERROR_LIMIT < GlobalsData.iAjaxErrorCount)
|
||||||
{
|
{
|
||||||
if (Globals.data.__APP__ && Globals.data.__APP__.clearClientSideToken)
|
if (GlobalsData.__APP__ && GlobalsData.__APP__.clearClientSideToken)
|
||||||
{
|
{
|
||||||
Globals.data.__APP__.clearClientSideToken();
|
GlobalsData.__APP__.clearClientSideToken();
|
||||||
|
|
||||||
if (!oData.ClearAuth && Globals.data.__APP__.loginAndLogoutReload)
|
if (!oData.ClearAuth && GlobalsData.__APP__.loginAndLogoutReload)
|
||||||
{
|
{
|
||||||
Globals.data.__APP__.loginAndLogoutReload(false, true);
|
GlobalsData.__APP__.loginAndLogoutReload(false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Enums.StorageResultType.Success === sType && oData && oData.Result)
|
else if (StorageResultType.Success === sType && oData && oData.Result)
|
||||||
{
|
{
|
||||||
Globals.data.iAjaxErrorCount = 0;
|
GlobalsData.iAjaxErrorCount = 0;
|
||||||
Globals.data.iTokenErrorCount = 0;
|
GlobalsData.iTokenErrorCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugins.runHook('ajax-default-response', [sRequestAction, Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]);
|
runHook('ajax-default-response', [sRequestAction, StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]);
|
||||||
|
|
||||||
if (fCallback)
|
if (fCallback)
|
||||||
{
|
{
|
||||||
fCallback(
|
fCallback(
|
||||||
sType,
|
sType,
|
||||||
Enums.StorageResultType.Success === sType ? oData : null,
|
StorageResultType.Success === sType ? oData : null,
|
||||||
bCached,
|
bCached,
|
||||||
sRequestAction,
|
sRequestAction,
|
||||||
oRequestParameters
|
oRequestParameters
|
||||||
|
|
@ -100,17 +94,17 @@ AbstractAjaxRemote.prototype.defaultResponse = function(fCallback, sRequestActio
|
||||||
switch (sType)
|
switch (sType)
|
||||||
{
|
{
|
||||||
case 'success':
|
case 'success':
|
||||||
sType = Enums.StorageResultType.Success;
|
sType = StorageResultType.Success;
|
||||||
break;
|
break;
|
||||||
case 'abort':
|
case 'abort':
|
||||||
sType = Enums.StorageResultType.Abort;
|
sType = StorageResultType.Abort;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sType = Enums.StorageResultType.Error;
|
sType = StorageResultType.Error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Enums.StorageResultType.Error === sType)
|
if (StorageResultType.Error === sType)
|
||||||
{
|
{
|
||||||
_.delay(fCall, 300);
|
_.delay(fCall, 300);
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +112,7 @@ AbstractAjaxRemote.prototype.defaultResponse = function(fCallback, sRequestActio
|
||||||
{
|
{
|
||||||
fCall();
|
fCall();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fResultCallback
|
* @param {?Function} fResultCallback
|
||||||
|
|
@ -128,91 +122,87 @@ AbstractAjaxRemote.prototype.defaultResponse = function(fCallback, sRequestActio
|
||||||
* @param {Array=} aAbortActions = []
|
* @param {Array=} aAbortActions = []
|
||||||
* @returns {jQuery.jqXHR}
|
* @returns {jQuery.jqXHR}
|
||||||
*/
|
*/
|
||||||
AbstractAjaxRemote.prototype.ajaxRequest = function(fResultCallback, oParameters, iTimeOut, sGetAdd, aAbortActions)
|
ajaxRequest(fResultCallback, params, iTimeOut = 20000, sGetAdd = '', abortActions = []) {
|
||||||
{
|
const
|
||||||
var
|
isPost = '' === sGetAdd,
|
||||||
self = this,
|
headers = {},
|
||||||
bPost = '' === sGetAdd,
|
start = (new window.Date()).getTime();
|
||||||
oHeaders = {},
|
|
||||||
iStart = (new window.Date()).getTime(),
|
|
||||||
sAction = '';
|
|
||||||
|
|
||||||
oParameters = oParameters || {};
|
let
|
||||||
iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : 20000;
|
action = '';
|
||||||
sGetAdd = Utils.isUnd(sGetAdd) ? '' : Utils.pString(sGetAdd);
|
|
||||||
aAbortActions = Utils.isArray(aAbortActions) ? aAbortActions : [];
|
|
||||||
|
|
||||||
sAction = oParameters.Action || '';
|
params = params || {};
|
||||||
|
action = params.Action || '';
|
||||||
|
|
||||||
if (sAction && 0 < aAbortActions.length)
|
if (action && 0 < abortActions.length)
|
||||||
{
|
{
|
||||||
_.each(aAbortActions, function(sActionToAbort) {
|
_.each(abortActions, (actionToAbort) => {
|
||||||
if (self.oRequests[sActionToAbort])
|
if (this.oRequests[actionToAbort])
|
||||||
{
|
{
|
||||||
self.oRequests[sActionToAbort].__aborted = true;
|
this.oRequests[actionToAbort].__aborted = true;
|
||||||
if (self.oRequests[sActionToAbort].abort)
|
if (this.oRequests[actionToAbort].abort)
|
||||||
{
|
{
|
||||||
self.oRequests[sActionToAbort].abort();
|
this.oRequests[actionToAbort].abort();
|
||||||
}
|
}
|
||||||
self.oRequests[sActionToAbort] = null;
|
this.oRequests[actionToAbort] = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bPost)
|
if (isPost)
|
||||||
{
|
{
|
||||||
oParameters.XToken = Settings.appSettingsGet('token');
|
params.XToken = Settings.appSettingsGet('token');
|
||||||
}
|
}
|
||||||
|
|
||||||
var oDefAjax = $.ajax({
|
const oDefAjax = $.ajax({
|
||||||
type: bPost ? 'POST' : 'GET',
|
type: isPost ? 'POST' : 'GET',
|
||||||
url: Links.ajax(sGetAdd),
|
url: ajax(sGetAdd),
|
||||||
async: true,
|
async: true,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: bPost ? oParameters : {},
|
data: isPost ? params : {},
|
||||||
headers: oHeaders,
|
headers: headers,
|
||||||
timeout: iTimeOut,
|
timeout: iTimeOut,
|
||||||
global: true
|
global: true
|
||||||
});
|
});
|
||||||
|
|
||||||
oDefAjax.always(function(oData, sType) {
|
oDefAjax.always((oData, sType) => {
|
||||||
|
|
||||||
var bCached = false;
|
let cached = false;
|
||||||
if (oData && oData.Time)
|
if (oData && oData.Time)
|
||||||
{
|
{
|
||||||
bCached = Utils.pInt(oData.Time) > (new window.Date()).getTime() - iStart;
|
cached = pInt(oData.Time) > (new window.Date()).getTime() - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sAction && self.oRequests[sAction])
|
if (action && this.oRequests[action])
|
||||||
{
|
{
|
||||||
if (self.oRequests[sAction].__aborted)
|
if (this.oRequests[action].__aborted)
|
||||||
{
|
{
|
||||||
sType = 'abort';
|
sType = 'abort';
|
||||||
}
|
}
|
||||||
|
|
||||||
self.oRequests[sAction] = null;
|
this.oRequests[action] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.defaultResponse(fResultCallback, sAction, sType, oData, bCached, oParameters);
|
this.defaultResponse(fResultCallback, action, sType, oData, cached, params);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (sAction && 0 < aAbortActions.length && -1 < Utils.inArray(sAction, aAbortActions))
|
if (action && 0 < abortActions.length && -1 < inArray(action, abortActions))
|
||||||
{
|
{
|
||||||
if (this.oRequests[sAction])
|
if (this.oRequests[action])
|
||||||
{
|
{
|
||||||
this.oRequests[sAction].__aborted = true;
|
this.oRequests[action].__aborted = true;
|
||||||
if (this.oRequests[sAction].abort)
|
if (this.oRequests[action].abort)
|
||||||
{
|
{
|
||||||
this.oRequests[sAction].abort();
|
this.oRequests[action].abort();
|
||||||
}
|
}
|
||||||
this.oRequests[sAction] = null;
|
this.oRequests[action] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.oRequests[sAction] = oDefAjax;
|
this.oRequests[action] = oDefAjax;
|
||||||
}
|
}
|
||||||
|
|
||||||
return oDefAjax;
|
return oDefAjax;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
|
|
@ -222,26 +212,24 @@ AbstractAjaxRemote.prototype.ajaxRequest = function(fResultCallback, oParameters
|
||||||
* @param {string=} sGetAdd = ''
|
* @param {string=} sGetAdd = ''
|
||||||
* @param {Array=} aAbortActions = []
|
* @param {Array=} aAbortActions = []
|
||||||
*/
|
*/
|
||||||
AbstractAjaxRemote.prototype.defaultRequest = function(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions)
|
defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions) {
|
||||||
{
|
|
||||||
oParameters = oParameters || {};
|
oParameters = oParameters || {};
|
||||||
oParameters.Action = sAction;
|
oParameters.Action = sAction;
|
||||||
|
|
||||||
sGetAdd = Utils.pString(sGetAdd);
|
sGetAdd = pString(sGetAdd);
|
||||||
|
|
||||||
Plugins.runHook('ajax-default-request', [sAction, oParameters, sGetAdd]);
|
runHook('ajax-default-request', [sAction, oParameters, sGetAdd]);
|
||||||
|
|
||||||
return this.ajaxRequest(fCallback, oParameters,
|
return this.ajaxRequest(fCallback, oParameters,
|
||||||
Utils.isUnd(iTimeout) ? Consts.DEFAULT_AJAX_TIMEOUT : Utils.pInt(iTimeout), sGetAdd, aAbortActions);
|
isUnd(iTimeout) ? DEFAULT_AJAX_TIMEOUT : pInt(iTimeout), sGetAdd, aAbortActions);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
*/
|
*/
|
||||||
AbstractAjaxRemote.prototype.noop = function(fCallback)
|
noop(fCallback) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'Noop');
|
this.defaultRequest(fCallback, 'Noop');
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
|
|
@ -252,8 +240,7 @@ AbstractAjaxRemote.prototype.noop = function(fCallback)
|
||||||
* @param {string} sHtmlCapa
|
* @param {string} sHtmlCapa
|
||||||
* @param {number} iTime
|
* @param {number} iTime
|
||||||
*/
|
*/
|
||||||
AbstractAjaxRemote.prototype.jsError = function(fCallback, sMessage, sFileName, iLineNo, sLocation, sHtmlCapa, iTime)
|
jsError(fCallback, sMessage, sFileName, iLineNo, sLocation, sHtmlCapa, iTime) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'JsError', {
|
this.defaultRequest(fCallback, 'JsError', {
|
||||||
'Message': sMessage,
|
'Message': sMessage,
|
||||||
'FileName': sFileName,
|
'FileName': sFileName,
|
||||||
|
|
@ -262,7 +249,7 @@ AbstractAjaxRemote.prototype.jsError = function(fCallback, sMessage, sFileName,
|
||||||
'HtmlCapa': sHtmlCapa,
|
'HtmlCapa': sHtmlCapa,
|
||||||
'TimeOnPage': iTime
|
'TimeOnPage': iTime
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
|
|
@ -270,32 +257,30 @@ AbstractAjaxRemote.prototype.jsError = function(fCallback, sMessage, sFileName,
|
||||||
* @param {Array=} mData = null
|
* @param {Array=} mData = null
|
||||||
* @param {boolean=} bIsError = false
|
* @param {boolean=} bIsError = false
|
||||||
*/
|
*/
|
||||||
AbstractAjaxRemote.prototype.jsInfo = function(fCallback, sType, mData, bIsError)
|
jsInfo(fCallback, sType, mData, bIsError = false) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'JsInfo', {
|
this.defaultRequest(fCallback, 'JsInfo', {
|
||||||
'Type': sType,
|
'Type': sType,
|
||||||
'Data': mData,
|
'Data': mData,
|
||||||
'IsError': (Utils.isUnd(bIsError) ? false : !!bIsError) ? '1' : '0'
|
'IsError': bIsError ? '1' : '0'
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
*/
|
*/
|
||||||
AbstractAjaxRemote.prototype.getPublicKey = function(fCallback)
|
getPublicKey(fCallback) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'GetPublicKey');
|
this.defaultRequest(fCallback, 'GetPublicKey');
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sVersion
|
* @param {string} sVersion
|
||||||
*/
|
*/
|
||||||
AbstractAjaxRemote.prototype.jsVersion = function(fCallback, sVersion)
|
jsVersion(fCallback, sVersion) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'Version', {
|
this.defaultRequest(fCallback, 'Version', {
|
||||||
'Version': sVersion
|
'Version': sVersion
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = AbstractAjaxRemote;
|
export {AbstractAjaxRemote, AbstractAjaxRemote as default};
|
||||||
|
|
|
||||||
|
|
@ -1,244 +1,212 @@
|
||||||
|
|
||||||
var
|
import {AbstractAjaxRemote} from 'Remote/AbstractAjax';
|
||||||
_ = require('_'),
|
|
||||||
|
|
||||||
Utils = require('Common/Utils'),
|
class RemoteAdminAjax extends AbstractAjaxRemote
|
||||||
|
|
||||||
AbstractAjaxRemote = require('Remote/AbstractAjax');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends AbstractAjaxRemote
|
|
||||||
*/
|
|
||||||
function RemoteAdminAjax()
|
|
||||||
{
|
{
|
||||||
AbstractAjaxRemote.call(this);
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
this.oRequests = {};
|
this.oRequests = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
_.extend(RemoteAdminAjax.prototype, AbstractAjaxRemote.prototype);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sLogin
|
* @param {string} sLogin
|
||||||
* @param {string} sPassword
|
* @param {string} sPassword
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.adminLogin = function(fCallback, sLogin, sPassword)
|
adminLogin(fCallback, sLogin, sPassword) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminLogin', {
|
this.defaultRequest(fCallback, 'AdminLogin', {
|
||||||
'Login': sLogin,
|
'Login': sLogin,
|
||||||
'Password': sPassword
|
'Password': sPassword
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.adminLogout = function(fCallback)
|
adminLogout(fCallback) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminLogout');
|
this.defaultRequest(fCallback, 'AdminLogout');
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {?} oData
|
* @param {?} oData
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.saveAdminConfig = function(fCallback, oData)
|
saveAdminConfig(fCallback, oData) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData);
|
this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @param {?Function} valueFn
|
* @param {?Function} valueFn
|
||||||
* @param {?Function} fn
|
* @param {?Function} fn
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.saveAdminConfigHelper = function(key, valueFn, fn)
|
saveAdminConfigHelper(key, valueFn, fn) {
|
||||||
{
|
return (value) => {
|
||||||
var self = this;
|
const data = {};
|
||||||
return function(value) {
|
|
||||||
var data = {};
|
|
||||||
data[key] = valueFn ? valueFn(value) : value;
|
data[key] = valueFn ? valueFn(value) : value;
|
||||||
self.saveAdminConfig(fn || null, data);
|
this.saveAdminConfig(fn || null, data);
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {boolean=} bIncludeAliases = true
|
* @param {boolean=} bIncludeAliases = true
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.domainList = function(fCallback, bIncludeAliases)
|
domainList(fCallback, bIncludeAliases = true) {
|
||||||
{
|
|
||||||
bIncludeAliases = Utils.isUnd(bIncludeAliases) ? true : bIncludeAliases;
|
|
||||||
this.defaultRequest(fCallback, 'AdminDomainList', {
|
this.defaultRequest(fCallback, 'AdminDomainList', {
|
||||||
'IncludeAliases': bIncludeAliases ? '1' : '0'
|
'IncludeAliases': bIncludeAliases ? '1' : '0'
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.pluginList = function(fCallback)
|
pluginList(fCallback) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPluginList');
|
this.defaultRequest(fCallback, 'AdminPluginList');
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.packagesList = function(fCallback)
|
packagesList(fCallback) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPackagesList');
|
this.defaultRequest(fCallback, 'AdminPackagesList');
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.coreData = function(fCallback)
|
coreData(fCallback) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminCoreData');
|
this.defaultRequest(fCallback, 'AdminCoreData');
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.updateCoreData = function(fCallback)
|
updateCoreData(fCallback) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000);
|
this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {Object} oPackage
|
* @param {Object} oPackage
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.packageInstall = function(fCallback, oPackage)
|
packageInstall(fCallback, oPackage) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPackageInstall', {
|
this.defaultRequest(fCallback, 'AdminPackageInstall', {
|
||||||
'Id': oPackage.id,
|
'Id': oPackage.id,
|
||||||
'Type': oPackage.type,
|
'Type': oPackage.type,
|
||||||
'File': oPackage.file
|
'File': oPackage.file
|
||||||
}, 60000);
|
}, 60000);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {Object} oPackage
|
* @param {Object} oPackage
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.packageDelete = function(fCallback, oPackage)
|
packageDelete(fCallback, oPackage) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPackageDelete', {
|
this.defaultRequest(fCallback, 'AdminPackageDelete', {
|
||||||
'Id': oPackage.id
|
'Id': oPackage.id
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sName
|
* @param {string} sName
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.domain = function(fCallback, sName)
|
domain(fCallback, sName) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminDomainLoad', {
|
this.defaultRequest(fCallback, 'AdminDomainLoad', {
|
||||||
'Name': sName
|
'Name': sName
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sName
|
* @param {string} sName
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.plugin = function(fCallback, sName)
|
plugin(fCallback, sName) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPluginLoad', {
|
this.defaultRequest(fCallback, 'AdminPluginLoad', {
|
||||||
'Name': sName
|
'Name': sName
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sName
|
* @param {string} sName
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.domainDelete = function(fCallback, sName)
|
domainDelete(fCallback, sName) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminDomainDelete', {
|
this.defaultRequest(fCallback, 'AdminDomainDelete', {
|
||||||
'Name': sName
|
'Name': sName
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sName
|
* @param {string} sName
|
||||||
* @param {boolean} bDisabled
|
* @param {boolean} bDisabled
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.domainDisable = function(fCallback, sName, bDisabled)
|
domainDisable(fCallback, sName, bDisabled) {
|
||||||
{
|
|
||||||
return this.defaultRequest(fCallback, 'AdminDomainDisable', {
|
return this.defaultRequest(fCallback, 'AdminDomainDisable', {
|
||||||
Name: sName,
|
Name: sName,
|
||||||
Disabled: bDisabled ? '1' : '0'
|
Disabled: bDisabled ? '1' : '0'
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {Object} oConfig
|
* @param {Object} oConfig
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.pluginSettingsUpdate = function(fCallback, oConfig)
|
pluginSettingsUpdate(fCallback, oConfig) {
|
||||||
{
|
|
||||||
return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig);
|
return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {boolean} bForce
|
* @param {boolean} bForce
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.licensing = function(fCallback, bForce)
|
licensing(fCallback, bForce) {
|
||||||
{
|
|
||||||
return this.defaultRequest(fCallback, 'AdminLicensing', {
|
return this.defaultRequest(fCallback, 'AdminLicensing', {
|
||||||
Force: bForce ? '1' : '0'
|
Force: bForce ? '1' : '0'
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sDomain
|
* @param {string} sDomain
|
||||||
* @param {string} sKey
|
* @param {string} sKey
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.licensingActivate = function(fCallback, sDomain, sKey)
|
licensingActivate(fCallback, sDomain, sKey) {
|
||||||
{
|
|
||||||
return this.defaultRequest(fCallback, 'AdminLicensingActivate', {
|
return this.defaultRequest(fCallback, 'AdminLicensingActivate', {
|
||||||
Domain: sDomain,
|
Domain: sDomain,
|
||||||
Key: sKey
|
Key: sKey
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sName
|
* @param {string} sName
|
||||||
* @param {boolean} bDisabled
|
* @param {boolean} bDisabled
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.pluginDisable = function(fCallback, sName, bDisabled)
|
pluginDisable(fCallback, sName, bDisabled) {
|
||||||
{
|
|
||||||
return this.defaultRequest(fCallback, 'AdminPluginDisable', {
|
return this.defaultRequest(fCallback, 'AdminPluginDisable', {
|
||||||
Name: sName,
|
Name: sName,
|
||||||
Disabled: bDisabled ? '1' : '0'
|
Disabled: bDisabled ? '1' : '0'
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
RemoteAdminAjax.prototype.createDomainAlias = function(fCallback, sName, sAlias)
|
createDomainAlias(fCallback, sName, sAlias) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminDomainAliasSave', {
|
this.defaultRequest(fCallback, 'AdminDomainAliasSave', {
|
||||||
Name: sName,
|
Name: sName,
|
||||||
Alias: sAlias
|
Alias: sAlias
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
RemoteAdminAjax.prototype.createOrUpdateDomain = function(fCallback,
|
createOrUpdateDomain(fCallback,
|
||||||
bCreate, sName,
|
bCreate, sName,
|
||||||
sIncHost, iIncPort, sIncSecure, bIncShortLogin,
|
sIncHost, iIncPort, sIncSecure, bIncShortLogin,
|
||||||
bUseSieve, sSieveAllowRaw, sSieveHost, iSievePort, sSieveSecure,
|
bUseSieve, sSieveAllowRaw, sSieveHost, iSievePort, sSieveSecure,
|
||||||
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, bOutPhpMail,
|
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, bOutPhpMail,
|
||||||
sWhiteList)
|
sWhiteList
|
||||||
{
|
) {
|
||||||
this.defaultRequest(fCallback, 'AdminDomainSave', {
|
this.defaultRequest(fCallback, 'AdminDomainSave', {
|
||||||
'Create': bCreate ? '1' : '0',
|
'Create': bCreate ? '1' : '0',
|
||||||
'Name': sName,
|
'Name': sName,
|
||||||
|
|
@ -263,13 +231,13 @@ RemoteAdminAjax.prototype.createOrUpdateDomain = function(fCallback,
|
||||||
|
|
||||||
'WhiteList': sWhiteList
|
'WhiteList': sWhiteList
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
RemoteAdminAjax.prototype.testConnectionForDomain = function(fCallback, sName,
|
testConnectionForDomain(fCallback, sName,
|
||||||
sIncHost, iIncPort, sIncSecure,
|
sIncHost, iIncPort, sIncSecure,
|
||||||
bUseSieve, sSieveHost, iSievePort, sSieveSecure,
|
bUseSieve, sSieveHost, iSievePort, sSieveSecure,
|
||||||
sOutHost, iOutPort, sOutSecure, bOutAuth, bOutPhpMail)
|
sOutHost, iOutPort, sOutSecure, bOutAuth, bOutPhpMail
|
||||||
{
|
) {
|
||||||
this.defaultRequest(fCallback, 'AdminDomainTest', {
|
this.defaultRequest(fCallback, 'AdminDomainTest', {
|
||||||
'Name': sName,
|
'Name': sName,
|
||||||
'IncHost': sIncHost,
|
'IncHost': sIncHost,
|
||||||
|
|
@ -285,32 +253,30 @@ RemoteAdminAjax.prototype.testConnectionForDomain = function(fCallback, sName,
|
||||||
'OutAuth': bOutAuth ? '1' : '0',
|
'OutAuth': bOutAuth ? '1' : '0',
|
||||||
'OutUsePhpMail': bOutPhpMail ? '1' : '0'
|
'OutUsePhpMail': bOutPhpMail ? '1' : '0'
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {?} oData
|
* @param {?} oData
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.testContacts = function(fCallback, oData)
|
testContacts(fCallback, oData) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminContactsTest', oData);
|
this.defaultRequest(fCallback, 'AdminContactsTest', oData);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {?} oData
|
* @param {?} oData
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.saveNewAdminPassword = function(fCallback, oData)
|
saveNewAdminPassword(fCallback, oData) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData);
|
this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
*/
|
*/
|
||||||
RemoteAdminAjax.prototype.adminPing = function(fCallback)
|
adminPing(fCallback) {
|
||||||
{
|
|
||||||
this.defaultRequest(fCallback, 'AdminPing');
|
this.defaultRequest(fCallback, 'AdminPing');
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new RemoteAdminAjax();
|
module.exports = new RemoteAdminAjax();
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -37,16 +37,15 @@ class AbstractSettingsScreen extends AbstractScreen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onRoute(sSubName) {
|
onRoute(subName) {
|
||||||
var
|
let
|
||||||
self = this,
|
settingsScreen = null,
|
||||||
oSettingsScreen = null,
|
|
||||||
RoutedSettingsViewModel = null,
|
RoutedSettingsViewModel = null,
|
||||||
oViewModelPlace = null,
|
viewModelPlace = null,
|
||||||
oViewModelDom = null;
|
viewModelDom = null;
|
||||||
|
|
||||||
RoutedSettingsViewModel = _.find(VIEW_MODELS.settings,
|
RoutedSettingsViewModel = _.find(VIEW_MODELS.settings,
|
||||||
(SettingsViewModel) => SettingsViewModel && SettingsViewModel.__rlSettingsData && sSubName === SettingsViewModel.__rlSettingsData.Route
|
(SettingsViewModel) => SettingsViewModel && SettingsViewModel.__rlSettingsData && subName === SettingsViewModel.__rlSettingsData.Route
|
||||||
);
|
);
|
||||||
|
|
||||||
if (RoutedSettingsViewModel)
|
if (RoutedSettingsViewModel)
|
||||||
|
|
@ -67,32 +66,32 @@ class AbstractSettingsScreen extends AbstractScreen
|
||||||
{
|
{
|
||||||
if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
|
if (RoutedSettingsViewModel.__builded && RoutedSettingsViewModel.__vm)
|
||||||
{
|
{
|
||||||
oSettingsScreen = RoutedSettingsViewModel.__vm;
|
settingsScreen = RoutedSettingsViewModel.__vm;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oViewModelPlace = this.oViewModelPlace;
|
viewModelPlace = this.oViewModelPlace;
|
||||||
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
if (viewModelPlace && 1 === viewModelPlace.length)
|
||||||
{
|
{
|
||||||
oSettingsScreen = new RoutedSettingsViewModel();
|
settingsScreen = new RoutedSettingsViewModel();
|
||||||
|
|
||||||
oViewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
|
viewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
|
||||||
oViewModelDom.appendTo(oViewModelPlace);
|
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.__builded = true;
|
||||||
RoutedSettingsViewModel.__vm = oSettingsScreen;
|
RoutedSettingsViewModel.__vm = settingsScreen;
|
||||||
|
|
||||||
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
|
ko.applyBindingAccessorsToNode(viewModelDom[0], {
|
||||||
translatorInit: true,
|
translatorInit: true,
|
||||||
template: () => ({name: RoutedSettingsViewModel.__rlSettingsData.Template})
|
template: () => ({name: RoutedSettingsViewModel.__rlSettingsData.Template})
|
||||||
}, oSettingsScreen);
|
}, settingsScreen);
|
||||||
|
|
||||||
delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
|
delegateRun(settingsScreen, 'onBuild', [viewModelDom]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -100,29 +99,29 @@ class AbstractSettingsScreen extends AbstractScreen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oSettingsScreen)
|
if (settingsScreen)
|
||||||
{
|
{
|
||||||
_.defer(function() {
|
_.defer(() => {
|
||||||
// hide
|
// hide
|
||||||
if (self.oCurrentSubScreen)
|
if (this.oCurrentSubScreen)
|
||||||
{
|
{
|
||||||
delegateRun(self.oCurrentSubScreen, 'onHide');
|
delegateRun(this.oCurrentSubScreen, 'onHide');
|
||||||
self.oCurrentSubScreen.viewModelDom.hide();
|
this.oCurrentSubScreen.viewModelDom.hide();
|
||||||
}
|
}
|
||||||
// --
|
// --
|
||||||
|
|
||||||
self.oCurrentSubScreen = oSettingsScreen;
|
this.oCurrentSubScreen = settingsScreen;
|
||||||
|
|
||||||
// show
|
// show
|
||||||
if (self.oCurrentSubScreen)
|
if (this.oCurrentSubScreen)
|
||||||
{
|
{
|
||||||
delegateRun(self.oCurrentSubScreen, 'onBeforeShow');
|
delegateRun(this.oCurrentSubScreen, 'onBeforeShow');
|
||||||
self.oCurrentSubScreen.viewModelDom.show();
|
this.oCurrentSubScreen.viewModelDom.show();
|
||||||
delegateRun(self.oCurrentSubScreen, 'onShow');
|
delegateRun(this.oCurrentSubScreen, 'onShow');
|
||||||
delegateRun(self.oCurrentSubScreen, 'onShowWithDelay', [], 200);
|
delegateRun(this.oCurrentSubScreen, 'onShowWithDelay', [], 200);
|
||||||
|
|
||||||
_.each(self.menu(), (oItem) => {
|
_.each(this.menu(), (item) => {
|
||||||
oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route);
|
item.selected(settingsScreen && settingsScreen.__rlSettingsData && item.route === settingsScreen.__rlSettingsData.Route);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#rl-content .b-settings .b-content .content').scrollTop(0);
|
$('#rl-content .b-settings .b-content .content').scrollTop(0);
|
||||||
|
|
@ -166,22 +165,23 @@ class AbstractSettingsScreen extends AbstractScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
routes() {
|
routes() {
|
||||||
var
|
const
|
||||||
DefaultViewModel = _.find(VIEW_MODELS.settings,
|
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',
|
defaultRoute = DefaultViewModel && DefaultViewModel.__rlSettingsData ? DefaultViewModel.__rlSettingsData.Route : 'general',
|
||||||
oRules = {
|
rules = {
|
||||||
subname: /^(.*)$/,
|
subname: /^(.*)$/,
|
||||||
normalize_: (oRequest, oVals) => {
|
normalize_: (rquest, vals) => {
|
||||||
oVals.subname = isUnd(oVals.subname) ? defaultRoute : pString(oVals.subname);
|
vals.subname = isUnd(vals.subname) ? defaultRoute : pString(vals.subname);
|
||||||
return [oVals.subname];
|
return [vals.subname];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return [
|
return [
|
||||||
['{subname}/', oRules],
|
['{subname}/', rules],
|
||||||
['{subname}', oRules],
|
['{subname}', rules],
|
||||||
['', oRules]
|
['', rules]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,20 @@
|
||||||
|
|
||||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
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
|
class LoginAdminScreen extends AbstractScreen
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
super('login', [
|
super('login', [
|
||||||
require('View/Admin/Login')
|
LoginAdminView
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
App.setWindowTitle('');
|
getApp().setWindowTitle('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
|
|
||||||
|
/* global RL_COMMUNITY */
|
||||||
|
|
||||||
import {addSettingsViewModel} from 'Knoin/Knoin';
|
import {addSettingsViewModel} from 'Knoin/Knoin';
|
||||||
import {runSettingsViewModelHooks} from 'Common/Plugins';
|
import {runSettingsViewModelHooks} from 'Common/Plugins';
|
||||||
|
|
||||||
import {AbstractSettingsScreen} from 'Screen/AbstractSettings';
|
import {AbstractSettingsScreen} from 'Screen/AbstractSettings';
|
||||||
import App from 'App/Admin';
|
|
||||||
|
|
||||||
import {GeneralAdminSettings} from 'Settings/Admin/General';
|
import {GeneralAdminSettings} from 'Settings/Admin/General';
|
||||||
import {LoginAdminSettings} from 'Settings/Admin/Login';
|
import {LoginAdminSettings} from 'Settings/Admin/Login';
|
||||||
|
|
@ -15,12 +16,17 @@ import {PluginsAdminSettings} from 'Settings/Admin/Plugins';
|
||||||
import {PackagesAdminSettings} from 'Settings/Admin/Packages';
|
import {PackagesAdminSettings} from 'Settings/Admin/Packages';
|
||||||
import {AboutAdminSettings} from 'Settings/Admin/About';
|
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
|
class SettingsAdminScreen extends AbstractSettingsScreen
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
super([
|
super([
|
||||||
require('View/Admin/Settings/Menu'),
|
MenuSettingsAdminView,
|
||||||
require('View/Admin/Settings/Pane')
|
PaneSettingsAdminView
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +87,7 @@ class SettingsAdminScreen extends AbstractSettingsScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
App.setWindowTitle('');
|
getApp().setWindowTitle('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
|
|
||||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
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
|
class AboutUserScreen extends AbstractScreen
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
super('about', [
|
super('about', [AboutUserView]);
|
||||||
require('View/User/About')
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
App.setWindowTitle('RainLoop');
|
getApp().setWindowTitle('RainLoop');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
|
|
||||||
import {AbstractScreen} from 'Knoin/AbstractScreen';
|
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
|
class LoginUserScreen extends AbstractScreen
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
super('login', [
|
super('login', [LoginUserView]);
|
||||||
require('View/User/Login')
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
App.setWindowTitle('');
|
getApp().setWindowTitle('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,17 +16,25 @@ import SettingsStore from 'Stores/User/Settings';
|
||||||
import FolderStore from 'Stores/User/Folder';
|
import FolderStore from 'Stores/User/Folder';
|
||||||
import MessageStore from 'Stores/User/Message';
|
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 {AbstractScreen} from 'Knoin/AbstractScreen';
|
||||||
import App from 'App/User';
|
|
||||||
|
|
||||||
class MailBoxUserScreen extends AbstractScreen
|
class MailBoxUserScreen extends AbstractScreen
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
super('mailbox', [
|
super('mailbox', [
|
||||||
require('View/User/MailBox/SystemDropDown'),
|
SystemDropDownMailBoxUserView,
|
||||||
require('View/User/MailBox/FolderList'),
|
FolderListMailBoxUserView,
|
||||||
require('View/User/MailBox/MessageList'),
|
MessageListMailBoxUserView,
|
||||||
require('View/User/MailBox/MessageView')
|
MessageViewMailBoxUserView
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +50,7 @@ class MailBoxUserScreen extends AbstractScreen
|
||||||
foldersInboxUnreadCount = 0;
|
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 {string} folderHash
|
||||||
* @param {number} page
|
* @param {number} page
|
||||||
* @param {string} search
|
* @param {string} search
|
||||||
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
onRoute(folderHash, page, search) {
|
onRoute(folderHash, page, search) {
|
||||||
let threadUid = folderHash.replace(/^(.+)~([\d]+)$/, '$2');
|
let threadUid = folderHash.replace(/^(.+)~([\d]+)$/, '$2');
|
||||||
|
|
@ -91,7 +100,7 @@ class MailBoxUserScreen extends AbstractScreen
|
||||||
MessageStore.messageListSearch(search);
|
MessageStore.messageListSearch(search);
|
||||||
MessageStore.messageListThreadUid(threadUid);
|
MessageStore.messageListThreadUid(threadUid);
|
||||||
|
|
||||||
App.reloadMessageList();
|
getApp().reloadMessageList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,9 +113,8 @@ class MailBoxUserScreen extends AbstractScreen
|
||||||
MessageStore.messageList.subscribe(windowResizeCallback);
|
MessageStore.messageList.subscribe(windowResizeCallback);
|
||||||
MessageStore.message.subscribe(windowResizeCallback);
|
MessageStore.message.subscribe(windowResizeCallback);
|
||||||
|
|
||||||
_.delay(() => {
|
_.delay(() => SettingsStore.layout.valueHasMutated(), Magics.Time50ms);
|
||||||
SettingsStore.layout.valueHasMutated();
|
_.delay(() => warmUpScreenPopup(require('View/Popup/Compose')), Magics.Time500ms);
|
||||||
}, Magics.Time50ms);
|
|
||||||
|
|
||||||
Events.sub('mailbox.inbox-unread-count', (count) => {
|
Events.sub('mailbox.inbox-unread-count', (count) => {
|
||||||
FolderStore.foldersInboxUnreadCount(count);
|
FolderStore.foldersInboxUnreadCount(count);
|
||||||
|
|
@ -130,7 +138,7 @@ class MailBoxUserScreen extends AbstractScreen
|
||||||
if (!bMobileDevice && !Settings.appSettingsGet('mobile'))
|
if (!bMobileDevice && !Settings.appSettingsGet('mobile'))
|
||||||
{
|
{
|
||||||
_.defer(() => {
|
_.defer(() => {
|
||||||
App.initHorizontalLayoutResizer(ClientSideKeyName.MessageListSize);
|
getApp().initHorizontalLayoutResizer(ClientSideKeyName.MessageListSize);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +147,7 @@ class MailBoxUserScreen extends AbstractScreen
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
routes() {
|
routes() {
|
||||||
var
|
const
|
||||||
inboxFolderName = getFolderInboxName(),
|
inboxFolderName = getFolderInboxName(),
|
||||||
fNormS = (request, vals) => {
|
fNormS = (request, vals) => {
|
||||||
vals[0] = pString(vals[0]);
|
vals[0] = pString(vals[0]);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import * as Settings from 'Storage/Settings';
|
||||||
import {addSettingsViewModel} from 'Knoin/Knoin';
|
import {addSettingsViewModel} from 'Knoin/Knoin';
|
||||||
|
|
||||||
import {AbstractSettingsScreen} from 'Screen/AbstractSettings';
|
import {AbstractSettingsScreen} from 'Screen/AbstractSettings';
|
||||||
import App from 'App/User';
|
|
||||||
|
|
||||||
import {GeneralUserSettings} from 'Settings/User/General';
|
import {GeneralUserSettings} from 'Settings/User/General';
|
||||||
import {ContactsUserSettings} from 'Settings/User/Contacts';
|
import {ContactsUserSettings} from 'Settings/User/Contacts';
|
||||||
|
|
@ -25,13 +24,19 @@ import {FoldersUserSettings} from 'Settings/User/Folders';
|
||||||
import {ThemesUserSettings} from 'Settings/User/Themes';
|
import {ThemesUserSettings} from 'Settings/User/Themes';
|
||||||
import {OpenPgpUserSettings} from 'Settings/User/OpenPgp';
|
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
|
class SettingsUserScreen extends AbstractSettingsScreen
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
super([
|
super([
|
||||||
require('View/User/Settings/SystemDropDown'),
|
SystemDropDownSettingsUserView,
|
||||||
require('View/User/Settings/Menu'),
|
MenuSettingsUserView,
|
||||||
require('View/User/Settings/Pane')
|
PaneSettingsUserView
|
||||||
]);
|
]);
|
||||||
|
|
||||||
initOnStartOrLangChange(() => {
|
initOnStartOrLangChange(() => {
|
||||||
|
|
@ -144,7 +149,7 @@ class SettingsUserScreen extends AbstractSettingsScreen
|
||||||
|
|
||||||
setSettingsTitle() {
|
setSettingsTitle() {
|
||||||
const sEmail = AccountStore.email();
|
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 ko from 'ko';
|
||||||
|
|
||||||
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
|
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
|
||||||
import {appSettingsGet, settingsGet} from 'Storage/Settings';
|
import {appSettingsGet, settingsGet} from 'Storage/Settings';
|
||||||
|
|
||||||
import CoreStore from 'Stores/Admin/Core';
|
|
||||||
import AppStore from 'Stores/Admin/App';
|
import AppStore from 'Stores/Admin/App';
|
||||||
|
import CoreStore from 'Stores/Admin/Core';
|
||||||
|
|
||||||
|
import {getApp} from 'Helper/Apps/Admin';
|
||||||
|
|
||||||
class AboutAdminSettings
|
class AboutAdminSettings
|
||||||
{
|
{
|
||||||
|
|
@ -71,14 +75,14 @@ class AboutAdminSettings
|
||||||
onBuild() {
|
onBuild() {
|
||||||
if (this.access() && !this.community)
|
if (this.access() && !this.community)
|
||||||
{
|
{
|
||||||
require('App/Admin').default.reloadCoreData();
|
getApp().reloadCoreData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCoreData() {
|
updateCoreData() {
|
||||||
if (!this.coreUpdating() && !this.community)
|
if (!this.coreUpdating() && !this.community)
|
||||||
{
|
{
|
||||||
require('App/Admin').default.updateCoreData();
|
getApp().updateCoreData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
/* global RL_COMMUNITY */
|
||||||
|
|
||||||
import _ from '_';
|
import _ from '_';
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,11 @@ class ContactsAdminSettings
|
||||||
}
|
}
|
||||||
}).extend({notify: 'always'});
|
}).extend({notify: 'always'});
|
||||||
|
|
||||||
this.contactsType.subscribe(function() {
|
this.contactsType.subscribe(() => {
|
||||||
this.testContactsSuccess(false);
|
this.testContactsSuccess(false);
|
||||||
this.testContactsError(false);
|
this.testContactsError(false);
|
||||||
this.testContactsErrorMessage('');
|
this.testContactsErrorMessage('');
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.pdoDsn = ko.observable(settingsGet('ContactsPdoDsn'));
|
this.pdoDsn = ko.observable(settingsGet('ContactsPdoDsn'));
|
||||||
this.pdoUser = ko.observable(settingsGet('ContactsPdoUser'));
|
this.pdoUser = ko.observable(settingsGet('ContactsPdoUser'));
|
||||||
|
|
@ -111,7 +111,7 @@ class ContactsAdminSettings
|
||||||
this.testContactsError = ko.observable(false);
|
this.testContactsError = ko.observable(false);
|
||||||
this.testContactsErrorMessage = ko.observable('');
|
this.testContactsErrorMessage = ko.observable('');
|
||||||
|
|
||||||
this.testContactsCommand = createCommand(this, () => {
|
this.testContactsCommand = createCommand(() => {
|
||||||
|
|
||||||
this.testContactsSuccess(false);
|
this.testContactsSuccess(false);
|
||||||
this.testContactsError(false);
|
this.testContactsError(false);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import {showScreenPopup} from 'Knoin/Knoin';
|
||||||
import DomainStore from 'Stores/Admin/Domain';
|
import DomainStore from 'Stores/Admin/Domain';
|
||||||
import Remote from 'Remote/Admin/Ajax';
|
import Remote from 'Remote/Admin/Ajax';
|
||||||
|
|
||||||
|
import {getApp} from 'Helper/Apps/Admin';
|
||||||
|
|
||||||
class DomainsAdminSettings
|
class DomainsAdminSettings
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -42,15 +44,15 @@ class DomainsAdminSettings
|
||||||
onBuild(oDom) {
|
onBuild(oDom) {
|
||||||
const self = this;
|
const self = this;
|
||||||
oDom
|
oDom
|
||||||
.on('click', '.b-admin-domains-list-table .e-item .e-action', function() {
|
.on('click', '.b-admin-domains-list-table .e-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||||
const domainItem = ko.dataFor(this);
|
const domainItem = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||||
if (domainItem)
|
if (domainItem)
|
||||||
{
|
{
|
||||||
Remote.domain(self.onDomainLoadRequest, domainItem.name);
|
Remote.domain(self.onDomainLoadRequest, domainItem.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
require('App/Admin').default.reloadDomainList();
|
getApp().reloadDomainList();
|
||||||
}
|
}
|
||||||
|
|
||||||
onDomainLoadRequest(sResult, oData) {
|
onDomainLoadRequest(sResult, oData) {
|
||||||
|
|
@ -61,7 +63,7 @@ class DomainsAdminSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
onDomainListChangeRequest() {
|
onDomainListChangeRequest() {
|
||||||
require('App/Admin').default.reloadDomainList();
|
getApp().reloadDomainList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,16 @@ import ko from 'ko';
|
||||||
import {settingsSaveHelperSimpleFunction, boolToAjax, trim} from 'Common/Utils';
|
import {settingsSaveHelperSimpleFunction, boolToAjax, trim} from 'Common/Utils';
|
||||||
import {settingsGet} from 'Storage/Settings';
|
import {settingsGet} from 'Storage/Settings';
|
||||||
|
|
||||||
import AppAdminStore from 'Stores/Admin/App';
|
import AppStore from 'Stores/Admin/App';
|
||||||
|
|
||||||
class LoginAdminSettings
|
class LoginAdminSettings
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
this.determineUserLanguage = AppAdminStore.determineUserLanguage;
|
this.determineUserLanguage = AppStore.determineUserLanguage;
|
||||||
this.determineUserDomain = AppAdminStore.determineUserDomain;
|
this.determineUserDomain = AppStore.determineUserDomain;
|
||||||
|
|
||||||
this.defaultDomain = ko.observable(settingsGet('LoginDefaultDomain')).idleTrigger();
|
this.defaultDomain = ko.observable(settingsGet('LoginDefaultDomain')).idleTrigger();
|
||||||
this.allowLanguagesOnLogin = AppAdminStore.allowLanguagesOnLogin;
|
this.allowLanguagesOnLogin = AppStore.allowLanguagesOnLogin;
|
||||||
|
|
||||||
this.dummy = ko.observable(false);
|
this.dummy = ko.observable(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import {getNotification} from 'Common/Translator';
|
||||||
import PackageStore from 'Stores/Admin/Package';
|
import PackageStore from 'Stores/Admin/Package';
|
||||||
import Remote from 'Remote/Admin/Ajax';
|
import Remote from 'Remote/Admin/Ajax';
|
||||||
|
|
||||||
|
import {getApp} from 'Helper/Apps/Admin';
|
||||||
|
|
||||||
class PackagesAdminSettings
|
class PackagesAdminSettings
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -30,7 +32,7 @@ class PackagesAdminSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
onBuild() {
|
onBuild() {
|
||||||
require('App/Admin').default.reloadPackagesList();
|
getApp().reloadPackagesList();
|
||||||
}
|
}
|
||||||
|
|
||||||
requestHelper(packageToRequest, install) {
|
requestHelper(packageToRequest, install) {
|
||||||
|
|
@ -63,7 +65,7 @@ class PackagesAdminSettings
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
require('App/Admin').default.reloadPackagesList();
|
getApp().reloadPackagesList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
/* global RL_COMMUNITY */
|
||||||
|
|
||||||
import _ from '_';
|
import _ from '_';
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
|
|
@ -14,6 +16,8 @@ import PluginStore from 'Stores/Admin/Plugin';
|
||||||
|
|
||||||
import Remote from 'Remote/Admin/Ajax';
|
import Remote from 'Remote/Admin/Ajax';
|
||||||
|
|
||||||
|
import {getApp} from 'Helper/Apps/Admin';
|
||||||
|
|
||||||
class PluginsAdminSettings
|
class PluginsAdminSettings
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -40,17 +44,19 @@ class PluginsAdminSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
onBuild(oDom) {
|
onBuild(oDom) {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
oDom
|
oDom
|
||||||
.on('click', '.e-item .configure-plugin-action', function() {
|
.on('click', '.e-item .configure-plugin-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||||
const plugin = ko.dataFor(this);
|
const plugin = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||||
if (plugin)
|
if (plugin)
|
||||||
{
|
{
|
||||||
self.configurePlugin(plugin);
|
self.configurePlugin(plugin);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on('click', '.e-item .disabled-plugin', function() {
|
.on('click', '.e-item .disabled-plugin', function() { // eslint-disable-line prefer-arrow-callback
|
||||||
const plugin = ko.dataFor(this);
|
const plugin = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||||
if (plugin)
|
if (plugin)
|
||||||
{
|
{
|
||||||
self.disablePlugin(plugin);
|
self.disablePlugin(plugin);
|
||||||
|
|
@ -66,7 +72,7 @@ class PluginsAdminSettings
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
PluginStore.plugins.error('');
|
PluginStore.plugins.error('');
|
||||||
require('App/Admin').default.reloadPluginList();
|
getApp().reloadPluginList();
|
||||||
}
|
}
|
||||||
|
|
||||||
onPluginLoadRequest(result, data) {
|
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.adminPasswordNewError(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.saveNewAdminPasswordCommand = createCommand(this, () => {
|
this.saveNewAdminPasswordCommand = createCommand(() => {
|
||||||
|
|
||||||
if ('' === trim(this.adminLogin()))
|
if ('' === trim(this.adminLogin()))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,14 @@ import {root} from 'Common/Links';
|
||||||
|
|
||||||
import {capa} from 'Storage/Settings';
|
import {capa} from 'Storage/Settings';
|
||||||
|
|
||||||
import {showScreenPopup, routeOff, setHash} from 'Knoin/Knoin';
|
|
||||||
|
|
||||||
import AccountStore from 'Stores/User/Account';
|
import AccountStore from 'Stores/User/Account';
|
||||||
import IdentityStore from 'Stores/User/Identity';
|
import IdentityStore from 'Stores/User/Identity';
|
||||||
import Remote from 'Remote/User/Ajax';
|
import Remote from 'Remote/User/Ajax';
|
||||||
|
|
||||||
|
import {getApp} from 'Helper/Apps/User';
|
||||||
|
|
||||||
|
import {showScreenPopup, routeOff, setHash} from 'Knoin/Knoin';
|
||||||
|
|
||||||
class AccountsUserSettings
|
class AccountsUserSettings
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -66,7 +68,7 @@ class AccountsUserSettings
|
||||||
{
|
{
|
||||||
this.accounts.remove((account) => accountToRemove === account);
|
this.accounts.remove((account) => accountToRemove === account);
|
||||||
|
|
||||||
Remote.accountDelete(function(result, data) {
|
Remote.accountDelete((result, data) => {
|
||||||
|
|
||||||
if (StorageResultType.Success === result && data && data.Result && data.Reload)
|
if (StorageResultType.Success === result && data && data.Result && data.Reload)
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +80,7 @@ class AccountsUserSettings
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
require('App/User').default.accountsAndIdentities();
|
getApp().accountsAndIdentities();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, accountToRemove.email);
|
}, accountToRemove.email);
|
||||||
|
|
@ -100,7 +102,7 @@ class AccountsUserSettings
|
||||||
IdentityStore.identities.remove((oIdentity) => identityToRemove === oIdentity);
|
IdentityStore.identities.remove((oIdentity) => identityToRemove === oIdentity);
|
||||||
|
|
||||||
Remote.identityDelete(() => {
|
Remote.identityDelete(() => {
|
||||||
require('App/User').default.accountsAndIdentities();
|
getApp().accountsAndIdentities();
|
||||||
}, identityToRemove.id);
|
}, identityToRemove.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,18 +114,19 @@ class AccountsUserSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
onBuild(oDom) {
|
onBuild(oDom) {
|
||||||
var self = this;
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
oDom
|
oDom
|
||||||
.on('click', '.accounts-list .account-item .e-action', function() {
|
.on('click', '.accounts-list .account-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||||
const account = ko.dataFor(this);
|
const account = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||||
if (account)
|
if (account)
|
||||||
{
|
{
|
||||||
self.editAccount(account);
|
self.editAccount(account);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on('click', '.identities-list .identity-item .e-action', function() {
|
.on('click', '.identities-list .identity-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||||
const identity = ko.dataFor(this);
|
const identity = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||||
if (identity)
|
if (identity)
|
||||||
{
|
{
|
||||||
self.editIdentity(identity);
|
self.editIdentity(identity);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import {getNotificationFromResponse, i18n} from 'Common/Translator';
|
||||||
|
|
||||||
import Remote from 'Remote/User/Ajax';
|
import Remote from 'Remote/User/Ajax';
|
||||||
|
|
||||||
|
import {getApp} from 'Helper/Apps/User';
|
||||||
|
|
||||||
class ChangePasswordUserSettings
|
class ChangePasswordUserSettings
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -41,7 +43,7 @@ class ChangePasswordUserSettings
|
||||||
this.passwordMismatch(false);
|
this.passwordMismatch(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.saveNewPasswordCommand = createCommand(this, () => {
|
this.saveNewPasswordCommand = createCommand(() => {
|
||||||
if (this.newPassword() !== this.newPassword2())
|
if (this.newPassword() !== this.newPassword2())
|
||||||
{
|
{
|
||||||
this.passwordMismatch(true);
|
this.passwordMismatch(true);
|
||||||
|
|
@ -90,7 +92,7 @@ class ChangePasswordUserSettings
|
||||||
this.passwordUpdateSuccess(true);
|
this.passwordUpdateSuccess(true);
|
||||||
this.currentPassword.error(false);
|
this.currentPassword.error(false);
|
||||||
|
|
||||||
require('App/User').default.setClientSideToken(data.Result);
|
getApp().setClientSideToken(data.Result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class FiltersUserSettings
|
||||||
this.filterForDeletion = ko.observable(null)
|
this.filterForDeletion = ko.observable(null)
|
||||||
.extend({falseTimeout: 3000}).extend({toggleSubscribeProperty: [this, 'deleteAccess']});
|
.extend({falseTimeout: 3000}).extend({toggleSubscribeProperty: [this, 'deleteAccess']});
|
||||||
|
|
||||||
this.saveChanges = createCommand(this, () => {
|
this.saveChanges = createCommand(() => {
|
||||||
if (!this.filters.saving())
|
if (!this.filters.saving())
|
||||||
{
|
{
|
||||||
if (this.filterRaw.active() && '' === trim(this.filterRaw()))
|
if (this.filterRaw.active() && '' === trim(this.filterRaw()))
|
||||||
|
|
@ -187,11 +187,12 @@ class FiltersUserSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
onBuild(oDom) {
|
onBuild(oDom) {
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
oDom
|
oDom
|
||||||
.on('click', '.filter-item .e-action', function() {
|
.on('click', '.filter-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||||
const filter = ko.dataFor(this);
|
const filter = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||||
if (filter)
|
if (filter)
|
||||||
{
|
{
|
||||||
self.editFilter(filter);
|
self.editFilter(filter);
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,15 @@ import {removeFolderFromCacheList} from 'Common/Cache';
|
||||||
import {appSettingsGet} from 'Storage/Settings';
|
import {appSettingsGet} from 'Storage/Settings';
|
||||||
import * as Local from 'Storage/Client';
|
import * as Local from 'Storage/Client';
|
||||||
|
|
||||||
import {showScreenPopup} from 'Knoin/Knoin';
|
|
||||||
|
|
||||||
import FolderStore from 'Stores/User/Folder';
|
import FolderStore from 'Stores/User/Folder';
|
||||||
|
|
||||||
import Promises from 'Promises/User/Ajax';
|
import Promises from 'Promises/User/Ajax';
|
||||||
import Remote from 'Remote/User/Ajax';
|
import Remote from 'Remote/User/Ajax';
|
||||||
|
|
||||||
|
import {getApp} from 'Helper/Apps/User';
|
||||||
|
|
||||||
|
import {showScreenPopup} from 'Knoin/Knoin';
|
||||||
|
|
||||||
class FoldersUserSettings
|
class FoldersUserSettings
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -61,7 +63,7 @@ class FoldersUserSettings
|
||||||
{
|
{
|
||||||
Local.set(ClientSideKeyName.FoldersLashHash, '');
|
Local.set(ClientSideKeyName.FoldersLashHash, '');
|
||||||
|
|
||||||
require('App/User').default.foldersPromisesActionHelper(
|
getApp().foldersPromisesActionHelper(
|
||||||
Promises.folderRename(folder.fullNameRaw, nameToEdit, FolderStore.foldersRenaming),
|
Promises.folderRename(folder.fullNameRaw, nameToEdit, FolderStore.foldersRenaming),
|
||||||
Notification.CantRenameFolder
|
Notification.CantRenameFolder
|
||||||
);
|
);
|
||||||
|
|
@ -131,7 +133,7 @@ class FoldersUserSettings
|
||||||
|
|
||||||
FolderStore.folderList.remove(fRemoveFolder);
|
FolderStore.folderList.remove(fRemoveFolder);
|
||||||
|
|
||||||
require('App/User').default.foldersPromisesActionHelper(
|
getApp().foldersPromisesActionHelper(
|
||||||
Promises.folderDelete(folderToRemove.fullNameRaw, FolderStore.foldersDeleting),
|
Promises.folderDelete(folderToRemove.fullNameRaw, FolderStore.foldersDeleting),
|
||||||
Notification.CantDeleteFolder
|
Notification.CantDeleteFolder
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ class GeneralUserSettings
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.layout.subscribe(function(value) {
|
this.layout.subscribe((value) => {
|
||||||
MessageStore.messageList([]);
|
MessageStore.messageList([]);
|
||||||
Remote.saveSettings(f2, {
|
Remote.saveSettings(f2, {
|
||||||
'Layout': value
|
'Layout': value
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,12 @@ import ko from 'ko';
|
||||||
import {delegateRunOnDestroy} from 'Common/Utils';
|
import {delegateRunOnDestroy} from 'Common/Utils';
|
||||||
import {bIsHttps} from 'Common/Globals';
|
import {bIsHttps} from 'Common/Globals';
|
||||||
|
|
||||||
import {showScreenPopup} from 'Knoin/Knoin';
|
|
||||||
|
|
||||||
import PgpStore from 'Stores/User/Pgp';
|
import PgpStore from 'Stores/User/Pgp';
|
||||||
|
|
||||||
|
import {getApp} from 'Helper/Apps/User';
|
||||||
|
|
||||||
|
import {showScreenPopup} from 'Knoin/Knoin';
|
||||||
|
|
||||||
class OpenPgpUserSettings
|
class OpenPgpUserSettings
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -60,7 +62,7 @@ class OpenPgpUserSettings
|
||||||
PgpStore.openpgpKeyring.store();
|
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 SocialStore from 'Stores/Social';
|
||||||
|
|
||||||
|
import {getApp} from 'Helper/Apps/User';
|
||||||
|
|
||||||
class SocialUserSettings
|
class SocialUserSettings
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -28,43 +30,39 @@ class SocialUserSettings
|
||||||
this.twitterLoggined = SocialStore.twitter.loggined;
|
this.twitterLoggined = SocialStore.twitter.loggined;
|
||||||
this.twitterUserName = SocialStore.twitter.userName;
|
this.twitterUserName = SocialStore.twitter.userName;
|
||||||
|
|
||||||
this.connectGoogle = createCommand(this, () => {
|
this.connectGoogle = createCommand(() => {
|
||||||
if (!this.googleLoggined())
|
if (!this.googleLoggined())
|
||||||
{
|
{
|
||||||
this.getApp().googleConnect();
|
getApp().googleConnect();
|
||||||
}
|
}
|
||||||
}, () => !this.googleLoggined() && !this.googleActions());
|
}, () => !this.googleLoggined() && !this.googleActions());
|
||||||
|
|
||||||
this.disconnectGoogle = createCommand(this, () => {
|
this.disconnectGoogle = createCommand(() => {
|
||||||
this.getApp().googleDisconnect();
|
getApp().googleDisconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.connectFacebook = createCommand(this, () => {
|
this.connectFacebook = createCommand(() => {
|
||||||
if (!this.facebookLoggined())
|
if (!this.facebookLoggined())
|
||||||
{
|
{
|
||||||
this.getApp().facebookConnect();
|
getApp().facebookConnect();
|
||||||
}
|
}
|
||||||
}, () => !this.facebookLoggined() && !this.facebookActions());
|
}, () => !this.facebookLoggined() && !this.facebookActions());
|
||||||
|
|
||||||
this.disconnectFacebook = createCommand(this, () => {
|
this.disconnectFacebook = createCommand(() => {
|
||||||
this.getApp().facebookDisconnect();
|
getApp().facebookDisconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.connectTwitter = createCommand(this, () => {
|
this.connectTwitter = createCommand(() => {
|
||||||
if (!this.twitterLoggined())
|
if (!this.twitterLoggined())
|
||||||
{
|
{
|
||||||
this.getApp().twitterConnect();
|
getApp().twitterConnect();
|
||||||
}
|
}
|
||||||
}, () => !this.twitterLoggined() && !this.twitterActions());
|
}, () => !this.twitterLoggined() && !this.twitterActions());
|
||||||
|
|
||||||
this.disconnectTwitter = createCommand(this, () => {
|
this.disconnectTwitter = createCommand(() => {
|
||||||
this.getApp().twitterDisconnect();
|
getApp().twitterDisconnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getApp() {
|
|
||||||
return require('App/User').default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export {SocialUserSettings, SocialUserSettings as default};
|
export {SocialUserSettings, SocialUserSettings as default};
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,13 @@ import ko from 'ko';
|
||||||
|
|
||||||
import {i18n} from 'Common/Translator';
|
import {i18n} from 'Common/Translator';
|
||||||
|
|
||||||
import {showScreenPopup} from 'Knoin/Knoin';
|
|
||||||
|
|
||||||
import TemplateStore from 'Stores/User/Template';
|
import TemplateStore from 'Stores/User/Template';
|
||||||
import Remote from 'Remote/User/Ajax';
|
import Remote from 'Remote/User/Ajax';
|
||||||
|
|
||||||
|
import {getApp} from 'Helper/Apps/User';
|
||||||
|
|
||||||
|
import {showScreenPopup} from 'Knoin/Knoin';
|
||||||
|
|
||||||
class TemplatesUserSettings
|
class TemplatesUserSettings
|
||||||
{
|
{
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -55,19 +57,16 @@ class TemplatesUserSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadTemplates() {
|
reloadTemplates() {
|
||||||
this.getApp().templates();
|
getApp().templates();
|
||||||
}
|
|
||||||
|
|
||||||
getApp() {
|
|
||||||
return require('App/User').default;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onBuild(oDom) {
|
onBuild(oDom) {
|
||||||
var self = this;
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
oDom
|
oDom
|
||||||
.on('click', '.templates-list .template-item .e-action', function() {
|
.on('click', '.templates-list .template-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||||
const template = ko.dataFor(this);
|
const template = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||||
if (template)
|
if (template)
|
||||||
{
|
{
|
||||||
self.editTemplate(template);
|
self.editTemplate(template);
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ class AbstractAppStore
|
||||||
|
|
||||||
this.interfaceAnimation = ko.observable(true);
|
this.interfaceAnimation = ko.observable(true);
|
||||||
|
|
||||||
this.interfaceAnimation.subscribe(function(bValue) {
|
this.interfaceAnimation.subscribe((value) => {
|
||||||
const bAnim = bMobileDevice || !bValue;
|
const anim = bMobileDevice || !value;
|
||||||
$html.toggleClass('rl-anim', !bAnim).toggleClass('no-rl-anim', bAnim);
|
$html.toggleClass('rl-anim', !anim).toggleClass('no-rl-anim', anim);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.interfaceAnimation.valueHasMutated();
|
this.interfaceAnimation.valueHasMutated();
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,11 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
import {Capa} from 'Common/Enums';
|
||||||
|
import * as Settings from 'Storage/Settings';
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
class CapaAdminStore
|
||||||
|
|
||||||
Settings = require('Storage/Settings');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function CapaAdminStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.additionalAccounts = ko.observable(false);
|
this.additionalAccounts = ko.observable(false);
|
||||||
this.identities = ko.observable(false);
|
this.identities = ko.observable(false);
|
||||||
this.gravatar = ko.observable(false);
|
this.gravatar = ko.observable(false);
|
||||||
|
|
@ -25,20 +20,20 @@ function CapaAdminStore()
|
||||||
this.templates = ko.observable(false);
|
this.templates = ko.observable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
CapaAdminStore.prototype.populate = function()
|
populate() {
|
||||||
{
|
this.additionalAccounts(Settings.capa(Capa.AdditionalAccounts));
|
||||||
this.additionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts));
|
this.identities(Settings.capa(Capa.Identities));
|
||||||
this.identities(Settings.capa(Enums.Capa.Identities));
|
this.gravatar(Settings.capa(Capa.Gravatar));
|
||||||
this.gravatar(Settings.capa(Enums.Capa.Gravatar));
|
this.attachmentThumbnails(Settings.capa(Capa.AttachmentThumbnails));
|
||||||
this.attachmentThumbnails(Settings.capa(Enums.Capa.AttachmentThumbnails));
|
this.sieve(Settings.capa(Capa.Sieve));
|
||||||
this.sieve(Settings.capa(Enums.Capa.Sieve));
|
this.filters(Settings.capa(Capa.Filters));
|
||||||
this.filters(Settings.capa(Enums.Capa.Filters));
|
this.themes(Settings.capa(Capa.Themes));
|
||||||
this.themes(Settings.capa(Enums.Capa.Themes));
|
this.userBackground(Settings.capa(Capa.UserBackground));
|
||||||
this.userBackground(Settings.capa(Enums.Capa.UserBackground));
|
this.openPGP(Settings.capa(Capa.OpenPGP));
|
||||||
this.openPGP(Settings.capa(Enums.Capa.OpenPGP));
|
this.twoFactorAuth(Settings.capa(Capa.TwoFactor));
|
||||||
this.twoFactorAuth(Settings.capa(Enums.Capa.TwoFactor));
|
this.twoFactorAuthForce(Settings.capa(Capa.TwoFactorForce));
|
||||||
this.twoFactorAuthForce(Settings.capa(Enums.Capa.TwoFactorForce));
|
this.templates(Settings.capa(Capa.Templates));
|
||||||
this.templates(Settings.capa(Enums.Capa.Templates));
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = new CapaAdminStore();
|
module.exports = new CapaAdminStore();
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,22 @@
|
||||||
|
|
||||||
var ko = require('ko');
|
import ko from 'ko';
|
||||||
|
|
||||||
/**
|
class CoreAdminStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function CoreAdminStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.coreReal = ko.observable(true);
|
this.coreReal = ko.observable(true);
|
||||||
this.coreChannel = ko.observable('stable');
|
this.coreChannel = ko.observable('stable');
|
||||||
this.coreType = ko.observable('stable');
|
this.coreType = ko.observable('stable');
|
||||||
this.coreUpdatable = ko.observable(true);
|
this.coreUpdatable = ko.observable(true);
|
||||||
this.coreAccess = ko.observable(true);
|
this.coreAccess = ko.observable(true);
|
||||||
this.coreWarning = ko.observable(false);
|
this.coreWarning = ko.observable(false);
|
||||||
this.coreChecking = ko.observable(false).extend({'throttle': 100});
|
this.coreChecking = ko.observable(false).extend({throttle: 100});
|
||||||
this.coreUpdating = ko.observable(false).extend({'throttle': 100});
|
this.coreUpdating = ko.observable(false).extend({throttle: 100});
|
||||||
this.coreVersion = ko.observable('');
|
this.coreVersion = ko.observable('');
|
||||||
this.coreRemoteVersion = ko.observable('');
|
this.coreRemoteVersion = ko.observable('');
|
||||||
this.coreRemoteRelease = ko.observable('');
|
this.coreRemoteRelease = ko.observable('');
|
||||||
this.coreVersionCompare = ko.observable(-2);
|
this.coreVersionCompare = ko.observable(-2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new CoreAdminStore();
|
module.exports = new CoreAdminStore();
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
|
|
||||||
var ko = require('ko');
|
import ko from 'ko';
|
||||||
|
|
||||||
/**
|
class DomainAdminStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function DomainAdminStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.domains = ko.observableArray([]);
|
this.domains = ko.observableArray([]);
|
||||||
this.domains.loading = ko.observable(false).extend({'throttle': 100});
|
this.domains.loading = ko.observable(false).extend({'throttle': 100});
|
||||||
|
this.domainsWithoutAliases = this.domains.filter((item) => item && !item.alias);
|
||||||
this.domainsWithoutAliases = this.domains.filter(function(oItem) {
|
}
|
||||||
return oItem && !oItem.alias;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new DomainAdminStore();
|
module.exports = new DomainAdminStore();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
|
|
||||||
var ko = require('ko');
|
import ko from 'ko';
|
||||||
|
|
||||||
/**
|
class LicenseAdminStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function LicenseAdminStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.licensing = ko.observable(false);
|
this.licensing = ko.observable(false);
|
||||||
this.licensingProcess = ko.observable(false);
|
this.licensingProcess = ko.observable(false);
|
||||||
this.licenseValid = ko.observable(false);
|
this.licenseValid = ko.observable(false);
|
||||||
|
|
@ -14,5 +12,6 @@ function LicenseAdminStore()
|
||||||
|
|
||||||
this.licenseTrigger = ko.observable(false);
|
this.licenseTrigger = ko.observable(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new LicenseAdminStore();
|
module.exports = new LicenseAdminStore();
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
|
|
||||||
var ko = require('ko');
|
import ko from 'ko';
|
||||||
|
|
||||||
/**
|
class PackageAdminStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function PackageAdminStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.packages = ko.observableArray([]);
|
this.packages = ko.observableArray([]);
|
||||||
this.packages.loading = ko.observable(false).extend({'throttle': 100});
|
this.packages.loading = ko.observable(false).extend({throttle: 100});
|
||||||
|
|
||||||
this.packagesReal = ko.observable(true);
|
this.packagesReal = ko.observable(true);
|
||||||
this.packagesMainUpdatable = ko.observable(true);
|
this.packagesMainUpdatable = ko.observable(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new PackageAdminStore();
|
module.exports = new PackageAdminStore();
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
|
|
||||||
var ko = require('ko');
|
import ko from 'ko';
|
||||||
|
|
||||||
/**
|
class PluginAdminStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function PluginAdminStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.plugins = ko.observableArray([]);
|
this.plugins = ko.observableArray([]);
|
||||||
this.plugins.loading = ko.observable(false).extend({'throttle': 100});
|
this.plugins.loading = ko.observable(false).extend({throttle: 100});
|
||||||
this.plugins.error = ko.observable('');
|
this.plugins.error = ko.observable('');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new PluginAdminStore();
|
module.exports = new PluginAdminStore();
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,40 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
import {isArray} from 'Common/Utils';
|
||||||
|
import * as Settings from 'Storage/Settings';
|
||||||
|
|
||||||
Utils = require('Common/Utils'),
|
class LanguageStore
|
||||||
|
|
||||||
Settings = require('Storage/Settings');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function LanguageStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.languages = ko.observableArray([]);
|
this.languages = ko.observableArray([]);
|
||||||
this.languagesAdmin = ko.observableArray([]);
|
this.languagesAdmin = ko.observableArray([]);
|
||||||
|
|
||||||
this.language = ko.observable('')
|
this.language = ko.observable('')
|
||||||
.extend({'limitedList': this.languages})
|
.extend({limitedList: this.languages})
|
||||||
.extend({'reversible': true});
|
.extend({reversible: true});
|
||||||
|
|
||||||
this.languageAdmin = ko.observable('')
|
this.languageAdmin = ko.observable('')
|
||||||
.extend({'limitedList': this.languagesAdmin})
|
.extend({limitedList: this.languagesAdmin})
|
||||||
.extend({'reversible': true});
|
.extend({reversible: true});
|
||||||
|
|
||||||
this.userLanguage = ko.observable('');
|
this.userLanguage = ko.observable('');
|
||||||
this.userLanguageAdmin = ko.observable('');
|
this.userLanguageAdmin = ko.observable('');
|
||||||
}
|
}
|
||||||
|
|
||||||
LanguageStore.prototype.populate = function()
|
populate() {
|
||||||
{
|
const
|
||||||
var
|
|
||||||
aLanguages = Settings.appSettingsGet('languages'),
|
aLanguages = Settings.appSettingsGet('languages'),
|
||||||
aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin');
|
aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin');
|
||||||
|
|
||||||
this.languages(Utils.isArray(aLanguages) ? aLanguages : []);
|
this.languages(isArray(aLanguages) ? aLanguages : []);
|
||||||
this.languagesAdmin(Utils.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
|
this.languagesAdmin(isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
|
||||||
|
|
||||||
this.language(Settings.settingsGet('Language'));
|
this.language(Settings.settingsGet('Language'));
|
||||||
this.languageAdmin(Settings.settingsGet('LanguageAdmin'));
|
this.languageAdmin(Settings.settingsGet('LanguageAdmin'));
|
||||||
|
|
||||||
this.userLanguage(Settings.settingsGet('UserLanguage'));
|
this.userLanguage(Settings.settingsGet('UserLanguage'));
|
||||||
this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin'));
|
this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin'));
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new LanguageStore();
|
module.exports = new LanguageStore();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
|
|
||||||
var ko = require('ko');
|
import window from 'window';
|
||||||
|
import ko from 'ko';
|
||||||
|
import $ from '$';
|
||||||
|
import * as Settings from 'Storage/Settings';
|
||||||
|
|
||||||
/**
|
class SocialStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function SocialStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.google = {};
|
this.google = {};
|
||||||
this.twitter = {};
|
this.twitter = {};
|
||||||
this.facebook = {};
|
this.facebook = {};
|
||||||
|
|
@ -21,9 +22,7 @@ function SocialStore()
|
||||||
this.google.loading = ko.observable(false);
|
this.google.loading = ko.observable(false);
|
||||||
this.google.userName = ko.observable('');
|
this.google.userName = ko.observable('');
|
||||||
|
|
||||||
this.google.loggined = ko.computed(function() {
|
this.google.loggined = ko.computed(() => '' !== this.google.userName());
|
||||||
return '' !== this.google.userName();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.google.capa = {};
|
this.google.capa = {};
|
||||||
this.google.capa.auth = ko.observable(false);
|
this.google.capa.auth = ko.observable(false);
|
||||||
|
|
@ -32,13 +31,10 @@ function SocialStore()
|
||||||
this.google.capa.preview = ko.observable(false);
|
this.google.capa.preview = ko.observable(false);
|
||||||
|
|
||||||
this.google.require = {};
|
this.google.require = {};
|
||||||
this.google.require.clientSettings = ko.computed(function() {
|
this.google.require.clientSettings = ko.computed(
|
||||||
return this.google.enabled() && (this.google.capa.auth() || this.google.capa.drive());
|
() => this.google.enabled() && (this.google.capa.auth() || this.google.capa.drive()));
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.google.require.apiKeySettings = ko.computed(function() {
|
this.google.require.apiKeySettings = ko.computed(() => this.google.enabled() && this.google.capa.drive());
|
||||||
return this.google.enabled() && this.google.capa.drive();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
// Facebook
|
// Facebook
|
||||||
this.facebook.enabled = ko.observable(false);
|
this.facebook.enabled = ko.observable(false);
|
||||||
|
|
@ -48,9 +44,7 @@ function SocialStore()
|
||||||
this.facebook.userName = ko.observable('');
|
this.facebook.userName = ko.observable('');
|
||||||
this.facebook.supported = ko.observable(false);
|
this.facebook.supported = ko.observable(false);
|
||||||
|
|
||||||
this.facebook.loggined = ko.computed(function() {
|
this.facebook.loggined = ko.computed(() => '' !== this.facebook.userName());
|
||||||
return '' !== this.facebook.userName();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
// Twitter
|
// Twitter
|
||||||
this.twitter.enabled = ko.observable(false);
|
this.twitter.enabled = ko.observable(false);
|
||||||
|
|
@ -59,24 +53,14 @@ function SocialStore()
|
||||||
this.twitter.loading = ko.observable(false);
|
this.twitter.loading = ko.observable(false);
|
||||||
this.twitter.userName = ko.observable('');
|
this.twitter.userName = ko.observable('');
|
||||||
|
|
||||||
this.twitter.loggined = ko.computed(function() {
|
this.twitter.loggined = ko.computed(() => '' !== this.twitter.userName());
|
||||||
return '' !== this.twitter.userName();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
// Dropbox
|
// Dropbox
|
||||||
this.dropbox.enabled = ko.observable(false);
|
this.dropbox.enabled = ko.observable(false);
|
||||||
this.dropbox.apiKey = ko.observable('');
|
this.dropbox.apiKey = ko.observable('');
|
||||||
}
|
}
|
||||||
|
|
||||||
SocialStore.prototype.google = {};
|
populate() {
|
||||||
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.enabled(!!Settings.settingsGet('AllowGoogleSocial'));
|
||||||
this.google.clientID(Settings.settingsGet('GoogleClientID'));
|
this.google.clientID(Settings.settingsGet('GoogleClientID'));
|
||||||
this.google.clientSecret(Settings.settingsGet('GoogleClientSecret'));
|
this.google.clientSecret(Settings.settingsGet('GoogleClientSecret'));
|
||||||
|
|
@ -98,6 +82,22 @@ SocialStore.prototype.populate = function()
|
||||||
|
|
||||||
this.dropbox.enabled(!!Settings.settingsGet('AllowDropboxSocial'));
|
this.dropbox.enabled(!!Settings.settingsGet('AllowDropboxSocial'));
|
||||||
this.dropbox.apiKey(Settings.settingsGet('DropboxApiKey'));
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new SocialStore();
|
module.exports = new SocialStore();
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,26 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
import {isArray} from 'Common/Utils';
|
||||||
|
import * as Settings from 'Storage/Settings';
|
||||||
|
|
||||||
Utils = require('Common/Utils'),
|
class ThemeStore
|
||||||
|
|
||||||
Settings = require('Storage/Settings');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function ThemeStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.themes = ko.observableArray([]);
|
this.themes = ko.observableArray([]);
|
||||||
this.themeBackgroundName = ko.observable('');
|
this.themeBackgroundName = ko.observable('');
|
||||||
this.themeBackgroundHash = ko.observable('');
|
this.themeBackgroundHash = ko.observable('');
|
||||||
|
|
||||||
this.theme = ko.observable('')
|
this.theme = ko.observable('').extend({limitedList: this.themes});
|
||||||
.extend({'limitedList': this.themes});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeStore.prototype.populate = function()
|
populate() {
|
||||||
{
|
const themes = Settings.appSettingsGet('themes');
|
||||||
var aThemes = Settings.appSettingsGet('themes');
|
|
||||||
|
|
||||||
this.themes(Utils.isArray(aThemes) ? aThemes : []);
|
this.themes(isArray(themes) ? themes : []);
|
||||||
this.theme(Settings.settingsGet('Theme'));
|
this.theme(Settings.settingsGet('Theme'));
|
||||||
this.themeBackgroundName(Settings.settingsGet('UserBackgroundName'));
|
this.themeBackgroundName(Settings.settingsGet('UserBackgroundName'));
|
||||||
this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash'));
|
this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash'));
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new ThemeStore();
|
module.exports = new ThemeStore();
|
||||||
|
|
|
||||||
|
|
@ -1,64 +1,50 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
_ = require('_'),
|
import _ from '_';
|
||||||
ko = require('ko'),
|
import * as Settings from 'Storage/Settings';
|
||||||
|
|
||||||
Settings = require('Storage/Settings');
|
class AccountUserStore
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function AccountUserStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.email = ko.observable('');
|
this.email = ko.observable('');
|
||||||
this.parentEmail = ko.observable('');
|
this.parentEmail = ko.observable('');
|
||||||
// this.incLogin = ko.observable('');
|
|
||||||
// this.outLogin = ko.observable('');
|
|
||||||
|
|
||||||
this.signature = ko.observable('');
|
this.signature = ko.observable('');
|
||||||
|
|
||||||
this.accounts = ko.observableArray([]);
|
this.accounts = ko.observableArray([]);
|
||||||
this.accounts.loading = ko.observable(false).extend({'throttle': 100});
|
this.accounts.loading = ko.observable(false).extend({throttle: 100});
|
||||||
|
|
||||||
this.computers();
|
this.computers();
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountUserStore.prototype.computers = function()
|
computers() {
|
||||||
{
|
this.accountsEmails = ko.computed(
|
||||||
this.accountsEmails = ko.computed(function() {
|
() => _.compact(_.map(this.accounts(), (item) => (item ? item.email : null))));
|
||||||
return _.compact(_.map(this.accounts(), function(oItem) {
|
|
||||||
return oItem ? oItem.email : null;
|
|
||||||
}));
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.accountsUnreadCount = ko.computed(function() {
|
this.accountsUnreadCount = ko.computed(() => 0);
|
||||||
|
// this.accountsUnreadCount = ko.computed(() => {
|
||||||
var iResult = 0;
|
// let result = 0;
|
||||||
|
// _.each(this.accounts(), (item) => {
|
||||||
// _.each(this.accounts(), function(oItem) {
|
// if (item)
|
||||||
// if (oItem)
|
|
||||||
// {
|
// {
|
||||||
// iResult += oItem.count();
|
// result += item.count();
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
// return result;
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
return iResult;
|
populate() {
|
||||||
|
|
||||||
}, this);
|
|
||||||
};
|
|
||||||
|
|
||||||
AccountUserStore.prototype.populate = function()
|
|
||||||
{
|
|
||||||
this.email(Settings.settingsGet('Email'));
|
this.email(Settings.settingsGet('Email'));
|
||||||
this.parentEmail(Settings.settingsGet('ParentEmail'));
|
this.parentEmail(Settings.settingsGet('ParentEmail'));
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
AccountUserStore.prototype.isRootAccount = function()
|
isRootAccount() {
|
||||||
{
|
|
||||||
return '' === this.parentEmail();
|
return '' === this.parentEmail();
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new AccountUserStore();
|
module.exports = new AccountUserStore();
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@ class AppUserStore extends AbstractAppStore
|
||||||
|
|
||||||
this.focusedState = ko.observable(Focused.None);
|
this.focusedState = ko.observable(Focused.None);
|
||||||
|
|
||||||
this.focusedState.subscribe(function(value) {
|
this.focusedState.subscribe((value) => {
|
||||||
|
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
case Focused.MessageList:
|
case Focused.MessageList:
|
||||||
|
|
@ -32,8 +31,7 @@ class AppUserStore extends AbstractAppStore
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.projectHash = ko.observable('');
|
this.projectHash = ko.observable('');
|
||||||
this.threadsAllowed = ko.observable(false);
|
this.threadsAllowed = ko.observable(false);
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
import * as Settings from 'Storage/Settings';
|
||||||
|
|
||||||
Settings = require('Storage/Settings');
|
class ContactUserStore
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function ContactUserStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.contacts = ko.observableArray([]);
|
this.contacts = ko.observableArray([]);
|
||||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||||
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
|
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
|
||||||
|
|
@ -23,14 +19,14 @@ function ContactUserStore()
|
||||||
this.contactsSyncPass = ko.observable('');
|
this.contactsSyncPass = ko.observable('');
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactUserStore.prototype.populate = function()
|
populate() {
|
||||||
{
|
|
||||||
this.allowContactsSync(!!Settings.settingsGet('ContactsSyncIsAllowed'));
|
this.allowContactsSync(!!Settings.settingsGet('ContactsSyncIsAllowed'));
|
||||||
this.enableContactsSync(!!Settings.settingsGet('EnableContactsSync'));
|
this.enableContactsSync(!!Settings.settingsGet('EnableContactsSync'));
|
||||||
|
|
||||||
this.contactsSyncUrl(Settings.settingsGet('ContactsSyncUrl'));
|
this.contactsSyncUrl(Settings.settingsGet('ContactsSyncUrl'));
|
||||||
this.contactsSyncUser(Settings.settingsGet('ContactsSyncUser'));
|
this.contactsSyncUser(Settings.settingsGet('ContactsSyncUser'));
|
||||||
this.contactsSyncPass(Settings.settingsGet('ContactsSyncPassword'));
|
this.contactsSyncPass(Settings.settingsGet('ContactsSyncPassword'));
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new ContactUserStore();
|
module.exports = new ContactUserStore();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
|
|
||||||
var ko = require('ko');
|
import ko from 'ko';
|
||||||
|
|
||||||
/**
|
class FilterUserStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function FilterUserStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.capa = ko.observable('');
|
this.capa = ko.observable('');
|
||||||
this.modules = ko.observable({});
|
this.modules = ko.observable({});
|
||||||
|
|
||||||
|
|
@ -16,5 +14,6 @@ function FilterUserStore()
|
||||||
|
|
||||||
this.raw = ko.observable('');
|
this.raw = ko.observable('');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new FilterUserStore();
|
module.exports = new FilterUserStore();
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,15 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
_ = require('_'),
|
import _ from '_';
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
import {FolderType} from 'Common/Enums';
|
||||||
Consts = require('Common/Consts'),
|
import {UNUSED_OPTION_VALUE} from 'Common/Consts';
|
||||||
Utils = require('Common/Utils'),
|
import {isArray, folderListOptionsBuilder} from 'Common/Utils';
|
||||||
|
import {getFolderInboxName, getFolderFromCacheList} from 'Common/Cache';
|
||||||
|
|
||||||
Cache = require('Common/Cache');
|
class FolderUserStore
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function FolderUserStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.displaySpecSetting = ko.observable(true);
|
this.displaySpecSetting = ko.observable(true);
|
||||||
|
|
||||||
this.sentFolder = ko.observable('');
|
this.sentFolder = ko.observable('');
|
||||||
|
|
@ -37,14 +33,14 @@ function FolderUserStore()
|
||||||
|
|
||||||
this.currentFolder = ko.observable(null).extend({toggleSubscribe: [
|
this.currentFolder = ko.observable(null).extend({toggleSubscribe: [
|
||||||
null,
|
null,
|
||||||
function(oPrev) {
|
(prev) => {
|
||||||
if (oPrev) {
|
if (prev) {
|
||||||
oPrev.selected(false);
|
prev.selected(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function(oNext) {
|
(next) => {
|
||||||
if (oNext) {
|
if (next) {
|
||||||
oNext.selected(true);
|
next.selected(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]});
|
]});
|
||||||
|
|
@ -53,122 +49,104 @@ function FolderUserStore()
|
||||||
this.subscribers();
|
this.subscribers();
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderUserStore.prototype.computers = function()
|
computers() {
|
||||||
{
|
|
||||||
this.draftFolderNotEnabled = ko.computed(function() {
|
|
||||||
return '' === this.draftFolder() || Consts.UNUSED_OPTION_VALUE === this.draftFolder();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.foldersListWithSingleInboxRootFolder = ko.computed(function() {
|
this.draftFolderNotEnabled = ko.computed(
|
||||||
return !_.find(this.folderList(), function(oFolder) {
|
() => ('' === this.draftFolder() || UNUSED_OPTION_VALUE === this.draftFolder())
|
||||||
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()
|
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)
|
||||||
{
|
{
|
||||||
var
|
if ('' !== sentFolder && UNUSED_OPTION_VALUE !== sentFolder)
|
||||||
fRemoveSystemFolderType = function(observable) {
|
|
||||||
return function() {
|
|
||||||
var oFolder = Cache.getFolderFromCacheList(observable());
|
|
||||||
if (oFolder)
|
|
||||||
{
|
{
|
||||||
oFolder.type(Enums.FolderType.User);
|
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 = function(iType) {
|
fSetSystemFolderType = (type) => (value) => {
|
||||||
return function(sValue) {
|
const folder = getFolderFromCacheList(value);
|
||||||
var oFolder = Cache.getFolderFromCacheList(sValue);
|
if (folder)
|
||||||
if (oFolder)
|
|
||||||
{
|
{
|
||||||
oFolder.type(iType);
|
folder.type(type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange');
|
this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange');
|
||||||
this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange');
|
this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange');
|
||||||
|
|
@ -176,46 +154,45 @@ FolderUserStore.prototype.subscribers = function()
|
||||||
this.trashFolder.subscribe(fRemoveSystemFolderType(this.trashFolder), this, 'beforeChange');
|
this.trashFolder.subscribe(fRemoveSystemFolderType(this.trashFolder), this, 'beforeChange');
|
||||||
this.archiveFolder.subscribe(fRemoveSystemFolderType(this.archiveFolder), this, 'beforeChange');
|
this.archiveFolder.subscribe(fRemoveSystemFolderType(this.archiveFolder), this, 'beforeChange');
|
||||||
|
|
||||||
this.sentFolder.subscribe(fSetSystemFolderType(Enums.FolderType.SentItems), this);
|
this.sentFolder.subscribe(fSetSystemFolderType(FolderType.SentItems), this);
|
||||||
this.draftFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Draft), this);
|
this.draftFolder.subscribe(fSetSystemFolderType(FolderType.Draft), this);
|
||||||
this.spamFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Spam), this);
|
this.spamFolder.subscribe(fSetSystemFolderType(FolderType.Spam), this);
|
||||||
this.trashFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Trash), this);
|
this.trashFolder.subscribe(fSetSystemFolderType(FolderType.Trash), this);
|
||||||
this.archiveFolder.subscribe(fSetSystemFolderType(Enums.FolderType.Archive), this);
|
this.archiveFolder.subscribe(fSetSystemFolderType(FolderType.Archive), this);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
FolderUserStore.prototype.getNextFolderNames = function()
|
getNextFolderNames() {
|
||||||
{
|
|
||||||
var
|
const
|
||||||
aResult = [],
|
result = [],
|
||||||
iLimit = 5,
|
limit = 5,
|
||||||
iUtc = require('Common/Momentor').momentNowUnix(),
|
utc = require('Common/Momentor').momentNowUnix(),
|
||||||
iTimeout = iUtc - 60 * 5,
|
timeout = utc - 60 * 5,
|
||||||
aTimeouts = [],
|
timeouts = [],
|
||||||
sInboxFolderName = Cache.getFolderInboxName(),
|
inboxFolderName = getFolderInboxName(),
|
||||||
fSearchFunction = function(aList) {
|
fSearchFunction = (list) => {
|
||||||
_.each(aList, function(oFolder) {
|
_.each(list, (folder) => {
|
||||||
if (oFolder && sInboxFolderName !== oFolder.fullNameRaw &&
|
if (folder && inboxFolderName !== folder.fullNameRaw &&
|
||||||
oFolder.selectable && oFolder.existen &&
|
folder.selectable && folder.existen && timeout > folder.interval &&
|
||||||
iTimeout > oFolder.interval &&
|
(folder.isSystemFolder() || (folder.subScribed() && folder.checkable()))
|
||||||
(oFolder.isSystemFolder() || (oFolder.subScribed() && oFolder.checkable()))
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
aTimeouts.push([oFolder.interval, oFolder.fullNameRaw]);
|
timeouts.push([folder.interval, folder.fullNameRaw]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oFolder && 0 < oFolder.subFolders().length)
|
if (folder && 0 < folder.subFolders().length)
|
||||||
{
|
{
|
||||||
fSearchFunction(oFolder.subFolders());
|
fSearchFunction(folder.subFolders());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
fSearchFunction(this.folderList());
|
fSearchFunction(this.folderList());
|
||||||
|
|
||||||
aTimeouts.sort(function(a, b) {
|
timeouts.sort((a, b) => {
|
||||||
if (a[0] < b[0])
|
if (a[0] < b[0])
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -228,20 +205,19 @@ FolderUserStore.prototype.getNextFolderNames = function()
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
_.find(aTimeouts, function(aItem) {
|
_.find(timeouts, (aItem) => {
|
||||||
var oFolder = Cache.getFolderFromCacheList(aItem[1]);
|
const folder = getFolderFromCacheList(aItem[1]);
|
||||||
if (oFolder)
|
if (folder)
|
||||||
{
|
{
|
||||||
oFolder.interval = iUtc;
|
folder.interval = utc;
|
||||||
aResult.push(aItem[1]);
|
result.push(aItem[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return iLimit <= aResult.length;
|
return limit <= result.length;
|
||||||
});
|
});
|
||||||
|
|
||||||
aResult = _.uniq(aResult);
|
return _.uniq(result);
|
||||||
|
}
|
||||||
return aResult;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = new FolderUserStore();
|
module.exports = new FolderUserStore();
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ class IdentityUserStore
|
||||||
this.identities = ko.observableArray([]);
|
this.identities = ko.observableArray([]);
|
||||||
this.identities.loading = ko.observable(false).extend({throttle: 100});
|
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,100 +1,92 @@
|
||||||
|
|
||||||
var
|
import window from 'window';
|
||||||
window = require('window'),
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
import {DesktopNotification, Magics} from 'Common/Enums';
|
||||||
Events = require('Common/Events'),
|
import * as Events from 'Common/Events';
|
||||||
Audio = require('Common/Audio'),
|
import Audio from 'Common/Audio';
|
||||||
|
|
||||||
Settings = require('Storage/Settings');
|
import * as Settings from 'Storage/Settings';
|
||||||
|
|
||||||
/**
|
class NotificationUserStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function NotificationUserStore()
|
|
||||||
{
|
{
|
||||||
var self = this;
|
constructor() {
|
||||||
|
|
||||||
this.enableSoundNotification = ko.observable(false);
|
this.enableSoundNotification = ko.observable(false);
|
||||||
this.soundNotificationIsSupported = ko.observable(false);
|
this.soundNotificationIsSupported = ko.observable(false);
|
||||||
|
|
||||||
this.allowDesktopNotification = ko.observable(false);
|
this.allowDesktopNotification = ko.observable(false);
|
||||||
|
|
||||||
this.desktopNotificationPermissions = ko.computed(function() {
|
this.desktopNotificationPermissions = ko.computed(() => {
|
||||||
|
|
||||||
this.allowDesktopNotification();
|
this.allowDesktopNotification();
|
||||||
|
|
||||||
var
|
let result = DesktopNotification.NotSupported;
|
||||||
NotificationClass = this.notificationClass(),
|
|
||||||
iResult = Enums.DesktopNotification.NotSupported;
|
|
||||||
|
|
||||||
|
const NotificationClass = this.notificationClass();
|
||||||
if (NotificationClass && NotificationClass.permission)
|
if (NotificationClass && NotificationClass.permission)
|
||||||
{
|
{
|
||||||
switch (NotificationClass.permission.toLowerCase())
|
switch (NotificationClass.permission.toLowerCase())
|
||||||
{
|
{
|
||||||
case 'granted':
|
case 'granted':
|
||||||
iResult = Enums.DesktopNotification.Allowed;
|
result = DesktopNotification.Allowed;
|
||||||
break;
|
break;
|
||||||
case 'denied':
|
case 'denied':
|
||||||
iResult = Enums.DesktopNotification.Denied;
|
result = DesktopNotification.Denied;
|
||||||
break;
|
break;
|
||||||
case 'default':
|
case 'default':
|
||||||
iResult = Enums.DesktopNotification.NotAllowed;
|
result = DesktopNotification.NotAllowed;
|
||||||
break;
|
break;
|
||||||
// no default
|
// no default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (window.webkitNotifications && window.webkitNotifications.checkPermission)
|
else if (window.webkitNotifications && window.webkitNotifications.checkPermission)
|
||||||
{
|
{
|
||||||
iResult = window.webkitNotifications.checkPermission();
|
result = window.webkitNotifications.checkPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
return iResult;
|
return result;
|
||||||
|
|
||||||
}, this).extend({'notify': 'always'});
|
}).extend({notify: 'always'});
|
||||||
|
|
||||||
this.enableDesktopNotification = ko.computed({
|
this.enableDesktopNotification = ko.computed({
|
||||||
'owner': this,
|
read: () => this.allowDesktopNotification() && DesktopNotification.Allowed === this.desktopNotificationPermissions(),
|
||||||
'read': function() {
|
write: (value) => {
|
||||||
return this.allowDesktopNotification() &&
|
if (value)
|
||||||
Enums.DesktopNotification.Allowed === this.desktopNotificationPermissions();
|
|
||||||
},
|
|
||||||
'write': function(bValue) {
|
|
||||||
if (bValue)
|
|
||||||
{
|
{
|
||||||
var
|
const
|
||||||
NotificationClass = this.notificationClass(),
|
NotificationClass = this.notificationClass(),
|
||||||
iPermission = this.desktopNotificationPermissions();
|
permission = this.desktopNotificationPermissions();
|
||||||
|
|
||||||
if (NotificationClass && Enums.DesktopNotification.Allowed === iPermission)
|
if (NotificationClass && DesktopNotification.Allowed === permission)
|
||||||
{
|
{
|
||||||
this.allowDesktopNotification(true);
|
this.allowDesktopNotification(true);
|
||||||
}
|
}
|
||||||
else if (NotificationClass && Enums.DesktopNotification.NotAllowed === iPermission)
|
else if (NotificationClass && DesktopNotification.NotAllowed === permission)
|
||||||
{
|
{
|
||||||
NotificationClass.requestPermission(function() {
|
NotificationClass.requestPermission(() => {
|
||||||
self.allowDesktopNotification.valueHasMutated();
|
|
||||||
if (Enums.DesktopNotification.Allowed === self.desktopNotificationPermissions())
|
this.allowDesktopNotification.valueHasMutated();
|
||||||
|
|
||||||
|
if (DesktopNotification.Allowed === this.desktopNotificationPermissions())
|
||||||
{
|
{
|
||||||
if (self.allowDesktopNotification())
|
if (this.allowDesktopNotification())
|
||||||
{
|
{
|
||||||
self.allowDesktopNotification.valueHasMutated();
|
this.allowDesktopNotification.valueHasMutated();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self.allowDesktopNotification(true);
|
this.allowDesktopNotification(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (self.allowDesktopNotification())
|
if (this.allowDesktopNotification())
|
||||||
{
|
{
|
||||||
self.allowDesktopNotification(false);
|
this.allowDesktopNotification(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self.allowDesktopNotification.valueHasMutated();
|
this.allowDesktopNotification.valueHasMutated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -109,12 +101,12 @@ function NotificationUserStore()
|
||||||
this.allowDesktopNotification(false);
|
this.allowDesktopNotification(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).extend({'notify': 'always'});
|
}).extend({notify: 'always'});
|
||||||
|
|
||||||
if (!this.enableDesktopNotification.valueHasMutated)
|
if (!this.enableDesktopNotification.valueHasMutated)
|
||||||
{
|
{
|
||||||
this.enableDesktopNotification.valueHasMutated = function() {
|
this.enableDesktopNotification.valueHasMutated = () => {
|
||||||
self.allowDesktopNotification.valueHasMutated();
|
this.allowDesktopNotification.valueHasMutated();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,20 +115,18 @@ function NotificationUserStore()
|
||||||
this.initNotificationPlayer();
|
this.initNotificationPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationUserStore.prototype.computers = function()
|
computers() {
|
||||||
{
|
this.isDesktopNotificationSupported = ko.computed(
|
||||||
this.isDesktopNotificationSupported = ko.computed(function() {
|
() => DesktopNotification.NotSupported !== this.desktopNotificationPermissions()
|
||||||
return Enums.DesktopNotification.NotSupported !== this.desktopNotificationPermissions();
|
);
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.isDesktopNotificationDenied = ko.computed(function() {
|
this.isDesktopNotificationDenied = ko.computed(
|
||||||
return Enums.DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
|
() => DesktopNotification.NotSupported === this.desktopNotificationPermissions() ||
|
||||||
Enums.DesktopNotification.Denied === this.desktopNotificationPermissions();
|
DesktopNotification.Denied === this.desktopNotificationPermissions()
|
||||||
}, this);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
NotificationUserStore.prototype.initNotificationPlayer = function()
|
initNotificationPlayer() {
|
||||||
{
|
|
||||||
if (Audio && Audio.supportedNotification)
|
if (Audio && Audio.supportedNotification)
|
||||||
{
|
{
|
||||||
this.soundNotificationIsSupported(true);
|
this.soundNotificationIsSupported(true);
|
||||||
|
|
@ -146,75 +136,72 @@ NotificationUserStore.prototype.initNotificationPlayer = function()
|
||||||
this.enableSoundNotification(false);
|
this.enableSoundNotification(false);
|
||||||
this.soundNotificationIsSupported(false);
|
this.soundNotificationIsSupported(false);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
NotificationUserStore.prototype.playSoundNotification = function(bSkipSetting)
|
playSoundNotification(skipSetting) {
|
||||||
{
|
if (Audio && Audio.supportedNotification && (skipSetting ? true : this.enableSoundNotification()))
|
||||||
if (Audio && Audio.supportedNotification && (bSkipSetting ? true : this.enableSoundNotification()))
|
|
||||||
{
|
{
|
||||||
Audio.playNotification();
|
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)
|
displayDesktopNotification(imageSrc, title, text, nessageData) {
|
||||||
|
if (this.enableDesktopNotification())
|
||||||
{
|
{
|
||||||
oNotification.onclick = function() {
|
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();
|
window.focus();
|
||||||
|
|
||||||
if (oMessageData.Folder && oMessageData.Uid)
|
if (nessageData.Folder && nessageData.Uid)
|
||||||
{
|
{
|
||||||
Events.pub('mailbox.message.show', [oMessageData.Folder, oMessageData.Uid]);
|
Events.pub('mailbox.message.show', [nessageData.Folder, nessageData.Uid]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
window.setTimeout((function(oLocalNotifications) {
|
window.setTimeout((function(localNotifications) {
|
||||||
return function() {
|
return () => {
|
||||||
if (oLocalNotifications.cancel)
|
if (localNotifications.cancel)
|
||||||
{
|
{
|
||||||
oLocalNotifications.cancel();
|
localNotifications.cancel();
|
||||||
}
|
}
|
||||||
else if (oLocalNotifications.close)
|
else if (localNotifications.close)
|
||||||
{
|
{
|
||||||
oLocalNotifications.close();
|
localNotifications.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}(oNotification)), Enums.Magics.Time7s);
|
}(notification)), Magics.Time7s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
NotificationUserStore.prototype.populate = function()
|
populate() {
|
||||||
{
|
|
||||||
this.enableSoundNotification(!!Settings.settingsGet('SoundNotification'));
|
this.enableSoundNotification(!!Settings.settingsGet('SoundNotification'));
|
||||||
this.enableDesktopNotification(!!Settings.settingsGet('DesktopNotifications'));
|
this.enableDesktopNotification(!!Settings.settingsGet('DesktopNotifications'));
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {*|null}
|
* @returns {*|null}
|
||||||
*/
|
*/
|
||||||
NotificationUserStore.prototype.notificationClass = function()
|
notificationClass() {
|
||||||
{
|
|
||||||
return window.Notification && window.Notification.requestPermission ? window.Notification : null;
|
return window.Notification && window.Notification.requestPermission ? window.Notification : null;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new NotificationUserStore();
|
module.exports = new NotificationUserStore();
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,16 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
_ = require('_'),
|
import _ from '_';
|
||||||
ko = require('ko'),
|
import $ from '$';
|
||||||
$ = require('$'),
|
|
||||||
kn = require('Knoin/Knoin'),
|
|
||||||
|
|
||||||
Translator = require('Common/Translator'),
|
import {showScreenPopup} from 'Knoin/Knoin';
|
||||||
Settings = require('Storage/Settings'),
|
|
||||||
|
|
||||||
Utils = require('Common/Utils');
|
import {i18n} from 'Common/Translator';
|
||||||
|
import {log, isArray, isNonEmptyArray, pString, isUnd, trim} from 'Common/Utils';
|
||||||
|
|
||||||
/**
|
class PgpUserStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function PgpUserStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.capaOpenPGP = ko.observable(false);
|
this.capaOpenPGP = ko.observable(false);
|
||||||
|
|
||||||
this.openpgp = null;
|
this.openpgp = null;
|
||||||
|
|
@ -22,199 +18,162 @@ function PgpUserStore()
|
||||||
this.openpgpkeys = ko.observableArray([]);
|
this.openpgpkeys = ko.observableArray([]);
|
||||||
this.openpgpKeyring = null;
|
this.openpgpKeyring = null;
|
||||||
|
|
||||||
this.openpgpkeysPublic = this.openpgpkeys.filter(function(oItem) {
|
this.openpgpkeysPublic = this.openpgpkeys.filter((item) => !!(item && !item.isPrivate));
|
||||||
return !!(oItem && !oItem.isPrivate);
|
this.openpgpkeysPrivate = this.openpgpkeys.filter((item) => !!(item && item.isPrivate));
|
||||||
});
|
|
||||||
|
|
||||||
this.openpgpkeysPrivate = this.openpgpkeys.filter(function(oItem) {
|
|
||||||
return !!(oItem && oItem.isPrivate);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
PgpUserStore.prototype.isSupported = function()
|
isSupported() {
|
||||||
{
|
|
||||||
return !!this.openpgp;
|
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;});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return aResult;
|
findKeyByHex(keys, hash) {
|
||||||
};
|
return _.find(keys, (item) => (hash && item && (hash === item.id || -1 < item.ids.indexOf(hash))));
|
||||||
|
}
|
||||||
|
|
||||||
|
findPublicKeyByHex(hash) {
|
||||||
|
return this.findKeyByHex(this.openpgpkeysPublic(), hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
findPrivateKeyByHex(hash) {
|
||||||
|
return this.findKeyByHex(this.openpgpkeysPrivate(), hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
findPublicKeysBySigningKeyIds(signingKeyIds) {
|
||||||
|
return _.compact(_.flatten(_.map(signingKeyIds, (id) => {
|
||||||
|
const key = id && id.toHex ? this.findPublicKeyByHex(id.toHex()) : null;
|
||||||
|
return key ? key.getNativeKeys() : [null];
|
||||||
|
}), true));
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
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} sEmail
|
* @param {string} email
|
||||||
* @returns {?}
|
* @returns {?}
|
||||||
*/
|
*/
|
||||||
PgpUserStore.prototype.findPublicKeyByEmailNotNative = function(sEmail)
|
findPublicKeyByEmailNotNative(email) {
|
||||||
{
|
return _.find(this.openpgpkeysPublic(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||||
return _.find(this.openpgpkeysPublic(), function(oItem) {
|
}
|
||||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
|
||||||
}) || null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sEmail
|
* @param {string} email
|
||||||
* @returns {?}
|
* @returns {?}
|
||||||
*/
|
*/
|
||||||
PgpUserStore.prototype.findPrivateKeyByEmailNotNative = function(sEmail)
|
findPrivateKeyByEmailNotNative(email) {
|
||||||
{
|
return _.find(this.openpgpkeysPrivate(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||||
return _.find(this.openpgpkeysPrivate(), function(oItem) {
|
}
|
||||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
|
||||||
}) || null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sEmail
|
* @param {string} email
|
||||||
* @returns {?}
|
* @returns {?}
|
||||||
*/
|
*/
|
||||||
PgpUserStore.prototype.findAllPublicKeysByEmailNotNative = function(sEmail)
|
findAllPublicKeysByEmailNotNative(email) {
|
||||||
{
|
return _.filter(this.openpgpkeysPublic(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||||
return _.filter(this.openpgpkeysPublic(), function(oItem) {
|
}
|
||||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
|
||||||
}) || null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sEmail
|
* @param {string} email
|
||||||
* @returns {?}
|
* @returns {?}
|
||||||
*/
|
*/
|
||||||
PgpUserStore.prototype.findAllPrivateKeysByEmailNotNative = function(sEmail)
|
findAllPrivateKeysByEmailNotNative(email) {
|
||||||
{
|
return _.filter(this.openpgpkeysPrivate(), (item) => (item && -1 < item.emails.indexOf(email))) || null;
|
||||||
return _.filter(this.openpgpkeysPrivate(), function(oItem) {
|
}
|
||||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
|
||||||
}) || null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sEmail
|
* @param {string} email
|
||||||
* @param {string=} sPassword
|
* @param {string=} password
|
||||||
* @returns {?}
|
* @returns {?}
|
||||||
*/
|
*/
|
||||||
PgpUserStore.prototype.findPrivateKeyByEmail = function(sEmail, sPassword)
|
findPrivateKeyByEmail(email, password) {
|
||||||
{
|
|
||||||
var
|
|
||||||
oPrivateKey = null,
|
|
||||||
oKey = _.find(this.openpgpkeysPrivate(), function(oItem) {
|
|
||||||
return oItem && -1 < oItem.emails.indexOf(sEmail);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (oKey)
|
let privateKey = null;
|
||||||
|
const key = _.find(this.openpgpkeysPrivate(), (item) => (item && -1 < item.emails.indexOf(email)));
|
||||||
|
|
||||||
|
if (key)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
oPrivateKey = oKey.getNativeKeys()[0] || null;
|
privateKey = key.getNativeKeys()[0] || null;
|
||||||
if (oPrivateKey)
|
if (privateKey)
|
||||||
{
|
{
|
||||||
oPrivateKey.decrypt(Utils.pString(sPassword));
|
privateKey.decrypt(pString(password));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
oPrivateKey = null;
|
privateKey = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return oPrivateKey;
|
return privateKey;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string=} sPassword
|
* @param {string=} password
|
||||||
* @returns {?}
|
* @returns {?}
|
||||||
*/
|
*/
|
||||||
PgpUserStore.prototype.findSelfPrivateKey = function(sPassword)
|
findSelfPrivateKey(password) {
|
||||||
{
|
return this.findPrivateKeyByEmail(require('Stores/User/Account').email(), password);
|
||||||
return this.findPrivateKeyByEmail(require('Stores/User/Account').email(), sPassword);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallback)
|
decryptMessage(message, recipients, fCallback) {
|
||||||
|
if (message && message.getEncryptionKeyIds)
|
||||||
{
|
{
|
||||||
if (oMessage && oMessage.getEncryptionKeyIds)
|
const privateKeys = this.findPrivateKeysByEncryptionKeyIds(message.getEncryptionKeyIds(), recipients, true);
|
||||||
|
if (privateKeys && 0 < privateKeys.length)
|
||||||
{
|
{
|
||||||
var self = this,
|
showScreenPopup(require('View/Popup/MessageOpenPgp'), [(decryptedKey) => {
|
||||||
aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true);
|
|
||||||
|
|
||||||
if (aPrivateKeys && 0 < aPrivateKeys.length)
|
if (decryptedKey)
|
||||||
{
|
{
|
||||||
kn.showScreenPopup(require('View/Popup/MessageOpenPgp'), [function(oDecryptedKey) {
|
message.decrypt(decryptedKey).then((decryptedMessage) => {
|
||||||
|
let privateKey = null;
|
||||||
if (oDecryptedKey)
|
if (decryptedMessage)
|
||||||
{
|
{
|
||||||
oMessage.decrypt(oDecryptedKey).then(function(oDecryptedMessage) {
|
privateKey = this.findPrivateKeyByHex(decryptedKey.primaryKey.keyid.toHex());
|
||||||
var oPrivateKey = null;
|
if (privateKey)
|
||||||
if (oDecryptedMessage)
|
|
||||||
{
|
{
|
||||||
oPrivateKey = self.findPrivateKeyByHex(oDecryptedKey.primaryKey.keyid.toHex());
|
this.verifyMessage(decryptedMessage, (oValidKey, aSigningKeyIds) => {
|
||||||
if (oPrivateKey)
|
fCallback(privateKey, decryptedMessage, oValidKey || null, aSigningKeyIds || null);
|
||||||
{
|
|
||||||
self.verifyMessage(oDecryptedMessage, function(oValidKey, aSigningKeyIds) {
|
|
||||||
fCallback(oPrivateKey, oDecryptedMessage, oValidKey || null, aSigningKeyIds || null);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fCallback(oPrivateKey, oDecryptedMessage);
|
fCallback(privateKey, decryptedMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fCallback(oPrivateKey, oDecryptedMessage);
|
fCallback(privateKey, decryptedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, function() {
|
}, () => {
|
||||||
fCallback(null, null);
|
fCallback(null, null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -223,7 +182,7 @@ PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallbac
|
||||||
fCallback(null, null);
|
fCallback(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, aPrivateKeys]);
|
}, privateKeys]);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -232,96 +191,68 @@ PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallbac
|
||||||
fCallback(null, null);
|
fCallback(null, null);
|
||||||
|
|
||||||
return false;
|
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)
|
verifyMessage(message, fCallback) {
|
||||||
|
if (message && message.getSigningKeyIds)
|
||||||
{
|
{
|
||||||
if (oMessage && oMessage.getSigningKeyIds)
|
const signingKeyIds = message.getSigningKeyIds();
|
||||||
|
if (signingKeyIds && 0 < signingKeyIds.length)
|
||||||
{
|
{
|
||||||
var aSigningKeyIds = oMessage.getSigningKeyIds();
|
const publicKeys = this.findPublicKeysBySigningKeyIds(signingKeyIds);
|
||||||
if (aSigningKeyIds && 0 < aSigningKeyIds.length)
|
if (publicKeys && 0 < publicKeys.length)
|
||||||
{
|
|
||||||
var aPublicKeys = this.findPublicKeysBySigningKeyIds(aSigningKeyIds);
|
|
||||||
if (aPublicKeys && 0 < aPublicKeys.length)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var
|
const
|
||||||
aResult = oMessage.verify(aPublicKeys),
|
result = message.verify(publicKeys),
|
||||||
oValid = _.find(_.isArray(aResult) ? aResult : [], function(oItem) {
|
valid = _.find(_.isArray(result) ? result : [], (item) => (item && item.valid && item.keyid));
|
||||||
return oItem && oItem.valid && oItem.keyid;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (oValid && oValid.keyid && oValid.keyid && oValid.keyid.toHex)
|
if (valid && valid.keyid && valid.keyid && valid.keyid.toHex)
|
||||||
{
|
{
|
||||||
fCallback(this.findPublicKeyByHex(oValid.keyid.toHex()));
|
fCallback(this.findPublicKeyByHex(valid.keyid.toHex()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
Utils.log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fCallback(null, aSigningKeyIds);
|
fCallback(null, signingKeyIds);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fCallback(null);
|
fCallback(null);
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
controlsHelper(dom, verControl, success, title, text) {
|
||||||
* @param {*} mDom
|
if (success)
|
||||||
*/
|
|
||||||
PgpUserStore.prototype.controlsHelper = function(mDom, oVerControl, bSuccess, sTitle, sText)
|
|
||||||
{
|
{
|
||||||
if (bSuccess)
|
dom.removeClass('error').addClass('success').attr('title', title);
|
||||||
{
|
verControl.removeClass('error').addClass('success').attr('title', title);
|
||||||
mDom.removeClass('error').addClass('success').attr('title', sTitle);
|
|
||||||
oVerControl.removeClass('error').addClass('success').attr('title', sTitle);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mDom.removeClass('success').addClass('error').attr('title', sTitle);
|
dom.removeClass('success').addClass('error').attr('title', title);
|
||||||
oVerControl.removeClass('success').addClass('error').attr('title', sTitle);
|
verControl.removeClass('success').addClass('error').attr('title', title);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Utils.isUnd(sText))
|
if (!isUnd(text))
|
||||||
{
|
{
|
||||||
mDom.text(Utils.trim(sText.replace(/(\u200C|\u0002)/g, '')));
|
dom.text(trim(text));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
static domControlEncryptedClickHelper(store, dom, armoredMessage, recipients) {
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMessage, aRecipients)
|
|
||||||
{
|
|
||||||
return function() {
|
return function() {
|
||||||
|
|
||||||
var
|
let message = null;
|
||||||
message = null,
|
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||||
$this = $(this);
|
|
||||||
|
|
||||||
if ($this.hasClass('success'))
|
if ($this.hasClass('success'))
|
||||||
{
|
{
|
||||||
|
|
@ -330,69 +261,59 @@ PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMess
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
message = store.openpgp.message.readArmored(sArmoredMessage);
|
message = store.openpgp.message.readArmored(armoredMessage);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
Utils.log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message && message.getText && message.verify && message.decrypt)
|
if (message && message.getText && message.verify && message.decrypt)
|
||||||
{
|
{
|
||||||
store.decryptMessage(message, aRecipients, function(oValidPrivateKey, oDecryptedMessage, oValidPublicKey, aSigningKeyIds) {
|
store.decryptMessage(message, recipients, (validPrivateKey, decryptedMessage, validPublicKey, signingKeyIds) => {
|
||||||
|
if (decryptedMessage)
|
||||||
if (oDecryptedMessage)
|
|
||||||
{
|
{
|
||||||
if (oValidPublicKey)
|
if (validPublicKey)
|
||||||
{
|
{
|
||||||
store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
store.controlsHelper(dom, $this, true, i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||||
'USER': oValidPublicKey.user + ' (' + oValidPublicKey.id + ')'
|
'USER': validPublicKey.user + ' (' + validPublicKey.id + ')'
|
||||||
}), oDecryptedMessage.getText());
|
}), decryptedMessage.getText());
|
||||||
}
|
}
|
||||||
else if (oValidPrivateKey)
|
else if (validPrivateKey)
|
||||||
{
|
{
|
||||||
var
|
const
|
||||||
aKeyIds = Utils.isNonEmptyArray(aSigningKeyIds) ? aSigningKeyIds : null,
|
keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||||
sAdditional = aKeyIds ? _.compact(_.map(aKeyIds, function(oItem) {
|
additional = keyIds ? _.compact(_.map(keyIds,
|
||||||
return oItem && oItem.toHex ? oItem.toHex() : null;
|
(item) => (item && item.toHex ? item.toHex() : null))).join(', ') : '';
|
||||||
})).join(', ') : '';
|
|
||||||
|
|
||||||
store.controlsHelper(mDom, $this, false,
|
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') +
|
||||||
Translator.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') +
|
(additional ? ' (' + additional + ')' : ''), decryptedMessage.getText());
|
||||||
(sAdditional ? ' (' + sAdditional + ')' : ''),
|
|
||||||
oDecryptedMessage.getText());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
store.controlsHelper(mDom, $this, false,
|
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||||
Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
store.controlsHelper(mDom, $this, false,
|
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||||
Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
store.controlsHelper(mDom, $this, false, Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
|
static domControlSignedClickHelper(store, dom, armoredMessage) {
|
||||||
|
|
||||||
/**
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage)
|
|
||||||
{
|
|
||||||
return function() {
|
return function() {
|
||||||
|
|
||||||
var
|
let message = null;
|
||||||
message = null,
|
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||||
$this = $(this);
|
|
||||||
|
|
||||||
if ($this.hasClass('success') || $this.hasClass('error'))
|
if ($this.hasClass('success') || $this.hasClass('error'))
|
||||||
{
|
{
|
||||||
|
|
@ -401,85 +322,82 @@ PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
message = store.openpgp.cleartext.readArmored(sArmoredMessage);
|
message = store.openpgp.cleartext.readArmored(armoredMessage);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
Utils.log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message && message.getText && message.verify)
|
if (message && message.getText && message.verify)
|
||||||
{
|
{
|
||||||
store.verifyMessage(message, function(oValidKey, aSigningKeyIds) {
|
store.verifyMessage(message, (validKey, signingKeyIds) => {
|
||||||
if (oValidKey)
|
if (validKey)
|
||||||
{
|
{
|
||||||
store.controlsHelper(mDom, $this, true, Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
store.controlsHelper(dom, $this, true, i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||||
'USER': oValidKey.user + ' (' + oValidKey.id + ')'
|
'USER': validKey.user + ' (' + validKey.id + ')'
|
||||||
}), message.getText());
|
}), message.getText());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var
|
const
|
||||||
aKeyIds = Utils.isNonEmptyArray(aSigningKeyIds) ? aSigningKeyIds : null,
|
keyIds = isNonEmptyArray(signingKeyIds) ? signingKeyIds : null,
|
||||||
sAdditional = aKeyIds ? _.compact(_.map(aKeyIds, function(oItem) {
|
additional = keyIds ? _.compact(_.map(keyIds, (item) => (item && item.toHex ? item.toHex() : null))).join(', ') : '';
|
||||||
return oItem && oItem.toHex ? oItem.toHex() : null;
|
|
||||||
})).join(', ') : '';
|
|
||||||
|
|
||||||
store.controlsHelper(mDom, $this, false,
|
store.controlsHelper(dom, $this, false,
|
||||||
Translator.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') +
|
i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE') + (additional ? ' (' + additional + ')' : ''));
|
||||||
(sAdditional ? ' (' + sAdditional + ')' : ''));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
store.controlsHelper(mDom, $this, false, Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
store.controlsHelper(dom, $this, false, i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR'));
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {*} mDom
|
* @param {*} dom
|
||||||
* @param {MessageModel} oRainLoopMessage
|
* @param {MessageModel} rainLoopMessage
|
||||||
*/
|
*/
|
||||||
PgpUserStore.prototype.initMessageBodyControls = function(mDom, oRainLoopMessage)
|
initMessageBodyControls(dom, rainLoopMessage) {
|
||||||
|
if (dom && !dom.hasClass('inited'))
|
||||||
{
|
{
|
||||||
if (mDom && !mDom.hasClass('inited'))
|
dom.addClass('inited');
|
||||||
{
|
|
||||||
mDom.addClass('inited');
|
|
||||||
|
|
||||||
var
|
const
|
||||||
bEncrypted = mDom.hasClass('encrypted'),
|
encrypted = dom.hasClass('encrypted'),
|
||||||
bSigned = mDom.hasClass('signed'),
|
signed = dom.hasClass('signed'),
|
||||||
oVerControl = null,
|
recipients = rainLoopMessage ? rainLoopMessage.getEmails(['from', 'to', 'cc']) : [];
|
||||||
aRecipients = oRainLoopMessage ? oRainLoopMessage.getEmails(['from', 'to', 'cc']) : [],
|
|
||||||
sData = '';
|
|
||||||
|
|
||||||
if (bEncrypted || bSigned)
|
let verControl = null;
|
||||||
{
|
|
||||||
sData = mDom.text();
|
|
||||||
mDom.data('openpgp-original', sData);
|
|
||||||
|
|
||||||
if (bEncrypted)
|
if (encrypted || signed)
|
||||||
{
|
{
|
||||||
oVerControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
const domText = dom.text();
|
||||||
.attr('title', Translator.i18n('MESSAGE/PGP_ENCRYPTED_MESSAGE_DESC'))
|
dom.data('openpgp-original', domText);
|
||||||
.on('click', PgpUserStore.domControlEncryptedClickHelper(this, mDom, sData, aRecipients));
|
|
||||||
|
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 (bSigned)
|
else if (signed)
|
||||||
{
|
{
|
||||||
oVerControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
verControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
|
||||||
.attr('title', Translator.i18n('MESSAGE/PGP_SIGNED_MESSAGE_DESC'))
|
.attr('title', i18n('MESSAGE/PGP_SIGNED_MESSAGE_DESC'))
|
||||||
.on('click', PgpUserStore.domControlSignedClickHelper(this, mDom, sData));
|
.on('click', PgpUserStore.domControlSignedClickHelper(this, dom, domText));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oVerControl)
|
if (verControl)
|
||||||
{
|
{
|
||||||
mDom.before(oVerControl).before('<div></div>');
|
dom.before(verControl).before('<div></div>');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = new PgpUserStore();
|
module.exports = new PgpUserStore();
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,32 @@
|
||||||
|
|
||||||
var
|
import window from 'window';
|
||||||
window = require('window'),
|
import ko from 'ko';
|
||||||
ko = require('ko');
|
|
||||||
|
|
||||||
/**
|
class QuotaUserStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function QuotaUserStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.quota = ko.observable(0);
|
this.quota = ko.observable(0);
|
||||||
this.usage = ko.observable(0);
|
this.usage = ko.observable(0);
|
||||||
|
|
||||||
this.percentage = ko.computed(function() {
|
this.percentage = ko.computed(() => {
|
||||||
|
|
||||||
var
|
const
|
||||||
iQuota = this.quota(),
|
quota = this.quota(),
|
||||||
iUsed = this.usage();
|
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} iQuota
|
* @param {number} quota
|
||||||
* @param {number} iUsage
|
* @param {number} usage
|
||||||
*/
|
*/
|
||||||
QuotaUserStore.prototype.populateData = function(iQuota, iUsage)
|
populateData(quota, usage) {
|
||||||
{
|
this.quota(quota * 1024);
|
||||||
this.quota(iQuota * 1024);
|
this.usage(usage * 1024);
|
||||||
this.usage(iUsage * 1024);
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = new QuotaUserStore();
|
module.exports = new QuotaUserStore();
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,32 @@
|
||||||
|
|
||||||
var
|
import window from 'window';
|
||||||
window = require('window'),
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Consts = require('Common/Consts'),
|
import {MESSAGES_PER_PAGE, MESSAGES_PER_PAGE_VALUES} from 'Common/Consts';
|
||||||
Enums = require('Common/Enums'),
|
import {Layout, EditorDefaultType, Magics} from 'Common/Enums';
|
||||||
Globals = require('Common/Globals'),
|
import {$html} from 'Common/Globals';
|
||||||
Utils = require('Common/Utils'),
|
import {pInt} from 'Common/Utils';
|
||||||
Events = require('Common/Events'),
|
import * as Events from 'Common/Events';
|
||||||
|
|
||||||
Settings = require('Storage/Settings');
|
import * as Settings from 'Storage/Settings';
|
||||||
|
|
||||||
/**
|
class SettingsUserStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function SettingsUserStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
|
|
||||||
this.iAutoLogoutTimer = 0;
|
this.iAutoLogoutTimer = 0;
|
||||||
|
|
||||||
this.layout = ko.observable(Enums.Layout.SidePreview)
|
this.layout = ko.observable(Layout.SidePreview)
|
||||||
.extend({'limitedList': [
|
.extend({limitedList: [Layout.SidePreview, Layout.BottomPreview, Layout.NoPreview]});
|
||||||
Enums.Layout.SidePreview, Enums.Layout.BottomPreview, Enums.Layout.NoPreview
|
|
||||||
|
this.editorDefaultType = ko.observable(EditorDefaultType.Html)
|
||||||
|
.extend({limitedList: [
|
||||||
|
EditorDefaultType.Html, EditorDefaultType.Plain,
|
||||||
|
EditorDefaultType.HtmlForced, EditorDefaultType.PlainForced
|
||||||
]});
|
]});
|
||||||
|
|
||||||
this.editorDefaultType = ko.observable(Enums.EditorDefaultType.Html)
|
this.messagesPerPage = ko.observable(MESSAGES_PER_PAGE)
|
||||||
.extend({'limitedList': [
|
.extend({limitedList: MESSAGES_PER_PAGE_VALUES});
|
||||||
Enums.EditorDefaultType.Html, Enums.EditorDefaultType.Plain,
|
|
||||||
Enums.EditorDefaultType.HtmlForced, Enums.EditorDefaultType.PlainForced
|
|
||||||
]});
|
|
||||||
|
|
||||||
this.messagesPerPage = ko.observable(Consts.MESSAGES_PER_PAGE)
|
|
||||||
.extend({'limitedList': Consts.MESSAGES_PER_PAGE_VALUES});
|
|
||||||
|
|
||||||
this.showImages = ko.observable(false);
|
this.showImages = ko.observable(false);
|
||||||
this.useCheckboxesInList = ko.observable(true);
|
this.useCheckboxesInList = ko.observable(true);
|
||||||
|
|
@ -43,31 +39,24 @@ function SettingsUserStore()
|
||||||
this.subscribers();
|
this.subscribers();
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsUserStore.prototype.computers = function()
|
computers() {
|
||||||
{
|
this.usePreviewPane = ko.computed(() => Layout.NoPreview !== this.layout());
|
||||||
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);
|
|
||||||
|
|
||||||
|
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]);
|
Events.pub('layout', [nValue]);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
SettingsUserStore.prototype.populate = function()
|
populate() {
|
||||||
{
|
this.layout(pInt(Settings.settingsGet('Layout')));
|
||||||
this.layout(Utils.pInt(Settings.settingsGet('Layout')));
|
|
||||||
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
|
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
|
||||||
|
|
||||||
this.autoLogout(Utils.pInt(Settings.settingsGet('AutoLogout')));
|
this.autoLogout(pInt(Settings.settingsGet('AutoLogout')));
|
||||||
this.messagesPerPage(Settings.settingsGet('MPP'));
|
this.messagesPerPage(Settings.settingsGet('MPP'));
|
||||||
|
|
||||||
this.showImages(!!Settings.settingsGet('ShowImages'));
|
this.showImages(!!Settings.settingsGet('ShowImages'));
|
||||||
|
|
@ -75,19 +64,18 @@ SettingsUserStore.prototype.populate = function()
|
||||||
this.useThreads(!!Settings.settingsGet('UseThreads'));
|
this.useThreads(!!Settings.settingsGet('UseThreads'));
|
||||||
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
|
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
|
||||||
|
|
||||||
var self = this;
|
Events.sub('rl.auto-logout-refresh', () => {
|
||||||
|
window.clearTimeout(this.iAutoLogoutTimer);
|
||||||
Events.sub('rl.auto-logout-refresh', function() {
|
if (0 < this.autoLogout() && !Settings.settingsGet('AccountSignMe'))
|
||||||
window.clearTimeout(self.iAutoLogoutTimer);
|
|
||||||
if (0 < self.autoLogout() && !Settings.settingsGet('AccountSignMe'))
|
|
||||||
{
|
{
|
||||||
self.iAutoLogoutTimer = window.setTimeout(function() {
|
this.iAutoLogoutTimer = window.setTimeout(() => {
|
||||||
Events.pub('rl.auto-logout');
|
Events.pub('rl.auto-logout');
|
||||||
}, self.autoLogout() * Enums.Magics.Time1m);
|
}, this.autoLogout() * Magics.Time1m);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.pub('rl.auto-logout-refresh');
|
Events.pub('rl.auto-logout-refresh');
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new SettingsUserStore();
|
module.exports = new SettingsUserStore();
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,28 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
_ = require('_'),
|
import _ from '_';
|
||||||
ko = require('ko');
|
|
||||||
|
|
||||||
// Remote = require('Remote/User/Ajax');
|
// Remote = require('Remote/User/Ajax');
|
||||||
|
|
||||||
/**
|
class TemplateUserStore
|
||||||
* @constructor
|
|
||||||
*/
|
|
||||||
function TemplateUserStore()
|
|
||||||
{
|
{
|
||||||
|
constructor() {
|
||||||
this.templates = ko.observableArray([]);
|
this.templates = ko.observableArray([]);
|
||||||
this.templates.loading = ko.observable(false).extend({'throttle': 100});
|
this.templates.loading = ko.observable(false).extend({throttle: 100});
|
||||||
|
|
||||||
this.templatesNames = ko.observableArray([]).extend({'throttle': 1000});
|
this.templatesNames = ko.observableArray([]).extend({throttle: 1000});
|
||||||
this.templatesNames.skipFirst = true;
|
this.templatesNames.skipFirst = true;
|
||||||
|
|
||||||
this.subscribers();
|
this.subscribers();
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateUserStore.prototype.subscribers = function()
|
subscribers() {
|
||||||
{
|
|
||||||
this.templates.subscribe(function(aList) {
|
|
||||||
this.templatesNames(_.compact(_.map(aList, function(oItem) {
|
|
||||||
return oItem ? oItem.name : null;
|
|
||||||
})));
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
// 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)
|
// if (this.templatesNames.skipFirst)
|
||||||
// {
|
// {
|
||||||
// this.templatesNames.skipFirst = false;
|
// this.templatesNames.skipFirst = false;
|
||||||
|
|
@ -36,7 +31,8 @@ TemplateUserStore.prototype.subscribers = function()
|
||||||
// {
|
// {
|
||||||
// Remote.templatesSortOrder(null, aList);
|
// Remote.templatesSortOrder(null, aList);
|
||||||
// }
|
// }
|
||||||
// }, this);
|
// });
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = new TemplateUserStore();
|
module.exports = new TemplateUserStore();
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,10 @@ html.no-css .thm-body {
|
||||||
html.no-css .thm-loading {
|
html.no-css .thm-loading {
|
||||||
color: #333 !important;
|
color: #333 !important;
|
||||||
text-shadow: none !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 {
|
html.no-css .thm-login-desc .desc {
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,15 @@ html {
|
||||||
|
|
||||||
html.rl-anim {
|
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 {
|
&.cssanimations.csstransitions.no-mobile .b-login-content .errorAnimated {
|
||||||
animation: login-form-shake 400ms ease-in-out;
|
animation: login-form-shake 400ms ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,3 +93,10 @@ svg-icon {
|
||||||
.btn .btn-text {
|
.btn .btn-text {
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active-scale-transition {
|
||||||
|
transition: transform .2s;
|
||||||
|
&:active {
|
||||||
|
transform: scale(.95);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,33 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
_ = require('_'),
|
import _ from '_';
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
import {
|
||||||
Utils = require('Common/Utils'),
|
trim, createCommand,
|
||||||
Translator = require('Common/Translator'),
|
triggerAutocompleteInputChange
|
||||||
|
} from 'Common/Utils';
|
||||||
|
|
||||||
Settings = require('Storage/Settings'),
|
import {StorageResultType, Notification, Magics} from 'Common/Enums';
|
||||||
Remote = require('Remote/Admin/Ajax'),
|
import {getNotification} from 'Common/Translator';
|
||||||
|
|
||||||
kn = require('Knoin/Knoin'),
|
import * as Settings from 'Storage/Settings';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
|
||||||
|
|
||||||
/**
|
import Remote from 'Remote/Admin/Ajax';
|
||||||
* @constructor
|
|
||||||
* @extends AbstractView
|
import {getApp} from 'Helper/Apps/Admin';
|
||||||
*/
|
|
||||||
function LoginAdminView()
|
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');
|
||||||
|
|
||||||
|
|
@ -39,38 +47,30 @@ function LoginAdminView()
|
||||||
|
|
||||||
this.formHidden = ko.observable(false);
|
this.formHidden = ko.observable(false);
|
||||||
|
|
||||||
this.formError = ko.computed(function() {
|
this.formError = ko.computed(() => this.loginErrorAnimation() || this.passwordErrorAnimation());
|
||||||
return this.loginErrorAnimation() || this.passwordErrorAnimation();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.login.subscribe(function() {
|
this.login.subscribe(() => this.loginError(false));
|
||||||
this.loginError(false);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.password.subscribe(function() {
|
this.password.subscribe(() => this.passwordError(false));
|
||||||
this.passwordError(false);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.loginError.subscribe(function(bV) {
|
this.loginError.subscribe((v) => this.loginErrorAnimation(!!v));
|
||||||
this.loginErrorAnimation(!!bV);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.passwordError.subscribe(function(bV) {
|
this.passwordError.subscribe((v) => {
|
||||||
this.passwordErrorAnimation(!!bV);
|
this.passwordErrorAnimation(!!v);
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.submitRequest = ko.observable(false);
|
this.submitRequest = ko.observable(false);
|
||||||
this.submitError = ko.observable('');
|
this.submitError = ko.observable('');
|
||||||
|
|
||||||
this.submitCommand = Utils.createCommand(this, function() {
|
this.submitCommand = createCommand(() => {
|
||||||
|
|
||||||
Utils.triggerAutocompleteInputChange();
|
triggerAutocompleteInputChange();
|
||||||
|
|
||||||
this.loginError(false);
|
this.loginError(false);
|
||||||
this.passwordError(false);
|
this.passwordError(false);
|
||||||
|
|
||||||
this.loginError('' === Utils.trim(this.login()));
|
this.loginError('' === trim(this.login()));
|
||||||
this.passwordError('' === Utils.trim(this.password()));
|
this.passwordError('' === trim(this.password()));
|
||||||
|
|
||||||
if (this.loginError() || this.passwordError())
|
if (this.loginError() || this.passwordError())
|
||||||
{
|
{
|
||||||
|
|
@ -79,63 +79,53 @@ function LoginAdminView()
|
||||||
|
|
||||||
this.submitRequest(true);
|
this.submitRequest(true);
|
||||||
|
|
||||||
Remote.adminLogin(_.bind(function(sResult, oData) {
|
Remote.adminLogin((sResult, oData) => {
|
||||||
|
|
||||||
if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
|
if (StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
|
||||||
{
|
{
|
||||||
if (oData.Result)
|
if (oData.Result)
|
||||||
{
|
{
|
||||||
require('App/Admin').default.loginAndLogoutReload(true);
|
getApp().loginAndLogoutReload(true);
|
||||||
}
|
}
|
||||||
else if (oData.ErrorCode)
|
else if (oData.ErrorCode)
|
||||||
{
|
{
|
||||||
this.submitRequest(false);
|
this.submitRequest(false);
|
||||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
this.submitError(getNotification(oData.ErrorCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.submitRequest(false);
|
this.submitRequest(false);
|
||||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
this.submitError(getNotification(Notification.UnknownError));
|
||||||
}
|
}
|
||||||
|
|
||||||
}, this), this.login(), this.password());
|
}, this.login(), this.password());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}, function() {
|
}, () => !this.submitRequest());
|
||||||
return !this.submitRequest();
|
|
||||||
});
|
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Admin/Login', 'AdminLoginViewModel'], LoginAdminView);
|
onShow() {
|
||||||
_.extend(LoginAdminView.prototype, AbstractView.prototype);
|
|
||||||
|
|
||||||
LoginAdminView.prototype.onShow = function()
|
routeOff();
|
||||||
{
|
|
||||||
kn.routeOff();
|
|
||||||
|
|
||||||
_.delay(_.bind(function() {
|
_.delay(() => {
|
||||||
this.loginFocus(true);
|
this.loginFocus(true);
|
||||||
}, this), Enums.Magics.Time100ms);
|
}, Magics.Time100ms);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
onHide() {
|
||||||
|
|
||||||
LoginAdminView.prototype.onHide = function()
|
|
||||||
{
|
|
||||||
this.loginFocus(false);
|
this.loginFocus(false);
|
||||||
};
|
}
|
||||||
|
|
||||||
LoginAdminView.prototype.onBuild = function()
|
onBuild() {
|
||||||
{
|
triggerAutocompleteInputChange(true);
|
||||||
Utils.triggerAutocompleteInputChange(true);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
LoginAdminView.prototype.submitForm = function()
|
submitForm() {
|
||||||
{
|
|
||||||
this.submitCommand();
|
this.submitCommand();
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = LoginAdminView;
|
export {LoginAdminView, LoginAdminView as default};
|
||||||
|
|
|
||||||
|
|
@ -1,69 +1,66 @@
|
||||||
|
|
||||||
var
|
import _ from '_';
|
||||||
_ = require('_'),
|
import $ from '$';
|
||||||
$ = require('$'),
|
import key from 'key';
|
||||||
key = require('key'),
|
|
||||||
|
|
||||||
Globals = require('Common/Globals'),
|
import {leftPanelDisabled} from 'Common/Globals';
|
||||||
Enums = require('Common/Enums'),
|
import {Magics} from 'Common/Enums';
|
||||||
|
|
||||||
kn = require('Knoin/Knoin'),
|
import {view, ViewType, setHash} from 'Knoin/Knoin';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||||
|
|
||||||
/**
|
@view({
|
||||||
* @constructor
|
name: 'View/Admin/Settings/Menu',
|
||||||
* @param {?} oScreen
|
type: ViewType.Left,
|
||||||
*
|
templateID: 'AdminMenu'
|
||||||
* @extends AbstractView
|
})
|
||||||
*/
|
class MenuSettingsAdminView extends AbstractViewNext
|
||||||
function MenuSettingsAdminView(oScreen)
|
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Admin/Settings/Menu', 'AdminSettingsMenuViewModel'], MenuSettingsAdminView);
|
link(route) {
|
||||||
_.extend(MenuSettingsAdminView.prototype, AbstractView.prototype);
|
return '#/' + route;
|
||||||
|
}
|
||||||
|
|
||||||
MenuSettingsAdminView.prototype.link = function(sRoute)
|
onBuild(dom) {
|
||||||
{
|
|
||||||
return '#/' + sRoute;
|
|
||||||
};
|
|
||||||
|
|
||||||
MenuSettingsAdminView.prototype.onBuild = function(oDom)
|
key('up, down', _.throttle((event, handler) => {
|
||||||
{
|
|
||||||
key('up, down', _.throttle(function(event, handler) {
|
|
||||||
|
|
||||||
var
|
const
|
||||||
sH = '',
|
up = handler && 'up' === handler.shortcut,
|
||||||
bUp = handler && 'up' === handler.shortcut,
|
$items = $('.b-admin-menu .e-item', dom);
|
||||||
$items = $('.b-admin-menu .e-item', oDom);
|
|
||||||
|
|
||||||
if (event && $items.length)
|
if (event && $items.length)
|
||||||
{
|
{
|
||||||
var index = $items.index($items.filter('.selected'));
|
let index = $items.index($items.filter('.selected'));
|
||||||
if (bUp && 0 < index)
|
if (up && 0 < index)
|
||||||
{
|
{
|
||||||
index -= 1;
|
index -= 1;
|
||||||
}
|
}
|
||||||
else if (!bUp && index < $items.length - 1)
|
else if (!up && index < $items.length - 1)
|
||||||
{
|
{
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sH = $items.eq(index).attr('href');
|
const sH = $items.eq(index).attr('href');
|
||||||
if (sH)
|
if (sH)
|
||||||
{
|
{
|
||||||
kn.setHash(sH, false, true);
|
setHash(sH, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}, Enums.Magics.Time200ms));
|
}, Magics.Time200ms));
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = MenuSettingsAdminView;
|
export {MenuSettingsAdminView, MenuSettingsAdminView as default};
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,30 @@
|
||||||
|
|
||||||
var
|
/* global RL_COMMUNITY */
|
||||||
_ = require('_'),
|
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Settings = require('Storage/Settings'),
|
import ko from 'ko';
|
||||||
Remote = require('Remote/Admin/Ajax'),
|
|
||||||
|
|
||||||
kn = require('Knoin/Knoin'),
|
import * as Settings from 'Storage/Settings';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
|
||||||
|
|
||||||
/**
|
import Remote from 'Remote/Admin/Ajax';
|
||||||
* @constructor
|
|
||||||
* @extends AbstractView
|
import DomainStore from 'Stores/Admin/Domain';
|
||||||
*/
|
import PluginStore from 'Stores/Admin/Plugin';
|
||||||
function PaneSettingsAdminView()
|
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.adminDomain = ko.observable(Settings.settingsGet('AdminDomain'));
|
||||||
this.version = ko.observable(Settings.appSettingsGet('version'));
|
this.version = ko.observable(Settings.appSettingsGet('version'));
|
||||||
|
|
@ -23,29 +32,24 @@ function PaneSettingsAdminView()
|
||||||
this.capa = !!Settings.settingsGet('PremType');
|
this.capa = !!Settings.settingsGet('PremType');
|
||||||
this.community = RL_COMMUNITY;
|
this.community = RL_COMMUNITY;
|
||||||
|
|
||||||
this.adminManLoading = ko.computed(function() {
|
this.adminManLoading = ko.computed(
|
||||||
return '000' !== [
|
() => '000' !== [
|
||||||
require('Stores/Admin/Domain').domains.loading() ? '1' : '0',
|
DomainStore.domains.loading() ? '1' : '0',
|
||||||
require('Stores/Admin/Plugin').plugins.loading() ? '1' : '0',
|
PluginStore.plugins.loading() ? '1' : '0',
|
||||||
require('Stores/Admin/Package').packages.loading() ? '1' : '0'
|
PackageStore.packages.loading() ? '1' : '0'
|
||||||
].join('');
|
].join('')
|
||||||
}, this);
|
);
|
||||||
|
|
||||||
this.adminManLoadingVisibility = ko.computed(function() {
|
this.adminManLoadingVisibility = ko.computed(
|
||||||
return this.adminManLoading() ? 'visible' : 'hidden';
|
() => (this.adminManLoading() ? 'visible' : 'hidden')
|
||||||
}, this).extend({'rateLimit': 300});
|
).extend({rateLimit: 300});
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Admin/Settings/Pane', 'AdminSettingsPaneViewModel'], PaneSettingsAdminView);
|
logoutClick() {
|
||||||
_.extend(PaneSettingsAdminView.prototype, AbstractView.prototype);
|
Remote.adminLogout(() => {
|
||||||
|
getApp().loginAndLogoutReload(true, true);
|
||||||
PaneSettingsAdminView.prototype.logoutClick = function()
|
|
||||||
{
|
|
||||||
Remote.adminLogout(function() {
|
|
||||||
require('App/Admin').default.loginAndLogoutReload(true, true);
|
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = PaneSettingsAdminView;
|
export {PaneSettingsAdminView, PaneSettingsAdminView as default};
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,26 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
_ = require('_'),
|
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
import {StorageResultType, Notification} from 'Common/Enums';
|
||||||
Utils = require('Common/Utils'),
|
import {trim, createCommand} from 'Common/Utils';
|
||||||
Translator = require('Common/Translator'),
|
import {getNotification} from 'Common/Translator';
|
||||||
|
|
||||||
Remote = require('Remote/User/Ajax'),
|
import Remote from 'Remote/User/Ajax';
|
||||||
|
|
||||||
kn = require('Knoin/Knoin'),
|
import {getApp} from 'Helper/Apps/User';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
|
||||||
|
|
||||||
/**
|
import {view, ViewType} from 'Knoin/Knoin';
|
||||||
* @constructor
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||||
* @extends AbstractView
|
|
||||||
*/
|
@view({
|
||||||
function AccountPopupView()
|
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);
|
||||||
|
|
||||||
|
|
@ -28,13 +30,13 @@ function AccountPopupView()
|
||||||
this.emailError = ko.observable(false);
|
this.emailError = ko.observable(false);
|
||||||
this.passwordError = ko.observable(false);
|
this.passwordError = ko.observable(false);
|
||||||
|
|
||||||
this.email.subscribe(function() {
|
this.email.subscribe(() => {
|
||||||
this.emailError(false);
|
this.emailError(false);
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.password.subscribe(function() {
|
this.password.subscribe(() => {
|
||||||
this.passwordError(false);
|
this.passwordError(false);
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.submitRequest = ko.observable(false);
|
this.submitRequest = ko.observable(false);
|
||||||
this.submitError = ko.observable('');
|
this.submitError = ko.observable('');
|
||||||
|
|
@ -42,10 +44,10 @@ function AccountPopupView()
|
||||||
|
|
||||||
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.emailError('' === trim(this.email()));
|
||||||
this.passwordError('' === Utils.trim(this.password()));
|
this.passwordError('' === trim(this.password()));
|
||||||
|
|
||||||
if (this.emailError() || this.passwordError())
|
if (this.emailError() || this.passwordError())
|
||||||
{
|
{
|
||||||
|
|
@ -54,49 +56,41 @@ function AccountPopupView()
|
||||||
|
|
||||||
this.submitRequest(true);
|
this.submitRequest(true);
|
||||||
|
|
||||||
Remote.accountSetup(_.bind(function(sResult, oData) {
|
Remote.accountSetup((result, data) => {
|
||||||
|
|
||||||
this.submitRequest(false);
|
this.submitRequest(false);
|
||||||
if (Enums.StorageResultType.Success === sResult && oData)
|
if (StorageResultType.Success === result && data)
|
||||||
{
|
{
|
||||||
if (oData.Result)
|
if (data.Result)
|
||||||
{
|
{
|
||||||
require('App/User').default.accountsAndIdentities();
|
getApp().accountsAndIdentities();
|
||||||
this.cancelCommand();
|
this.cancelCommand();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.submitError(oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) :
|
this.submitError(data.ErrorCode ? getNotification(data.ErrorCode) :
|
||||||
Translator.getNotification(Enums.Notification.UnknownError));
|
getNotification(Notification.UnknownError));
|
||||||
|
|
||||||
if (oData.ErrorMessageAdditional)
|
if (data.ErrorMessageAdditional)
|
||||||
{
|
{
|
||||||
this.submitErrorAdditional(oData.ErrorMessageAdditional);
|
this.submitErrorAdditional(data.ErrorMessageAdditional);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
this.submitError(getNotification(Notification.UnknownError));
|
||||||
this.submitErrorAdditional('');
|
this.submitErrorAdditional('');
|
||||||
}
|
}
|
||||||
|
|
||||||
}, this), this.email(), this.password(), this.isNew());
|
}, this.email(), this.password(), this.isNew());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}, function() {
|
}, () => !this.submitRequest());
|
||||||
return !this.submitRequest();
|
|
||||||
});
|
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Popup/Account', 'View/Popup/AddAccount', 'PopupsAddAccountViewModel'], AccountPopupView);
|
clearPopup() {
|
||||||
_.extend(AccountPopupView.prototype, AbstractView.prototype);
|
|
||||||
|
|
||||||
AccountPopupView.prototype.clearPopup = function()
|
|
||||||
{
|
|
||||||
this.isNew(true);
|
this.isNew(true);
|
||||||
|
|
||||||
this.email('');
|
this.email('');
|
||||||
|
|
@ -108,21 +102,20 @@ AccountPopupView.prototype.clearPopup = function()
|
||||||
this.submitRequest(false);
|
this.submitRequest(false);
|
||||||
this.submitError('');
|
this.submitError('');
|
||||||
this.submitErrorAdditional('');
|
this.submitErrorAdditional('');
|
||||||
};
|
}
|
||||||
|
|
||||||
AccountPopupView.prototype.onShow = function(oAccount)
|
onShow(account) {
|
||||||
{
|
|
||||||
this.clearPopup();
|
this.clearPopup();
|
||||||
if (oAccount && oAccount.canBeEdit())
|
if (account && account.canBeEdit())
|
||||||
{
|
{
|
||||||
this.isNew(false);
|
this.isNew(false);
|
||||||
this.email(oAccount.email);
|
this.email(account.email);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
AccountPopupView.prototype.onShowWithDelay = function()
|
onShowWithDelay() {
|
||||||
{
|
|
||||||
this.emailFocus(true);
|
this.emailFocus(true);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = AccountPopupView;
|
module.exports = AccountPopupView;
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,28 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
_ = require('_'),
|
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
import {StorageResultType, Notification} from 'Common/Enums';
|
||||||
Utils = require('Common/Utils'),
|
import {trim, isUnd, createCommand} from 'Common/Utils';
|
||||||
Consts = require('Common/Consts'),
|
import {RAINLOOP_TRIAL_KEY} from 'Common/Consts';
|
||||||
Translator = require('Common/Translator'),
|
import {i18n, getNotification} from 'Common/Translator';
|
||||||
|
|
||||||
Settings = require('Storage/Settings'),
|
import * as Settings from 'Storage/Settings';
|
||||||
Remote = require('Remote/Admin/Ajax'),
|
|
||||||
|
|
||||||
LicenseStore = require('Stores/Admin/License'),
|
import Remote from 'Remote/Admin/Ajax';
|
||||||
|
import LicenseStore from 'Stores/Admin/License';
|
||||||
|
|
||||||
kn = require('Knoin/Knoin'),
|
import {view, ViewType} from 'Knoin/Knoin';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||||
|
|
||||||
/**
|
@view({
|
||||||
* @constructor
|
name: 'View/Popup/Activate',
|
||||||
* @extends AbstractView
|
type: ViewType.Popup,
|
||||||
*/
|
templateID: 'PopupsActivate'
|
||||||
function ActivatePopupView()
|
})
|
||||||
|
class ActivatePopupView extends AbstractViewNext
|
||||||
{
|
{
|
||||||
AbstractView.call(this, 'Popups', 'PopupsActivate');
|
constructor() {
|
||||||
|
super();
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.domain = ko.observable('');
|
this.domain = ko.observable('');
|
||||||
this.key = ko.observable('');
|
this.key = ko.observable('');
|
||||||
|
|
@ -37,56 +35,54 @@ function ActivatePopupView()
|
||||||
this.activateText = ko.observable('');
|
this.activateText = ko.observable('');
|
||||||
this.activateText.isError = ko.observable(false);
|
this.activateText.isError = ko.observable(false);
|
||||||
|
|
||||||
this.htmlDescription = ko.computed(function() {
|
this.htmlDescription = ko.computed(() => i18n('POPUPS_ACTIVATE/HTML_DESC', {'DOMAIN': this.domain()}));
|
||||||
return Translator.i18n('POPUPS_ACTIVATE/HTML_DESC', {'DOMAIN': this.domain()});
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.key.subscribe(function() {
|
this.key.subscribe(() => {
|
||||||
this.activateText('');
|
this.activateText('');
|
||||||
this.activateText.isError(false);
|
this.activateText.isError(false);
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.activationSuccessed.subscribe(function(bValue) {
|
this.activationSuccessed.subscribe((value) => {
|
||||||
if (bValue)
|
if (value)
|
||||||
{
|
{
|
||||||
this.licenseTrigger(!this.licenseTrigger());
|
this.licenseTrigger(!this.licenseTrigger());
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.activateCommand = Utils.createCommand(this, function() {
|
this.activateCommand = createCommand(() => {
|
||||||
|
|
||||||
this.activateProcess(true);
|
this.activateProcess(true);
|
||||||
if (this.validateSubscriptionKey())
|
if (this.validateSubscriptionKey())
|
||||||
{
|
{
|
||||||
Remote.licensingActivate(function(sResult, oData) {
|
Remote.licensingActivate((sResult, oData) => {
|
||||||
|
|
||||||
self.activateProcess(false);
|
this.activateProcess(false);
|
||||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
if (StorageResultType.Success === sResult && oData.Result)
|
||||||
{
|
{
|
||||||
if (true === oData.Result)
|
if (true === oData.Result)
|
||||||
{
|
{
|
||||||
self.activationSuccessed(true);
|
this.activationSuccessed(true);
|
||||||
self.activateText(Translator.i18n('POPUPS_ACTIVATE/SUBS_KEY_ACTIVATED'));
|
this.activateText(i18n('POPUPS_ACTIVATE/SUBS_KEY_ACTIVATED'));
|
||||||
self.activateText.isError(false);
|
this.activateText.isError(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self.activateText(oData.Result);
|
this.activateText(oData.Result);
|
||||||
self.activateText.isError(true);
|
this.activateText.isError(true);
|
||||||
self.key.focus(true);
|
this.key.focus(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (oData.ErrorCode)
|
else if (oData.ErrorCode)
|
||||||
{
|
{
|
||||||
self.activateText(Translator.getNotification(oData.ErrorCode));
|
this.activateText(getNotification(oData.ErrorCode));
|
||||||
self.activateText.isError(true);
|
this.activateText.isError(true);
|
||||||
self.key.focus(true);
|
this.key.focus(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self.activateText(Translator.getNotification(Enums.Notification.UnknownError));
|
this.activateText(getNotification(Notification.UnknownError));
|
||||||
self.activateText.isError(true);
|
this.activateText.isError(true);
|
||||||
self.key.focus(true);
|
this.key.focus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, this.domain(), this.key());
|
}, this.domain(), this.key());
|
||||||
|
|
@ -94,50 +90,41 @@ function ActivatePopupView()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.activateProcess(false);
|
this.activateProcess(false);
|
||||||
this.activateText(Translator.i18n('POPUPS_ACTIVATE/ERROR_INVALID_SUBS_KEY'));
|
this.activateText(i18n('POPUPS_ACTIVATE/ERROR_INVALID_SUBS_KEY'));
|
||||||
this.activateText.isError(true);
|
this.activateText.isError(true);
|
||||||
this.key.focus(true);
|
this.key.focus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, function() {
|
}, () => !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed());
|
||||||
return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed();
|
|
||||||
});
|
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Popup/Activate', 'PopupsActivateViewModel'], ActivatePopupView);
|
onShow(isTrial) {
|
||||||
_.extend(ActivatePopupView.prototype, AbstractView.prototype);
|
|
||||||
|
|
||||||
ActivatePopupView.prototype.onShow = function(bTrial)
|
|
||||||
{
|
|
||||||
this.domain(Settings.settingsGet('AdminDomain'));
|
this.domain(Settings.settingsGet('AdminDomain'));
|
||||||
if (!this.activateProcess())
|
if (!this.activateProcess())
|
||||||
{
|
{
|
||||||
bTrial = Utils.isUnd(bTrial) ? false : !!bTrial;
|
isTrial = isUnd(isTrial) ? false : !!isTrial;
|
||||||
|
|
||||||
this.key(bTrial ? Consts.RAINLOOP_TRIAL_KEY : '');
|
this.key(isTrial ? RAINLOOP_TRIAL_KEY : '');
|
||||||
this.activateText('');
|
this.activateText('');
|
||||||
this.activateText.isError(false);
|
this.activateText.isError(false);
|
||||||
this.activationSuccessed(false);
|
this.activationSuccessed(false);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
ActivatePopupView.prototype.onShowWithDelay = function()
|
onShowWithDelay() {
|
||||||
{
|
|
||||||
if (!this.activateProcess())
|
if (!this.activateProcess())
|
||||||
{
|
{
|
||||||
this.key.focus(true);
|
this.key.focus(true);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
ActivatePopupView.prototype.validateSubscriptionKey = function()
|
validateSubscriptionKey() {
|
||||||
{
|
const value = this.key();
|
||||||
var sValue = this.key();
|
return '' === value || RAINLOOP_TRIAL_KEY === value || !!(/^RL[\d]+-[A-Z0-9\-]+Z$/).test(trim(value));
|
||||||
return '' === sValue || Consts.RAINLOOP_TRIAL_KEY === sValue || !!(/^RL[\d]+-[A-Z0-9\-]+Z$/).test(Utils.trim(sValue));
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = ActivatePopupView;
|
module.exports = ActivatePopupView;
|
||||||
|
|
|
||||||
|
|
@ -1,67 +1,82 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
_ = require('_'),
|
import {trim, delegateRun, createCommand, log} from 'Common/Utils';
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
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'),
|
import {view, ViewType} from 'Knoin/Knoin';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||||
|
|
||||||
/**
|
@view({
|
||||||
* @constructor
|
name: 'View/Popup/AddOpenPgpKey',
|
||||||
* @extends AbstractView
|
type: ViewType.Popup,
|
||||||
*/
|
templateID: 'PopupsAddOpenPgpKey'
|
||||||
function AddOpenPgpKeyPopupView()
|
})
|
||||||
|
class AddOpenPgpKeyPopupView extends AbstractViewNext
|
||||||
{
|
{
|
||||||
AbstractView.call(this, 'Popups', 'PopupsAddOpenPgpKey');
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
this.key = ko.observable('');
|
this.key = ko.observable('');
|
||||||
this.key.error = ko.observable(false);
|
|
||||||
this.key.focus = ko.observable(false);
|
this.key.focus = ko.observable(false);
|
||||||
|
this.key.error = ko.observable(false);
|
||||||
|
this.key.errorMessage = ko.observable('');
|
||||||
|
|
||||||
this.key.subscribe(function() {
|
this.key.subscribe(() => {
|
||||||
this.key.error(false);
|
this.key.error(false);
|
||||||
}, this);
|
this.key.errorMessage('');
|
||||||
|
});
|
||||||
|
|
||||||
this.addOpenPgpKeyCommand = Utils.createCommand(this, function() {
|
this.addOpenPgpKeyCommand = createCommand(() => {
|
||||||
|
|
||||||
var
|
const
|
||||||
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,
|
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;
|
openpgpKeyring = PgpStore.openpgpKeyring;
|
||||||
|
|
||||||
|
let keyTrimmed = trim(this.key());
|
||||||
|
|
||||||
if (/[\n]/.test(keyTrimmed))
|
if (/[\n]/.test(keyTrimmed))
|
||||||
{
|
{
|
||||||
keyTrimmed = keyTrimmed.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n');
|
keyTrimmed = keyTrimmed.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.key.error('' === keyTrimmed);
|
this.key.error('' === keyTrimmed);
|
||||||
|
this.key.errorMessage('');
|
||||||
|
|
||||||
if (!openpgpKeyring || this.key.error())
|
if (!openpgpKeyring || this.key.error())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var done = false;
|
let
|
||||||
|
match = null,
|
||||||
|
count = 30,
|
||||||
|
done = false;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
var match = reg.exec(keyTrimmed);
|
match = reg.exec(keyTrimmed);
|
||||||
if (match && 0 < count)
|
if (match && 0 < count)
|
||||||
{
|
{
|
||||||
if (match[0] && match[1] && match[2] && match[1] === match[2])
|
if (match[0] && match[1] && match[2] && match[1] === match[2])
|
||||||
{
|
{
|
||||||
|
let err = null;
|
||||||
if ('PRIVATE' === match[1])
|
if ('PRIVATE' === match[1])
|
||||||
{
|
{
|
||||||
openpgpKeyring.privateKeys.importKey(match[0]);
|
err = openpgpKeyring.privateKeys.importKey(match[0]);
|
||||||
}
|
}
|
||||||
else if ('PUBLIC' === match[1])
|
else if ('PUBLIC' === match[1])
|
||||||
{
|
{
|
||||||
openpgpKeyring.publicKeys.importKey(match[0]);
|
err = openpgpKeyring.publicKeys.importKey(match[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
this.key.error(true);
|
||||||
|
this.key.errorMessage(err && err[0] ? '' + err[0] : '');
|
||||||
|
log(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,32 +92,31 @@ function AddOpenPgpKeyPopupView()
|
||||||
|
|
||||||
openpgpKeyring.store();
|
openpgpKeyring.store();
|
||||||
|
|
||||||
require('App/User').default.reloadOpenPgpKeys();
|
getApp().reloadOpenPgpKeys();
|
||||||
Utils.delegateRun(this, 'cancelCommand');
|
|
||||||
|
|
||||||
return true;
|
if (this.key.error())
|
||||||
});
|
{
|
||||||
|
return false;
|
||||||
kn.constructorEnd(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Popup/AddOpenPgpKey', 'PopupsAddOpenPgpKeyViewModel'], AddOpenPgpKeyPopupView);
|
delegateRun(this, 'cancelCommand');
|
||||||
_.extend(AddOpenPgpKeyPopupView.prototype, AbstractView.prototype);
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
AddOpenPgpKeyPopupView.prototype.clearPopup = function()
|
clearPopup() {
|
||||||
{
|
|
||||||
this.key('');
|
this.key('');
|
||||||
this.key.error(false);
|
this.key.error(false);
|
||||||
};
|
this.key.errorMessage('');
|
||||||
|
}
|
||||||
|
|
||||||
AddOpenPgpKeyPopupView.prototype.onShow = function()
|
onShow() {
|
||||||
{
|
|
||||||
this.clearPopup();
|
this.clearPopup();
|
||||||
};
|
}
|
||||||
|
|
||||||
AddOpenPgpKeyPopupView.prototype.onShowWithDelay = function()
|
onShowWithDelay() {
|
||||||
{
|
|
||||||
this.key.focus(true);
|
this.key.focus(true);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = AddOpenPgpKeyPopupView;
|
module.exports = AddOpenPgpKeyPopupView;
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,25 @@
|
||||||
|
|
||||||
var
|
import _ from '_';
|
||||||
_ = require('_'),
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Utils = require('Common/Utils'),
|
import {trim, createCommand} from 'Common/Utils';
|
||||||
Translator = require('Common/Translator'),
|
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'),
|
import {view, ViewType} from 'Knoin/Knoin';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||||
|
|
||||||
/**
|
@view({
|
||||||
* @constructor
|
name: 'View/Popup/AdvancedSearch',
|
||||||
* @extends AbstractView
|
type: ViewType.Popup,
|
||||||
*/
|
templateID: 'PopupsAdvancedSearch'
|
||||||
function AdvancedSearchPopupView()
|
})
|
||||||
|
class AdvancedSearchPopupView extends AbstractViewNext
|
||||||
{
|
{
|
||||||
AbstractView.call(this, 'Popups', 'PopupsAdvancedSearch');
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
this.fromFocus = ko.observable(false);
|
this.fromFocus = ko.observable(false);
|
||||||
|
|
||||||
|
|
@ -31,135 +33,121 @@ function AdvancedSearchPopupView()
|
||||||
this.starred = ko.observable(false);
|
this.starred = ko.observable(false);
|
||||||
this.unseen = ko.observable(false);
|
this.unseen = ko.observable(false);
|
||||||
|
|
||||||
this.searchCommand = Utils.createCommand(this, function() {
|
this.searchCommand = createCommand(() => {
|
||||||
|
const search = this.buildSearchString();
|
||||||
var sSearch = this.buildSearchString();
|
if ('' !== search)
|
||||||
if ('' !== sSearch)
|
|
||||||
{
|
{
|
||||||
MessageStore.mainMessageListSearch(sSearch);
|
MessageStore.mainMessageListSearch(search);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cancelCommand();
|
this.cancelCommand();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.selectedDates = ko.computed(function() {
|
this.selectedDates = ko.computed(() => {
|
||||||
Translator.trigger();
|
translatorTrigger();
|
||||||
return [
|
return [
|
||||||
{'id': -1, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_ALL')},
|
{id: -1, name: i18n('SEARCH/LABEL_ADV_DATE_ALL')},
|
||||||
{'id': 3, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_3_DAYS')},
|
{id: 3, name: i18n('SEARCH/LABEL_ADV_DATE_3_DAYS')},
|
||||||
{'id': 7, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_7_DAYS')},
|
{id: 7, name: i18n('SEARCH/LABEL_ADV_DATE_7_DAYS')},
|
||||||
{'id': 30, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_MONTH')},
|
{id: 30, name: i18n('SEARCH/LABEL_ADV_DATE_MONTH')},
|
||||||
{'id': 90, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_3_MONTHS')},
|
{id: 90, name: i18n('SEARCH/LABEL_ADV_DATE_3_MONTHS')},
|
||||||
{'id': 180, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_6_MONTHS')},
|
{id: 180, name: i18n('SEARCH/LABEL_ADV_DATE_6_MONTHS')},
|
||||||
{'id': 365, 'name': Translator.i18n('SEARCH/LABEL_ADV_DATE_YEAR')}
|
{id: 365, name: i18n('SEARCH/LABEL_ADV_DATE_YEAR')}
|
||||||
];
|
];
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Popup/AdvancedSearch', 'PopupsAdvancedSearchViewModel'], AdvancedSearchPopupView);
|
parseSearchStringValue(search) {
|
||||||
_.extend(AdvancedSearchPopupView.prototype, AbstractView.prototype);
|
const parts = (search || '').split(/[\s]+/g);
|
||||||
|
_.each(parts, (part) => {
|
||||||
AdvancedSearchPopupView.prototype.parseSearchStringValue = function(search)
|
|
||||||
{
|
|
||||||
var
|
|
||||||
self = this,
|
|
||||||
parts = (search || '').split(/[\s]+/g);
|
|
||||||
|
|
||||||
_.each(parts, function(part) {
|
|
||||||
switch (part)
|
switch (part)
|
||||||
{
|
{
|
||||||
case 'has:attachment':
|
case 'has:attachment':
|
||||||
self.hasAttachment(true);
|
this.hasAttachment(true);
|
||||||
break;
|
break;
|
||||||
case 'is:unseen,flagged':
|
case 'is:unseen,flagged':
|
||||||
self.starred(true);
|
this.starred(true);
|
||||||
/* falls through */
|
/* falls through */
|
||||||
case 'is:unseen':
|
case 'is:unseen':
|
||||||
self.unseen(true);
|
this.unseen(true);
|
||||||
break;
|
break;
|
||||||
// no default
|
// no default
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
AdvancedSearchPopupView.prototype.buildSearchStringValue = function(sValue)
|
|
||||||
{
|
|
||||||
if (-1 < sValue.indexOf(' '))
|
|
||||||
{
|
|
||||||
sValue = '"' + sValue + '"';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sValue;
|
buildSearchStringValue(value) {
|
||||||
};
|
if (-1 < value.indexOf(' '))
|
||||||
|
|
||||||
AdvancedSearchPopupView.prototype.buildSearchString = function()
|
|
||||||
{
|
{
|
||||||
var
|
value = '"' + value + '"';
|
||||||
aResult = [],
|
}
|
||||||
sFrom = Utils.trim(this.from()),
|
return value;
|
||||||
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)
|
buildSearchString() {
|
||||||
|
const
|
||||||
|
result = [],
|
||||||
|
from_ = trim(this.from()),
|
||||||
|
to = trim(this.to()),
|
||||||
|
subject = trim(this.subject()),
|
||||||
|
text = trim(this.text()),
|
||||||
|
isPart = [],
|
||||||
|
hasPart = [];
|
||||||
|
|
||||||
|
if (from_ && '' !== from_)
|
||||||
{
|
{
|
||||||
aResult.push('to:' + this.buildSearchStringValue(sTo));
|
result.push('from:' + this.buildSearchStringValue(from_));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sSubject && '' !== sSubject)
|
if (to && '' !== to)
|
||||||
{
|
{
|
||||||
aResult.push('subject:' + this.buildSearchStringValue(sSubject));
|
result.push('to:' + this.buildSearchStringValue(to));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subject && '' !== subject)
|
||||||
|
{
|
||||||
|
result.push('subject:' + this.buildSearchStringValue(subject));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasAttachment())
|
if (this.hasAttachment())
|
||||||
{
|
{
|
||||||
aHas.push('attachment');
|
hasPart.push('attachment');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.unseen())
|
if (this.unseen())
|
||||||
{
|
{
|
||||||
aIs.push('unseen');
|
isPart.push('unseen');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.starred())
|
if (this.starred())
|
||||||
{
|
{
|
||||||
aIs.push('flagged');
|
isPart.push('flagged');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < aHas.length)
|
if (0 < hasPart.length)
|
||||||
{
|
{
|
||||||
aResult.push('has:' + aHas.join(','));
|
result.push('has:' + hasPart.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < aIs.length)
|
if (0 < isPart.length)
|
||||||
{
|
{
|
||||||
aResult.push('is:' + aIs.join(','));
|
result.push('is:' + isPart.join(','));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1 < this.selectedDateValue())
|
if (-1 < this.selectedDateValue())
|
||||||
{
|
{
|
||||||
aResult.push('date:' + require('Common/Momentor').searchSubtractFormatDateHelper(this.selectedDateValue()) + '/');
|
result.push('date:' + searchSubtractFormatDateHelper(this.selectedDateValue()) + '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sText && '' !== sText)
|
if (text && '' !== text)
|
||||||
{
|
{
|
||||||
aResult.push('text:' + this.buildSearchStringValue(sText));
|
result.push('text:' + this.buildSearchStringValue(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Utils.trim(aResult.join(' '));
|
return trim(result.join(' '));
|
||||||
};
|
}
|
||||||
|
|
||||||
AdvancedSearchPopupView.prototype.clearPopup = function()
|
clearPopup() {
|
||||||
{
|
|
||||||
this.from('');
|
this.from('');
|
||||||
this.to('');
|
this.to('');
|
||||||
this.subject('');
|
this.subject('');
|
||||||
|
|
@ -171,17 +159,16 @@ AdvancedSearchPopupView.prototype.clearPopup = function()
|
||||||
this.unseen(false);
|
this.unseen(false);
|
||||||
|
|
||||||
this.fromFocus(true);
|
this.fromFocus(true);
|
||||||
};
|
}
|
||||||
|
|
||||||
AdvancedSearchPopupView.prototype.onShow = function(search)
|
onShow(search) {
|
||||||
{
|
|
||||||
this.clearPopup();
|
this.clearPopup();
|
||||||
this.parseSearchStringValue(search);
|
this.parseSearchStringValue(search);
|
||||||
};
|
}
|
||||||
|
|
||||||
AdvancedSearchPopupView.prototype.onShowWithDelay = function()
|
onShowWithDelay() {
|
||||||
{
|
|
||||||
this.fromFocus(true);
|
this.fromFocus(true);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = AdvancedSearchPopupView;
|
module.exports = AdvancedSearchPopupView;
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
|
|
||||||
var
|
import ko from 'ko';
|
||||||
_ = require('_'),
|
import key from 'key';
|
||||||
ko = require('ko'),
|
|
||||||
key = require('key'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
import {KeyState} from 'Common/Enums';
|
||||||
Utils = require('Common/Utils'),
|
import {isFunc} from 'Common/Utils';
|
||||||
Translator = require('Common/Translator'),
|
import {i18n} from 'Common/Translator';
|
||||||
|
|
||||||
kn = require('Knoin/Knoin'),
|
import {view, ViewType} from 'Knoin/Knoin';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||||
|
|
||||||
/**
|
@view({
|
||||||
* @constructor
|
name: 'View/Popup/Ask',
|
||||||
* @extends AbstractView
|
type: ViewType.Popup,
|
||||||
*/
|
templateID: 'PopupsAsk'
|
||||||
function AskPopupView()
|
})
|
||||||
|
class AskPopupView extends AbstractViewNext
|
||||||
{
|
{
|
||||||
AbstractView.call(this, 'Popups', 'PopupsAsk');
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
this.askDesc = ko.observable('');
|
this.askDesc = ko.observable('');
|
||||||
this.yesButton = ko.observable('');
|
this.yesButton = ko.observable('');
|
||||||
|
|
@ -31,46 +31,38 @@ function AskPopupView()
|
||||||
|
|
||||||
this.bFocusYesOnShow = true;
|
this.bFocusYesOnShow = true;
|
||||||
this.bDisabeCloseOnEsc = true;
|
this.bDisabeCloseOnEsc = true;
|
||||||
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
|
this.sDefaultKeyScope = KeyState.PopupAsk;
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Popup/Ask', 'PopupsAskViewModel'], AskPopupView);
|
clearPopup() {
|
||||||
_.extend(AskPopupView.prototype, AbstractView.prototype);
|
|
||||||
|
|
||||||
AskPopupView.prototype.clearPopup = function()
|
|
||||||
{
|
|
||||||
this.askDesc('');
|
this.askDesc('');
|
||||||
this.yesButton(Translator.i18n('POPUPS_ASK/BUTTON_YES'));
|
this.yesButton(i18n('POPUPS_ASK/BUTTON_YES'));
|
||||||
this.noButton(Translator.i18n('POPUPS_ASK/BUTTON_NO'));
|
this.noButton(i18n('POPUPS_ASK/BUTTON_NO'));
|
||||||
|
|
||||||
this.yesFocus(false);
|
this.yesFocus(false);
|
||||||
this.noFocus(false);
|
this.noFocus(false);
|
||||||
|
|
||||||
this.fYesAction = null;
|
this.fYesAction = null;
|
||||||
this.fNoAction = null;
|
this.fNoAction = null;
|
||||||
};
|
}
|
||||||
|
|
||||||
AskPopupView.prototype.yesClick = function()
|
yesClick() {
|
||||||
{
|
|
||||||
this.cancelCommand();
|
this.cancelCommand();
|
||||||
|
|
||||||
if (Utils.isFunc(this.fYesAction))
|
if (isFunc(this.fYesAction))
|
||||||
{
|
{
|
||||||
this.fYesAction.call(null);
|
this.fYesAction.call(null);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
AskPopupView.prototype.noClick = function()
|
noClick() {
|
||||||
{
|
|
||||||
this.cancelCommand();
|
this.cancelCommand();
|
||||||
|
|
||||||
if (Utils.isFunc(this.fNoAction))
|
if (isFunc(this.fNoAction))
|
||||||
{
|
{
|
||||||
this.fNoAction.call(null);
|
this.fNoAction.call(null);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} sAskDesc
|
* @param {string} sAskDesc
|
||||||
|
|
@ -78,42 +70,40 @@ AskPopupView.prototype.noClick = function()
|
||||||
* @param {Function=} fNoFunc
|
* @param {Function=} fNoFunc
|
||||||
* @param {string=} sYesButton
|
* @param {string=} sYesButton
|
||||||
* @param {string=} sNoButton
|
* @param {string=} sNoButton
|
||||||
* @param {boolean=} bFocusYesOnShow
|
* @param {boolean=} bFocusYesOnShow = true
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
AskPopupView.prototype.onShow = function(sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton, bFocusYesOnShow)
|
onShow(askDesc, fYesFunc = null, fNoFunc = null, yesButton = '', noButton = '', isFocusYesOnShow = true) {
|
||||||
{
|
|
||||||
this.clearPopup();
|
this.clearPopup();
|
||||||
|
|
||||||
this.fYesAction = fYesFunc || null;
|
this.fYesAction = fYesFunc || null;
|
||||||
this.fNoAction = fNoFunc || null;
|
this.fNoAction = fNoFunc || null;
|
||||||
|
|
||||||
this.askDesc(sAskDesc || '');
|
this.askDesc(askDesc || '');
|
||||||
|
|
||||||
if (sYesButton)
|
if (yesButton)
|
||||||
{
|
{
|
||||||
this.yesButton(sYesButton);
|
this.yesButton(yesButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sNoButton)
|
if (noButton)
|
||||||
{
|
{
|
||||||
this.noButton(sNoButton);
|
this.noButton(noButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bFocusYesOnShow = Utils.isUnd(bFocusYesOnShow) ? true : !!bFocusYesOnShow;
|
this.bFocusYesOnShow = !!isFocusYesOnShow;
|
||||||
};
|
}
|
||||||
|
|
||||||
AskPopupView.prototype.onShowWithDelay = function()
|
onShowWithDelay() {
|
||||||
{
|
|
||||||
if (this.bFocusYesOnShow)
|
if (this.bFocusYesOnShow)
|
||||||
{
|
{
|
||||||
this.yesFocus(true);
|
this.yesFocus(true);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
AskPopupView.prototype.onBuild = function()
|
onBuild() {
|
||||||
{
|
key('tab, shift+tab, right, left', KeyState.PopupAsk, () => {
|
||||||
key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function() {
|
|
||||||
if (this.yesFocus())
|
if (this.yesFocus())
|
||||||
{
|
{
|
||||||
this.noFocus(true);
|
this.noFocus(true);
|
||||||
|
|
@ -123,12 +113,13 @@ AskPopupView.prototype.onBuild = function()
|
||||||
this.yesFocus(true);
|
this.yesFocus(true);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}, this));
|
});
|
||||||
|
|
||||||
key('esc', Enums.KeyState.PopupAsk, _.bind(function() {
|
key('esc', KeyState.PopupAsk, () => {
|
||||||
this.noClick();
|
this.noClick();
|
||||||
return false;
|
return false;
|
||||||
}, this));
|
});
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = AskPopupView;
|
module.exports = AskPopupView;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,33 +1,37 @@
|
||||||
|
|
||||||
var
|
import _ from '_';
|
||||||
_ = require('_'),
|
import $ from '$';
|
||||||
$ = require('$'),
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
import key from 'key';
|
||||||
key = require('key'),
|
|
||||||
|
|
||||||
Utils = require('Common/Utils'),
|
import {
|
||||||
Enums = require('Common/Enums'),
|
inArray, createCommand,
|
||||||
Translator = require('Common/Translator'),
|
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'),
|
import {EmailModel} from 'Model/Email';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
|
||||||
|
|
||||||
/**
|
import {view, ViewType} from 'Knoin/Knoin';
|
||||||
* @constructor
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||||
* @extends AbstractView
|
|
||||||
*/
|
@view({
|
||||||
function ComposeOpenPgpPopupView()
|
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('');
|
||||||
|
|
||||||
|
|
@ -45,36 +49,41 @@ function ComposeOpenPgpPopupView()
|
||||||
this.signKey = ko.observable(null);
|
this.signKey = ko.observable(null);
|
||||||
this.encryptKeys = ko.observableArray([]);
|
this.encryptKeys = ko.observableArray([]);
|
||||||
|
|
||||||
this.encryptKeysView = ko.computed(function() {
|
this.encryptKeysView = ko.computed(
|
||||||
return _.compact(_.map(this.encryptKeys(), function(oKey) {
|
() => _.compact(_.map(this.encryptKeys(), (oKey) => (oKey ? oKey.key : null)))
|
||||||
return oKey ? oKey.key : null;
|
);
|
||||||
|
|
||||||
|
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() + ') ' + user,
|
||||||
|
'key': oKey,
|
||||||
|
'class': iIndex % 2 ? 'odd' : 'even'
|
||||||
}));
|
}));
|
||||||
}, 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 {
|
|
||||||
'id': oKey.guid,
|
|
||||||
'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + sUser,
|
|
||||||
'key': oKey,
|
|
||||||
'class': iIndex % 2 ? 'odd' : 'even'
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}), true));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.publicKeysOptions = ko.computed(function() {
|
return _.compact(_.flatten(opts, true));
|
||||||
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.publicKeysOptions = ko.computed(() => {
|
||||||
|
const opts = _.map(PgpStore.openpgpkeysPublic(), (oKey, index) => {
|
||||||
|
if (-1 < inArray(oKey, this.encryptKeysView()))
|
||||||
|
{
|
||||||
|
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));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.submitRequest = ko.observable(false);
|
this.submitRequest = ko.observable(false);
|
||||||
|
|
@ -82,261 +91,246 @@ function ComposeOpenPgpPopupView()
|
||||||
this.resultCallback = null;
|
this.resultCallback = null;
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
this.doCommand = Utils.createCommand(this, function() {
|
this.doCommand = createCommand(() => {
|
||||||
|
|
||||||
var
|
let
|
||||||
bResult = true,
|
result = true,
|
||||||
oPrivateKey = null,
|
privateKey = null,
|
||||||
aPublicKeys = [];
|
aPublicKeys = [];
|
||||||
|
|
||||||
this.submitRequest(true);
|
this.submitRequest(true);
|
||||||
|
|
||||||
if (bResult && this.sign())
|
if (result && this.sign())
|
||||||
{
|
{
|
||||||
if (!this.signKey())
|
if (!this.signKey())
|
||||||
{
|
{
|
||||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||||
bResult = false;
|
result = false;
|
||||||
}
|
}
|
||||||
else if (!this.signKey().key)
|
else if (!this.signKey().key)
|
||||||
{
|
{
|
||||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
|
||||||
'EMAIL': this.signKey().email
|
'EMAIL': this.signKey().email
|
||||||
}));
|
}));
|
||||||
|
|
||||||
bResult = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bResult)
|
if (result)
|
||||||
{
|
{
|
||||||
var aPrivateKeys = this.signKey().key.getNativeKeys();
|
const privateKeys = this.signKey().key.getNativeKeys();
|
||||||
oPrivateKey = aPrivateKeys[0] || null;
|
privateKey = privateKeys[0] || null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (oPrivateKey)
|
if (privateKey)
|
||||||
{
|
{
|
||||||
oPrivateKey.decrypt(Utils.pString(this.password()));
|
privateKey.decrypt(pString(this.password()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
oPrivateKey = null;
|
privateKey = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oPrivateKey)
|
if (!privateKey)
|
||||||
{
|
{
|
||||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
this.notification(i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND'));
|
||||||
bResult = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bResult && this.encrypt())
|
if (result && this.encrypt())
|
||||||
{
|
{
|
||||||
if (0 === this.encryptKeys().length)
|
if (0 === this.encryptKeys().length)
|
||||||
{
|
{
|
||||||
this.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND'));
|
this.notification(i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND'));
|
||||||
bResult = false;
|
result = false;
|
||||||
}
|
}
|
||||||
else if (this.encryptKeys())
|
else if (this.encryptKeys())
|
||||||
{
|
{
|
||||||
aPublicKeys = [];
|
aPublicKeys = [];
|
||||||
|
|
||||||
_.each(this.encryptKeys(), function(oKey) {
|
_.each(this.encryptKeys(), (oKey) => {
|
||||||
if (oKey && oKey.key)
|
if (oKey && oKey.key)
|
||||||
{
|
{
|
||||||
aPublicKeys = aPublicKeys.concat(_.compact(_.flatten(oKey.key.getNativeKeys())));
|
aPublicKeys = aPublicKeys.concat(_.compact(_.flatten(oKey.key.getNativeKeys())));
|
||||||
}
|
}
|
||||||
else if (oKey && oKey.email)
|
else if (oKey && oKey.email)
|
||||||
{
|
{
|
||||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
this.notification(i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
|
||||||
'EMAIL': oKey.email
|
'EMAIL': oKey.email
|
||||||
}));
|
}));
|
||||||
|
|
||||||
bResult = false;
|
result = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (bResult && (0 === aPublicKeys.length || this.encryptKeys().length !== aPublicKeys.length))
|
if (result && (0 === aPublicKeys.length || this.encryptKeys().length !== aPublicKeys.length))
|
||||||
{
|
{
|
||||||
bResult = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bResult && self.resultCallback)
|
if (result && this.resultCallback)
|
||||||
{
|
{
|
||||||
_.delay(function() {
|
_.delay(() => {
|
||||||
|
|
||||||
var oPromise = null;
|
let pgpPromise = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (oPrivateKey && 0 === aPublicKeys.length)
|
if (privateKey && 0 === aPublicKeys.length)
|
||||||
{
|
{
|
||||||
oPromise = PgpStore.openpgp.sign({
|
pgpPromise = PgpStore.openpgp.sign({
|
||||||
data: self.text(),
|
data: this.text(),
|
||||||
privateKeys: [oPrivateKey]
|
privateKeys: [privateKey]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (oPrivateKey && 0 < aPublicKeys.length)
|
else if (privateKey && 0 < aPublicKeys.length)
|
||||||
{
|
{
|
||||||
oPromise = PgpStore.openpgp.encrypt({
|
pgpPromise = PgpStore.openpgp.encrypt({
|
||||||
data: self.text(),
|
data: this.text(),
|
||||||
publicKeys: aPublicKeys,
|
publicKeys: aPublicKeys,
|
||||||
privateKeys: [oPrivateKey]
|
privateKeys: [privateKey]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (!oPrivateKey && 0 < aPublicKeys.length)
|
else if (!privateKey && 0 < aPublicKeys.length)
|
||||||
{
|
{
|
||||||
oPromise = PgpStore.openpgp.encrypt({
|
pgpPromise = PgpStore.openpgp.encrypt({
|
||||||
data: self.text(),
|
data: this.text(),
|
||||||
publicKeys: aPublicKeys
|
publicKeys: aPublicKeys
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
Utils.log(e);
|
log(e);
|
||||||
|
|
||||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||||
'ERROR': '' + e
|
'ERROR': '' + e
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oPromise)
|
if (pgpPromise)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
oPromise.then(function(mData) {
|
pgpPromise.then((mData) => {
|
||||||
|
this.resultCallback(mData.data);
|
||||||
self.resultCallback(mData.data);
|
this.cancelCommand();
|
||||||
self.cancelCommand();
|
}).catch((e) => {
|
||||||
|
this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||||
}).then(null, function(e) {
|
|
||||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
|
||||||
'ERROR': '' + e
|
'ERROR': '' + e
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
self.notification(Translator.i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
this.notification(i18n('PGP_NOTIFICATIONS/PGP_ERROR', {
|
||||||
'ERROR': '' + e
|
'ERROR': '' + e
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.submitRequest(false);
|
this.submitRequest(false);
|
||||||
|
|
||||||
}, Enums.Magics.Time20ms);
|
}, Magics.Time20ms);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self.submitRequest(false);
|
this.submitRequest(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bResult;
|
return result;
|
||||||
|
|
||||||
}, function() {
|
}, () => !this.submitRequest() && (this.sign() || this.encrypt()));
|
||||||
return !this.submitRequest() && (this.sign() || this.encrypt());
|
|
||||||
});
|
|
||||||
|
|
||||||
this.selectCommand = Utils.createCommand(this, function() {
|
this.selectCommand = createCommand(() => {
|
||||||
|
|
||||||
var
|
const
|
||||||
sKeyId = this.selectedPrivateKey(),
|
keyId = this.selectedPrivateKey(),
|
||||||
oOption = sKeyId ? _.find(this.privateKeysOptions(), function(oItem) {
|
option = keyId ? _.find(this.privateKeysOptions(), (oItem) => oItem && keyId === oItem.id) : null;
|
||||||
return oItem && sKeyId === oItem.id;
|
|
||||||
}) : null;
|
|
||||||
|
|
||||||
if (oOption)
|
if (option)
|
||||||
{
|
{
|
||||||
this.signKey({
|
this.signKey({
|
||||||
'empty': !oOption.key,
|
'empty': !option.key,
|
||||||
'selected': ko.observable(!!oOption.key),
|
'selected': ko.observable(!!option.key),
|
||||||
'users': oOption.key.users,
|
'users': option.key.users,
|
||||||
'hash': oOption.key.id.substr(-8).toUpperCase(),
|
'hash': option.key.id.substr(-8).toUpperCase(),
|
||||||
'key': oOption.key
|
'key': option.key
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addCommand = Utils.createCommand(this, function() {
|
this.addCommand = createCommand(() => {
|
||||||
|
|
||||||
var
|
const
|
||||||
sKeyId = this.selectedPublicKey(),
|
keyId = this.selectedPublicKey(),
|
||||||
aKeys = this.encryptKeys(),
|
keys = this.encryptKeys(),
|
||||||
oOption = sKeyId ? _.find(this.publicKeysOptions(), function(oItem) {
|
option = keyId ? _.find(this.publicKeysOptions(), (item) => (item && keyId === item.id)) : null;
|
||||||
return oItem && sKeyId === oItem.id;
|
|
||||||
}) : null;
|
|
||||||
|
|
||||||
if (oOption)
|
if (option)
|
||||||
{
|
{
|
||||||
aKeys.push({
|
keys.push({
|
||||||
'empty': !oOption.key,
|
'empty': !option.key,
|
||||||
'selected': ko.observable(!!oOption.key),
|
'selected': ko.observable(!!option.key),
|
||||||
'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== oOption.key.id),
|
'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== option.key.id),
|
||||||
'users': oOption.key.users,
|
'users': option.key.users,
|
||||||
'hash': oOption.key.id.substr(-8).toUpperCase(),
|
'hash': option.key.id.substr(-8).toUpperCase(),
|
||||||
'key': oOption.key
|
'key': option.key
|
||||||
});
|
});
|
||||||
|
|
||||||
this.encryptKeys(aKeys);
|
this.encryptKeys(keys);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.updateCommand = Utils.createCommand(this, function() {
|
this.updateCommand = createCommand(() => {
|
||||||
_.each(this.encryptKeys(), function(oKey) {
|
_.each(this.encryptKeys(), (oKey) => {
|
||||||
oKey.removable(!self.sign() || !self.signKey() || self.signKey().key.id !== oKey.key.id);
|
oKey.removable(!this.sign() || !this.signKey() || this.signKey().key.id !== oKey.key.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.selectedPrivateKey.subscribe(function(sValue) {
|
this.selectedPrivateKey.subscribe((value) => {
|
||||||
if (sValue)
|
if (value)
|
||||||
{
|
{
|
||||||
this.selectCommand();
|
this.selectCommand();
|
||||||
this.updateCommand();
|
this.updateCommand();
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.selectedPublicKey.subscribe(function(sValue) {
|
this.selectedPublicKey.subscribe((value) => {
|
||||||
if (sValue)
|
if (value)
|
||||||
{
|
{
|
||||||
this.addCommand();
|
this.addCommand();
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP;
|
this.sDefaultKeyScope = KeyState.PopupComposeOpenPGP;
|
||||||
|
|
||||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
this.defautOptionsAfterRender = defautOptionsAfterRender;
|
||||||
|
|
||||||
this.addOptionClass = function(oDomOption, oItem) {
|
this.addOptionClass = (domOption, item) => {
|
||||||
|
|
||||||
self.defautOptionsAfterRender(oDomOption, oItem);
|
this.defautOptionsAfterRender(domOption, item);
|
||||||
|
|
||||||
if (oItem && !Utils.isUnd(oItem.class) && oDomOption)
|
if (item && !isUnd(item.class) && domOption)
|
||||||
{
|
{
|
||||||
$(oDomOption).addClass(oItem.class);
|
$(domOption).addClass(item.class);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.deletePublickKey = _.bind(this.deletePublickKey, this);
|
this.deletePublickKey = _.bind(this.deletePublickKey, this);
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Popup/ComposeOpenPgp', 'PopupsComposeOpenPgpViewModel'], ComposeOpenPgpPopupView);
|
deletePublickKey(publicKey) {
|
||||||
_.extend(ComposeOpenPgpPopupView.prototype, AbstractView.prototype);
|
this.encryptKeys.remove(publicKey);
|
||||||
|
}
|
||||||
|
|
||||||
ComposeOpenPgpPopupView.prototype.deletePublickKey = function(oKey)
|
clearPopup() {
|
||||||
{
|
|
||||||
this.encryptKeys.remove(oKey);
|
|
||||||
};
|
|
||||||
|
|
||||||
ComposeOpenPgpPopupView.prototype.clearPopup = function()
|
|
||||||
{
|
|
||||||
this.notification('');
|
this.notification('');
|
||||||
|
|
||||||
this.sign(false);
|
this.sign(false);
|
||||||
|
|
@ -351,12 +345,10 @@ ComposeOpenPgpPopupView.prototype.clearPopup = function()
|
||||||
this.text('');
|
this.text('');
|
||||||
|
|
||||||
this.resultCallback = null;
|
this.resultCallback = null;
|
||||||
};
|
}
|
||||||
|
|
||||||
ComposeOpenPgpPopupView.prototype.onBuild = function()
|
|
||||||
{
|
|
||||||
key('tab,shift+tab', Enums.KeyState.PopupComposeOpenPGP, _.bind(function() {
|
|
||||||
|
|
||||||
|
onBuild() {
|
||||||
|
key('tab,shift+tab', KeyState.PopupComposeOpenPGP, () => {
|
||||||
switch (true)
|
switch (true)
|
||||||
{
|
{
|
||||||
case this.password.focus():
|
case this.password.focus():
|
||||||
|
|
@ -367,19 +359,15 @@ ComposeOpenPgpPopupView.prototype.onBuild = function()
|
||||||
break;
|
break;
|
||||||
// no default
|
// no default
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}, this));
|
onHideWithDelay() {
|
||||||
};
|
|
||||||
|
|
||||||
ComposeOpenPgpPopupView.prototype.onHideWithDelay = function()
|
|
||||||
{
|
|
||||||
this.clearPopup();
|
this.clearPopup();
|
||||||
};
|
}
|
||||||
|
|
||||||
ComposeOpenPgpPopupView.prototype.onShowWithDelay = function()
|
onShowWithDelay() {
|
||||||
{
|
|
||||||
if (this.sign())
|
if (this.sign())
|
||||||
{
|
{
|
||||||
this.password.focus(true);
|
this.password.focus(true);
|
||||||
|
|
@ -388,54 +376,54 @@ ComposeOpenPgpPopupView.prototype.onShowWithDelay = function()
|
||||||
{
|
{
|
||||||
this.buttonFocus(true);
|
this.buttonFocus(true);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
onShow(fCallback, sText, identity, sTo, sCc, sBcc) {
|
||||||
|
|
||||||
ComposeOpenPgpPopupView.prototype.onShow = function(fCallback, sText, oIdentity, sTo, sCc, sBcc)
|
|
||||||
{
|
|
||||||
this.clearPopup();
|
this.clearPopup();
|
||||||
|
|
||||||
var
|
let
|
||||||
self = this,
|
rec = [],
|
||||||
aRec = [],
|
emailLine = '';
|
||||||
sEmail = '',
|
|
||||||
oEmail = new EmailModel();
|
const email = new EmailModel();
|
||||||
|
|
||||||
this.resultCallback = fCallback;
|
this.resultCallback = fCallback;
|
||||||
|
|
||||||
if ('' !== sTo)
|
if ('' !== sTo)
|
||||||
{
|
{
|
||||||
aRec.push(sTo);
|
rec.push(sTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('' !== sCc)
|
if ('' !== sCc)
|
||||||
{
|
{
|
||||||
aRec.push(sCc);
|
rec.push(sCc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('' !== sBcc)
|
if ('' !== sBcc)
|
||||||
{
|
{
|
||||||
aRec.push(sBcc);
|
rec.push(sBcc);
|
||||||
}
|
}
|
||||||
|
|
||||||
aRec = aRec.join(', ').split(',');
|
rec = rec.join(', ').split(',');
|
||||||
aRec = _.compact(_.map(aRec, function(sValue) {
|
rec = _.compact(_.map(rec, (value) => {
|
||||||
oEmail.clear();
|
email.clear();
|
||||||
oEmail.mailsoParse(Utils.trim(sValue));
|
email.mailsoParse(trim(value));
|
||||||
return '' === oEmail.email ? false : oEmail.email;
|
return '' === email.email ? false : email.email;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (oIdentity && oIdentity.email())
|
if (identity && identity.email())
|
||||||
{
|
{
|
||||||
sEmail = oIdentity.email();
|
emailLine = identity.email();
|
||||||
aRec.unshift(sEmail);
|
rec.unshift(emailLine);
|
||||||
|
|
||||||
var aKeys = PgpStore.findAllPrivateKeysByEmailNotNative(sEmail);
|
const keys = PgpStore.findAllPrivateKeysByEmailNotNative(emailLine);
|
||||||
if (aKeys && aKeys[0])
|
if (keys && keys[0])
|
||||||
{
|
{
|
||||||
this.signKey({
|
this.signKey({
|
||||||
'users': aKeys[0].users || [sEmail],
|
'users': keys[0].users || [emailLine],
|
||||||
'hash': aKeys[0].id.substr(-8).toUpperCase(),
|
'hash': keys[0].id.substr(-8).toUpperCase(),
|
||||||
'key': aKeys[0]
|
'key': keys[0]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -445,23 +433,19 @@ ComposeOpenPgpPopupView.prototype.onShow = function(fCallback, sText, oIdentity,
|
||||||
this.sign(true);
|
this.sign(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aRec && 0 < aRec.length)
|
if (rec && 0 < rec.length)
|
||||||
{
|
{
|
||||||
this.encryptKeys(_.uniq(_.compact(_.flatten(_.map(aRec, function(sRecEmail) {
|
this.encryptKeys(_.uniq(_.compact(_.flatten(_.map(rec, (recEmail) => {
|
||||||
var keys = PgpStore.findAllPublicKeysByEmailNotNative(sRecEmail);
|
const keys = PgpStore.findAllPublicKeysByEmailNotNative(recEmail);
|
||||||
return keys ? _.map(keys, function(oKey) {
|
return keys ? _.map(keys, (oKey) => ({
|
||||||
return {
|
|
||||||
'empty': !oKey,
|
'empty': !oKey,
|
||||||
'selected': ko.observable(!!oKey),
|
'selected': ko.observable(!!oKey),
|
||||||
'removable': ko.observable(!self.sign() || !self.signKey() || self.signKey().key.id !== oKey.id),
|
'removable': ko.observable(!this.sign() || !this.signKey() || this.signKey().key.id !== oKey.id),
|
||||||
'users': oKey ? (oKey.users || [sRecEmail]) : [sRecEmail],
|
'users': oKey ? (oKey.users || [recEmail]) : [recEmail],
|
||||||
'hash': oKey ? oKey.id.substr(-8).toUpperCase() : '',
|
'hash': oKey ? oKey.id.substr(-8).toUpperCase() : '',
|
||||||
'key': oKey
|
'key': oKey
|
||||||
};
|
})) : [];
|
||||||
}) : [];
|
}), true)), (encryptKey) => encryptKey.hash));
|
||||||
}), true)), function(oEncryptKey) {
|
|
||||||
return oEncryptKey.hash;
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (0 < this.encryptKeys().length)
|
if (0 < this.encryptKeys().length)
|
||||||
{
|
{
|
||||||
|
|
@ -470,6 +454,7 @@ ComposeOpenPgpPopupView.prototype.onShow = function(fCallback, sText, oIdentity,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.text(sText);
|
this.text(sText);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = ComposeOpenPgpPopupView;
|
module.exports = ComposeOpenPgpPopupView;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,29 +1,31 @@
|
||||||
|
|
||||||
var
|
import _ from '_';
|
||||||
_ = require('_'),
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
import {StorageResultType, ServerSecure, Ports, Notification} from 'Common/Enums';
|
||||||
Consts = require('Common/Consts'),
|
import {IMAP_DEFAULT_PORT, SIEVE_DEFAULT_PORT, SMTP_DEFAULT_PORT} from 'Common/Consts';
|
||||||
Globals = require('Common/Globals'),
|
import {bMobileDevice} from 'Common/Globals';
|
||||||
Utils = require('Common/Utils'),
|
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'),
|
import {view, ViewType} from 'Knoin/Knoin';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||||
|
|
||||||
/**
|
@view({
|
||||||
* @constructor
|
name: 'View/Popup/Domain',
|
||||||
* @extends AbstractView
|
type: ViewType.Popup,
|
||||||
*/
|
templateID: 'PopupsDomain'
|
||||||
function DomainPopupView()
|
})
|
||||||
|
class DomainPopupView extends AbstractViewNext
|
||||||
{
|
{
|
||||||
AbstractView.call(this, 'Popups', 'PopupsDomain');
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
this.edit = ko.observable(false);
|
this.edit = ko.observable(false);
|
||||||
this.saving = ko.observable(false);
|
this.saving = ko.observable(false);
|
||||||
|
|
@ -40,26 +42,26 @@ function DomainPopupView()
|
||||||
this.testingSieveErrorDesc = ko.observable('');
|
this.testingSieveErrorDesc = ko.observable('');
|
||||||
this.testingSmtpErrorDesc = ko.observable('');
|
this.testingSmtpErrorDesc = ko.observable('');
|
||||||
|
|
||||||
this.testingImapError.subscribe(function(bValue) {
|
this.testingImapError.subscribe((value) => {
|
||||||
if (!bValue)
|
if (!value)
|
||||||
{
|
{
|
||||||
this.testingImapErrorDesc('');
|
this.testingImapErrorDesc('');
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.testingSieveError.subscribe(function(bValue) {
|
this.testingSieveError.subscribe((value) => {
|
||||||
if (!bValue)
|
if (!value)
|
||||||
{
|
{
|
||||||
this.testingSieveErrorDesc('');
|
this.testingSieveErrorDesc('');
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.testingSmtpError.subscribe(function(bValue) {
|
this.testingSmtpError.subscribe((value) => {
|
||||||
if (!bValue)
|
if (!value)
|
||||||
{
|
{
|
||||||
this.testingSmtpErrorDesc('');
|
this.testingSmtpErrorDesc('');
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.imapServerFocus = ko.observable(false);
|
this.imapServerFocus = ko.observable(false);
|
||||||
this.sieveServerFocus = ko.observable(false);
|
this.sieveServerFocus = ko.observable(false);
|
||||||
|
|
@ -69,17 +71,17 @@ function DomainPopupView()
|
||||||
this.name.focused = ko.observable(false);
|
this.name.focused = ko.observable(false);
|
||||||
|
|
||||||
this.imapServer = ko.observable('');
|
this.imapServer = ko.observable('');
|
||||||
this.imapPort = ko.observable('' + Consts.IMAP_DEFAULT_PORT);
|
this.imapPort = ko.observable('' + IMAP_DEFAULT_PORT);
|
||||||
this.imapSecure = ko.observable(Enums.ServerSecure.None);
|
this.imapSecure = ko.observable(ServerSecure.None);
|
||||||
this.imapShortLogin = ko.observable(false);
|
this.imapShortLogin = ko.observable(false);
|
||||||
this.useSieve = ko.observable(false);
|
this.useSieve = ko.observable(false);
|
||||||
this.sieveAllowRaw = ko.observable(false);
|
this.sieveAllowRaw = ko.observable(false);
|
||||||
this.sieveServer = ko.observable('');
|
this.sieveServer = ko.observable('');
|
||||||
this.sievePort = ko.observable('' + Consts.SIEVE_DEFAULT_PORT);
|
this.sievePort = ko.observable('' + SIEVE_DEFAULT_PORT);
|
||||||
this.sieveSecure = ko.observable(Enums.ServerSecure.None);
|
this.sieveSecure = ko.observable(ServerSecure.None);
|
||||||
this.smtpServer = ko.observable('');
|
this.smtpServer = ko.observable('');
|
||||||
this.smtpPort = ko.observable('' + Consts.SMTP_DEFAULT_PORT);
|
this.smtpPort = ko.observable('' + SMTP_DEFAULT_PORT);
|
||||||
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
|
this.smtpSecure = ko.observable(ServerSecure.None);
|
||||||
this.smtpShortLogin = ko.observable(false);
|
this.smtpShortLogin = ko.observable(false);
|
||||||
this.smtpAuth = ko.observable(true);
|
this.smtpAuth = ko.observable(true);
|
||||||
this.smtpPhpMail = ko.observable(false);
|
this.smtpPhpMail = ko.observable(false);
|
||||||
|
|
@ -88,64 +90,58 @@ function DomainPopupView()
|
||||||
|
|
||||||
this.enableSmartPorts = ko.observable(false);
|
this.enableSmartPorts = ko.observable(false);
|
||||||
|
|
||||||
this.allowSieve = ko.computed(function() {
|
this.allowSieve = ko.computed(() => CapaAdminStore.filters() && CapaAdminStore.sieve());
|
||||||
return CapaAdminStore.filters() && CapaAdminStore.sieve();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.headerText = ko.computed(function() {
|
this.headerText = ko.computed(() => {
|
||||||
|
|
||||||
var
|
const
|
||||||
sName = this.name(),
|
name = this.name(),
|
||||||
sAliasName = this.aliasName(),
|
aliasName = this.aliasName();
|
||||||
sResult = '';
|
|
||||||
|
let result = '';
|
||||||
|
|
||||||
if (this.edit())
|
if (this.edit())
|
||||||
{
|
{
|
||||||
sResult = Translator.i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', {'NAME': sName});
|
result = i18n('POPUPS_DOMAIN/TITLE_EDIT_DOMAIN', {'NAME': name});
|
||||||
if (sAliasName)
|
if (aliasName)
|
||||||
{
|
{
|
||||||
sResult += ' ← ' + sAliasName;
|
result += ' ← ' + aliasName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sResult = ('' === sName ? Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN') :
|
result = ('' === name ? i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN') :
|
||||||
Translator.i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', {'NAME': sName}));
|
i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', {'NAME': name}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sResult;
|
return result;
|
||||||
|
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.domainDesc = ko.computed(function() {
|
this.domainDesc = ko.computed(() => {
|
||||||
var sName = this.name();
|
const name = this.name();
|
||||||
return !this.edit() && sName ? Translator.i18n('POPUPS_DOMAIN/NEW_DOMAIN_DESC', {'NAME': '*@' + sName}) : '';
|
return !this.edit() && name ? i18n('POPUPS_DOMAIN/NEW_DOMAIN_DESC', {'NAME': '*@' + name}) : '';
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.domainIsComputed = ko.computed(function() {
|
this.domainIsComputed = ko.computed(() => {
|
||||||
|
|
||||||
var
|
const
|
||||||
bPhpMail = this.smtpPhpMail(),
|
usePhpMail = this.smtpPhpMail(),
|
||||||
bAllowSieve = this.allowSieve(),
|
allowSieve = this.allowSieve(),
|
||||||
bUseSieve = this.useSieve();
|
useSieve = this.useSieve();
|
||||||
|
|
||||||
return '' !== this.name() &&
|
return '' !== this.name() &&
|
||||||
'' !== this.imapServer() &&
|
'' !== this.imapServer() &&
|
||||||
'' !== this.imapPort() &&
|
'' !== this.imapPort() &&
|
||||||
(bAllowSieve && bUseSieve ? ('' !== this.sieveServer() && '' !== this.sievePort()) : true) &&
|
(allowSieve && useSieve ? ('' !== this.sieveServer() && '' !== this.sievePort()) : true) &&
|
||||||
(('' !== this.smtpServer() && '' !== this.smtpPort()) || bPhpMail);
|
(('' !== this.smtpServer() && '' !== this.smtpPort()) || usePhpMail);
|
||||||
|
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.canBeTested = ko.computed(function() {
|
this.canBeTested = ko.computed(() => !this.testing() && this.domainIsComputed());
|
||||||
return !this.testing() && this.domainIsComputed();
|
this.canBeSaved = ko.computed(() => !this.saving() && this.domainIsComputed());
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.canBeSaved = ko.computed(function() {
|
this.createOrAddCommand = createCommand(() => {
|
||||||
return !this.saving() && this.domainIsComputed();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.createOrAddCommand = Utils.createCommand(this, function() {
|
|
||||||
this.saving(true);
|
this.saving(true);
|
||||||
Remote.createOrUpdateDomain(
|
Remote.createOrUpdateDomain(
|
||||||
_.bind(this.onDomainCreateOrSaveResponse, this),
|
_.bind(this.onDomainCreateOrSaveResponse, this),
|
||||||
|
|
@ -153,18 +149,18 @@ function DomainPopupView()
|
||||||
this.name(),
|
this.name(),
|
||||||
|
|
||||||
this.imapServer(),
|
this.imapServer(),
|
||||||
Utils.pInt(this.imapPort()),
|
pInt(this.imapPort()),
|
||||||
this.imapSecure(),
|
this.imapSecure(),
|
||||||
this.imapShortLogin(),
|
this.imapShortLogin(),
|
||||||
|
|
||||||
this.useSieve(),
|
this.useSieve(),
|
||||||
this.sieveAllowRaw(),
|
this.sieveAllowRaw(),
|
||||||
this.sieveServer(),
|
this.sieveServer(),
|
||||||
Utils.pInt(this.sievePort()),
|
pInt(this.sievePort()),
|
||||||
this.sieveSecure(),
|
this.sieveSecure(),
|
||||||
|
|
||||||
this.smtpServer(),
|
this.smtpServer(),
|
||||||
Utils.pInt(this.smtpPort()),
|
pInt(this.smtpPort()),
|
||||||
this.smtpSecure(),
|
this.smtpSecure(),
|
||||||
this.smtpShortLogin(),
|
this.smtpShortLogin(),
|
||||||
this.smtpAuth(),
|
this.smtpAuth(),
|
||||||
|
|
@ -174,7 +170,7 @@ function DomainPopupView()
|
||||||
);
|
);
|
||||||
}, this.canBeSaved);
|
}, this.canBeSaved);
|
||||||
|
|
||||||
this.testConnectionCommand = Utils.createCommand(this, function() {
|
this.testConnectionCommand = createCommand(() => {
|
||||||
|
|
||||||
this.page('main');
|
this.page('main');
|
||||||
|
|
||||||
|
|
@ -189,125 +185,119 @@ function DomainPopupView()
|
||||||
this.name(),
|
this.name(),
|
||||||
|
|
||||||
this.imapServer(),
|
this.imapServer(),
|
||||||
Utils.pInt(this.imapPort()),
|
pInt(this.imapPort()),
|
||||||
this.imapSecure(),
|
this.imapSecure(),
|
||||||
|
|
||||||
this.useSieve(),
|
this.useSieve(),
|
||||||
this.sieveServer(),
|
this.sieveServer(),
|
||||||
Utils.pInt(this.sievePort()),
|
pInt(this.sievePort()),
|
||||||
this.sieveSecure(),
|
this.sieveSecure(),
|
||||||
|
|
||||||
this.smtpServer(),
|
this.smtpServer(),
|
||||||
Utils.pInt(this.smtpPort()),
|
pInt(this.smtpPort()),
|
||||||
this.smtpSecure(),
|
this.smtpSecure(),
|
||||||
this.smtpAuth(),
|
this.smtpAuth(),
|
||||||
this.smtpPhpMail()
|
this.smtpPhpMail()
|
||||||
);
|
);
|
||||||
}, this.canBeTested);
|
}, this.canBeTested);
|
||||||
|
|
||||||
this.whiteListCommand = Utils.createCommand(this, function() {
|
this.whiteListCommand = createCommand(() => {
|
||||||
this.page('white-list');
|
this.page('white-list');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.backCommand = Utils.createCommand(this, function() {
|
this.backCommand = createCommand(() => {
|
||||||
this.page('main');
|
this.page('main');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.sieveCommand = Utils.createCommand(this, function() {
|
this.sieveCommand = createCommand(() => {
|
||||||
this.sieveSettings(!this.sieveSettings());
|
this.sieveSettings(!this.sieveSettings());
|
||||||
this.clearTesting();
|
this.clearTesting();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.page.subscribe(function() {
|
this.page.subscribe(() => {
|
||||||
this.sieveSettings(false);
|
this.sieveSettings(false);
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
// smart form improvements
|
// smart form improvements
|
||||||
this.imapServerFocus.subscribe(function(bValue) {
|
this.imapServerFocus.subscribe((value) => {
|
||||||
if (bValue && '' !== this.name() && '' === this.imapServer())
|
if (value && '' !== this.name() && '' === this.imapServer())
|
||||||
{
|
{
|
||||||
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
|
this.imapServer(this.name().replace(/[.]?[*][.]?/g, ''));
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.sieveServerFocus.subscribe(function(bValue) {
|
this.sieveServerFocus.subscribe((value) => {
|
||||||
if (bValue && '' !== this.imapServer() && '' === this.sieveServer())
|
if (value && '' !== this.imapServer() && '' === this.sieveServer())
|
||||||
{
|
{
|
||||||
this.sieveServer(this.imapServer());
|
this.sieveServer(this.imapServer());
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.smtpServerFocus.subscribe(function(bValue) {
|
this.smtpServerFocus.subscribe((value) => {
|
||||||
if (bValue && '' !== this.imapServer() && '' === this.smtpServer())
|
if (value && '' !== this.imapServer() && '' === this.smtpServer())
|
||||||
{
|
{
|
||||||
this.smtpServer(this.imapServer().replace(/imap/ig, 'smtp'));
|
this.smtpServer(this.imapServer().replace(/imap/ig, 'smtp'));
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.imapSecure.subscribe(function(sValue) {
|
this.imapSecure.subscribe((value) => {
|
||||||
if (this.enableSmartPorts())
|
if (this.enableSmartPorts())
|
||||||
{
|
{
|
||||||
var iPort = Utils.pInt(this.imapPort());
|
const port = pInt(this.imapPort());
|
||||||
switch (Utils.pString(sValue))
|
switch (pString(value))
|
||||||
{
|
{
|
||||||
case '0':
|
case '0':
|
||||||
if (Enums.Ports.ImapSsl === iPort)
|
if (Ports.ImapSsl === port)
|
||||||
{
|
{
|
||||||
this.imapPort(Utils.pString(Enums.Ports.Imap));
|
this.imapPort(pString(Ports.Imap));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
if (Enums.Ports.Imap === iPort)
|
if (Ports.Imap === port)
|
||||||
{
|
{
|
||||||
this.imapPort(Utils.pString(Enums.Ports.ImapSsl));
|
this.imapPort(pString(Ports.ImapSsl));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// no default
|
// no default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.smtpSecure.subscribe(function(sValue) {
|
this.smtpSecure.subscribe((value) => {
|
||||||
if (this.enableSmartPorts())
|
if (this.enableSmartPorts())
|
||||||
{
|
{
|
||||||
var iPort = Utils.pInt(this.smtpPort());
|
const port = pInt(this.smtpPort());
|
||||||
switch (Utils.pString(sValue))
|
switch (pString(value))
|
||||||
{
|
{
|
||||||
case '0':
|
case '0':
|
||||||
if (Enums.Ports.SmtpSsl === iPort || Enums.Ports.SmtpStartTls === iPort)
|
if (Ports.SmtpSsl === port || Ports.SmtpStartTls === port)
|
||||||
{
|
{
|
||||||
this.smtpPort(Utils.pString(Enums.Ports.Smtp));
|
this.smtpPort(pString(Ports.Smtp));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
if (Enums.Ports.Smtp === iPort || Enums.Ports.SmtpStartTls === iPort)
|
if (Ports.Smtp === port || Ports.SmtpStartTls === port)
|
||||||
{
|
{
|
||||||
this.smtpPort(Utils.pString(Enums.Ports.SmtpSsl));
|
this.smtpPort(pString(Ports.SmtpSsl));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
if (Enums.Ports.Smtp === iPort || Enums.Ports.SmtpSsl === iPort)
|
if (Ports.Smtp === port || Ports.SmtpSsl === port)
|
||||||
{
|
{
|
||||||
this.smtpPort(Utils.pString(Enums.Ports.SmtpStartTls));
|
this.smtpPort(pString(Ports.SmtpStartTls));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// no default
|
// no default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Popup/Domain', 'PopupsDomainViewModel'], DomainPopupView);
|
onTestConnectionResponse(sResult, oData) {
|
||||||
_.extend(DomainPopupView.prototype, AbstractView.prototype);
|
|
||||||
|
|
||||||
DomainPopupView.prototype.onTestConnectionResponse = function(sResult, oData)
|
|
||||||
{
|
|
||||||
this.testing(false);
|
this.testing(false);
|
||||||
if (Enums.StorageResultType.Success === sResult && oData.Result)
|
if (StorageResultType.Success === sResult && oData.Result)
|
||||||
{
|
{
|
||||||
var
|
let
|
||||||
bImap = false,
|
bImap = false,
|
||||||
bSieve = false;
|
bSieve = false;
|
||||||
|
|
||||||
|
|
@ -343,14 +333,11 @@ DomainPopupView.prototype.onTestConnectionResponse = function(sResult, oData)
|
||||||
this.sieveSettings(false);
|
this.sieveSettings(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (bSieve && !bImap)
|
||||||
{
|
|
||||||
if (bSieve && !bImap)
|
|
||||||
{
|
{
|
||||||
this.sieveSettings(true);
|
this.sieveSettings(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.testingImapError(true);
|
this.testingImapError(true);
|
||||||
|
|
@ -358,46 +345,42 @@ DomainPopupView.prototype.onTestConnectionResponse = function(sResult, oData)
|
||||||
this.testingSmtpError(true);
|
this.testingSmtpError(true);
|
||||||
this.sieveSettings(false);
|
this.sieveSettings(false);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
DomainPopupView.prototype.onDomainCreateOrSaveResponse = function(sResult, oData)
|
onDomainCreateOrSaveResponse(sResult, oData) {
|
||||||
{
|
|
||||||
this.saving(false);
|
this.saving(false);
|
||||||
if (Enums.StorageResultType.Success === sResult && oData)
|
if (StorageResultType.Success === sResult && oData)
|
||||||
{
|
{
|
||||||
if (oData.Result)
|
if (oData.Result)
|
||||||
{
|
{
|
||||||
require('App/Admin').default.reloadDomainList();
|
getApp().reloadDomainList();
|
||||||
this.closeCommand();
|
this.closeCommand();
|
||||||
}
|
}
|
||||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
else if (Notification.DomainAlreadyExists === oData.ErrorCode)
|
||||||
{
|
{
|
||||||
this.savingError(Translator.i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
this.savingError(i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.savingError(Translator.i18n('ERRORS/UNKNOWN_ERROR'));
|
this.savingError(i18n('ERRORS/UNKNOWN_ERROR'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
DomainPopupView.prototype.clearTesting = function()
|
clearTesting() {
|
||||||
{
|
|
||||||
this.testing(false);
|
this.testing(false);
|
||||||
this.testingDone(false);
|
this.testingDone(false);
|
||||||
this.testingImapError(false);
|
this.testingImapError(false);
|
||||||
this.testingSieveError(false);
|
this.testingSieveError(false);
|
||||||
this.testingSmtpError(false);
|
this.testingSmtpError(false);
|
||||||
};
|
}
|
||||||
|
|
||||||
DomainPopupView.prototype.onHide = function()
|
onHide() {
|
||||||
{
|
|
||||||
this.page('main');
|
this.page('main');
|
||||||
this.sieveSettings(false);
|
this.sieveSettings(false);
|
||||||
};
|
}
|
||||||
|
|
||||||
DomainPopupView.prototype.onShow = function(oDomain)
|
onShow(oDomain) {
|
||||||
{
|
|
||||||
this.saving(false);
|
this.saving(false);
|
||||||
|
|
||||||
this.page('main');
|
this.page('main');
|
||||||
|
|
@ -412,39 +395,37 @@ DomainPopupView.prototype.onShow = function(oDomain)
|
||||||
|
|
||||||
this.edit(true);
|
this.edit(true);
|
||||||
|
|
||||||
this.name(Utils.trim(oDomain.Name));
|
this.name(trim(oDomain.Name));
|
||||||
this.imapServer(Utils.trim(oDomain.IncHost));
|
this.imapServer(trim(oDomain.IncHost));
|
||||||
this.imapPort('' + Utils.pInt(oDomain.IncPort));
|
this.imapPort('' + pInt(oDomain.IncPort));
|
||||||
this.imapSecure(Utils.trim(oDomain.IncSecure));
|
this.imapSecure(trim(oDomain.IncSecure));
|
||||||
this.imapShortLogin(!!oDomain.IncShortLogin);
|
this.imapShortLogin(!!oDomain.IncShortLogin);
|
||||||
this.useSieve(!!oDomain.UseSieve);
|
this.useSieve(!!oDomain.UseSieve);
|
||||||
this.sieveAllowRaw(!!oDomain.SieveAllowRaw);
|
this.sieveAllowRaw(!!oDomain.SieveAllowRaw);
|
||||||
this.sieveServer(Utils.trim(oDomain.SieveHost));
|
this.sieveServer(trim(oDomain.SieveHost));
|
||||||
this.sievePort('' + Utils.pInt(oDomain.SievePort));
|
this.sievePort('' + pInt(oDomain.SievePort));
|
||||||
this.sieveSecure(Utils.trim(oDomain.SieveSecure));
|
this.sieveSecure(trim(oDomain.SieveSecure));
|
||||||
this.smtpServer(Utils.trim(oDomain.OutHost));
|
this.smtpServer(trim(oDomain.OutHost));
|
||||||
this.smtpPort('' + Utils.pInt(oDomain.OutPort));
|
this.smtpPort('' + pInt(oDomain.OutPort));
|
||||||
this.smtpSecure(Utils.trim(oDomain.OutSecure));
|
this.smtpSecure(trim(oDomain.OutSecure));
|
||||||
this.smtpShortLogin(!!oDomain.OutShortLogin);
|
this.smtpShortLogin(!!oDomain.OutShortLogin);
|
||||||
this.smtpAuth(!!oDomain.OutAuth);
|
this.smtpAuth(!!oDomain.OutAuth);
|
||||||
this.smtpPhpMail(!!oDomain.OutUsePhpMail);
|
this.smtpPhpMail(!!oDomain.OutUsePhpMail);
|
||||||
this.whiteList(Utils.trim(oDomain.WhiteList));
|
this.whiteList(trim(oDomain.WhiteList));
|
||||||
this.aliasName(Utils.trim(oDomain.AliasName));
|
this.aliasName(trim(oDomain.AliasName));
|
||||||
|
|
||||||
this.enableSmartPorts(true);
|
this.enableSmartPorts(true);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
DomainPopupView.prototype.onShowWithDelay = function()
|
onShowWithDelay() {
|
||||||
{
|
if ('' === this.name() && !bMobileDevice)
|
||||||
if ('' === this.name() && !Globals.bMobile)
|
|
||||||
{
|
{
|
||||||
this.name.focused(true);
|
this.name.focused(true);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
DomainPopupView.prototype.clearForm = function()
|
clearForm() {
|
||||||
{
|
|
||||||
this.edit(false);
|
this.edit(false);
|
||||||
|
|
||||||
this.page('main');
|
this.page('main');
|
||||||
|
|
@ -458,19 +439,19 @@ DomainPopupView.prototype.clearForm = function()
|
||||||
this.name.focused(false);
|
this.name.focused(false);
|
||||||
|
|
||||||
this.imapServer('');
|
this.imapServer('');
|
||||||
this.imapPort('' + Consts.IMAP_DEFAULT_PORT);
|
this.imapPort('' + IMAP_DEFAULT_PORT);
|
||||||
this.imapSecure(Enums.ServerSecure.None);
|
this.imapSecure(ServerSecure.None);
|
||||||
this.imapShortLogin(false);
|
this.imapShortLogin(false);
|
||||||
|
|
||||||
this.useSieve(false);
|
this.useSieve(false);
|
||||||
this.sieveAllowRaw(false);
|
this.sieveAllowRaw(false);
|
||||||
this.sieveServer('');
|
this.sieveServer('');
|
||||||
this.sievePort('' + Consts.SIEVE_DEFAULT_PORT);
|
this.sievePort('' + SIEVE_DEFAULT_PORT);
|
||||||
this.sieveSecure(Enums.ServerSecure.None);
|
this.sieveSecure(ServerSecure.None);
|
||||||
|
|
||||||
this.smtpServer('');
|
this.smtpServer('');
|
||||||
this.smtpPort('' + Consts.SMTP_DEFAULT_PORT);
|
this.smtpPort('' + SMTP_DEFAULT_PORT);
|
||||||
this.smtpSecure(Enums.ServerSecure.None);
|
this.smtpSecure(ServerSecure.None);
|
||||||
this.smtpShortLogin(false);
|
this.smtpShortLogin(false);
|
||||||
this.smtpAuth(true);
|
this.smtpAuth(true);
|
||||||
this.smtpPhpMail(false);
|
this.smtpPhpMail(false);
|
||||||
|
|
@ -478,6 +459,7 @@ DomainPopupView.prototype.clearForm = function()
|
||||||
this.whiteList('');
|
this.whiteList('');
|
||||||
this.aliasName('');
|
this.aliasName('');
|
||||||
this.enableSmartPorts(true);
|
this.enableSmartPorts(true);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = DomainPopupView;
|
module.exports = DomainPopupView;
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,30 @@
|
||||||
|
|
||||||
var
|
import _ from '_';
|
||||||
_ = require('_'),
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
import {StorageResultType, Notification} from 'Common/Enums';
|
||||||
Globals = require('Common/Globals'),
|
import {bMobileDevice} from 'Common/Globals';
|
||||||
Utils = require('Common/Utils'),
|
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'),
|
import {view, ViewType} from 'Knoin/Knoin';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||||
|
|
||||||
/**
|
@view({
|
||||||
* @constructor
|
name: 'View/Popup/DomainAlias',
|
||||||
* @extends AbstractView
|
type: ViewType.Popup,
|
||||||
*/
|
templateID: 'PopupsDomainAlias'
|
||||||
function DomainAliasPopupView()
|
})
|
||||||
|
class DomainAliasPopupView extends AbstractViewNext
|
||||||
{
|
{
|
||||||
AbstractView.call(this, 'Popups', 'PopupsDomainAlias');
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
this.saving = ko.observable(false);
|
this.saving = ko.observable(false);
|
||||||
this.savingError = ko.observable('');
|
this.savingError = ko.observable('');
|
||||||
|
|
@ -34,70 +36,56 @@ function DomainAliasPopupView()
|
||||||
|
|
||||||
this.domains = DomainStore.domainsWithoutAliases;
|
this.domains = DomainStore.domainsWithoutAliases;
|
||||||
|
|
||||||
this.domainsOptions = ko.computed(function() {
|
this.domainsOptions = ko.computed(
|
||||||
return _.map(this.domains(), function(item) {
|
() => _.map(this.domains(), (item) => ({optValue: item.name, optText: item.name}))
|
||||||
return {
|
);
|
||||||
optValue: item.name,
|
|
||||||
optText: item.name
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.canBeSaved = ko.computed(function() {
|
this.canBeSaved = ko.computed(() => !this.saving() && '' !== this.name() && '' !== this.alias());
|
||||||
return !this.saving() && '' !== this.name() && '' !== this.alias();
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
this.createCommand = Utils.createCommand(this, function() {
|
this.createCommand = createCommand(() => {
|
||||||
this.saving(true);
|
this.saving(true);
|
||||||
Remote.createDomainAlias(
|
Remote.createDomainAlias(
|
||||||
_.bind(this.onDomainAliasCreateOrSaveResponse, this),
|
this.onDomainAliasCreateOrSaveResponse,
|
||||||
this.name(),
|
this.name(),
|
||||||
this.alias()
|
this.alias()
|
||||||
);
|
);
|
||||||
}, this.canBeSaved);
|
}, this.canBeSaved);
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
this.onDomainAliasCreateOrSaveResponse = _.bind(this.onDomainAliasCreateOrSaveResponse, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Popup/DomainAlias', 'PopupsDomainAliasViewModel'], DomainAliasPopupView);
|
onDomainAliasCreateOrSaveResponse(result, data) {
|
||||||
_.extend(DomainAliasPopupView.prototype, AbstractView.prototype);
|
|
||||||
|
|
||||||
DomainAliasPopupView.prototype.onDomainAliasCreateOrSaveResponse = function(sResult, oData)
|
|
||||||
{
|
|
||||||
this.saving(false);
|
this.saving(false);
|
||||||
if (Enums.StorageResultType.Success === sResult && oData)
|
if (StorageResultType.Success === result && data)
|
||||||
{
|
{
|
||||||
if (oData.Result)
|
if (data.Result)
|
||||||
{
|
{
|
||||||
require('App/Admin').default.reloadDomainList();
|
getApp().reloadDomainList();
|
||||||
this.closeCommand();
|
this.closeCommand();
|
||||||
}
|
}
|
||||||
else if (Enums.Notification.DomainAlreadyExists === oData.ErrorCode)
|
else if (Notification.DomainAlreadyExists === data.ErrorCode)
|
||||||
{
|
{
|
||||||
this.savingError(Translator.i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
this.savingError(i18n('ERRORS/DOMAIN_ALREADY_EXISTS'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.savingError(Translator.i18n('ERRORS/UNKNOWN_ERROR'));
|
this.savingError(i18n('ERRORS/UNKNOWN_ERROR'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
DomainAliasPopupView.prototype.onShow = function()
|
onShow() {
|
||||||
{
|
|
||||||
this.clearForm();
|
this.clearForm();
|
||||||
};
|
}
|
||||||
|
|
||||||
DomainAliasPopupView.prototype.onShowWithDelay = function()
|
onShowWithDelay() {
|
||||||
{
|
if ('' === this.name() && !bMobileDevice)
|
||||||
if ('' === this.name() && !Globals.bMobile)
|
|
||||||
{
|
{
|
||||||
this.name.focused(true);
|
this.name.focused(true);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
DomainAliasPopupView.prototype.clearForm = function()
|
clearForm() {
|
||||||
{
|
|
||||||
this.saving(false);
|
this.saving(false);
|
||||||
this.savingError('');
|
this.savingError('');
|
||||||
|
|
||||||
|
|
@ -105,6 +93,7 @@ DomainAliasPopupView.prototype.clearForm = function()
|
||||||
this.name.focused(false);
|
this.name.focused(false);
|
||||||
|
|
||||||
this.alias('');
|
this.alias('');
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = DomainAliasPopupView;
|
module.exports = DomainAliasPopupView;
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,27 @@
|
||||||
|
|
||||||
var
|
import _ from '_';
|
||||||
_ = require('_'),
|
import ko from 'ko';
|
||||||
ko = require('ko'),
|
|
||||||
|
|
||||||
Enums = require('Common/Enums'),
|
import {FiltersAction, FilterConditionField, FilterConditionType} from 'Common/Enums';
|
||||||
Globals = require('Common/Globals'),
|
import {bMobileDevice} from 'Common/Globals';
|
||||||
Utils = require('Common/Utils'),
|
import {defautOptionsAfterRender, createCommand, delegateRun} from 'Common/Utils';
|
||||||
Translator = require('Common/Translator'),
|
import {i18n, initOnStartOrLangChange} from 'Common/Translator';
|
||||||
|
|
||||||
FilterStore = require('Stores/User/Filter'),
|
import FilterStore from 'Stores/User/Filter';
|
||||||
FolderStore = require('Stores/User/Folder'),
|
import FolderStore from 'Stores/User/Folder';
|
||||||
|
|
||||||
kn = require('Knoin/Knoin'),
|
import {view, ViewType} from 'Knoin/Knoin';
|
||||||
AbstractView = require('Knoin/AbstractView');
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||||
|
|
||||||
/**
|
@view({
|
||||||
* @constructor
|
name: 'View/Popup/Filter',
|
||||||
* @extends AbstractView
|
type: ViewType.Popup,
|
||||||
*/
|
templateID: 'PopupsFilter'
|
||||||
function FilterPopupView()
|
})
|
||||||
|
class FilterPopupView extends AbstractViewNext
|
||||||
{
|
{
|
||||||
AbstractView.call(this, 'Popups', 'PopupsFilter');
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
this.isNew = ko.observable(true);
|
this.isNew = ko.observable(true);
|
||||||
|
|
||||||
|
|
@ -31,22 +32,22 @@ function FilterPopupView()
|
||||||
|
|
||||||
this.allowMarkAsRead = ko.observable(false);
|
this.allowMarkAsRead = ko.observable(false);
|
||||||
|
|
||||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
this.defautOptionsAfterRender = defautOptionsAfterRender;
|
||||||
this.folderSelectList = FolderStore.folderMenuForFilters;
|
this.folderSelectList = FolderStore.folderMenuForFilters;
|
||||||
this.selectedFolderValue = ko.observable('');
|
this.selectedFolderValue = ko.observable('');
|
||||||
|
|
||||||
this.selectedFolderValue.subscribe(function() {
|
this.selectedFolderValue.subscribe(() => {
|
||||||
if (this.filter())
|
if (this.filter())
|
||||||
{
|
{
|
||||||
this.filter().actionValue.error(false);
|
this.filter().actionValue.error(false);
|
||||||
}
|
}
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
this.saveFilter = Utils.createCommand(this, function() {
|
this.saveFilter = createCommand(() => {
|
||||||
|
|
||||||
if (this.filter())
|
if (this.filter())
|
||||||
{
|
{
|
||||||
if (Enums.FiltersAction.MoveTo === this.filter().actionType())
|
if (FiltersAction.MoveTo === this.filter().actionType())
|
||||||
{
|
{
|
||||||
this.filter().actionValue(this.selectedFolderValue());
|
this.filter().actionValue(this.selectedFolderValue());
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +64,7 @@ function FilterPopupView()
|
||||||
|
|
||||||
if (this.modalVisibility())
|
if (this.modalVisibility())
|
||||||
{
|
{
|
||||||
Utils.delegateRun(this, 'closeCommand');
|
delegateRun(this, 'closeCommand');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,104 +76,95 @@ function FilterPopupView()
|
||||||
this.typeOptions = ko.observableArray([]);
|
this.typeOptions = ko.observableArray([]);
|
||||||
this.typeOptionsSize = ko.observableArray([]);
|
this.typeOptionsSize = ko.observableArray([]);
|
||||||
|
|
||||||
Translator.initOnStartOrLangChange(_.bind(this.populateOptions, this));
|
initOnStartOrLangChange(_.bind(this.populateOptions, this));
|
||||||
|
|
||||||
this.modules.subscribe(this.populateOptions, this);
|
this.modules.subscribe(this.populateOptions, this);
|
||||||
|
|
||||||
kn.constructorEnd(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kn.extendAsViewModel(['View/Popup/Filter', 'PopupsFilterViewModel'], FilterPopupView);
|
populateOptions() {
|
||||||
_.extend(FilterPopupView.prototype, AbstractView.prototype);
|
|
||||||
|
|
||||||
FilterPopupView.prototype.populateOptions = function()
|
|
||||||
{
|
|
||||||
this.actionTypeOptions([]);
|
this.actionTypeOptions([]);
|
||||||
|
|
||||||
// this.actionTypeOptions.push({'id': Enums.FiltersAction.None,
|
// this.actionTypeOptions.push({'id': FiltersAction.None,
|
||||||
// 'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_NONE')});
|
// 'name': i18n('POPUPS_FILTER/SELECT_ACTION_NONE')});
|
||||||
|
|
||||||
var oModules = this.modules();
|
const modules = this.modules();
|
||||||
if (oModules)
|
if (modules)
|
||||||
{
|
{
|
||||||
if (oModules.markasread)
|
if (modules.markasread)
|
||||||
{
|
{
|
||||||
this.allowMarkAsRead(true);
|
this.allowMarkAsRead(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oModules.moveto)
|
if (modules.moveto)
|
||||||
{
|
{
|
||||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.MoveTo,
|
this.actionTypeOptions.push({'id': FiltersAction.MoveTo,
|
||||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_MOVE_TO')});
|
'name': i18n('POPUPS_FILTER/SELECT_ACTION_MOVE_TO')});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oModules.redirect)
|
if (modules.redirect)
|
||||||
{
|
{
|
||||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Forward,
|
this.actionTypeOptions.push({'id': FiltersAction.Forward,
|
||||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_FORWARD_TO')});
|
'name': i18n('POPUPS_FILTER/SELECT_ACTION_FORWARD_TO')});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oModules.reject)
|
if (modules.reject)
|
||||||
{
|
{
|
||||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Reject,
|
this.actionTypeOptions.push({'id': FiltersAction.Reject,
|
||||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_REJECT')});
|
'name': i18n('POPUPS_FILTER/SELECT_ACTION_REJECT')});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oModules.vacation)
|
if (modules.vacation)
|
||||||
{
|
{
|
||||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Vacation,
|
this.actionTypeOptions.push({'id': FiltersAction.Vacation,
|
||||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_VACATION_MESSAGE')});
|
'name': i18n('POPUPS_FILTER/SELECT_ACTION_VACATION_MESSAGE')});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.actionTypeOptions.push({'id': Enums.FiltersAction.Discard,
|
this.actionTypeOptions.push({'id': FiltersAction.Discard,
|
||||||
'name': Translator.i18n('POPUPS_FILTER/SELECT_ACTION_DISCARD')});
|
'name': i18n('POPUPS_FILTER/SELECT_ACTION_DISCARD')});
|
||||||
|
|
||||||
this.fieldOptions([
|
this.fieldOptions([
|
||||||
{'id': Enums.FilterConditionField.From, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_FROM')},
|
{'id': FilterConditionField.From, 'name': i18n('POPUPS_FILTER/SELECT_FIELD_FROM')},
|
||||||
{'id': Enums.FilterConditionField.Recipient, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_RECIPIENTS')},
|
{'id': FilterConditionField.Recipient, 'name': i18n('POPUPS_FILTER/SELECT_FIELD_RECIPIENTS')},
|
||||||
{'id': Enums.FilterConditionField.Subject, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SUBJECT')},
|
{'id': FilterConditionField.Subject, 'name': i18n('POPUPS_FILTER/SELECT_FIELD_SUBJECT')},
|
||||||
{'id': Enums.FilterConditionField.Size, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SIZE')},
|
{'id': FilterConditionField.Size, 'name': i18n('POPUPS_FILTER/SELECT_FIELD_SIZE')},
|
||||||
{'id': Enums.FilterConditionField.Header, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_HEADER')}
|
{'id': FilterConditionField.Header, 'name': i18n('POPUPS_FILTER/SELECT_FIELD_HEADER')}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.typeOptions([
|
this.typeOptions([
|
||||||
{'id': Enums.FilterConditionType.Contains, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_CONTAINS')},
|
{'id': FilterConditionType.Contains, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_CONTAINS')},
|
||||||
{'id': Enums.FilterConditionType.NotContains, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_CONTAINS')},
|
{'id': FilterConditionType.NotContains, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_NOT_CONTAINS')},
|
||||||
{'id': Enums.FilterConditionType.EqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_EQUAL_TO')},
|
{'id': FilterConditionType.EqualTo, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_EQUAL_TO')},
|
||||||
{'id': Enums.FilterConditionType.NotEqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_EQUAL_TO')}
|
{'id': FilterConditionType.NotEqualTo, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_NOT_EQUAL_TO')}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (oModules && oModules.regex)
|
if (modules && modules.regex)
|
||||||
{
|
{
|
||||||
this.typeOptions.push({'id': Enums.FilterConditionType.Regex, 'name': 'Regex'});
|
this.typeOptions.push({'id': FilterConditionType.Regex, 'name': 'Regex'});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.typeOptionsSize([
|
this.typeOptionsSize([
|
||||||
{'id': Enums.FilterConditionType.Over, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_OVER')},
|
{'id': FilterConditionType.Over, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_OVER')},
|
||||||
{'id': Enums.FilterConditionType.Under, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_UNDER')}
|
{'id': FilterConditionType.Under, 'name': i18n('POPUPS_FILTER/SELECT_TYPE_UNDER')}
|
||||||
]);
|
]);
|
||||||
};
|
}
|
||||||
|
|
||||||
FilterPopupView.prototype.removeCondition = function(oConditionToDelete)
|
removeCondition(oConditionToDelete) {
|
||||||
{
|
|
||||||
if (this.filter())
|
if (this.filter())
|
||||||
{
|
{
|
||||||
this.filter().removeCondition(oConditionToDelete);
|
this.filter().removeCondition(oConditionToDelete);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
FilterPopupView.prototype.clearPopup = function()
|
clearPopup() {
|
||||||
{
|
|
||||||
this.isNew(true);
|
this.isNew(true);
|
||||||
|
|
||||||
this.fTrueCallback = null;
|
this.fTrueCallback = null;
|
||||||
this.filter(null);
|
this.filter(null);
|
||||||
};
|
}
|
||||||
|
|
||||||
FilterPopupView.prototype.onShow = function(oFilter, fTrueCallback, bEdit)
|
onShow(oFilter, fTrueCallback, bEdit) {
|
||||||
{
|
|
||||||
this.clearPopup();
|
this.clearPopup();
|
||||||
|
|
||||||
this.fTrueCallback = fTrueCallback;
|
this.fTrueCallback = fTrueCallback;
|
||||||
|
|
@ -189,14 +181,14 @@ FilterPopupView.prototype.onShow = function(oFilter, fTrueCallback, bEdit)
|
||||||
{
|
{
|
||||||
oFilter.name.focused(true);
|
oFilter.name.focused(true);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
FilterPopupView.prototype.onShowWithDelay = function()
|
onShowWithDelay() {
|
||||||
{
|
if (this.isNew() && this.filter() && !bMobileDevice)
|
||||||
if (this.isNew() && this.filter() && !Globals.bMobile)
|
|
||||||
{
|
{
|
||||||
this.filter().name.focused(true);
|
this.filter().name.focused(true);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = FilterPopupView;
|
module.exports = FilterPopupView;
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue