From d323e95480e675c01c1c5c9fdfb25083c448de7f Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 24 May 2013 16:45:28 +0200 Subject: switchboard calls --- app/models/switchboard.rb | 4 +++ app/serializers/sip_account_serializer.rb | 1 + app/serializers/switchboard_serializer.rb | 1 + app/views/switchboards/show.html.erb | 48 ++++++++++++++++++++++++------- 4 files changed, 43 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb index cf8c708..095f878 100644 --- a/app/models/switchboard.rb +++ b/app/models/switchboard.rb @@ -35,6 +35,10 @@ class Switchboard < ActiveRecord::Base self.name.to_s end + def active_calls + self.switchboard_entries.where(:switchable => true).map{|se| se.sip_account}.uniq.map{|sip_account| sip_account.calls}.flatten + end + private def convert_0_to_nil if self.reload_interval == 0 diff --git a/app/serializers/sip_account_serializer.rb b/app/serializers/sip_account_serializer.rb index c85c8a0..aa749b0 100644 --- a/app/serializers/sip_account_serializer.rb +++ b/app/serializers/sip_account_serializer.rb @@ -3,4 +3,5 @@ class SipAccountSerializer < ActiveModel::Serializer attributes :id, :auth_name, :caller_name, :sip_accountable_id has_many :phone_numbers + has_many :calls end diff --git a/app/serializers/switchboard_serializer.rb b/app/serializers/switchboard_serializer.rb index 600c79a..6d39667 100644 --- a/app/serializers/switchboard_serializer.rb +++ b/app/serializers/switchboard_serializer.rb @@ -5,4 +5,5 @@ class SwitchboardSerializer < ActiveModel::Serializer has_many :switchboard_entries has_many :sip_accounts, :through => :switchboard_entries has_many :phone_numbers + has_many :active_calls end diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index a240b55..2a2765f 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -11,7 +11,7 @@
- @@ -24,19 +24,45 @@
  • {{avatar_img switchboardEntry.avatar_src}} -

    - {{switchboardEntry.name}}
    - - {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}} - - {{phoneNumber.number}} - - {{/each}} -
    +

    + {{switchboardEntry.name}} + + {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}} + + {{phoneNumber.number}} + + {{/each}} +

    + {{show_callstate switchboardEntry.callstate}} + {{#if switchboardEntry.sipAccount.calls.length}} +

    + Anrufe: +
    + {{#each call in switchboardEntry.sipAccount.calls}} + + {{call.b_caller_id_number}} -> {{call.destination}} + {{#if call.isActive}} + * + {{/if}} + + {{/each}} +

    + {{/if}} + + {{#if activeCalls.length}} +

    + Verbinden mit: +
    + {{#each activeCall in activeCalls}} + + {{/each}} +

    + {{/if}}
    -

  • {{/each}} -- cgit v1.2.3