Admin: Ask for IMAP login credentials when testing, idea for #477

This commit is contained in:
the-djmaze 2022-08-04 14:58:13 +02:00
parent db95565b70
commit aff9ba29e7
66 changed files with 214 additions and 62 deletions

View file

@ -11,6 +11,8 @@ export class AskPopupView extends AbstractViewPopup {
askDesc: '',
yesButton: '',
noButton: '',
username: '',
askUsername: false,
passphrase: '',
askPass: false
});
@ -40,15 +42,19 @@ export class AskPopupView extends AbstractViewPopup {
* @param {boolean=} focusOnShow = true
* @returns {void}
*/
onShow(sAskDesc, fYesFunc = null, fNoFunc = null, focusOnShow = true, askPass = false, btnText = '') {
onShow(sAskDesc, fYesFunc = null, fNoFunc = null, focusOnShow = true, ask = 0, btnText = '') {
this.askDesc(sAskDesc || '');
this.askPass(askPass);
this.askUsername(ask & 2);
this.askPass(ask & 1);
this.username('');
this.passphrase('');
this.yesButton(i18n(btnText || 'GLOBAL/YES'));
this.noButton(i18n(askPass ? 'GLOBAL/CANCEL' : 'GLOBAL/NO'));
this.noButton(i18n(ask ? 'GLOBAL/CANCEL' : 'GLOBAL/NO'));
this.fYesAction = fYesFunc;
this.fNoAction = fNoFunc;
this.focusOnShow = focusOnShow ? (askPass ? 'input[type="password"]' : '.buttonYes') : '';
this.focusOnShow = focusOnShow
? (ask ? 'input[type="'+(ask&2?'text':'password')+'"]' : '.buttonYes')
: '';
}
afterShow() {
@ -80,7 +86,20 @@ AskPopupView.password = function(sAskDesc, btnText) {
() => resolve(this.__vm.passphrase()),
() => resolve(null),
true,
true,
1,
btnText
]);
});
}
AskPopupView.credentials = function(sAskDesc, btnText) {
return new Promise(resolve => {
this.showModal([
sAskDesc,
() => resolve({username:this.__vm.username(), password:this.__vm.passphrase()}),
() => resolve(null),
true,
3,
btnText
]);
});