snappymail/dev/Settings/User/Security.js
djmaze ad8fd8879b This version uses Rollup instead of WebPack.
Due to that the code is smaller and has changes to prevent Circular Dependencies
2021-01-25 22:00:13 +01:00

52 lines
1.9 KiB
JavaScript

import ko from 'ko';
import { pInt, settingsSaveHelperSimpleFunction } from 'Common/Utils';
import { Capa, SaveSettingsStep } from 'Common/Enums';
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
import { showScreenPopup } from 'Knoin/Knoin';
import SettinsStore from 'Stores/User/Settings';
import Remote from 'Remote/User/Fetch';
import { TwoFactorConfigurationPopupView } from 'View/Popup/TwoFactorConfiguration';
export class SecurityUserSettings {
constructor() {
this.capaAutoLogout = rl.settings.capa(Capa.AutoLogout);
this.capaTwoFactor = rl.settings.capa(Capa.TwoFactor);
this.autoLogout = SettinsStore.autoLogout;
this.autoLogout.trigger = ko.observable(SaveSettingsStep.Idle);
this.autoLogoutOptions = ko.computed(() => {
translatorTrigger();
return [
{ 'id': 0, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME') },
{ 'id': 5, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', { 'MINUTES': 5 }) },
{ 'id': 10, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', { 'MINUTES': 10 }) },
{ 'id': 30, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', { 'MINUTES': 30 }) },
{ 'id': 60, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', { 'MINUTES': 60 }) },
{ 'id': 60 * 2, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', { 'HOURS': 2 }) },
{ 'id': 60 * 5, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', { 'HOURS': 5 }) },
{ 'id': 60 * 10, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', { 'HOURS': 10 }) }
];
});
}
configureTwoFactor() {
showScreenPopup(TwoFactorConfigurationPopupView);
}
onBuild() {
if (this.capaAutoLogout) {
setTimeout(() => {
const f0 = settingsSaveHelperSimpleFunction(this.autoLogout.trigger, this);
this.autoLogout.subscribe(Remote.saveSettingsHelper('AutoLogout', pInt, f0));
});
}
}
}