WebClient: refactor alerts

Fix events handling on disabling MFA

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2023-11-07 18:52:05 +01:00
parent 96c614550f
commit 894e12e285
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF

View file

@ -310,29 +310,33 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
}
}
var cancelFn = function() {
resolvePromise(false);
modal.hide();
}
var okFn = function() {
resolvePromise(true);
modal.hide();
}
var hideFn = function() {
resolvePromise(false);
}
return {
fire: function (params) {
if (!modal){
modal = new bootstrap.Modal('#modal_alert');
modal._element.addEventListener('hide.bs.modal',function() {
resolvePromise(false);
});
$('#modal_alert_cancel').on("click", function(){
resolvePromise(false);
modal.hide();
});
$('#modal_alert_ok').on("click", function(){
resolvePromise(true);
modal.hide();
});
}
modal = new bootstrap.Modal('#modal_alert');
let modalEl = $('#modal_alert');
let okBtn = $("#modal_alert_ok");
let cancelBtn = $("#modal_alert_cancel");
modalEl.off('hide.bs.modal');
modalEl.on('hide.bs.modal', hideFn);
cancelBtn.off("click");
okBtn.off("click");
cancelBtn.on("click", cancelFn);
okBtn.on("click", okFn);
okBtn.removeClass();
okBtn.addClass(params.customClass.confirmButton);
okBtn.addClass("m-2");