Allow users to hide notifications explorer (#2071)

This commit is contained in:
Christophe Maudoux 2020-02-13 17:14:44 +01:00
parent a8bda7dadf
commit 75657190f7
18 changed files with 55 additions and 9 deletions

View File

@ -33,7 +33,11 @@ toggle = (button, notif, epoch) ->
button.removeClass 'btn-success'
button.addClass 'btn-danger'
$("#myNotification").removeAttr('hidden')
else $("#myNotification").attr('hidden', 'true')
else
$("#icon-explorer-button").removeClass 'fa-eye'
$("#icon-explorer-button").addClass 'fa-eye-slash'
$("#myNotification").attr('hidden', 'true')
$("#explorer-button").attr('hidden', 'true')
# viewNotif function (launched by "verify" button)
viewNotif = (notif, epoch, button) ->
@ -55,6 +59,7 @@ viewNotif = (notif, epoch, button) ->
$('#notifRef').text(notif)
myDate = new Date(epoch * 1000)
$('#notifEpoch').text(myDate.toLocaleString())
$("#explorer-button").removeAttr('hidden')
else setMsg 'notificationNotFound', 'warning'
else setMsg 'notificationRetreiveFailed', 'warning'
@ -66,4 +71,12 @@ $(document).ready ->
$('#goback').attr 'href', portal
$('body').on 'click', '.btn-success', () -> viewNotif ( $(this).attr 'notif' ), ( $(this).attr 'epoch' ), $(this)
$('body').on 'click', '.btn-danger', () -> toggle $(this)
$('body').on 'click', '.btn-info', () ->
if $('#explorer').is(':visible')
$('#explorer').hide()
$("#icon-explorer-button").removeClass 'fa-eye-slash'
$("#icon-explorer-button").addClass 'fa-eye'
else
$('#explorer').show()
$("#icon-explorer-button").removeClass 'fa-eye'
$("#icon-explorer-button").addClass 'fa-eye-slash'

View File

@ -46,7 +46,10 @@ LemonLDAP::NG Notifications script
button.addClass('btn-danger');
return $("#myNotification").removeAttr('hidden');
} else {
return $("#myNotification").attr('hidden', 'true');
$("#icon-explorer-button").removeClass('fa-eye');
$("#icon-explorer-button").addClass('fa-eye-slash');
$("#myNotification").attr('hidden', 'true');
return $("#explorer-button").attr('hidden', 'true');
}
};
@ -70,7 +73,8 @@ LemonLDAP::NG Notifications script
$('#displayNotif').html(resp.notification);
$('#notifRef').text(notif);
myDate = new Date(epoch * 1000);
return $('#notifEpoch').text(myDate.toLocaleString());
$('#notifEpoch').text(myDate.toLocaleString());
return $("#explorer-button").removeAttr('hidden');
} else {
return setMsg('notificationNotFound', 'warning');
}
@ -91,9 +95,20 @@ LemonLDAP::NG Notifications script
$('body').on('click', '.btn-success', function() {
return viewNotif($(this).attr('notif'), $(this).attr('epoch'), $(this));
});
return $('body').on('click', '.btn-danger', function() {
$('body').on('click', '.btn-danger', function() {
return toggle($(this));
});
return $('body').on('click', '.btn-info', function() {
if ($('#explorer').is(':visible')) {
$('#explorer').hide();
$("#icon-explorer-button").removeClass('fa-eye-slash');
return $("#icon-explorer-button").addClass('fa-eye');
} else {
$('#explorer').show();
$("#icon-explorer-button").removeClass('fa-eye');
return $("#icon-explorer-button").addClass('fa-eye-slash');
}
});
});
}).call(this);

View File

