Code refactoring (5) (es5 -> es2015)

This commit is contained in:
RainLoop Team 2016-07-16 00:29:42 +03:00
parent c148e19ea3
commit cec53b111f
68 changed files with 2210 additions and 2472 deletions

View file

@ -1,3 +1,4 @@
module.exports = { module.exports = {
'extends': 'eslint:recommended', 'extends': 'eslint:recommended',
'ecmaFeatures': { 'ecmaFeatures': {
@ -14,18 +15,7 @@ module.exports = {
'browser': true 'browser': true
}, },
'globals': { 'globals': {
'RL_COMMUNITY': true, 'RL_COMMUNITY': true
'ko': true,
'ssm': true,
'moment': true,
'ifvisible': true,
'crossroads': true,
'hasher': true,
'key': true,
'Jua': true,
'_': true,
'$': true,
'Dropbox': true
}, },
// http://eslint.org/docs/rules/ // http://eslint.org/docs/rules/
'rules': { 'rules': {
@ -166,7 +156,7 @@ module.exports = {
'array-bracket-spacing': 2, 'array-bracket-spacing': 2,
'block-spacing': [2, 'never'], 'block-spacing': [2, 'never'],
// 'brace-style': [2, 'allman'], // 'brace-style': [2, 'allman'],
// 'camelcase': 2, 'camelcase': 2,
'comma-dangle': [2, 'never'], 'comma-dangle': [2, 'never'],
'comma-spacing': 2, 'comma-spacing': 2,
'comma-style': 2, 'comma-style': 2,
@ -234,9 +224,9 @@ module.exports = {
// 'one-var': [2, { // 'one-var': [2, {
// 'var': 'always', // 'var': 'always',
// 'let': 'always', // 'let': 'always',
// 'const': 'never' // 'const': 'always'
// }], // }],
// 'one-var-declaration-per-line': [2, 'always'], 'one-var-declaration-per-line': [2, 'always'],
'operator-assignment': 2, 'operator-assignment': 2,
'operator-linebreak': [2, 'after'], 'operator-linebreak': [2, 'after'],
// 'padded-blocks': [2, 'never'], // 'padded-blocks': [2, 'never'],
@ -284,7 +274,7 @@ module.exports = {
// 'prefer-template': 2, // 'prefer-template': 2,
'require-yield': 2, 'require-yield': 2,
'rest-spread-spacing': 2, 'rest-spread-spacing': 2,
'sort-imports': 0, 'sort-imports': 0, // off
'template-curly-spacing': 2, 'template-curly-spacing': 2,
'yield-star-spacing': 2 'yield-star-spacing': 2
} }

View file

@ -27,8 +27,7 @@ import {AbstractApp} from 'App/Abstract';
class AdminApp extends AbstractApp class AdminApp extends AbstractApp
{ {
constructor() constructor() {
{
super(Remote); super(Remote);
} }

View file

@ -66,8 +66,7 @@ import {AbstractApp} from 'App/Abstract';
class AppUser extends AbstractApp class AppUser extends AbstractApp
{ {
constructor() constructor() {
{
super(Remote); super(Remote);
this.moveCache = {}; this.moveCache = {};

View file

@ -8,8 +8,7 @@ import {trim} from 'Common/Utils';
class Audio class Audio
{ {
constructor() constructor() {
{
this.notificator = null; this.notificator = null;
this.supportedMp3 = false; this.supportedMp3 = false;

View file

@ -158,8 +158,8 @@ const Base64 = {
return string; return string;
} }
}; };
/* eslint-enable */
export const decode = Base64.decode; export const decode = Base64.decode;
export const encode = Base64.encode; export const encode = Base64.encode;
export const urlsafe_encode = Base64.urlsafe_encode; export const urlsafe_encode = Base64.urlsafe_encode;
/* eslint-enable */

View file

@ -10,10 +10,12 @@ import {getHash, setHash, clearHash} from 'Storage/RainLoop';
let RL_APP_DATA_STORAGE = null; let RL_APP_DATA_STORAGE = null;
/* eslint-disable */
window.__rlah = () => getHash(); window.__rlah = () => getHash();
window.__rlah_set = () => setHash(); window.__rlah_set = () => setHash();
window.__rlah_clear = () => clearHash(); window.__rlah_clear = () => clearHash();
window.__rlah_data = () => RL_APP_DATA_STORAGE; window.__rlah_data = () => RL_APP_DATA_STORAGE;
/* eslint-enable */
/** /**
* @param {string} id * @param {string} id

View file

@ -7,8 +7,7 @@ import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
class LocalStorageDriver class LocalStorageDriver
{ {
constructor() constructor() {
{
this.s = window.localStorage || null; this.s = window.localStorage || null;
} }

View file

@ -82,15 +82,20 @@ export const bAnimationSupported = !bMobileDevice && $html.hasClass('csstransiti
*/ */
export const bXMLHttpRequestSupported = !!window.XMLHttpRequest; export const bXMLHttpRequestSupported = !!window.XMLHttpRequest;
/**
* @type {boolean}
*/
export const bIsHttps = window.document && window.document.location ? 'https:' === window.document.location.protocol : false;
/** /**
* @type {Object} * @type {Object}
*/ */
export const oHtmlEditorDefaultConfig = { export const oHtmlEditorDefaultConfig = {
title: false, 'title': false,
stylesSet: false, 'stylesSet': false,
customConfig: '', 'customConfig': '',
contentsCss: '', 'contentsCss': '',
toolbarGroups: [ 'toolbarGroups': [
{name: 'spec'}, {name: 'spec'},
{name: 'styles'}, {name: 'styles'},
{name: 'basicstyles', groups: ['basicstyles', 'cleanup', 'bidi']}, {name: 'basicstyles', groups: ['basicstyles', 'cleanup', 'bidi']},
@ -102,54 +107,54 @@ export const oHtmlEditorDefaultConfig = {
{name: 'others'} {name: 'others'}
], ],
removePlugins: 'liststyle', 'removePlugins': 'liststyle',
removeButtons: 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll,Source', 'removeButtons': 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll,Source',
removeDialogTabs: 'link:advanced;link:target;image:advanced;images:advanced', 'removeDialogTabs': 'link:advanced;link:target;image:advanced;images:advanced',
extraPlugins: 'plain,signature', 'extraPlugins': 'plain,signature',
allowedContent: true, 'allowedContent': true,
extraAllowedContent: true, 'extraAllowedContent': true,
fillEmptyBlocks: false, 'fillEmptyBlocks': false,
ignoreEmptyParagraph: true, 'ignoreEmptyParagraph': true,
disableNativeSpellChecker: false, 'disableNativeSpellChecker': false,
font_defaultLabel: 'Arial', 'font_defaultLabel': 'Arial',
fontSize_defaultLabel: '13', 'fontSize_defaultLabel': '13',
fontSize_sizes: '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px' 'fontSize_sizes': '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px'
}; };
/** /**
* @type {Object} * @type {Object}
*/ */
export const oHtmlEditorLangsMap = { export const oHtmlEditorLangsMap = {
bg_bg: 'bg', 'bg_bg': 'bg',
de_de: 'de', 'de_de': 'de',
el_gr: 'el', 'el_gr': 'el',
es_es: 'es', 'es_es': 'es',
fr_fr: 'fr', 'fr_fr': 'fr',
hu_hu: 'hu', 'hu_hu': 'hu',
is_is: 'is', 'is_is': 'is',
it_it: 'it', 'it_it': 'it',
ja_jp: 'ja', 'ja_jp': 'ja',
ko_kr: 'ko', 'ko_kr': 'ko',
lt_lt: 'lt', 'lt_lt': 'lt',
lv_lv: 'lv', 'lv_lv': 'lv',
nl_nl: 'nl', 'nl_nl': 'nl',
bg_no: 'no', 'bg_no': 'no',
pl_pl: 'pl', 'pl_pl': 'pl',
pt_pt: 'pt', 'pt_pt': 'pt',
pt_br: 'pt-br', 'pt_br': 'pt-br',
ro_ro: 'ro', 'ro_ro': 'ro',
ru_ru: 'ru', 'ru_ru': 'ru',
sk_sk: 'sk', 'sk_sk': 'sk',
sl_si: 'sl', 'sl_si': 'sl',
sv_se: 'sv', 'sv_se': 'sv',
tr_tr: 'tr', 'tr_tr': 'tr',
uk_ua: 'ru', 'uk_ua': 'ru',
zh_tw: 'zh', 'zh_tw': 'zh',
zh_cn: 'zh-cn' 'zh_cn': 'zh-cn'
}; };
/** /**

View file

@ -163,12 +163,12 @@ export function i18nToNodes(elements, animate = false)
if (animate && bAnimationSupported) if (animate && bAnimationSupported)
{ {
$('.i18n-animation[data-i18n]', elements).letterfx({ $('.i18n-animation[data-i18n]', elements).letterfx({
fx: 'fall fade', 'fx': 'fall fade',
backwards: false, 'backwards': false,
timing: 50, 'timing': 50,
fx_duration: '50ms', 'fx_duration': '50ms',
letter_end: 'restore', 'letter_end': 'restore',
element_end: 'restore' 'element_end': 'restore'
}); });
} }
}); });

View file

@ -145,7 +145,10 @@ export function encodeURI(url)
*/ */
export function simpleQueryParser(queryString) export function simpleQueryParser(queryString)
{ {
let index = 0, len = 0, temp = null; let
index = 0,
len = 0,
temp = null;
const const
queries = queryString.split('&'), queries = queryString.split('&'),
@ -498,7 +501,7 @@ export function delegateRun(object, methodName, params, delay = 0)
/** /**
* @param {?} event * @param {?} event
*/ */
export function kill_CtrlA_CtrlS(event) export function killCtrlACtrlS(event)
{ {
event = event || window.event; event = event || window.event;
if (event && event.ctrlKey && !event.shiftKey && !event.altKey) if (event && event.ctrlKey && !event.shiftKey && !event.altKey)
@ -1055,8 +1058,8 @@ export function plainToHtml(plain, findEmailAndLinksInText = false)
return findEmailAndLinksInText ? findEmailAndLinks(plain) : plain; return findEmailAndLinksInText ? findEmailAndLinks(plain) : plain;
} }
window.rainloop_Utils_htmlToPlain = htmlToPlain; window['rainloop_Utils_htmlToPlain'] = htmlToPlain; // eslint-disable-line dot-notation
window.rainloop_Utils_plainToHtml = plainToHtml; window['rainloop_Utils_plainToHtml'] = plainToHtml; // eslint-disable-line dot-notation
/** /**
* @param {Array} aSystem * @param {Array} aSystem
@ -1195,7 +1198,10 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
*/ */
export function selectElement(element) export function selectElement(element)
{ {
let sel = null, range = null; let
sel = null,
range = null;
if (window.getSelection) if (window.getSelection)
{ {
sel = window.getSelection(); sel = window.getSelection();

5
dev/External/ko.js vendored
View file

@ -1210,6 +1210,11 @@ ko.extenders.idleTrigger = function(oTarget)
// functions // functions
ko.observable.fn.idleTrigger = function()
{
return this.extend({'idleTrigger': true});
};
ko.observable.fn.validateNone = function() ko.observable.fn.validateNone = function()
{ {
this.hasError = ko.observable(false); this.hasError = ko.observable(false);

View file

@ -9,10 +9,11 @@ import {EmailModel} from 'Model/Email';
* @returns {string} * @returns {string}
*/ */
export function emailArrayToString(emails, friendlyView = false, wrapWithLink = false) { export function emailArrayToString(emails, friendlyView = false, wrapWithLink = false) {
let
index = 0,
len = 0;
let index = 0, len = 0;
const result = []; const result = [];
if (isNonEmptyArray(emails)) if (isNonEmptyArray(emails))
{ {
for (len = emails.length; index < len; index++) for (len = emails.length; index < len; index++)
@ -29,10 +30,11 @@ export function emailArrayToString(emails, friendlyView = false, wrapWithLink =
* @returns {string} * @returns {string}
*/ */
export function emailArrayToStringClear(emails) { export function emailArrayToStringClear(emails) {
let
index = 0,
len = 0;
let index = 0, len = 0;
const result = []; const result = [];
if (isNonEmptyArray(emails)) if (isNonEmptyArray(emails))
{ {
for (len = emails.length; index < len; index++) for (len = emails.length; index < len; index++)
@ -52,10 +54,12 @@ export function emailArrayToStringClear(emails) {
* @returns {Array.<EmailModel>} * @returns {Array.<EmailModel>}
*/ */
export function emailArrayFromJson(json) { export function emailArrayFromJson(json) {
let
index = 0,
len = 0,
email = null;
let index = 0, len = 0, email = null;
const result = []; const result = [];
if (isNonEmptyArray(json)) if (isNonEmptyArray(json))
{ {
for (index = 0, len = json.length; index < len; index++) for (index = 0, len = json.length; index < len; index++)

View file

@ -233,8 +233,7 @@ export const staticCombinedIconClass = (data) => {
class AttachmentModel extends AbstractModel class AttachmentModel extends AbstractModel
{ {
constructor() constructor() {
{
super('AttachmentModel'); super('AttachmentModel');
this.checked = ko.observable(false); this.checked = ko.observable(false);

View file

@ -10,8 +10,7 @@ import {AbstractModel} from 'Knoin/AbstractModel';
class ContactModel extends AbstractModel class ContactModel extends AbstractModel
{ {
constructor() constructor() {
{
super('ContactModel'); super('ContactModel');
this.idContact = 0; this.idContact = 0;

View file

@ -12,8 +12,7 @@ import {AbstractModel} from 'Knoin/AbstractModel';
class FilterModel extends AbstractModel class FilterModel extends AbstractModel
{ {
constructor() constructor() {
{
super('FilterModel'); super('FilterModel');
this.enabled = ko.observable(true); this.enabled = ko.observable(true);

View file

@ -8,8 +8,7 @@ import {AbstractModel} from 'Knoin/AbstractModel';
class FilterConditionModel extends AbstractModel class FilterConditionModel extends AbstractModel
{ {
constructor() constructor() {
{
super('FilterConditionModel'); super('FilterConditionModel');
this.field = ko.observable(FilterConditionField.From); this.field = ko.observable(FilterConditionField.From);

View file

@ -12,8 +12,7 @@ import {AbstractModel} from 'Knoin/AbstractModel';
class FolderModel extends AbstractModel class FolderModel extends AbstractModel
{ {
constructor() constructor() {
{
super('FolderModel'); super('FolderModel');
this.name = ko.observable(''); this.name = ko.observable('');

View file

@ -20,8 +20,7 @@ import {AbstractModel} from 'Knoin/AbstractModel';
class MessageModel extends AbstractModel class MessageModel extends AbstractModel
{ {
constructor() constructor() {
{
super('MessageModel'); super('MessageModel');
this.folderFullNameRaw = ''; this.folderFullNameRaw = '';

View file

@ -81,8 +81,11 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut,
timeout: iTimeOut, timeout: iTimeOut,
global: true global: true
}).always(function(oData, sTextStatus) { }).always(function(oData, sTextStatus) {
var
bCached = false,
oErrorData = null,
sType = Enums.StorageResultType.Error;
var bCached = false, oErrorData = null, sType = Enums.StorageResultType.Error;
if (oData && oData.Time) if (oData && oData.Time)
{ {
bCached = Utils.pInt(oData.Time) > Utils.microtime() - iStart; bCached = Utils.pInt(oData.Time) > Utils.microtime() - iStart;

View file

@ -83,10 +83,10 @@ AbstractAjaxRemote.prototype.defaultResponse = function(fCallback, sRequestActio
Globals.data.iTokenErrorCount = 0; Globals.data.iTokenErrorCount = 0;
} }
if (fCallback)
{
Plugins.runHook('ajax-default-response', [sRequestAction, Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]); Plugins.runHook('ajax-default-response', [sRequestAction, Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]);
if (fCallback)
{
fCallback( fCallback(
sType, sType,
Enums.StorageResultType.Success === sType ? oData : null, Enums.StorageResultType.Success === sType ? oData : null,

View file

@ -10,21 +10,21 @@ var
* @constructor * @constructor
* @extends AbstractAjaxRemote * @extends AbstractAjaxRemote
*/ */
function RemoteAdminStorage() function RemoteAdminAjax()
{ {
AbstractAjaxRemote.call(this); AbstractAjaxRemote.call(this);
this.oRequests = {}; this.oRequests = {};
} }
_.extend(RemoteAdminStorage.prototype, AbstractAjaxRemote.prototype); _.extend(RemoteAdminAjax.prototype, AbstractAjaxRemote.prototype);
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sLogin * @param {string} sLogin
* @param {string} sPassword * @param {string} sPassword
*/ */
RemoteAdminStorage.prototype.adminLogin = function(fCallback, sLogin, sPassword) RemoteAdminAjax.prototype.adminLogin = function(fCallback, sLogin, sPassword)
{ {
this.defaultRequest(fCallback, 'AdminLogin', { this.defaultRequest(fCallback, 'AdminLogin', {
'Login': sLogin, 'Login': sLogin,
@ -35,7 +35,7 @@ RemoteAdminStorage.prototype.adminLogin = function(fCallback, sLogin, sPassword)
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.adminLogout = function(fCallback) RemoteAdminAjax.prototype.adminLogout = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminLogout'); this.defaultRequest(fCallback, 'AdminLogout');
}; };
@ -44,16 +44,31 @@ RemoteAdminStorage.prototype.adminLogout = function(fCallback)
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {?} oData * @param {?} oData
*/ */
RemoteAdminStorage.prototype.saveAdminConfig = function(fCallback, oData) RemoteAdminAjax.prototype.saveAdminConfig = function(fCallback, oData)
{ {
this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData); this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData);
}; };
/**
* @param {string} key
* @param {?Function} valueFn
* @param {?Function} fn
*/
RemoteAdminAjax.prototype.saveAdminConfigHelper = function(key, valueFn, fn)
{
var self = this;
return function(value) {
var data = {};
data[key] = valueFn ? valueFn(value) : value;
self.saveAdminConfig(fn || null, data);
};
};
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {boolean=} bIncludeAliases = true * @param {boolean=} bIncludeAliases = true
*/ */
RemoteAdminStorage.prototype.domainList = function(fCallback, bIncludeAliases) RemoteAdminAjax.prototype.domainList = function(fCallback, bIncludeAliases)
{ {
bIncludeAliases = Utils.isUnd(bIncludeAliases) ? true : bIncludeAliases; bIncludeAliases = Utils.isUnd(bIncludeAliases) ? true : bIncludeAliases;
this.defaultRequest(fCallback, 'AdminDomainList', { this.defaultRequest(fCallback, 'AdminDomainList', {
@ -64,7 +79,7 @@ RemoteAdminStorage.prototype.domainList = function(fCallback, bIncludeAliases)
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.pluginList = function(fCallback) RemoteAdminAjax.prototype.pluginList = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminPluginList'); this.defaultRequest(fCallback, 'AdminPluginList');
}; };
@ -72,7 +87,7 @@ RemoteAdminStorage.prototype.pluginList = function(fCallback)
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.packagesList = function(fCallback) RemoteAdminAjax.prototype.packagesList = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminPackagesList'); this.defaultRequest(fCallback, 'AdminPackagesList');
}; };
@ -80,7 +95,7 @@ RemoteAdminStorage.prototype.packagesList = function(fCallback)
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.coreData = function(fCallback) RemoteAdminAjax.prototype.coreData = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminCoreData'); this.defaultRequest(fCallback, 'AdminCoreData');
}; };
@ -88,7 +103,7 @@ RemoteAdminStorage.prototype.coreData = function(fCallback)
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.updateCoreData = function(fCallback) RemoteAdminAjax.prototype.updateCoreData = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000); this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000);
}; };
@ -97,7 +112,7 @@ RemoteAdminStorage.prototype.updateCoreData = function(fCallback)
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Object} oPackage * @param {Object} oPackage
*/ */
RemoteAdminStorage.prototype.packageInstall = function(fCallback, oPackage) RemoteAdminAjax.prototype.packageInstall = function(fCallback, oPackage)
{ {
this.defaultRequest(fCallback, 'AdminPackageInstall', { this.defaultRequest(fCallback, 'AdminPackageInstall', {
'Id': oPackage.id, 'Id': oPackage.id,
@ -110,7 +125,7 @@ RemoteAdminStorage.prototype.packageInstall = function(fCallback, oPackage)
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Object} oPackage * @param {Object} oPackage
*/ */
RemoteAdminStorage.prototype.packageDelete = function(fCallback, oPackage) RemoteAdminAjax.prototype.packageDelete = function(fCallback, oPackage)
{ {
this.defaultRequest(fCallback, 'AdminPackageDelete', { this.defaultRequest(fCallback, 'AdminPackageDelete', {
'Id': oPackage.id 'Id': oPackage.id
@ -121,7 +136,7 @@ RemoteAdminStorage.prototype.packageDelete = function(fCallback, oPackage)
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sName * @param {string} sName
*/ */
RemoteAdminStorage.prototype.domain = function(fCallback, sName) RemoteAdminAjax.prototype.domain = function(fCallback, sName)
{ {
this.defaultRequest(fCallback, 'AdminDomainLoad', { this.defaultRequest(fCallback, 'AdminDomainLoad', {
'Name': sName 'Name': sName
@ -132,7 +147,7 @@ RemoteAdminStorage.prototype.domain = function(fCallback, sName)
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sName * @param {string} sName
*/ */
RemoteAdminStorage.prototype.plugin = function(fCallback, sName) RemoteAdminAjax.prototype.plugin = function(fCallback, sName)
{ {
this.defaultRequest(fCallback, 'AdminPluginLoad', { this.defaultRequest(fCallback, 'AdminPluginLoad', {
'Name': sName 'Name': sName
@ -143,7 +158,7 @@ RemoteAdminStorage.prototype.plugin = function(fCallback, sName)
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sName * @param {string} sName
*/ */
RemoteAdminStorage.prototype.domainDelete = function(fCallback, sName) RemoteAdminAjax.prototype.domainDelete = function(fCallback, sName)
{ {
this.defaultRequest(fCallback, 'AdminDomainDelete', { this.defaultRequest(fCallback, 'AdminDomainDelete', {
'Name': sName 'Name': sName
@ -155,7 +170,7 @@ RemoteAdminStorage.prototype.domainDelete = function(fCallback, sName)
* @param {string} sName * @param {string} sName
* @param {boolean} bDisabled * @param {boolean} bDisabled
*/ */
RemoteAdminStorage.prototype.domainDisable = function(fCallback, sName, bDisabled) RemoteAdminAjax.prototype.domainDisable = function(fCallback, sName, bDisabled)
{ {
return this.defaultRequest(fCallback, 'AdminDomainDisable', { return this.defaultRequest(fCallback, 'AdminDomainDisable', {
Name: sName, Name: sName,
@ -167,7 +182,7 @@ RemoteAdminStorage.prototype.domainDisable = function(fCallback, sName, bDisable
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Object} oConfig * @param {Object} oConfig
*/ */
RemoteAdminStorage.prototype.pluginSettingsUpdate = function(fCallback, oConfig) RemoteAdminAjax.prototype.pluginSettingsUpdate = function(fCallback, oConfig)
{ {
return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig); return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig);
}; };
@ -176,7 +191,7 @@ RemoteAdminStorage.prototype.pluginSettingsUpdate = function(fCallback, oConfig)
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {boolean} bForce * @param {boolean} bForce
*/ */
RemoteAdminStorage.prototype.licensing = function(fCallback, bForce) RemoteAdminAjax.prototype.licensing = function(fCallback, bForce)
{ {
return this.defaultRequest(fCallback, 'AdminLicensing', { return this.defaultRequest(fCallback, 'AdminLicensing', {
Force: bForce ? '1' : '0' Force: bForce ? '1' : '0'
@ -188,7 +203,7 @@ RemoteAdminStorage.prototype.licensing = function(fCallback, bForce)
* @param {string} sDomain * @param {string} sDomain
* @param {string} sKey * @param {string} sKey
*/ */
RemoteAdminStorage.prototype.licensingActivate = function(fCallback, sDomain, sKey) RemoteAdminAjax.prototype.licensingActivate = function(fCallback, sDomain, sKey)
{ {
return this.defaultRequest(fCallback, 'AdminLicensingActivate', { return this.defaultRequest(fCallback, 'AdminLicensingActivate', {
Domain: sDomain, Domain: sDomain,
@ -201,7 +216,7 @@ RemoteAdminStorage.prototype.licensingActivate = function(fCallback, sDomain, sK
* @param {string} sName * @param {string} sName
* @param {boolean} bDisabled * @param {boolean} bDisabled
*/ */
RemoteAdminStorage.prototype.pluginDisable = function(fCallback, sName, bDisabled) RemoteAdminAjax.prototype.pluginDisable = function(fCallback, sName, bDisabled)
{ {
return this.defaultRequest(fCallback, 'AdminPluginDisable', { return this.defaultRequest(fCallback, 'AdminPluginDisable', {
Name: sName, Name: sName,
@ -209,7 +224,7 @@ RemoteAdminStorage.prototype.pluginDisable = function(fCallback, sName, bDisable
}); });
}; };
RemoteAdminStorage.prototype.createDomainAlias = function(fCallback, sName, sAlias) RemoteAdminAjax.prototype.createDomainAlias = function(fCallback, sName, sAlias)
{ {
this.defaultRequest(fCallback, 'AdminDomainAliasSave', { this.defaultRequest(fCallback, 'AdminDomainAliasSave', {
Name: sName, Name: sName,
@ -217,7 +232,7 @@ RemoteAdminStorage.prototype.createDomainAlias = function(fCallback, sName, sAli
}); });
}; };
RemoteAdminStorage.prototype.createOrUpdateDomain = function(fCallback, RemoteAdminAjax.prototype.createOrUpdateDomain = function(fCallback,
bCreate, sName, bCreate, sName,
sIncHost, iIncPort, sIncSecure, bIncShortLogin, sIncHost, iIncPort, sIncSecure, bIncShortLogin,
bUseSieve, sSieveAllowRaw, sSieveHost, iSievePort, sSieveSecure, bUseSieve, sSieveAllowRaw, sSieveHost, iSievePort, sSieveSecure,
@ -250,7 +265,7 @@ RemoteAdminStorage.prototype.createOrUpdateDomain = function(fCallback,
}); });
}; };
RemoteAdminStorage.prototype.testConnectionForDomain = function(fCallback, sName, RemoteAdminAjax.prototype.testConnectionForDomain = function(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)
@ -276,7 +291,7 @@ RemoteAdminStorage.prototype.testConnectionForDomain = function(fCallback, sName
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {?} oData * @param {?} oData
*/ */
RemoteAdminStorage.prototype.testContacts = function(fCallback, oData) RemoteAdminAjax.prototype.testContacts = function(fCallback, oData)
{ {
this.defaultRequest(fCallback, 'AdminContactsTest', oData); this.defaultRequest(fCallback, 'AdminContactsTest', oData);
}; };
@ -285,7 +300,7 @@ RemoteAdminStorage.prototype.testContacts = function(fCallback, oData)
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {?} oData * @param {?} oData
*/ */
RemoteAdminStorage.prototype.saveNewAdminPassword = function(fCallback, oData) RemoteAdminAjax.prototype.saveNewAdminPassword = function(fCallback, oData)
{ {
this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData); this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData);
}; };
@ -293,9 +308,9 @@ RemoteAdminStorage.prototype.saveNewAdminPassword = function(fCallback, oData)
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.adminPing = function(fCallback) RemoteAdminAjax.prototype.adminPing = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminPing'); this.defaultRequest(fCallback, 'AdminPing');
}; };
module.exports = new RemoteAdminStorage(); module.exports = new RemoteAdminAjax();

View file

@ -669,6 +669,21 @@ RemoteUserAjax.prototype.saveSettings = function(fCallback, oData)
this.defaultRequest(fCallback, 'SettingsUpdate', oData); this.defaultRequest(fCallback, 'SettingsUpdate', oData);
}; };
/**
* @param {string} key
* @param {?Function} valueFn
* @param {?Function} fn
*/
RemoteUserAjax.prototype.saveSettingsHelper = function(key, valueFn, fn)
{
var self = this;
return function(value) {
var data = {};
data[key] = valueFn ? valueFn(value) : value;
self.saveSettings(fn || null, data);
};
};
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sPrevPassword * @param {string} sPrevPassword

View file

@ -4,8 +4,7 @@ import App from 'App/Admin';
class LoginAdminScreen extends AbstractScreen class LoginAdminScreen extends AbstractScreen
{ {
constructor() constructor() {
{
super('login', [ super('login', [
require('View/Admin/Login') require('View/Admin/Login')
]); ]);

View file

@ -13,12 +13,11 @@ import {SecurityAdminSettings} from 'Settings/Admin/Security';
import {SocialAdminSettings} from 'Settings/Admin/Social'; import {SocialAdminSettings} from 'Settings/Admin/Social';
import {PluginsAdminSettings} from 'Settings/Admin/Plugins'; 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';
class SettingsAdminScreen extends AbstractSettingsScreen class SettingsAdminScreen extends AbstractSettingsScreen
{ {
constructor() constructor() {
{
super([ super([
require('View/Admin/Settings/Menu'), require('View/Admin/Settings/Menu'),
require('View/Admin/Settings/Pane') require('View/Admin/Settings/Pane')
@ -70,8 +69,8 @@ class SettingsAdminScreen extends AbstractSettingsScreen
'AdminSettingsLicensing', 'TABS_LABELS/LABEL_LICENSING_NAME', 'licensing'); 'AdminSettingsLicensing', 'TABS_LABELS/LABEL_LICENSING_NAME', 'licensing');
} }
// addSettingsViewModel(AboutAdminSettings, addSettingsViewModel(AboutAdminSettings,
// 'AdminSettingsAbout', 'TABS_LABELS/LABEL_ABOUT_NAME', 'about'); 'AdminSettingsAbout', 'TABS_LABELS/LABEL_ABOUT_NAME', 'about');
runSettingsViewModelHooks(true); runSettingsViewModelHooks(true);

View file

@ -4,8 +4,7 @@ import App from 'App/User';
class AboutUserScreen extends AbstractScreen class AboutUserScreen extends AbstractScreen
{ {
constructor() constructor() {
{
super('about', [ super('about', [
require('View/User/About') require('View/User/About')
]); ]);

View file

@ -4,8 +4,7 @@ import App from 'App/User';
class LoginUserScreen extends AbstractScreen class LoginUserScreen extends AbstractScreen
{ {
constructor() constructor() {
{
super('login', [ super('login', [
require('View/User/Login') require('View/User/Login')
]); ]);

View file

@ -21,8 +21,7 @@ import App from 'App/User';
class MailBoxUserScreen extends AbstractScreen class MailBoxUserScreen extends AbstractScreen
{ {
constructor() constructor() {
{
super('mailbox', [ super('mailbox', [
require('View/User/MailBox/SystemDropDown'), require('View/User/MailBox/SystemDropDown'),
require('View/User/MailBox/FolderList'), require('View/User/MailBox/FolderList'),

View file

@ -27,8 +27,7 @@ import {OpenPgpUserSettings} from 'Settings/User/OpenPgp';
class SettingsUserScreen extends AbstractSettingsScreen class SettingsUserScreen extends AbstractSettingsScreen
{ {
constructor() constructor() {
{
super([ super([
require('View/User/Settings/SystemDropDown'), require('View/User/Settings/SystemDropDown'),
require('View/User/Settings/Menu'), require('View/User/Settings/Menu'),

View file

@ -1,20 +1,17 @@
var import ko from 'ko';
ko = require('ko'),
Translator = require('Common/Translator'), import {i18n, trigger as translatorTrigger} from 'Common/Translator';
import {appSettingsGet, settingsGet} from 'Storage/Settings';
Settings = require('Storage/Settings'), import CoreStore from 'Stores/Admin/Core';
CoreStore = require('Stores/Admin/Core'), import AppStore from 'Stores/Admin/App';
AppStore = require('Stores/Admin/App');
/** class AboutAdminSettings
* @constructor
*/
function AboutAdminSettings()
{ {
this.version = ko.observable(Settings.appSettingsGet('version')); constructor() {
this.access = ko.observable(!!Settings.settingsGet('CoreAccess')); this.version = ko.observable(appSettingsGet('version'));
this.access = ko.observable(!!settingsGet('CoreAccess'));
this.errorDesc = ko.observable(''); this.errorDesc = ko.observable('');
this.coreReal = CoreStore.coreReal; this.coreReal = CoreStore.coreReal;
@ -32,61 +29,58 @@ function AboutAdminSettings()
this.community = RL_COMMUNITY || AppStore.community(); this.community = RL_COMMUNITY || AppStore.community();
this.coreRemoteVersionHtmlDesc = ko.computed(function() { this.coreRemoteVersionHtmlDesc = ko.computed(() => {
Translator.trigger(); translatorTrigger();
return Translator.i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()}); return i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()});
}, this); });
this.statusType = ko.computed(function() { this.statusType = ko.computed(() => {
let type = '';
const
versionToCompare = this.coreVersionCompare(),
isChecking = this.coreChecking(),
isUpdating = this.coreUpdating(),
isReal = this.coreReal();
var if (isChecking)
sType = '',
iVersionCompare = this.coreVersionCompare(),
bChecking = this.coreChecking(),
bUpdating = this.coreUpdating(),
bReal = this.coreReal();
if (bChecking)
{ {
sType = 'checking'; type = 'checking';
} }
else if (bUpdating) else if (isUpdating)
{ {
sType = 'updating'; type = 'updating';
} }
else if (bReal && 0 === iVersionCompare) else if (isReal && 0 === versionToCompare)
{ {
sType = 'up-to-date'; type = 'up-to-date';
} }
else if (bReal && -1 === iVersionCompare) else if (isReal && -1 === versionToCompare)
{ {
sType = 'available'; type = 'available';
} }
else if (!bReal) else if (!isReal)
{ {
sType = 'error'; type = 'error';
this.errorDesc('Cannot access the repository at the moment.'); this.errorDesc('Cannot access the repository at the moment.');
} }
return sType; return type;
});
}
}, this); onBuild() {
}
AboutAdminSettings.prototype.onBuild = function()
{
if (this.access() && !this.community) if (this.access() && !this.community)
{ {
require('App/Admin').default.reloadCoreData(); require('App/Admin').default.reloadCoreData();
} }
}; }
AboutAdminSettings.prototype.updateCoreData = function() updateCoreData() {
{
if (!this.coreUpdating() && !this.community) if (!this.coreUpdating() && !this.community)
{ {
require('App/Admin').default.updateCoreData(); require('App/Admin').default.updateCoreData();
} }
}; }
}
export {AboutAdminSettings, AboutAdminSettings as default}; export {AboutAdminSettings, AboutAdminSettings as default};

View file

@ -9,26 +9,25 @@ import {settingsGet} from 'Storage/Settings';
class BrandingAdminSettings class BrandingAdminSettings
{ {
constructor() constructor() {
{
const AppStore = require('Stores/Admin/App'); const AppStore = require('Stores/Admin/App');
this.capa = AppStore.prem; this.capa = AppStore.prem;
this.title = ko.observable(settingsGet('Title')).extend({idleTrigger: true}); this.title = ko.observable(settingsGet('Title')).idleTrigger();
this.loadingDesc = ko.observable(settingsGet('LoadingDescription')).extend({idleTrigger: true}); this.loadingDesc = ko.observable(settingsGet('LoadingDescription')).idleTrigger();
this.faviconUrl = ko.observable(settingsGet('FaviconUrl')).extend({idleTrigger: true}); this.faviconUrl = ko.observable(settingsGet('FaviconUrl')).idleTrigger();
this.loginLogo = ko.observable(settingsGet('LoginLogo') || '').extend({idleTrigger: true}); this.loginLogo = ko.observable(settingsGet('LoginLogo') || '').idleTrigger();
this.loginBackground = ko.observable(settingsGet('LoginBackground') || '').extend({idleTrigger: true}); this.loginBackground = ko.observable(settingsGet('LoginBackground') || '').idleTrigger();
this.userLogo = ko.observable(settingsGet('UserLogo') || '').extend({idleTrigger: true}); this.userLogo = ko.observable(settingsGet('UserLogo') || '').idleTrigger();
this.userLogoMessage = ko.observable(settingsGet('UserLogoMessage') || '').extend({idleTrigger: true}); this.userLogoMessage = ko.observable(settingsGet('UserLogoMessage') || '').idleTrigger();
this.userIframeMessage = ko.observable(settingsGet('UserIframeMessage') || '').extend({idleTrigger: true}); this.userIframeMessage = ko.observable(settingsGet('UserIframeMessage') || '').idleTrigger();
this.userLogoTitle = ko.observable(settingsGet('UserLogoTitle') || '').extend({idleTrigger: true}); this.userLogoTitle = ko.observable(settingsGet('UserLogoTitle') || '').idleTrigger();
this.loginDescription = ko.observable(settingsGet('LoginDescription')).extend({idleTrigger: true}); this.loginDescription = ko.observable(settingsGet('LoginDescription')).idleTrigger();
this.loginCss = ko.observable(settingsGet('LoginCss')).extend({idleTrigger: true}); this.loginCss = ko.observable(settingsGet('LoginCss')).idleTrigger();
this.userCss = ko.observable(settingsGet('UserCss')).extend({idleTrigger: true}); this.userCss = ko.observable(settingsGet('UserCss')).idleTrigger();
this.welcomePageUrl = ko.observable(settingsGet('WelcomePageUrl')).extend({idleTrigger: true}); this.welcomePageUrl = ko.observable(settingsGet('WelcomePageUrl')).idleTrigger();
this.welcomePageDisplay = ko.observable(settingsGet('WelcomePageDisplay')).extend({idleTrigger: true}); this.welcomePageDisplay = ko.observable(settingsGet('WelcomePageDisplay')).idleTrigger();
this.welcomePageDisplay.options = ko.computed(() => { this.welcomePageDisplay.options = ko.computed(() => {
translatorTrigger(); translatorTrigger();
return [ return [

View file

@ -1,88 +1,85 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {
Utils = require('Common/Utils'), settingsSaveHelperSimpleFunction,
defautOptionsAfterRender, createCommand,
inArray, trim, boolToAjax
} from 'Common/Utils';
Translator = require('Common/Translator'), import {SaveSettingsStep, StorageResultType, Magics} from 'Common/Enums';
import {i18n} from 'Common/Translator';
import {settingsGet} from 'Storage/Settings';
Settings = require('Storage/Settings'); class ContactsAdminSettings
/**
* @constructor
*/
function ContactsAdminSettings()
{ {
var constructor() {
Remote = require('Remote/Admin/Ajax'); this.defautOptionsAfterRender = defautOptionsAfterRender;
this.enableContacts = ko.observable(!!settingsGet('ContactsEnable'));
this.contactsSharing = ko.observable(!!settingsGet('ContactsSharing'));
this.contactsSync = ko.observable(!!settingsGet('ContactsSync'));
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; const
this.enableContacts = ko.observable(!!Settings.settingsGet('ContactsEnable')); Remote = require('Remote/Admin/Ajax'),
this.contactsSharing = ko.observable(!!Settings.settingsGet('ContactsSharing')); supportedTypes = [],
this.contactsSync = ko.observable(!!Settings.settingsGet('ContactsSync')); types = ['sqlite', 'mysql', 'pgsql'],
getTypeName = (name) => {
var switch (name)
aTypes = ['sqlite', 'mysql', 'pgsql'],
aSupportedTypes = [],
getTypeName = function(sName) {
switch (sName)
{ {
case 'sqlite': case 'sqlite':
sName = 'SQLite'; name = 'SQLite';
break; break;
case 'mysql': case 'mysql':
sName = 'MySQL'; name = 'MySQL';
break; break;
case 'pgsql': case 'pgsql':
sName = 'PostgreSQL'; name = 'PostgreSQL';
break; break;
// no default // no default
} }
return sName; return name;
}; };
if (Settings.settingsGet('SQLiteIsSupported')) if (settingsGet('SQLiteIsSupported'))
{ {
aSupportedTypes.push('sqlite'); supportedTypes.push('sqlite');
} }
if (Settings.settingsGet('MySqlIsSupported')) if (settingsGet('MySqlIsSupported'))
{ {
aSupportedTypes.push('mysql'); supportedTypes.push('mysql');
} }
if (Settings.settingsGet('PostgreSqlIsSupported')) if (settingsGet('PostgreSqlIsSupported'))
{ {
aSupportedTypes.push('pgsql'); supportedTypes.push('pgsql');
} }
this.contactsSupported = 0 < aSupportedTypes.length; this.contactsSupported = 0 < supportedTypes.length;
this.contactsTypes = ko.observableArray([]); this.contactsTypes = ko.observableArray([]);
this.contactsTypesOptions = this.contactsTypes.map(function(sValue) { this.contactsTypesOptions = this.contactsTypes.map((value) => {
var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes); const disabled = -1 === inArray(value, supportedTypes);
return { return {
'id': sValue, 'id': value,
'name': getTypeName(sValue) + (bDisabled ? ' (' + Translator.i18n('HINTS/NOT_SUPPORTED') + ')' : ''), 'name': getTypeName(value) + (disabled ? ' (' + i18n('HINTS/NOT_SUPPORTED') + ')' : ''),
'disabled': bDisabled 'disabled': disabled
}; };
}); });
this.contactsTypes(aTypes); this.contactsTypes(types);
this.contactsType = ko.observable(''); this.contactsType = ko.observable('');
this.mainContactsType = ko.computed({ this.mainContactsType = ko.computed({
'owner': this,
'read': this.contactsType, 'read': this.contactsType,
'write': function(sValue) { 'write': (value) => {
if (sValue !== this.contactsType()) if (value !== this.contactsType())
{ {
if (-1 < Utils.inArray(sValue, aSupportedTypes)) if (-1 < inArray(value, supportedTypes))
{ {
this.contactsType(sValue); this.contactsType(value);
} }
else if (0 < aSupportedTypes.length) else if (0 < supportedTypes.length)
{ {
this.contactsType(''); this.contactsType('');
} }
@ -92,7 +89,7 @@ function ContactsAdminSettings()
this.contactsType.valueHasMutated(); this.contactsType.valueHasMutated();
} }
} }
}).extend({'notify': 'always'}); }).extend({notify: 'always'});
this.contactsType.subscribe(function() { this.contactsType.subscribe(function() {
this.testContactsSuccess(false); this.testContactsSuccess(false);
@ -100,21 +97,21 @@ function ContactsAdminSettings()
this.testContactsErrorMessage(''); this.testContactsErrorMessage('');
}, this); }, this);
this.pdoDsn = ko.observable(Settings.settingsGet('ContactsPdoDsn')); this.pdoDsn = ko.observable(settingsGet('ContactsPdoDsn'));
this.pdoUser = ko.observable(Settings.settingsGet('ContactsPdoUser')); this.pdoUser = ko.observable(settingsGet('ContactsPdoUser'));
this.pdoPassword = ko.observable(Settings.settingsGet('ContactsPdoPassword')); this.pdoPassword = ko.observable(settingsGet('ContactsPdoPassword'));
this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.pdoDsnTrigger = ko.observable(SaveSettingsStep.Idle);
this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.pdoUserTrigger = ko.observable(SaveSettingsStep.Idle);
this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.pdoPasswordTrigger = ko.observable(SaveSettingsStep.Idle);
this.contactsTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.contactsTypeTrigger = ko.observable(SaveSettingsStep.Idle);
this.testing = ko.observable(false); this.testing = ko.observable(false);
this.testContactsSuccess = ko.observable(false); this.testContactsSuccess = ko.observable(false);
this.testContactsError = ko.observable(false); this.testContactsError = ko.observable(false);
this.testContactsErrorMessage = ko.observable(''); this.testContactsErrorMessage = ko.observable('');
this.testContactsCommand = Utils.createCommand(this, function() { this.testContactsCommand = createCommand(this, () => {
this.testContactsSuccess(false); this.testContactsSuccess(false);
this.testContactsError(false); this.testContactsError(false);
@ -128,31 +125,28 @@ function ContactsAdminSettings()
'ContactsPdoPassword': this.pdoPassword() 'ContactsPdoPassword': this.pdoPassword()
}); });
}, function() { }, () => '' !== this.pdoDsn() && '' !== this.pdoUser());
return '' !== this.pdoDsn() && '' !== this.pdoUser();
});
this.contactsType(Settings.settingsGet('ContactsPdoType')); this.contactsType(settingsGet('ContactsPdoType'));
this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this); this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this);
} }
ContactsAdminSettings.prototype.onTestContactsResponse = function(sResult, oData) onTestContactsResponse(result, data) {
{
this.testContactsSuccess(false); this.testContactsSuccess(false);
this.testContactsError(false); this.testContactsError(false);
this.testContactsErrorMessage(''); this.testContactsErrorMessage('');
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Result) if (StorageResultType.Success === result && data && data.Result && data.Result.Result)
{ {
this.testContactsSuccess(true); this.testContactsSuccess(true);
} }
else else
{ {
this.testContactsError(true); this.testContactsError(true);
if (oData && oData.Result) if (data && data.Result)
{ {
this.testContactsErrorMessage(oData.Result.Message || ''); this.testContactsErrorMessage(data.Result.Message || '');
} }
else else
{ {
@ -161,74 +155,68 @@ ContactsAdminSettings.prototype.onTestContactsResponse = function(sResult, oData
} }
this.testing(false); this.testing(false);
}; }
ContactsAdminSettings.prototype.onShow = function() onShow() {
{
this.testContactsSuccess(false); this.testContactsSuccess(false);
this.testContactsError(false); this.testContactsError(false);
this.testContactsErrorMessage(''); this.testContactsErrorMessage('');
}; }
ContactsAdminSettings.prototype.onBuild = function() onBuild() {
{ _.delay(() => {
var const
self = this, Remote = require('Remote/Admin/Ajax'),
Remote = require('Remote/Admin/Ajax'); f1 = settingsSaveHelperSimpleFunction(this.pdoDsnTrigger, this),
f3 = settingsSaveHelperSimpleFunction(this.pdoUserTrigger, this),
f4 = settingsSaveHelperSimpleFunction(this.pdoPasswordTrigger, this),
f5 = settingsSaveHelperSimpleFunction(this.contactsTypeTrigger, this);
_.delay(function() { this.enableContacts.subscribe((value) => {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self);
self.enableContacts.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'ContactsEnable': bValue ? '1' : '0' 'ContactsEnable': boolToAjax(value)
}); });
}); });
self.contactsSharing.subscribe(function(bValue) { this.contactsSharing.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'ContactsSharing': bValue ? '1' : '0' 'ContactsSharing': boolToAjax(value)
}); });
}); });
self.contactsSync.subscribe(function(bValue) { this.contactsSync.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'ContactsSync': bValue ? '1' : '0' 'ContactsSync': boolToAjax(value)
}); });
}); });
self.contactsType.subscribe(function(sValue) { this.contactsType.subscribe((value) => {
Remote.saveAdminConfig(f5, { Remote.saveAdminConfig(f5, {
'ContactsPdoType': sValue 'ContactsPdoType': trim(value)
}); });
}); });
self.pdoDsn.subscribe(function(sValue) { this.pdoDsn.subscribe((value) => {
Remote.saveAdminConfig(f1, { Remote.saveAdminConfig(f1, {
'ContactsPdoDsn': Utils.trim(sValue) 'ContactsPdoDsn': trim(value)
}); });
}); });
self.pdoUser.subscribe(function(sValue) { this.pdoUser.subscribe((value) => {
Remote.saveAdminConfig(f3, { Remote.saveAdminConfig(f3, {
'ContactsPdoUser': Utils.trim(sValue) 'ContactsPdoUser': trim(value)
}); });
}); });
self.pdoPassword.subscribe(function(sValue) { this.pdoPassword.subscribe((value) => {
Remote.saveAdminConfig(f4, { Remote.saveAdminConfig(f4, {
'ContactsPdoPassword': Utils.trim(sValue) 'ContactsPdoPassword': trim(value)
}); });
}); });
self.contactsType(Settings.settingsGet('ContactsPdoType')); this.contactsType(settingsGet('ContactsPdoType'));
}, Magics.Time50ms);
}, 50); }
}; }
export {ContactsAdminSettings, ContactsAdminSettings as default}; export {ContactsAdminSettings, ContactsAdminSettings as default};

View file

@ -1,78 +1,68 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {StorageResultType} from 'Common/Enums';
import {showScreenPopup} from 'Knoin/Knoin';
DomainStore = require('Stores/Admin/Domain'), import DomainStore from 'Stores/Admin/Domain';
Remote = require('Remote/Admin/Ajax'); import Remote from 'Remote/Admin/Ajax';
/** class DomainsAdminSettings
* @constructor
*/
function DomainsAdminSettings()
{ {
constructor() {
this.domains = DomainStore.domains; this.domains = DomainStore.domains;
this.visibility = ko.computed(function() { this.visibility = ko.computed(() => (this.domains.loading() ? 'visible' : 'hidden'));
return this.domains.loading() ? 'visible' : 'hidden';
}, this);
this.domainForDeletion = ko.observable(null).deleteAccessHelper(); this.domainForDeletion = ko.observable(null).deleteAccessHelper();
this.onDomainListChangeRequest = _.bind(this.onDomainListChangeRequest, this); this.onDomainListChangeRequest = _.bind(this.onDomainListChangeRequest, this);
this.onDomainLoadRequest = _.bind(this.onDomainLoadRequest, this); this.onDomainLoadRequest = _.bind(this.onDomainLoadRequest, this);
} }
DomainsAdminSettings.prototype.createDomain = function() createDomain() {
{ showScreenPopup(require('View/Popup/Domain'));
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain')); }
};
DomainsAdminSettings.prototype.createDomainAlias = function() createDomainAlias() {
{ showScreenPopup(require('View/Popup/DomainAlias'));
require('Knoin/Knoin').showScreenPopup(require('View/Popup/DomainAlias')); }
};
DomainsAdminSettings.prototype.deleteDomain = function(oDomain) deleteDomain(domain) {
{ this.domains.remove(domain);
this.domains.remove(oDomain); Remote.domainDelete(this.onDomainListChangeRequest, domain.name);
Remote.domainDelete(this.onDomainListChangeRequest, oDomain.name); }
};
DomainsAdminSettings.prototype.disableDomain = function(oDomain) disableDomain(domain) {
{ domain.disabled(!domain.disabled());
oDomain.disabled(!oDomain.disabled()); Remote.domainDisable(this.onDomainListChangeRequest, domain.name, domain.disabled());
Remote.domainDisable(this.onDomainListChangeRequest, oDomain.name, oDomain.disabled()); }
};
DomainsAdminSettings.prototype.onBuild = function(oDom) onBuild(oDom) {
{ const self = this;
var 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() {
var oDomainItem = ko.dataFor(this); const domainItem = ko.dataFor(this);
if (oDomainItem) if (domainItem)
{ {
Remote.domain(self.onDomainLoadRequest, oDomainItem.name); Remote.domain(self.onDomainLoadRequest, domainItem.name);
} }
}); });
require('App/Admin').default.reloadDomainList(); require('App/Admin').default.reloadDomainList();
};
DomainsAdminSettings.prototype.onDomainLoadRequest = function(sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain'), [oData.Result]);
} }
};
DomainsAdminSettings.prototype.onDomainListChangeRequest = function() onDomainLoadRequest(sResult, oData) {
{ if (StorageResultType.Success === sResult && oData && oData.Result)
{
showScreenPopup(require('View/Popup/Domain'), [oData.Result]);
}
}
onDomainListChangeRequest() {
require('App/Admin').default.reloadDomainList(); require('App/Admin').default.reloadDomainList();
}; }
}
export {DomainsAdminSettings, DomainsAdminSettings as default}; export {DomainsAdminSettings, DomainsAdminSettings as default};

View file

@ -1,25 +1,27 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {
Utils = require('Common/Utils'), trim, pInt, boolToAjax, settingsSaveHelperSimpleFunction,
Links = require('Common/Links'), changeTheme, convertThemeName, convertLangName
Translator = require('Common/Translator'), } from 'Common/Utils';
ThemeStore = require('Stores/Theme'), import {SaveSettingsStep, Magics} from 'Common/Enums';
LanguageStore = require('Stores/Language'), import {reload as translatorReload} from 'Common/Translator';
AppAdminStore = require('Stores/Admin/App'), import {phpInfo} from 'Common/Links';
CapaAdminStore = require('Stores/Admin/Capa'),
Settings = require('Storage/Settings'); import {settingsGet} from 'Storage/Settings';
import {showScreenPopup} from 'Knoin/Knoin';
/** import ThemeStore from 'Stores/Theme';
* @constructor import LanguageStore from 'Stores/Language';
*/ import AppAdminStore from 'Stores/Admin/App';
function GeneralAdminSettings() import CapaAdminStore from 'Stores/Admin/Capa';
class GeneralAdminSettings
{ {
constructor() {
this.language = LanguageStore.language; this.language = LanguageStore.language;
this.languages = LanguageStore.languages; this.languages = LanguageStore.languages;
this.languageAdmin = LanguageStore.languageAdmin; this.languageAdmin = LanguageStore.languageAdmin;
@ -39,164 +41,136 @@ function GeneralAdminSettings()
this.allowLanguagesOnSettings = AppAdminStore.allowLanguagesOnSettings; this.allowLanguagesOnSettings = AppAdminStore.allowLanguagesOnSettings;
this.weakPassword = AppAdminStore.weakPassword; this.weakPassword = AppAdminStore.weakPassword;
this.mainAttachmentLimit = ko.observable(Utils.pInt(Settings.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25}); this.mainAttachmentLimit = ko.observable(pInt(settingsGet('AttachmentLimit')) / (Magics.BitLength1024 * Magics.BitLength1024)).extend({posInterer: 25});
this.uploadData = Settings.settingsGet('PhpUploadSizes');
this.uploadData = settingsGet('PhpUploadSizes');
this.uploadDataDesc = this.uploadData && (this.uploadData.upload_max_filesize || this.uploadData.post_max_size) ? [ this.uploadDataDesc = this.uploadData && (this.uploadData.upload_max_filesize || this.uploadData.post_max_size) ? [
this.uploadData.upload_max_filesize ? 'upload_max_filesize = ' + this.uploadData.upload_max_filesize + '; ' : '', this.uploadData.upload_max_filesize ? 'upload_max_filesize = ' + this.uploadData.upload_max_filesize + '; ' : '',
this.uploadData.post_max_size ? 'post_max_size = ' + this.uploadData.post_max_size : '' this.uploadData.post_max_size ? 'post_max_size = ' + this.uploadData.post_max_size : ''
].join('') : ''; ].join('') : '';
this.themesOptions = ko.computed(function() { this.themesOptions = ko.computed(() => _.map(this.themes(), (theme) => ({optValue: theme, optText: convertThemeName(theme)})));
return _.map(this.themes(), function(sTheme) {
return {
optValue: sTheme,
optText: Utils.convertThemeName(sTheme)
};
});
}, this);
this.languageFullName = ko.computed(function() { this.languageFullName = ko.computed(() => convertLangName(this.language()));
return Utils.convertLangName(this.language()); this.languageAdminFullName = ko.computed(() => convertLangName(this.languageAdmin()));
}, this);
this.languageAdminFullName = ko.computed(function() { this.attachmentLimitTrigger = ko.observable(SaveSettingsStep.Idle);
return Utils.convertLangName(this.languageAdmin()); this.languageTrigger = ko.observable(SaveSettingsStep.Idle);
}, this); this.languageAdminTrigger = ko.observable(SaveSettingsStep.Idle).extend({throttle: Magics.Time100ms});
this.themeTrigger = ko.observable(SaveSettingsStep.Idle);
}
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle); onBuild() {
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle); _.delay(() => {
this.languageAdminTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100}); const
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle); Remote = require('Remote/Admin/Ajax'),
} f1 = settingsSaveHelperSimpleFunction(this.attachmentLimitTrigger, this),
f2 = settingsSaveHelperSimpleFunction(this.languageTrigger, this),
GeneralAdminSettings.prototype.onBuild = function() f3 = settingsSaveHelperSimpleFunction(this.themeTrigger, this),
{ fReloadLanguageHelper = (saveSettingsStep) => () => {
var this.languageAdminTrigger(saveSettingsStep);
self = this, _.delay(() => this.languageAdminTrigger(SaveSettingsStep.Idle), Magics.Time1s);
Remote = require('Remote/Admin/Ajax');
_.delay(function() {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self),
fReloadLanguageHelper = function(iSaveSettingsStep) {
return function() {
self.languageAdminTrigger(iSaveSettingsStep);
_.delay(function() {
self.languageAdminTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
};
}; };
self.mainAttachmentLimit.subscribe(function(sValue) { this.mainAttachmentLimit.subscribe((value) => {
Remote.saveAdminConfig(f1, { Remote.saveAdminConfig(f1, {
'AttachmentLimit': Utils.pInt(sValue) 'AttachmentLimit': pInt(value)
}); });
}); });
self.language.subscribe(function(sValue) { this.language.subscribe((value) => {
Remote.saveAdminConfig(f2, { Remote.saveAdminConfig(f2, {
'Language': Utils.trim(sValue) 'Language': trim(value)
}); });
}); });
self.languageAdmin.subscribe(function(sValue) { this.languageAdmin.subscribe((value) => {
this.languageAdminTrigger(SaveSettingsStep.Animate);
self.languageAdminTrigger(Enums.SaveSettingsStep.Animate); translatorReload(true, value).then(
fReloadLanguageHelper(SaveSettingsStep.TrueResult),
Translator.reload(true, sValue).then( fReloadLanguageHelper(SaveSettingsStep.FalseResult)
fReloadLanguageHelper(Enums.SaveSettingsStep.TrueResult), ).then(() => {
fReloadLanguageHelper(Enums.SaveSettingsStep.FalseResult)
).then(function() {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'LanguageAdmin': Utils.trim(sValue) 'LanguageAdmin': trim(value)
});
}); });
}); });
}); this.theme.subscribe((value) => {
changeTheme(value, this.themeTrigger);
self.theme.subscribe(function(sValue) {
Utils.changeTheme(sValue, self.themeTrigger);
Remote.saveAdminConfig(f3, { Remote.saveAdminConfig(f3, {
'Theme': Utils.trim(sValue) 'Theme': trim(value)
}); });
}); });
self.capaAdditionalAccounts.subscribe(function(bValue) { this.capaAdditionalAccounts.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaAdditionalAccounts': bValue ? '1' : '0' 'CapaAdditionalAccounts': boolToAjax(value)
}); });
}); });
self.capaIdentities.subscribe(function(bValue) { this.capaIdentities.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaIdentities': bValue ? '1' : '0' 'CapaIdentities': boolToAjax(value)
}); });
}); });
self.capaTemplates.subscribe(function(bValue) { this.capaTemplates.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaTemplates': bValue ? '1' : '0' 'CapaTemplates': boolToAjax(value)
}); });
}); });
self.capaGravatar.subscribe(function(bValue) { this.capaGravatar.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaGravatar': bValue ? '1' : '0' 'CapaGravatar': boolToAjax(value)
}); });
}); });
self.capaAttachmentThumbnails.subscribe(function(bValue) { this.capaAttachmentThumbnails.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaAttachmentThumbnails': bValue ? '1' : '0' 'CapaAttachmentThumbnails': boolToAjax(value)
}); });
}); });
self.capaThemes.subscribe(function(bValue) { this.capaThemes.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaThemes': bValue ? '1' : '0' 'CapaThemes': boolToAjax(value)
}); });
}); });
self.capaUserBackground.subscribe(function(bValue) { this.capaUserBackground.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaUserBackground': bValue ? '1' : '0' 'CapaUserBackground': boolToAjax(value)
}); });
}); });
self.allowLanguagesOnSettings.subscribe(function(bValue) { this.allowLanguagesOnSettings.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'AllowLanguagesOnSettings': bValue ? '1' : '0' 'AllowLanguagesOnSettings': boolToAjax(value)
}); });
}); });
}, Magics.Time50ms);
}
}, 50); selectLanguage() {
}; showScreenPopup(require('View/Popup/Languages'), [
GeneralAdminSettings.prototype.selectLanguage = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
this.language, this.languages(), LanguageStore.userLanguage() this.language, this.languages(), LanguageStore.userLanguage()
]); ]);
}; }
GeneralAdminSettings.prototype.selectLanguageAdmin = function() selectLanguageAdmin() {
{ showScreenPopup(require('View/Popup/Languages'), [
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
this.languageAdmin, this.languagesAdmin(), LanguageStore.userLanguageAdmin() this.languageAdmin, this.languagesAdmin(), LanguageStore.userLanguageAdmin()
]); ]);
}; }
/** /**
* @returns {string} * @returns {string}
*/ */
GeneralAdminSettings.prototype.phpInfoLink = function() phpInfoLink() {
{ return phpInfo();
return Links.phpInfo(); }
}; }
export {GeneralAdminSettings, GeneralAdminSettings as default}; export {GeneralAdminSettings, GeneralAdminSettings as default};

View file

@ -1,66 +1,55 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {settingsSaveHelperSimpleFunction, boolToAjax, trim} from 'Common/Utils';
Utils = require('Common/Utils'), import {settingsGet} from 'Storage/Settings';
AppAdminStore = require('Stores/Admin/App'), import AppAdminStore from 'Stores/Admin/App';
Settings = require('Storage/Settings'); class LoginAdminSettings
/**
* @constructor
*/
function LoginAdminSettings()
{ {
constructor() {
this.determineUserLanguage = AppAdminStore.determineUserLanguage; this.determineUserLanguage = AppAdminStore.determineUserLanguage;
this.determineUserDomain = AppAdminStore.determineUserDomain; this.determineUserDomain = AppAdminStore.determineUserDomain;
this.defaultDomain = ko.observable(Settings.settingsGet('LoginDefaultDomain')); this.defaultDomain = ko.observable(settingsGet('LoginDefaultDomain')).idleTrigger();
this.allowLanguagesOnLogin = AppAdminStore.allowLanguagesOnLogin; this.allowLanguagesOnLogin = AppAdminStore.allowLanguagesOnLogin;
this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.dummy = ko.observable(false); this.dummy = ko.observable(false);
}
onBuild() {
_.delay(() => {
const
Remote = require('Remote/Admin/Ajax'),
f1 = settingsSaveHelperSimpleFunction(this.defaultDomain.trigger, this);
this.determineUserLanguage.subscribe((value) => {
Remote.saveAdminConfig(null, {
'DetermineUserLanguage': boolToAjax(value)
});
});
this.determineUserDomain.subscribe((value) => {
Remote.saveAdminConfig(null, {
'DetermineUserDomain': boolToAjax(value)
});
});
this.allowLanguagesOnLogin.subscribe((value) => {
Remote.saveAdminConfig(null, {
'AllowLanguagesOnLogin': boolToAjax(value)
});
});
this.defaultDomain.subscribe((value) => {
Remote.saveAdminConfig(f1, {
'LoginDefaultDomain': trim(value)
});
});
}, 50);
}
} }
LoginAdminSettings.prototype.onBuild = function()
{
var
self = this,
Remote = require('Remote/Admin/Ajax');
_.delay(function() {
var f1 = Utils.settingsSaveHelperSimpleFunction(self.defaultDomainTrigger, self);
self.determineUserLanguage.subscribe(function(bValue) {
Remote.saveAdminConfig(null, {
'DetermineUserLanguage': bValue ? '1' : '0'
});
});
self.determineUserDomain.subscribe(function(bValue) {
Remote.saveAdminConfig(null, {
'DetermineUserDomain': bValue ? '1' : '0'
});
});
self.allowLanguagesOnLogin.subscribe(function(bValue) {
Remote.saveAdminConfig(null, {
'AllowLanguagesOnLogin': bValue ? '1' : '0'
});
});
self.defaultDomain.subscribe(function(sValue) {
Remote.saveAdminConfig(f1, {
'LoginDefaultDomain': Utils.trim(sValue)
});
});
}, 50);
};
export {LoginAdminSettings, LoginAdminSettings as default}; export {LoginAdminSettings, LoginAdminSettings as default};

View file

@ -1,80 +1,63 @@
var import window from 'window';
window = require('window'), import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {StorageResultType, Notification} from 'Common/Enums';
Translator = require('Common/Translator'), import {getNotification} from 'Common/Translator';
PackageStore = require('Stores/Admin/Package'), import PackageStore from 'Stores/Admin/Package';
Remote = require('Remote/Admin/Ajax'); import Remote from 'Remote/Admin/Ajax';
/** class PackagesAdminSettings
* @constructor
*/
function PackagesAdminSettings()
{ {
constructor() {
this.packagesError = ko.observable(''); this.packagesError = ko.observable('');
this.packages = PackageStore.packages; this.packages = PackageStore.packages;
this.packagesReal = PackageStore.packagesReal; this.packagesReal = PackageStore.packagesReal;
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable; this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
this.packagesCurrent = this.packages.filter(function(item) { this.packagesCurrent = this.packages.filter((item) => item && '' !== item.installed && !item.compare);
return item && '' !== item.installed && !item.compare; this.packagesAvailableForUpdate = this.packages.filter((item) => item && '' !== item.installed && !!item.compare);
}); this.packagesAvailableForInstallation = this.packages.filter((item) => item && '' === item.installed);
this.packagesAvailableForUpdate = this.packages.filter(function(item) { this.visibility = ko.computed(() => (PackageStore.packages.loading() ? 'visible' : 'hidden'));
return item && '' !== item.installed && !!item.compare; }
});
this.packagesAvailableForInstallation = this.packages.filter(function(item) { onShow() {
return item && '' === item.installed;
});
this.visibility = ko.computed(function() {
return PackageStore.packages.loading() ? 'visible' : 'hidden';
}, this);
}
PackagesAdminSettings.prototype.onShow = function()
{
this.packagesError(''); this.packagesError('');
}; }
PackagesAdminSettings.prototype.onBuild = function() onBuild() {
{
require('App/Admin').default.reloadPackagesList(); require('App/Admin').default.reloadPackagesList();
}; }
PackagesAdminSettings.prototype.requestHelper = function(oPackage, bInstall) requestHelper(packageToRequest, install) {
{ return (result, data) => {
var self = this;
return function(sResult, oData) {
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) if (StorageResultType.Success !== result || !data || !data.Result)
{ {
if (oData && oData.ErrorCode) if (data && data.ErrorCode)
{ {
self.packagesError(Translator.getNotification(oData.ErrorCode)); this.packagesError(getNotification(data.ErrorCode));
} }
else else
{ {
self.packagesError(Translator.getNotification( this.packagesError(getNotification(
bInstall ? Enums.Notification.CantInstallPackage : Enums.Notification.CantDeletePackage)); install ? Notification.CantInstallPackage : Notification.CantDeletePackage));
} }
} }
_.each(self.packages(), function(item) { _.each(this.packages(), (item) => {
if (item && oPackage && item.loading && item.loading() && oPackage.file === item.file) if (item && packageToRequest && item.loading && item.loading() && packageToRequest.file === item.file)
{ {
oPackage.loading(false); packageToRequest.loading(false);
item.loading(false); item.loading(false);
} }
}); });
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Reload) if (StorageResultType.Success === result && data && data.Result && data.Result.Reload)
{ {
window.location.reload(); window.location.reload();
} }
@ -83,24 +66,23 @@ PackagesAdminSettings.prototype.requestHelper = function(oPackage, bInstall)
require('App/Admin').default.reloadPackagesList(); require('App/Admin').default.reloadPackagesList();
} }
}; };
};
PackagesAdminSettings.prototype.deletePackage = function(oPackage)
{
if (oPackage)
{
oPackage.loading(true);
Remote.packageDelete(this.requestHelper(oPackage, false), oPackage);
} }
};
PackagesAdminSettings.prototype.installPackage = function(oPackage) deletePackage(packageToDelete) {
{ if (packageToDelete)
if (oPackage)
{ {
oPackage.loading(true); packageToDelete.loading(true);
Remote.packageInstall(this.requestHelper(oPackage, true), oPackage); Remote.packageDelete(this.requestHelper(packageToDelete, false), packageToDelete);
} }
}; }
installPackage(packageToInstall) {
if (packageToInstall)
{
packageToInstall.loading(true);
Remote.packageInstall(this.requestHelper(packageToInstall, true), packageToInstall);
}
}
}
export {PackagesAdminSettings, PackagesAdminSettings as default}; export {PackagesAdminSettings, PackagesAdminSettings as default};

View file

@ -1,109 +1,99 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {StorageResultType, Notification} from 'Common/Enums';
Utils = require('Common/Utils'), import {getNotification} from 'Common/Translator';
Translator = require('Common/Translator'), import {boolToAjax} from 'Common/Utils';
Settings = require('Storage/Settings'), import {settingsGet} from 'Storage/Settings';
import {showScreenPopup} from 'Knoin/Knoin';
AppStore = require('Stores/Admin/App'), import AppStore from 'Stores/Admin/App';
PluginStore = require('Stores/Admin/Plugin'), import PluginStore from 'Stores/Admin/Plugin';
Remote = require('Remote/Admin/Ajax'); import Remote from 'Remote/Admin/Ajax';
/** class PluginsAdminSettings
* @constructor
*/
function PluginsAdminSettings()
{ {
this.enabledPlugins = ko.observable(!!Settings.settingsGet('EnabledPlugins')); constructor() {
this.enabledPlugins = ko.observable(!!settingsGet('EnabledPlugins'));
this.plugins = PluginStore.plugins; this.plugins = PluginStore.plugins;
this.pluginsError = PluginStore.plugins.error; this.pluginsError = PluginStore.plugins.error;
this.community = RL_COMMUNITY || AppStore.community(); this.community = RL_COMMUNITY || AppStore.community();
this.visibility = ko.computed(function() { this.visibility = ko.computed(() => (PluginStore.plugins.loading() ? 'visible' : 'hidden'));
return PluginStore.plugins.loading() ? 'visible' : 'hidden';
}, this);
this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this); this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this);
this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this); this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this);
} }
PluginsAdminSettings.prototype.disablePlugin = function(oPlugin) disablePlugin(plugin) {
{ plugin.disabled(!plugin.disabled());
oPlugin.disabled(!oPlugin.disabled()); Remote.pluginDisable(this.onPluginDisableRequest, plugin.name, plugin.disabled());
Remote.pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled()); }
};
PluginsAdminSettings.prototype.configurePlugin = function(oPlugin) configurePlugin(plugin) {
{ Remote.plugin(this.onPluginLoadRequest, plugin.name);
Remote.plugin(this.onPluginLoadRequest, oPlugin.name); }
};
PluginsAdminSettings.prototype.onBuild = function(oDom)
{
var self = this;
onBuild(oDom) {
const self = this;
oDom oDom
.on('click', '.e-item .configure-plugin-action', function() { .on('click', '.e-item .configure-plugin-action', function() {
var oPlugin = ko.dataFor(this); const plugin = ko.dataFor(this);
if (oPlugin) if (plugin)
{ {
self.configurePlugin(oPlugin); self.configurePlugin(plugin);
} }
}) })
.on('click', '.e-item .disabled-plugin', function() { .on('click', '.e-item .disabled-plugin', function() {
var oPlugin = ko.dataFor(this); const plugin = ko.dataFor(this);
if (oPlugin) if (plugin)
{ {
self.disablePlugin(oPlugin); self.disablePlugin(plugin);
} }
}); });
this.enabledPlugins.subscribe(function(bValue) { this.enabledPlugins.subscribe((value) => {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(null, {
'EnabledPlugins': bValue ? '1' : '0' 'EnabledPlugins': boolToAjax(value)
}); });
}); });
}; }
PluginsAdminSettings.prototype.onShow = function() onShow() {
{
PluginStore.plugins.error(''); PluginStore.plugins.error('');
require('App/Admin').default.reloadPluginList(); require('App/Admin').default.reloadPluginList();
};
PluginsAdminSettings.prototype.onPluginLoadRequest = function(sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Plugin'), [oData.Result]);
} }
};
PluginsAdminSettings.prototype.onPluginDisableRequest = function(sResult, oData) onPluginLoadRequest(result, data) {
{ if (StorageResultType.Success === result && data && data.Result)
if (Enums.StorageResultType.Success === sResult && oData)
{ {
if (!oData.Result && oData.ErrorCode) showScreenPopup(require('View/Popup/Plugin'), [data.Result]);
}
}
onPluginDisableRequest(result, data) {
if (StorageResultType.Success === result && data)
{ {
if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage) if (!data.Result && data.ErrorCode)
{ {
PluginStore.plugins.error(oData.ErrorMessage); if (Notification.UnsupportedPluginPackage === data.ErrorCode && data.ErrorMessage && '' !== data.ErrorMessage)
{
PluginStore.plugins.error(data.ErrorMessage);
} }
else else
{ {
PluginStore.plugins.error(Translator.getNotification(oData.ErrorCode)); PluginStore.plugins.error(getNotification(data.ErrorCode));
} }
} }
} }
require('App/Admin').default.reloadPluginList(); require('App/Admin').default.reloadPluginList();
}; }
}
export {PluginsAdminSettings, PluginsAdminSettings as default}; export {PluginsAdminSettings, PluginsAdminSettings as default};

View file

@ -1,23 +1,21 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {createCommand, trim, boolToAjax} from 'Common/Utils';
Utils = require('Common/Utils'), import {phpInfo} from 'Common/Links';
Links = require('Common/Links'), import {StorageResultType} from 'Common/Enums';
AppAdminStore = require('Stores/Admin/App'), import {settingsGet} from 'Storage/Settings';
CapaAdminStore = require('Stores/Admin/Capa'),
Settings = require('Storage/Settings'), import AppAdminStore from 'Stores/Admin/App';
Remote = require('Remote/Admin/Ajax'); import CapaAdminStore from 'Stores/Admin/Capa';
/** import Remote from 'Remote/Admin/Ajax';
* @constructor
*/ class SecurityAdminSettings
function SecurityAdminSettings()
{ {
constructor() {
this.useLocalProxyForExternalImages = AppAdminStore.useLocalProxyForExternalImages; this.useLocalProxyForExternalImages = AppAdminStore.useLocalProxyForExternalImages;
this.weakPassword = AppAdminStore.weakPassword; this.weakPassword = AppAdminStore.weakPassword;
@ -27,24 +25,24 @@ function SecurityAdminSettings()
this.capaTwoFactorAuth = CapaAdminStore.twoFactorAuth; this.capaTwoFactorAuth = CapaAdminStore.twoFactorAuth;
this.capaTwoFactorAuthForce = CapaAdminStore.twoFactorAuthForce; this.capaTwoFactorAuthForce = CapaAdminStore.twoFactorAuthForce;
this.capaTwoFactorAuth.subscribe(function(bValue) { this.capaTwoFactorAuth.subscribe((value) => {
if (!bValue) if (!value)
{ {
this.capaTwoFactorAuthForce(false); this.capaTwoFactorAuthForce(false);
} }
}, this); });
this.verifySslCertificate = ko.observable(!!Settings.settingsGet('VerifySslCertificate')); this.verifySslCertificate = ko.observable(!!settingsGet('VerifySslCertificate'));
this.allowSelfSigned = ko.observable(!!Settings.settingsGet('AllowSelfSigned')); this.allowSelfSigned = ko.observable(!!settingsGet('AllowSelfSigned'));
this.verifySslCertificate.subscribe(function(bValue) { this.verifySslCertificate.subscribe((value) => {
if (!bValue) if (!value)
{ {
this.allowSelfSigned(true); this.allowSelfSigned(true);
} }
}, this); });
this.adminLogin = ko.observable(Settings.settingsGet('AdminLogin')); this.adminLogin = ko.observable(settingsGet('AdminLogin'));
this.adminLoginError = ko.observable(false); this.adminLoginError = ko.observable(false);
this.adminPassword = ko.observable(''); this.adminPassword = ko.observable('');
this.adminPasswordNew = ko.observable(''); this.adminPasswordNew = ko.observable('');
@ -54,30 +52,30 @@ function SecurityAdminSettings()
this.adminPasswordUpdateError = ko.observable(false); this.adminPasswordUpdateError = ko.observable(false);
this.adminPasswordUpdateSuccess = ko.observable(false); this.adminPasswordUpdateSuccess = ko.observable(false);
this.adminPassword.subscribe(function() { this.adminPassword.subscribe(() => {
this.adminPasswordUpdateError(false); this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false); this.adminPasswordUpdateSuccess(false);
}, this); });
this.adminLogin.subscribe(function() { this.adminLogin.subscribe(() => {
this.adminLoginError(false); this.adminLoginError(false);
}, this); });
this.adminPasswordNew.subscribe(function() { this.adminPasswordNew.subscribe(() => {
this.adminPasswordUpdateError(false); this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false); this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false); this.adminPasswordNewError(false);
}, this); });
this.adminPasswordNew2.subscribe(function() { this.adminPasswordNew2.subscribe(() => {
this.adminPasswordUpdateError(false); this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false); this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false); this.adminPasswordNewError(false);
}, this); });
this.saveNewAdminPasswordCommand = Utils.createCommand(this, function() { this.saveNewAdminPasswordCommand = createCommand(this, () => {
if ('' === Utils.trim(this.adminLogin())) if ('' === trim(this.adminLogin()))
{ {
this.adminLoginError(true); this.adminLoginError(true);
return false; return false;
@ -99,17 +97,13 @@ function SecurityAdminSettings()
}); });
return true; return true;
}, () => '' !== trim(this.adminLogin()) && '' !== this.adminPassword());
}, function() {
return '' !== Utils.trim(this.adminLogin()) && '' !== this.adminPassword();
});
this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this); this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this);
} }
SecurityAdminSettings.prototype.onNewAdminPasswordResponse = function(sResult, oData) onNewAdminPasswordResponse(result, data) {
{ if (StorageResultType.Success === result && data && data.Result)
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
this.adminPassword(''); this.adminPassword('');
this.adminPasswordNew(''); this.adminPasswordNew('');
@ -117,66 +111,64 @@ SecurityAdminSettings.prototype.onNewAdminPasswordResponse = function(sResult, o
this.adminPasswordUpdateSuccess(true); this.adminPasswordUpdateSuccess(true);
this.weakPassword(!!oData.Result.Weak); this.weakPassword(!!data.Result.Weak);
} }
else else
{ {
this.adminPasswordUpdateError(true); this.adminPasswordUpdateError(true);
} }
}; }
SecurityAdminSettings.prototype.onBuild = function() onBuild() {
{ this.capaOpenPGP.subscribe((value) => {
this.capaOpenPGP.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'CapaOpenPGP': bValue ? '1' : '0'
});
});
this.capaTwoFactorAuth.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'CapaTwoFactorAuth': bValue ? '1' : '0'
});
});
this.capaTwoFactorAuthForce.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'CapaTwoFactorAuthForce': bValue ? '1' : '0'
});
});
this.useLocalProxyForExternalImages.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'UseLocalProxyForExternalImages': bValue ? '1' : '0' 'CapaOpenPGP': boolToAjax(value)
}); });
}); });
this.verifySslCertificate.subscribe(function(bValue) { this.capaTwoFactorAuth.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'VerifySslCertificate': bValue ? '1' : '0' 'CapaTwoFactorAuth': boolToAjax(value)
}); });
}); });
this.allowSelfSigned.subscribe(function(bValue) { this.capaTwoFactorAuthForce.subscribe((value) => {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'AllowSelfSigned': bValue ? '1' : '0' 'CapaTwoFactorAuthForce': boolToAjax(value)
}); });
}); });
};
SecurityAdminSettings.prototype.onHide = function() this.useLocalProxyForExternalImages.subscribe((value) => {
{ Remote.saveAdminConfig(null, {
'UseLocalProxyForExternalImages': boolToAjax(value)
});
});
this.verifySslCertificate.subscribe((value) => {
Remote.saveAdminConfig(null, {
'VerifySslCertificate': boolToAjax(value)
});
});
this.allowSelfSigned.subscribe((value) => {
Remote.saveAdminConfig(null, {
'AllowSelfSigned': boolToAjax(value)
});
});
}
onHide() {
this.adminPassword(''); this.adminPassword('');
this.adminPasswordNew(''); this.adminPasswordNew('');
this.adminPasswordNew2(''); this.adminPasswordNew2('');
}; }
/** /**
* @returns {string} * @returns {string}
*/ */
SecurityAdminSettings.prototype.phpInfoLink = function() phpInfoLink() {
{ return phpInfo();
return Links.phpInfo(); }
}; }
export {SecurityAdminSettings, SecurityAdminSettings as default}; export {SecurityAdminSettings, SecurityAdminSettings as default};

View file

@ -1,18 +1,15 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {SaveSettingsStep, Magics} from 'Common/Enums';
Utils = require('Common/Utils'); import {settingsSaveHelperSimpleFunction, trim, boolToAjax} from 'Common/Utils';
/** import SocialStore from 'Stores/Social';
* @constructor
*/ class SocialAdminSettings
function SocialAdminSettings()
{ {
var SocialStore = require('Stores/Social'); constructor() {
this.googleEnable = SocialStore.google.enabled; this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth; this.googleEnableAuth = SocialStore.google.capa.auth;
this.googleEnableAuthFast = SocialStore.google.capa.authFast; this.googleEnableAuthFast = SocialStore.google.capa.authFast;
@ -26,149 +23,87 @@ function SocialAdminSettings()
this.googleClientSecret = SocialStore.google.clientSecret; this.googleClientSecret = SocialStore.google.clientSecret;
this.googleApiKey = SocialStore.google.apiKey; this.googleApiKey = SocialStore.google.apiKey;
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); this.googleTrigger1 = ko.observable(SaveSettingsStep.Idle);
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle); this.googleTrigger2 = ko.observable(SaveSettingsStep.Idle);
this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle); this.googleTrigger3 = ko.observable(SaveSettingsStep.Idle);
this.facebookSupported = SocialStore.facebook.supported; this.facebookSupported = SocialStore.facebook.supported;
this.facebookEnable = SocialStore.facebook.enabled; this.facebookEnable = SocialStore.facebook.enabled;
this.facebookAppID = SocialStore.facebook.appID; this.facebookAppID = SocialStore.facebook.appID;
this.facebookAppSecret = SocialStore.facebook.appSecret; this.facebookAppSecret = SocialStore.facebook.appSecret;
this.facebookTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); this.facebookTrigger1 = ko.observable(SaveSettingsStep.Idle);
this.facebookTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle); this.facebookTrigger2 = ko.observable(SaveSettingsStep.Idle);
this.twitterEnable = SocialStore.twitter.enabled; this.twitterEnable = SocialStore.twitter.enabled;
this.twitterConsumerKey = SocialStore.twitter.consumerKey; this.twitterConsumerKey = SocialStore.twitter.consumerKey;
this.twitterConsumerSecret = SocialStore.twitter.consumerSecret; this.twitterConsumerSecret = SocialStore.twitter.consumerSecret;
this.twitterTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); this.twitterTrigger1 = ko.observable(SaveSettingsStep.Idle);
this.twitterTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle); this.twitterTrigger2 = ko.observable(SaveSettingsStep.Idle);
this.dropboxEnable = SocialStore.dropbox.enabled; this.dropboxEnable = SocialStore.dropbox.enabled;
this.dropboxApiKey = SocialStore.dropbox.apiKey; this.dropboxApiKey = SocialStore.dropbox.apiKey;
this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); this.dropboxTrigger1 = ko.observable(SaveSettingsStep.Idle);
} }
SocialAdminSettings.prototype.onBuild = function() onBuild() {
{ _.delay(() => {
var const
self = this, Remote = require('Remote/Admin/Ajax'),
Remote = require('Remote/Admin/Ajax'); f1 = settingsSaveHelperSimpleFunction(this.facebookTrigger1, this),
f2 = settingsSaveHelperSimpleFunction(this.facebookTrigger2, this),
f3 = settingsSaveHelperSimpleFunction(this.twitterTrigger1, this),
f4 = settingsSaveHelperSimpleFunction(this.twitterTrigger2, this),
f5 = settingsSaveHelperSimpleFunction(this.googleTrigger1, this),
f6 = settingsSaveHelperSimpleFunction(this.googleTrigger2, this),
f7 = settingsSaveHelperSimpleFunction(this.googleTrigger3, this),
f8 = settingsSaveHelperSimpleFunction(this.dropboxTrigger1, this);
_.delay(function() { this.facebookEnable.subscribe((value) => {
if (this.facebookSupported())
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger1, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger2, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger1, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self),
f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self),
f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self),
f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self);
self.facebookEnable.subscribe(function(bValue) {
if (self.facebookSupported())
{ {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(null, {
'FacebookEnable': bValue ? '1' : '0' 'FacebookEnable': boolToAjax(value)
}); });
} }
}); });
self.facebookAppID.subscribe(function(sValue) { this.facebookAppID.subscribe((value) => {
if (self.facebookSupported()) if (this.facebookSupported())
{ {
Remote.saveAdminConfig(f1, { Remote.saveAdminConfig(f1, {
'FacebookAppID': Utils.trim(sValue) 'FacebookAppID': trim(value)
}); });
} }
}); });
self.facebookAppSecret.subscribe(function(sValue) { this.facebookAppSecret.subscribe((value) => {
if (self.facebookSupported()) if (this.facebookSupported())
{ {
Remote.saveAdminConfig(f2, { Remote.saveAdminConfig(f2, {
'FacebookAppSecret': Utils.trim(sValue) 'FacebookAppSecret': trim(value)
}); });
} }
}); });
self.twitterEnable.subscribe(function(bValue) { this.twitterEnable.subscribe(Remote.saveAdminConfigHelper('TwitterEnable', boolToAjax));
Remote.saveAdminConfig(Utils.noop, { this.twitterConsumerKey.subscribe(Remote.saveAdminConfigHelper('TwitterConsumerKey', trim, f3));
'TwitterEnable': bValue ? '1' : '0' this.twitterConsumerSecret.subscribe(Remote.saveAdminConfigHelper('TwitterConsumerSecret', trim, f4));
});
});
self.twitterConsumerKey.subscribe(function(sValue) { this.googleEnable.subscribe(Remote.saveAdminConfigHelper('GoogleEnable', boolToAjax));
Remote.saveAdminConfig(f3, { this.googleEnableAuth.subscribe(Remote.saveAdminConfigHelper('GoogleEnableAuth', boolToAjax));
'TwitterConsumerKey': Utils.trim(sValue) this.googleEnableDrive.subscribe(Remote.saveAdminConfigHelper('GoogleEnableDrive', boolToAjax));
}); this.googleEnablePreview.subscribe(Remote.saveAdminConfigHelper('GoogleEnablePreview', boolToAjax));
}); this.googleClientID.subscribe(Remote.saveAdminConfigHelper('GoogleClientID', trim, f5));
this.googleClientSecret.subscribe(Remote.saveAdminConfigHelper('GoogleClientSecret', trim, f6));
this.googleApiKey.subscribe(Remote.saveAdminConfigHelper('GoogleApiKey', trim, f7));
self.twitterConsumerSecret.subscribe(function(sValue) { this.dropboxEnable.subscribe(Remote.saveAdminConfigHelper('DropboxEnable', boolToAjax));
Remote.saveAdminConfig(f4, { this.dropboxApiKey.subscribe(Remote.saveAdminConfigHelper('DropboxApiKey', trim, f8));
'TwitterConsumerSecret': Utils.trim(sValue) }, Magics.Time50ms);
}); }
}); }
self.googleEnable.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'GoogleEnable': bValue ? '1' : '0'
});
});
self.googleEnableAuth.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'GoogleEnableAuth': bValue ? '1' : '0'
});
});
self.googleEnableDrive.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'GoogleEnableDrive': bValue ? '1' : '0'
});
});
self.googleEnablePreview.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'GoogleEnablePreview': bValue ? '1' : '0'
});
});
self.googleClientID.subscribe(function(sValue) {
Remote.saveAdminConfig(f5, {
'GoogleClientID': Utils.trim(sValue)
});
});
self.googleClientSecret.subscribe(function(sValue) {
Remote.saveAdminConfig(f6, {
'GoogleClientSecret': Utils.trim(sValue)
});
});
self.googleApiKey.subscribe(function(sValue) {
Remote.saveAdminConfig(f7, {
'GoogleApiKey': Utils.trim(sValue)
});
});
self.dropboxEnable.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'DropboxEnable': bValue ? '1' : '0'
});
});
self.dropboxApiKey.subscribe(function(sValue) {
Remote.saveAdminConfig(f8, {
'DropboxApiKey': Utils.trim(sValue)
});
});
}, 50);
};
export {SocialAdminSettings, SocialAdminSettings as default}; export {SocialAdminSettings, SocialAdminSettings as default};

