Add notifications auto refresh

This commit is contained in:
Erik Kalkoken
2020-06-04 08:25:01 +00:00
committed by Ariel Rin
parent d92d629c25
commit 7d711a54bc
6 changed files with 63 additions and 12 deletions

View File

@@ -0,0 +1,27 @@
/*
Javascript for the base template
*/
$(function() {
var elem = document.getElementById("dataExport");
var notificationsRenderUrl = elem.getAttribute("data-notificationsRenderUrl");
// render the notifications item in the top menu
function render_notifications(){
$("#menu_item_notifications").load(
notificationsRenderUrl,
function(responseTxt, statusTxt, xhr){
if(statusTxt == "error")
console.log(
"Failed to load HTMl to render notifications item. Error: "
+ xhr.status
+ ": "
+ xhr.statusText
);
});
}
render_notifications()
// re-render notifications every x seconds
setInterval(render_notifications, 5000);
});