diff --git a/src/index.html b/src/index.html index 05861437a..cfe939803 100644 --- a/src/index.html +++ b/src/index.html @@ -161,9 +161,9 @@
{{ notification.messageJson | json }}
diff --git a/src/views/notifications.js b/src/views/notifications.js
index fbfb19b6c..506a4f13b 100644
--- a/src/views/notifications.js
+++ b/src/views/notifications.js
@@ -12,7 +12,7 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
busy: true,
refresh: function () {
- Client.getNotifications(false, 1, 100, function (error, result) {
+ Client.getNotifications({}, 1, 100, function (error, result) {
if (error) return console.error(error);
// collapse by default
@@ -31,69 +31,44 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
});
},
- clicked: function (notification) {
- if ($scope.notifications.activeNotification === notification) return $scope.notifications.activeNotification = null;
- $scope.notifications.activeNotification = notification;
- },
+ ack: function (notification, acked, event) {
+ if (event) event.stopPropagation();
- ackOne: function (id, callback) {
- Client.ackNotification(id, function (error) {
- if (error) return callback(error);
+ if (notification.acknowledged === acked) return;
- $scope.$parent.notificationAcknowledged(id);
-
- callback();
- });
- },
-
- ack: function (notification, event) {
- event.stopPropagation();
-
- $scope.notifications.ackOne(notification.id, function (error) {
+ Client.ackNotification(notification.id, acked, function (error) {
if (error) console.error(error);
- $scope.notifications.refresh();
+ notification.acknowledged = acked;
+ $scope.$parent.notificationAcknowledged(acked);
});
},
- action: function (notification) {
- if (notification.action) window.location = notification.action;
- },
-
clearAll: function () {
$scope.clearAllBusy = true;
async.eachLimit($scope.notifications.notifications, 20, function (notification, callback) {
if (notification.acknowledged) return callback();
- $scope.notifications.ackOne(notification.id, callback);
+
+ Client.ackNotification(notification.id, true, function (error) {
+ if (error) {
+ console.error(error);
+ } else {
+ notification.acknowledged = true;
+ $scope.$parent.notificationAcknowledged(true);
+ }
+
+ callback();
+ });
}, function (error) {
if (error) console.error(error);
- $scope.notifications.refresh();
$scope.clearAllBusy = false;
});
}
};
- $scope.notificationExpanding = function (notification) {
- if (!notification.eventId) return;
-
- notification.busyLoadEvent = true;
-
- Client.getEvent(notification.eventId, function (error, result) {
- notification.busyLoadEvent = false;
-
- if (error) return console.error(error);
-
- notification.event = result;
- });
- };
-
Client.onReady(function () {
$scope.notifications.refresh();
});
-
- Client.onReconnect(function () {
- $scope.notifications.refresh();
- });
}]);