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-15 16:50:01 +02:00
|
|
|
import template from 'templates/settings/settings-devices.hbs';
|
2020-04-19 18:52:21 +02:00
|
|
|
import { Links } from 'const/links';
|
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',
|
|
|
|
'change .settings__yubikey-chalresp-show': 'changeYubiKeyShowChalResp'
|
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-04-19 18:52:21 +02:00
|
|
|
enableUsb: 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-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();
|
|
|
|
}
|
|
|
|
|
|
|
|
changeYubiKeyShowChalResp(e) {
|
|
|
|
AppSettingsModel.yubiKeyShowChalResp = e.target.checked;
|
|
|
|
this.render();
|
|
|
|
}
|
2020-04-15 16:50:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export { SettingsDevicesView };
|