Просмотр исходного кода

add notification to confirm unconfirmed emails

Tim Alby 8 лет назад
Родитель
Сommit
6f63cd7ca0

+ 27 - 0
services/web/app/views/project/list/notifications.pug

@@ -82,3 +82,30 @@ span(ng-controller="NotificationsController").userNotifications
 									button(ng-click="dismiss(notification)").close.pull-right
 										span(aria-hidden="true") ×
 										span.sr-only #{translate("close")}
+
+	ul.list-unstyled.notifications-list(
+		ng-controller="EmailNotificationController",
+		ng-cloak
+	)
+		li.notification_entry(
+			ng-repeat="userEmail in userEmails",
+			ng-if="!userEmail.confirmedAt && !userEmail.hide"
+		)
+			.row
+				.col-xs-12
+					.alert.alert-warning
+						.notification_inner(
+							ng-if="!userEmail.confirmationInflight"
+						)
+							| #{translate("please_confirm_email", {emailAddress: "{{ userEmail.email }}"})}
+							|
+							a(
+								href
+								ng-click="resendConfirmationEmail(userEmail)"
+							) (#{translate('resend_confirmation_email')})
+						.notification_inner(
+							ng-if="userEmail.confirmationInflight"
+						)
+							i.fa.fa-spinner.fa-spin
+							|
+							| #{translate('resending_confirmation_email')}…

+ 21 - 0
services/web/public/coffee/main/project-list/notifications-controller.coffee

@@ -53,3 +53,24 @@ define [
 				localStorage('overleaf_v1_notification_hidden_at', Date.now())
 			else
 				localStorage('overleaf_v1_notification_hidden_at', null)
+
+	App.controller "EmailNotificationController", ($scope, $http, UserAffiliationsDataService) ->
+		$scope.userEmails = []
+		for userEmail in $scope.userEmails
+			userEmail.hide = false
+
+		_getUserEmails = () ->
+			UserAffiliationsDataService
+				.getUserEmails().then (emails) ->
+					$scope.userEmails = emails
+					$scope.$emit "project-list:notifications-received"
+		_getUserEmails()
+
+		$scope.resendConfirmationEmail = (userEmail) ->
+			userEmail.confirmationInflight = true
+			UserAffiliationsDataService
+				.resendConfirmationEmail userEmail.email
+				.then () ->
+					userEmail.hide = true
+					userEmail.confirmationInflight = false
+					$scope.$emit "project-list:notifications-received"

+ 3 - 0
services/web/public/coffee/main/project-list/project-list.coffee

@@ -38,6 +38,9 @@ define [
 			recalculateProjectListHeight()
 			$scope.$apply()
 
+		$scope.$on "project-list:notifications-received", () ->
+			$scope.$applyAsync () -> recalculateProjectListHeight()
+
 		# Allow tags to be accessed on projects as well
 		projectsById = {}
 		for project in $scope.projects