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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,66 +1,55 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
import {settingsSaveHelperSimpleFunction, boolToAjax, trim} from 'Common/Utils';
import {settingsGet} from 'Storage/Settings';
AppAdminStore = require('Stores/Admin/App'),
import AppAdminStore from 'Stores/Admin/App';
Settings = require('Storage/Settings');
/**
* @constructor
*/
function LoginAdminSettings()
class LoginAdminSettings
{
this.determineUserLanguage = AppAdminStore.determineUserLanguage;
this.determineUserDomain = AppAdminStore.determineUserDomain;
constructor() {
this.determineUserLanguage = AppAdminStore.determineUserLanguage;
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};

View file

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

View file

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

View file

@ -1,182 +1,174 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Links = require('Common/Links'),
import {createCommand, trim, boolToAjax} from 'Common/Utils';
import {phpInfo} from 'Common/Links';
import {StorageResultType} from 'Common/Enums';
AppAdminStore = require('Stores/Admin/App'),
CapaAdminStore = require('Stores/Admin/Capa'),
import {settingsGet} from 'Storage/Settings';
Settings = require('Storage/Settings'),
Remote = require('Remote/Admin/Ajax');
import AppAdminStore from 'Stores/Admin/App';
import CapaAdminStore from 'Stores/Admin/Capa';
/**
* @constructor
*/
function SecurityAdminSettings()
import Remote from 'Remote/Admin/Ajax';
class SecurityAdminSettings
{
this.useLocalProxyForExternalImages = AppAdminStore.useLocalProxyForExternalImages;
constructor() {
this.useLocalProxyForExternalImages = AppAdminStore.useLocalProxyForExternalImages;
this.weakPassword = AppAdminStore.weakPassword;
this.weakPassword = AppAdminStore.weakPassword;
this.capaOpenPGP = CapaAdminStore.openPGP;
this.capaOpenPGP = CapaAdminStore.openPGP;
this.capaTwoFactorAuth = CapaAdminStore.twoFactorAuth;
this.capaTwoFactorAuthForce = CapaAdminStore.twoFactorAuthForce;
this.capaTwoFactorAuth = CapaAdminStore.twoFactorAuth;
this.capaTwoFactorAuthForce = CapaAdminStore.twoFactorAuthForce;
this.capaTwoFactorAuth.subscribe(function(bValue) {
if (!bValue)
{
this.capaTwoFactorAuthForce(false);
}
}, this);
this.verifySslCertificate = ko.observable(!!Settings.settingsGet('VerifySslCertificate'));
this.allowSelfSigned = ko.observable(!!Settings.settingsGet('AllowSelfSigned'));
this.verifySslCertificate.subscribe(function(bValue) {
if (!bValue)
{
this.allowSelfSigned(true);
}
}, this);
this.adminLogin = ko.observable(Settings.settingsGet('AdminLogin'));
this.adminLoginError = ko.observable(false);
this.adminPassword = ko.observable('');
this.adminPasswordNew = ko.observable('');
this.adminPasswordNew2 = ko.observable('');
this.adminPasswordNewError = ko.observable(false);
this.adminPasswordUpdateError = ko.observable(false);
this.adminPasswordUpdateSuccess = ko.observable(false);
this.adminPassword.subscribe(function() {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
}, this);
this.adminLogin.subscribe(function() {
this.adminLoginError(false);
}, this);
this.adminPasswordNew.subscribe(function() {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
}, this);
this.adminPasswordNew2.subscribe(function() {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
}, this);
this.saveNewAdminPasswordCommand = Utils.createCommand(this, function() {
if ('' === Utils.trim(this.adminLogin()))
{
this.adminLoginError(true);
return false;
}
if (this.adminPasswordNew() !== this.adminPasswordNew2())
{
this.adminPasswordNewError(true);
return false;
}
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, {
'Login': this.adminLogin(),
'Password': this.adminPassword(),
'NewPassword': this.adminPasswordNew()
this.capaTwoFactorAuth.subscribe((value) => {
if (!value)
{
this.capaTwoFactorAuthForce(false);
}
});
return true;
this.verifySslCertificate = ko.observable(!!settingsGet('VerifySslCertificate'));
this.allowSelfSigned = ko.observable(!!settingsGet('AllowSelfSigned'));
}, function() {
return '' !== Utils.trim(this.adminLogin()) && '' !== this.adminPassword();
});
this.verifySslCertificate.subscribe((value) => {
if (!value)
{
this.allowSelfSigned(true);
}
});
this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this);
}
this.adminLogin = ko.observable(settingsGet('AdminLogin'));
this.adminLoginError = ko.observable(false);
this.adminPassword = ko.observable('');
this.adminPasswordNew = ko.observable('');
this.adminPasswordNew2 = ko.observable('');
this.adminPasswordNewError = ko.observable(false);
SecurityAdminSettings.prototype.onNewAdminPasswordResponse = function(sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.adminPasswordUpdateError = ko.observable(false);
this.adminPasswordUpdateSuccess = ko.observable(false);
this.adminPassword.subscribe(() => {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
});
this.adminLogin.subscribe(() => {
this.adminLoginError(false);
});
this.adminPasswordNew.subscribe(() => {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
});
this.adminPasswordNew2.subscribe(() => {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
});
this.saveNewAdminPasswordCommand = createCommand(this, () => {
if ('' === trim(this.adminLogin()))
{
this.adminLoginError(true);
return false;
}
if (this.adminPasswordNew() !== this.adminPasswordNew2())
{
this.adminPasswordNewError(true);
return false;
}
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, {
'Login': this.adminLogin(),
'Password': this.adminPassword(),
'NewPassword': this.adminPasswordNew()
});
return true;
}, () => '' !== trim(this.adminLogin()) && '' !== this.adminPassword());
this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this);
}
onNewAdminPasswordResponse(result, data) {
if (StorageResultType.Success === result && data && data.Result)
{
this.adminPassword('');
this.adminPasswordNew('');
this.adminPasswordNew2('');
this.adminPasswordUpdateSuccess(true);
this.weakPassword(!!data.Result.Weak);
}
else
{
this.adminPasswordUpdateError(true);
}
}
onBuild() {
this.capaOpenPGP.subscribe((value) => {
Remote.saveAdminConfig(null, {
'CapaOpenPGP': boolToAjax(value)
});
});
this.capaTwoFactorAuth.subscribe((value) => {
Remote.saveAdminConfig(null, {
'CapaTwoFactorAuth': boolToAjax(value)
});
});
this.capaTwoFactorAuthForce.subscribe((value) => {
Remote.saveAdminConfig(null, {
'CapaTwoFactorAuthForce': boolToAjax(value)
});
});
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.adminPasswordNew('');
this.adminPasswordNew2('');
this.adminPasswordUpdateSuccess(true);
this.weakPassword(!!oData.Result.Weak);
}
else
{
this.adminPasswordUpdateError(true);
/**
* @returns {string}
*/
phpInfoLink() {
return phpInfo();
}
};
SecurityAdminSettings.prototype.onBuild = function()
{
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, {
'UseLocalProxyForExternalImages': bValue ? '1' : '0'
});
});
this.verifySslCertificate.subscribe(function(bValue) {
Remote.saveAdminConfig(null, {
'VerifySslCertificate': bValue ? '1' : '0'
});
});
this.allowSelfSigned.subscribe(function(bValue) {
Remote.saveAdminConfig(null, {
'AllowSelfSigned': bValue ? '1' : '0'
});
});
};
SecurityAdminSettings.prototype.onHide = function()
{
this.adminPassword('');
this.adminPasswordNew('');
this.adminPasswordNew2('');
};
/**
* @returns {string}
*/
SecurityAdminSettings.prototype.phpInfoLink = function()
{
return Links.phpInfo();
};
}
export {SecurityAdminSettings, SecurityAdminSettings as default};

