From 4ce04ec03bc8f362d48ded43833645e7f454cb5c Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 21 Jun 2013 15:07:44 +0200 Subject: Added blind transfer functionality for the switchboard. --- app/controllers/api/v1/calls_controller.rb | 24 ++++++++++++++++++++++ app/controllers/switchboard_entries_controller.rb | 2 +- app/views/switchboard_entries/_form_core.html.haml | 1 + app/views/switchboard_entries/show.html.haml | 5 +++++ app/views/switchboards/show.html.erb | 22 ++++++++++---------- config/routes.rb | 1 + public/js/app.js | 21 ++++++++----------- 7 files changed, 51 insertions(+), 25 deletions(-) create mode 100644 app/controllers/api/v1/calls_controller.rb diff --git a/app/controllers/api/v1/calls_controller.rb b/app/controllers/api/v1/calls_controller.rb new file mode 100644 index 0000000..e6fbed4 --- /dev/null +++ b/app/controllers/api/v1/calls_controller.rb @@ -0,0 +1,24 @@ +module Api + module V1 + class CallsController < ApplicationController + respond_to :json + + def index + @calls = Call.limit(10) + + respond_with @calls + end + + def show + @call = Call.find(params[:id]) + + if params[:transfer_blind] + @call.transfer_blind(params[:transfer_blind]) + end + + respond_with @call + end + + end + end +end diff --git a/app/controllers/switchboard_entries_controller.rb b/app/controllers/switchboard_entries_controller.rb index ef6c72e..5b41816 100644 --- a/app/controllers/switchboard_entries_controller.rb +++ b/app/controllers/switchboard_entries_controller.rb @@ -58,7 +58,7 @@ class SwitchboardEntriesController < ApplicationController private def switchboard_entry_params - params.require(:switchboard_entry).permit(:name, :sip_account_id) + params.require(:switchboard_entry).permit(:name, :sip_account_id, :switchable) end def spread_breadcrumbs diff --git a/app/views/switchboard_entries/_form_core.html.haml b/app/views/switchboard_entries/_form_core.html.haml index 6f340c2..2caaba5 100644 --- a/app/views/switchboard_entries/_form_core.html.haml +++ b/app/views/switchboard_entries/_form_core.html.haml @@ -1,3 +1,4 @@ .inputs = f.association :sip_account, :collection => @sip_accounts, :label => t('switchboard_entries.form.sip_account_id.label'), :hint => conditional_hint('switchboard_entries.form.sip_account_id.hint'), :autofocus => true, :include_blank => false = f.input :name, :label => t('switchboard_entries.form.name.label'), :hint => conditional_hint('switchboard_entries.form.name.hint') + = f.input :switchable, :as => :boolean, :label => t('switchboard_entries.form.switchable.label'), :hint => conditional_hint('switchboard_entries.form.switchable.hint') \ No newline at end of file diff --git a/app/views/switchboard_entries/show.html.haml b/app/views/switchboard_entries/show.html.haml index b519781..85b8166 100644 --- a/app/views/switchboard_entries/show.html.haml +++ b/app/views/switchboard_entries/show.html.haml @@ -18,5 +18,10 @@ %strong= t('switchboard_entries.show.position') + ":" %td = @switchboard_entry.position + %tr + %td + %strong= t('switchboard_entries.show.switchable') + ":" + %td + = @switchboard_entry.switchable = render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @switchboard, :child => @switchboard_entry } \ No newline at end of file diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index 2a2765f..4877613 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -26,16 +26,27 @@ {{avatar_img switchboardEntry.avatar_src}}

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

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

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

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

Anrufe: @@ -51,17 +62,6 @@

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

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

- {{/if}}
diff --git a/config/routes.rb b/config/routes.rb index 46562eb..eeb9c0b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,7 @@ Gemeinschaft42c::Application.routes.draw do resources :sip_accounts, :only => [:show, :index] resources :pager_groups resources :phone_numbers, :only => [:show, :index] + resources :calls, :only => [:index, :show, :update] end resources :rows diff --git a/public/js/app.js b/public/js/app.js index 51b3b71..da887c4 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1,5 +1,4 @@ App = Ember.Application.create({ - LOG_TRANSITIONS: true, rootElement: '#emberjs-container', // Reload the switchboard every x milliseconds @@ -9,11 +8,6 @@ App = Ember.Application.create({ var switchboard = App.Switchboard.find(switchboard_id); setInterval(function() { switchboard.reload(); - - // var switchboard_entries = App.SwitchboardEntry.find(); - // switchboard_entries.forEach(function(switchboard_entry) { - // switchboard_entry.reload(); - // }); }, reload_interval); } } @@ -32,8 +26,10 @@ App.SwitchboardRoute = Ember.Route.extend({ // Controller App.SwitchboardController = Ember.ObjectController.extend({ - blind_transfer: function() { - console.log('transfer') + transfer_blind: function(call_id, destination) { + console.log('test') + request_url = '/api/v1/calls/' + call_id + '.json'; + jQuery.get(request_url, { transfer_blind: destination }); } }); @@ -52,8 +48,6 @@ App.Switchboard = DS.Model.extend({ switchboardEntrys: DS.hasMany('App.SwitchboardEntry'), activeCalls: DS.hasMany('App.ActiveCall'), name: DS.attr('string') - - }); App.SwitchboardEntry = DS.Model.extend({ @@ -114,8 +108,7 @@ App.Call = DS.Model.extend({ } else { return false } - }.property('b_callstate') - + }.property('b_callstate') }); App.store.adapter.serializer.configure(App.PhoneNumber, { sideloadAs: 'phone_numbers' }); @@ -125,5 +118,7 @@ Ember.Handlebars.registerBoundHelper('avatar_img', function(value) { }); Ember.Handlebars.registerBoundHelper('show_callstate', function(value) { - return new Handlebars.SafeString('' + value + ''); + if (value) { + return new Handlebars.SafeString('' + value + ''); + } }); -- cgit v1.2.3