mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-18 11:04:17 +08:00
Enable AbstractViewSettings
This commit is contained in:
parent
92cec80b73
commit
97bc3ef585
20 changed files with 149 additions and 212 deletions
|
@ -48,12 +48,6 @@ export const
|
|||
*/
|
||||
b64EncodeJSONSafe = data => b64EncodeJSON(data).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''),
|
||||
|
||||
settingsSaveHelperSimpleFunction = (koTrigger, context) =>
|
||||
iError => {
|
||||
koTrigger.call(context, iError ? SaveSettingsStep.FalseResult : SaveSettingsStep.TrueResult);
|
||||
setTimeout(() => koTrigger.call(context, SaveSettingsStep.Idle), 1000);
|
||||
},
|
||||
|
||||
changeTheme = (value, themeTrigger = ()=>0) => {
|
||||
const themeStyle = elementById('app-theme-style'),
|
||||
clearTimer = () => {
|
||||
|
|
2
dev/External/ko.js
vendored
2
dev/External/ko.js
vendored
|
@ -18,7 +18,7 @@ export const
|
|||
|
||||
addObservablesTo = (target, observables) =>
|
||||
forEachObjectEntry(observables, (key, value) =>
|
||||
target[key] = /*isArray(value) ? ko.observableArray(value) :*/ ko.observable(value) ),
|
||||
target[key] || (target[key] = /*isArray(value) ? ko.observableArray(value) :*/ ko.observable(value)) ),
|
||||
|
||||
addComputablesTo = (target, computables) =>
|
||||
forEachObjectEntry(computables, (key, fn) => target[key] = koComputable(fn)),
|
||||
|
|
|
@ -6,6 +6,9 @@ import { Scope } from 'Common/Enums';
|
|||
import { keyScope, Settings, leftPanelDisabled } from 'Common/Globals';
|
||||
import { ViewType, showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
|
||||
class AbstractView {
|
||||
constructor(templateID, type)
|
||||
{
|
||||
|
@ -117,16 +120,37 @@ export class AbstractViewRight extends AbstractView
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
export class AbstractViewSettings
|
||||
{
|
||||
/*
|
||||
onBuild(viewModelDom) {}
|
||||
onBeforeShow() {}
|
||||
onShow() {}
|
||||
onHide() {}
|
||||
viewModelDom
|
||||
}
|
||||
*/
|
||||
addSetting(name, valueCb)
|
||||
{
|
||||
let prop = name = name[0].toLowerCase() + name.slice(1),
|
||||
trigger = prop + 'Trigger';
|
||||
addObservablesTo(this, {
|
||||
[prop]: SettingsGet(name),
|
||||
[trigger]: SaveSettingsStep.Idle,
|
||||
});
|
||||
addSubscribablesTo(this, {
|
||||
[prop]: (value => {
|
||||
this[trigger](SaveSettingsStep.Animate);
|
||||
valueCb && valueCb(value);
|
||||
rl.app.Remote.saveSetting(name, value,
|
||||
iError => {
|
||||
this[trigger](iError ? SaveSettingsStep.FalseResult : SaveSettingsStep.TrueResult);
|
||||
setTimeout(() => this[trigger](SaveSettingsStep.Idle), 1000);
|
||||
}
|
||||
);
|
||||
}).debounce(999),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class AbstractViewLogin extends AbstractViewCenter {
|
||||
constructor(templateID) {
|
||||
|
|
|
@ -10,6 +10,15 @@ class RemoteAdminFetch extends AbstractFetchRemote {
|
|||
this.request('AdminSettingsUpdate', fCallback, oData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @param {?scalar} value
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
saveSetting(key, value, fCallback) {
|
||||
this.saveConfig({[key]: value}, fCallback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new RemoteAdminFetch();
|
||||
|
|
|
@ -1,40 +1,10 @@
|
|||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { settingsSaveHelperSimpleFunction } from 'Common/Utils';
|
||||
import { addObservablesTo, addSubscribablesTo } from 'External/ko';
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
export class BrandingAdminSettings /*extends AbstractViewSettings*/ {
|
||||
export class BrandingAdminSettings extends AbstractViewSettings {
|
||||
constructor() {
|
||||
addObservablesTo(this, {
|
||||
title: SettingsGet('Title'),
|
||||
loadingDesc: SettingsGet('LoadingDescription'),
|
||||
faviconUrl: SettingsGet('FaviconUrl'),
|
||||
|
||||
titleTrigger: SaveSettingsStep.Idle,
|
||||
loadingDescTrigger: SaveSettingsStep.Idle,
|
||||
faviconUrlTrigger: SaveSettingsStep.Idle
|
||||
});
|
||||
|
||||
addSubscribablesTo(this, {
|
||||
title: (value =>
|
||||
Remote.saveConfig({
|
||||
Title: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.titleTrigger, this))
|
||||
).debounce(999),
|
||||
|
||||
loadingDesc: (value =>
|
||||
Remote.saveConfig({
|
||||
LoadingDescription: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.loadingDescTrigger, this))
|
||||
).debounce(999),
|
||||
|
||||
faviconUrl: (value =>
|
||||
Remote.saveConfig({
|
||||
FaviconUrl: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.faviconUrlTrigger, this))
|
||||
).debounce(999)
|
||||
});
|
||||
super();
|
||||
this.addSetting('Title');
|
||||
this.addSetting('LoadingDescription');
|
||||
this.addSetting('FaviconUrl');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,30 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import {
|
||||
settingsSaveHelperSimpleFunction,
|
||||
defaultOptionsAfterRender
|
||||
} from 'Common/Utils';
|
||||
import { defaultOptionsAfterRender } from 'Common/Utils';
|
||||
import { addObservablesTo, addSubscribablesTo } from 'External/ko';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
export class ContactsAdminSettings /*extends AbstractViewSettings*/ {
|
||||
export class ContactsAdminSettings extends AbstractViewSettings {
|
||||
constructor() {
|
||||
super();
|
||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||
|
||||
this.addSetting('ContactsPdoDsn');
|
||||
this.addSetting('ContactsPdoUser');
|
||||
this.addSetting('ContactsPdoPassword');
|
||||
this.addSetting('ContactsPdoType', () => {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
});
|
||||
|
||||
addObservablesTo(this, {
|
||||
enableContacts: !!SettingsGet('ContactsEnable'),
|
||||
contactsSync: !!SettingsGet('ContactsSync'),
|
||||
contactsType: SettingsGet('ContactsPdoType'),
|
||||
|
||||
pdoDsn: SettingsGet('ContactsPdoDsn'),
|
||||
pdoUser: SettingsGet('ContactsPdoUser'),
|
||||
pdoPassword: SettingsGet('ContactsPdoPassword'),
|
||||
|
||||
pdoDsnTrigger: SaveSettingsStep.Idle,
|
||||
pdoUserTrigger: SaveSettingsStep.Idle,
|
||||
pdoPasswordTrigger: SaveSettingsStep.Idle,
|
||||
contactsTypeTrigger: SaveSettingsStep.Idle,
|
||||
|
||||
testing: false,
|
||||
testContactsSuccess: false,
|
||||
|
@ -53,16 +50,16 @@ export class ContactsAdminSettings /*extends AbstractViewSettings*/ {
|
|||
|
||||
this.mainContactsType = ko
|
||||
.computed({
|
||||
read: this.contactsType,
|
||||
read: this.contactsPdoType,
|
||||
write: value => {
|
||||
if (value !== this.contactsType()) {
|
||||
if (value !== this.contactsPdoType()) {
|
||||
if (supportedTypes.includes(value)) {
|
||||
this.contactsType(value);
|
||||
this.contactsPdoType(value);
|
||||
} else if (types.length) {
|
||||
this.contactsType('');
|
||||
this.contactsPdoType('');
|
||||
}
|
||||
} else {
|
||||
this.contactsType.valueHasMutated();
|
||||
this.contactsPdoType.valueHasMutated();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -77,35 +74,11 @@ export class ContactsAdminSettings /*extends AbstractViewSettings*/ {
|
|||
contactsSync: value =>
|
||||
Remote.saveConfig({
|
||||
ContactsSync: value ? 1 : 0
|
||||
}),
|
||||
|
||||
contactsType: value => {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
Remote.saveConfig({
|
||||
ContactsPdoType: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.contactsTypeTrigger, this))
|
||||
},
|
||||
|
||||
pdoDsn: value =>
|
||||
Remote.saveConfig({
|
||||
ContactsPdoDsn: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.pdoDsnTrigger, this)),
|
||||
|
||||
pdoUser: value =>
|
||||
Remote.saveConfig({
|
||||
ContactsPdoUser: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.pdoUserTrigger, this)),
|
||||
|
||||
pdoPassword: value =>
|
||||
Remote.saveConfig({
|
||||
ContactsPdoPassword: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.pdoPasswordTrigger, this))
|
||||
})
|
||||
})
|
||||
|
||||
decorateKoCommands(this, {
|
||||
testContactsCommand: self => self.pdoDsn() && self.pdoUser()
|
||||
testContactsCommand: self => self.contactsPdoDsn() && self.contactsPdoUser()
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -134,10 +107,10 @@ export class ContactsAdminSettings /*extends AbstractViewSettings*/ {
|
|||
|
||||
this.testing(false);
|
||||
}, {
|
||||
ContactsPdoType: this.contactsType(),
|
||||
ContactsPdoDsn: this.pdoDsn(),
|
||||
ContactsPdoUser: this.pdoUser(),
|
||||
ContactsPdoPassword: this.pdoPassword()
|
||||
ContactsPdoType: this.contactsPdoType(),
|
||||
ContactsPdoDsn: this.contactsPdoDsn(),
|
||||
ContactsPdoUser: this.contactsPdo(),
|
||||
ContactsPdoPassword: this.contactsPdoPassword()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ import ko from 'ko';
|
|||
|
||||
import {
|
||||
isArray,
|
||||
pInt,
|
||||
settingsSaveHelperSimpleFunction,
|
||||
changeTheme,
|
||||
convertThemeName
|
||||
} from 'Common/Utils';
|
||||
|
@ -14,6 +12,7 @@ import { Capa, SaveSettingsStep } from 'Common/Enums';
|
|||
import { Settings, SettingsGet, SettingsCapa } from 'Common/Globals';
|
||||
import { translatorReload, convertLangName } from 'Common/Translator';
|
||||
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
@ -22,8 +21,10 @@ import { ThemeStore } from 'Stores/Theme';
|
|||
import { LanguageStore } from 'Stores/Language';
|
||||
import { LanguagesPopupView } from 'View/Popup/Languages';
|
||||
|
||||
export class GeneralAdminSettings /*extends AbstractViewSettings*/ {
|
||||
export class GeneralAdminSettings extends AbstractViewSettings {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.language = LanguageStore.language;
|
||||
this.languages = LanguageStore.languages;
|
||||
|
||||
|
@ -37,10 +38,9 @@ export class GeneralAdminSettings /*extends AbstractViewSettings*/ {
|
|||
this.themes = ThemeStore.themes;
|
||||
|
||||
addObservablesTo(this, {
|
||||
allowLanguagesOnSettings: !!SettingsGet('AllowLanguagesOnSettings'),
|
||||
newMoveToFolder: !!SettingsGet('NewMoveToFolder'),
|
||||
allowLanguagesOnSettings: SettingsGet('AllowLanguagesOnSettings'),
|
||||
newMoveToFolder: SettingsGet('NewMoveToFolder'),
|
||||
attachmentLimitTrigger: SaveSettingsStep.Idle,
|
||||
languageTrigger: SaveSettingsStep.Idle,
|
||||
themeTrigger: SaveSettingsStep.Idle,
|
||||
capaThemes: SettingsCapa(Capa.Themes),
|
||||
capaUserBackground: SettingsCapa(Capa.UserBackground),
|
||||
|
@ -58,10 +58,14 @@ export class GeneralAdminSettings /*extends AbstractViewSettings*/ {
|
|||
}
|
||||
*/
|
||||
|
||||
this.mainAttachmentLimit = ko
|
||||
.observable(pInt(SettingsGet('AttachmentLimit')) / (1024 * 1024))
|
||||
this.attachmentLimit = ko
|
||||
.observable(SettingsGet('AttachmentLimit') / (1024 * 1024))
|
||||
.extend({ debounce: 500 });
|
||||
|
||||
this.addSetting('Language');
|
||||
this.addSetting('AttachmentLimit');
|
||||
this.addSetting('Theme', value => changeTheme(value, this.themeTrigger));
|
||||
|
||||
this.uploadData = SettingsGet('PhpUploadSizes');
|
||||
this.uploadDataDesc =
|
||||
this.uploadData && (this.uploadData.upload_max_filesize || this.uploadData.post_max_size)
|
||||
|
@ -86,20 +90,9 @@ export class GeneralAdminSettings /*extends AbstractViewSettings*/ {
|
|||
this.languageAdminTrigger(saveSettingsStep);
|
||||
setTimeout(() => this.languageAdminTrigger(SaveSettingsStep.Idle), 1000);
|
||||
},
|
||||
fSaveBoolHelper = key =>
|
||||
value => Remote.saveConfig({[key]: value ? 1 : 0});
|
||||
fSaveHelper = key => value => Remote.saveSetting(key, value);
|
||||
|
||||
addSubscribablesTo(this, {
|
||||
mainAttachmentLimit: value =>
|
||||
Remote.saveConfig({
|
||||
AttachmentLimit: pInt(value)
|
||||
}, settingsSaveHelperSimpleFunction(this.attachmentLimitTrigger, this)),
|
||||
|
||||
language: value =>
|
||||
Remote.saveConfig({
|
||||
Language: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.languageTrigger, this)),
|
||||
|
||||
languageAdmin: value => {
|
||||
this.languageAdminTrigger(SaveSettingsStep.Animate);
|
||||
translatorReload(true, value)
|
||||
|
@ -109,26 +102,19 @@ export class GeneralAdminSettings /*extends AbstractViewSettings*/ {
|
|||
}));
|
||||
},
|
||||
|
||||
theme: value => {
|
||||
changeTheme(value, this.themeTrigger);
|
||||
Remote.saveConfig({
|
||||
Theme: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.themeTrigger, this));
|
||||
},
|
||||
capaAdditionalAccounts: fSaveHelper('CapaAdditionalAccounts'),
|
||||
|
||||
capaAdditionalAccounts: fSaveBoolHelper('CapaAdditionalAccounts'),
|
||||
capaIdentities: fSaveHelper('CapaIdentities'),
|
||||
|
||||
capaIdentities: fSaveBoolHelper('CapaIdentities'),
|
||||
capaAttachmentThumbnails: fSaveHelper('CapaAttachmentThumbnails'),
|
||||
|
||||
capaAttachmentThumbnails: fSaveBoolHelper('CapaAttachmentThumbnails'),
|
||||
capaThemes: fSaveHelper('CapaThemes'),
|
||||
|
||||
capaThemes: fSaveBoolHelper('CapaThemes'),
|
||||
capaUserBackground: fSaveHelper('CapaUserBackground'),
|
||||
|
||||
capaUserBackground: fSaveBoolHelper('CapaUserBackground'),
|
||||
allowLanguagesOnSettings: fSaveHelper('AllowLanguagesOnSettings'),
|
||||
|
||||
allowLanguagesOnSettings: fSaveBoolHelper('AllowLanguagesOnSettings'),
|
||||
|
||||
newMoveToFolder: fSaveBoolHelper('NewMoveToFolder')
|
||||
newMoveToFolder: fSaveHelper('NewMoveToFolder')
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
import { Settings, SettingsGet } from 'Common/Globals';
|
||||
import { settingsSaveHelperSimpleFunction } from 'Common/Utils';
|
||||
import { addObservablesTo, addSubscribablesTo } from 'External/ko';
|
||||
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
export class LoginAdminSettings /*extends AbstractViewSettings*/ {
|
||||
export class LoginAdminSettings extends AbstractViewSettings {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.addSetting('LoginDefaultDomain');
|
||||
|
||||
addObservablesTo(this, {
|
||||
determineUserLanguage: !!SettingsGet('DetermineUserLanguage'),
|
||||
determineUserDomain: !!SettingsGet('DetermineUserDomain'),
|
||||
allowLanguagesOnLogin: !!SettingsGet('AllowLanguagesOnLogin'),
|
||||
hideSubmitButton: !!Settings.app('hideSubmitButton'),
|
||||
defaultDomain: SettingsGet('LoginDefaultDomain'),
|
||||
defaultDomainTrigger: SaveSettingsStep.Idle
|
||||
});
|
||||
|
||||
addSubscribablesTo(this, {
|
||||
|
@ -35,13 +35,7 @@ export class LoginAdminSettings /*extends AbstractViewSettings*/ {
|
|||
hideSubmitButton: value =>
|
||||
Remote.saveConfig({
|
||||
hideSubmitButton: value ? 1 : 0
|
||||
}),
|
||||
|
||||
defaultDomain: (value =>
|
||||
Remote.saveConfig({
|
||||
LoginDefaultDomain: value.trim()
|
||||
}, settingsSaveHelperSimpleFunction(this.defaultDomainTrigger, this))
|
||||
).debounce(999)
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ export class FoldersUserSettings /*extends AbstractViewSettings*/ {
|
|||
|
||||
this.folderForEdit = ko.observable(null).extend({ toggleSubscribeProperty: [this, 'edited'] });
|
||||
|
||||
SettingsUserStore.hideUnsubscribed.subscribe(value => Remote.saveSetting('HideUnsubscribed', value ? 1 : 0));
|
||||
SettingsUserStore.hideUnsubscribed.subscribe(value => Remote.saveSetting('HideUnsubscribed', value));
|
||||
}
|
||||
|
||||
folderEditOnEnter(folder) {
|
||||
|
|
|
@ -3,10 +3,11 @@ import ko from 'ko';
|
|||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
import { EditorDefaultType, Layout } from 'Common/EnumsUser';
|
||||
import { Settings, SettingsGet } from 'Common/Globals';
|
||||
import { isArray, settingsSaveHelperSimpleFunction } from 'Common/Utils';
|
||||
import { addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko';
|
||||
import { isArray } from 'Common/Utils';
|
||||
import { addSubscribablesTo, addComputablesTo } from 'External/ko';
|
||||
import { i18n, trigger as translatorTrigger, translatorReload, convertLangName } from 'Common/Translator';
|
||||
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import { AppUserStore } from 'Stores/User/App';
|
||||
|
@ -22,8 +23,10 @@ import Remote from 'Remote/User/Fetch';
|
|||
import { IdentityPopupView } from 'View/Popup/Identity';
|
||||
import { LanguagesPopupView } from 'View/Popup/Languages';
|
||||
|
||||
export class GeneralUserSettings /*extends AbstractViewSettings*/ {
|
||||
export class GeneralUserSettings extends AbstractViewSettings {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.language = LanguageStore.language;
|
||||
this.languages = LanguageStore.languages;
|
||||
this.messageReadDelay = SettingsUserStore.messageReadDelay;
|
||||
|
@ -48,14 +51,7 @@ export class GeneralUserSettings /*extends AbstractViewSettings*/ {
|
|||
this.replySameFolder = SettingsUserStore.replySameFolder;
|
||||
this.allowLanguagesOnSettings = !!SettingsGet('AllowLanguagesOnSettings');
|
||||
|
||||
this.languageTrigger = ko.observable(SaveSettingsStep.Idle).extend({ debounce: 100 });
|
||||
|
||||
addObservablesTo(this, {
|
||||
mppTrigger: SaveSettingsStep.Idle,
|
||||
messageReadDelayTrigger: SaveSettingsStep.Idle,
|
||||
editorDefaultTypeTrigger: SaveSettingsStep.Idle,
|
||||
layoutTrigger: SaveSettingsStep.Idle
|
||||
});
|
||||
this.languageTrigger = ko.observable(SaveSettingsStep.Idle);
|
||||
|
||||
this.identities = IdentityUserStore;
|
||||
|
||||
|
@ -92,59 +88,51 @@ export class GeneralUserSettings /*extends AbstractViewSettings*/ {
|
|||
}
|
||||
});
|
||||
|
||||
this.addSetting('EditorDefaultType');
|
||||
this.addSetting('MessageReadDelay');
|
||||
this.addSetting('MessagesPerPage');
|
||||
this.addSetting('Layout', () => MessagelistUserStore([]));
|
||||
|
||||
const fReloadLanguageHelper = (saveSettingsStep) => () => {
|
||||
this.languageTrigger(saveSettingsStep);
|
||||
setTimeout(() => this.languageTrigger(SaveSettingsStep.Idle), 1000);
|
||||
};
|
||||
},
|
||||
fSaveHelper = key => value => Remote.saveSetting(key, value);
|
||||
|
||||
addSubscribablesTo(this, {
|
||||
language: value => {
|
||||
this.languageTrigger(SaveSettingsStep.Animate);
|
||||
translatorReload(false, value)
|
||||
.then(fReloadLanguageHelper(SaveSettingsStep.TrueResult),
|
||||
fReloadLanguageHelper(SaveSettingsStep.FalseResult))
|
||||
.then(fReloadLanguageHelper(SaveSettingsStep.TrueResult), fReloadLanguageHelper(SaveSettingsStep.FalseResult))
|
||||
.then(() => Remote.saveSetting('Language', value));
|
||||
},
|
||||
|
||||
editorDefaultType: value => Remote.saveSetting('EditorDefaultType', value,
|
||||
settingsSaveHelperSimpleFunction(this.editorDefaultTypeTrigger, this)),
|
||||
|
||||
messageReadDelay: value => Remote.saveSetting('MessageReadDelay', value,
|
||||
settingsSaveHelperSimpleFunction(this.messageReadDelayTrigger, this)),
|
||||
|
||||
messagesPerPage: value => Remote.saveSetting('MPP', value,
|
||||
settingsSaveHelperSimpleFunction(this.mppTrigger, this)),
|
||||
|
||||
viewHTML: value => Remote.saveSetting('ViewHTML', value ? 1 : 0),
|
||||
showImages: value => Remote.saveSetting('ShowImages', value ? 1 : 0),
|
||||
viewHTML: fSaveHelper('ViewHTML'),
|
||||
showImages: fSaveHelper('ShowImages'),
|
||||
|
||||
removeColors: value => {
|
||||
let dom = MessageUserStore.bodiesDom();
|
||||
if (dom) {
|
||||
dom.innerHTML = '';
|
||||
}
|
||||
Remote.saveSetting('RemoveColors', value ? 1 : 0);
|
||||
Remote.saveSetting('RemoveColors', value);
|
||||
},
|
||||
|
||||
useCheckboxesInList: value => Remote.saveSetting('UseCheckboxesInList', value ? 1 : 0),
|
||||
useCheckboxesInList: fSaveHelper('UseCheckboxesInList'),
|
||||
|
||||
enableDesktopNotification: value => Remote.saveSetting('DesktopNotifications', value ? 1 : 0),
|
||||
enableDesktopNotification: fSaveHelper('DesktopNotifications'),
|
||||
|
||||
enableSoundNotification: value => Remote.saveSetting('SoundNotification', value ? 1 : 0),
|
||||
enableSoundNotification: fSaveHelper('SoundNotification'),
|
||||
notificationSound: value => {
|
||||
Remote.saveSetting('NotificationSound', value);
|
||||
Settings.set('NotificationSound', value);
|
||||
},
|
||||
|
||||
replySameFolder: value => Remote.saveSetting('ReplySameFolder', value ? 1 : 0),
|
||||
replySameFolder: fSaveHelper('ReplySameFolder'),
|
||||
|
||||
useThreads: value => {
|
||||
MessagelistUserStore([]);
|
||||
Remote.saveSetting('UseThreads', value ? 1 : 0);
|
||||
},
|
||||
|
||||
layout: value => {
|
||||
MessagelistUserStore([]);
|
||||
Remote.saveSetting('Layout', value, settingsSaveHelperSimpleFunction(this.layoutTrigger, this));
|
||||
Remote.saveSetting('UseThreads', value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ export class OpenPgpUserSettings /*extends AbstractViewSettings*/ {
|
|||
|
||||
this.allowDraftAutosave = SettingsUserStore.allowDraftAutosave;
|
||||
|
||||
this.allowDraftAutosave.subscribe(value => Remote.saveSetting('AllowDraftAutosave', value ? 1 : 0))
|
||||
this.allowDraftAutosave.subscribe(value => Remote.saveSetting('AllowDraftAutosave', value))
|
||||
}
|
||||
|
||||
addOpenPgpKey() {
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
import ko from 'ko';
|
||||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { pInt, settingsSaveHelperSimpleFunction } from 'Common/Utils';
|
||||
import { Capa, SaveSettingsStep } from 'Common/Enums';
|
||||
import { Capa } from 'Common/Enums';
|
||||
import { SettingsCapa } from 'Common/Globals';
|
||||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
import { SettingsUserStore } from 'Stores/User/Settings';
|
||||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
||||
export class SecurityUserSettings /*extends AbstractViewSettings*/ {
|
||||
export class SecurityUserSettings extends AbstractViewSettings {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.capaAutoLogout = SettingsCapa(Capa.AutoLogout);
|
||||
|
||||
this.autoLogout = SettingsUserStore.autoLogout;
|
||||
this.autoLogoutTrigger = ko.observable(SaveSettingsStep.Idle);
|
||||
|
||||
let i18nLogout = (key, params) => i18n('SETTINGS_SECURITY/AUTOLOGIN_' + key, params);
|
||||
this.autoLogoutOptions = koComputable(() => {
|
||||
|
@ -33,10 +32,7 @@ export class SecurityUserSettings /*extends AbstractViewSettings*/ {
|
|||
});
|
||||
|
||||
if (this.capaAutoLogout) {
|
||||
this.autoLogout.subscribe(value => Remote.saveSetting(
|
||||
'AutoLogout', pInt(value),
|
||||
settingsSaveHelperSimpleFunction(this.autoLogoutTrigger, this)
|
||||
));
|
||||
this.addSetting('AutoLogout');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -856,13 +856,16 @@ class Actions
|
|||
if ($oConfig->Get('webmail', 'allow_languages_on_settings', true)) {
|
||||
$sLanguage = (string) $oSettings->GetConf('Language', $sLanguage);
|
||||
}
|
||||
if (!$oSettings->GetConf('MessagesPerPage')) {
|
||||
$oSettings->SetConf('MessagesPerPage', $oSettings->GetConf('MPP', $aResult['MessagesPerPage']));
|
||||
}
|
||||
|
||||
$aResult['EditorDefaultType'] = (string)$oSettings->GetConf('EditorDefaultType', $aResult['EditorDefaultType']);
|
||||
$aResult['ViewHTML'] = (bool)$oSettings->GetConf('ViewHTML', $aResult['ViewHTML']);
|
||||
$aResult['ShowImages'] = (bool)$oSettings->GetConf('ShowImages', $aResult['ShowImages']);
|
||||
$aResult['RemoveColors'] = (bool)$oSettings->GetConf('RemoveColors', $aResult['RemoveColors']);
|
||||
$aResult['ContactsAutosave'] = (bool)$oSettings->GetConf('ContactsAutosave', $aResult['ContactsAutosave']);
|
||||
$aResult['MessagesPerPage'] = (int)$oSettings->GetConf('MPP', $aResult['MessagesPerPage']);
|
||||
$aResult['MessagesPerPage'] = (int)$oSettings->GetConf('MessagesPerPage', $aResult['MessagesPerPage']);
|
||||
$aResult['MessageReadDelay'] = (int)$oSettings->GetConf('MessageReadDelay', $aResult['MessageReadDelay']);
|
||||
$aResult['SoundNotification'] = (bool)$oSettings->GetConf('SoundNotification', $aResult['SoundNotification']);
|
||||
$aResult['NotificationSound'] = (string)$oSettings->GetConf('NotificationSound', $aResult['NotificationSound']);
|
||||
|
|
|
@ -918,13 +918,13 @@ trait Admin
|
|||
$sValue = $mStringCallback($sValue);
|
||||
}
|
||||
|
||||
$oConfig->Set($sConfigSector, $sConfigName, (string)$sValue);
|
||||
$oConfig->Set($sConfigSector, $sConfigName, $sValue);
|
||||
break;
|
||||
|
||||
case 'dummy':
|
||||
$sValue = (string)$this->GetActionParam('ContactsPdoPassword', APP_DUMMY);
|
||||
$sValue = (string) $this->GetActionParam($sParamName, APP_DUMMY);
|
||||
if (APP_DUMMY !== $sValue) {
|
||||
$oConfig->Set($sConfigSector, $sConfigName, (string)$sValue);
|
||||
$oConfig->Set($sConfigSector, $sConfigName, $sValue);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -934,7 +934,7 @@ trait Admin
|
|||
break;
|
||||
|
||||
case 'bool':
|
||||
$oConfig->Set($sConfigSector, $sConfigName, '1' === (string)$sValue);
|
||||
$oConfig->Set($sConfigSector, $sConfigName, !empty($sValue) && 'false' !== $sValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ trait User
|
|||
$oSettingsLocal->SetConf('Theme', $this->ValidateTheme($oConfig->Get('webmail', 'theme', 'Default')));
|
||||
}
|
||||
|
||||
$this->setSettingsFromParams($oSettings, 'MPP', 'int', function ($iValue) {
|
||||
$this->setSettingsFromParams($oSettings, 'MessagesPerPage', 'int', function ($iValue) {
|
||||
return \min(50, \max(10, $iValue));
|
||||
});
|
||||
|
||||
|
@ -556,7 +556,7 @@ trait User
|
|||
break;
|
||||
|
||||
case 'bool':
|
||||
$oSettings->SetConf($sConfigName, !empty($sValue));
|
||||
$oSettings->SetConf($sConfigName, !empty($sValue) && 'false' !== $sValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
<div data-bind="component: {
|
||||
name: 'Input',
|
||||
params: {
|
||||
value: loadingDesc,
|
||||
trigger: loadingDescTrigger,
|
||||
value: loadingDescription,
|
||||
trigger: loadingDescriptionTrigger,
|
||||
size: 5
|
||||
}
|
||||
}"></div>
|
||||
|
|
|
@ -28,32 +28,32 @@
|
|||
params: {
|
||||
options: contactsTypesOptions,
|
||||
value: mainContactsType,
|
||||
trigger: contactsTypeTrigger,
|
||||
trigger: contactsPdoTypeTrigger,
|
||||
optionsText: 'name',
|
||||
optionsValue: 'id'
|
||||
}
|
||||
}"></div>
|
||||
</div>
|
||||
<div data-bind="visible: 'sqlite' !== contactsType()">
|
||||
<div data-bind="visible: 'sqlite' !== contactsPdoType()">
|
||||
<div class="control-group">
|
||||
<label data-i18n="TAB_CONTACTS/LABEL_STORAGE_DSN"></label>
|
||||
<div>
|
||||
<input type="text" class="span6" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: pdoDsn, saveTrigger: pdoDsnTrigger" placeholder="mysql:host=127.0.0.1;port=3306;dbname=snappymail">
|
||||
data-bind="value: contactsPdoDsn, saveTrigger: contactsPdoDsnTrigger" placeholder="mysql:host=127.0.0.1;port=3306;dbname=snappymail">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label data-i18n="TAB_CONTACTS/LABEL_STORAGE_USER"></label>
|
||||
<div>
|
||||
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: pdoUser, saveTrigger: pdoUserTrigger">
|
||||
data-bind="value: contactsPdoUser, saveTrigger: contactsPdoUserTrigger">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label data-i18n="TAB_CONTACTS/LABEL_STORAGE_PASSWORD"></label>
|
||||
<div>
|
||||
<input type="password" autocomplete="current-password" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: pdoPassword, saveTrigger: pdoPasswordTrigger">
|
||||
data-bind="value: contactsPdoPassword, saveTrigger: contactsPdoPasswordTrigger">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
|
@ -64,7 +64,7 @@
|
|||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div data-bind="visible: 'sqlite' === contactsType()">
|
||||
<div data-bind="visible: 'sqlite' === contactsPdoType()">
|
||||
<div class="control-group">
|
||||
<div class="alert">
|
||||
<h4 data-i18n="TAB_CONTACTS/ALERT_NOTICE"></h4>
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
<div class="control-group">
|
||||
<label data-i18n="TAB_GENERAL/LABEL_ATTACHMENT_SIZE_LIMIT"></label>
|
||||
<div>
|
||||
<input type="number" min="1" step="1" class="span1" data-bind="textInput: mainAttachmentLimit">
|
||||
<input type="number" min="1" step="1" class="span1" data-bind="textInput: attachmentLimit">
|
||||
|
||||
<span data-i18n="MB"></span>
|
||||
<span data-bind="saveTrigger: attachmentLimitTrigger"></span>
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<div data-bind="component: {
|
||||
name: 'Input',
|
||||
params: {
|
||||
value: defaultDomain,
|
||||
trigger: defaultDomainTrigger,
|
||||
value: loginDefaultDomain,
|
||||
trigger: loginDefaultDomainTrigger,
|
||||
size: 3
|
||||
}
|
||||
}"></div>
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<div>
|
||||
<input type="number" min="10" max="50" step="1" class="span1" data-bind="textInput: messagesPerPage">
|
||||
|
||||
<span data-bind="saveTrigger: mppTrigger"></span>
|
||||
<span data-bind="saveTrigger: messagesPerPageTrigger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
|
@ -77,7 +77,7 @@
|
|||
<div>
|
||||
<input type="number" min="0" step="1" class="span1" data-bind="textInput: messageReadDelay">
|
||||
|
||||
<span data-i18n="SETTINGS_GENERAL/SECONDS"></label>
|
||||
<span data-i18n="SETTINGS_GENERAL/SECONDS"></span>
|
||||
<span data-bind="saveTrigger: messageReadDelayTrigger"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue