notifications: per user email prefs

This commit is contained in:
Girish Ramakrishnan
2024-12-11 18:24:20 +01:00
parent 746e694d7e
commit 6004cd17bf
12 changed files with 130 additions and 27 deletions
+24 -1
View File
@@ -1,7 +1,7 @@
'use strict';
/* global async */
/* global angular */
/* global angular, $ */
angular.module('Application').controller('NotificationsController', ['$scope', '$location', '$timeout', '$translate', '$interval', 'Client', function ($scope, $location, $timeout, $translate, $interval, Client) {
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); });
@@ -80,6 +80,29 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
});
};
$scope.settings = {
busy: false,
config: {},
show: function () {
for (const s of Client.getUserInfo().notificationConfig) {
$scope.settings.config[s] = true;
}
$('#notificationsSettingsModal').modal('show');
},
submit: function () {
const config = Object.keys($scope.settings.config).filter(c => $scope.settings.config[c] === true);
Client.setNotificationConfig(config, function (error) {
if (error) return Client.error(error);
Client.refreshConfig();
$('#notificationsSettingsModal').modal('hide');
});
},
};
Client.onReady(function () {
var refreshTimer = $interval($scope.refresh, 60 * 1000); // keep this interval in sync with the notification count indicator in main.js
$scope.$on('$destroy', function () {