Merge branch 'develop' of github.com:martini/zammad into develop
# Conflicts: # public/assets/chat/chat.coffee
This commit is contained in:
commit
27ebc6a0a6
10 changed files with 85 additions and 32 deletions
|
@ -220,7 +220,7 @@ class chatWindow extends App.Controller
|
||||||
)
|
)
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
@html App.view('layout_ref/customer_chat_window')
|
@html App.view('customer_chat/chat_window')
|
||||||
name: @options.name
|
name: @options.name
|
||||||
|
|
||||||
@el.one 'transitionend', @onTransitionend
|
@el.one 'transitionend', @onTransitionend
|
||||||
|
@ -353,7 +353,7 @@ class chatWindow extends App.Controller
|
||||||
|
|
||||||
@lastAddedType = sender
|
@lastAddedType = sender
|
||||||
|
|
||||||
@body.append App.view('layout_ref/customer_chat_message')
|
@body.append App.view('customer_chat/chat_message')
|
||||||
message: message
|
message: message
|
||||||
sender: sender
|
sender: sender
|
||||||
isNew: isNew
|
isNew: isNew
|
||||||
|
@ -365,7 +365,7 @@ class chatWindow extends App.Controller
|
||||||
if !@isTyping
|
if !@isTyping
|
||||||
@isTyping = true
|
@isTyping = true
|
||||||
@maybeAddTimestamp()
|
@maybeAddTimestamp()
|
||||||
@body.append App.view('layout_ref/customer_chat_loader')()
|
@body.append App.view('customer_chat/chat_loader')()
|
||||||
@scrollToBottom()
|
@scrollToBottom()
|
||||||
|
|
||||||
# clear old delay, set new
|
# clear old delay, set new
|
||||||
|
@ -397,7 +397,7 @@ class chatWindow extends App.Controller
|
||||||
@lastAddedType = 'timestamp'
|
@lastAddedType = 'timestamp'
|
||||||
|
|
||||||
addTimestamp: (label, time) =>
|
addTimestamp: (label, time) =>
|
||||||
@body.append App.view('layout_ref/customer_chat_timestamp')
|
@body.append App.view('customer_chat/chat_timestamp')
|
||||||
label: label
|
label: label
|
||||||
time: time
|
time: time
|
||||||
|
|
||||||
|
@ -405,12 +405,12 @@ class chatWindow extends App.Controller
|
||||||
@body
|
@body
|
||||||
.find('.js-timestamp')
|
.find('.js-timestamp')
|
||||||
.last()
|
.last()
|
||||||
.replaceWith App.view('layout_ref/customer_chat_timestamp')
|
.replaceWith App.view('customer_chat/chat_timestamp')
|
||||||
label: label
|
label: label
|
||||||
time: time
|
time: time
|
||||||
|
|
||||||
addStatusMessage: (message) ->
|
addStatusMessage: (message) ->
|
||||||
@body.append App.view('layout_ref/customer_chat_status_message')
|
@body.append App.view('customer_chat/customer_chat_status_message')
|
||||||
message: message
|
message: message
|
||||||
|
|
||||||
@scrollToBottom()
|
@scrollToBottom()
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<div class="chat-message chat-message--customer chat-message--loader js-loader">
|
||||||
|
<div class="chat-loader">
|
||||||
|
<%- @Icon('loading') %>
|
||||||
|
<%- @Icon('loading') %>
|
||||||
|
<%- @Icon('loading') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1 @@
|
||||||
|
<div class="chat-message chat-message--<%= @sender %><%= ' chat-message--new' if @isNew %>"><%- @message %></div>
|
|
@ -0,0 +1 @@
|
||||||
|
<div class="chat-status-message"><%- @message %></div>
|
|
@ -0,0 +1 @@
|
||||||
|
<div class="chat-timestamp js-timestamp"><span class="chat-timestamp-label"><%= @label %></span> <%= @time %></div>
|
|
@ -0,0 +1,20 @@
|
||||||
|
<div class="chat-header">
|
||||||
|
<div class="chat-status js-status" data-status="online">
|
||||||
|
<div class="chat-status-holder">
|
||||||
|
<%- @Icon('status') %>
|
||||||
|
<%- @Icon('status-modified-outer-circle') %>
|
||||||
|
<%- @Icon('status-modified-inner-circle') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="chat-name"><%- @name %></div>
|
||||||
|
<div class="chat-close js-close">
|
||||||
|
<%- @Icon('diagonal-cross') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="chat-body-holder js-scrollHolder">
|
||||||
|
<div class="chat-body js-body"></div>
|
||||||
|
</div>
|
||||||
|
<div class="chat-controls">
|
||||||
|
<div class="chat-input form-control form-control--small form-control--multiline js-customerChatInput" contenteditable="true"></div>
|
||||||
|
<div class="btn btn--primary btn--slim btn--small js-send"><%= @T('Send') %></div>
|
||||||
|
</div>
|
|
@ -10,16 +10,13 @@ class Sessions::Event::ChatBase
|
||||||
def pre
|
def pre
|
||||||
|
|
||||||
# check if feature is enabled
|
# check if feature is enabled
|
||||||
if !Setting.get('chat')
|
return if Setting.get('chat')
|
||||||
return {
|
{
|
||||||
event: 'chat_error',
|
event: 'chat_error',
|
||||||
data: {
|
data: {
|
||||||
state: 'chat_disabled',
|
state: 'chat_disabled',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
|
||||||
|
|
||||||
false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def post
|
def post
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Sessions::Event::ChatSessionInit < Sessions::Event::ChatBase
|
||||||
|
|
||||||
# return new session
|
# return new session
|
||||||
{
|
{
|
||||||
event: 'chat_session_init',
|
event: 'chat_session_queue',
|
||||||
data: {
|
data: {
|
||||||
state: 'queue',
|
state: 'queue',
|
||||||
position: Chat.waiting_chat_count,
|
position: Chat.waiting_chat_count,
|
||||||
|
|
|
@ -36,15 +36,23 @@ class Sessions::Event::ChatSessionStart < Sessions::Event::ChatBase
|
||||||
session_id: chat_session.session_id,
|
session_id: chat_session.session_id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
chat_session.send_to_recipients(data, @client_id)
|
chat_session.send_to_recipients(data)
|
||||||
|
|
||||||
# send chat_session_init to agent
|
# send position update to other waiting sessions
|
||||||
{
|
position = 0
|
||||||
event: 'chat_session_start',
|
Chat::Session.where(state: 'waiting').order('created_at ASC').each {|local_chat_session|
|
||||||
data: {
|
position += 1
|
||||||
state: 'ok',
|
data = {
|
||||||
session: chat_session,
|
event: 'chat_session_queue',
|
||||||
},
|
data: {
|
||||||
|
state: 'queue',
|
||||||
|
position: position,
|
||||||
|
session_id: local_chat_session.session_id,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
local_chat_session.send_to_recipients(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,6 +19,7 @@ do($ = window.jQuery, window) ->
|
||||||
inputTimeout: null
|
inputTimeout: null
|
||||||
isTyping: false
|
isTyping: false
|
||||||
isOnline: true
|
isOnline: true
|
||||||
|
initialQueueDelay: 10000,
|
||||||
debug: true
|
debug: true
|
||||||
host: 'ws://localhost:6042'
|
host: 'ws://localhost:6042'
|
||||||
strings:
|
strings:
|
||||||
|
@ -94,9 +95,9 @@ do($ = window.jQuery, window) ->
|
||||||
|
|
||||||
onWebSocketMessage: (e) =>
|
onWebSocketMessage: (e) =>
|
||||||
pipes = JSON.parse( e.data )
|
pipes = JSON.parse( e.data )
|
||||||
@log 'debug', 'ws:onmessage', pipes
|
|
||||||
|
|
||||||
for pipe in pipes
|
for pipe in pipes
|
||||||
|
@log 'debug', 'ws:onmessage', pipe
|
||||||
switch pipe.event
|
switch pipe.event
|
||||||
when 'chat_session_message'
|
when 'chat_session_message'
|
||||||
return if pipe.data.self_written
|
return if pipe.data.self_written
|
||||||
|
@ -293,8 +294,24 @@ do($ = window.jQuery, window) ->
|
||||||
@el.find('.zammad-chat-input').prop('disabled', false)
|
@el.find('.zammad-chat-input').prop('disabled', false)
|
||||||
@el.find('.zammad-chat-send').prop('disabled', false)
|
@el.find('.zammad-chat-send').prop('disabled', false)
|
||||||
|
|
||||||
onQueue: (data) =>
|
onQueueScreen: (data) =>
|
||||||
@log 'notice', 'onQueue', data.position
|
|
||||||
|
# delay initial queue position, show connecting first
|
||||||
|
show = =>
|
||||||
|
@onQueue data.position
|
||||||
|
if @initialQueueDelay && !@onInitialQueueDelayId
|
||||||
|
@onInitialQueueDelayId = setTimeout(show, @initialQueueDelay)
|
||||||
|
return
|
||||||
|
|
||||||
|
# stop delay of initial queue position
|
||||||
|
if @onInitialQueueDelayId
|
||||||
|
clearTimeout(@onInitialQueueDelayId)
|
||||||
|
|
||||||
|
# show queue position
|
||||||
|
show()
|
||||||
|
|
||||||
|
onQueue: (position) =>
|
||||||
|
@log 'notice', 'onQueue', position
|
||||||
@inQueue = true
|
@inQueue = true
|
||||||
@setSessionId data.session_id
|
@setSessionId data.session_id
|
||||||
|
|
||||||
|
@ -406,11 +423,12 @@ do($ = window.jQuery, window) ->
|
||||||
@el.find('.zammad-chat-agent').addClass('zammad-chat-is-hidden')
|
@el.find('.zammad-chat-agent').addClass('zammad-chat-is-hidden')
|
||||||
@el.find('.zammad-chat-agent-status').addClass('zammad-chat-is-hidden')
|
@el.find('.zammad-chat-agent-status').addClass('zammad-chat-is-hidden')
|
||||||
|
|
||||||
setSessionId: (id) =>
|
onConnectionEstablished: (agent) =>
|
||||||
@sessionId = id
|
|
||||||
sessionStorage.setItem 'sessionId', id
|
# stop delay of initial queue position
|
||||||
|
if @onInitialQueueDelayId
|
||||||
|
clearTimeout(@onInitialQueueDelayId)
|
||||||
|
|
||||||
onConnectionEstablished: (data) =>
|
|
||||||
@inQueue = false
|
@inQueue = false
|
||||||
@agent = data.agent
|
@agent = data.agent
|
||||||
@setSessionId data.session_id
|
@setSessionId data.session_id
|
||||||
|
|
Loading…
Reference in a new issue