Update angular-ui-notification and show unread notifications

This commit is contained in:
Johannes Zellner
2019-01-07 17:23:26 +01:00
parent 4051e34e20
commit 48f63ec761
13 changed files with 402 additions and 32 deletions
+26 -4
View File
@@ -201,14 +201,18 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
Client.notify('title', 'message', true, actionScope);
*/
Client.prototype.notify = function (title, message, persistent, type, actionScope) {
Client.prototype.notify = function (title, message, persistent, type, action) {
var options = { title: title, message: message};
if (persistent) options.delay = 'never'; // any non Number means never timeout
if (actionScope) {
if (typeof actionScope.action !== 'string') throw('an actionScope has to have an action url');
options.scope = actionScope;
if (action) {
options.onClick = function (/* params */) {
// if action is a string, we assume it is a link
if (typeof action === 'string' && action !== '') window.location = action;
else if (typeof action === 'function') action();
else console.warn('Notification action is not supported.', action);
};
}
if (type === 'error') Notification.error(options);
@@ -722,6 +726,24 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
});
};
Client.prototype.getNotifications = function (acknowledged, page, perPage, callback) {
var config = {
params: {
page: page,
per_page: perPage
}
};
if (typeof acknowledged === 'boolean') config.params.acknowledged = acknowledged;
get('/api/v1/notifications', config, function (error, data, status) {
if (error) return callback(error);
if (status !== 200) return callback(new ClientError(status, data));
callback(null, data.notifications);
});
};
Client.prototype.getEventLogs = function (actions, search, page, perPage, callback) {
var config = {
params: {