summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-05-24 16:45:28 +0200
committerPeter Kozak <spag@golwen.net>2013-05-24 16:45:28 +0200
commitd323e95480e675c01c1c5c9fdfb25083c448de7f (patch)
treeaa85ccccccf44a5ab2304dfe385bfef58db6447d
parentffd1deac7e54df6892a1d6393dda1919b571c919 (diff)
switchboard calls
-rw-r--r--app/models/switchboard.rb4
-rw-r--r--app/serializers/sip_account_serializer.rb1
-rw-r--r--app/serializers/switchboard_serializer.rb1
-rw-r--r--app/views/switchboards/show.html.erb48
-rw-r--r--public/js/app.js39
5 files changed, 80 insertions, 13 deletions
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 @@
<div class='span12'>
<div id='emberjs-container'></div>
- <script type="text/x-handlebars" data-template-name="application">
+ <script type="text/x-handlebars">
{{outlet}}
</script>
@@ -24,19 +24,45 @@
<li class="span2">
<div class="thumbnail">
{{avatar_img switchboardEntry.avatar_src}}
- <p>
<small>
- {{switchboardEntry.name}}<br>
-
- {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}}
- <span class="label">
- {{phoneNumber.number}}
- </span>
- {{/each}}
- <br>
+ <p>
+ <span class="label">{{switchboardEntry.name}}</span>
+
+ {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}}
+ <span class="label">
+ {{phoneNumber.number}}
+ </span>
+ {{/each}}
+ </p>
+
{{show_callstate switchboardEntry.callstate}}
+ {{#if switchboardEntry.sipAccount.calls.length}}
+ <p>
+ Anrufe:
+ <br>
+ {{#each call in switchboardEntry.sipAccount.calls}}
+ <span {{bindAttr class=":label call.isActive:label-success"}}>
+ {{call.b_caller_id_number}} -> {{call.destination}}
+ {{#if call.isActive}}
+ *
+ {{/if}}
+ </span>
+ {{/each}}
+ </p>
+ {{/if}}
+
+ {{#if activeCalls.length}}
+ <p>
+ Verbinden mit:
+ <br>
+ {{#each activeCall in activeCalls}}
+ <button {{action blind_transfer}}>
+ {{activeCall.b_caller_id_number}}
+ </button>
+ {{/each}}
+ </p>
+ {{/if}}
</small>
- </p>
</div>
</li>
{{/each}}
diff --git a/public/js/app.js b/public/js/app.js
index 3124f41..893b4af 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -31,6 +31,11 @@ App.SwitchboardRoute = Ember.Route.extend({
});
// Controller
+App.SwitchboardController = Ember.ObjectController.extend({
+ blind_transfer: function() {
+ console.log('transfer')
+ }
+});
// Models
App.Store = DS.Store.extend({
@@ -47,7 +52,10 @@ DS.RESTAdapter.reopen({
App.Switchboard = DS.Model.extend({
switchboardEntrys: DS.hasMany('App.SwitchboardEntry'),
+ activeCalls: DS.hasMany('App.ActiveCall'),
name: DS.attr('string')
+
+
});
App.SwitchboardEntry = DS.Model.extend({
@@ -56,7 +64,15 @@ 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')
+});
+
+App.ActiveCall = 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')
});
App.Adapter = DS.RESTAdapter.extend();
@@ -69,6 +85,7 @@ App.store.adapter.serializer.configure(App.SwitchboardEntry, { sideloadAs: 'swit
App.SipAccount = DS.Model.extend({
switchboardEntrys: DS.hasMany('App.SwitchboardEntry'),
+ calls: DS.hasMany('App.Call'),
phoneNumbers: DS.hasMany('App.PhoneNumber'),
callerName: DS.attr('string'),
authName: DS.attr('string'),
@@ -82,7 +99,25 @@ App.SipAccount = DS.Model.extend({
App.PhoneNumber = DS.Model.extend({
name: DS.attr('string'),
- number: DS.attr('string')
+ number: DS.attr('string'),
+ destination: DS.attr('string')
+});
+
+App.Call = 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')
+
});
App.store.adapter.serializer.configure(App.PhoneNumber, { sideloadAs: 'phone_numbers' });