Merge branch 'master' into UserMailTemplates

# Conflicts:
#	dev/App/User.js
#	dev/Common/Enums.js
#	dev/Screen/User/Settings.js
#	dev/Settings/Admin/General.js
#	snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php
#	snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Admin.php
#	snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php
This commit is contained in:
djmaze 2022-03-15 15:00:14 +01:00
commit f7f56b3789
794 changed files with 96444 additions and 74188 deletions

View file

@ -2,29 +2,29 @@ import ko from 'ko';
import {
isArray,
pInt,
settingsSaveHelperSimpleFunction,
changeTheme,
convertThemeName,
addObservablesTo,
addSubscribablesTo,
addComputablesTo
convertThemeName
} from 'Common/Utils';
import { Capa, SaveSettingsStep } from 'Common/Enums';
import { Settings, SettingsGet } from 'Common/Globals';
import { reload as translatorReload, convertLangName } from 'Common/Translator';
import { addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko';
import { 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';
import { ThemeStore } from 'Stores/Theme';
import { LanguageStore } from 'Stores/Language';
import LanguagesPopupView from 'View/Popup/Languages';
import { LanguagesPopupView } from 'View/Popup/Languages';
export class GeneralAdminSettings {
export class AdminSettingsGeneral extends AbstractViewSettings {
constructor() {
super();
this.language = LanguageStore.language;
this.languages = LanguageStore.languages;
@ -37,18 +37,17 @@ export class GeneralAdminSettings {
this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes;
this.addSettings(['AllowLanguagesOnSettings','NewMoveToFolder']);
addObservablesTo(this, {
allowLanguagesOnSettings: !!SettingsGet('AllowLanguagesOnSettings'),
newMoveToFolder: !!SettingsGet('NewMoveToFolder'),
attachmentLimitTrigger: SaveSettingsStep.Idle,
languageTrigger: SaveSettingsStep.Idle,
themeTrigger: SaveSettingsStep.Idle,
capaThemes: Settings.capa(Capa.Themes),
capaUserBackground: Settings.capa(Capa.UserBackground),
capaAdditionalAccounts: Settings.capa(Capa.AdditionalAccounts),
capaIdentities: Settings.capa(Capa.Identities),
capaAttachmentThumbnails: Settings.capa(Capa.AttachmentThumbnails),
capaTemplates: Settings.capa(Capa.Templates),
capaThemes: SettingsCapa('Themes'),
capaUserBackground: SettingsCapa('UserBackground'),
capaAdditionalAccounts: SettingsCapa('AdditionalAccounts'),
capaIdentities: SettingsCapa('Identities'),
capaAttachmentThumbnails: SettingsCapa('AttachmentThumbnails'),
capaTemplates: SettingsCapa('Templates'),
dataFolderAccess: false
});
@ -60,10 +59,14 @@ export class GeneralAdminSettings {
}
*/
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)
@ -88,55 +91,27 @@ export class GeneralAdminSettings {
this.languageAdminTrigger(saveSettingsStep);
setTimeout(() => this.languageAdminTrigger(SaveSettingsStep.Idle), 1000);
},
fSaveBoolHelper = (key, fn) =>
value => {
const data = {};
data[key] = value ? 1 : 0;
Remote.saveAdminConfig(fn, data);
};
fSaveHelper = key => value => Remote.saveSetting(key, value);
addSubscribablesTo(this, {
mainAttachmentLimit: value =>
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.attachmentLimitTrigger, this), {
AttachmentLimit: pInt(value)
}),
language: value =>
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.languageTrigger, this), {
Language: value.trim()
}),
languageAdmin: value => {
this.languageAdminTrigger(SaveSettingsStep.Animate);
translatorReload(true, value)
.then(fReloadLanguageHelper(SaveSettingsStep.TrueResult), fReloadLanguageHelper(SaveSettingsStep.FalseResult))
.then(() => Remote.saveAdminConfig(null, {
LanguageAdmin: value.trim()
}));
.then(() => Remote.saveSetting('LanguageAdmin', value));
},
theme: value => {
changeTheme(value, this.themeTrigger);
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.themeTrigger, this), {
Theme: value.trim()
});
},
capaAdditionalAccounts: fSaveHelper('CapaAdditionalAccounts'),
capaAdditionalAccounts: fSaveBoolHelper('CapaAdditionalAccounts'),
capaIdentities: fSaveHelper('CapaIdentities'),
capaIdentities: fSaveBoolHelper('CapaIdentities'),
capaTemplates: fSaveHelper('CapaTemplates'),
capaTemplates: fSaveBoolHelper('CapaTemplates'),
capaAttachmentThumbnails: fSaveHelper('CapaAttachmentThumbnails'),
capaAttachmentThumbnails: fSaveBoolHelper('CapaAttachmentThumbnails'),
capaThemes: fSaveHelper('CapaThemes'),
capaThemes: fSaveBoolHelper('CapaThemes'),
capaUserBackground: fSaveBoolHelper('CapaUserBackground'),
allowLanguagesOnSettings: fSaveBoolHelper('AllowLanguagesOnSettings'),
newMoveToFolder: fSaveBoolHelper('NewMoveToFolder')
capaUserBackground: fSaveHelper('CapaUserBackground')
});
}