@ -1,2 +1 @@
(function(){var t,e,n,a,i;e=$("#msg").attr("trspan"),n=function(t,e){return $("#msg").html(window.translate(t)),$("#color").removeClass("message-positive message-warning alert-success alert-warning"),$("#color").addClass("message-"+e),"positive"===e&&(e="success"),$("#color").addClass("alert-"+e)},t=function(t,e,a){return n("notificationRetreiveFailed","warning")},a=function(t,a,i){return n(e,"positive"),$(".btn-danger").each(function(){return $(this).removeClass("btn-danger"),$(this).addClass("btn-success")}),$(".fa-eye-slash").each(function(){return $(this).removeClass("fa-eye-slash"),$(this).addClass("fa-eye")}),$(".verify").each(function(){return $(this).text(window.translate("verify")),$(this).attr("trspan","verify")}),a&&i?($("#icon-"+a+"-"+i).removeClass("fa-eye"),$("#icon-"+a+"-"+i).addClass("fa-eye-slash"),$("#text-"+a+"-"+i).text(window.translate("hide")),$("#text-"+a+"-"+i).attr("trspan","hide"),t.removeClass("btn-success"),t.addClass("btn-danger"),$("#myNotification").removeAttr("hidden")):$("#myNotification").attr("hidden","true")},i=function(e,i,o){return console.log("Ref:",e,"epoch:",i),e&&i?(console.log("Send AJAX request"),$.ajax({type:"GET",url:portal+"mynotifications/"+e,data:{epoch:i},dataType:"json",error:t,success:function(t){var s;return t.result?(console.log("Notification:",t.notification),a(o,e,i),$("#displayNotif").html(t.notification),$("#notifRef").text(e),s=new Date(1e3*i),$("#notifEpoch").text(s.toLocaleString())):n("notificationNotFound","warning")}})):n("notificationRetreiveFailed","warning")},$(document).ready(function(){return $(".data-epoch").each(function(){var t;return t=new Date(1e3*$(this).text()),$(this).text(t.toLocaleString())}),$("#goback").attr("href",portal),$("body").on("click",".btn-success",function(){return i($(this).attr("notif"),$(this).attr("epoch"),$(this))}),$("body").on("click",".btn-danger",function(){return a($(this))})})}).call(this);
//# sourceMappingURL=lemonldap-ng-portal/site/htdocs/static/common/js/notifications.min.js.map
(function(){var e,o,r,s,t;o=$("#msg").attr("trspan"),r=function(e,t){return $("#msg").html(window.translate(e)),$("#color").removeClass("message-positive message-warning alert-success alert-warning"),$("#color").addClass("message-"+t),"positive"===t&&(t="success"),$("#color").addClass("alert-"+t)},e=function(e,t,n){return r("notificationRetreiveFailed","warning")},s=function(e,t,n){return r(o,"positive"),$(".btn-danger").each(function(){return $(this).removeClass("btn-danger"),$(this).addClass("btn-success")}),$(".fa-eye-slash").each(function(){return $(this).removeClass("fa-eye-slash"),$(this).addClass("fa-eye")}),$(".verify").each(function(){return $(this).text(window.translate("verify")),$(this).attr("trspan","verify")}),t&&n?($("#icon-"+t+"-"+n).removeClass("fa-eye"),$("#icon-"+t+"-"+n).addClass("fa-eye-slash"),$("#text-"+t+"-"+n).text(window.translate("hide")),$("#text-"+t+"-"+n).attr("trspan","hide"),e.removeClass("btn-success"),e.addClass("btn-danger"),$("#myNotification").removeAttr("hidden")):($("#icon-explorer-button").removeClass("fa-eye"),$("#icon-explorer-button").addClass("fa-eye-slash"),$("#myNotification").attr("hidden","true"),$("#explorer-button").attr("hidden","true"))},t=function(n,o,a){return console.log("Ref:",n,"epoch:",o),n&&o?(console.log("Send AJAX request"),$.ajax({type:"GET",url:portal+"mynotifications/"+n,data:{epoch:o},dataType:"json",error:e,success:function(e){var t;return e.result?(console.log("Notification:",e.notification),s(a,n,o),$("#displayNotif").html(e.notification),$("#notifRef").text(n),t=new Date(1e3*o),$("#notifEpoch").text(t.toLocaleString()),$("#explorer-button").removeAttr("hidden")):r("notificationNotFound","warning")}})):r("notificationRetreiveFailed","warning")},$(document).ready(function(){return $(".data-epoch").each(function(){var e;return e=new Date(1e3*$(this).text()),$(this).text(e.toLocaleString())}),$("#goback").attr("href",portal),$("body").on("click",".btn-success",function(){return t($(this).attr("notif"),$(this).attr("epoch"),$(this))}),$("body").on("click",".btn-danger",function(){return s($(this))}),$("body").on("click",".btn-info",function(){return $("#explorer").is(":visible")?($("#explorer").hide(),$("#icon-explorer-button").removeClass("fa-eye-slash"),$("#icon-explorer-button").addClass("fa-eye")):($("#explorer").show(),$("#icon-explorer-button").removeClass("fa-eye"),$("#icon-explorer-button").addClass("fa-eye-slash"))})})}).call(this);

View File

