From e0c3ca61eeed9b9ac6d5786809e023f5dc27c069 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 24 Jun 2013 15:37:47 +0200 Subject: Added i18n for switchable. --- config/locales/views/switchboard_entries/de.yml | 5 +++++ config/locales/views/switchboard_entries/en.yml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/config/locales/views/switchboard_entries/de.yml b/config/locales/views/switchboard_entries/de.yml index 41804b5..e79b6e8 100644 --- a/config/locales/views/switchboard_entries/de.yml +++ b/config/locales/views/switchboard_entries/de.yml @@ -11,6 +11,7 @@ de: sip_account_id: 'SIP-Account' name: 'Name' position: 'Position' + switchable: 'Vermittelbar' actions: confirm_destroy: 'Sind Sie sicher, dass Sie folgendes löschen möchten: Switchboard-Eintrag' destroy: 'Löschen' @@ -24,6 +25,7 @@ de: sip_account_id: 'SIP-Account' name: 'Name' position: 'Position' + switchable: 'Vermittelbar' actions: confirm_destroy: 'Sind Sie sicher, dass die dieses Element löschen möchten?' destroy: 'Löschen' @@ -52,4 +54,7 @@ de: position: label: 'Position' hint: '' + switchable: + label: 'Vermittelbarer SIP-Account' + hint: 'Gespräche an diesen SIP-Account können im Switchboard vermittelt werden.' submit: 'Absenden' \ No newline at end of file diff --git a/config/locales/views/switchboard_entries/en.yml b/config/locales/views/switchboard_entries/en.yml index 71f2fe4..a964a41 100644 --- a/config/locales/views/switchboard_entries/en.yml +++ b/config/locales/views/switchboard_entries/en.yml @@ -11,6 +11,7 @@ en: sip_account_id: 'Sip account' name: 'Name' position: 'Position' + switchable: 'Switchable' actions: confirm_destroy: 'Are you sure you want to delete this Switchboardentry?' destroy: 'Delete' @@ -24,6 +25,7 @@ en: sip_account_id: 'Sip account' name: 'Name' position: 'Position' + switchable: 'Switchable' actions: confirm_destroy: 'Are you sure you want to delete this element?' destroy: 'Delete' @@ -52,4 +54,7 @@ en: position: label: 'Position' hint: '' + switchable: + label: 'Switchable SIP-Account' + hint: 'Only calls to switchable SIP-Accounts can be transfered.' submit: 'Submit' \ No newline at end of file -- cgit v1.2.3 From a24aee0fdfcbbc2200ad05ee5b789aec5988f1ad Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 24 Jun 2013 16:43:42 +0200 Subject: First step to provide an attended transfer. --- app/controllers/api/v1/calls_controller.rb | 17 +++++++++++++++++ app/views/switchboards/show.html.erb | 1 + public/js/app.js | 8 ++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/calls_controller.rb b/app/controllers/api/v1/calls_controller.rb index e6fbed4..329bd94 100644 --- a/app/controllers/api/v1/calls_controller.rb +++ b/app/controllers/api/v1/calls_controller.rb @@ -14,6 +14,23 @@ module Api if params[:transfer_blind] @call.transfer_blind(params[:transfer_blind]) + else + if params[:transfer_attended] && @call.b_sip_account.phones.first.phone_model.manufacturer.name == 'SNOM Technology AG' + phone = @call.b_sip_account.phones.first + ip_address = phone.ip_address + http_user = phone.http_user + http_password = phone.http_password + + # Hold + open("http://#{ip_address}/command.htm?key=F_HOLD", :http_basic_authentication=>[http_user, http_password]) + + # Call the other party + (0..(params[:transfer_attended].length - 1)).each do |i| + digit = params[:transfer_attended][i] + open("http://#{ip_address}/command.htm?key=#{digit}", :http_basic_authentication=>[http_user, http_password]) + end + open("http://#{ip_address}/command.htm?key=ENTER", :http_basic_authentication=>[http_user, http_password]) + end end respond_with @call diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index 1a8e5a0..f3304cf 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -50,6 +50,7 @@