View file

@ -1,154 +1,135 @@
var import window from 'window';
window = require('window'), import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {Capa, StorageResultType} from 'Common/Enums';
Links = require('Common/Links'), import {root} from 'Common/Links';
AccountStore = require('Stores/User/Account'), import {capa} from 'Storage/Settings';
IdentityStore = require('Stores/User/Identity'),
Settings = require('Storage/Settings'), import {showScreenPopup, routeOff, setHash} from 'Knoin/Knoin';
Remote = require('Remote/User/Ajax');
/** import AccountStore from 'Stores/User/Account';
* @constructor import IdentityStore from 'Stores/User/Identity';
*/ import Remote from 'Remote/User/Ajax';
function AccountsUserSettings()
class AccountsUserSettings
{ {
this.allowAdditionalAccount = Settings.capa(Enums.Capa.AdditionalAccounts); constructor() {
this.allowIdentities = Settings.capa(Enums.Capa.Identities); this.allowAdditionalAccount = capa(Capa.AdditionalAccounts);
this.allowIdentities = capa(Capa.Identities);
this.accounts = AccountStore.accounts; this.accounts = AccountStore.accounts;
this.identities = IdentityStore.identities; this.identities = IdentityStore.identities;
this.accountForDeletion = ko.observable(null).deleteAccessHelper(); this.accountForDeletion = ko.observable(null).deleteAccessHelper();
this.identityForDeletion = ko.observable(null).deleteAccessHelper(); this.identityForDeletion = ko.observable(null).deleteAccessHelper();
} }
AccountsUserSettings.prototype.scrollableOptions = function(sWrapper) scrollableOptions(wrapper) {
{
return { return {
handle: '.drag-handle', handle: '.drag-handle',
containment: sWrapper || 'parent', containment: wrapper || 'parent',
axis: 'y' axis: 'y'
}; };
};
AccountsUserSettings.prototype.addNewAccount = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'));
};
AccountsUserSettings.prototype.editAccount = function(oAccountItem)
{
if (oAccountItem && oAccountItem.canBeEdit())
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'), [oAccountItem]);
} }
};
AccountsUserSettings.prototype.addNewIdentity = function() addNewAccount() {
{ showScreenPopup(require('View/Popup/Account'));
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity')); }
};
AccountsUserSettings.prototype.editIdentity = function(oIdentity) editAccount(account) {
{ if (account && account.canBeEdit())
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]); {
}; showScreenPopup(require('View/Popup/Account'), [account]);
}
}
/** addNewIdentity() {
* @param {AccountModel} oAccountToRemove showScreenPopup(require('View/Popup/Identity'));
}
editIdentity(identity) {
showScreenPopup(require('View/Popup/Identity'), [identity]);
}
/**
* @param {AccountModel} accountToRemove
* @returns {void}
*/ */
AccountsUserSettings.prototype.deleteAccount = function(oAccountToRemove) deleteAccount(accountToRemove) {
{ if (accountToRemove && accountToRemove.deleteAccess())
if (oAccountToRemove && oAccountToRemove.deleteAccess())
{ {
this.accountForDeletion(null); this.accountForDeletion(null);
if (accountToRemove)
var
kn = require('Knoin/Knoin'),
fRemoveAccount = function(oAccount) {
return oAccountToRemove === oAccount;
};
if (oAccountToRemove)
{ {
this.accounts.remove(fRemoveAccount); this.accounts.remove((account) => accountToRemove === account);
Remote.accountDelete(function(sResult, oData) { Remote.accountDelete(function(result, data) {
if (Enums.StorageResultType.Success === sResult && oData && if (StorageResultType.Success === result && data && data.Result && data.Reload)
oData.Result && oData.Reload)
{ {
kn.routeOff(); routeOff();
kn.setHash(Links.root(), true); setHash(root(), true);
kn.routeOff(); routeOff();
_.defer(function() { _.defer(() => window.location.reload());
window.location.reload();
});
} }
else else
{ {
require('App/User').default.accountsAndIdentities(); require('App/User').default.accountsAndIdentities();
} }
}, oAccountToRemove.email); }, accountToRemove.email);
}
} }
} }
};
/** /**
* @param {IdentityModel} oIdentityToRemove * @param {IdentityModel} identityToRemove
* @returns {void}
*/ */
AccountsUserSettings.prototype.deleteIdentity = function(oIdentityToRemove) deleteIdentity(identityToRemove) {
{ if (identityToRemove && identityToRemove.deleteAccess())
if (oIdentityToRemove && oIdentityToRemove.deleteAccess())
{ {
this.identityForDeletion(null); this.identityForDeletion(null);
if (oIdentityToRemove) if (identityToRemove)
{ {
IdentityStore.identities.remove(function(oIdentity) { IdentityStore.identities.remove((oIdentity) => identityToRemove === oIdentity);
return oIdentityToRemove === oIdentity;
});
Remote.identityDelete(function() { Remote.identityDelete(() => {
require('App/User').default.accountsAndIdentities(); require('App/User').default.accountsAndIdentities();
}, oIdentityToRemove.id); }, identityToRemove.id);
}
} }
} }
};
AccountsUserSettings.prototype.accountsAndIdentitiesAfterMove = function() accountsAndIdentitiesAfterMove() {
{
Remote.accountsAndIdentitiesSortOrder(null, Remote.accountsAndIdentitiesSortOrder(null,
AccountStore.accountsEmails.peek(), IdentityStore.identitiesIDS.peek()); AccountStore.accountsEmails.peek(), IdentityStore.identitiesIDS.peek());
}; }
AccountsUserSettings.prototype.onBuild = function(oDom) onBuild(oDom) {
{
var self = this; var self = this;
oDom oDom
.on('click', '.accounts-list .account-item .e-action', function() { .on('click', '.accounts-list .account-item .e-action', function() {
var oAccountItem = ko.dataFor(this); const account = ko.dataFor(this);
if (oAccountItem) if (account)
{ {
self.editAccount(oAccountItem); self.editAccount(account);
} }
}) })
.on('click', '.identities-list .identity-item .e-action', function() { .on('click', '.identities-list .identity-item .e-action', function() {
var oIdentityItem = ko.dataFor(this); const identity = ko.dataFor(this);
if (oIdentityItem) if (identity)
{ {
self.editIdentity(oIdentityItem); self.editIdentity(identity);
} }
}); });
}; }
}
export {AccountsUserSettings, AccountsUserSettings as default}; export {AccountsUserSettings, AccountsUserSettings as default};

