2021-12-31 20:30:05 +08:00
|
|
|
import { koComputable } from 'External/ko';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2022-02-28 17:38:47 +08:00
|
|
|
import { Capa } from 'Common/Enums';
|
2022-02-24 19:22:27 +08:00
|
|
|
import { SettingsCapa } from 'Common/Globals';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2022-02-28 17:38:47 +08:00
|
|
|
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2022-02-28 17:38:47 +08:00
|
|
|
import { SettingsUserStore } from 'Stores/User/Settings';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2022-02-28 17:38:47 +08:00
|
|
|
export class SecurityUserSettings extends AbstractViewSettings {
|
2016-07-16 05:29:42 +08:00
|
|
|
constructor() {
|
2022-02-28 17:38:47 +08:00
|
|
|
super();
|
|
|
|
|
2022-02-24 19:22:27 +08:00
|
|
|
this.capaAutoLogout = SettingsCapa(Capa.AutoLogout);
|
2016-07-16 05:29:42 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
this.autoLogout = SettingsUserStore.autoLogout;
|
2016-07-16 05:29:42 +08:00
|
|
|
|
2021-01-26 18:46:30 +08:00
|
|
|
let i18nLogout = (key, params) => i18n('SETTINGS_SECURITY/AUTOLOGIN_' + key, params);
|
2021-12-31 20:30:05 +08:00
|
|
|
this.autoLogoutOptions = koComputable(() => {
|
2016-07-16 05:29:42 +08:00
|
|
|
translatorTrigger();
|
|
|
|
return [
|
2021-03-25 04:26:40 +08:00
|
|
|
{ id: 0, name: i18nLogout('NEVER_OPTION_NAME') },
|
|
|
|
{ id: 5, name: i18nLogout('MINUTES_OPTION_NAME', { MINUTES: 5 }) },
|
|
|
|
{ id: 10, name: i18nLogout('MINUTES_OPTION_NAME', { MINUTES: 10 }) },
|
|
|
|
{ id: 30, name: i18nLogout('MINUTES_OPTION_NAME', { MINUTES: 30 }) },
|
|
|
|
{ id: 60, name: i18nLogout('MINUTES_OPTION_NAME', { MINUTES: 60 }) },
|
|
|
|
{ id: 60 * 2, name: i18nLogout('HOURS_OPTION_NAME', { HOURS: 2 }) },
|
|
|
|
{ id: 60 * 5, name: i18nLogout('HOURS_OPTION_NAME', { HOURS: 5 }) },
|
|
|
|
{ id: 60 * 10, name: i18nLogout('HOURS_OPTION_NAME', { HOURS: 10 }) }
|
2016-07-16 05:29:42 +08:00
|
|
|
];
|
|
|
|
});
|
2021-03-18 23:12:24 +08:00
|
|
|
|
|
|
|
if (this.capaAutoLogout) {
|
2022-02-28 17:38:47 +08:00
|
|
|
this.addSetting('AutoLogout');
|
2021-03-18 23:12:24 +08:00
|
|
|
}
|
2016-07-16 05:29:42 +08:00
|
|
|
}
|
|
|
|
}
|