PHRAS-3442_optimize-list-notifications_4.1-bis

WIP
poll only from menubar (Aina)
back : only one method/route to fetch notifs
front : fix exponential pagination
big refacto
todo : mark read notifications (button ? click ?)
This commit is contained in:
jygaulier
2021-06-15 17:46:14 +02:00
parent eec8a92ce9
commit 22c3b273f7
24 changed files with 710 additions and 628 deletions

View File

@@ -21,35 +21,37 @@ define([
eventManager: _.extend({}, Backbone.Events)
};
window.pullNotifications = function (){
$.ajax({
type: "POST",
url: AdminApp.$scope.data("notif-url"),
dataType: 'json',
data: {
module : 3,
usr : AdminApp.$scope.data("usr")
},
error: function(){
window.setTimeout("pullNotifications();", 10000);
},
timeout: function(){
window.setTimeout("pullNotifications();", 10000);
},
success: function(data){
if (data) {
if (data.status == 'disconnected' || data.status == 'session') {
self.location.replace(self.location.href);
}
}
var t = 120000;
if (data.apps && parseInt(data.apps) > 1) {
t = Math.round((Math.sqrt(parseInt(data.apps)-1) * 1.3 * 120000));
}
window.setTimeout("pullNotifications();", t);
}
});
};
// pull notification is called from menu bar
// window.pullNotifications = function (){
// $.ajax({
// type: "POST",
// url: AdminApp.$scope.data("notif-url"),
// dataType: 'json',
// data: {
// module : 3,
// usr : AdminApp.$scope.data("usr")
// },
// error: function(){
// window.setTimeout("pullNotifications();", 10000);
// },
// timeout: function(){
// window.setTimeout("pullNotifications();", 10000);
// },
// success: function(data){
// if (data) {
// if (data.status == 'disconnected' || data.status == 'session') {
// self.location.replace(self.location.href);
// }
// }
// var t = 120000;
// if (data.apps && parseInt(data.apps) > 1) {
// t = Math.round((Math.sqrt(parseInt(data.apps)-1) * 1.3 * 120000));
// }
// window.setTimeout("pullNotifications();", t);
// }
// });
// };
window.enableForms = function (forms) {
forms.bind('submit', function(event){
var method = $(this).attr('method');

View File

@@ -15,7 +15,7 @@ define([
var TaskCollection = Backbone.Collection.extend({
model: TaskModel,
url: function () {
return "/admin/task-manager/tasks";
return "/admin/task-manager/tasks?update_session=0";
}
});