View file

@ -1,19 +1,16 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {StorageResultType, Notification} from 'Common/Enums';
Utils = require('Common/Utils'), import {createCommand} from 'Common/Utils';
Translator = require('Common/Translator'), import {getNotificationFromResponse, i18n} from 'Common/Translator';
Remote = require('Remote/User/Ajax'); import Remote from 'Remote/User/Ajax';
/** class ChangePasswordUserSettings
* @constructor
*/
function ChangePasswordUserSettings()
{ {
constructor() {
this.changeProcess = ko.observable(false); this.changeProcess = ko.observable(false);
this.errorDescription = ko.observable(''); this.errorDescription = ko.observable('');
@ -26,30 +23,29 @@ function ChangePasswordUserSettings()
this.newPassword = ko.observable(''); this.newPassword = ko.observable('');
this.newPassword2 = ko.observable(''); this.newPassword2 = ko.observable('');
this.currentPassword.subscribe(function() { this.currentPassword.subscribe(() => {
this.passwordUpdateError(false); this.passwordUpdateError(false);
this.passwordUpdateSuccess(false); this.passwordUpdateSuccess(false);
this.currentPassword.error(false); this.currentPassword.error(false);
}, this); });
this.newPassword.subscribe(function() { this.newPassword.subscribe(() => {
this.passwordUpdateError(false); this.passwordUpdateError(false);
this.passwordUpdateSuccess(false); this.passwordUpdateSuccess(false);
this.passwordMismatch(false); this.passwordMismatch(false);
}, this); });
this.newPassword2.subscribe(function() { this.newPassword2.subscribe(() => {
this.passwordUpdateError(false); this.passwordUpdateError(false);
this.passwordUpdateSuccess(false); this.passwordUpdateSuccess(false);
this.passwordMismatch(false); this.passwordMismatch(false);
}, this); });
this.saveNewPasswordCommand = Utils.createCommand(this, function() {
this.saveNewPasswordCommand = createCommand(this, () => {
if (this.newPassword() !== this.newPassword2()) if (this.newPassword() !== this.newPassword2())
{ {
this.passwordMismatch(true); this.passwordMismatch(true);
this.errorDescription(Translator.i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH')); this.errorDescription(i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH'));
} }
else else
{ {
@ -64,16 +60,12 @@ function ChangePasswordUserSettings()
Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword()); Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword());
} }
}, function() { }, () => !this.changeProcess() && '' !== this.currentPassword() && '' !== this.newPassword() && '' !== this.newPassword2());
return !this.changeProcess() && '' !== this.currentPassword() &&
'' !== this.newPassword() && '' !== this.newPassword2();
});
this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this); this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this);
} }
ChangePasswordUserSettings.prototype.onHide = function() onHide() {
{
this.changeProcess(false); this.changeProcess(false);
this.currentPassword(''); this.currentPassword('');
this.newPassword(''); this.newPassword('');
@ -81,16 +73,15 @@ ChangePasswordUserSettings.prototype.onHide = function()
this.errorDescription(''); this.errorDescription('');
this.passwordMismatch(false); this.passwordMismatch(false);
this.currentPassword.error(false); this.currentPassword.error(false);
}; }
ChangePasswordUserSettings.prototype.onChangePasswordResponse = function(sResult, oData) onChangePasswordResponse(result, data) {
{
this.changeProcess(false); this.changeProcess(false);
this.passwordMismatch(false); this.passwordMismatch(false);
this.errorDescription(''); this.errorDescription('');
this.currentPassword.error(false); this.currentPassword.error(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (StorageResultType.Success === result && data && data.Result)
{ {
this.currentPassword(''); this.currentPassword('');
this.newPassword(''); this.newPassword('');
@ -99,19 +90,19 @@ ChangePasswordUserSettings.prototype.onChangePasswordResponse = function(sResult
this.passwordUpdateSuccess(true); this.passwordUpdateSuccess(true);
this.currentPassword.error(false); this.currentPassword.error(false);
require('App/User').default.setClientSideToken(oData.Result); require('App/User').default.setClientSideToken(data.Result);
} }
else else
{ {
if (oData && Enums.Notification.CurrentPasswordIncorrect === oData.ErrorCode) if (data && Notification.CurrentPasswordIncorrect === data.ErrorCode)
{ {
this.currentPassword.error(true); this.currentPassword.error(true);
} }
this.passwordUpdateError(true); this.passwordUpdateError(true);
this.errorDescription( this.errorDescription(getNotificationFromResponse(data, Notification.CouldNotSaveNewPassword));
Translator.getNotificationFromResponse(oData, Enums.Notification.CouldNotSaveNewPassword));
} }
}; }
}
export {ChangePasswordUserSettings, ChangePasswordUserSettings as default}; export {ChangePasswordUserSettings, ChangePasswordUserSettings as default};

View file

@ -1,17 +1,16 @@
var import ko from 'ko';
ko = require('ko'),
AppStore = require('Stores/User/App'), import {Magics} from 'Common/Enums';
ContactStore = require('Stores/User/Contact'), import {boolToAjax} from 'Common/Utils';
Remote = require('Remote/User/Ajax'); import AppStore from 'Stores/User/App';
import ContactStore from 'Stores/User/Contact';
import Remote from 'Remote/User/Ajax';
/** class ContactsUserSettings
* @constructor
*/
function ContactsUserSettings()
{ {
constructor() {
this.contactsAutosave = AppStore.contactsAutosave; this.contactsAutosave = AppStore.contactsAutosave;
this.allowContactsSync = ContactStore.allowContactsSync; this.allowContactsSync = ContactStore.allowContactsSync;
@ -20,32 +19,30 @@ function ContactsUserSettings()
this.contactsSyncUser = ContactStore.contactsSyncUser; this.contactsSyncUser = ContactStore.contactsSyncUser;
this.contactsSyncPass = ContactStore.contactsSyncPass; this.contactsSyncPass = ContactStore.contactsSyncPass;
this.saveTrigger = ko.computed(function() { this.saveTrigger = ko.computed(() => [
return [
this.enableContactsSync() ? '1' : '0', this.enableContactsSync() ? '1' : '0',
this.contactsSyncUrl(), this.contactsSyncUrl(),
this.contactsSyncUser(), this.contactsSyncUser(),
this.contactsSyncPass() this.contactsSyncPass()
].join('|'); ].join('|')).extend({throttle: Magics.Time500ms});
}, this).extend({'throttle': 500}); }
}
ContactsUserSettings.prototype.onBuild = function() onBuild() {
{ this.contactsAutosave.subscribe((value) => {
this.contactsAutosave.subscribe(function(bValue) {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'ContactsAutosave': bValue ? '1' : '0' 'ContactsAutosave': boolToAjax(value)
}); });
}); });
this.saveTrigger.subscribe(function() { this.saveTrigger.subscribe(() => {
Remote.saveContactsSyncData(null, Remote.saveContactsSyncData(null,
this.enableContactsSync(), this.enableContactsSync(),
this.contactsSyncUrl(), this.contactsSyncUrl(),
this.contactsSyncUser(), this.contactsSyncUser(),
this.contactsSyncPass() this.contactsSyncPass()
); );
}, this); });
}; }
}
export {ContactsUserSettings, ContactsUserSettings as default}; export {ContactsUserSettings, ContactsUserSettings as default};

