diff --git a/app/assets/javascripts/app/controllers/navigation.coffee b/app/assets/javascripts/app/controllers/navigation.coffee index 8b5155af8..768a62fb6 100644 --- a/app/assets/javascripts/app/controllers/navigation.coffee +++ b/app/assets/javascripts/app/controllers/navigation.coffee @@ -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 diff --git a/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee b/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee index bd69223ed..64e82fe1f 100644 --- a/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee +++ b/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee @@ -83,7 +83,7 @@ App.Config.set( $('#global-search').focus() } { - key: 'y' + key: 'a' hotkeys: true description: 'Notifications' callback: (e) -> diff --git a/app/assets/javascripts/app/controllers/widget/online_notification.coffee b/app/assets/javascripts/app/controllers/widget/online_notification.coffee index f03bde6d7..391ce2a16 100644 --- a/app/assets/javascripts/app/controllers/widget/online_notification.coffee +++ b/app/assets/javascripts/app/controllers/widget/online_notification.coffee @@ -44,10 +44,12 @@ class App.OnlineNotificationWidget extends App.Controller @bind 'auth', (user) => if !user @counterUpdate(0) - else - if !@access() - @counterUpdate(0) - return + 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() \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/app_init/track.coffee b/app/assets/javascripts/app/lib/app_init/track.coffee index 5db73b967..160cfb1fa 100644 --- a/app/assets/javascripts/app/lib/app_init/track.coffee +++ b/app/assets/javascripts/app/lib/app_init/track.coffee @@ -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,11 +111,10 @@ 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 ) + time: Math.round(new Date().getTime() / 1000) facility: facility level: level location: window.location.pathname + window.location.hash @@ -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 diff --git a/test/browser/keyboard_shortcuts_test.rb b/test/browser/keyboard_shortcuts_test.rb index ad355a9e8..a2dc7f597 100644 --- a/test/browser/keyboard_shortcuts_test.rb +++ b/test/browser/keyboard_shortcuts_test.rb @@ -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') diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index d33dff2ae..7d663b5b1 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -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