List unread notifications in accounts view

This commit is contained in:
Johannes Zellner
2019-01-07 18:05:02 +01:00
parent 2bc66af55d
commit fa04bea64b
2 changed files with 53 additions and 0 deletions
+20
View File
@@ -12,6 +12,7 @@ angular.module('Application').controller('AccountController', ['$scope', 'Client
$scope.activeClients = [];
$scope.webadminClient = {};
$scope.apiClient = {};
$scope.notifications = [];
$scope.twoFactorAuthentication = {
busy: false,
@@ -381,6 +382,23 @@ 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 = result;
});
}
$scope.notificationClicked = function (notification) {
Client.ackNotification(notification.id, function (error) {
if (error) return console.error(error);
if (notification.action) window.location = notification.action;
else refreshNotifications();
});
};
Client.onReady(function () {
Client.getOAuthClients(function (error, activeClients) {
if (error) return console.error(error);
@@ -397,6 +415,8 @@ angular.module('Application').controller('AccountController', ['$scope', 'Client
$scope.activeTokenCount += $scope.webadminClient ? $scope.webadminClient.activeTokens.length : 0;
});
});
refreshNotifications();
});
// setup all the dialog focus handling