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};