snappymail/dev/Settings/User/Security.js

65 lines
2 KiB
JavaScript
Raw Normal View History

import { koComputable } from 'External/ko';
2016-06-30 08:02:45 +08:00
2022-02-24 19:22:27 +08:00
import { SettingsCapa } from 'Common/Globals';
import { i18n, translateTrigger, relativeTime } 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
import { GnuPGUserStore } from 'Stores/User/GnuPG';
import { OpenPGPUserStore } from 'Stores/User/OpenPGP';
import { showScreenPopup } from 'Knoin/Knoin';
import { OpenPgpImportPopupView } from 'View/Popup/OpenPgpImport';
import { OpenPgpGeneratePopupView } from 'View/Popup/OpenPgpGenerate';
export class UserSettingsSecurity extends AbstractViewSettings {
2016-07-16 05:29:42 +08:00
constructor() {
2022-02-28 17:38:47 +08:00
super();
2022-10-27 22:05:28 +08:00
this.autoLogout = SettingsUserStore.autoLogout;
this.autoLogoutOptions = koComputable(() => {
2022-10-10 19:52:56 +08:00
translateTrigger();
2016-07-16 05:29:42 +08:00
return [
{ id: 0, name: i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME') },
{ id: 5, name: relativeTime(300) },
{ id: 10, name: relativeTime(600) },
{ id: 30, name: relativeTime(1800) },
{ id: 60, name: relativeTime(3600) },
{ id: 120, name: relativeTime(7200) },
{ id: 300, name: relativeTime(18000) },
{ id: 600, name: relativeTime(36000) }
2016-07-16 05:29:42 +08:00
];
});
2022-10-27 22:05:28 +08:00
this.addSetting('AutoLogout');
this.gnupgPublicKeys = GnuPGUserStore.publicKeys;
this.gnupgPrivateKeys = GnuPGUserStore.privateKeys;
this.openpgpkeysPublic = OpenPGPUserStore.publicKeys;
this.openpgpkeysPrivate = OpenPGPUserStore.privateKeys;
this.canOpenPGP = SettingsCapa('OpenPGP');
this.canGnuPG = GnuPGUserStore.isSupported();
this.canMailvelope = !!window.mailvelope;
}
addOpenPgpKey() {
showScreenPopup(OpenPgpImportPopupView);
}
generateOpenPgpKey() {
showScreenPopup(OpenPgpGeneratePopupView);
}
onBuild() {
/**
* Create an iframe to display the Mailvelope keyring settings.
* The iframe will be injected into the container identified by selector.
*/
window.mailvelope && mailvelope.createSettingsContainer('#mailvelope-settings'/*[, keyring], options*/);
2016-07-16 05:29:42 +08:00
}
}