summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-14 20:21:59 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-03-14 20:21:59 +0100
commit3a0ea10cdd6084a8beb235f5c1573c22a5d733f0 (patch)
treeb46f34f8b88593af3bdcc164a563614d2dd41969 /app
parentf476fb7648fd235642233b2bbe5bb90cb57e8549 (diff)
Added a dashboard for Switchboard.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/trigger_controller.rb19
-rw-r--r--app/views/switchboard_entries/_switchboard_entry.html.haml28
-rw-r--r--app/views/switchboards/_current_user_dashboard.html.haml26
-rw-r--r--app/views/switchboards/show.html.haml23
4 files changed, 66 insertions, 30 deletions
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb
index 0c635b9..fc0556b 100644
--- a/app/controllers/trigger_controller.rb
+++ b/app/controllers/trigger_controller.rb
@@ -92,15 +92,18 @@ class TriggerController < ApplicationController
def sip_account_update
sip_account = SipAccount.find(params[:id])
- if sip_account && sip_account.switchboard_entries.any?
- # 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}');")
- end
+ # 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|
+ 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,
diff --git a/app/views/switchboard_entries/_switchboard_entry.html.haml b/app/views/switchboard_entries/_switchboard_entry.html.haml
index b2b6bff..8d4ee92 100644
--- a/app/views/switchboard_entries/_switchboard_entry.html.haml
+++ b/app/views/switchboard_entries/_switchboard_entry.html.haml
@@ -12,16 +12,22 @@
%small
= truncate(switchboard_entry.to_s, :length => 10)
%br
- - if !switchboard_entry.sip_account.registration
- %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
+ = switchboard_entry.sip_account.phone_numbers.first.number
+
+ %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}"
+
+ - 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
new file mode 100644
index 0000000..1c57a0d
--- /dev/null
+++ b/app/views/switchboards/_current_user_dashboard.html.haml
@@ -0,0 +1,26 @@
+.dashboard
+ - current_user.sip_accounts.each do |sip_account|
+ %table.table.table-striped
+ %thead
+ %tr
+ %td
+ SIP Account
+ %td
+ Direction
+ %td
+ StartStamp
+ %td
+ Destination
+ %td
+ CalleeName
+ %tbody
+ - sip_account.calls.each do |call|
+ %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
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