2016-01-21 15:42:50 -05:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
|
|
|
|
2016-01-22 15:08:39 -05:00
|
|
|
App.controller "NotificationsController", ($scope, $http) ->
|
|
|
|
for notification in $scope.notifications
|
|
|
|
notification.hide = false
|
|
|
|
|
|
|
|
$scope.dismiss = (notification) ->
|
|
|
|
$http({
|
|
|
|
url: "/notifications/#{notification._id}"
|
|
|
|
method: "DELETE"
|
|
|
|
headers:
|
|
|
|
"X-Csrf-Token": window.csrfToken
|
|
|
|
})
|
2017-06-20 11:04:06 -04:00
|
|
|
.then () ->
|
2016-01-22 15:08:39 -05:00
|
|
|
notification.hide = true
|
2016-09-21 06:59:35 -04:00
|
|
|
|
|
|
|
App.controller "ProjectInviteNotificationController", ($scope, $http) ->
|
|
|
|
# Shortcuts for translation keys
|
|
|
|
$scope.projectName = $scope.notification.messageOpts.projectName
|
|
|
|
$scope.userName = $scope.notification.messageOpts.userName
|
|
|
|
|
|
|
|
$scope.accept = () ->
|
|
|
|
$scope.notification.inflight = true
|
|
|
|
$http({
|
2016-09-22 12:24:06 -04:00
|
|
|
url: "/project/#{$scope.notification.messageOpts.projectId}/invite/token/#{$scope.notification.messageOpts.token}/accept"
|
2016-09-21 06:59:35 -04:00
|
|
|
method: "POST"
|
|
|
|
headers:
|
|
|
|
"X-Csrf-Token": window.csrfToken
|
|
|
|
"X-Requested-With": "XMLHttpRequest"
|
|
|
|
})
|
2017-06-20 06:49:55 -04:00
|
|
|
.then () ->
|
2016-09-21 06:59:35 -04:00
|
|
|
$scope.notification.inflight = false
|
|
|
|
$scope.notification.accepted = true
|
2017-06-20 06:49:55 -04:00
|
|
|
.catch () ->
|
2016-09-21 06:59:35 -04:00
|
|
|
$scope.notification.inflight = false
|
2018-03-20 06:27:45 -04:00
|
|
|
$scope.notification.error = true
|
|
|
|
|
2018-03-20 09:50:51 -04:00
|
|
|
App.controller "OverleafV2NotificationController", ($scope, localStorage) ->
|
2018-08-28 07:16:39 -04:00
|
|
|
$scope.visible = !localStorage('overleaf_v2_2_notification_hidden_at')
|
2018-03-20 06:27:45 -04:00
|
|
|
|
|
|
|
$scope.dismiss = () ->
|
|
|
|
$scope.visible = false
|
2018-08-28 07:16:39 -04:00
|
|
|
localStorage('overleaf_v2_2_notification_hidden_at', Date.now())
|
2018-03-20 09:50:51 -04:00
|
|
|
|
|
|
|
App.controller "OverleafV1NotificationController", ($scope, localStorage) ->
|
|
|
|
$scope.visible = !localStorage('overleaf_v1_notification_hidden_at')
|
|
|
|
|
|
|
|
$scope.toggle = () ->
|
|
|
|
$scope.visible = !$scope.visible
|
|
|
|
if !$scope.visible
|
|
|
|
localStorage('overleaf_v1_notification_hidden_at', Date.now())
|
|
|
|
else
|
2018-08-28 07:16:39 -04:00
|
|
|
localStorage('overleaf_v1_notification_hidden_at', null)
|
2018-09-18 05:54:13 -04:00
|
|
|
|
|
|
|
App.controller "EmailNotificationController", ($scope, $http, UserAffiliationsDataService) ->
|
|
|
|
$scope.userEmails = []
|
|
|
|
|
|
|
|
_getUserEmails = () ->
|
|
|
|
UserAffiliationsDataService
|
|
|
|
.getUserEmails().then (emails) ->
|
|
|
|
$scope.userEmails = emails
|
|
|
|
_getUserEmails()
|
|
|
|
|
|
|
|
$scope.resendConfirmationEmail = (userEmail) ->
|
|
|
|
UserAffiliationsDataService
|
|
|
|
.resendConfirmationEmail userEmail.email
|