You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.1 KiB

  1. 'use strict';
  2. angular.module('app.notifications', ['ngRoute'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/notifications', {
  5. templateUrl: 'views/notifications/notifications.html',
  6. controller: 'NotificationsCtrl'
  7. });
  8. }])
  9. .controller('NotificationsCtrl', function($scope, $http) {
  10. $scope.notifications = [];
  11. $http.get(urlapi + 'notifications')
  12. .then(function(data) {
  13. //get the storage notifications
  14. if (localStorage.getItem("cr_webapp_notifications")) {
  15. $scope.notifications = JSON.parse(localStorage.getItem("cr_webapp_notifications"));
  16. $scope.notifications = $scope.notifications.concat(data.data); // for UI
  17. } else {
  18. $scope.notifications = data.data;
  19. }
  20. //store the notifications
  21. localStorage.setItem("cr_webapp_notifications", JSON.stringify($scope.notifications));
  22. }, function(data) {
  23. console.log('data error');
  24. toastr.error("Error connecting server");
  25. });
  26. });