From 97bc3ef585cfc5e7b98349eb490efbbc18176219 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Mon, 28 Feb 2022 10:38:47 +0100 Subject: [PATCH] Enable AbstractViewSettings --- dev/Common/Utils.js | 6 -- dev/External/ko.js | 2 +- dev/Knoin/AbstractViews.js | 28 ++++++- dev/Remote/Admin/Fetch.js | 9 +++ dev/Settings/Admin/Branding.js | 42 ++--------- dev/Settings/Admin/Contacts.js | 75 ++++++------------- dev/Settings/Admin/General.js | 54 +++++-------- dev/Settings/Admin/Login.js | 20 ++--- dev/Settings/User/Folders.js | 2 +- dev/Settings/User/General.js | 60 ++++++--------- dev/Settings/User/OpenPgp.js | 2 +- dev/Settings/User/Security.js | 18 ++--- .../0.0.0/app/libraries/RainLoop/Actions.php | 5 +- .../app/libraries/RainLoop/Actions/Admin.php | 8 +- .../app/libraries/RainLoop/Actions/User.php | 4 +- .../Views/Admin/AdminSettingsBranding.html | 4 +- .../Views/Admin/AdminSettingsContacts.html | 12 +-- .../Views/Admin/AdminSettingsGeneral.html | 2 +- .../Views/Admin/AdminSettingsLogin.html | 4 +- .../templates/Views/User/SettingsGeneral.html | 4 +- 20 files changed, 149 insertions(+), 212 deletions(-) diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index 585b2edc1..fef3b523d 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -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 = () => { diff --git a/dev/External/ko.js b/dev/External/ko.js index ab87619f4..f7dfe6c9c 100644 --- a/dev/External/ko.js +++ b/dev/External/ko.js @@ -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)), diff --git a/dev/Knoin/AbstractViews.js b/dev/Knoin/AbstractViews.js index 568025aa7..588fd9980 100644 --- a/dev/Knoin/AbstractViews.js +++ b/dev/Knoin/AbstractViews.js @@ -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) { diff --git a/dev/Remote/Admin/Fetch.js b/dev/Remote/Admin/Fetch.js index 3ac2280c6..624d05bf4 100644 --- a/dev/Remote/Admin/Fetch.js +++ b/dev/Remote/Admin/Fetch.js @@ -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(); diff --git a/dev/Settings/Admin/Branding.js b/dev/Settings/Admin/Branding.js index cfe7e3fe9..35bd3383f 100644 --- a/dev/Settings/Admin/Branding.js +++ b/dev/Settings/Admin/Branding.js @@ -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'); } } diff --git a/dev/Settings/Admin/Contacts.js b/dev/Settings/Admin/Contacts.js index 95db097d9..6c02e830e 100644 --- a/dev/Settings/Admin/Contacts.js +++ b/dev/Settings/Admin/Contacts.js @@ -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() } ); } diff --git a/dev/Settings/Admin/General.js b/dev/Settings/Admin/General.js index 06440fcdf..46dc6fb9a 100644 --- a/dev/Settings/Admin/General.js +++ b/dev/Settings/Admin/General.js @@ -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') }); } diff --git a/dev/Settings/Admin/Login.js b/dev/Settings/Admin/Login.js index ac5d8b26f..fba0b4598 100644 --- a/dev/Settings/Admin/Login.js +++ b/dev/Settings/Admin/Login.js @@ -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) + }) }); } } diff --git a/dev/Settings/User/Folders.js b/dev/Settings/User/Folders.js index 5087babc0..b7e1c429e 100644 --- a/dev/Settings/User/Folders.js +++ b/dev/Settings/User/Folders.js @@ -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) { diff --git a/dev/Settings/User/General.js b/dev/Settings/User/General.js index 57eefefb6..879cb245d 100644 --- a/dev/Settings/User/General.js +++ b/dev/Settings/User/General.js @@ -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); } }); } diff --git a/dev/Settings/User/OpenPgp.js b/dev/Settings/User/OpenPgp.js index 544ccb3c0..6927a612e 100644 --- a/dev/Settings/User/OpenPgp.js +++ b/dev/Settings/User/OpenPgp.js @@ -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() { diff --git a/dev/Settings/User/Security.js b/dev/Settings/User/Security.js index 8a77f25e8..59045cf66 100644 --- a/dev/Settings/User/Security.js +++ b/dev/Settings/User/Security.js @@ -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'); } } } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php index 4b151047b..88f8860cc 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -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']); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Admin.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Admin.php index 0ee498a4c..d69bf12e6 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Admin.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Admin.php @@ -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; } } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php index 176a335b9..f20f3b8a7 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php @@ -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; } } diff --git a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsBranding.html b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsBranding.html index f091cc904..13bd4ec70 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsBranding.html +++ b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsBranding.html @@ -16,8 +16,8 @@
diff --git a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsContacts.html b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsContacts.html index a016cc519..12b3ff55c 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsContacts.html +++ b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsContacts.html @@ -28,32 +28,32 @@ params: { options: contactsTypesOptions, value: mainContactsType, - trigger: contactsTypeTrigger, + trigger: contactsPdoTypeTrigger, optionsText: 'name', optionsValue: 'id' } }"> -
+
+ data-bind="value: contactsPdoDsn, saveTrigger: contactsPdoDsnTrigger" placeholder="mysql:host=127.0.0.1;port=3306;dbname=snappymail">
+ data-bind="value: contactsPdoUser, saveTrigger: contactsPdoUserTrigger">
+ data-bind="value: contactsPdoPassword, saveTrigger: contactsPdoPasswordTrigger">
@@ -64,7 +64,7 @@
-
+

diff --git a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsGeneral.html b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsGeneral.html index c079ab0be..2d4f30a3b 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsGeneral.html +++ b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsGeneral.html @@ -90,7 +90,7 @@
- +   diff --git a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsLogin.html b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsLogin.html index 30a01c74a..4f0aa2f20 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsLogin.html +++ b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsLogin.html @@ -5,8 +5,8 @@
diff --git a/snappymail/v/0.0.0/app/templates/Views/User/SettingsGeneral.html b/snappymail/v/0.0.0/app/templates/Views/User/SettingsGeneral.html index da0b69634..2e893e6a7 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/SettingsGeneral.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/SettingsGeneral.html @@ -42,7 +42,7 @@
  - +
@@ -77,7 +77,7 @@
  - +