-
+
+
+
+ |
{{ notification.title }}
|
-
- {{ notification.message }}
+ |
+
+ |
+
+
+ | {{ notification.message }} |
+
+
|
diff --git a/src/views/account.js b/src/views/account.js
index df2aa739e..0c06ade3b 100644
--- a/src/views/account.js
+++ b/src/views/account.js
@@ -12,7 +12,6 @@ angular.module('Application').controller('AccountController', ['$scope', 'Client
$scope.activeClients = [];
$scope.webadminClient = {};
$scope.apiClient = {};
- $scope.notifications = [];
$scope.twoFactorAuthentication = {
busy: false,
@@ -382,23 +381,54 @@ angular.module('Application').controller('AccountController', ['$scope', 'Client
});
}
- function refreshNotifications() {
- Client.getNotifications(false, 1, 100, function (error, result) {
- if (error) return console.error(error);
+ $scope.notifications = {
+ notifications: [],
+ activeNotification: null,
+ busy: true,
- $scope.notifications = result;
- });
- }
+ refresh: function () {
+ Client.getNotifications(false, 1, 100, function (error, result) {
+ if (error) return console.error(error);
- $scope.notificationClicked = function (notification) {
- Client.ackNotification(notification.id, function (error) {
- if (error) return console.error(error);
+ $scope.notifications.notifications = result;
- $scope.$parent.notificationAcknowledged(notification.id);
+ $scope.notifications.busy = false;
+ });
+ },
- if (notification.action) window.location = notification.action;
- else refreshNotifications();
- });
+ clicked: function (notification) {
+ if ($scope.notifications.activeNotification === notification) return $scope.notifications.activeNotification = null;
+ $scope.notifications.activeNotification = notification;
+ },
+
+ ack: function (notification, callback) {
+ callback = callback || function (error) { if (error) console.error(error); };
+
+ Client.ackNotification(notification.id, function (error) {
+ if (error) return callback(error);
+
+ $scope.$parent.notificationAcknowledged(notification.id);
+ $scope.notifications.refresh();
+
+ callback();
+ });
+ },
+
+ action: function (notification) {
+ if (notification.action) window.location = notification.action
+ },
+
+ clearAll: function () {
+ $scope.notifications.busy = true;
+
+ asyncForEach($scope.notifications.notifications, function (notification, callback) {
+ $scope.notifications.ack(notification, callback);
+ }, function (error) {
+ if (error) console.error(error);
+
+ $scope.notifications.busy = false;
+ });
+ }
};
Client.onReady(function () {
@@ -418,7 +448,7 @@ angular.module('Application').controller('AccountController', ['$scope', 'Client
});
});
- refreshNotifications();
+ $scope.notifications.refresh();
});
// setup all the dialog focus handling
|