mend
parent
529c91d9e9
commit
d984507a3a
|
@ -113,6 +113,16 @@ class EventsService
|
||||||
if (permission == "granted")
|
if (permission == "granted")
|
||||||
subscribe()
|
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)
|
# Heartbeat (Ping - Pong)
|
||||||
###########################################
|
###########################################
|
||||||
|
@ -243,6 +253,7 @@ class EventsService
|
||||||
@.startHeartBeatMessages()
|
@.startHeartBeatMessages()
|
||||||
@.notifications()
|
@.notifications()
|
||||||
@.liveNotifications()
|
@.liveNotifications()
|
||||||
|
@.webNotifications()
|
||||||
|
|
||||||
onMessage: (event) ->
|
onMessage: (event) ->
|
||||||
@.log.debug "WebSocket message received: #{event.data}"
|
@.log.debug "WebSocket message received: #{event.data}"
|
||||||
|
|
|
@ -22,7 +22,7 @@ timeout = @.taiga.timeout
|
||||||
DropdownNotificationsDirective = ($rootScope, notificationsService, currentUserService) ->
|
DropdownNotificationsDirective = ($rootScope, notificationsService, currentUserService) ->
|
||||||
link = ($scope, $el, $attrs, $ctrl) ->
|
link = ($scope, $el, $attrs, $ctrl) ->
|
||||||
$scope.notificationsList = []
|
$scope.notificationsList = []
|
||||||
$scope.loading = true
|
$scope.loading = false
|
||||||
|
|
||||||
$scope.$on "notifications:loaded", (event, total) ->
|
$scope.$on "notifications:loaded", (event, total) ->
|
||||||
$scope.loading = false
|
$scope.loading = false
|
||||||
|
|
|
@ -12,8 +12,8 @@ div.navbar-dropdown-notifications(
|
||||||
)
|
)
|
||||||
.header
|
.header
|
||||||
span.notifications-title {{ 'EVENTS.MY_EVENTS' | translate }}
|
span.notifications-title {{ 'EVENTS.MY_EVENTS' | translate }}
|
||||||
a(href="", ng-click="setAllAsRead()") {{ 'EVENTS.DISMISS_ALL' | translate }}
|
a.action(href="", ng-class="{'disabled': !total}", ng-click="!total||setAllAsRead()") {{ 'EVENTS.DISMISS_ALL' | translate }}
|
||||||
a(tg-nav="notifications") {{ 'EVENTS.VIEW_ALL' | translate }}
|
a.action(tg-nav="notifications") {{ 'EVENTS.VIEW_ALL' | translate }}
|
||||||
|
|
||||||
.notifications-wrapper
|
.notifications-wrapper
|
||||||
.empty(ng-if="!total && !loading")
|
.empty(ng-if="!total && !loading")
|
||||||
|
|
|
@ -240,7 +240,8 @@ $dropdown-width: 350px;
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
color: $gray-light;
|
color: $gray-light;
|
||||||
padding: 2.5em 0;
|
font-size: .9em;
|
||||||
|
padding: 1.5em 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -250,23 +251,29 @@ $dropdown-width: 350px;
|
||||||
color: $gray;
|
color: $gray;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
padding: .6rem 0 .5rem .7rem;
|
padding: .6rem .75rem;
|
||||||
.notifications-title {
|
.notifications-title {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
text-transform: uppercase;
|
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;
|
color: $primary;
|
||||||
}
|
}
|
||||||
|
&:not(.disabled):hover {
|
||||||
|
color: $primary-light;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.notifications-wrapper {
|
.notifications-wrapper {
|
||||||
min-height: 100px;
|
min-height: 70px;
|
||||||
}
|
}
|
||||||
.notifications-list {
|
.notifications-list {
|
||||||
max-height: 400px;
|
max-height: 400px;
|
||||||
|
|
|
@ -39,7 +39,6 @@ class NotificationsController extends mixOf(taiga.Controller, taiga.PageMixin, t
|
||||||
@.user = @currentUserService.getUser()
|
@.user = @currentUserService.getUser()
|
||||||
@.scrollDisabled = false
|
@.scrollDisabled = false
|
||||||
@.initList()
|
@.initList()
|
||||||
@.initializeSubscription()
|
|
||||||
@.loadNotifications()
|
@.loadNotifications()
|
||||||
|
|
||||||
@rootScope.$on "notifications:updated", (event) =>
|
@rootScope.$on "notifications:updated", (event) =>
|
||||||
|
@ -89,13 +88,5 @@ class NotificationsController extends mixOf(taiga.Controller, taiga.PageMixin, t
|
||||||
@notificationsService.setNotificationsAsRead().then =>
|
@notificationsService.setNotificationsAsRead().then =>
|
||||||
@rootScope.$emit("notifications:updated")
|
@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)
|
angular.module("taigaNotifications").controller("Notifications", NotificationsController)
|
||||||
|
|
|
@ -60,13 +60,15 @@
|
||||||
|
|
||||||
.notifications-list {
|
.notifications-list {
|
||||||
.entry {
|
.entry {
|
||||||
border-bottom: 1px solid $whitish;
|
|
||||||
color: $blackish;
|
color: $blackish;
|
||||||
display: flex;
|
display: flex;
|
||||||
font-size: .9rem;
|
font-size: .9rem;
|
||||||
margin: 0 .8rem;
|
margin: 0 .8rem;
|
||||||
padding: .8rem 0;
|
padding: .8rem 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
&:not(:last-child) {
|
||||||
|
border-bottom: 1px solid $whitish;
|
||||||
|
}
|
||||||
p {
|
p {
|
||||||
line-height: 1.25em;
|
line-height: 1.25em;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
|
Loading…
Reference in New Issue