diff --git a/app/assets/javascripts/app/controllers/_application_controller.coffee b/app/assets/javascripts/app/controllers/_application_controller.coffee index 176173dc3..e695c369e 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.coffee @@ -546,6 +546,15 @@ class App.Controller extends Spine.Controller return if !@initLoadingDoneDelay @clearDelay(@initLoadingDoneDelay) + renderScreenError: (data) -> + @html App.view('generic/error/generic')(data) + + renderScreenNotFound: (data) -> + @html App.view('generic/error/not_found')(data) + + renderScreenUnauthorized: (data) -> + @html App.view('generic/error/unauthorized')(data) + class App.ControllerPermanent extends App.Controller constructor: -> super diff --git a/app/assets/javascripts/app/controllers/chat.coffee b/app/assets/javascripts/app/controllers/chat.coffee index a26cbd98f..7bd2133c1 100644 --- a/app/assets/javascripts/app/controllers/chat.coffee +++ b/app/assets/javascripts/app/controllers/chat.coffee @@ -10,11 +10,17 @@ class App.CustomerChat extends App.Controller constructor: -> super - return if !@isRole('Chat') + # access check + if !@isRole('Chat') + @renderScreenUnauthorized(objectName: 'Chat') + return + if !@Config.get('chat') + @renderScreenError(detail: 'Feature disabled!') + return @chatWindows = {} @maxChats = 4 - + @pushStateStarted = false @messageCounter = 0 @meta = active: false @@ -26,21 +32,28 @@ class App.CustomerChat extends App.Controller @on 'layout-has-changed', @propagateLayoutChange + # update navbar on new status @bind( 'chat_status_agent' (data) => @meta = data @updateMeta() - @interval(@pushState, 20000, 'pushState') + if !@pushStateStarted + @pushStateStarted = true + @interval(@pushState, 30000, 'pushState') ) + + # add new chat window @bind( 'chat_session_start' (data) => if data.session @addChat(data.session) ) + + # on new login or on @bind( - 'ws:login' + 'ws:login chat_agent_state' -> App.WebSocket.send(event:'chat_status_agent') ) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index aaeb4cc7d..e9a6cb1e1 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -201,18 +201,18 @@ class App.TicketZoom extends App.Controller if status is 401 || statusText is 'Unauthorized' @taskHead = '» ' + App.i18n.translateInline('Unauthorized') + ' «' @taskIconClass = 'diagonal-cross' - @html App.view('generic/error/unauthorized')( objectName: 'Ticket' ) + @renderScreenUnauthorized(objectName: 'Ticket') else if status is 404 || statusText is 'Not Found' @taskHead = '» ' + App.i18n.translateInline('Not Found') + ' «' @taskIconClass = 'diagonal-cross' - @html App.view('generic/error/not_found')( objectName: 'Ticket' ) + @renderScreenNotFound(objectName: 'Ticket') else @taskHead = '» ' + App.i18n.translateInline('Error') + ' «' @taskIconClass = 'diagonal-cross' if !detail detail = 'General communication error, maybe internet is not available!' - @html App.view('generic/error/generic')( + @renderScreenError( status: status detail: detail objectName: 'Ticket' diff --git a/app/assets/javascripts/app/views/generic/error/generic.jst.eco b/app/assets/javascripts/app/views/generic/error/generic.jst.eco index 180360653..1a97ed816 100644 --- a/app/assets/javascripts/app/views/generic/error/generic.jst.eco +++ b/app/assets/javascripts/app/views/generic/error/generic.jst.eco @@ -1,4 +1,4 @@