Improved show error screens.

This commit is contained in:
Martin Edenhofer 2015-11-15 11:01:48 +01:00
parent 4df599b28a
commit 404c82f427
6 changed files with 35 additions and 9 deletions

View file

@ -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

View file

@ -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')
)

View file

@ -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'

View file

@ -1,4 +1,4 @@
<div class="fullscreenMessage">
<%- @Icon('diagonal-cross', 'icon-error') %>
<h2><%- @T('Status Code') %>: <%= @status %>. <%= @detail %></h2>
<h2><% if @status isnt undefined: %><%- @T('Status Code') %>: <%= @status %>. <% end %><%= @detail %></h2>
</div>

View file

@ -17,6 +17,9 @@ class Sessions::Event::ChatAgentState < Sessions::Event::ChatBase
Chat::Agent.state(@session['id'], @data['data']['active'])
# broadcast new state to agents
broadcast_agent_state_update(@session['id'])
{
event: 'chat_agent_state',
data: {

View file

@ -22,10 +22,11 @@ class Sessions::Event::ChatBase
false
end
def broadcast_agent_state_update
def broadcast_agent_state_update(ignore_user_id = nil)
# send broadcast to agents
Chat::Agent.where(active: true).each {|item|
next if item.updated_by_id == ignore_user_id
data = {
event: 'chat_status_agent',
data: Chat.agent_state(item.updated_by_id),