mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-15 04:04:50 +08:00
17669b7be0
Signature plugin fixes Add view decorator A large number of fixes
73 lines
1.4 KiB
JavaScript
73 lines
1.4 KiB
JavaScript
|
|
import ko from 'ko';
|
|
|
|
import {StorageResultType} from 'Common/Enums';
|
|
import {bMobileDevice} from 'Common/Globals';
|
|
import {createCommand} from 'Common/Utils';
|
|
|
|
import Remote from 'Remote/User/Ajax';
|
|
|
|
import {view, ViewType} from 'Knoin/Knoin';
|
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
|
|
|
@view({
|
|
name: 'View/Popup/TwoFactorTest',
|
|
type: ViewType.Popup,
|
|
templateID: 'PopupsTwoFactorTest'
|
|
})
|
|
class TwoFactorTestPopupView extends AbstractViewNext
|
|
{
|
|
constructor() {
|
|
super();
|
|
|
|
this.code = ko.observable('');
|
|
this.code.focused = ko.observable(false);
|
|
this.code.status = ko.observable(null);
|
|
|
|
this.koTestedTrigger = null;
|
|
|
|
this.testing = ko.observable(false);
|
|
|
|
// commands
|
|
this.testCode = createCommand(() => {
|
|
|
|
this.testing(true);
|
|
Remote.testTwoFactor((result, data) => {
|
|
|
|
this.testing(false);
|
|
this.code.status(StorageResultType.Success === result && data && !!data.Result);
|
|
|
|
if (this.koTestedTrigger && this.code.status())
|
|
{
|
|
this.koTestedTrigger(true);
|
|
}
|
|
|
|
}, this.code());
|
|
|
|
}, () => '' !== this.code() && !this.testing());
|
|
}
|
|
|
|
clearPopup() {
|
|
this.code('');
|
|
this.code.focused(false);
|
|
this.code.status(null);
|
|
this.testing(false);
|
|
|
|
this.koTestedTrigger = null;
|
|
}
|
|
|
|
onShow(koTestedTrigger) {
|
|
this.clearPopup();
|
|
|
|
this.koTestedTrigger = koTestedTrigger;
|
|
}
|
|
|
|
onShowWithDelay() {
|
|
if (!bMobileDevice)
|
|
{
|
|
this.code.focused(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = TwoFactorTestPopupView;
|