2014-08-21 23:08:34 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
import _ from '_';
|
|
|
|
import ko from 'ko';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
import {pInt, settingsSaveHelperSimpleFunction} from 'Common/Utils';
|
|
|
|
import {Capa, SaveSettingsStep} from 'Common/Enums';
|
|
|
|
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
import {capa} from 'Storage/Settings';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
import {showScreenPopup} from 'Knoin/Knoin';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
import SettinsStore from 'Stores/User/Settings';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
import Remote from 'Remote/User/Ajax';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
class SecurityUserSettings
|
2016-06-30 08:02:45 +08:00
|
|
|
{
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
|
|
|
this.capaAutoLogout = capa(Capa.AutoLogout);
|
|
|
|
this.capaTwoFactor = 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})}
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
configureTwoFactor() {
|
|
|
|
showScreenPopup(require('View/Popup/TwoFactorConfiguration'));
|
|
|
|
}
|
2015-02-19 03:52:52 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
onBuild() {
|
|
|
|
if (this.capaAutoLogout)
|
|
|
|
{
|
|
|
|
_.delay(() => {
|
|
|
|
const f0 = settingsSaveHelperSimpleFunction(this.autoLogout.trigger, this);
|
2015-02-19 03:52:52 +08:00
|
|
|
|
2016-07-16 05:29:42 +08:00
|
|
|
this.autoLogout.subscribe(Remote.saveSettingsHelper('AutoLogout', pInt, f0));
|
2015-02-20 06:13:27 +08:00
|
|
|
});
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-07-16 03:54:37 +08:00
|
|
|
export {SecurityUserSettings, SecurityUserSettings as default};
|