notifications-controller.coffee 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. define [
  2. "base"
  3. ], (App) ->
  4. App.controller "NotificationsController", ($scope, $http) ->
  5. for notification in $scope.notifications
  6. notification.hide = false
  7. $scope.dismiss = (notification) ->
  8. $http({
  9. url: "/notifications/#{notification._id}"
  10. method: "DELETE"
  11. headers:
  12. "X-Csrf-Token": window.csrfToken
  13. })
  14. .then () ->
  15. notification.hide = true
  16. App.controller "ProjectInviteNotificationController", ($scope, $http) ->
  17. # Shortcuts for translation keys
  18. $scope.projectName = $scope.notification.messageOpts.projectName
  19. $scope.userName = $scope.notification.messageOpts.userName
  20. $scope.accept = () ->
  21. $scope.notification.inflight = true
  22. $http({
  23. url: "/project/#{$scope.notification.messageOpts.projectId}/invite/token/#{$scope.notification.messageOpts.token}/accept"
  24. method: "POST"
  25. headers:
  26. "X-Csrf-Token": window.csrfToken
  27. "X-Requested-With": "XMLHttpRequest"
  28. })
  29. .then () ->
  30. $scope.notification.inflight = false
  31. $scope.notification.accepted = true
  32. .catch () ->
  33. $scope.notification.inflight = false
  34. $scope.notification.error = true