View file

@ -1,174 +1,109 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils');
import {SaveSettingsStep, Magics} from 'Common/Enums';
import {settingsSaveHelperSimpleFunction, trim, boolToAjax} from 'Common/Utils';
/**
* @constructor
*/
function SocialAdminSettings()
import SocialStore from 'Stores/Social';
class SocialAdminSettings
{
var SocialStore = require('Stores/Social');
constructor() {
this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth;
this.googleEnableAuthFast = SocialStore.google.capa.authFast;
this.googleEnableDrive = SocialStore.google.capa.drive;
this.googleEnablePreview = SocialStore.google.capa.preview;
this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth;
this.googleEnableAuthFast = SocialStore.google.capa.authFast;
this.googleEnableDrive = SocialStore.google.capa.drive;
this.googleEnablePreview = SocialStore.google.capa.preview;
this.googleEnableRequireClientSettings = SocialStore.google.require.clientSettings;
this.googleEnableRequireApiKey = SocialStore.google.require.apiKeySettings;
this.googleEnableRequireClientSettings = SocialStore.google.require.clientSettings;
this.googleEnableRequireApiKey = SocialStore.google.require.apiKeySettings;
this.googleClientID = SocialStore.google.clientID;
this.googleClientSecret = SocialStore.google.clientSecret;
this.googleApiKey = SocialStore.google.apiKey;
this.googleClientID = SocialStore.google.clientID;
this.googleClientSecret = SocialStore.google.clientSecret;
this.googleApiKey = SocialStore.google.apiKey;
this.googleTrigger1 = ko.observable(SaveSettingsStep.Idle);
this.googleTrigger2 = ko.observable(SaveSettingsStep.Idle);
this.googleTrigger3 = ko.observable(SaveSettingsStep.Idle);
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle);
this.facebookSupported = SocialStore.facebook.supported;
this.facebookEnable = SocialStore.facebook.enabled;
this.facebookAppID = SocialStore.facebook.appID;
this.facebookAppSecret = SocialStore.facebook.appSecret;
this.facebookSupported = SocialStore.facebook.supported;
this.facebookEnable = SocialStore.facebook.enabled;
this.facebookAppID = SocialStore.facebook.appID;
this.facebookAppSecret = SocialStore.facebook.appSecret;
this.facebookTrigger1 = ko.observable(SaveSettingsStep.Idle);
this.facebookTrigger2 = ko.observable(SaveSettingsStep.Idle);
this.facebookTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.facebookTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.twitterEnable = SocialStore.twitter.enabled;
this.twitterConsumerKey = SocialStore.twitter.consumerKey;
this.twitterConsumerSecret = SocialStore.twitter.consumerSecret;
this.twitterEnable = SocialStore.twitter.enabled;
this.twitterConsumerKey = SocialStore.twitter.consumerKey;
this.twitterConsumerSecret = SocialStore.twitter.consumerSecret;
this.twitterTrigger1 = ko.observable(SaveSettingsStep.Idle);
this.twitterTrigger2 = ko.observable(SaveSettingsStep.Idle);
this.twitterTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.twitterTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.dropboxEnable = SocialStore.dropbox.enabled;
this.dropboxApiKey = SocialStore.dropbox.apiKey;
this.dropboxEnable = SocialStore.dropbox.enabled;
this.dropboxApiKey = SocialStore.dropbox.apiKey;
this.dropboxTrigger1 = ko.observable(SaveSettingsStep.Idle);
}
this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
onBuild() {
_.delay(() => {
const
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);
this.facebookEnable.subscribe((value) => {
if (this.facebookSupported())
{
Remote.saveAdminConfig(null, {
'FacebookEnable': boolToAjax(value)
});
}
});
this.facebookAppID.subscribe((value) => {
if (this.facebookSupported())
{
Remote.saveAdminConfig(f1, {
'FacebookAppID': trim(value)
});
}
});
this.facebookAppSecret.subscribe((value) => {
if (this.facebookSupported())
{
Remote.saveAdminConfig(f2, {
'FacebookAppSecret': trim(value)
});
}
});
this.twitterEnable.subscribe(Remote.saveAdminConfigHelper('TwitterEnable', boolToAjax));
this.twitterConsumerKey.subscribe(Remote.saveAdminConfigHelper('TwitterConsumerKey', trim, f3));
this.twitterConsumerSecret.subscribe(Remote.saveAdminConfigHelper('TwitterConsumerSecret', trim, f4));
this.googleEnable.subscribe(Remote.saveAdminConfigHelper('GoogleEnable', boolToAjax));
this.googleEnableAuth.subscribe(Remote.saveAdminConfigHelper('GoogleEnableAuth', boolToAjax));
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));
this.dropboxEnable.subscribe(Remote.saveAdminConfigHelper('DropboxEnable', boolToAjax));
this.dropboxApiKey.subscribe(Remote.saveAdminConfigHelper('DropboxApiKey', trim, f8));
}, Magics.Time50ms);
}
}
SocialAdminSettings.prototype.onBuild = function()
{
var
self = this,
Remote = require('Remote/Admin/Ajax');
_.delay(function() {
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, {
'FacebookEnable': bValue ? '1' : '0'
});
}
});
self.facebookAppID.subscribe(function(sValue) {
if (self.facebookSupported())
{
Remote.saveAdminConfig(f1, {
'FacebookAppID': Utils.trim(sValue)
});
}
});
self.facebookAppSecret.subscribe(function(sValue) {
if (self.facebookSupported())
{
Remote.saveAdminConfig(f2, {
'FacebookAppSecret': Utils.trim(sValue)
});
}
});
self.twitterEnable.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'TwitterEnable': bValue ? '1' : '0'
});
});
self.twitterConsumerKey.subscribe(function(sValue) {
Remote.saveAdminConfig(f3, {
'TwitterConsumerKey': Utils.trim(sValue)
});
});
self.twitterConsumerSecret.subscribe(function(sValue) {
Remote.saveAdminConfig(f4, {
'TwitterConsumerSecret': Utils.trim(sValue)
});
});
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};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,76 +1,69 @@
var
_ = require('_'),
ko = require('ko'),
window = require('window'),
import _ from '_';
import ko from 'ko';
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';
/**
* @constructor
*/
function OpenPgpUserSettings()
class OpenPgpUserSettings
{
this.openpgpkeys = PgpStore.openpgpkeys;
this.openpgpkeysPublic = PgpStore.openpgpkeysPublic;
this.openpgpkeysPrivate = PgpStore.openpgpkeysPrivate;
constructor() {
this.openpgpkeys = PgpStore.openpgpkeys;
this.openpgpkeysPublic = PgpStore.openpgpkeysPublic;
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;
}
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]);
this.isHttps = bIsHttps;
}
};
/**
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
*/
OpenPgpUserSettings.prototype.deleteOpenPgpKey = function(oOpenPgpKeyToRemove)
{
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
{
this.openPgpKeyForDeletion(null);
addOpenPgpKey() {
showScreenPopup(require('View/Popup/AddOpenPgpKey'));
}
if (oOpenPgpKeyToRemove && PgpStore.openpgpKeyring)
generateOpenPgpKey() {
showScreenPopup(require('View/Popup/NewOpenPgpKey'));
}
viewOpenPgpKey(openPgpKey) {
if (openPgpKey)
{
var oFindedItem = _.find(PgpStore.openpgpkeys(), function(oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey;
});
if (oFindedItem)
{
PgpStore.openpgpkeys.remove(oFindedItem);
Utils.delegateRunOnDestroy(oFindedItem);
PgpStore.openpgpKeyring[oFindedItem.isPrivate ? 'privateKeys' : 'publicKeys']
.removeForId(oFindedItem.guid);
PgpStore.openpgpKeyring.store();
}
require('App/User').default.reloadOpenPgpKeys();
showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [openPgpKey]);
}
}
};
/**
* @param {OpenPgpKeyModel} openPgpKeyToRemove
* @returns {void}
*/
deleteOpenPgpKey(openPgpKeyToRemove) {
if (openPgpKeyToRemove && openPgpKeyToRemove.deleteAccess())
{
this.openPgpKeyForDeletion(null);
if (openPgpKeyToRemove && PgpStore.openpgpKeyring)
{
const findedItem = _.find(PgpStore.openpgpkeys(), (key) => openPgpKeyToRemove === key);
if (findedItem)
{
PgpStore.openpgpkeys.remove(findedItem);
delegateRunOnDestroy(findedItem);
PgpStore
.openpgpKeyring[findedItem.isPrivate ? 'privateKeys' : 'publicKeys']
.removeForId(findedItem.guid);
PgpStore.openpgpKeyring.store();
}
require('App/User').default.reloadOpenPgpKeys();
}
}
}
}
export {OpenPgpUserSettings, OpenPgpUserSettings as default};

