snappymail/dev/Settings/Admin/Branding.js

72 lines
2.7 KiB
JavaScript
Raw Normal View History

2016-07-16 03:54:37 +08:00
import _ from '_';
import ko from 'ko';
2019-07-05 03:19:24 +08:00
import { Magics } from 'Common/Enums';
import { settingsSaveHelperSimpleFunction, trim } from 'Common/Utils';
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
2016-07-16 03:54:37 +08:00
2016-08-24 06:17:50 +08:00
import Remote from 'Remote/Admin/Ajax';
import AppStore from 'Stores/Admin/App';
2019-07-05 03:19:24 +08:00
import { settingsGet } from 'Storage/Settings';
2016-07-16 03:54:37 +08:00
2019-07-05 03:19:24 +08:00
class BrandingAdminSettings {
2016-07-16 05:29:42 +08:00
constructor() {
2016-07-16 03:54:37 +08:00
this.capa = AppStore.prem;
2016-07-16 05:29:42 +08:00
this.title = ko.observable(settingsGet('Title')).idleTrigger();
this.loadingDesc = ko.observable(settingsGet('LoadingDescription')).idleTrigger();
this.faviconUrl = ko.observable(settingsGet('FaviconUrl')).idleTrigger();
this.loginLogo = ko.observable(settingsGet('LoginLogo') || '').idleTrigger();
this.loginBackground = ko.observable(settingsGet('LoginBackground') || '').idleTrigger();
this.userLogo = ko.observable(settingsGet('UserLogo') || '').idleTrigger();
this.userLogoMessage = ko.observable(settingsGet('UserLogoMessage') || '').idleTrigger();
this.userIframeMessage = ko.observable(settingsGet('UserIframeMessage') || '').idleTrigger();
this.userLogoTitle = ko.observable(settingsGet('UserLogoTitle') || '').idleTrigger();
this.loginDescription = ko.observable(settingsGet('LoginDescription')).idleTrigger();
this.loginCss = ko.observable(settingsGet('LoginCss')).idleTrigger();
this.userCss = ko.observable(settingsGet('UserCss')).idleTrigger();
this.welcomePageUrl = ko.observable(settingsGet('WelcomePageUrl')).idleTrigger();
this.welcomePageDisplay = ko.observable(settingsGet('WelcomePageDisplay')).idleTrigger();
2016-07-16 03:54:37 +08:00
this.welcomePageDisplay.options = ko.computed(() => {
translatorTrigger();
return [
2019-07-05 03:19:24 +08:00
{ optValue: 'none', optText: i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_NONE') },
{ optValue: 'once', optText: i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_ONCE') },
{ optValue: 'always', optText: i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_ALWAYS') }
2016-07-16 03:54:37 +08:00
];
});
this.loginPowered = ko.observable(!!settingsGet('LoginPowered'));
this.community = RL_COMMUNITY || AppStore.community();
}
onBuild() {
_.delay(() => {
2019-07-05 03:19:24 +08:00
const f1 = settingsSaveHelperSimpleFunction(this.title.trigger, this),
2016-07-16 03:54:37 +08:00
f2 = settingsSaveHelperSimpleFunction(this.loadingDesc.trigger, this),
f3 = settingsSaveHelperSimpleFunction(this.faviconUrl.trigger, this);
this.title.subscribe((value) => {
Remote.saveAdminConfig(f1, {
'Title': trim(value)
});
});
this.loadingDesc.subscribe((value) => {
Remote.saveAdminConfig(f2, {
'LoadingDescription': trim(value)
});
});
this.faviconUrl.subscribe((value) => {
Remote.saveAdminConfig(f3, {
'FaviconUrl': trim(value)
});
});
2016-08-24 06:17:50 +08:00
}, Magics.Time50ms);
2016-07-16 03:54:37 +08:00
}
}
2019-07-05 03:19:24 +08:00
export { BrandingAdminSettings, BrandingAdminSettings as default };