@ -1 +1 @@
{"version":3,"sources":["lemonldap-ng-portal/site/htdocs/static/common/js/notifications.js"],"names":["displayError","msg","setMsg","toggle","viewNotif","$","attr","level","html","window","translate","removeClass","addClass","j","status","err","button","notif","epoch","each","this","text","removeAttr","console","log","ajax","type","url","portal","data","dataType","error","success","resp","myDate","result","notification","Date","toLocaleString","document","ready","on","call"],"mappings":"CAMA,WACE,GAAIA,GAAcC,EAAKC,EAAQC,EAAQC,CAEvCH,GAAMI,EAAE,QAAQC,KAAK,UAErBJ,EAAS,SAASD,EAAKM,GAOrB,MANAF,GAAE,QAAQG,KAAKC,OAAOC,UAAUT,IAChCI,EAAE,UAAUM,YAAY,gEACxBN,EAAE,UAAUO,SAAS,WAAaL,GACpB,aAAVA,IACFA,EAAQ,WAEHF,EAAE,UAAUO,SAAS,SAAWL,IAGzCP,EAAe,SAASa,EAAGC,EAAQC,GACjC,MAAOb,GAAO,6BAA8B,YAG9CC,EAAS,SAASa,EAAQC,EAAOC,GAc/B,MAbAhB,GAAOD,EAAK,YACZI,EAAE,eAAec,KAAK,WAEpB,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AjBhC,EAAEe,MAAMC,QACnBhB,EAAEe,MAAMC,KAAKa,EAAOI,oBAE7BjC,EAAE,WAAWC,KAAK,OAAQsB,QAC1BvB,EAAE,QAAQoC,GAAG,QAAS,eAAgB,WACpC,MAAOrC,GAAUC,EAAEe,MAAMd,KAAK,SAAUD,EAAEe,MAAMd,KAAK,SAAUD,EAAEe,SAE5Df,EAAE,QAAQoC,GAAG,QAAS,cAAe,WAC1C,MAAOtC,GAAOE,EAAEe,aAInBsB,KAAKtB","file":"lemonldap-ng-portal/site/htdocs/static/common/js/notifications.min.js"}
{"version":3,"sources":["lemonldap-ng-portal/site/htdocs/static/common/js/notifications.js"],"names":["displayError","msg","setMsg","toggle","viewNotif","$","attr","level","html","window","translate","removeClass","addClass","j","status","err","button","notif","epoch","each","this","text","removeAttr","console","log","ajax","type","url","portal","data","dataType","error","success","resp","myDate","result","notification","Date","toLocaleString","document","ready","on","is","hide","show","call"],"mappings":"CAMA,WACE,IAAIA,EAAcC,EAAKC,EAAQC,EAAQC,EAEvCH,EAAMI,EAAE,QAAQC,KAAK,UAErBJ,EAAS,SAASD,EAAKM,GAOrB,OANAF,EAAE,QAAQG,KAAKC,OAAOC,UAAUT,IAChCI,EAAE,UAAUM,YAAY,gEACxBN,EAAE,UAAUO,SAAS,WAAaL,GACpB,aAAVA,IACFA,EAAQ,WAEHF,EAAE,UAAUO,SAAS,SAAWL,IAGzCP,EAAe,SAASa,EAAGC,EAAQC,GACjC,OAAOb,EAAO,6BAA8B,YAG9CC,EAAS,SAASa,EAAQC,EAAOC,GAc/B,OAbAhB,EAAOD,EAAK,YACZI,EAAE,eAAec,KAAK,WAEpB,OADAd,EAAEe,MAAMT,YAAY,cACbN,EAAEe,MAAMR,SAAS,iBAE1BP,EAAE,iBAAiBc,KAAK,WAEtB,OADAd,EAAEe,MAAMT,YAAY,gBACbN,EAAEe,MAAMR,SAAS,YAE1BP,EAAE,WAAWc,KAAK,WAEhB,OADAd,EAAEe,MAAMC,KAAKZ,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EAAE,WAAWC,KAAK,OAAQsB,QAC1BvB,EAAE,QAAQoC,GAAG,QAAS,eAAgB,WACpC,OAAOrC,EAAUC,EAAEe,MAAMd,KAAK,SAAUD,EAAEe,MAAMd,KAAK,SAAUD,EAAEe,SAEnEf,EAAE,QAAQoC,GAAG,QAAS,cAAe,WACnC,OAAOtC,EAAOE,EAAEe,SAEXf,EAAE,QAAQoC,GAAG,QAAS,YAAa,WACxC,OAAIpC,EAAE,aAAaqC,GAAG,aACpBrC,EAAE,aAAasC,OACftC,EAAE,yBAAyBM,YAAY,gBAChCN,EAAE,yBAAyBO,SAAS,YAE3CP,EAAE,aAAauC,OACfvC,EAAE,yBAAyBM,YAAY,UAChCN,EAAE,yBAAyBO,SAAS,uBAKhDiC,KAAKzB"}

View File