View file

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

View file

@ -1,73 +1,70 @@
/**
* @constructor
*/
function SocialUserSettings()
import {createCommand} from 'Common/Utils';
import SocialStore from 'Stores/Social';
class SocialUserSettings
{
var
Utils = require('Common/Utils'),
SocialStore = require('Stores/Social');
constructor() {
this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth;
this.googleEnableAuthFast = SocialStore.google.capa.authFast;
this.googleEnableDrive = SocialStore.google.capa.drive;
this.googleEnablePreview = SocialStore.google.capa.preview;
this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth;
this.googleEnableAuthFast = SocialStore.google.capa.authFast;
this.googleEnableDrive = SocialStore.google.capa.drive;
this.googleEnablePreview = SocialStore.google.capa.preview;
this.googleActions = SocialStore.google.loading;
this.googleLoggined = SocialStore.google.loggined;
this.googleUserName = SocialStore.google.userName;
this.googleActions = SocialStore.google.loading;
this.googleLoggined = SocialStore.google.loggined;
this.googleUserName = SocialStore.google.userName;
this.facebookEnable = SocialStore.facebook.enabled;
this.facebookEnable = SocialStore.facebook.enabled;
this.facebookActions = SocialStore.facebook.loading;
this.facebookLoggined = SocialStore.facebook.loggined;
this.facebookUserName = SocialStore.facebook.userName;
this.facebookActions = SocialStore.facebook.loading;
this.facebookLoggined = SocialStore.facebook.loggined;
this.facebookUserName = SocialStore.facebook.userName;
this.twitterEnable = SocialStore.twitter.enabled;
this.twitterEnable = SocialStore.twitter.enabled;
this.twitterActions = SocialStore.twitter.loading;
this.twitterLoggined = SocialStore.twitter.loggined;
this.twitterUserName = SocialStore.twitter.userName;
this.twitterActions = SocialStore.twitter.loading;
this.twitterLoggined = SocialStore.twitter.loggined;
this.twitterUserName = SocialStore.twitter.userName;
this.connectGoogle = createCommand(this, () => {
if (!this.googleLoggined())
{
this.getApp().googleConnect();
}
}, () => !this.googleLoggined() && !this.googleActions());
this.connectGoogle = Utils.createCommand(this, function() {
if (!this.googleLoggined())
{
require('App/User').default.googleConnect();
}
}, function() {
return !this.googleLoggined() && !this.googleActions();
});
this.disconnectGoogle = createCommand(this, () => {
this.getApp().googleDisconnect();
});
this.disconnectGoogle = Utils.createCommand(this, function() {
require('App/User').default.googleDisconnect();
});
this.connectFacebook = createCommand(this, () => {
if (!this.facebookLoggined())
{
this.getApp().facebookConnect();
}
}, () => !this.facebookLoggined() && !this.facebookActions());
this.connectFacebook = Utils.createCommand(this, function() {
if (!this.facebookLoggined())
{
require('App/User').default.facebookConnect();
}
}, function() {
return !this.facebookLoggined() && !this.facebookActions();
});
this.disconnectFacebook = createCommand(this, () => {
this.getApp().facebookDisconnect();
});
this.disconnectFacebook = Utils.createCommand(this, function() {
require('App/User').default.facebookDisconnect();
});
this.connectTwitter = createCommand(this, () => {
if (!this.twitterLoggined())
{
this.getApp().twitterConnect();
}
}, () => !this.twitterLoggined() && !this.twitterActions());
this.connectTwitter = Utils.createCommand(this, function() {
if (!this.twitterLoggined())
{
require('App/User').default.twitterConnect();
}
}, function() {
return !this.twitterLoggined() && !this.twitterActions();
});
this.disconnectTwitter = createCommand(this, () => {
this.getApp().twitterDisconnect();
});
}
this.disconnectTwitter = Utils.createCommand(this, function() {
require('App/User').default.twitterDisconnect();
});
getApp() {
return require('App/User').default;
}
}
export {SocialUserSettings, SocialUserSettings as default};

