Skip already acknowledged notifications on clear
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div class="content">
|
||||
|
||||
<div class="text-left">
|
||||
<h1>Notifications <button class="btn btn-primary btn-outline pull-right" ng-click="notifications.clearAll()"><i class="fa fa-check"></i> Clear All</button></h1>
|
||||
<h1>Notifications <button class="btn btn-primary btn-outline pull-right" ng-click="notifications.clearAll()" ng-disabled="clearAllBusy"><i class="fa fa-circle-notch fa-spin" ng-show="clearAllBusy"></i><i class="fa fa-check" ng-hide="clearAllBusy"></i> Clear All</button></h1>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 text-center" ng-show="notifications.busy">
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
angular.module('Application').controller('NotificationsController', ['$scope', 'Client', function ($scope, Client) {
|
||||
|
||||
$scope.clearAllBusy = false;
|
||||
|
||||
$scope.notifications = {
|
||||
notifications: [],
|
||||
activeNotification: null,
|
||||
@@ -54,14 +56,15 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
|
||||
},
|
||||
|
||||
clearAll: function () {
|
||||
$scope.notifications.busy = true;
|
||||
$scope.clearAllBusy = true;
|
||||
|
||||
asyncForEach($scope.notifications.notifications, function (notification, callback) {
|
||||
if (notification.acknowledged) return callback();
|
||||
$scope.notifications.ack(notification, callback);
|
||||
}, function (error) {
|
||||
if (error) console.error(error);
|
||||
|
||||
$scope.notifications.busy = false;
|
||||
$scope.clearAllBusy = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user