View file

@ -1,23 +1,24 @@
var import _ from '_';
ko = require('ko'), import ko from 'ko';
_ = require('_'),
Enums = require('Common/Enums'), import {StorageResultType, Notification} from 'Common/Enums';
Utils = require('Common/Utils'), import {getNotification} from 'Common/Translator';
Translator = require('Common/Translator'),
FilterStore = require('Stores/User/Filter'), import {
windowResizeCallback, createCommand, isArray, trim, delegateRunOnDestroy
} from 'Common/Utils';
Remote = require('Remote/User/Ajax'); import {showScreenPopup} from 'Knoin/Knoin';
/** import FilterStore from 'Stores/User/Filter';
* @constructor import Remote from 'Remote/User/Ajax';
*/
function FiltersUserSettings() import {FilterModel} from 'Model/Filter';
class FiltersUserSettings
{ {
var self = this; constructor() {
this.modules = FilterStore.modules; this.modules = FilterStore.modules;
this.filters = FilterStore.filters; this.filters = FilterStore.filters;
@ -28,10 +29,10 @@ function FiltersUserSettings()
this.saveErrorText = ko.observable(''); this.saveErrorText = ko.observable('');
this.filters.subscribe(Utils.windowResizeCallback); this.filters.subscribe(windowResizeCallback);
this.serverError.subscribe(function(bValue) { this.serverError.subscribe((value) => {
if (!bValue) if (!value)
{ {
this.serverErrorDesc(''); this.serverErrorDesc('');
} }
@ -43,14 +44,13 @@ function FiltersUserSettings()
this.filterRaw.allow = ko.observable(false); this.filterRaw.allow = ko.observable(false);
this.filterRaw.error = ko.observable(false); this.filterRaw.error = ko.observable(false);
this.filterForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend( this.filterForDeletion = ko.observable(null)
{'toggleSubscribeProperty': [this, 'deleteAccess']}); .extend({falseTimeout: 3000}).extend({toggleSubscribeProperty: [this, 'deleteAccess']});
this.saveChanges = Utils.createCommand(this, function() {
this.saveChanges = createCommand(this, () => {
if (!this.filters.saving()) if (!this.filters.saving())
{ {
if (this.filterRaw.active() && '' === Utils.trim(this.filterRaw())) if (this.filterRaw.active() && '' === trim(this.filterRaw()))
{ {
this.filterRaw.error(true); this.filterRaw.error(true);
return false; return false;
@ -59,176 +59,149 @@ function FiltersUserSettings()
this.filters.saving(true); this.filters.saving(true);
this.saveErrorText(''); this.saveErrorText('');
Remote.filtersSave(function(sResult, oData) { Remote.filtersSave((result, data) => {
this.filters.saving(false);
self.filters.saving(false); if (StorageResultType.Success === result && data && data.Result)
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
self.haveChanges(false); this.haveChanges(false);
self.updateList(); this.updateList();
} }
else if (oData && oData.ErrorCode) else if (data && data.ErrorCode)
{ {
self.saveErrorText(oData.ErrorMessageAdditional || Translator.getNotification(oData.ErrorCode)); this.saveErrorText(data.ErrorMessageAdditional || getNotification(data.ErrorCode));
} }
else else
{ {
self.saveErrorText(Translator.getNotification(Enums.Notification.CantSaveFilters)); this.saveErrorText(getNotification(Notification.CantSaveFilters));
} }
}, this.filters(), this.filterRaw(), this.filterRaw.active()); }, this.filters(), this.filterRaw(), this.filterRaw.active());
} }
return true; return true;
}, () => this.haveChanges());
}, function() { this.filters.subscribe(() => {
return this.haveChanges(); this.haveChanges(true);
}); });
this.filters.subscribe(function() { this.filterRaw.subscribe(() => {
this.haveChanges(true);
}, this);
this.filterRaw.subscribe(function() {
this.haveChanges(true); this.haveChanges(true);
this.filterRaw.error(false); this.filterRaw.error(false);
}, this); });
this.haveChanges.subscribe(function() { this.haveChanges.subscribe(() => {
this.saveErrorText(''); this.saveErrorText('');
}, this); });
this.filterRaw.active.subscribe(function() { this.filterRaw.active.subscribe(() => {
this.haveChanges(true); this.haveChanges(true);
this.filterRaw.error(false); this.filterRaw.error(false);
}, this); });
} }
FiltersUserSettings.prototype.scrollableOptions = function(sWrapper) scrollableOptions(wrapper) {
{
return { return {
handle: '.drag-handle', handle: '.drag-handle',
containment: sWrapper || 'parent', containment: wrapper || 'parent',
axis: 'y' axis: 'y'
}; };
}; }
FiltersUserSettings.prototype.updateList = function()
{
var
self = this,
FilterModel = require('Model/Filter').default;
updateList() {
if (!this.filters.loading()) if (!this.filters.loading())
{ {
this.filters.loading(true); this.filters.loading(true);
Remote.filtersGet(function(sResult, oData) { Remote.filtersGet((result, data) => {
self.filters.loading(false); this.filters.loading(false);
self.serverError(false); this.serverError(false);
if (Enums.StorageResultType.Success === sResult && oData && if (StorageResultType.Success === result && data && data.Result && isArray(data.Result.Filters))
oData.Result && Utils.isArray(oData.Result.Filters))
{ {
self.inited(true); this.inited(true);
self.serverError(false); this.serverError(false);
var aResult = _.compact(_.map(oData.Result.Filters, function(aItem) { this.filters(_.compact(_.map(data.Result.Filters, (aItem) => {
var oNew = new FilterModel(); const filter = new FilterModel();
return (oNew && oNew.parse(aItem)) ? oNew : null; return (filter && filter.parse(aItem)) ? filter : null;
})); })));
self.filters(aResult); this.modules(data.Result.Modules ? data.Result.Modules : {});
self.modules(oData.Result.Modules ? oData.Result.Modules : {}); this.filterRaw(data.Result.Raw || '');
this.filterRaw.capa(isArray(data.Result.Capa) ? data.Result.Capa.join(' ') : '');
self.filterRaw(oData.Result.Raw || ''); this.filterRaw.active(!!data.Result.RawIsActive);
self.filterRaw.capa(Utils.isArray(oData.Result.Capa) ? oData.Result.Capa.join(' ') : ''); this.filterRaw.allow(!!data.Result.RawIsAllow);
self.filterRaw.active(!!oData.Result.RawIsActive);
self.filterRaw.allow(!!oData.Result.RawIsAllow);
} }
else else
{ {
self.filters([]); this.filters([]);
self.modules({}); this.modules({});
self.filterRaw(''); this.filterRaw('');
self.filterRaw.capa({}); this.filterRaw.capa({});
self.serverError(true); this.serverError(true);
self.serverErrorDesc(oData && oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) : this.serverErrorDesc(data && data.ErrorCode ? getNotification(data.ErrorCode) : getNotification(Notification.CantGetFilters));
Translator.getNotification(Enums.Notification.CantGetFilters));
} }
self.haveChanges(false); this.haveChanges(false);
}); });
} }
};
FiltersUserSettings.prototype.deleteFilter = function(oFilter)
{
this.filters.remove(oFilter);
Utils.delegateRunOnDestroy(oFilter);
};
FiltersUserSettings.prototype.addFilter = function()
{
var
self = this,
FilterModel = require('Model/Filter').default,
oNew = new FilterModel();
oNew.generateID();
require('Knoin/Knoin').showScreenPopup(
require('View/Popup/Filter'), [oNew, function() {
self.filters.push(oNew);
self.filterRaw.active(false);
}, false]);
};
FiltersUserSettings.prototype.editFilter = function(oEdit)
{
var
self = this,
oCloned = oEdit.cloneSelf();
require('Knoin/Knoin').showScreenPopup(
require('View/Popup/Filter'), [oCloned, function() {
var
aFilters = self.filters(),
iIndex = aFilters.indexOf(oEdit);
if (-1 < iIndex && aFilters[iIndex])
{
Utils.delegateRunOnDestroy(aFilters[iIndex]);
aFilters[iIndex] = oCloned;
self.filters(aFilters);
self.haveChanges(true);
} }
}, true]); deleteFilter(filter) {
}; this.filters.remove(filter);
delegateRunOnDestroy(filter);
}
FiltersUserSettings.prototype.onBuild = function(oDom) addFilter() {
{ const filter = new FilterModel();
var self = this;
filter.generateID();
showScreenPopup(require('View/Popup/Filter'), [filter, () => {
this.filters.push(filter);
this.filterRaw.active(false);
}, false]);
}
editFilter(filter) {
const clonedFilter = filter.cloneSelf();
showScreenPopup(require('View/Popup/Filter'), [clonedFilter, () => {
const
filters = this.filters(),
index = filters.indexOf(filter);
if (-1 < index && filters[index])
{
delegateRunOnDestroy(filters[index]);
filters[index] = clonedFilter;
this.filters(filters);
this.haveChanges(true);
}
}, true]);
}
onBuild(oDom) {
const self = this;
oDom oDom
.on('click', '.filter-item .e-action', function() { .on('click', '.filter-item .e-action', function() {
var oFilterItem = ko.dataFor(this); const filter = ko.dataFor(this);
if (oFilterItem) if (filter)
{ {
self.editFilter(oFilterItem); self.editFilter(filter);
} }
}); });
}; }
FiltersUserSettings.prototype.onShow = function() onShow() {
{
this.updateList(); this.updateList();
}; }
}
export {FiltersUserSettings, FiltersUserSettings as default}; export {FiltersUserSettings, FiltersUserSettings as default};

View file

@ -1,192 +1,171 @@
var import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {ClientSideKeyName, Notification} from 'Common/Enums';
Utils = require('Common/Utils'), import {trim, noop} from 'Common/Utils';
Translator = require('Common/Translator'), import {getNotification, i18n} from 'Common/Translator';
Cache = require('Common/Cache'), import {removeFolderFromCacheList} from 'Common/Cache';
Settings = require('Storage/Settings'), import {appSettingsGet} from 'Storage/Settings';
Local = require('Storage/Client'), import * as Local from 'Storage/Client';
FolderStore = require('Stores/User/Folder'), import {showScreenPopup} from 'Knoin/Knoin';
Promises = require('Promises/User/Ajax'), import FolderStore from 'Stores/User/Folder';
Remote = require('Remote/User/Ajax');
/** import Promises from 'Promises/User/Ajax';
* @constructor import Remote from 'Remote/User/Ajax';
*/
function FoldersUserSettings() class FoldersUserSettings
{ {
constructor() {
this.displaySpecSetting = FolderStore.displaySpecSetting; this.displaySpecSetting = FolderStore.displaySpecSetting;
this.folderList = FolderStore.folderList; this.folderList = FolderStore.folderList;
this.folderListHelp = ko.observable('').extend({'throttle': 100}); this.folderListHelp = ko.observable('').extend({throttle: 100});
this.loading = ko.computed(function() { this.loading = ko.computed(() => {
const
var
bLoading = FolderStore.foldersLoading(), bLoading = FolderStore.foldersLoading(),
bCreating = FolderStore.foldersCreating(), bCreating = FolderStore.foldersCreating(),
bDeleting = FolderStore.foldersDeleting(), bDeleting = FolderStore.foldersDeleting(),
bRenaming = FolderStore.foldersRenaming(); bRenaming = FolderStore.foldersRenaming();
return bLoading || bCreating || bDeleting || bRenaming; return bLoading || bCreating || bDeleting || bRenaming;
});
}, this);
this.folderForDeletion = ko.observable(null).deleteAccessHelper(); this.folderForDeletion = ko.observable(null).deleteAccessHelper();
this.folderForEdit = ko.observable(null).extend({'toggleSubscribe': [this, this.folderForEdit = ko.observable(null).extend({toggleSubscribe: [this,
function(oPrev) { (prev) => {
if (oPrev) if (prev)
{ {
oPrev.edited(false); prev.edited(false);
} }
}, function(oNext) { }, (next) => {
if (oNext && oNext.canBeEdited()) if (next && next.canBeEdited())
{ {
oNext.edited(true); next.edited(true);
} }
} }
]}); ]});
this.useImapSubscribe = !!Settings.appSettingsGet('useImapSubscribe'); this.useImapSubscribe = !!appSettingsGet('useImapSubscribe');
} }
FoldersUserSettings.prototype.folderEditOnEnter = function(oFolder) folderEditOnEnter(folder) {
{ const nameToEdit = folder ? trim(folder.nameForEdit()) : '';
var
sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : '';
if ('' !== sEditName && oFolder.name() !== sEditName) if ('' !== nameToEdit && folder.name() !== nameToEdit)
{ {
Local.set(Enums.ClientSideKeyName.FoldersLashHash, ''); Local.set(ClientSideKeyName.FoldersLashHash, '');
require('App/User').default.foldersPromisesActionHelper( require('App/User').default.foldersPromisesActionHelper(
Promises.folderRename(oFolder.fullNameRaw, sEditName, FolderStore.foldersRenaming), Promises.folderRename(folder.fullNameRaw, nameToEdit, FolderStore.foldersRenaming),
Enums.Notification.CantRenameFolder Notification.CantRenameFolder
); );
Cache.removeFolderFromCacheList(oFolder.fullNameRaw); removeFolderFromCacheList(folder.fullNameRaw);
oFolder.name(sEditName); folder.name(nameToEdit);
} }
oFolder.edited(false); folder.edited(false);
}; }
FoldersUserSettings.prototype.folderEditOnEsc = function(oFolder) folderEditOnEsc(folder) {
{ if (folder)
if (oFolder)
{ {
oFolder.edited(false); folder.edited(false);
}
} }
};
FoldersUserSettings.prototype.onShow = function() onShow() {
{
FolderStore.folderList.error(''); FolderStore.folderList.error('');
}; }
FoldersUserSettings.prototype.onBuild = function(oDom) onBuild(oDom) {
{
var self = this;
oDom oDom
.on('mouseover', '.delete-folder-parent', function() { .on('mouseover', '.delete-folder-parent', () => {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_DELETE_FOLDER')); this.folderListHelp(i18n('SETTINGS_FOLDERS/HELP_DELETE_FOLDER'));
}) })
.on('mouseover', '.subscribe-folder-parent', function() { .on('mouseover', '.subscribe-folder-parent', () => {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_SHOW_HIDE_FOLDER')); this.folderListHelp(i18n('SETTINGS_FOLDERS/HELP_SHOW_HIDE_FOLDER'));
}) })
.on('mouseover', '.check-folder-parent', function() { .on('mouseover', '.check-folder-parent', () => {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_CHECK_FOR_NEW_MESSAGES')); this.folderListHelp(i18n('SETTINGS_FOLDERS/HELP_CHECK_FOR_NEW_MESSAGES'));
}) })
.on('mouseout', '.subscribe-folder-parent, .check-folder-parent, .delete-folder-parent', function() { .on('mouseout', '.subscribe-folder-parent, .check-folder-parent, .delete-folder-parent', () => {
self.folderListHelp(''); this.folderListHelp('');
}); });
}; }
FoldersUserSettings.prototype.createFolder = function() createFolder() {
{ showScreenPopup(require('View/Popup/FolderCreate'));
require('Knoin/Knoin').showScreenPopup(require('View/Popup/FolderCreate')); }
};
FoldersUserSettings.prototype.systemFolder = function() systemFolder() {
{ showScreenPopup(require('View/Popup/FolderSystem'));
require('Knoin/Knoin').showScreenPopup(require('View/Popup/FolderSystem')); }
};
FoldersUserSettings.prototype.deleteFolder = function(oFolderToRemove) deleteFolder(folderToRemove) {
{ if (folderToRemove && folderToRemove.canBeDeleted() && folderToRemove.deleteAccess() &&
if (oFolderToRemove && oFolderToRemove.canBeDeleted() && oFolderToRemove.deleteAccess() && 0 === folderToRemove.privateMessageCountAll())
0 === oFolderToRemove.privateMessageCountAll())
{ {
this.folderForDeletion(null); this.folderForDeletion(null);
var if (folderToRemove)
fRemoveFolder = function(oFolder) { {
const
if (oFolderToRemove === oFolder) fRemoveFolder = function(folder) {
if (folderToRemove === folder)
{ {
return true; return true;
} }
folder.subFolders.remove(fRemoveFolder);
oFolder.subFolders.remove(fRemoveFolder);
return false; return false;
}; };
if (oFolderToRemove) Local.set(ClientSideKeyName.FoldersLashHash, '');
{
Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
FolderStore.folderList.remove(fRemoveFolder); FolderStore.folderList.remove(fRemoveFolder);
require('App/User').default.foldersPromisesActionHelper( require('App/User').default.foldersPromisesActionHelper(
Promises.folderDelete(oFolderToRemove.fullNameRaw, FolderStore.foldersDeleting), Promises.folderDelete(folderToRemove.fullNameRaw, FolderStore.foldersDeleting),
Enums.Notification.CantDeleteFolder Notification.CantDeleteFolder
); );
Cache.removeFolderFromCacheList(oFolderToRemove.fullNameRaw); removeFolderFromCacheList(folderToRemove.fullNameRaw);
} }
} }
else if (0 < oFolderToRemove.privateMessageCountAll()) else if (0 < folderToRemove.privateMessageCountAll())
{ {
FolderStore.folderList.error(Translator.getNotification(Enums.Notification.CantDeleteNonEmptyFolder)); FolderStore.folderList.error(getNotification(Notification.CantDeleteNonEmptyFolder));
}
} }
};
FoldersUserSettings.prototype.subscribeFolder = function(oFolder) subscribeFolder(folder) {
{ Local.set(ClientSideKeyName.FoldersLashHash, '');
Local.set(Enums.ClientSideKeyName.FoldersLashHash, ''); Remote.folderSetSubscribe(noop, folder.fullNameRaw, true);
Remote.folderSetSubscribe(Utils.noop, oFolder.fullNameRaw, true); folder.subScribed(true);
}
oFolder.subScribed(true); unSubscribeFolder(folder) {
}; Local.set(ClientSideKeyName.FoldersLashHash, '');
Remote.folderSetSubscribe(noop, folder.fullNameRaw, false);
folder.subScribed(false);
}
FoldersUserSettings.prototype.unSubscribeFolder = function(oFolder) checkableTrueFolder(folder) {
{ Remote.folderSetCheckable(noop, folder.fullNameRaw, true);
Local.set(Enums.ClientSideKeyName.FoldersLashHash, ''); folder.checkable(true);
Remote.folderSetSubscribe(Utils.noop, oFolder.fullNameRaw, false); }
oFolder.subScribed(false); checkableFalseFolder(folder) {
}; Remote.folderSetCheckable(noop, folder.fullNameRaw, false);
folder.checkable(false);
FoldersUserSettings.prototype.checkableTrueFolder = function(oFolder) }
{ }
Remote.folderSetCheckable(Utils.noop, oFolder.fullNameRaw, true);
oFolder.checkable(true);
};
FoldersUserSettings.prototype.checkableFalseFolder = function(oFolder)
{
Remote.folderSetCheckable(Utils.noop, oFolder.fullNameRaw, false);
oFolder.checkable(false);
};
export {FoldersUserSettings, FoldersUserSettings as default}; export {FoldersUserSettings, FoldersUserSettings as default};

View file

@ -1,32 +1,37 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {MESSAGES_PER_PAGE_VALUES} from 'Common/Consts';
Consts = require('Common/Consts'), import {bAnimationSupported} from 'Common/Globals';
Globals = require('Common/Globals'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
AppStore = require('Stores/User/App'), import {SaveSettingsStep, Magics, EditorDefaultType, Layout} from 'Common/Enums';
LanguageStore = require('Stores/Language'),
SettingsStore = require('Stores/User/Settings'),
IdentityStore = require('Stores/User/Identity'),
NotificationStore = require('Stores/User/Notification'),
MessageStore = require('Stores/User/Message'),
Remote = require('Remote/User/Ajax'); import {
settingsSaveHelperSimpleFunction,
convertLangName, isArray, timeOutAction, boolToAjax
} from 'Common/Utils';
/** import {i18n, trigger as translatorTrigger, reload as translatorReload} from 'Common/Translator';
* @constructor
*/ import {showScreenPopup} from 'Knoin/Knoin';
function GeneralUserSettings()
import AppStore from 'Stores/User/App';
import LanguageStore from 'Stores/Language';
import SettingsStore from 'Stores/User/Settings';
import IdentityStore from 'Stores/User/Identity';
import NotificationStore from 'Stores/User/Notification';
import MessageStore from 'Stores/User/Message';
import Remote from 'Remote/User/Ajax';
class GeneralUserSettings
{ {
constructor() {
this.language = LanguageStore.language; this.language = LanguageStore.language;
this.languages = LanguageStore.languages; this.languages = LanguageStore.languages;
this.messagesPerPage = SettingsStore.messagesPerPage; this.messagesPerPage = SettingsStore.messagesPerPage;
this.messagesPerPageArray = Consts.MESSAGES_PER_PAGE_VALUES; this.messagesPerPageArray = MESSAGES_PER_PAGE_VALUES;
this.editorDefaultType = SettingsStore.editorDefaultType; this.editorDefaultType = SettingsStore.editorDefaultType;
this.layout = SettingsStore.layout; this.layout = SettingsStore.layout;
@ -46,179 +51,138 @@ function GeneralUserSettings()
this.replySameFolder = SettingsStore.replySameFolder; this.replySameFolder = SettingsStore.replySameFolder;
this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings; this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings;
this.languageFullName = ko.computed(function() { this.languageFullName = ko.computed(() => convertLangName(this.language()));
return Utils.convertLangName(this.language()); this.languageTrigger = ko.observable(SaveSettingsStep.Idle).extend({throttle: Magics.Time100ms});
}, this);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': Enums.Magics.Time100ms}); this.mppTrigger = ko.observable(SaveSettingsStep.Idle);
this.editorDefaultTypeTrigger = ko.observable(SaveSettingsStep.Idle);
this.layoutTrigger = ko.observable(SaveSettingsStep.Idle);
this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.isAnimationSupported = bAnimationSupported;
this.editorDefaultTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.layoutTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.isAnimationSupported = Globals.bAnimationSupported;
this.identities = IdentityStore.identities; this.identities = IdentityStore.identities;
this.identityMain = ko.computed(function() { this.identityMain = ko.computed(() => {
var aList = this.identities(); const list = this.identities();
return Utils.isArray(aList) ? _.find(aList, function(oItem) { return isArray(list) ? _.find(list, (item) => item && '' === item.id()) : null;
return oItem && '' === oItem.id(); });
}) : null;
}, this);
this.identityMainDesc = ko.computed(function() { this.identityMainDesc = ko.computed(() => {
var oIdentity = this.identityMain(); const identity = this.identityMain();
return oIdentity ? oIdentity.formattedName() : '---'; return identity ? identity.formattedName() : '---';
}, this); });
this.editorDefaultTypes = ko.computed(function() { this.editorDefaultTypes = ko.computed(() => {
Translator.trigger(); translatorTrigger();
return [ return [
{'id': Enums.EditorDefaultType.Html, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML')}, {'id': EditorDefaultType.Html, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML')},
{'id': Enums.EditorDefaultType.Plain, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN')}, {'id': EditorDefaultType.Plain, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN')},
{'id': Enums.EditorDefaultType.HtmlForced, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML_FORCED')}, {'id': EditorDefaultType.HtmlForced, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML_FORCED')},
{'id': Enums.EditorDefaultType.PlainForced, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN_FORCED')} {'id': EditorDefaultType.PlainForced, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN_FORCED')}
]; ];
}, this); });
this.layoutTypes = ko.computed(function() { this.layoutTypes = ko.computed(() => {
Translator.trigger(); translatorTrigger();
return [ return [
{'id': Enums.Layout.NoPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_NO_SPLIT')}, {'id': Layout.NoPreview, 'name': i18n('SETTINGS_GENERAL/LABEL_LAYOUT_NO_SPLIT')},
{'id': Enums.Layout.SidePreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_VERTICAL_SPLIT')}, {'id': Layout.SidePreview, 'name': i18n('SETTINGS_GENERAL/LABEL_LAYOUT_VERTICAL_SPLIT')},
{'id': Enums.Layout.BottomPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_HORIZONTAL_SPLIT')} {'id': Layout.BottomPreview, 'name': i18n('SETTINGS_GENERAL/LABEL_LAYOUT_HORIZONTAL_SPLIT')}
]; ];
}, this); });
}
GeneralUserSettings.prototype.editMainIdentity = function()
{
var oIdentity = this.identityMain();
if (oIdentity)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]);
} }
};
GeneralUserSettings.prototype.testSoundNotification = function() editMainIdentity() {
{ const identity = this.identityMain();
if (identity)
{
showScreenPopup(require('View/Popup/Identity'), [identity]);
}
}
testSoundNotification() {
NotificationStore.playSoundNotification(true); NotificationStore.playSoundNotification(true);
}; }
GeneralUserSettings.prototype.onBuild = function() onBuild() {
{ _.delay(() => {
var self = this; const
f0 = settingsSaveHelperSimpleFunction(this.editorDefaultTypeTrigger, this),
_.delay(function() { f1 = settingsSaveHelperSimpleFunction(this.mppTrigger, this),
f2 = settingsSaveHelperSimpleFunction(this.layoutTrigger, this),
var fReloadLanguageHelper = (saveSettingsStep) => () => {
f0 = Utils.settingsSaveHelperSimpleFunction(self.editorDefaultTypeTrigger, self), this.languageTrigger(saveSettingsStep);
f1 = Utils.settingsSaveHelperSimpleFunction(self.mppTrigger, self), _.delay(() => this.languageTrigger(SaveSettingsStep.Idle), Magics.Time1s);
f2 = Utils.settingsSaveHelperSimpleFunction(self.layoutTrigger, self),
fReloadLanguageHelper = function(iSaveSettingsStep) {
return function() {
self.languageTrigger(iSaveSettingsStep);
_.delay(function() {
self.languageTrigger(Enums.SaveSettingsStep.Idle);
}, Enums.Magics.Time1s);
};
}; };
self.language.subscribe(function(sValue) { this.language.subscribe((value) => {
this.languageTrigger(SaveSettingsStep.Animate);
self.languageTrigger(Enums.SaveSettingsStep.Animate); translatorReload(false, value).then(
fReloadLanguageHelper(SaveSettingsStep.TrueResult),
Translator.reload(false, sValue).then( fReloadLanguageHelper(SaveSettingsStep.FalseResult)
fReloadLanguageHelper(Enums.SaveSettingsStep.TrueResult), ).then(() => {
fReloadLanguageHelper(Enums.SaveSettingsStep.FalseResult)
).then(function() {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'Language': sValue 'Language': value
}); });
}); });
}); });
self.editorDefaultType.subscribe(function(sValue) { this.editorDefaultType.subscribe(Remote.saveSettingsHelper('EditorDefaultType', null, f0));
Remote.saveSettings(f0, { this.messagesPerPage.subscribe(Remote.saveSettingsHelper('MPP', null, f1));
'EditorDefaultType': sValue this.showImages.subscribe(Remote.saveSettingsHelper('ShowImages', boolToAjax));
});
});
self.messagesPerPage.subscribe(function(iValue) { this.useCheckboxesInList.subscribe(Remote.saveSettingsHelper('UseCheckboxesInList', boolToAjax));
Remote.saveSettings(f1, {
'MPP': iValue
});
});
self.showImages.subscribe(function(bValue) { this.enableDesktopNotification.subscribe((value) => {
timeOutAction('SaveDesktopNotifications', () => {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'ShowImages': bValue ? '1' : '0' 'DesktopNotifications': boolToAjax(value)
}); });
}, Magics.Time3s);
}); });
self.enableDesktopNotification.subscribe(function(bValue) { this.enableSoundNotification.subscribe((value) => {
Utils.timeOutAction('SaveDesktopNotifications', function() { timeOutAction('SaveSoundNotification', () => {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'DesktopNotifications': bValue ? '1' : '0' 'SoundNotification': boolToAjax(value)
}); });
}, Enums.Magics.Time3s); }, Magics.Time3s);
}); });
self.enableSoundNotification.subscribe(function(bValue) { this.replySameFolder.subscribe((value) => {
Utils.timeOutAction('SaveSoundNotification', function() { timeOutAction('SaveReplySameFolder', () => {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'SoundNotification': bValue ? '1' : '0' 'ReplySameFolder': boolToAjax(value)
}); });
}, Enums.Magics.Time3s); }, Magics.Time3s);
}); });
self.replySameFolder.subscribe(function(bValue) { this.useThreads.subscribe((value) => {
Utils.timeOutAction('SaveReplySameFolder', function() {
Remote.saveSettings(null, {
'ReplySameFolder': bValue ? '1' : '0'
});
}, Enums.Magics.Time3s);
});
self.useThreads.subscribe(function(bValue) {
MessageStore.messageList([]); MessageStore.messageList([]);
Remote.saveSettings(null, { Remote.saveSettings(null, {
'UseThreads': bValue ? '1' : '0' 'UseThreads': boolToAjax(value)
}); });
}); });
self.layout.subscribe(function(nValue) { this.layout.subscribe(function(value) {
MessageStore.messageList([]); MessageStore.messageList([]);
Remote.saveSettings(f2, { Remote.saveSettings(f2, {
'Layout': nValue 'Layout': value
}); });
}); });
}, Magics.Time50ms);
}
self.useCheckboxesInList.subscribe(function(bValue) { onShow() {
Remote.saveSettings(null, {
'UseCheckboxesInList': bValue ? '1' : '0'
});
});
}, Enums.Magics.Time50ms);
};
GeneralUserSettings.prototype.onShow = function()
{
this.enableDesktopNotification.valueHasMutated(); this.enableDesktopNotification.valueHasMutated();
}; }
GeneralUserSettings.prototype.selectLanguage = function() selectLanguage() {
{ showScreenPopup(require('View/Popup/Languages'), [
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
this.language, this.languages(), LanguageStore.userLanguage() this.language, this.languages(), LanguageStore.userLanguage()
]); ]);
}; }
}
export {GeneralUserSettings, GeneralUserSettings as default}; export {GeneralUserSettings, GeneralUserSettings as default};