{{#each activeCall in activeCalls}} + {{/each}}

{{/if}} diff --git a/public/js/app.js b/public/js/app.js index 6d8448a..efc0752 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -27,10 +27,14 @@ App.SwitchboardRoute = Ember.Route.extend({ // Controller App.SwitchboardController = Ember.ObjectController.extend({ transfer_blind: function(call_id, destination) { - console.log('test') request_url = '/api/v1/calls/' + call_id + '.json'; jQuery.get(request_url, { transfer_blind: destination }); - } + }, + + transfer_attended: function(call_id, destination) { + request_url = '/api/v1/calls/' + call_id + '.json'; + jQuery.get(request_url, { transfer_attended: destination }); + } }); // Models -- cgit v1.2.3 From 17f94f46374d60e58a00071303c9081469e7997c Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 25 Jun 2013 12:53:13 +0200 Subject: Optimized the active_calls method. Much faster now. Added a dispatchable_incoming_calls method. --- app/models/switchboard.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb index 095f878..73219e8 100644 --- a/app/models/switchboard.rb +++ b/app/models/switchboard.rb @@ -25,8 +25,13 @@ class Switchboard < ActiveRecord::Base } belongs_to :user, :touch => true + has_many :switchboard_entries, :dependent => :destroy + has_many :switchable_switchboard_entries, :class_name => "SwitchboardEntry", :conditions => {:switchable => true} + has_many :sip_accounts, :through => :switchboard_entries + has_many :switchable_sip_accounts, :source => :sip_account, :through => :switchable_switchboard_entries, :uniq => true + has_many :phone_numbers, :through => :sip_accounts before_validation :convert_0_to_nil @@ -36,7 +41,11 @@ class Switchboard < ActiveRecord::Base end def active_calls - self.switchboard_entries.where(:switchable => true).map{|se| se.sip_account}.uniq.map{|sip_account| sip_account.calls}.flatten + Call.where("sip_account_id = ? or b_sip_account_id = ?", self.switchable_sip_account_ids, self.switchable_sip_account_ids) + end + + def dispatchable_incoming_calls + Call.where("b_sip_account_id = ?", self.switchable_sip_account_ids) end private -- cgit v1.2.3 From 14da4be11fe13d4fcd55143c39b73c0d086b901b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 25 Jun 2013 13:09:07 +0200 Subject: Show transfer buttons only for switchable incoming calls. --- app/models/switchboard.rb | 6 +++--- app/serializers/switchboard_serializer.rb | 1 + app/views/switchboards/show.html.erb | 8 ++++---- public/js/app.js | 25 +++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb index 73219e8..d62657f 100644 --- a/app/models/switchboard.rb +++ b/app/models/switchboard.rb @@ -25,7 +25,7 @@ class Switchboard < ActiveRecord::Base } belongs_to :user, :touch => true - + has_many :switchboard_entries, :dependent => :destroy has_many :switchable_switchboard_entries, :class_name => "SwitchboardEntry", :conditions => {:switchable => true} @@ -41,11 +41,11 @@ class Switchboard < ActiveRecord::Base end def active_calls - Call.where("sip_account_id = ? or b_sip_account_id = ?", self.switchable_sip_account_ids, self.switchable_sip_account_ids) + Call.where("sip_account_id = ? or b_sip_account_id = ?", self.switchable_sip_account_ids, self.switchable_sip_account_ids).order(:start_stamp) end def dispatchable_incoming_calls - Call.where("b_sip_account_id = ?", self.switchable_sip_account_ids) + Call.where("b_sip_account_id = ?", self.switchable_sip_account_ids).order(:start_stamp) end private diff --git a/app/serializers/switchboard_serializer.rb b/app/serializers/switchboard_serializer.rb index 6d39667..7c21f82 100644 --- a/app/serializers/switchboard_serializer.rb +++ b/app/serializers/switchboard_serializer.rb @@ -6,4 +6,5 @@ class SwitchboardSerializer < ActiveModel::Serializer has_many :sip_accounts, :through => :switchboard_entries has_many :phone_numbers has_many :active_calls + has_many :dispatchable_incoming_calls end diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index f3304cf..69b0ed6 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -46,11 +46,11 @@ {{phoneNumber.number}} - {{#if activeCalls.length}} + {{#if dispatchableIncomingCalls.length}}

- {{#each activeCall in activeCalls}} - - + {{#each dispatchableIncomingCall in dispatchableIncomingCalls}} + + {{/each}}

{{/if}} diff --git a/public/js/app.js b/public/js/app.js index efc0752..1dee270 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -51,6 +51,7 @@ DS.RESTAdapter.reopen({ App.Switchboard = DS.Model.extend({ switchboardEntrys: DS.hasMany('App.SwitchboardEntry'), activeCalls: DS.hasMany('App.ActiveCall'), + dispatchableIncomingCalls: DS.hasMany('App.DispatchableIncomingCall'), name: DS.attr('string') }); @@ -87,6 +88,30 @@ App.ActiveCall = DS.Model.extend({ }.property('b_callstate') }); +App.DispatchableIncomingCall = DS.Model.extend({ + start_stamp: DS.attr('number'), + callstate: DS.attr('string'), + b_callstate: DS.attr('string'), + destination: DS.attr('string'), + b_caller_id_number: DS.attr('string'), + + isActive: function() { + if (this.get('b_callstate') == 'ACTIVE') { + return true + } else { + return false + } + }.property('b_callstate'), + + isRinging: function() { + if (this.get('b_callstate') == 'RINGING') { + return true + } else { + return false + } + }.property('b_callstate') +}); + App.Adapter = DS.RESTAdapter.extend(); App.store = App.Store.create({ -- cgit v1.2.3 From 1c6646bc732def369e54ef4ac576d748c6ba9c92 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 25 Jun 2013 13:19:26 +0200 Subject: GUI improvements. --- app/serializers/switchboard_entry_serializer.rb | 2 +- app/views/switchboards/show.html.erb | 40 +++++++++++++++---------- public/js/app.js | 3 +- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/app/serializers/switchboard_entry_serializer.rb b/app/serializers/switchboard_entry_serializer.rb index 1b6c761..5d76e16 100644 --- a/app/serializers/switchboard_entry_serializer.rb +++ b/app/serializers/switchboard_entry_serializer.rb @@ -1,5 +1,5 @@ class SwitchboardEntrySerializer < ActiveModel::Serializer - attributes :id, :name, :path_to_user, :avatar_src, :callstate + attributes :id, :name, :path_to_user, :avatar_src, :callstate, :switchable has_one :sip_account, embed: :ids has_one :switchboard, embed: :ids diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index 69b0ed6..b390ce5 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -40,22 +40,32 @@

{{/if}} -

- {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}} - - {{phoneNumber.number}} - + {{#if switchboardEntry.switchable}} +

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

+ {{else}} +

+ {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}} + + {{phoneNumber.number}} + - {{#if dispatchableIncomingCalls.length}} -

- {{#each dispatchableIncomingCall in dispatchableIncomingCalls}} - - - {{/each}} -

- {{/if}} - {{/each}} -

+ {{#if dispatchableIncomingCalls.length}} +

+ {{#each dispatchableIncomingCall in dispatchableIncomingCalls}} + + + {{/each}} +

+ {{/if}} + {{/each}} +

+ {{/if}} {{#if switchboardEntry.sipAccount.calls.length}}

diff --git a/public/js/app.js b/public/js/app.js index 1dee270..531e4b8 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -61,7 +61,8 @@ App.SwitchboardEntry = DS.Model.extend({ name: DS.attr('string'), path_to_user: DS.attr('string'), avatar_src: DS.attr('string'), - callstate: DS.attr('string') + callstate: DS.attr('string'), + switchable: DS.attr('boolean') }); App.ActiveCall = DS.Model.extend({ -- cgit v1.2.3