Commit b25164ab authored by Evren Kutar's avatar Evren Kutar

Merge branch 'issue28'

parents efef9849 75197418
...@@ -32,16 +32,19 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST ...@@ -32,16 +32,19 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST
restrict: 'E', restrict: 'E',
replace: true, replace: true,
link: function ($scope) { link: function ($scope) {
$scope.groupNotifications = function (notifications) {
// notification categories:
// 1: tasks, 2: messages, 3: announcements, 4: recents
$scope.notifications = {1: [], 2: [], 3: [], 4: []};
angular.forEach(notifications, function (value, key) {
$scope.notifications[value.type].push(value);
});
};
$scope.getNotifications = function () { $scope.getNotifications = function () {
// ignore loading bar here // ignore loading bar here
$http.get(RESTURL.url+"notify", {ignoreLoadingBar: true}).success(function (data) { $http.get(RESTURL.url+"notify", {ignoreLoadingBar: true}).success(function (data) {
// notification categories: $scope.groupNotifications(data.notifications);
// 1: tasks, 2: messages, 3: announcements, 4: recents
$scope.notifications = {1: [], 2: [], 3: [], 4: []};
angular.forEach(data.notifications, function (value, key) {
$scope.notifications[value.type].push(value);
});
$rootScope.$broadcast("notifications", $scope.notifications); $rootScope.$broadcast("notifications", $scope.notifications);
}); });
}; };
...@@ -50,6 +53,7 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST ...@@ -50,6 +53,7 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST
// check notifications every 5 seconds // check notifications every 5 seconds
$interval(function () { $interval(function () {
console.log('get notification call - interval');
$scope.getNotifications(); $scope.getNotifications();
}, 5000); }, 5000);
...@@ -58,7 +62,8 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST ...@@ -58,7 +62,8 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST
$scope.markAsRead = function (items) { $scope.markAsRead = function (items) {
$http.post(RESTURL.url+"notify", {ignoreLoadingBar: true, read: [items]}) $http.post(RESTURL.url+"notify", {ignoreLoadingBar: true, read: [items]})
.success(function (data) { .success(function (data) {
console.log(data); $scope.groupNotifications(data.notifications);
$rootScope.$broadcast("notifications", $scope.notifications);
}); });
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment