Improve notification view layout and add relevant actions

This commit is contained in:
Johannes Zellner
2019-01-08 13:18:35 +01:00
parent 9653d07ae2
commit 71eaf9966f
3 changed files with 72 additions and 29 deletions
+45 -15
View File
@@ -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