Move notifications into a separate view

This commit is contained in:
Johannes Zellner
2019-01-09 15:18:10 +01:00
parent e36c15f770
commit d2d75b8e41
6 changed files with 115 additions and 101 deletions
-58
View File
@@ -381,62 +381,6 @@ angular.module('Application').controller('AccountController', ['$scope', 'Client
});
}
$scope.notifications = {
notifications: [],
activeNotification: null,
busy: true,
all: false,
refresh: function () {
Client.getNotifications($scope.notifications.all ? null : false, 1, 20, function (error, result) {
if (error) return console.error(error);
$scope.notifications.notifications = result;
$scope.notifications.busy = false;
});
},
showOld: function () {
$scope.notifications.all = true;
$scope.notifications.refresh();
},
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 () {
Client.getOAuthClients(function (error, activeClients) {
if (error) return console.error(error);
@@ -453,8 +397,6 @@ angular.module('Application').controller('AccountController', ['$scope', 'Client
$scope.activeTokenCount += $scope.webadminClient ? $scope.webadminClient.activeTokens.length : 0;
});
});
$scope.notifications.refresh();
});
// setup all the dialog focus handling