keeweb/app/scripts/views/settings/settings-devices-view.js

80 lines
2.7 KiB
JavaScript
Raw Normal View History

import { Events } from 'framework/events';
2020-04-15 16:50:01 +02:00
import { View } from 'framework/views/view';
import { AppSettingsModel } from 'models/app-settings-model';
2020-04-19 20:42:55 +02:00
import { YubiKeyOtpModel } from 'models/external/yubikey-otp-model';
2020-04-19 18:52:21 +02:00
import { Links } from 'const/links';
2020-05-05 18:01:16 +02:00
import { UsbListener } from 'comp/app/usb-listener';
import template from 'templates/settings/settings-devices.hbs';
2020-04-15 16:50:01 +02:00
class SettingsDevicesView extends View {
template = template;
events = {
2020-04-19 18:52:21 +02:00
'change .settings__devices-enable-usb': 'changeEnableUsb',
'change .settings__yubikey-show-icon': 'changeYubiKeyShowIcon',
'change .settings__yubikey-auto-open': 'changeYubiKeyAutoOpen',
'change .settings__yubikey-match-entries': 'changeYubiKeyMatchEntries',
2020-05-06 18:37:37 +02:00
'change .settings__yubikey-chalresp-show': 'changeYubiKeyShowChalResp',
'change .settings__yubikey-oath-workaround': 'changeYubiKeyOathWorkaround'
2020-04-15 16:50:01 +02:00
};
2020-04-19 20:42:55 +02:00
constructor(...args) {
super(...args);
if (!['ok', 'checking'].includes(YubiKeyOtpModel.ykmanStatus)) {
this.toolCheckPromise = YubiKeyOtpModel.checkToolStatus();
}
}
2020-04-15 16:50:01 +02:00
render() {
2020-04-19 20:42:55 +02:00
if (this.toolCheckPromise) {
this.toolCheckPromise.then(() => this.render());
this.toolCheckPromise = undefined;
}
2020-04-15 16:50:01 +02:00
super.render({
2020-05-05 17:57:01 +02:00
supported: UsbListener.supported,
enableUsb: UsbListener.supported && AppSettingsModel.enableUsb,
2020-04-19 20:42:55 +02:00
ykmanStatus: YubiKeyOtpModel.ykmanStatus,
2020-04-19 18:52:21 +02:00
yubiKeyShowIcon: AppSettingsModel.yubiKeyShowIcon,
yubiKeyAutoOpen: AppSettingsModel.yubiKeyAutoOpen,
yubiKeyMatchEntries: AppSettingsModel.yubiKeyMatchEntries,
yubiKeyShowChalResp: AppSettingsModel.yubiKeyShowChalResp,
2020-05-06 18:37:37 +02:00
yubiKeyOathWorkaround: AppSettingsModel.yubiKeyOathWorkaround,
2020-04-19 20:42:55 +02:00
yubiKeyManualLink: Links.YubiKeyManual,
ykmanInstallLink: Links.YubiKeyManagerInstall
2020-04-15 16:50:01 +02:00
});
}
changeEnableUsb(e) {
AppSettingsModel.enableUsb = e.target.checked;
this.render();
}
2020-04-19 18:52:21 +02:00
changeYubiKeyShowIcon(e) {
AppSettingsModel.yubiKeyShowIcon = e.target.checked;
this.render();
}
changeYubiKeyAutoOpen(e) {
AppSettingsModel.yubiKeyAutoOpen = e.target.checked;
this.render();
}
changeYubiKeyMatchEntries(e) {
AppSettingsModel.yubiKeyMatchEntries = e.target.checked;
this.render();
Events.emit('refresh');
2020-04-19 18:52:21 +02:00
}
changeYubiKeyShowChalResp(e) {
AppSettingsModel.yubiKeyShowChalResp = e.target.checked;
this.render();
}
2020-05-06 18:37:37 +02:00
changeYubiKeyOathWorkaround(e) {
AppSettingsModel.yubiKeyOathWorkaround = e.target.checked;
this.render();
}
2020-04-15 16:50:01 +02:00
}
export { SettingsDevicesView };