Added chat window details popover.

This commit is contained in:
Martin Edenhofer 2016-03-24 15:34:49 +01:00
parent 3b47640d01
commit 698f69d1b0
4 changed files with 51 additions and 10 deletions

View file

@ -366,14 +366,8 @@ class ChatWindow extends App.Controller
@isAgentTyping = false
@resetUnreadMessages()
chat = App.Chat.find(@session.chat_id)
@name = "#{chat.displayName()} [##{@session.id}]"
@title = ''
if @session && @session.preferences && @session.preferences.geo_ip
if @session.preferences.geo_ip.country_name
@title += @session.preferences.geo_ip.country_name
if @session.preferences.geo_ip.city_name
@title += " #{@session.preferences.geo_ip.city_name}"
@chat = App.Chat.find(@session.chat_id)
@name = "#{@chat.displayName()} ##{@session.id}"
@on 'layout-change', @scrollToBottom
@ -407,7 +401,6 @@ class ChatWindow extends App.Controller
render: ->
@html App.view('customer_chat/chat_window')
name: @name
title: @title
@el.one 'transitionend', @onTransitionend
@ -435,6 +428,21 @@ class ChatWindow extends App.Controller
@input.html(phrase)
@sendMessage(1600)
@$('.js-info').popover(
trigger: 'hover'
html: true
animation: false
delay: 0
placement: 'bottom'
container: 'body' # place in body do prevent it from animating
title: ->
App.i18n.translateContent('Details')
content: =>
App.view('customer_chat/chat_window_info')(
session: @session
)
)
focus: =>
@input.focus()

View file

@ -6,7 +6,7 @@
<%- @Icon('small-dot', 'icon-status-modified-inner-circle') %>
</div>
</div>
<div class="chat-name" title="<%= @title %>">
<div class="chat-name">
<%= @name %> <div class="status-badge js-info">
<div class="info-badge"><%- @Icon('info') %></div>
</div>

View file

@ -0,0 +1,16 @@
<ul>
<% if @session: %>
<li><%- @T('Created at') %>: <%- @Ttimestamp(@session.created_at) %>
<% end %>
<% if @session && @session.preferences: %>
<% if @session.preferences.geo_ip: %>
<li>GeoIP: <%= @session.preferences.geo_ip.country_name %> <%= @session.preferences.geo_ip.city_name %>
<% end %>
<% if @session.preferences.remote_ip: %>
<li>IP: <%= @session.preferences.remote_ip %>
<% end %>
<% if @session.preferences.dns_name: %>
<li>DNS: <%= @session.preferences.dns_name %>
<% end %>
<% end %>
</ul>

View file

@ -10,6 +10,22 @@ class Sessions::Event::ChatSessionInit < Sessions::Event::ChatBase
geo_ip = Service::GeoIp.location(@remote_ip)
end
# dns lookup
dns_name = nil
if @remote_ip
begin
dns = Resolv::DNS.new
dns.timeouts = 3
result = dns.getname @remote_ip
if result
dns_name = result.to_s
end
rescue => e
Rails.logger.error e.message
Rails.logger.error e.backtrace.inspect
end
end
# create chat session
chat_session = Chat::Session.create(
chat_id: @payload['data']['chat_id'],
@ -19,6 +35,7 @@ class Sessions::Event::ChatSessionInit < Sessions::Event::ChatBase
participants: [@client_id],
remote_ip: @remote_ip,
geo_ip: geo_ip,
dns_name: dns_name,
},
)