diff --git a/src/theme.scss b/src/theme.scss index 3a6e81d40..8f34452be 100644 --- a/src/theme.scss +++ b/src/theme.scss @@ -1027,6 +1027,14 @@ footer { background-color: white; } +// ---------------------------- +// Account/Notifications +// ---------------------------- + +.notification-details { + background-color: #e5e5e5 !important; +} + // ---------------------------- // Tag Input // ---------------------------- diff --git a/src/views/account.html b/src/views/account.html index 85e8d4da6..62a7c2522 100644 --- a/src/views/account.html +++ b/src/views/account.html @@ -286,27 +286,32 @@
-

Notifications

+

Notifications

-
+
+
+

+
+
+
- - - - - - - - - -
Title
+ + + + - + + + + 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
{{ notification.title }} + +
{{ notification.message }} +