@ -153,6 +153,7 @@
"enterYubikey":"يرجى استخدام يوبي كي الخاص بك",
"errorMsg":"رسالة خاطئة",
"expired2Fremoved":"%s expired 2F devices have been removed!",
"explorer":"Explorer",
"ext2f":"Verification code",
"fillTheForm":"Fill the form",
"firstName":"الاسم الاول",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Benutze bitte deinen Yubikey",
"errorMsg":"Fehlermeldung",
"expired2Fremoved":"%s expired 2F devices have been removed!",
"explorer":"Explorer",
"ext2f":"Verification code",
"fillTheForm":"Fülle das Formular aus",
"firstName":"Vorname",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Please use your Yubikey",
"errorMsg":"Error Message",
"expired2Fremoved":"%s expired 2F devices have been removed!",
"explorer":"Explorer",
"ext2f":"Verification code",
"fillTheForm":"Fill the form",
"firstName":"First name",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Por favor utilice su Yubikey",
"errorMsg":"Mensaje de Error",
"expired2Fremoved":"¡%s dispositivos 2F caducados han sido suprimidos!",
"explorer":"Explorer",
"ext2f":"Código de verificación",
"fillTheForm":"Llene el formulario",
"firstName":"Nombre",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Please use your Yubikey",
"errorMsg":"Virhe viesti",
"expired2Fremoved":"%s expired 2F devices have been removed!",
"explorer":"Explorer",
"ext2f":"Verification code",
"fillTheForm":"Fill the form",
"firstName":"Etunimi",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Utilisez votre Yubikey",
"errorMsg":"Message d'erreur",
"expired2Fremoved":"%s seconds facteurs expirés ont été supprimés !",
"explorer":"Explorateur",
"ext2f":"Code de vérification",
"fillTheForm":"Remplissez le formulaire",
"forbidden":"Accès INTERDIT",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Utilizza il tuo Yubikey",
"errorMsg":"Messaggio di errore",
"expired2Fremoved":"%s expired 2F devices have been removed!",
"explorer":"Explorer",
"ext2f":"Verification code",
"fillTheForm":"Compila il modulo",
"firstName":"Nome",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Please use your Yubikey",
"errorMsg":"Error Message",
"expired2Fremoved":"%s expired 2F devices have been removed!",
"explorer":"Explorer",
"ext2f":"Verification code",
"fillTheForm":"Fill the form",
"firstName":"First name",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Please use your Yubikey",
"errorMsg":"Error Message",
"expired2Fremoved":"%s expired 2F devices have been removed!",
"explorer":"Explorer",
"ext2f":"Verification code",
"fillTheForm":"Fill the form",
"firstName":"First name",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Please use your Yubikey",
"errorMsg":"Error Message",
"expired2Fremoved":"%s expired 2F devices have been removed!",
"explorer":"Explorer",
"ext2f":"Verification code",
"fillTheForm":"Fill the form",
"firstName":"First name",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Lütfen Yubikey'inizi kullanın",
"errorMsg":"Hata Mesajı",
"expired2Fremoved":"Kullanım süresi dolan %s2F cihazı kaldırıldı!",
"explorer":"Explorer",
"ext2f":"Doğrulama Kodu",
"fillTheForm":"Formu doldur",
"firstName":"Ad",

View File

@ -153,6 +153,7 @@
"enterYubikey":"Vui lòng sử dụng Yubikey của bạn",
"errorMsg":"Thông báo lỗi",
"expired2Fremoved":"%s expired 2F devices have been removed!",
"explorer":"Explorer",
"ext2f":"Verification code",
"fillTheForm":"Fill the form",
"firstName":"Tên",

View File

@ -153,6 +153,7 @@
"enterYubikey":"请使用您的Yubikey",
"errorMsg":"错误消息",
"expired2Fremoved":"%s expired 2F devices have been removed!",
"explorer":"Explorer",
"ext2f":"Verification code",
"fillTheForm":"Fill the form",
"firstName":"名",

View File

@ -5,7 +5,7 @@
<span id="msg" trspan='<TMPL_VAR NAME="MSG">'></span>
</div>
<TMPL_IF NAME="NOTIFICATIONS">
<div class="card mb-3 border-secondary">
<div id="explorer" class="card mb-3 border-secondary">
<div class="card-body table-responsive">
<table class="table table-hover">
<thead>
@ -52,8 +52,14 @@
<span class="fa fa-home"></span>
<span trspan="goToPortal">Go to portal</span>
</a>
<span id="explorer-button" class="btn btn-info" role="button" hidden>
<span id='icon-explorer-button' class="fa fa-eye"></span>
<span id='text-explorer-button' class="explorer" trspan="explorer">Explorer</span>
</span>
</div>
<!-- //if:jsminified
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">/common/js/notifications.min.js"></script>
//else -->