Improved show error screens.
This commit is contained in:
parent
4df599b28a
commit
404c82f427
6 changed files with 35 additions and 9 deletions
|
@ -546,6 +546,15 @@ class App.Controller extends Spine.Controller
|
||||||
return if !@initLoadingDoneDelay
|
return if !@initLoadingDoneDelay
|
||||||
@clearDelay(@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
|
class App.ControllerPermanent extends App.Controller
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
|
|
@ -10,11 +10,17 @@ class App.CustomerChat extends App.Controller
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
|
||||||
return if !@isRole('Chat')
|
# access check
|
||||||
|
if !@isRole('Chat')
|
||||||
|
@renderScreenUnauthorized(objectName: 'Chat')
|
||||||
|
return
|
||||||
|
if !@Config.get('chat')
|
||||||
|
@renderScreenError(detail: 'Feature disabled!')
|
||||||
|
return
|
||||||
|
|
||||||
@chatWindows = {}
|
@chatWindows = {}
|
||||||
@maxChats = 4
|
@maxChats = 4
|
||||||
|
@pushStateStarted = false
|
||||||
@messageCounter = 0
|
@messageCounter = 0
|
||||||
@meta =
|
@meta =
|
||||||
active: false
|
active: false
|
||||||
|
@ -26,21 +32,28 @@ class App.CustomerChat extends App.Controller
|
||||||
|
|
||||||
@on 'layout-has-changed', @propagateLayoutChange
|
@on 'layout-has-changed', @propagateLayoutChange
|
||||||
|
|
||||||
|
# update navbar on new status
|
||||||
@bind(
|
@bind(
|
||||||
'chat_status_agent'
|
'chat_status_agent'
|
||||||
(data) =>
|
(data) =>
|
||||||
@meta = data
|
@meta = data
|
||||||
@updateMeta()
|
@updateMeta()
|
||||||
@interval(@pushState, 20000, 'pushState')
|
if !@pushStateStarted
|
||||||
|
@pushStateStarted = true
|
||||||
|
@interval(@pushState, 30000, 'pushState')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# add new chat window
|
||||||
@bind(
|
@bind(
|
||||||
'chat_session_start'
|
'chat_session_start'
|
||||||
(data) =>
|
(data) =>
|
||||||
if data.session
|
if data.session
|
||||||
@addChat(data.session)
|
@addChat(data.session)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# on new login or on
|
||||||
@bind(
|
@bind(
|
||||||
'ws:login'
|
'ws:login chat_agent_state'
|
||||||
->
|
->
|
||||||
App.WebSocket.send(event:'chat_status_agent')
|
App.WebSocket.send(event:'chat_status_agent')
|
||||||
)
|
)
|
||||||
|
|
|
@ -201,18 +201,18 @@ class App.TicketZoom extends App.Controller
|
||||||
if status is 401 || statusText is 'Unauthorized'
|
if status is 401 || statusText is 'Unauthorized'
|
||||||
@taskHead = '» ' + App.i18n.translateInline('Unauthorized') + ' «'
|
@taskHead = '» ' + App.i18n.translateInline('Unauthorized') + ' «'
|
||||||
@taskIconClass = 'diagonal-cross'
|
@taskIconClass = 'diagonal-cross'
|
||||||
@html App.view('generic/error/unauthorized')( objectName: 'Ticket' )
|
@renderScreenUnauthorized(objectName: 'Ticket')
|
||||||
else if status is 404 || statusText is 'Not Found'
|
else if status is 404 || statusText is 'Not Found'
|
||||||
@taskHead = '» ' + App.i18n.translateInline('Not Found') + ' «'
|
@taskHead = '» ' + App.i18n.translateInline('Not Found') + ' «'
|
||||||
@taskIconClass = 'diagonal-cross'
|
@taskIconClass = 'diagonal-cross'
|
||||||
@html App.view('generic/error/not_found')( objectName: 'Ticket' )
|
@renderScreenNotFound(objectName: 'Ticket')
|
||||||
else
|
else
|
||||||
@taskHead = '» ' + App.i18n.translateInline('Error') + ' «'
|
@taskHead = '» ' + App.i18n.translateInline('Error') + ' «'
|
||||||
@taskIconClass = 'diagonal-cross'
|
@taskIconClass = 'diagonal-cross'
|
||||||
|
|
||||||
if !detail
|
if !detail
|
||||||
detail = 'General communication error, maybe internet is not available!'
|
detail = 'General communication error, maybe internet is not available!'
|
||||||
@html App.view('generic/error/generic')(
|
@renderScreenError(
|
||||||
status: status
|
status: status
|
||||||
detail: detail
|
detail: detail
|
||||||
objectName: 'Ticket'
|
objectName: 'Ticket'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="fullscreenMessage">
|
<div class="fullscreenMessage">
|
||||||
<%- @Icon('diagonal-cross', 'icon-error') %>
|
<%- @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>
|
</div>
|
|
@ -17,6 +17,9 @@ class Sessions::Event::ChatAgentState < Sessions::Event::ChatBase
|
||||||
|
|
||||||
Chat::Agent.state(@session['id'], @data['data']['active'])
|
Chat::Agent.state(@session['id'], @data['data']['active'])
|
||||||
|
|
||||||
|
# broadcast new state to agents
|
||||||
|
broadcast_agent_state_update(@session['id'])
|
||||||
|
|
||||||
{
|
{
|
||||||
event: 'chat_agent_state',
|
event: 'chat_agent_state',
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -22,10 +22,11 @@ class Sessions::Event::ChatBase
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def broadcast_agent_state_update
|
def broadcast_agent_state_update(ignore_user_id = nil)
|
||||||
|
|
||||||
# send broadcast to agents
|
# send broadcast to agents
|
||||||
Chat::Agent.where(active: true).each {|item|
|
Chat::Agent.where(active: true).each {|item|
|
||||||
|
next if item.updated_by_id == ignore_user_id
|
||||||
data = {
|
data = {
|
||||||
event: 'chat_status_agent',
|
event: 'chat_status_agent',
|
||||||
data: Chat.agent_state(item.updated_by_id),
|
data: Chat.agent_state(item.updated_by_id),
|
||||||
|
|
Loading…
Reference in a new issue