View file

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

View file

@ -1,177 +1,159 @@
var
_ = require('_'),
$ = require('$'),
ko = require('ko'),
import _ from '_';
import $ from '$';
import ko from 'ko';
Jua = require('Jua'),
import Jua from 'Jua';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Links = require('Common/Links'),
Translator = require('Common/Translator'),
import {SaveSettingsStep, UploadErrorCode, Capa, Magics} from 'Common/Enums';
import {changeTheme, convertThemeName} from 'Common/Utils';
import {userBackground, themePreviewLink, uploadBackground} from 'Common/Links';
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';
/**
* @constructor
*/
function ThemesUserSettings()
class ThemesUserSettings
{
this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes;
this.themesObjects = ko.observableArray([]);
constructor() {
this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes;
this.themesObjects = ko.observableArray([]);
this.background = {};
this.background.name = ThemeStore.themeBackgroundName;
this.background.hash = ThemeStore.themeBackgroundHash;
this.background.uploaderButton = ko.observable(null);
this.background.loading = ko.observable(false);
this.background.error = ko.observable('');
this.background = {};
this.background.name = ThemeStore.themeBackgroundName;
this.background.hash = ThemeStore.themeBackgroundHash;
this.background.uploaderButton = ko.observable(null);
this.background.loading = ko.observable(false);
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.oThemeAjaxRequest = null;
this.iTimer = 0;
this.oThemeAjaxRequest = null;
this.theme.subscribe(function(sValue) {
_.each(this.themesObjects(), function(oTheme) {
oTheme.selected(sValue === oTheme.name);
});
Utils.changeTheme(sValue, this.themeTrigger);
Remote.saveSettings(null, {
'Theme': sValue
});
}, this);
this.background.hash.subscribe(function(sValue) {
var $oBg = $('#rl-bg');
if (!sValue)
{
if ($oBg.data('backstretch'))
{
$oBg.backstretch('destroy').attr('style', '');
}
}
else
{
$('#rl-bg').attr('style', 'background-image: none !important;').backstretch(
Links.userBackground(sValue), {
'fade': 1000, 'centeredX': true, 'centeredY': true
}).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()
{
if (this.background.uploaderButton() && this.capaUserBackground())
{
var
oJua = new Jua({
'action': Links.uploadBackground(),
'name': 'uploader',
'queueSize': 1,
'multipleSizeLimit': 1,
'disableDragAndDrop': true,
'disableMultiple': true,
'clickElement': this.background.uploaderButton()
this.theme.subscribe((value) => {
_.each(this.themesObjects(), (theme) => {
theme.selected(value === theme.name);
});
oJua
.on('onStart', _.bind(function() {
changeTheme(value, this.themeTrigger);
this.background.loading(true);
this.background.error('');
Remote.saveSettings(null, {
'Theme': value
});
});
return true;
}, this))
.on('onComplete', _.bind(function(sId, bResult, oData) {
this.background.loading(false);
if (bResult && sId && oData && oData.Result && oData.Result.Name && oData.Result.Hash)
this.background.hash.subscribe((value) => {
const $bg = $('#rl-bg');
if (!value)
{
if ($bg.data('backstretch'))
{
this.background.name(oData.Result.Name);
this.background.hash(oData.Result.Hash);
$bg.backstretch('destroy').attr('style', '');
}
else
{
this.background.name('');
this.background.hash('');
var sError = '';
if (oData.ErrorCode)
{
switch (oData.ErrorCode)
{
case Enums.UploadErrorCode.FileIsTooBig:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG');
break;
case Enums.UploadErrorCode.FileType:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR');
break;
// no default
}
}
if (!sError && oData.ErrorMessage)
{
sError = oData.ErrorMessage;
}
this.background.error(sError || Translator.i18n('SETTINGS_THEMES/ERROR_UNKNOWN'));
}
return true;
}, this));
}
else
{
$bg.attr('style', 'background-image: none !important;').backstretch(userBackground(value), {
fade: 1000, centeredX: true, centeredY: true
}).removeAttr('style');
}
});
}
};
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())
{
const
oJua = new Jua({
'action': uploadBackground(),
'name': 'uploader',
'queueSize': 1,
'multipleSizeLimit': 1,
'disableDragAndDrop': true,
'disableMultiple': true,
'clickElement': this.background.uploaderButton()
});
oJua
.on('onStart', () => {
this.background.loading(true);
this.background.error('');
return true;
})
.on('onComplete', (id, result, data) => {
this.background.loading(false);
if (result && id && data && data.Result && data.Result.Name && data.Result.Hash)
{
this.background.name(data.Result.Name);
this.background.hash(data.Result.Hash);
}
else
{
this.background.name('');
this.background.hash('');
let errorMsg = '';
if (data.ErrorCode)
{
switch (data.ErrorCode)
{
case UploadErrorCode.FileIsTooBig:
errorMsg = i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG');
break;
case UploadErrorCode.FileType:
errorMsg = i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR');
break;
// no default
}
}
if (!errorMsg && data.ErrorMessage)
{
errorMsg = data.ErrorMessage;
}
this.background.error(errorMsg || i18n('SETTINGS_THEMES/ERROR_UNKNOWN'));
}
return true;
});
}
}
}
export {ThemesUserSettings, ThemesUserSettings as default};