diff --git a/src/views/notifications.html b/src/views/notifications.html index 63749bb17..74f8aba23 100644 --- a/src/views/notifications.html +++ b/src/views/notifications.html @@ -1,14 +1,14 @@
-

{{ 'notifications.title' | tr }}

+

{{ 'notifications.title' | tr }}

-
+

-
+

{{ 'notifications.nonePending' | tr }}

@@ -16,14 +16,14 @@
-
+
{{ notification.title }} {{ notification.creationTime | prettyDate }} - + -
+

{{ notification.messageJson | json }}
diff --git a/src/views/notifications.js b/src/views/notifications.js index 506a4f13b..ee066fc2d 100644 --- a/src/views/notifications.js +++ b/src/views/notifications.js @@ -6,69 +6,67 @@ angular.module('Application').controller('NotificationsController', ['$scope', '$timeout', 'Client', function ($scope, $timeout, Client) { $scope.clearAllBusy = false; - $scope.notifications = { - notifications: [], - activeNotification: null, - busy: true, + $scope.notifications = []; + $scope.activeNotification = null; + $scope.busy = true; - refresh: function () { - Client.getNotifications({}, 1, 100, function (error, result) { - if (error) return console.error(error); + $scope.refresh = function () { + Client.getNotifications({}, 1, 100, function (error, result) { + if (error) return console.error(error); - // collapse by default - result.forEach(function (r) { r.isCollapsed = true; }); + // collapse by default + result.forEach(function (r) { r.isCollapsed = true; }); - // attempt to parse the message as json - result.forEach(function (r) { - try { - r.messageJson = JSON.parse(r.message); - } catch (e) {} - }); - - $scope.notifications.notifications = result; - - $scope.notifications.busy = false; + // attempt to parse the message as json + result.forEach(function (r) { + try { + r.messageJson = JSON.parse(r.message); + } catch (e) {} }); - }, - ack: function (notification, acked, event) { - if (event) event.stopPropagation(); + $scope.notifications = result; - if (notification.acknowledged === acked) return; + $scope.busy = false; + }); + }; - Client.ackNotification(notification.id, acked, function (error) { - if (error) console.error(error); + $scope.ack = function (notification, acked, event) { + if (event) event.stopPropagation(); - notification.acknowledged = acked; - $scope.$parent.notificationAcknowledged(acked); + if (notification.acknowledged === acked) return; + + Client.ackNotification(notification.id, acked, function (error) { + if (error) console.error(error); + + notification.acknowledged = acked; + $scope.$parent.notificationAcknowledged(acked); + }); + }; + + $scope.clearAll = function () { + $scope.clearAllBusy = true; + + async.eachLimit($scope.notifications, 20, function (notification, callback) { + if (notification.acknowledged) return 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); - clearAll: function () { - $scope.clearAllBusy = true; - - async.eachLimit($scope.notifications.notifications, 20, function (notification, callback) { - if (notification.acknowledged) return 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.clearAllBusy = false; - }); - } + $scope.clearAllBusy = false; + }); }; Client.onReady(function () { - $scope.notifications.refresh(); + $scope.refresh(); }); }]);