View file

@ -1,69 +1,61 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
window = require('window'),
Utils = require('Common/Utils'), import {delegateRunOnDestroy} from 'Common/Utils';
import {bIsHttps} from 'Common/Globals';
kn = require('Knoin/Knoin'), import {showScreenPopup} from 'Knoin/Knoin';
PgpStore = require('Stores/User/Pgp'); import PgpStore from 'Stores/User/Pgp';
/** class OpenPgpUserSettings
* @constructor
*/
function OpenPgpUserSettings()
{ {
constructor() {
this.openpgpkeys = PgpStore.openpgpkeys; this.openpgpkeys = PgpStore.openpgpkeys;
this.openpgpkeysPublic = PgpStore.openpgpkeysPublic; this.openpgpkeysPublic = PgpStore.openpgpkeysPublic;
this.openpgpkeysPrivate = PgpStore.openpgpkeysPrivate; this.openpgpkeysPrivate = PgpStore.openpgpkeysPrivate;
this.openPgpKeyForDeletion = ko.observable(null).deleteAccessHelper(); this.openPgpKeyForDeletion = ko.observable(null).deleteAccessHelper();
this.isHttps = window.document && window.document.location ? 'https:' === window.document.location.protocol : false; this.isHttps = bIsHttps;
}
OpenPgpUserSettings.prototype.addOpenPgpKey = function()
{
kn.showScreenPopup(require('View/Popup/AddOpenPgpKey'));
};
OpenPgpUserSettings.prototype.generateOpenPgpKey = function()
{
kn.showScreenPopup(require('View/Popup/NewOpenPgpKey'));
};
OpenPgpUserSettings.prototype.viewOpenPgpKey = function(oOpenPgpKey)
{
if (oOpenPgpKey)
{
kn.showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [oOpenPgpKey]);
} }
};
/** addOpenPgpKey() {
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove showScreenPopup(require('View/Popup/AddOpenPgpKey'));
}
generateOpenPgpKey() {
showScreenPopup(require('View/Popup/NewOpenPgpKey'));
}
viewOpenPgpKey(openPgpKey) {
if (openPgpKey)
{
showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [openPgpKey]);
}
}
/**
* @param {OpenPgpKeyModel} openPgpKeyToRemove
* @returns {void}
*/ */
OpenPgpUserSettings.prototype.deleteOpenPgpKey = function(oOpenPgpKeyToRemove) deleteOpenPgpKey(openPgpKeyToRemove) {
{ if (openPgpKeyToRemove && openPgpKeyToRemove.deleteAccess())
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
{ {
this.openPgpKeyForDeletion(null); this.openPgpKeyForDeletion(null);
if (oOpenPgpKeyToRemove && PgpStore.openpgpKeyring) if (openPgpKeyToRemove && PgpStore.openpgpKeyring)
{ {
var oFindedItem = _.find(PgpStore.openpgpkeys(), function(oOpenPgpKey) { const findedItem = _.find(PgpStore.openpgpkeys(), (key) => openPgpKeyToRemove === key);
return oOpenPgpKeyToRemove === oOpenPgpKey; if (findedItem)
});
if (oFindedItem)
{ {
PgpStore.openpgpkeys.remove(oFindedItem); PgpStore.openpgpkeys.remove(findedItem);
Utils.delegateRunOnDestroy(oFindedItem); delegateRunOnDestroy(findedItem);
PgpStore.openpgpKeyring[oFindedItem.isPrivate ? 'privateKeys' : 'publicKeys'] PgpStore
.removeForId(oFindedItem.guid); .openpgpKeyring[findedItem.isPrivate ? 'privateKeys' : 'publicKeys']
.removeForId(findedItem.guid);
PgpStore.openpgpKeyring.store(); PgpStore.openpgpKeyring.store();
} }
@ -71,6 +63,7 @@ OpenPgpUserSettings.prototype.deleteOpenPgpKey = function(oOpenPgpKeyToRemove)
require('App/User').default.reloadOpenPgpKeys(); require('App/User').default.reloadOpenPgpKeys();
} }
} }
}; }
}
export {OpenPgpUserSettings, OpenPgpUserSettings as default}; export {OpenPgpUserSettings, OpenPgpUserSettings as default};

