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