summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-14 21:34:06 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-14 21:34:06 +0100
commit0b4e3dfd031b21c26f7bc9c7c05cd931950ecbd6 (patch)
treeca1e9ed8e63057e0310cf8e8c21e94dc699da64e
parent3a0ea10cdd6084a8beb235f5c1573c22a5d733f0 (diff)
Switchboard stuff
-rw-r--r--app/controllers/trigger_controller.rb7
-rw-r--r--app/views/switchboard_entries/_switchboard_entry.html.haml34
-rw-r--r--app/views/switchboards/_current_user_dashboard.html.haml35
3 files changed, 47 insertions, 29 deletions
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb
index fc0556b..a858e33 100644
--- a/app/controllers/trigger_controller.rb
+++ b/app/controllers/trigger_controller.rb
@@ -100,8 +100,11 @@ class TriggerController < ApplicationController
end
Switchboard.all.each do |switchboard|
- new_html = ActionController::Base.helpers.escape_javascript(render_to_string("switchboards/_current_user_dashboard", :layout => false, :locals => {:current_user => switchboard.user}))
- PrivatePub.publish_to("/switchboards/#{switchboard.id}", "$('.dashboard').replaceWith('#{new_html}');")
+ if sip_account.call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any? ||
+ sip_account.b_call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any?
+ new_html = ActionController::Base.helpers.escape_javascript(render_to_string("switchboards/_current_user_dashboard", :layout => false, :locals => {:current_user => switchboard.user}))
+ PrivatePub.publish_to("/switchboards/#{switchboard.id}", "$('.dashboard').replaceWith('#{new_html}');")
+ end
end
render(
diff --git a/app/views/switchboard_entries/_switchboard_entry.html.haml b/app/views/switchboard_entries/_switchboard_entry.html.haml
index 8d4ee92..b82bb74 100644
--- a/app/views/switchboard_entries/_switchboard_entry.html.haml
+++ b/app/views/switchboard_entries/_switchboard_entry.html.haml
@@ -1,16 +1,16 @@
-%li.span1{:id => "switchboard_entry_id_#{switchboard_entry.id}"}
+%li.span2{:id => "switchboard_entry_id_#{switchboard_entry.id}"}
%div.thumbnail
%a.thumbnail{:href => tenant_user_path(switchboard_entry.sip_account.sip_accountable.current_tenant, switchboard_entry.sip_account.sip_accountable)}
- if switchboard_entry.sip_account.sip_accountable.image?
- = image_tag(switchboard_entry.sip_account.sip_accountable.image_url(:small).to_s, :class => 'img-rounded')
+ = image_tag(switchboard_entry.sip_account.sip_accountable.image_url(:profile).to_s, :class => 'img-rounded', :style => 'width: 100px;')
- else
- if switchboard_entry.sip_account.sip_accountable.male?
- = image_tag 'icons/user-male-16x.png', :class => 'img-rounded'
+ = image_tag('icons/user-male-16x.png', :class => 'img-rounded', :style => 'width: 100px;')
- else
- = image_tag 'icons/user-female-16x.png', :class => 'img-rounded'
+ = image_tag('icons/user-female-16x.png', :class => 'img-rounded', :style => 'width: 100px;')
%p
%small
- = truncate(switchboard_entry.to_s, :length => 10)
+ = truncate(switchboard_entry.to_s, :length => 23)
%br
- if switchboard_entry.sip_account.phone_numbers.any?
%span.label
@@ -19,15 +19,23 @@
%br
- if switchboard_entry.sip_account.registration
- - switchboard_entry.sip_account.calls.each do |call|
- - if call.callstate == 'RINGING'
- %span.label.label-info
- %i.icon-bell.icon-white
- = "from #{call.callee_number}"
+ - switchboard_entry.sip_account.call_legs.where(callstate: 'RINGING').each do |call_leg|
+ %span.label.label-warning
+ %i.icon-bell.icon-white
+ = "#{call_leg.caller_id_number}"
+
+ - switchboard_entry.sip_account.call_legs.where(callstate: 'EARLY').each do |call_leg|
+ %span.label.label-info
+ = "calls #{call_leg.destination}"
+
+ - switchboard_entry.sip_account.call_legs.where(callstate: 'ACTIVE').each do |call_leg|
+ %span.label.label-info
+ = "#{call_leg.b_caller_id_number} => #{call_leg.callee_number}"
+
+ - switchboard_entry.sip_account.b_call_legs.where(b_callstate: 'ACTIVE').each do |b_call_leg|
+ %span.label.label-info
+ = "#{b_call_leg.b_caller_id_number} => #{b_call_leg.destination}"
- - if call.callstate == 'EARLY'
- %span.label.label-info
- = "calls #{call.destination}"
- else
%span.label.label-inverse
%i.icon-ban-circle.icon-white
diff --git a/app/views/switchboards/_current_user_dashboard.html.haml b/app/views/switchboards/_current_user_dashboard.html.haml
index 1c57a0d..8dd75b9 100644
--- a/app/views/switchboards/_current_user_dashboard.html.haml
+++ b/app/views/switchboards/_current_user_dashboard.html.haml
@@ -4,23 +4,30 @@
%thead
%tr
%td
- SIP Account
- %td
- Direction
- %td
- StartStamp
%td
Destination
%td
- CalleeName
+ Start
+ %td{:span => '2'}
+ Caller
%tbody
- - sip_account.calls.each do |call|
+ - sip_account.call_legs.where(callstate: 'RINGING').each do |call_leg|
+ %tr.warning
+ %td
+ %i.icon-bell
+ %td
+ %span.label.label-info
+ =sip_account.phone_numbers.first.to_s
+ %td=l Time.at(call_leg.start_stamp)
+ %td=call_leg.callee_name
+ %td=call_leg.callee_number
+
+ - sip_account.b_call_legs.where(direction: 'inbound').each do |call_leg|
%tr
%td
- - current_user.sip_accounts.each do |sip_account|
- %span.label.label-info
- =sip_account.phone_numbers.first.to_s
- %td=call.direction
- %td=l Time.at(call.start_stamp)
- %td=call.destination
- %td=call.callee_name \ No newline at end of file
+ %td
+ %span.label.label-info
+ =sip_account.phone_numbers.first.to_s
+ %td=l Time.at(call_leg.start_stamp)
+ %td=call_leg.b_caller_id_name
+ %td=call_leg.b_caller_id_number