View file

@ -1,68 +1,57 @@
var import _ from '_';
_ = require('_'), import ko from 'ko';
ko = require('ko'),
Enums = require('Common/Enums'), import {pInt, settingsSaveHelperSimpleFunction} from 'Common/Utils';
Utils = require('Common/Utils'), import {Capa, SaveSettingsStep} from 'Common/Enums';
Translator = require('Common/Translator'), import {i18n, trigger as translatorTrigger} from 'Common/Translator';
SettinsStore = require('Stores/User/Settings'), import {capa} from 'Storage/Settings';
Settings = require('Storage/Settings'), import {showScreenPopup} from 'Knoin/Knoin';
Remote = require('Remote/User/Ajax'); import SettinsStore from 'Stores/User/Settings';
/** import Remote from 'Remote/User/Ajax';
* @constructor
*/ class SecurityUserSettings
function SecurityUserSettings()
{ {
this.capaAutoLogout = Settings.capa(Enums.Capa.AutoLogout); constructor() {
this.capaTwoFactor = Settings.capa(Enums.Capa.TwoFactor); this.capaAutoLogout = capa(Capa.AutoLogout);
this.capaTwoFactor = capa(Capa.TwoFactor);
this.autoLogout = SettinsStore.autoLogout; this.autoLogout = SettinsStore.autoLogout;
this.autoLogout.trigger = ko.observable(Enums.SaveSettingsStep.Idle); this.autoLogout.trigger = ko.observable(SaveSettingsStep.Idle);
this.autoLogoutOptions = ko.computed(function() { this.autoLogoutOptions = ko.computed(() => {
Translator.trigger(); translatorTrigger();
return [ return [
{'id': 0, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME')}, {'id': 0, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME')},
{'id': 5, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 5})}, {'id': 5, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 5})},
{'id': 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 10})}, {'id': 10, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 10})},
{'id': 30, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 30})}, {'id': 30, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 30})},
{'id': 60, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 60})}, {'id': 60, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 60})},
{'id': 60 * 2, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 2})}, {'id': 60 * 2, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 2})},
{'id': 60 * 5, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 5})}, {'id': 60 * 5, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 5})},
{'id': 60 * 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 10})} {'id': 60 * 10, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 10})}
]; ];
}); });
} }
SecurityUserSettings.prototype.configureTwoFactor = function() configureTwoFactor() {
{ showScreenPopup(require('View/Popup/TwoFactorConfiguration'));
require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorConfiguration')); }
};
SecurityUserSettings.prototype.onBuild = function() onBuild() {
{
if (this.capaAutoLogout) if (this.capaAutoLogout)
{ {
var self = this; _.delay(() => {
const f0 = settingsSaveHelperSimpleFunction(this.autoLogout.trigger, this);
_.delay(function() {
var
f0 = Utils.settingsSaveHelperSimpleFunction(self.autoLogout.trigger, self);
self.autoLogout.subscribe(function(sValue) {
Remote.saveSettings(f0, {
'AutoLogout': Utils.pInt(sValue)
});
});
this.autoLogout.subscribe(Remote.saveSettingsHelper('AutoLogout', pInt, f0));
}); });
} }
}; }
}
export {SecurityUserSettings, SecurityUserSettings as default}; export {SecurityUserSettings, SecurityUserSettings as default};

