Prevent multiple online notification objects and replace ctrl+alt+y with ctrl+alt+a (because of issues in browsers).
This commit is contained in:
parent
e6ea12c75c
commit
fe9174da9c
6 changed files with 61 additions and 16 deletions
|
@ -49,6 +49,11 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|||
else
|
||||
@$('.bell').removeClass('show')
|
||||
|
||||
release: =>
|
||||
if @notificationWidget
|
||||
@notificationWidget.remove()
|
||||
@notificationWidget = undefined
|
||||
|
||||
renderMenu: =>
|
||||
items = @getItems( navbar: @Config.get( 'NavBar' ) )
|
||||
|
||||
|
@ -205,6 +210,8 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|||
@emptyAndClose()
|
||||
)
|
||||
|
||||
if @notificationWidget
|
||||
@notificationWidget.remove()
|
||||
@notificationWidget = new App.OnlineNotificationWidget()
|
||||
$('#app').append @notificationWidget.el
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ App.Config.set(
|
|||
$('#global-search').focus()
|
||||
}
|
||||
{
|
||||
key: 'y'
|
||||
key: 'a'
|
||||
hotkeys: true
|
||||
description: 'Notifications'
|
||||
callback: (e) ->
|
||||
|
|
|
@ -44,10 +44,12 @@ class App.OnlineNotificationWidget extends App.Controller
|
|||
@bind 'auth', (user) =>
|
||||
if !user
|
||||
@counterUpdate(0)
|
||||
else
|
||||
return
|
||||
if !@access()
|
||||
@counterUpdate(0)
|
||||
return
|
||||
if !@subscribeId
|
||||
@subscribeId = App.OnlineNotification.subscribe(@updateContent)
|
||||
|
||||
if @access()
|
||||
@subscribeId = App.OnlineNotification.subscribe(@updateContent)
|
||||
|
@ -69,9 +71,7 @@ class App.OnlineNotificationWidget extends App.Controller
|
|||
|
||||
access: ->
|
||||
return false if !@Session.get()
|
||||
return true if @isRole('Agent')
|
||||
return true if @isRole('Admin')
|
||||
return false
|
||||
return true
|
||||
|
||||
listNavigate: (e) =>
|
||||
if e.keyCode is 27 # close on esc
|
||||
|
@ -140,7 +140,9 @@ class App.OnlineNotificationWidget extends App.Controller
|
|||
heightPopoverSpacer = 22
|
||||
heightPopoverHeader = @header.outerHeight(true)
|
||||
isOverflowing = false
|
||||
heightPopoverContent = 0
|
||||
@item.each (i, el) =>
|
||||
|
||||
# accumulate height of items
|
||||
heightPopoverContent += el.clientHeight
|
||||
|
||||
|
@ -206,6 +208,7 @@ class App.OnlineNotificationWidget extends App.Controller
|
|||
@show()
|
||||
|
||||
show: =>
|
||||
return if !@access()
|
||||
$(window).on 'keydown.notifications', @listNavigate
|
||||
@shown = true
|
||||
@el.show()
|
||||
|
@ -230,3 +233,6 @@ class App.OnlineNotificationWidget extends App.Controller
|
|||
id = row.data('id')
|
||||
App.OnlineNotification.destroy(id)
|
||||
@updateHeight()
|
||||
|
||||
remove: =>
|
||||
@el.remove()
|
|
@ -15,6 +15,11 @@ class App.Track
|
|||
_instance ?= new _trackSingleton
|
||||
_instance.send()
|
||||
|
||||
@force: (value) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _trackSingleton
|
||||
_instance.force(value)
|
||||
|
||||
@_all: ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _trackSingleton
|
||||
|
@ -28,6 +33,8 @@ class _trackSingleton
|
|||
# @url = 'http://localhost:3005/api/v1/ui'
|
||||
@url = 'https://log.zammad.com/api/v1/ui'
|
||||
|
||||
@forceSending = false
|
||||
|
||||
@log('start', 'notice', {})
|
||||
|
||||
# start initial submit 30 sec. later to avoid ie10 cookie issues
|
||||
|
@ -104,9 +111,8 @@ class _trackSingleton
|
|||
return
|
||||
)
|
||||
|
||||
log: (facility, level, args) ->
|
||||
return if App.Config.get('developer_mode')
|
||||
return if !App.Config.get('ui_send_client_stats')
|
||||
log: (facility, level, args) =>
|
||||
return if !@shouldSend()
|
||||
info =
|
||||
time: Math.round(new Date().getTime() / 1000)
|
||||
facility: facility
|
||||
|
@ -116,8 +122,7 @@ class _trackSingleton
|
|||
@data.push info
|
||||
|
||||
send: (async = true) =>
|
||||
return if App.Config.get('developer_mode')
|
||||
return if !App.Config.get('ui_send_client_stats')
|
||||
return if !@shouldSend()
|
||||
return if _.isEmpty @data
|
||||
newData = _.clone(@data)
|
||||
@data = []
|
||||
|
@ -155,6 +160,15 @@ class _trackSingleton
|
|||
@data.push item
|
||||
)
|
||||
|
||||
force: (value = true) ->
|
||||
@forceSending = value
|
||||
|
||||
shouldSend: ->
|
||||
return true if @forceSending
|
||||
return false if App.Config.get('developer_mode')
|
||||
return false if !App.Config.get('ui_send_client_stats')
|
||||
true
|
||||
|
||||
_all: ->
|
||||
@data
|
||||
|
||||
|
|
|
@ -35,6 +35,21 @@ class KeyboardShortcutsTest < TestCase
|
|||
timeout: 2,
|
||||
)
|
||||
|
||||
# show notifications
|
||||
shortcut(key: 'a')
|
||||
watch_for(
|
||||
css: '.js-notificationsContainer .js-header',
|
||||
value: 'Notification',
|
||||
timeout: 10,
|
||||
)
|
||||
|
||||
shortcut(key: 'a')
|
||||
watch_for_disappear(
|
||||
css: '.js-notificationsContainer .js-header',
|
||||
value: 'Notification',
|
||||
timeout: 2,
|
||||
)
|
||||
|
||||
# go to overviews
|
||||
shortcut(key: 'o')
|
||||
watch_for(
|
||||
|
@ -172,7 +187,7 @@ class KeyboardShortcutsTest < TestCase
|
|||
},
|
||||
)
|
||||
sleep 5
|
||||
shortcut(key: 'y')
|
||||
shortcut(key: 'a')
|
||||
watch_for(
|
||||
css: '.js-notificationsContainer',
|
||||
value: 'Test Ticket for Shortcuts II',
|
||||
|
@ -183,7 +198,7 @@ class KeyboardShortcutsTest < TestCase
|
|||
watch_for(
|
||||
css: '.active.content',
|
||||
value: ticket2[:number],
|
||||
timeout: 2,
|
||||
timeout: 3,
|
||||
)
|
||||
|
||||
shortcut(key: 'e')
|
||||
|
|
|
@ -139,6 +139,9 @@ class TestCase < Test::Unit::TestCase
|
|||
instance.get(params[:url])
|
||||
end
|
||||
|
||||
# submit logs anyway
|
||||
instance.execute_script('App.Track.force()')
|
||||
|
||||
element = instance.find_elements(css: '#login input[name="username"]')[0]
|
||||
if !element
|
||||
|
||||
|
|
Loading…
Reference in a new issue