From ab528402b2598fa26add97c142db756ef41d9da8 Mon Sep 17 00:00:00 2001 From: Pierre Date: Mon, 19 Feb 2018 14:09:15 +0100 Subject: [PATCH] Get the list of unread notifications from the server --- assets/js/components/notifications/dropdown.js | 13 +++++++++++-- .../js/components/notifications/interface.js | 18 +++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/assets/js/components/notifications/dropdown.js b/assets/js/components/notifications/dropdown.js index 06621545..667632f2 100644 --- a/assets/js/components/notifications/dropdown.js +++ b/assets/js/components/notifications/dropdown.js @@ -82,9 +82,18 @@ ComunicWeb.components.notifications.dropdown = { * * @param {HTMLElement} list The notifications list to refresh */ - refresh: function(list){ + refresh_list: function(list){ - //Perform a request on the database + //Perform a request on the API + ComunicWeb.components.notifications.interface.get_list_unread(function(result){ + + //Check for errors + if(result.error){ + ComunicWeb.common.notificationSystem.showNotification("An error occured while trying to retrieve notifications list !", "danger"); + return; + } + + }); }, } \ No newline at end of file diff --git a/assets/js/components/notifications/interface.js b/assets/js/components/notifications/interface.js index a4437b68..822db3b8 100644 --- a/assets/js/components/notifications/interface.js +++ b/assets/js/components/notifications/interface.js @@ -20,6 +20,22 @@ ComunicWeb.components.notifications.interface = { //Perform the request ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback); - } + }, + + /** + * Get the list of unread notifications + * + * @param {function} callback + */ + get_list_unread: function(callback){ + + //Perform API request + var apiURI = "notifications/get_list_unread"; + var params = {}; + + //Perform the request + ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback); + + }, } \ No newline at end of file