View file

@ -1,13 +1,11 @@
/** import {createCommand} from 'Common/Utils';
* @constructor
*/ import SocialStore from 'Stores/Social';
function SocialUserSettings()
class SocialUserSettings
{ {
var constructor() {
Utils = require('Common/Utils'),
SocialStore = require('Stores/Social');
this.googleEnable = SocialStore.google.enabled; this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth; this.googleEnableAuth = SocialStore.google.capa.auth;
this.googleEnableAuthFast = SocialStore.google.capa.authFast; this.googleEnableAuthFast = SocialStore.google.capa.authFast;
@ -30,44 +28,43 @@ function SocialUserSettings()
this.twitterLoggined = SocialStore.twitter.loggined; this.twitterLoggined = SocialStore.twitter.loggined;
this.twitterUserName = SocialStore.twitter.userName; this.twitterUserName = SocialStore.twitter.userName;
this.connectGoogle = Utils.createCommand(this, function() { this.connectGoogle = createCommand(this, () => {
if (!this.googleLoggined()) if (!this.googleLoggined())
{ {
require('App/User').default.googleConnect(); this.getApp().googleConnect();
} }
}, function() { }, () => !this.googleLoggined() && !this.googleActions());
return !this.googleLoggined() && !this.googleActions();
this.disconnectGoogle = createCommand(this, () => {
this.getApp().googleDisconnect();
}); });
this.disconnectGoogle = Utils.createCommand(this, function() { this.connectFacebook = createCommand(this, () => {
require('App/User').default.googleDisconnect();
});
this.connectFacebook = Utils.createCommand(this, function() {
if (!this.facebookLoggined()) if (!this.facebookLoggined())
{ {
require('App/User').default.facebookConnect(); this.getApp().facebookConnect();
} }
}, function() { }, () => !this.facebookLoggined() && !this.facebookActions());
return !this.facebookLoggined() && !this.facebookActions();
this.disconnectFacebook = createCommand(this, () => {
this.getApp().facebookDisconnect();
}); });
this.disconnectFacebook = Utils.createCommand(this, function() { this.connectTwitter = createCommand(this, () => {
require('App/User').default.facebookDisconnect();
});
this.connectTwitter = Utils.createCommand(this, function() {
if (!this.twitterLoggined()) if (!this.twitterLoggined())
{ {
require('App/User').default.twitterConnect(); this.getApp().twitterConnect();
} }
}, function() { }, () => !this.twitterLoggined() && !this.twitterActions());
return !this.twitterLoggined() && !this.twitterActions();
});
this.disconnectTwitter = Utils.createCommand(this, function() { this.disconnectTwitter = createCommand(this, () => {
require('App/User').default.twitterDisconnect(); this.getApp().twitterDisconnect();
}); });
}
getApp() {
return require('App/User').default;
}
} }
export {SocialUserSettings, SocialUserSettings as default}; export {SocialUserSettings, SocialUserSettings as default};

View file

@ -1,98 +1,81 @@
var import ko from 'ko';
ko = require('ko'),
Translator = require('Common/Translator'), import {i18n} from 'Common/Translator';
TemplateStore = require('Stores/User/Template'), import {showScreenPopup} from 'Knoin/Knoin';
Remote = require('Remote/User/Ajax'); import TemplateStore from 'Stores/User/Template';
import Remote from 'Remote/User/Ajax';
/** class TemplatesUserSettings
* @constructor
*/
function TemplatesUserSettings()
{ {
constructor() {
this.templates = TemplateStore.templates; this.templates = TemplateStore.templates;
this.processText = ko.computed(function() { this.processText = ko.computed(() => (TemplateStore.templates.loading() ? i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : ''));
return TemplateStore.templates.loading() ? Translator.i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : ''; this.visibility = ko.computed(() => ('' === this.processText() ? 'hidden' : 'visible'));
}, this);
this.visibility = ko.computed(function() {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.templateForDeletion = ko.observable(null).deleteAccessHelper(); this.templateForDeletion = ko.observable(null).deleteAccessHelper();
} }
TemplatesUserSettings.prototype.scrollableOptions = function(sWrapper) scrollableOptions(sWrapper) {
{
return { return {
handle: '.drag-handle', handle: '.drag-handle',
containment: sWrapper || 'parent', containment: sWrapper || 'parent',
axis: 'y' axis: 'y'
}; };
}; }
TemplatesUserSettings.prototype.addNewTemplate = function() addNewTemplate() {
{ showScreenPopup(require('View/Popup/Template'));
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template')); }
};
TemplatesUserSettings.prototype.editTemplate = function(oTemplateItem) editTemplate(oTemplateItem) {
{
if (oTemplateItem) if (oTemplateItem)
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template'), [oTemplateItem]); showScreenPopup(require('View/Popup/Template'), [oTemplateItem]);
}
} }
};
/** deleteTemplate(templateToRemove) {
* @param {AccountModel} oTemplateToRemove if (templateToRemove && templateToRemove.deleteAccess())
*/
TemplatesUserSettings.prototype.deleteTemplate = function(oTemplateToRemove)
{
if (oTemplateToRemove && oTemplateToRemove.deleteAccess())
{ {
this.templateForDeletion(null); this.templateForDeletion(null);
var if (templateToRemove)
self = this,
fRemoveAccount = function(oAccount) {
return oTemplateToRemove === oAccount;
};
if (oTemplateToRemove)
{ {
this.templates.remove(fRemoveAccount); this.templates.remove((template) => templateToRemove === template);
Remote.templateDelete(function() { Remote.templateDelete(() => {
self.reloadTemplates(); this.reloadTemplates();
}, oTemplateToRemove.id); }, templateToRemove.id);
}
} }
} }
};
TemplatesUserSettings.prototype.reloadTemplates = function() reloadTemplates() {
{ this.getApp().templates();
require('App/User').default.templates(); }
};
TemplatesUserSettings.prototype.onBuild = function(oDom) getApp() {
{ return require('App/User').default;
}
onBuild(oDom) {
var self = this; var self = this;
oDom oDom
.on('click', '.templates-list .template-item .e-action', function() { .on('click', '.templates-list .template-item .e-action', function() {
var oTemplateItem = ko.dataFor(this); const template = ko.dataFor(this);
if (oTemplateItem) if (template)
{ {
self.editTemplate(oTemplateItem); self.editTemplate(template);
} }
}); });
this.reloadTemplates(); this.reloadTemplates();
}; }
}
export {TemplatesUserSettings, TemplatesUserSettings as default}; export {TemplatesUserSettings, TemplatesUserSettings as default};

View file

