stable
Daniel García 2018-10-17 15:57:57 +02:00 committed by Alex Hermida
parent 529c91d9e9
commit d984507a3a
6 changed files with 33 additions and 22 deletions

View File

@ -113,6 +113,16 @@ class EventsService
if (permission == "granted")
subscribe()
webNotifications: ->
if not @.auth.userData?
return
userId = @.auth.userData.get('id')
routingKey = "web_notifications.#{userId}"
randomTimeout = taiga.randomInt(700, 1000)
@.subscribe null, routingKey, (data) =>
@rootScope.$broadcast "notifications:updated"
###########################################
# Heartbeat (Ping - Pong)
###########################################
@ -243,6 +253,7 @@ class EventsService
@.startHeartBeatMessages()
@.notifications()
@.liveNotifications()
@.webNotifications()
onMessage: (event) ->
@.log.debug "WebSocket message received: #{event.data}"

View File

@ -22,7 +22,7 @@ timeout = @.taiga.timeout
DropdownNotificationsDirective = ($rootScope, notificationsService, currentUserService) ->
link = ($scope, $el, $attrs, $ctrl) ->
$scope.notificationsList = []
$scope.loading = true
$scope.loading = false
$scope.$on "notifications:loaded", (event, total) ->
$scope.loading = false

View File

@ -12,8 +12,8 @@ div.navbar-dropdown-notifications(
)
.header
span.notifications-title {{ 'EVENTS.MY_EVENTS' | translate }}
a(href="", ng-click="setAllAsRead()") {{ 'EVENTS.DISMISS_ALL' | translate }}
a(tg-nav="notifications") {{ 'EVENTS.VIEW_ALL' | translate }}
a.action(href="", ng-class="{'disabled': !total}", ng-click="!total||setAllAsRead()") {{ 'EVENTS.DISMISS_ALL' | translate }}
a.action(tg-nav="notifications") {{ 'EVENTS.VIEW_ALL' | translate }}
.notifications-wrapper
.empty(ng-if="!total && !loading")

View File

@ -240,7 +240,8 @@ $dropdown-width: 350px;
.empty {
color: $gray-light;
padding: 2.5em 0;
font-size: .9em;
padding: 1.5em 0;
text-align: center;
width: 100%;
}
@ -250,23 +251,29 @@ $dropdown-width: 350px;
color: $gray;
display: flex;
flex-direction: row;
padding: .6rem 0 .5rem .7rem;
padding: .6rem .75rem;
.notifications-title {
flex-grow: 1;
text-transform: uppercase;
}
a {
color: $gray-light;
font-size: .9rem;
padding: 0 .7rem 0 0;
text-align: right;
}
a:hover {
.action {
font-size: .9rem;
padding-left: 1.2rem;
text-align: right;
&.disabled {
color: $gray-lighter;
cursor: default;
}
&:not(.disabled) {
color: $primary;
}
&:not(.disabled):hover {
color: $primary-light;
}
}
.notifications-wrapper {
min-height: 100px;
min-height: 70px;
}
.notifications-list {
max-height: 400px;

View File

@ -39,7 +39,6 @@ class NotificationsController extends mixOf(taiga.Controller, taiga.PageMixin, t
@.user = @currentUserService.getUser()
@.scrollDisabled = false
@.initList()
@.initializeSubscription()
@.loadNotifications()
@rootScope.$on "notifications:updated", (event) =>
@ -89,13 +88,5 @@ class NotificationsController extends mixOf(taiga.Controller, taiga.PageMixin, t
@notificationsService.setNotificationsAsRead().then =>
@rootScope.$emit("notifications:updated")
initializeSubscription: ->
routingKey = "web_notifications.#{@.user.get("id")}"
randomTimeout = taiga.randomInt(700, 1000)
@events.subscribe(
@scope,
routingKey,
debounceLeading(randomTimeout, (message) => @rootScope.$broadcast "notifications:updated")
)
angular.module("taigaNotifications").controller("Notifications", NotificationsController)

View File

@ -60,13 +60,15 @@
.notifications-list {
.entry {
border-bottom: 1px solid $whitish;
color: $blackish;
display: flex;
font-size: .9rem;
margin: 0 .8rem;
padding: .8rem 0;
position: relative;
&:not(:last-child) {
border-bottom: 1px solid $whitish;
}
p {
line-height: 1.25em;
margin-bottom: 0;