summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Pawlowski <julian.pawlowski@gmail.com>2013-03-14 22:22:16 +0100
committerJulian Pawlowski <julian.pawlowski@gmail.com>2013-03-14 22:22:16 +0100
commitebd0aa9c41f8ca6cf7de25c282efa759d7a1e273 (patch)
treeaffbe1fd88dd6bd8115593b91717d8d157d77b16
parent4b96a024bf77d96220ff06b3074556fbfa41bd7d (diff)
parent5ed3837a8688e46a33d3ad3b0eb0343eb1a5ba85 (diff)
Merge branch 'develop' of https://github.com/amooma/GS5 into develop
-rw-r--r--app/controllers/trigger_controller.rb39
-rw-r--r--app/views/switchboard_entries/_switchboard_entry.html.haml50
-rw-r--r--app/views/switchboards/_current_user_dashboard.html.haml33
-rw-r--r--app/views/switchboards/show.html.haml23
4 files changed, 98 insertions, 47 deletions
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb
index 623ea94..a858e33 100644
--- a/app/controllers/trigger_controller.rb
+++ b/app/controllers/trigger_controller.rb
@@ -92,28 +92,27 @@ class TriggerController < ApplicationController
def sip_account_update
sip_account = SipAccount.find(params[:id])
- if sip_account
- # push the partial to the webbrowser
- #
- sip_account.switchboard_entries.each do |switchboard_entry|
- new_html = ActionController::Base.helpers.escape_javascript(render_to_string("switchboard_entries/_switchboard_entry", :layout => false, :locals => {:switchboard_entry => switchboard_entry}))
- PrivatePub.publish_to("/switchboards/#{switchboard_entry.switchboard.id}", "$('#switchboard_entry_id_" + switchboard_entry.id.to_s + "').replaceWith('#{new_html}');")
+ # TO-DO: Only update the neccessary entries.
+ #
+ SwitchboardEntry.all.each do |switchboard_entry|
+ new_html = ActionController::Base.helpers.escape_javascript(render_to_string("switchboard_entries/_switchboard_entry", :layout => false, :locals => {:switchboard_entry => switchboard_entry}))
+ PrivatePub.publish_to("/switchboards/#{switchboard_entry.switchboard.id}", "$('#switchboard_entry_id_" + switchboard_entry.id.to_s + "').replaceWith('#{new_html}');")
+ end
+
+ Switchboard.all.each do |switchboard|
+ 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
-
- render(
- :status => 200,
- :layout => false,
- :content_type => 'text/plain',
- :text => "<!-- OK -->",
- )
- else
- render(
- :status => 501,
- :layout => false,
- :content_type => 'text/plain',
- :text => "<!-- ERRORS: #{errors.join(', ')} -->",
- )
end
+
+ render(
+ :status => 200,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- OK -->",
+ )
end
def fax
diff --git a/app/views/switchboard_entries/_switchboard_entry.html.haml b/app/views/switchboard_entries/_switchboard_entry.html.haml
index b2b6bff..8c44153 100644
--- a/app/views/switchboard_entries/_switchboard_entry.html.haml
+++ b/app/views/switchboard_entries/_switchboard_entry.html.haml
@@ -1,27 +1,45 @@
-%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.registration
+ - if switchboard_entry.sip_account.phone_numbers.any? && !switchboard_entry.sip_account.call_legs.where(callstate: 'ACTIVE').any? && !switchboard_entry.sip_account.b_call_legs.where(b_callstate: 'ACTIVE').any?
+ %span.label
+ = switchboard_entry.sip_account.phone_numbers.first.number
+
+ %br
+
+ - if switchboard_entry.sip_account.registration
+ - 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
+ = "#{switchboard_entry.sip_account.phone_numbers.first.number} => "
+ %span.label.label-info
+ = "#{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} =>"
+ %span.label
+ = switchboard_entry.sip_account.phone_numbers.first.number
+
+ - else
%span.label.label-inverse
%i.icon-ban-circle.icon-white
- - else
- - if switchboard_entry.sip_account.call_legs(:where => ["HELD", "ACTIVE"]).size != 0
- %span.label.label-success
- %i.icon-user.icon-white
- - if switchboard_entry.sip_account.call_legs(:where => ["RINGING"]).size != 0
- %span.label.label-info
- %i.icon-bell.icon-white
- - if switchboard_entry.sip_account.phone_numbers.any?
- %span.label
- = switchboard_entry.sip_account.phone_numbers.first.number
diff --git a/app/views/switchboards/_current_user_dashboard.html.haml b/app/views/switchboards/_current_user_dashboard.html.haml
new file mode 100644
index 0000000..8dd75b9
--- /dev/null
+++ b/app/views/switchboards/_current_user_dashboard.html.haml
@@ -0,0 +1,33 @@
+.dashboard
+ - current_user.sip_accounts.each do |sip_account|
+ %table.table.table-striped
+ %thead
+ %tr
+ %td
+ %td
+ Destination
+ %td
+ Start
+ %td{:span => '2'}
+ Caller
+ %tbody
+ - 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
+ %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
diff --git a/app/views/switchboards/show.html.haml b/app/views/switchboards/show.html.haml
index 2932366..a825806 100644
--- a/app/views/switchboards/show.html.haml
+++ b/app/views/switchboards/show.html.haml
@@ -1,20 +1,21 @@
-- content_for :title, @switchboard.name
+- content_for :title, "Switchboard #{@switchboard.name}"
.row
.span12
- .well.pull-right
- %p
- =current_user
+ = render :partial => "current_user_dashboard", :current_user => current_user
%ul.thumbnails
= render :partial => "switchboard_entries/switchboard_entry", :collection => @switchboard_entries
-- if can? :edit, @switchboard
- .row
- .span12
- %a.btn.btn-small.btn-warning{:href => switchboard_switchboard_entries_path(@switchboard) }
- %i.icon-edit.icon-white
- %span.hidden-phone
- =t("switchboard_entries.index.page_title")
+ - if can? :edit, @switchboard
+ .row
+ .span12
+ %a.btn.btn-small.btn-warning{:href => switchboard_switchboard_entries_path(@switchboard) }
+ %i.icon-edit.icon-white
+ %span.hidden-phone
+ =t("switchboard_entries.index.page_title")
+
+ .span6
+
= subscribe_to "/switchboards/#{@switchboard.id}" \ No newline at end of file