@ -1,27 +1,24 @@
var import _ from '_';
_ = require('_'), import $ from '$';
$ = require('$'), import ko from 'ko';
ko = require('ko'),
Jua = require('Jua'), import Jua from 'Jua';
Enums = require('Common/Enums'), import {SaveSettingsStep, UploadErrorCode, Capa, Magics} from 'Common/Enums';
Utils = require('Common/Utils'), import {changeTheme, convertThemeName} from 'Common/Utils';
Links = require('Common/Links'), import {userBackground, themePreviewLink, uploadBackground} from 'Common/Links';
Translator = require('Common/Translator'), import {i18n} from 'Common/Translator';
ThemeStore = require('Stores/Theme'), import {capa} from 'Storage/Settings';
Settings = require('Storage/Settings'), import ThemeStore from 'Stores/Theme';
Remote = require('Remote/User/Ajax'); import Remote from 'Remote/User/Ajax';
/** class ThemesUserSettings
* @constructor
*/
function ThemesUserSettings()
{ {
constructor() {
this.theme = ThemeStore.theme; this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes; this.themes = ThemeStore.themes;
this.themesObjects = ko.observableArray([]); this.themesObjects = ko.observableArray([]);
@ -33,87 +30,76 @@ function ThemesUserSettings()
this.background.loading = ko.observable(false); this.background.loading = ko.observable(false);
this.background.error = ko.observable(''); this.background.error = ko.observable('');
this.capaUserBackground = ko.observable(Settings.capa(Enums.Capa.UserBackground)); this.capaUserBackground = ko.observable(capa(Capa.UserBackground));
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100}); this.themeTrigger = ko.observable(SaveSettingsStep.Idle).extend({throttle: Magics.Time100ms});
this.iTimer = 0; this.iTimer = 0;
this.oThemeAjaxRequest = null; this.oThemeAjaxRequest = null;
this.theme.subscribe(function(sValue) { this.theme.subscribe((value) => {
_.each(this.themesObjects(), (theme) => {
_.each(this.themesObjects(), function(oTheme) { theme.selected(value === theme.name);
oTheme.selected(sValue === oTheme.name);
}); });
Utils.changeTheme(sValue, this.themeTrigger); changeTheme(value, this.themeTrigger);
Remote.saveSettings(null, { Remote.saveSettings(null, {
'Theme': sValue 'Theme': value
});
}); });
}, this); this.background.hash.subscribe((value) => {
const $bg = $('#rl-bg');
this.background.hash.subscribe(function(sValue) { if (!value)
var $oBg = $('#rl-bg');
if (!sValue)
{ {
if ($oBg.data('backstretch')) if ($bg.data('backstretch'))
{ {
$oBg.backstretch('destroy').attr('style', ''); $bg.backstretch('destroy').attr('style', '');
} }
} }
else else
{ {
$('#rl-bg').attr('style', 'background-image: none !important;').backstretch( $bg.attr('style', 'background-image: none !important;').backstretch(userBackground(value), {
Links.userBackground(sValue), { fade: 1000, centeredX: true, centeredY: true
'fade': 1000, 'centeredX': true, 'centeredY': true
}).removeAttr('style'); }).removeAttr('style');
} }
}, this);
}
ThemesUserSettings.prototype.onBuild = function()
{
var sCurrentTheme = this.theme();
this.themesObjects(_.map(this.themes(), function(sTheme) {
return {
'name': sTheme,
'nameDisplay': Utils.convertThemeName(sTheme),
'selected': ko.observable(sTheme === sCurrentTheme),
'themePreviewSrc': Links.themePreviewLink(sTheme)
};
}));
this.initUploader();
};
ThemesUserSettings.prototype.onShow = function()
{
this.background.error('');
};
ThemesUserSettings.prototype.clearBackground = function()
{
if (this.capaUserBackground())
{
var self = this;
Remote.clearUserBackground(function() {
self.background.name('');
self.background.hash('');
}); });
} }
};
ThemesUserSettings.prototype.initUploader = function() onBuild() {
{ const currentTheme = this.theme();
this.themesObjects(_.map(this.themes(), (theme) => ({
name: theme,
nameDisplay: convertThemeName(theme),
selected: ko.observable(theme === currentTheme),
themePreviewSrc: themePreviewLink(theme)
})));
this.initUploader();
}
onShow() {
this.background.error('');
}
clearBackground() {
if (this.capaUserBackground())
{
Remote.clearUserBackground(() => {
this.background.name('');
this.background.hash('');
});
}
}
initUploader() {
if (this.background.uploaderButton() && this.capaUserBackground()) if (this.background.uploaderButton() && this.capaUserBackground())
{ {
var const
oJua = new Jua({ oJua = new Jua({
'action': Links.uploadBackground(), 'action': uploadBackground(),
'name': 'uploader', 'name': 'uploader',
'queueSize': 1, 'queueSize': 1,
'multipleSizeLimit': 1, 'multipleSizeLimit': 1,
@ -123,55 +109,51 @@ ThemesUserSettings.prototype.initUploader = function()
}); });
oJua oJua
.on('onStart', _.bind(function() { .on('onStart', () => {
this.background.loading(true); this.background.loading(true);
this.background.error(''); this.background.error('');
return true; return true;
})
}, this)) .on('onComplete', (id, result, data) => {
.on('onComplete', _.bind(function(sId, bResult, oData) {
this.background.loading(false); this.background.loading(false);
if (bResult && sId && oData && oData.Result && oData.Result.Name && oData.Result.Hash) if (result && id && data && data.Result && data.Result.Name && data.Result.Hash)
{ {
this.background.name(oData.Result.Name); this.background.name(data.Result.Name);
this.background.hash(oData.Result.Hash); this.background.hash(data.Result.Hash);
} }
else else
{ {
this.background.name(''); this.background.name('');
this.background.hash(''); this.background.hash('');
var sError = ''; let errorMsg = '';
if (oData.ErrorCode) if (data.ErrorCode)
{ {
switch (oData.ErrorCode) switch (data.ErrorCode)
{ {
case Enums.UploadErrorCode.FileIsTooBig: case UploadErrorCode.FileIsTooBig:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG'); errorMsg = i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG');
break; break;
case Enums.UploadErrorCode.FileType: case UploadErrorCode.FileType:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR'); errorMsg = i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR');
break; break;
// no default // no default
} }
} }
if (!sError && oData.ErrorMessage) if (!errorMsg && data.ErrorMessage)
{ {
sError = oData.ErrorMessage; errorMsg = data.ErrorMessage;
} }
this.background.error(sError || Translator.i18n('SETTINGS_THEMES/ERROR_UNKNOWN')); this.background.error(errorMsg || i18n('SETTINGS_THEMES/ERROR_UNKNOWN'));
} }
return true; return true;
});
}, this));
} }
}; }
}
export {ThemesUserSettings, ThemesUserSettings as default}; export {ThemesUserSettings, ThemesUserSettings as default};

View file

@ -5,8 +5,7 @@ import * as Settings from 'Storage/Settings';
class AbstractAppStore class AbstractAppStore
{ {
constructor() constructor() {
{
this.allowLanguagesOnSettings = ko.observable(true); this.allowLanguagesOnSettings = ko.observable(true);
this.allowLanguagesOnLogin = ko.observable(true); this.allowLanguagesOnLogin = ko.observable(true);

View file

@ -5,8 +5,7 @@ import {AbstractAppStore} from 'Stores/AbstractApp';
class AppAdminStore extends AbstractAppStore class AppAdminStore extends AbstractAppStore
{ {
constructor() constructor() {
{
super(); super();
this.determineUserLanguage = ko.observable(false); this.determineUserLanguage = ko.observable(false);

View file

@ -9,8 +9,7 @@ import {AbstractAppStore} from 'Stores/AbstractApp';
class AppUserStore extends AbstractAppStore class AppUserStore extends AbstractAppStore
{ {
constructor() constructor() {
{
super(); super();
this.currentAudio = ko.observable(''); this.currentAudio = ko.observable('');

View file

@ -4,8 +4,7 @@ import ko from 'ko';
class IdentityUserStore class IdentityUserStore
{ {
constructor() constructor() {
{
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});

View file

@ -75,7 +75,10 @@ PgpUserStore.prototype.findPublicKeysBySigningKeyIds = function(aSigningKeyIds)
PgpUserStore.prototype.findPrivateKeysByEncryptionKeyIds = function(aEncryptionKeyIds, aRecipients, bReturnWrapKeys) PgpUserStore.prototype.findPrivateKeysByEncryptionKeyIds = function(aEncryptionKeyIds, aRecipients, bReturnWrapKeys)
{ {
var self = this, aResult = []; var
self = this,
aResult = [];
aResult = Utils.isArray(aEncryptionKeyIds) ? _.compact(_.flatten(_.map(aEncryptionKeyIds, function(oId) { aResult = Utils.isArray(aEncryptionKeyIds) ? _.compact(_.flatten(_.map(aEncryptionKeyIds, function(oId) {
var oKey = oId && oId.toHex ? self.findPrivateKeyByHex(oId.toHex()) : null; var oKey = oId && oId.toHex ? self.findPrivateKeyByHex(oId.toHex()) : null;
return oKey ? (bReturnWrapKeys ? [oKey] : oKey.getNativeKeys()) : [null]; return oKey ? (bReturnWrapKeys ? [oKey] : oKey.getNativeKeys()) : [null];
@ -184,7 +187,10 @@ PgpUserStore.prototype.findSelfPrivateKey = function(sPassword)
PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallback) PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallback)
{ {
var self = this, aPrivateKeys = []; var
self = this,
aPrivateKeys = [];
if (oMessage && oMessage.getEncryptionKeyIds) if (oMessage && oMessage.getEncryptionKeyIds)
{ {
aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true); aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true);
@ -254,7 +260,12 @@ PgpUserStore.prototype.findKeyExternal = function(sEmail, fCallback)
PgpUserStore.prototype.verifyMessage = function(oMessage, fCallback) PgpUserStore.prototype.verifyMessage = function(oMessage, fCallback)
{ {
var oValid = null, aResult = [], aPublicKeys = [], aSigningKeyIds = []; var
oValid = null,
aResult = [],
aPublicKeys = [],
aSigningKeyIds = [];
if (oMessage && oMessage.getSigningKeyIds) if (oMessage && oMessage.getSigningKeyIds)
{ {
aSigningKeyIds = oMessage.getSigningKeyIds(); aSigningKeyIds = oMessage.getSigningKeyIds();
@ -323,8 +334,9 @@ PgpUserStore.prototype.controlsHelper = function(mDom, oVerControl, bSuccess, sT
PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMessage, aRecipients) PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMessage, aRecipients)
{ {
return function() { return function() {
var
var oMessage = null, $this = $(this); oMessage = null,
$this = $(this);
if ($this.hasClass('success')) if ($this.hasClass('success'))
{ {
@ -393,7 +405,10 @@ PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage
{ {
return function() { return function() {
var oMessage = null, $this = $(this); var
oMessage = null,
$this = $(this);
if ($this.hasClass('success') || $this.hasClass('error')) if ($this.hasClass('success') || $this.hasClass('error'))
{ {
return false; return false;

View file

@ -3,6 +3,13 @@
transform: rotate(1turn); transform: rotate(1turn);
} }
} }
html, body {
padding: 0;
margin: 0;
overflow: hidden;
}
.social-icon-wrp { .social-icon-wrp {
position: absolute; position: absolute;
top: 0; top: 0;

View file

@ -1,6 +1,8 @@
var var
_ = require('_'), _ = require('_'),
$ = require('$'),
key = require('key'),
Globals = require('Common/Globals'), Globals = require('Common/Globals'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),

View file

@ -4,6 +4,7 @@ var
_ = require('_'), _ = require('_'),
$ = require('$'), $ = require('$'),
ko = require('ko'), ko = require('ko'),
key = require('key'),
JSON = require('JSON'), JSON = require('JSON'),
Jua = require('Jua'), Jua = require('Jua'),
@ -928,7 +929,10 @@ ComposePopupView.prototype.setSignatureFromIdentity = function(oIdentity)
{ {
var self = this; var self = this;
this.editor(function(oEditor) { this.editor(function(oEditor) {
var bHtml = false, sSignature = oIdentity.signature(); var
bHtml = false,
sSignature = oIdentity.signature();
if ('' !== sSignature) if ('' !== sSignature)
{ {
if (':HTML:' === sSignature.substr(0, 6)) if (':HTML:' === sSignature.substr(0, 6))

View file

@ -6,6 +6,8 @@ var
ko = require('ko'), ko = require('ko'),
key = require('key'), key = require('key'),
Jua = require('Jua'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
Consts = require('Common/Consts'), Consts = require('Common/Consts'),
Globals = require('Common/Globals'), Globals = require('Common/Globals'),

View file

@ -28,6 +28,7 @@ function NewOpenPgpKeyPopupView()
this.keyBitLength = ko.observable(Enums.Magics.BitLength2048); this.keyBitLength = ko.observable(Enums.Magics.BitLength2048);
this.submitRequest = ko.observable(false); this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.email.subscribe(function() { this.email.subscribe(function() {
this.email.error(false); this.email.error(false);
@ -53,6 +54,7 @@ function NewOpenPgpKeyPopupView()
} }
this.submitRequest(true); this.submitRequest(true);
this.submitError('');
_.delay(function() { _.delay(function() {
@ -81,14 +83,15 @@ function NewOpenPgpKeyPopupView()
Utils.delegateRun(self, 'cancelCommand'); Utils.delegateRun(self, 'cancelCommand');
} }
}).then(null, function() { }).then(null, function(e) {
self.submitRequest(false); self.submitRequest(false);
self.showError(e);
}); });
} }
catch (e) catch (e)
{ {
Utils.log(e);
self.submitRequest(false); self.submitRequest(false);
self.showError(e);
} }
}, Enums.Magics.Time100ms); }, Enums.Magics.Time100ms);
@ -102,6 +105,15 @@ function NewOpenPgpKeyPopupView()
kn.extendAsViewModel(['View/Popup/NewOpenPgpKey', 'PopupsNewOpenPgpKeyViewModel'], NewOpenPgpKeyPopupView); kn.extendAsViewModel(['View/Popup/NewOpenPgpKey', 'PopupsNewOpenPgpKeyViewModel'], NewOpenPgpKeyPopupView);
_.extend(NewOpenPgpKeyPopupView.prototype, AbstractView.prototype); _.extend(NewOpenPgpKeyPopupView.prototype, AbstractView.prototype);
NewOpenPgpKeyPopupView.prototype.showError = function(e)
{
Utils.log(e);
if (e && e.message)
{
this.submitError(e.message);
}
};
NewOpenPgpKeyPopupView.prototype.clearPopup = function() NewOpenPgpKeyPopupView.prototype.clearPopup = function()
{ {
this.name(''); this.name('');
@ -110,6 +122,8 @@ NewOpenPgpKeyPopupView.prototype.clearPopup = function()
this.email(''); this.email('');
this.email.error(false); this.email.error(false);
this.keyBitLength(Enums.Magics.BitLength2048); this.keyBitLength(Enums.Magics.BitLength2048);
this.submitError('');
}; };
NewOpenPgpKeyPopupView.prototype.onShow = function() NewOpenPgpKeyPopupView.prototype.onShow = function()

View file

@ -60,15 +60,14 @@ function PluginPopupView()
list.Name = this.name(); list.Name = this.name();
_.each(this.configures(), function(oItem) { _.each(this.configures(), function(oItem) {
var value = oItem.value(); var value = oItem.value();
if (false === value || true === value) if (false === value || true === value)
{ {
value = value ? '1' : '0'; value = value ? '1' : '0';
} }
list['_' + oItem.Name] = value; list['_' + oItem.Name] = value;
}, this); }, this);
this.saveError(''); this.saveError('');
@ -119,6 +118,7 @@ PluginPopupView.prototype.onShow = function(oPlugin)
this.readme(oPlugin.Readme); this.readme(oPlugin.Readme);
var aConfig = oPlugin.Config; var aConfig = oPlugin.Config;
if (Utils.isNonEmptyArray(aConfig)) if (Utils.isNonEmptyArray(aConfig))
{ {
this.configures(_.map(aConfig, function(aItem) { this.configures(_.map(aConfig, function(aItem) {
@ -160,6 +160,7 @@ PluginPopupView.prototype.onBuild = function()
{ {
this.tryToClosePopup(); this.tryToClosePopup();
} }
return false; return false;
}, this)); }, this));
}; };

View file

@ -124,9 +124,10 @@ TemplatePopupView.prototype.populateBodyFromEditor = function()
TemplatePopupView.prototype.editorSetBody = function(sBody) TemplatePopupView.prototype.editorSetBody = function(sBody)
{ {
var self = this;
if (!this.editor && this.signatureDom()) if (!this.editor && this.signatureDom())
{ {
var self = this;
this.editor = new HtmlEditor(self.signatureDom(), function() { this.editor = new HtmlEditor(self.signatureDom(), function() {
self.populateBodyFromEditor(); self.populateBodyFromEditor();
}, function() { }, function() {

View file

@ -135,7 +135,6 @@ function LoginUserView()
}, this); }, this);
this.submitCommand = Utils.createCommand(this, function() { this.submitCommand = Utils.createCommand(this, function() {
Utils.triggerAutocompleteInputChange(); Utils.triggerAutocompleteInputChange();
this.emailError(false); this.emailError(false);
@ -276,7 +275,6 @@ function LoginUserView()
} }
return true; return true;
}, function() { }, function() {
return !this.submitRequest(); return !this.submitRequest();
}); });
@ -284,12 +282,9 @@ function LoginUserView()
this.facebookLoginEnabled = ko.observable(false); this.facebookLoginEnabled = ko.observable(false);
this.facebookCommand = Utils.createCommand(this, function() { this.facebookCommand = Utils.createCommand(this, function() {
window.open(Links.socialFacebook(), 'Facebook', window.open(Links.socialFacebook(), 'Facebook',
'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes'); 'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true; return true;
}, function() { }, function() {
return !this.submitRequest() && this.facebookLoginEnabled(); return !this.submitRequest() && this.facebookLoginEnabled();
}); });
@ -298,23 +293,17 @@ function LoginUserView()
this.googleFastLoginEnabled = ko.observable(false); this.googleFastLoginEnabled = ko.observable(false);
this.googleCommand = Utils.createCommand(this, function() { this.googleCommand = Utils.createCommand(this, function() {
window.open(Links.socialGoogle(), 'Google', window.open(Links.socialGoogle(), 'Google',
'left=200,top=100,width=650,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes'); 'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true; return true;
}, function() { }, function() {
return !this.submitRequest() && this.googleLoginEnabled(); return !this.submitRequest() && this.googleLoginEnabled();
}); });
this.googleFastCommand = Utils.createCommand(this, function() { this.googleFastCommand = Utils.createCommand(this, function() {
window.open(Links.socialGoogle(true), 'Google', window.open(Links.socialGoogle(true), 'Google',
'left=200,top=100,width=650,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes'); 'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true; return true;
}, function() { }, function() {
return !this.submitRequest() && this.googleFastLoginEnabled(); return !this.submitRequest() && this.googleFastLoginEnabled();
}); });
@ -322,18 +311,14 @@ function LoginUserView()
this.twitterLoginEnabled = ko.observable(false); this.twitterLoginEnabled = ko.observable(false);
this.twitterCommand = Utils.createCommand(this, function() { this.twitterCommand = Utils.createCommand(this, function() {
window.open(Links.socialTwitter(), 'Twitter', window.open(Links.socialTwitter(), 'Twitter',
'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes'); 'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true; return true;
}, function() { }, function() {
return !this.submitRequest() && this.twitterLoginEnabled(); return !this.submitRequest() && this.twitterLoginEnabled();
}); });
this.socialLoginEnabled = ko.computed(function() { this.socialLoginEnabled = ko.computed(function() {
var var
bF = this.facebookLoginEnabled(), bF = this.facebookLoginEnabled(),
bG = this.googleLoginEnabled(), bG = this.googleLoginEnabled(),

View file

@ -182,7 +182,11 @@ FolderListMailBoxUserView.prototype.onBuild = function(oDom)
}); });
key('space', Enums.KeyState.FolderList, function() { key('space', Enums.KeyState.FolderList, function() {
var bCollapsed = true, oFolder = null, $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom); var
bCollapsed = true,
oFolder = null,
$items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
if ($items.length && $items[0]) if ($items.length && $items[0])
{ {
oFolder = ko.dataFor($items[0]); oFolder = ko.dataFor($items[0]);

View file

@ -1068,7 +1068,10 @@ MessageViewMailBoxUserView.prototype.getAttachmentsHashes = function()
MessageViewMailBoxUserView.prototype.downloadAsZip = function() MessageViewMailBoxUserView.prototype.downloadAsZip = function()
{ {
var self = this, aHashes = this.getAttachmentsHashes(); var
self = this,
aHashes = this.getAttachmentsHashes();
if (0 < aHashes.length) if (0 < aHashes.length)
{ {
Promises.attachmentsActions('Zip', aHashes, this.downloadAsZipLoading).then(function(oResult) { Promises.attachmentsActions('Zip', aHashes, this.downloadAsZipLoading).then(function(oResult) {
@ -1094,7 +1097,10 @@ MessageViewMailBoxUserView.prototype.downloadAsZip = function()
MessageViewMailBoxUserView.prototype.saveToOwnCloud = function() MessageViewMailBoxUserView.prototype.saveToOwnCloud = function()
{ {
var self = this, aHashes = this.getAttachmentsHashes(); var
self = this,
aHashes = this.getAttachmentsHashes();
if (0 < aHashes.length) if (0 < aHashes.length)
{ {
Promises.attachmentsActions('OwnCloud', aHashes, this.saveToOwnCloudLoading).then(function(oResult) { Promises.attachmentsActions('OwnCloud', aHashes, this.saveToOwnCloudLoading).then(function(oResult) {
@ -1118,7 +1124,11 @@ MessageViewMailBoxUserView.prototype.saveToOwnCloud = function()
MessageViewMailBoxUserView.prototype.saveToDropbox = function() MessageViewMailBoxUserView.prototype.saveToDropbox = function()
{ {
var self = this, aFiles = [], aHashes = this.getAttachmentsHashes(); var
self = this,
aFiles = [],
aHashes = this.getAttachmentsHashes();
if (0 < aHashes.length) if (0 < aHashes.length)
{ {
if (window.Dropbox) if (window.Dropbox)

View file

@ -1,6 +1,7 @@
var var
_ = require('_'), _ = require('_'),
$ = require('$'),
key = require('key'), key = require('key'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),

View file

@ -1,7 +1,7 @@
import window from 'window'; import window from 'window';
import $ from '$'; import $ from '$';
import {kill_CtrlA_CtrlS, detectDropdownVisibility, createCommand} from 'Common/Utils'; import {killCtrlACtrlS, detectDropdownVisibility, createCommand} from 'Common/Utils';
import {$win, $html, data as GlobalsData, bMobileDevice} from 'Common/Globals'; import {$win, $html, data as GlobalsData, bMobileDevice} from 'Common/Globals';
import * as Enums from 'Common/Enums'; import * as Enums from 'Common/Enums';
import * as Plugins from 'Common/Plugins'; import * as Plugins from 'Common/Plugins';
@ -13,7 +13,7 @@ export default (App) => {
GlobalsData.__APP__ = App; GlobalsData.__APP__ = App;
$win $win
.on('keydown', kill_CtrlA_CtrlS) .on('keydown', killCtrlACtrlS)
.on('unload', () => { .on('unload', () => {
GlobalsData.bUnload = true; GlobalsData.bUnload = true;
}); });

View file

@ -8,7 +8,7 @@
name: 'Input', name: 'Input',
params: { params: {
value: defaultDomain, value: defaultDomain,
trigger: defaultDomainTrigger, trigger: defaultDomain.trigger,
size: 3 size: 3
} }
}"></div> }"></div>

View file

@ -9,6 +9,11 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="form-horizontal"> <div class="form-horizontal">
<div class="alert" data-bind="visible: '' !== submitError()">
<button type="button" class="close" data-bind="click: function () { submitError('') }">&times;</button>
<span data-bind="text: submitError"></span>
</div>
<br />
<div class="control-group" data-bind="css: {'error': email.error}"> <div class="control-group" data-bind="css: {'error': email.error}">
<label class="i18n control-label" data-i18n="POPUPS_GENERATE_OPEN_PGP_KEYS/LABEL_EMAIL"></label> <label class="i18n control-label" data-i18n="POPUPS_GENERATE_OPEN_PGP_KEYS/LABEL_EMAIL"></label>
<div class="controls"> <div class="controls">