Clear up to 1k unread notifications
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
<div class="title-toolbar">
|
<div class="title-toolbar">
|
||||||
<button class="btn btn-default" ng-click="showPrevPage()" ng-disabled="busy || currentPage <= 1"><i class="fa fa-angle-double-left"></i> {{ 'main.pagination.prev' | tr }}</button>
|
<button class="btn btn-default" ng-click="showPrevPage()" ng-disabled="busy || currentPage <= 1"><i class="fa fa-angle-double-left"></i> {{ 'main.pagination.prev' | tr }}</button>
|
||||||
<button class="btn btn-default" ng-click="showNextPage()" ng-disabled="busy || perPage > notifications.length">{{ 'main.pagination.next' | tr }} <i class="fa fa-angle-double-right"></i></button>
|
<button class="btn btn-default" ng-click="showNextPage()" ng-disabled="busy || perPage > notifications.length">{{ 'main.pagination.next' | tr }} <i class="fa fa-angle-double-right"></i></button>
|
||||||
<button class="btn btn-primary" ng-click="clearAll()" ng-disabled="!hasUnread || clearAllBusy"><i class="fa fa-circle-notch fa-spin" ng-show="clearAllBusy"></i><i class="fa fa-check" ng-hide="clearAllBusy"></i> {{ 'notifications.markAllAsRead' | tr }}</button>
|
<button class="btn btn-primary" ng-click="clearAll()" ng-disabled="!$parent.notificationCount || clearAllBusy"><i class="fa fa-circle-notch fa-spin" ng-show="clearAllBusy"></i><i class="fa fa-check" ng-hide="clearAllBusy"></i> {{ 'notifications.markAllAsRead' | tr }}</button>
|
||||||
</div>
|
</div>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+13
-19
@@ -11,7 +11,6 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
|
|||||||
$scope.notifications = [];
|
$scope.notifications = [];
|
||||||
$scope.activeNotification = null;
|
$scope.activeNotification = null;
|
||||||
$scope.busy = true;
|
$scope.busy = true;
|
||||||
$scope.hasUnread = false;
|
|
||||||
$scope.currentPage = 1;
|
$scope.currentPage = 1;
|
||||||
$scope.perPage = 20;
|
$scope.perPage = 20;
|
||||||
|
|
||||||
@@ -30,7 +29,6 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
|
|||||||
});
|
});
|
||||||
|
|
||||||
$scope.notifications = result;
|
$scope.notifications = result;
|
||||||
$scope.hasUnread = !!result.find(function (n) { return !n.acknowledged; });
|
|
||||||
|
|
||||||
$scope.busy = false;
|
$scope.busy = false;
|
||||||
});
|
});
|
||||||
@@ -62,26 +60,22 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
|
|||||||
$scope.clearAll = function () {
|
$scope.clearAll = function () {
|
||||||
$scope.clearAllBusy = true;
|
$scope.clearAllBusy = true;
|
||||||
|
|
||||||
async.eachLimit($scope.notifications, 20, function (notification, callback) {
|
Client.getNotifications({ acknowledged: false }, 1, 1000, function (error, results) { // hopefully 1k unread is sufficient
|
||||||
if (notification.acknowledged) return callback();
|
|
||||||
|
|
||||||
Client.ackNotification(notification.id, true, function (error) {
|
|
||||||
if (error) {
|
|
||||||
console.error(error);
|
|
||||||
} else {
|
|
||||||
notification.acknowledged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}, function (error) {
|
|
||||||
if (error) console.error(error);
|
if (error) console.error(error);
|
||||||
|
|
||||||
// refresh the main navbar indicator
|
async.eachLimit(results, 20, function (notification, callback) {
|
||||||
$scope.$parent.notificationAcknowledged();
|
Client.ackNotification(notification.id, true, function (error) {
|
||||||
|
if (error) console.error(error);
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}, function (error) {
|
||||||
|
if (error) console.error(error);
|
||||||
|
|
||||||
$scope.hasUnread = false;
|
// refresh the main navbar indicator
|
||||||
$scope.clearAllBusy = false;
|
$scope.$parent.notificationAcknowledged();
|
||||||
|
|
||||||
|
$scope.clearAllBusy = false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user