mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +03:00
Code refactoring
This commit is contained in:
parent
4a95dd6195
commit
36329110e5
81 changed files with 3474 additions and 2124 deletions
89
dev/Settings/Admin/AdminSettingsAbout.js
Normal file
89
dev/Settings/Admin/AdminSettingsAbout.js
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsAbout()
|
||||
{
|
||||
var
|
||||
AppSettings = require('../../Storages/AppSettings.js'),
|
||||
Data = require('../../Storages/AdminDataStorage.js')
|
||||
;
|
||||
|
||||
this.version = ko.observable(AppSettings.settingsGet('Version'));
|
||||
this.access = ko.observable(!!AppSettings.settingsGet('CoreAccess'));
|
||||
this.errorDesc = ko.observable('');
|
||||
|
||||
this.coreReal = Data.coreReal;
|
||||
this.coreUpdatable = Data.coreUpdatable;
|
||||
this.coreAccess = Data.coreAccess;
|
||||
this.coreChecking = Data.coreChecking;
|
||||
this.coreUpdating = Data.coreUpdating;
|
||||
this.coreRemoteVersion = Data.coreRemoteVersion;
|
||||
this.coreRemoteRelease = Data.coreRemoteRelease;
|
||||
this.coreVersionCompare = Data.coreVersionCompare;
|
||||
|
||||
this.statusType = ko.computed(function () {
|
||||
|
||||
var
|
||||
sType = '',
|
||||
iVersionCompare = this.coreVersionCompare(),
|
||||
bChecking = this.coreChecking(),
|
||||
bUpdating = this.coreUpdating(),
|
||||
bReal = this.coreReal()
|
||||
;
|
||||
|
||||
if (bChecking)
|
||||
{
|
||||
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.');
|
||||
}
|
||||
|
||||
return sType;
|
||||
|
||||
}, this);
|
||||
}
|
||||
|
||||
AdminSettingsAbout.prototype.onBuild = function ()
|
||||
{
|
||||
if (this.access())
|
||||
{
|
||||
require('../../Apps/AdminApp.js').reloadCoreData();
|
||||
}
|
||||
};
|
||||
|
||||
AdminSettingsAbout.prototype.updateCoreData = function ()
|
||||
{
|
||||
if (!this.coreUpdating())
|
||||
{
|
||||
require('../../Apps/AdminApp.js').updateCoreData();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsAbout;
|
||||
|
||||
}(module, require));
|
||||
92
dev/Settings/Admin/AdminSettingsBranding.js
Normal file
92
dev/Settings/Admin/AdminSettingsBranding.js
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Utils = require('Utils')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsBranding()
|
||||
{
|
||||
var
|
||||
Enums = require('Enums'),
|
||||
AppSettings = require('../../Storages/AppSettings.js')
|
||||
;
|
||||
|
||||
this.title = ko.observable(AppSettings.settingsGet('Title'));
|
||||
this.title.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.loadingDesc = ko.observable(AppSettings.settingsGet('LoadingDescription'));
|
||||
this.loadingDesc.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.loginLogo = ko.observable(AppSettings.settingsGet('LoginLogo'));
|
||||
this.loginLogo.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.loginDescription = ko.observable(AppSettings.settingsGet('LoginDescription'));
|
||||
this.loginDescription.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.loginCss = ko.observable(AppSettings.settingsGet('LoginCss'));
|
||||
this.loginCss.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
}
|
||||
|
||||
AdminSettingsBranding.prototype.onBuild = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
var
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.title.trigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.loadingDesc.trigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.loginLogo.trigger, self),
|
||||
f4 = Utils.settingsSaveHelperSimpleFunction(self.loginDescription.trigger, self),
|
||||
f5 = Utils.settingsSaveHelperSimpleFunction(self.loginCss.trigger, self)
|
||||
;
|
||||
|
||||
self.title.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f1, {
|
||||
'Title': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loadingDesc.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f2, {
|
||||
'LoadingDescription': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginLogo.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f3, {
|
||||
'LoginLogo': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginDescription.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f4, {
|
||||
'LoginDescription': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginCss.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f5, {
|
||||
'LoginCss': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
}, 50);
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsBranding;
|
||||
|
||||
}(module, require));
|
||||
243
dev/Settings/Admin/AdminSettingsContacts.js
Normal file
243
dev/Settings/Admin/AdminSettingsContacts.js
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
|
||||
AppSettings = require('../../Storages/AppSettings.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsContacts()
|
||||
{
|
||||
var
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
this.enableContacts = ko.observable(!!AppSettings.settingsGet('ContactsEnable'));
|
||||
this.contactsSharing = ko.observable(!!AppSettings.settingsGet('ContactsSharing'));
|
||||
this.contactsSync = ko.observable(!!AppSettings.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;
|
||||
}
|
||||
|
||||
return sName;
|
||||
}
|
||||
;
|
||||
|
||||
if (!!AppSettings.settingsGet('SQLiteIsSupported'))
|
||||
{
|
||||
aSupportedTypes.push('sqlite');
|
||||
}
|
||||
if (!!AppSettings.settingsGet('MySqlIsSupported'))
|
||||
{
|
||||
aSupportedTypes.push('mysql');
|
||||
}
|
||||
if (!!AppSettings.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 ? ' (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))
|
||||
{
|
||||
this.contactsType(sValue);
|
||||
}
|
||||
else if (0 < aSupportedTypes.length)
|
||||
{
|
||||
this.contactsType('');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.contactsType.valueHasMutated();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.contactsType.subscribe(function () {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
}, this);
|
||||
|
||||
this.pdoDsn = ko.observable(AppSettings.settingsGet('ContactsPdoDsn'));
|
||||
this.pdoUser = ko.observable(AppSettings.settingsGet('ContactsPdoUser'));
|
||||
this.pdoPassword = ko.observable(AppSettings.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()
|
||||
});
|
||||
|
||||
}, function () {
|
||||
return '' !== this.pdoDsn() && '' !== this.pdoUser();
|
||||
});
|
||||
|
||||
this.contactsType(AppSettings.settingsGet('ContactsPdoType'));
|
||||
|
||||
this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this);
|
||||
}
|
||||
|
||||
AdminSettingsContacts.prototype.onTestContactsResponse = function (sResult, oData)
|
||||
{
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Result)
|
||||
{
|
||||
this.testContactsSuccess(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.testContactsError(true);
|
||||
if (oData && oData.Result)
|
||||
{
|
||||
this.testContactsErrorMessage(oData.Result.Message || '');
|
||||
}
|
||||
else
|
||||
{
|
||||
this.testContactsErrorMessage('');
|
||||
}
|
||||
}
|
||||
|
||||
this.testing(false);
|
||||
};
|
||||
|
||||
AdminSettingsContacts.prototype.onShow = function ()
|
||||
{
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
};
|
||||
|
||||
AdminSettingsContacts.prototype.onBuild = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
_.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'
|
||||
});
|
||||
});
|
||||
|
||||
self.contactsSharing.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'ContactsSharing': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.contactsSync.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'ContactsSync': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.contactsType.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f5, {
|
||||
'ContactsPdoType': sValue
|
||||
});
|
||||
});
|
||||
|
||||
self.pdoDsn.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f1, {
|
||||
'ContactsPdoDsn': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.pdoUser.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f3, {
|
||||
'ContactsPdoUser': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.pdoPassword.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f4, {
|
||||
'ContactsPdoPassword': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.contactsType(AppSettings.settingsGet('ContactsPdoType'));
|
||||
|
||||
}, 50);
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsContacts;
|
||||
|
||||
}(module, require));
|
||||
107
dev/Settings/Admin/AdminSettingsDomains.js
Normal file
107
dev/Settings/Admin/AdminSettingsDomains.js
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
|
||||
PopupsDomainViewModel = require('../../ViewModels/Popups/PopupsDomainViewModel.js'),
|
||||
|
||||
Data = require('../../Storages/AdminDataStorage.js'),
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsDomains()
|
||||
{
|
||||
this.domains = Data.domains;
|
||||
this.domainsLoading = Data.domainsLoading;
|
||||
|
||||
this.iDomainForDeletionTimeout = 0;
|
||||
|
||||
this.visibility = ko.computed(function () {
|
||||
return Data.domainsLoading() ? 'visible' : 'hidden';
|
||||
}, this);
|
||||
|
||||
this.domainForDeletion = ko.observable(null).extend({'toggleSubscribe': [this,
|
||||
function (oPrev) {
|
||||
if (oPrev)
|
||||
{
|
||||
oPrev.deleteAccess(false);
|
||||
}
|
||||
}, function (oNext) {
|
||||
if (oNext)
|
||||
{
|
||||
oNext.deleteAccess(true);
|
||||
this.startDomainForDeletionTimeout();
|
||||
}
|
||||
}
|
||||
]});
|
||||
}
|
||||
|
||||
AdminSettingsDomains.prototype.startDomainForDeletionTimeout = function ()
|
||||
{
|
||||
var self = this;
|
||||
window.clearInterval(this.iDomainForDeletionTimeout);
|
||||
this.iDomainForDeletionTimeout = window.setTimeout(function () {
|
||||
self.domainForDeletion(null);
|
||||
}, 1000 * 3);
|
||||
};
|
||||
|
||||
AdminSettingsDomains.prototype.createDomain = function ()
|
||||
{
|
||||
require('kn').showScreenPopup(PopupsDomainViewModel);
|
||||
};
|
||||
|
||||
AdminSettingsDomains.prototype.deleteDomain = function (oDomain)
|
||||
{
|
||||
this.domains.remove(oDomain);
|
||||
Remote.domainDelete(_.bind(this.onDomainListChangeRequest, this), oDomain.name);
|
||||
};
|
||||
|
||||
AdminSettingsDomains.prototype.disableDomain = function (oDomain)
|
||||
{
|
||||
oDomain.disabled(!oDomain.disabled());
|
||||
Remote.domainDisable(_.bind(this.onDomainListChangeRequest, this), oDomain.name, oDomain.disabled());
|
||||
};
|
||||
|
||||
AdminSettingsDomains.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(_.bind(self.onDomainLoadRequest, self), oDomainItem.name);
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
require('../../Apps/AdminApp.js').reloadDomainList();
|
||||
};
|
||||
|
||||
AdminSettingsDomains.prototype.onDomainLoadRequest = function (sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
require('kn').showScreenPopup(PopupsDomainViewModel, [oData.Result]);
|
||||
}
|
||||
};
|
||||
|
||||
AdminSettingsDomains.prototype.onDomainListChangeRequest = function ()
|
||||
{
|
||||
require('../../Apps/AdminApp.js').reloadDomainList();
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsDomains;
|
||||
|
||||
}(module, require));
|
||||
148
dev/Settings/Admin/AdminSettingsGeneral.js
Normal file
148
dev/Settings/Admin/AdminSettingsGeneral.js
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
LinkBuilder = require('LinkBuilder'),
|
||||
|
||||
AppSettings = require('../../Storages/AppSettings.js'),
|
||||
Data = require('../../Storages/AdminDataStorage.js'),
|
||||
|
||||
PopupsLanguagesViewModel = require('../../ViewModels/Popups/PopupsLanguagesViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsGeneral()
|
||||
{
|
||||
this.mainLanguage = Data.mainLanguage;
|
||||
this.mainTheme = Data.mainTheme;
|
||||
|
||||
this.language = Data.language;
|
||||
this.theme = Data.theme;
|
||||
|
||||
this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings;
|
||||
this.capaThemes = Data.capaThemes;
|
||||
this.capaGravatar = Data.capaGravatar;
|
||||
this.capaAdditionalAccounts = Data.capaAdditionalAccounts;
|
||||
this.capaAdditionalIdentities = Data.capaAdditionalIdentities;
|
||||
|
||||
this.mainAttachmentLimit = ko.observable(Utils.pInt(AppSettings.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
|
||||
this.uploadData = AppSettings.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.themesOptions = ko.computed(function () {
|
||||
return _.map(Data.themes(), function (sTheme) {
|
||||
return {
|
||||
'optValue': sTheme,
|
||||
'optText': Utils.convertThemeName(sTheme)
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
this.mainLanguageFullName = ko.computed(function () {
|
||||
return Utils.convertLangName(this.mainLanguage());
|
||||
}, this);
|
||||
|
||||
this.weakPassword = !!AppSettings.settingsGet('WeakPassword');
|
||||
|
||||
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
}
|
||||
|
||||
AdminSettingsGeneral.prototype.onBuild = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
var
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self)
|
||||
;
|
||||
|
||||
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.theme.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f3, {
|
||||
'Theme': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.capaAdditionalAccounts.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaAdditionalAccounts': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.capaAdditionalIdentities.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaAdditionalIdentities': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.capaGravatar.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaGravatar': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.capaThemes.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'CapaThemes': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.allowLanguagesOnSettings.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'AllowLanguagesOnSettings': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
}, 50);
|
||||
};
|
||||
|
||||
AdminSettingsGeneral.prototype.selectLanguage = function ()
|
||||
{
|
||||
require('kn').showScreenPopup(PopupsLanguagesViewModel);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
AdminSettingsGeneral.prototype.phpInfoLink = function ()
|
||||
{
|
||||
return LinkBuilder.phpInfo();
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsGeneral;
|
||||
|
||||
}(module, require));
|
||||
73
dev/Settings/Admin/AdminSettingsLicensing.js
Normal file
73
dev/Settings/Admin/AdminSettingsLicensing.js
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
moment = require('moment'),
|
||||
|
||||
AppSettings = require('../../Storages/AppSettings.js'),
|
||||
Data = require('../../Storages/AdminDataStorage.js'),
|
||||
|
||||
PopupsActivateViewModel = require('../../ViewModels/Popups/PopupsActivateViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsLicensing()
|
||||
{
|
||||
this.licensing = Data.licensing;
|
||||
this.licensingProcess = Data.licensingProcess;
|
||||
this.licenseValid = Data.licenseValid;
|
||||
this.licenseExpired = Data.licenseExpired;
|
||||
this.licenseError = Data.licenseError;
|
||||
this.licenseTrigger = Data.licenseTrigger;
|
||||
|
||||
this.adminDomain = ko.observable('');
|
||||
this.subscriptionEnabled = ko.observable(!!AppSettings.settingsGet('SubscriptionEnabled'));
|
||||
|
||||
this.licenseTrigger.subscribe(function () {
|
||||
if (this.subscriptionEnabled())
|
||||
{
|
||||
require('../../Apps/AdminApp.js').reloadLicensing(true);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
AdminSettingsLicensing.prototype.onBuild = function ()
|
||||
{
|
||||
if (this.subscriptionEnabled())
|
||||
{
|
||||
require('../../Apps/AdminApp.js').reloadLicensing(false);
|
||||
}
|
||||
};
|
||||
|
||||
AdminSettingsLicensing.prototype.onShow = function ()
|
||||
{
|
||||
this.adminDomain(AppSettings.settingsGet('AdminDomain'));
|
||||
};
|
||||
|
||||
AdminSettingsLicensing.prototype.showActivationForm = function ()
|
||||
{
|
||||
require('kn').showScreenPopup(PopupsActivateViewModel);
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
AdminSettingsLicensing.prototype.licenseExpiredMomentValue = function ()
|
||||
{
|
||||
var
|
||||
iTime = this.licenseExpired(),
|
||||
oDate = moment.unix(iTime)
|
||||
;
|
||||
|
||||
return iTime && 1898625600 === iTime ? 'Never' : (oDate.format('LL') + ' (' + oDate.from(moment()) + ')');
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsLicensing;
|
||||
|
||||
}(module, require));
|
||||
72
dev/Settings/Admin/AdminSettingsLogin.js
Normal file
72
dev/Settings/Admin/AdminSettingsLogin.js
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
|
||||
AppSettings = require('../../Storages/AppSettings.js'),
|
||||
Data = require('../../Storages/AdminDataStorage.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsLogin()
|
||||
{
|
||||
this.determineUserLanguage = Data.determineUserLanguage;
|
||||
this.determineUserDomain = Data.determineUserDomain;
|
||||
|
||||
this.defaultDomain = ko.observable(AppSettings.settingsGet('LoginDefaultDomain'));
|
||||
|
||||
this.allowLanguagesOnLogin = Data.allowLanguagesOnLogin;
|
||||
this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
}
|
||||
|
||||
AdminSettingsLogin.prototype.onBuild = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
_.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);
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsLogin;
|
||||
|
||||
}(module, require));
|
||||
114
dev/Settings/Admin/AdminSettingsPackages.js
Normal file
114
dev/Settings/Admin/AdminSettingsPackages.js
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
|
||||
Data = require('../../Storages/AdminDataStorage.js'),
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsPackages()
|
||||
{
|
||||
this.packagesError = ko.observable('');
|
||||
|
||||
this.packages = Data.packages;
|
||||
this.packagesLoading = Data.packagesLoading;
|
||||
this.packagesReal = Data.packagesReal;
|
||||
this.packagesMainUpdatable = Data.packagesMainUpdatable;
|
||||
|
||||
this.packagesCurrent = this.packages.filter(function (oItem) {
|
||||
return oItem && '' !== oItem['installed'] && !oItem['compare'];
|
||||
});
|
||||
|
||||
this.packagesAvailableForUpdate = this.packages.filter(function (oItem) {
|
||||
return oItem && '' !== oItem['installed'] && !!oItem['compare'];
|
||||
});
|
||||
|
||||
this.packagesAvailableForInstallation = this.packages.filter(function (oItem) {
|
||||
return oItem && '' === oItem['installed'];
|
||||
});
|
||||
|
||||
this.visibility = ko.computed(function () {
|
||||
return Data.packagesLoading() ? 'visible' : 'hidden';
|
||||
}, this);
|
||||
}
|
||||
|
||||
AdminSettingsPackages.prototype.onShow = function ()
|
||||
{
|
||||
this.packagesError('');
|
||||
};
|
||||
|
||||
AdminSettingsPackages.prototype.onBuild = function ()
|
||||
{
|
||||
require('../../Apps/AdminApp.js').reloadPackagesList();
|
||||
};
|
||||
|
||||
AdminSettingsPackages.prototype.requestHelper = function (oPackage, bInstall)
|
||||
{
|
||||
var self = this;
|
||||
return function (sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||
{
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
self.packagesError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
self.packagesError(Utils.getNotification(
|
||||
bInstall ? Enums.Notification.CantInstallPackage : Enums.Notification.CantDeletePackage));
|
||||
}
|
||||
}
|
||||
|
||||
_.each(Data.packages(), function (oItem) {
|
||||
if (oItem && oPackage && oItem['loading']() && oPackage['file'] === oItem['file'])
|
||||
{
|
||||
oPackage['loading'](false);
|
||||
oItem['loading'](false);
|
||||
}
|
||||
});
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result['Reload'])
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
require('../../Apps/AdminApp.js').reloadPackagesList();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
AdminSettingsPackages.prototype.deletePackage = function (oPackage)
|
||||
{
|
||||
if (oPackage)
|
||||
{
|
||||
oPackage['loading'](true);
|
||||
Remote.packageDelete(this.requestHelper(oPackage, false), oPackage);
|
||||
}
|
||||
};
|
||||
|
||||
AdminSettingsPackages.prototype.installPackage = function (oPackage)
|
||||
{
|
||||
if (oPackage)
|
||||
{
|
||||
oPackage['loading'](true);
|
||||
Remote.packageInstall(this.requestHelper(oPackage, true), oPackage);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsPackages;
|
||||
|
||||
}(module, require));
|
||||
116
dev/Settings/Admin/AdminSettingsPlugins.js
Normal file
116
dev/Settings/Admin/AdminSettingsPlugins.js
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
|
||||
AppSettings = require('../../Storages/AppSettings.js'),
|
||||
Data = require('../../Storages/AdminDataStorage.js'),
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js'),
|
||||
|
||||
PopupsPluginViewModel = require('../../ViewModels/Popups/PopupsPluginViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsPlugins()
|
||||
{
|
||||
this.enabledPlugins = ko.observable(!!AppSettings.settingsGet('EnabledPlugins'));
|
||||
|
||||
this.pluginsError = ko.observable('');
|
||||
|
||||
this.plugins = Data.plugins;
|
||||
this.pluginsLoading = Data.pluginsLoading;
|
||||
|
||||
this.visibility = ko.computed(function () {
|
||||
return Data.pluginsLoading() ? 'visible' : 'hidden';
|
||||
}, this);
|
||||
|
||||
this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this);
|
||||
this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this);
|
||||
}
|
||||
|
||||
AdminSettingsPlugins.prototype.disablePlugin = function (oPlugin)
|
||||
{
|
||||
oPlugin.disabled(!oPlugin.disabled());
|
||||
Remote.pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled());
|
||||
};
|
||||
|
||||
AdminSettingsPlugins.prototype.configurePlugin = function (oPlugin)
|
||||
{
|
||||
Remote.plugin(this.onPluginLoadRequest, oPlugin.name);
|
||||
};
|
||||
|
||||
AdminSettingsPlugins.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.emptyFunction, {
|
||||
'EnabledPlugins': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
AdminSettingsPlugins.prototype.onShow = function ()
|
||||
{
|
||||
this.pluginsError('');
|
||||
require('../../Apps/AdminApp.js').reloadPluginList();
|
||||
};
|
||||
|
||||
AdminSettingsPlugins.prototype.onPluginLoadRequest = function (sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
require('kn').showScreenPopup(PopupsPluginViewModel, [oData.Result]);
|
||||
}
|
||||
};
|
||||
|
||||
AdminSettingsPlugins.prototype.onPluginDisableRequest = function (sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (!oData.Result && oData.ErrorCode)
|
||||
{
|
||||
if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage)
|
||||
{
|
||||
this.pluginsError(oData.ErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pluginsError(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require('../../Apps/AdminApp.js').reloadPluginList();
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsPlugins;
|
||||
|
||||
}(module, require));
|
||||
137
dev/Settings/Admin/AdminSettingsSecurity.js
Normal file
137
dev/Settings/Admin/AdminSettingsSecurity.js
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
LinkBuilder = require('LinkBuilder'),
|
||||
|
||||
AppSettings = require('../../Storages/AppSettings.js'),
|
||||
Data = require('../../Storages/AdminDataStorage.js'),
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsSecurity()
|
||||
{
|
||||
this.useLocalProxyForExternalImages = Data.useLocalProxyForExternalImages;
|
||||
|
||||
this.capaOpenPGP = ko.observable(AppSettings.capa(Enums.Capa.OpenPGP));
|
||||
this.capaTwoFactorAuth = ko.observable(AppSettings.capa(Enums.Capa.TwoFactor));
|
||||
|
||||
this.adminLogin = ko.observable(AppSettings.settingsGet('AdminLogin'));
|
||||
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.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 (this.adminPasswordNew() !== this.adminPasswordNew2())
|
||||
{
|
||||
this.adminPasswordNewError(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.adminPasswordUpdateError(false);
|
||||
this.adminPasswordUpdateSuccess(false);
|
||||
|
||||
Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, {
|
||||
'Password': this.adminPassword(),
|
||||
'NewPassword': this.adminPasswordNew()
|
||||
});
|
||||
|
||||
}, function () {
|
||||
return '' !== this.adminPassword() && '' !== this.adminPasswordNew() && '' !== this.adminPasswordNew2();
|
||||
});
|
||||
|
||||
this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this);
|
||||
}
|
||||
|
||||
AdminSettingsSecurity.prototype.onNewAdminPasswordResponse = function (sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
this.adminPassword('');
|
||||
this.adminPasswordNew('');
|
||||
this.adminPasswordNew2('');
|
||||
|
||||
this.adminPasswordUpdateSuccess(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.adminPasswordUpdateError(true);
|
||||
}
|
||||
};
|
||||
|
||||
AdminSettingsSecurity.prototype.onBuild = function ()
|
||||
{
|
||||
var
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
this.capaOpenPGP.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(Utils.emptyFunction, {
|
||||
'CapaOpenPGP': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.capaTwoFactorAuth.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(Utils.emptyFunction, {
|
||||
'CapaTwoFactorAuth': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.useLocalProxyForExternalImages.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'UseLocalProxyForExternalImages': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
AdminSettingsSecurity.prototype.onHide = function ()
|
||||
{
|
||||
this.adminPassword('');
|
||||
this.adminPasswordNew('');
|
||||
this.adminPasswordNew2('');
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
AdminSettingsSecurity.prototype.phpInfoLink = function ()
|
||||
{
|
||||
return LinkBuilder.phpInfo();
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsSecurity;
|
||||
|
||||
}(module, require));
|
||||
154
dev/Settings/Admin/AdminSettingsSocial.js
Normal file
154
dev/Settings/Admin/AdminSettingsSocial.js
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
(function (module, require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function AdminSettingsSocial()
|
||||
{
|
||||
var Data = require('../../Storages/AdminDataStorage.js');
|
||||
|
||||
this.googleEnable = Data.googleEnable;
|
||||
this.googleClientID = Data.googleClientID;
|
||||
this.googleApiKey = Data.googleApiKey;
|
||||
this.googleClientSecret = Data.googleClientSecret;
|
||||
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.facebookSupported = Data.facebookSupported;
|
||||
this.facebookEnable = Data.facebookEnable;
|
||||
this.facebookAppID = Data.facebookAppID;
|
||||
this.facebookAppSecret = Data.facebookAppSecret;
|
||||
this.facebookTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.facebookTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.twitterEnable = Data.twitterEnable;
|
||||
this.twitterConsumerKey = Data.twitterConsumerKey;
|
||||
this.twitterConsumerSecret = Data.twitterConsumerSecret;
|
||||
this.twitterTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
this.twitterTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.dropboxEnable = Data.dropboxEnable;
|
||||
this.dropboxApiKey = Data.dropboxApiKey;
|
||||
this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
}
|
||||
|
||||
AdminSettingsSocial.prototype.onBuild = function ()
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
Remote = require('../../Storages/AdminAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
_.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.emptyFunction, {
|
||||
'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.emptyFunction, {
|
||||
'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.emptyFunction, {
|
||||
'GoogleEnable': 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.emptyFunction, {
|
||||
'DropboxEnable': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.dropboxApiKey.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f8, {
|
||||
'DropboxApiKey': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
}, 50);
|
||||
};
|
||||
|
||||
module.exports = AdminSettingsSocial;
|
||||
|
||||
}(module, require));
|
||||
|
|
@ -13,11 +13,11 @@
|
|||
Utils = require('Utils'),
|
||||
LinkBuilder = require('LinkBuilder'),
|
||||
|
||||
Data = require('../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
|
||||
kn = require('kn'),
|
||||
PopupsAddAccountViewModel = require('../ViewModels/Popups/PopupsAddAccountViewModel.js')
|
||||
PopupsAddAccountViewModel = require('../../ViewModels/Popups/PopupsAddAccountViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
this.accountForDeletion(null);
|
||||
|
||||
var
|
||||
RL = require('../Boots/RainLoopApp.js'),
|
||||
App = require('../../Apps/RainLoopApp.js'),
|
||||
fRemoveAccount = function (oAccount) {
|
||||
return oAccountToRemove === oAccount;
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
RL.accountsAndIdentities();
|
||||
App.accountsAndIdentities();
|
||||
}
|
||||
|
||||
}, oAccountToRemove.email);
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
|
||||
Remote = require('../Storages/WebMailAjaxRemoteStorage.js')
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
Utils = require('Utils'),
|
||||
|
||||
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
Data = require('../Storages/WebMailDataStorage.js')
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
Data = require('../../Storages/WebMailDataStorage.js')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -31,8 +31,8 @@
|
|||
{
|
||||
var
|
||||
kn = require('kn'),
|
||||
FilterModel = require('../Models/FilterModel.js'),
|
||||
PopupsFilterViewModel = require('../ViewModels/Popups/PopupsFilterViewModel.js')
|
||||
FilterModel = require('../../Models/FilterModel.js'),
|
||||
PopupsFilterViewModel = require('../../ViewModels/Popups/PopupsFilterViewModel.js')
|
||||
;
|
||||
|
||||
kn.showScreenPopup(PopupsFilterViewModel, [new FilterModel()]);
|
||||
|
|
@ -12,14 +12,14 @@
|
|||
|
||||
kn = require('kn'),
|
||||
|
||||
AppSettings = require('../Storages/AppSettings.js'),
|
||||
LocalStorage = require('../Storages/LocalStorage.js'),
|
||||
Data = require('../Storages/WebMailDataStorage.js'),
|
||||
Cache = require('../Storages/WebMailCacheStorage.js'),
|
||||
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
AppSettings = require('../../Storages/AppSettings.js'),
|
||||
LocalStorage = require('../../Storages/LocalStorage.js'),
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
Cache = require('../../Storages/WebMailCacheStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
|
||||
PopupsFolderCreateViewModel = require('../ViewModels/Popups/PopupsFolderCreateViewModel.js'),
|
||||
PopupsFolderSystemViewModel = require('../ViewModels/Popups/PopupsFolderSystemViewModel.js')
|
||||
PopupsFolderCreateViewModel = require('../../ViewModels/Popups/PopupsFolderCreateViewModel.js'),
|
||||
PopupsFolderSystemViewModel = require('../../ViewModels/Popups/PopupsFolderSystemViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
SettingsFolders.prototype.folderEditOnEnter = function (oFolder)
|
||||
{
|
||||
var
|
||||
RL = require('../Boots/RainLoopApp.js'),
|
||||
App = require('../../Apps/RainLoopApp.js'),
|
||||
sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : ''
|
||||
;
|
||||
|
||||
|
|
@ -116,7 +116,7 @@
|
|||
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER'));
|
||||
}
|
||||
|
||||
RL.folders();
|
||||
App.folders();
|
||||
|
||||
}, oFolder.fullNameRaw, sEditName);
|
||||
|
||||
|
|
@ -159,7 +159,7 @@
|
|||
this.folderForDeletion(null);
|
||||
|
||||
var
|
||||
RL = require('../Boots/RainLoopApp.js'),
|
||||
App = require('../../Apps/RainLoopApp.js'),
|
||||
fRemoveFolder = function (oFolder) {
|
||||
|
||||
if (oFolderToRemove === oFolder)
|
||||
|
|
@ -188,7 +188,7 @@
|
|||
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER'));
|
||||
}
|
||||
|
||||
RL.folders();
|
||||
App.folders();
|
||||
|
||||
}, oFolderToRemove.fullNameRaw);
|
||||
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
var
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
_ = require('_'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Consts = require('Consts'),
|
||||
|
|
@ -14,11 +15,11 @@
|
|||
Utils = require('Utils'),
|
||||
LinkBuilder = require('LinkBuilder'),
|
||||
|
||||
Data = require('../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
|
||||
kn = require('kn'),
|
||||
PopupsLanguagesViewModel = require('../ViewModels/Popups/PopupsLanguagesViewModel.js')
|
||||
PopupsLanguagesViewModel = require('../../ViewModels/Popups/PopupsLanguagesViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -6,16 +6,17 @@
|
|||
|
||||
var
|
||||
ko = require('ko'),
|
||||
_ = require('_'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
NewHtmlEditorWrapper = require('NewHtmlEditorWrapper'),
|
||||
|
||||
Data = require('../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
|
||||
kn = require('kn'),
|
||||
PopupsIdentityViewModel = require('../ViewModels/Popups/PopupsIdentityViewModel.js')
|
||||
PopupsIdentityViewModel = require('../../ViewModels/Popups/PopupsIdentityViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -133,7 +134,7 @@
|
|||
this.identityForDeletion(null);
|
||||
|
||||
var
|
||||
RL = require('../Boots/RainLoopApp.js'),
|
||||
App = require('../../Apps/RainLoopApp.js'),
|
||||
fRemoveFolder = function (oIdentity) {
|
||||
return oIdentityToRemove === oIdentity;
|
||||
}
|
||||
|
|
@ -144,7 +145,7 @@
|
|||
this.identities.remove(fRemoveFolder);
|
||||
|
||||
Remote.identityDelete(function () {
|
||||
RL.accountsAndIdentities();
|
||||
App.accountsAndIdentities();
|
||||
}, oIdentityToRemove.id);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,13 +6,14 @@
|
|||
|
||||
var
|
||||
ko = require('ko'),
|
||||
_ = require('_'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
NewHtmlEditorWrapper = require('NewHtmlEditorWrapper'),
|
||||
|
||||
Data = require('../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../Storages/WebMailAjaxRemoteStorage.js')
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -9,11 +9,11 @@
|
|||
|
||||
kn = require('kn'),
|
||||
|
||||
Data = require('../Storages/WebMailDataStorage.js'),
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
|
||||
PopupsAddOpenPgpKeyViewModel = require('../ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js'),
|
||||
PopupsGenerateNewOpenPgpKeyViewModel = require('../ViewModels/Popups/PopupsGenerateNewOpenPgpKeyViewModel.js'),
|
||||
PopupsViewOpenPgpKeyViewModel = require('../ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js')
|
||||
PopupsAddOpenPgpKeyViewModel = require('../../ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js'),
|
||||
PopupsGenerateNewOpenPgpKeyViewModel = require('../../ViewModels/Popups/PopupsGenerateNewOpenPgpKeyViewModel.js'),
|
||||
PopupsViewOpenPgpKeyViewModel = require('../../ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -78,8 +78,8 @@
|
|||
|
||||
Data.openpgpKeyring.store();
|
||||
|
||||
var RL = require('../Boots/RainLoopApp.js');
|
||||
RL.reloadOpenPgpKeys();
|
||||
var App = require('../../Apps/RainLoopApp.js');
|
||||
App.reloadOpenPgpKeys();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -11,10 +11,10 @@
|
|||
Globals = require('Globals'),
|
||||
Utils = require('Utils'),
|
||||
|
||||
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
|
||||
|
||||
kn = require('kn'),
|
||||
PopupsTwoFactorTestViewModel = require('../ViewModels/Popups/PopupsTwoFactorTestViewModel.js')
|
||||
PopupsTwoFactorTestViewModel = require('../../ViewModels/Popups/PopupsTwoFactorTestViewModel.js')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
{
|
||||
var
|
||||
Utils = require('Utils'),
|
||||
RL = require('../Boots/RainLoopApp.js'),
|
||||
Data = require('../Storages/WebMailDataStorage.js')
|
||||
App = require('../../Apps/RainLoopApp.js'),
|
||||
Data = require('../../Storages/WebMailDataStorage.js')
|
||||
;
|
||||
|
||||
this.googleEnable = Data.googleEnable;
|
||||
|
|
@ -36,40 +36,40 @@
|
|||
this.connectGoogle = Utils.createCommand(this, function () {
|
||||
if (!this.googleLoggined())
|
||||
{
|
||||
RL.googleConnect();
|
||||
App.googleConnect();
|
||||
}
|
||||
}, function () {
|
||||
return !this.googleLoggined() && !this.googleActions();
|
||||
});
|
||||
|
||||
this.disconnectGoogle = Utils.createCommand(this, function () {
|
||||
RL.googleDisconnect();
|
||||
App.googleDisconnect();
|
||||
});
|
||||
|
||||
this.connectFacebook = Utils.createCommand(this, function () {
|
||||
if (!this.facebookLoggined())
|
||||
{
|
||||
RL.facebookConnect();
|
||||
App.facebookConnect();
|
||||
}
|
||||
}, function () {
|
||||
return !this.facebookLoggined() && !this.facebookActions();
|
||||
});
|
||||
|
||||
this.disconnectFacebook = Utils.createCommand(this, function () {
|
||||
RL.facebookDisconnect();
|
||||
App.facebookDisconnect();
|
||||
});
|
||||
|
||||
this.connectTwitter = Utils.createCommand(this, function () {
|
||||
if (!this.twitterLoggined())
|
||||
{
|
||||
RL.twitterConnect();
|
||||
App.twitterConnect();
|
||||
}
|
||||
}, function () {
|
||||
return !this.twitterLoggined() && !this.twitterActions();
|
||||
});
|
||||
|
||||
this.disconnectTwitter = Utils.createCommand(this, function () {
|
||||
RL.twitterDisconnect();
|
||||
App.twitterDisconnect();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -8,13 +8,14 @@
|
|||
window = require('window'),
|
||||
$ = require('$'),
|
||||
ko = require('ko'),
|
||||
_ = require('_'),
|
||||
|
||||
Enums = require('Enums'),
|
||||
Utils = require('Utils'),
|
||||
LinkBuilder = require('LinkBuilder'),
|
||||
|
||||
Data = require('../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../Storages/WebMailAjaxRemoteStorage.js')
|
||||
Data = require('../../Storages/WebMailDataStorage.js'),
|
||||
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js')
|
||||
;
|
||||
|
||||
/**
|
||||
Loading…
Add table
Add a link
Reference in a new issue