From db9dbf03d88cfbd68ce99a242730b9e870339539 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 7 Mar 2013 13:15:35 +0100 Subject: Added Switchboard scaffold. --- app/controllers/switchboards_controller.rb | 65 ++++++++++++++++++++++++++++ app/helpers/switchboards_helper.rb | 2 + app/models/call_route.rb | 2 +- app/models/switchboard.rb | 14 ++++++ app/models/user.rb | 2 + app/views/switchboards/_form.html.haml | 7 +++ app/views/switchboards/_form_core.html.haml | 2 + app/views/switchboards/_index_core.html.haml | 10 +++++ app/views/switchboards/edit.html.haml | 3 ++ app/views/switchboards/index.html.haml | 8 ++++ app/views/switchboards/new.html.haml | 3 ++ app/views/switchboards/show.html.haml | 12 +++++ 12 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 app/controllers/switchboards_controller.rb create mode 100644 app/helpers/switchboards_helper.rb create mode 100644 app/models/switchboard.rb create mode 100644 app/views/switchboards/_form.html.haml create mode 100644 app/views/switchboards/_form_core.html.haml create mode 100644 app/views/switchboards/_index_core.html.haml create mode 100644 app/views/switchboards/edit.html.haml create mode 100644 app/views/switchboards/index.html.haml create mode 100644 app/views/switchboards/new.html.haml create mode 100644 app/views/switchboards/show.html.haml (limited to 'app') diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb new file mode 100644 index 0000000..8f21d5e --- /dev/null +++ b/app/controllers/switchboards_controller.rb @@ -0,0 +1,65 @@ +class SwitchboardsController < ApplicationController + load_and_authorize_resource :user + authorize_resource :switchboard, :through => :user + + def index + @switchboards = @user.switchboards + spread_breadcrumbs + end + + def show + @switchboard = @user.switchboards.find(params[:id]) + spread_breadcrumbs + end + + def new + @switchboard = @user.switchboards.build + spread_breadcrumbs + end + + def create + @switchboard = @user.switchboards.build(switchboard_params) + spread_breadcrumbs + if @switchboard.save + redirect_to user_switchboards_path(@user), :notice => t('switchboards.controller.successfuly_created') + else + render :new + end + end + + def edit + @switchboard = @user.switchboards.find(params[:id]) + spread_breadcrumbs + end + + def update + @switchboard = @user.switchboards.find(params[:id]) + spread_breadcrumbs + if @switchboard.update_attributes(switchboard_params) + redirect_to [@user, @switchboard], :notice => t('switchboards.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @switchboard = @user.switchboards.find(params[:id]) + @switchboard.destroy + spread_breadcrumbs + redirect_to user_switchboards_path(@user), :notice => t('switchboards.controller.successfuly_destroyed') + end + + private + def switchboard_params + params.require(:switchboard).permit(:name) + end + + def spread_breadcrumbs + add_breadcrumb t("users.index.page_title"), tenant_users_path(@user.current_tenant) + add_breadcrumb @user, tenant_user_path(@user.current_tenant, @user) + add_breadcrumb t("switchboards.index.page_title"), user_switchboards_path(@user) + if @switchboard && !@switchboard.new_record? + add_breadcrumb @switchboard, user_switchboard_path(@user, @switchboard) + end + end +end diff --git a/app/helpers/switchboards_helper.rb b/app/helpers/switchboards_helper.rb new file mode 100644 index 0000000..6fbea8a --- /dev/null +++ b/app/helpers/switchboards_helper.rb @@ -0,0 +1,2 @@ +module SwitchboardsHelper +end diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 8bc811a..6c54549 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -7,7 +7,7 @@ class CallRoute < ActiveRecord::Base has_many :route_elements, :dependent => :destroy, :order => :position validates :name, - :presence => true + :presence => true validates :routing_table, :presence => true, diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb new file mode 100644 index 0000000..cb0c70f --- /dev/null +++ b/app/models/switchboard.rb @@ -0,0 +1,14 @@ +class Switchboard < ActiveRecord::Base + # https://github.com/rails/strong_parameters + include ActiveModel::ForbiddenAttributesProtection + + validates :name, + :presence => true, + :uniqueness => {:scope => :user_id} + + belongs_to :user, :touch => true + + def to_s + self.name.to_s + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 913d75f..6091e32 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -94,6 +94,8 @@ class User < ActiveRecord::Base has_many :group_memberships, :as => :item, :dependent => :destroy, :uniq => true has_many :groups, :through => :group_memberships + has_many :switchboards, :dependent => :destroy + # Avatar like photo mount_uploader :image, ImageUploader diff --git a/app/views/switchboards/_form.html.haml b/app/views/switchboards/_form.html.haml new file mode 100644 index 0000000..bb09713 --- /dev/null +++ b/app/views/switchboards/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for([@user, @switchboard]) do |f| + = f.error_notification + + = render "form_core", :f => f + + .form-actions + = f.button :submit, conditional_t('switchboards.form.submit') diff --git a/app/views/switchboards/_form_core.html.haml b/app/views/switchboards/_form_core.html.haml new file mode 100644 index 0000000..61b5934 --- /dev/null +++ b/app/views/switchboards/_form_core.html.haml @@ -0,0 +1,2 @@ +.inputs + = f.input :name, :label => t('switchboards.form.name.label'), :hint => conditional_hint('switchboards.form.name.hint'), :autofocus => true diff --git a/app/views/switchboards/_index_core.html.haml b/app/views/switchboards/_index_core.html.haml new file mode 100644 index 0000000..858f624 --- /dev/null +++ b/app/views/switchboards/_index_core.html.haml @@ -0,0 +1,10 @@ +%table.table.table-striped + %tr + %th= t('switchboards.index.name') + %th + + + - for switchboard in switchboards + %tr + %td= switchboard.name + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => user, :child => switchboard} \ No newline at end of file diff --git a/app/views/switchboards/edit.html.haml b/app/views/switchboards/edit.html.haml new file mode 100644 index 0000000..1ab0efe --- /dev/null +++ b/app/views/switchboards/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("switchboards.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/switchboards/index.html.haml b/app/views/switchboards/index.html.haml new file mode 100644 index 0000000..4f29d7d --- /dev/null +++ b/app/views/switchboards/index.html.haml @@ -0,0 +1,8 @@ +- content_for :title, t("switchboards.index.page_title") + +.row + .span6 + - if @switchboards && @switchboards.count > 0 + = render :partial => "index_core", :locals => {:switchboards => @switchboards, :user => @user} + + = render :partial => 'shared/create_link', :locals => {:parent => @user, :child_class => Switchboard} \ No newline at end of file diff --git a/app/views/switchboards/new.html.haml b/app/views/switchboards/new.html.haml new file mode 100644 index 0000000..9f5918f --- /dev/null +++ b/app/views/switchboards/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("switchboards.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/switchboards/show.html.haml b/app/views/switchboards/show.html.haml new file mode 100644 index 0000000..746e180 --- /dev/null +++ b/app/views/switchboards/show.html.haml @@ -0,0 +1,12 @@ +- content_for :title, t("switchboards.show.page_title") + +.row + .span6 + %table.table.table-striped + %tr + %td + %strong= t('switchboards.show.name') + ":" + %td + = @switchboard.name + += render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @user, :child => @switchboard } \ No newline at end of file -- cgit v1.2.3 From 3cf3b921ee398472f2663cc1210932429f7710d9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 7 Mar 2013 07:18:46 -0500 Subject: target_group_ids_by_permission method added --- app/models/sip_account.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 81b9c1c..3340a76 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -155,12 +155,16 @@ class SipAccount < ActiveRecord::Base ); end - - def target_sip_accounts_by_permission(permission) + def target_group_ids_by_permission(permission) target_groups = Group.union(self.groups.collect{|g| g.permission_targets(permission)}) target_groups = target_groups + Group.union(self.sip_accountable.groups.collect{|g| g.permission_targets(permission)}) + + return target_groups + end + + def target_sip_accounts_by_permission(permission) sip_accounts = [] - GroupMembership.where(:group_id => target_groups).each do |group_membership| + GroupMembership.where(:group_id => target_group_ids_by_permission(permission)).each do |group_membership| if group_membership.item.class == User || group_membership.item.class == Tenant sip_accounts = sip_accounts + group_membership.item.sip_accounts elsif group_membership.item.class == SipAccount -- cgit v1.2.3 From 678baf479066ad6b517b3a97925a7e37bf5327e4 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 7 Mar 2013 07:38:44 -0500 Subject: softkey form fixed --- app/controllers/softkeys_controller.rb | 3 ++- app/models/softkey.rb | 22 ++++++++++++++++------ app/views/softkeys/_form_core.html.haml | 3 ++- 3 files changed, 20 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/controllers/softkeys_controller.rb b/app/controllers/softkeys_controller.rb index 9179d8c..6727de1 100644 --- a/app/controllers/softkeys_controller.rb +++ b/app/controllers/softkeys_controller.rb @@ -2,7 +2,7 @@ class SoftkeysController < ApplicationController load_and_authorize_resource :sip_account, :except => [:sort] load_and_authorize_resource :softkey, :through => [:sip_account], :except => [:sort] - before_filter :set_available_softkey_functions, :only => [ :new, :edit, :update ] + before_filter :set_available_softkey_functions, :only => [ :new, :edit, :update, :create ] before_filter :spread_breadcrumbs, :except => [:sort] def index @@ -35,6 +35,7 @@ class SoftkeysController < ApplicationController redirect_to sip_account_softkey_path(@softkey.sip_account, @softkey), :notice => t('softkeys.controller.successfuly_updated') else delete_call_forward_softkey_if_no_callforward_is_available + render :edit end end diff --git a/app/models/softkey.rb b/app/models/softkey.rb index 6063017..7f77a25 100644 --- a/app/models/softkey.rb +++ b/app/models/softkey.rb @@ -1,17 +1,17 @@ class Softkey < ActiveRecord::Base - attr_accessible :softkey_function_id, :number, :label, :uuid, :softkeyable_type, :softkeyable_id + attr_accessible :softkey_function_id, :number, :label, :uuid, :softkeyable_type, :softkeyable_id, :call_forward, :blf belongs_to :sip_account belongs_to :softkey_function belongs_to :softkeyable, :polymorphic => true - validates_presence_of :softkeyable_id, :if => Proc.new{ |softkey| self.softkey_function_id != nil && - self.softkey_function_id == SoftkeyFunction.find_by_name('call_forwarding').try(:id) } - # These functions need a number to act. # validates_presence_of :number, :if => Proc.new{ |softkey| self.softkey_function_id != nil && - ['blf','speed_dial','dtmf','conference'].include?(softkey.softkey_function.name) } + ['blf', 'speed_dial','dtmf','conference'].include?(softkey.softkey_function.name) } + + validates_presence_of :softkeyable_id, :if => Proc.new{ |softkey| self.softkey_function_id != nil && + ['call_forwarding'].include?(softkey.softkey_function.name) } validates_presence_of :uuid validates_uniqueness_of :uuid @@ -43,7 +43,16 @@ class Softkey < ActiveRecord::Base end def possible_blf_sip_accounts - self.sip_account.target_sip_accounts_by_permission('presence') + self.sip_account.target_sip_accounts_by_permission(:presence) + end + + def possible_pickup_groups + Group.where(:id => self.sip_account.target_group_ids_by_permission(:presence)) + end + + def possible_blf + blf = possible_pickup_groups.collect{ |g| ["#{g.class.name}: #{g.to_s}", "#{g.id}:#{g.class.name}"] } + blf + possible_blf_sip_accounts.collect{ |g| ["#{g.class.name}: #{g.to_s}", "#{g.id}:#{g.class.name}"] } end def to_s @@ -73,6 +82,7 @@ class Softkey < ActiveRecord::Base return self.position.to_i < Softkey.where(:sip_account_id => self.sip_account_id ).order(:position).last.position.to_i end + private # Make sure that no number is set when there is no need for one. # And make sure that there is no CallForward connected when not needed. diff --git a/app/views/softkeys/_form_core.html.haml b/app/views/softkeys/_form_core.html.haml index f447aa6..0e251f3 100644 --- a/app/views/softkeys/_form_core.html.haml +++ b/app/views/softkeys/_form_core.html.haml @@ -4,10 +4,11 @@ hold_function_name = "#{I18n.t('softkeys.functions.hold')}" deactivated_function_name = "#{I18n.t('softkeys.functions.deactivated')}" + .inputs = f.input :softkey_function_id, :as => :select, :collection => @softkey_functions.map {|x| [I18n.t("softkeys.functions.#{x}"), x.id] }, :label => t('softkeys.form.function.label'), :hint => conditional_hint('softkeys.form.function.hint'), :include_blank => false - call_forwards = @softkey.possible_call_forwards - if call_forwards && call_forwards.count > 0 - = f.association :softkeyable, :collection => call_forwards, :label => t('softkeys.form.call_forward.label'), :hint => conditional_hint('softkeys.form.call_forward.hint'), :include_blank => false + = f.input :softkeyable_id, :collection => call_forwards, :label => t('softkeys.form.call_forward.label'), :hint => conditional_hint('softkeys.form.call_forward.hint'), :include_blank => false = f.input :number, :label => t('softkeys.form.number.label'), :hint => conditional_hint('softkeys.form.number.hint') = f.input :label, :label => t('softkeys.form.label.label'), :hint => conditional_hint('softkeys.form.label.hint') -- cgit v1.2.3 From 800cf2f11ab5d7f03a52d5ca35e893654ef520ab Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 7 Mar 2013 15:22:06 -0500 Subject: call forwards view added --- app/models/hunt_group.rb | 3 ++- app/views/hunt_groups/show.html.haml | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/hunt_group.rb b/app/models/hunt_group.rb index 7338606..93279ae 100644 --- a/app/models/hunt_group.rb +++ b/app/models/hunt_group.rb @@ -2,7 +2,8 @@ class HuntGroup < ActiveRecord::Base attr_accessible :name, :strategy, :seconds_between_jumps, :phone_numbers_attributes belongs_to :tenant, :touch => true - has_many :call_forwards, :as => :destinationable, :dependent => :destroy + has_many :destrination_call_forwards, :as => :destinationable, :dependent => :destroy + has_many :call_forwards, :as => :call_forwardable, :dependent => :destroy validates_uniqueness_of :name, :scope => :tenant_id, :allow_nil => true, :allow_blank => true diff --git a/app/views/hunt_groups/show.html.haml b/app/views/hunt_groups/show.html.haml index 3ffe4f3..99eb3e0 100644 --- a/app/views/hunt_groups/show.html.haml +++ b/app/views/hunt_groups/show.html.haml @@ -19,6 +19,13 @@ %br = render :partial => 'shared/create_link', :locals => {:parent => @hunt_group, :child_class => PhoneNumber} +- if @hunt_group.call_forwards.count > 0 || can?(:create, @hunt_group.call_forwards.build) + %h2= t('call_forwards.index.page_title') + - if @hunt_group.call_forwards.count > 0 + = render "call_forwards/index_core", :call_forwards => @hunt_group.call_forwards + %br + = render :partial => 'shared/create_link', :locals => { :parent => @hunt_group, :child_class => CallForward } + %h2= t('hunt_groups.form.hunt_group_members.label') - if @hunt_group.hunt_group_members.count > 0 = render 'hunt_group_members/index_core', :hunt_group_members => @hunt_group.hunt_group_members -- cgit v1.2.3 From 2abc9cfb22e55b709a21b041e04a8221f605e9d7 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 7 Mar 2013 15:57:02 -0500 Subject: call forwards view added --- app/models/automatic_call_distributor.rb | 2 ++ app/views/automatic_call_distributors/show.html.haml | 7 +++++++ 2 files changed, 9 insertions(+) (limited to 'app') diff --git a/app/models/automatic_call_distributor.rb b/app/models/automatic_call_distributor.rb index 5807757..b9d7c51 100644 --- a/app/models/automatic_call_distributor.rb +++ b/app/models/automatic_call_distributor.rb @@ -5,6 +5,8 @@ class AutomaticCallDistributor < ActiveRecord::Base has_many :acd_agents, :dependent => :destroy has_many :phone_numbers, :as => :phone_numberable, :dependent => :destroy + has_many :call_forwards, :as => :call_forwardable, :dependent => :destroy + accepts_nested_attributes_for :phone_numbers, :reject_if => lambda { |phone_number| phone_number[:number].blank? }, :allow_destroy => true diff --git a/app/views/automatic_call_distributors/show.html.haml b/app/views/automatic_call_distributors/show.html.haml index a461652..18fd8b8 100644 --- a/app/views/automatic_call_distributors/show.html.haml +++ b/app/views/automatic_call_distributors/show.html.haml @@ -63,6 +63,13 @@ = render 'phone_numbers/index_core', :phone_numbers => @automatic_call_distributor.phone_numbers = render :partial => 'shared/create_link', :locals => {:parent => @automatic_call_distributor, :child_class => PhoneNumber, :short_link => true} +- if @automatic_call_distributor.call_forwards.count > 0 || can?(:create, @automatic_call_distributor.call_forwards.build) + %h3= t('call_forwards.index.page_title') + - if @automatic_call_distributor.call_forwards.count > 0 + = render "call_forwards/index_core", :call_forwards => @automatic_call_distributor.call_forwards + %br + = render :partial => 'shared/create_link', :locals => { :parent => @automatic_call_distributor, :child_class => CallForward } + - if can?( :index, @automatic_call_distributor.acd_agents ) %h3= t('automatic_call_distributors.index.acd_agents') = render 'acd_agents/index_core', :acd_agents => @automatic_call_distributor.acd_agents -- cgit v1.2.3 From 4d7d5ad238990582d6c90a25272f2141ea9a3b28 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 8 Mar 2013 05:50:02 -0500 Subject: toggle action added to acd_agents --- app/controllers/acd_agents_controller.rb | 32 +++++++++++++++++++----------- app/models/ability.rb | 5 +++++ app/models/acd_agent.rb | 9 +++++++++ app/models/sip_account.rb | 2 ++ app/views/acd_agents/_index_core.html.haml | 13 ++++++++++-- app/views/sip_accounts/show.html.haml | 7 +++++++ 6 files changed, 54 insertions(+), 14 deletions(-) (limited to 'app') diff --git a/app/controllers/acd_agents_controller.rb b/app/controllers/acd_agents_controller.rb index 4c08f68..e2aabdf 100644 --- a/app/controllers/acd_agents_controller.rb +++ b/app/controllers/acd_agents_controller.rb @@ -1,7 +1,7 @@ class AcdAgentsController < ApplicationController - load_and_authorize_resource :automatic_call_distributor - load_and_authorize_resource :acd_agent, :through => [:automatic_call_distributor] - + load_and_authorize_resource :automatic_call_distributor, :except => [:toggle] + load_and_authorize_resource :acd_agent, :through => [:automatic_call_distributor], :except => [:toggle] + load_and_authorize_resource :acd_agent, :only => [:toggle] before_filter :spread_breadcrumbs def index @@ -62,16 +62,24 @@ class AcdAgentsController < ApplicationController redirect_to automatic_call_distributor_acd_agents_path(@automatic_call_distributor), :notice => t('acd_agents.controller.successfuly_destroyed') end + def toggle + @acd_agent.toggle_status + redirect_to request.referer + end + + private def spread_breadcrumbs - if @automatic_call_distributor.automatic_call_distributorable.class == User - add_breadcrumb t("#{@automatic_call_distributor.automatic_call_distributorable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@automatic_call_distributor.automatic_call_distributorable.class.name.underscore.pluralize}_path" ).(@automatic_call_distributor.tenant) - add_breadcrumb @automatic_call_distributor.automatic_call_distributorable, method( :"tenant_#{@automatic_call_distributor.automatic_call_distributorable.class.name.underscore}_path" ).(@automatic_call_distributor.tenant, @automatic_call_distributor.automatic_call_distributorable) - end - add_breadcrumb t("automatic_call_distributors.index.page_title"), method( :"#{@automatic_call_distributor.automatic_call_distributorable.class.name.underscore}_automatic_call_distributors_path" ).(@automatic_call_distributor.automatic_call_distributorable) - add_breadcrumb @automatic_call_distributor, method( :"#{@automatic_call_distributor.automatic_call_distributorable.class.name.underscore}_automatic_call_distributor_path" ).(@automatic_call_distributor.automatic_call_distributorable, @automatic_call_distributor) - add_breadcrumb t("acd_agents.index.page_title"), automatic_call_distributor_acd_agents_path(@automatic_call_distributor) - if @acd_agent && !@acd_agent.new_record? - add_breadcrumb @acd_agent, automatic_call_distributor_acd_agent_path(@automatic_call_distributor, @acd_agent) + if @automatic_call_distributor + if @automatic_call_distributor.automatic_call_distributorable.class == User + add_breadcrumb t("#{@automatic_call_distributor.automatic_call_distributorable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@automatic_call_distributor.automatic_call_distributorable.class.name.underscore.pluralize}_path" ).(@automatic_call_distributor.tenant) + add_breadcrumb @automatic_call_distributor.automatic_call_distributorable, method( :"tenant_#{@automatic_call_distributor.automatic_call_distributorable.class.name.underscore}_path" ).(@automatic_call_distributor.tenant, @automatic_call_distributor.automatic_call_distributorable) + end + add_breadcrumb t("automatic_call_distributors.index.page_title"), method( :"#{@automatic_call_distributor.automatic_call_distributorable.class.name.underscore}_automatic_call_distributors_path" ).(@automatic_call_distributor.automatic_call_distributorable) + add_breadcrumb @automatic_call_distributor, method( :"#{@automatic_call_distributor.automatic_call_distributorable.class.name.underscore}_automatic_call_distributor_path" ).(@automatic_call_distributor.automatic_call_distributorable, @automatic_call_distributor) + add_breadcrumb t("acd_agents.index.page_title"), automatic_call_distributor_acd_agents_path(@automatic_call_distributor) + if @acd_agent && !@acd_agent.new_record? + add_breadcrumb @acd_agent, automatic_call_distributor_acd_agent_path(@automatic_call_distributor, @acd_agent) + end end end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 3cd1d4d..fe67547 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -170,6 +170,11 @@ class Ability can :manage, Ringtone, :ringtoneable_type => 'SipAccount', :ringtoneable_id => user.sip_account_ids can :create, Ringtone + # User can read and toggle status of ACD agents + # + can :read, AcdAgent, :destination_type => 'SipAccount', :destination_id => user.sip_account_ids + can :toggle, AcdAgent, :destination_type => 'SipAccount', :destination_id => user.sip_account_ids + # SoftkeyFunctions # can :read, SoftkeyFunction diff --git a/app/models/acd_agent.rb b/app/models/acd_agent.rb index 4be4700..61899f8 100644 --- a/app/models/acd_agent.rb +++ b/app/models/acd_agent.rb @@ -20,6 +20,15 @@ class AcdAgent < ActiveRecord::Base self.name || I18n.t('acd_agents.name') + ' ID ' + self.id.to_s end + def toggle_status + if self.status == 'active' + self.status = 'inactive' + else + self.status = 'active' + end + return self.save + end + private def set_presence dialplan_function = nil diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 1ff3c9a..a5b8bad 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -41,6 +41,8 @@ class SipAccount < ActiveRecord::Base has_many :call_legs, :class_name => 'Call' has_many :b_call_legs, :class_name => 'Call', :foreign_key => 'b_sip_account_id' + has_many :acd_agents, :as => :destination, :dependent => :destroy + # Delegations: # delegate :host, :to => :sip_domain, :allow_nil => true diff --git a/app/views/acd_agents/_index_core.html.haml b/app/views/acd_agents/_index_core.html.haml index c8967cd..f1172f2 100644 --- a/app/views/acd_agents/_index_core.html.haml +++ b/app/views/acd_agents/_index_core.html.haml @@ -1,8 +1,8 @@ %table.table.table-striped %thead %tr + %th %th= t('acd_agents.index.name') - %th= t('acd_agents.index.status') %th= t('acd_agents.index.last_call') %th= t('acd_agents.index.calls_answered') %th= t('acd_agents.index.destination') @@ -10,8 +10,17 @@ %tbody - for acd_agent in acd_agents %tr + %td + - if acd_agent.status == 'active' + %a.btn.btn-small.btn-success{ :href => toggle_acd_agent_path(acd_agent) } + %i.icon-ok.icon-white + - elsif acd_agent.status == 'inactive' + %a.btn.btn-small.btn-danger{ :href => toggle_acd_agent_path(acd_agent) } + %i.icon-ban-circle.icon-white + - else + %a.btn.btn-small.btn-warning{ :href => toggle_acd_agent_path(acd_agent) } + = acd_agent.status %td= acd_agent.name - %td= acd_agent.status %td= acd_agent.last_call %td= acd_agent.calls_answered %td= acd_agent.destination diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml index 365aea8..9f84c92 100644 --- a/app/views/sip_accounts/show.html.haml +++ b/app/views/sip_accounts/show.html.haml @@ -99,3 +99,10 @@ - if @sip_account.calls.count > 0 %h2= t("calls.index.page_title") = render "calls/index_core", :calls => @sip_account.calls, :parent => @sip_account + +- if (can?(:read, AcdAgent) && @sip_account.acd_agents.count > 0) || can?(:create, @sip_account.acd_agents.build) + %h2= t('acd_agents.index.page_title') + - if @sip_account.acd_agents.count > 0 + = render "acd_agents/index_core", :acd_agents => @sip_account.acd_agents + %br + = render :partial => 'shared/create_link', :locals => { :parent => @sip_account, :child_class => AcdAgent } -- cgit v1.2.3 From 6374c0b3e38dfc74eb1b4a5a1fcc5229eacdcaf2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Fri, 8 Mar 2013 12:09:17 +0100 Subject: Added SwitchboardEntry scaffold. switchboard has_many switchboard_entries --- app/assets/javascripts/switchboard_entry.js.coffee | 6 ++ app/assets/stylesheets/application.css | 1 + .../stylesheets/switchboard_entries.css.scss | 5 ++ app/controllers/switchboard_entries_controller.rb | 74 ++++++++++++++++++++++ app/helpers/switchboard_entries_helper.rb | 2 + app/models/sip_account.rb | 2 + app/models/switchboard.rb | 2 + app/models/switchboard_entry.rb | 30 +++++++++ app/views/switchboard_entries/_form.html.haml | 7 ++ app/views/switchboard_entries/_form_core.html.haml | 3 + .../switchboard_entries/_index_core.html.haml | 16 +++++ app/views/switchboard_entries/edit.html.haml | 3 + app/views/switchboard_entries/index.html.haml | 6 ++ app/views/switchboard_entries/new.html.haml | 3 + app/views/switchboard_entries/show.html.haml | 22 +++++++ 15 files changed, 182 insertions(+) create mode 100644 app/assets/javascripts/switchboard_entry.js.coffee create mode 100644 app/assets/stylesheets/switchboard_entries.css.scss create mode 100644 app/controllers/switchboard_entries_controller.rb create mode 100644 app/helpers/switchboard_entries_helper.rb create mode 100644 app/models/switchboard_entry.rb create mode 100644 app/views/switchboard_entries/_form.html.haml create mode 100644 app/views/switchboard_entries/_form_core.html.haml create mode 100644 app/views/switchboard_entries/_index_core.html.haml create mode 100644 app/views/switchboard_entries/edit.html.haml create mode 100644 app/views/switchboard_entries/index.html.haml create mode 100644 app/views/switchboard_entries/new.html.haml create mode 100644 app/views/switchboard_entries/show.html.haml (limited to 'app') diff --git a/app/assets/javascripts/switchboard_entry.js.coffee b/app/assets/javascripts/switchboard_entry.js.coffee new file mode 100644 index 0000000..d14825e --- /dev/null +++ b/app/assets/javascripts/switchboard_entry.js.coffee @@ -0,0 +1,6 @@ +jQuery -> + $('#switchboard_entries').sortable + axis: 'y' + handle: '.handle' + update: -> + $.post($(this).data('update-url'), $(this).sortable('serialize')) \ No newline at end of file diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 44868e4..557bbda 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -16,4 +16,5 @@ *= require softkeys *= require phone_numbers *= require route_elements + *= require switchboard_entries */ diff --git a/app/assets/stylesheets/switchboard_entries.css.scss b/app/assets/stylesheets/switchboard_entries.css.scss new file mode 100644 index 0000000..12b67ee --- /dev/null +++ b/app/assets/stylesheets/switchboard_entries.css.scss @@ -0,0 +1,5 @@ +#switchboard_entries .handle { + font-size: 12px; + color: #777; + cursor: move; +} \ No newline at end of file diff --git a/app/controllers/switchboard_entries_controller.rb b/app/controllers/switchboard_entries_controller.rb new file mode 100644 index 0000000..ef6c72e --- /dev/null +++ b/app/controllers/switchboard_entries_controller.rb @@ -0,0 +1,74 @@ +class SwitchboardEntriesController < ApplicationController + load_and_authorize_resource :switchboard + authorize_resource :switchboard_entry, :through => :switchboard, :except => [:sort] + + def index + @switchboard_entries = @switchboard.switchboard_entries + spread_breadcrumbs + end + + def show + @switchboard_entry = @switchboard.switchboard_entries.find(params[:id]) + spread_breadcrumbs + end + + def new + @switchboard_entry = @switchboard.switchboard_entries.build + @sip_accounts = SipAccount.all - @switchboard.sip_accounts + spread_breadcrumbs + end + + def create + @switchboard_entry = @switchboard.switchboard_entries.build(switchboard_entry_params) + spread_breadcrumbs + if @switchboard_entry.save + redirect_to switchboard_switchboard_entries_path(@switchboard), :notice => t('switchboard_entries.controller.successfuly_created') + else + render :new + end + end + + def edit + @switchboard_entry = @switchboard.switchboard_entries.find(params[:id]) + @sip_accounts = SipAccount.all - @switchboard.sip_accounts + [@switchboard_entry.sip_account] + spread_breadcrumbs + end + + def update + @switchboard_entry = @switchboard.switchboard_entries.find(params[:id]) + if @switchboard_entry.update_attributes(switchboard_entry_params) + redirect_to [@switchboard, @switchboard_entry], :notice => t('switchboard_entries.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @switchboard_entry = @switchboard.switchboard_entries.find(params[:id]) + @switchboard_entry.destroy + redirect_to switchboard_switchboard_entries_path(@switchboard), :notice => t('switchboard_entries.controller.successfuly_destroyed') + end + + def sort + params[:switchboard_entry].reverse.each do |id| + @switchboard.switchboard_entries.find(id).move_to_top + end + render nothing: true + end + + private + def switchboard_entry_params + params.require(:switchboard_entry).permit(:name, :sip_account_id) + end + + def spread_breadcrumbs + add_breadcrumb t("users.index.page_title"), tenant_users_path(@switchboard.user.current_tenant) + add_breadcrumb @switchboard.user, tenant_user_path(@switchboard.user.current_tenant, @switchboard.user) + add_breadcrumb t("switchboards.index.page_title"), user_switchboards_path(@switchboard.user) + add_breadcrumb @switchboard, user_switchboard_path(@switchboard.user, @switchboard) + add_breadcrumb t("switchboard_entries.index.page_title"), switchboard_switchboard_entries_path(@switchboard) + if @switchboard_entry && !@switchboard_entry.new_record? + add_breadcrumb @switchboard_entry, switchboard_switchboard_entries_path(@switchboard, @switchboard_entry) + end + end +end diff --git a/app/helpers/switchboard_entries_helper.rb b/app/helpers/switchboard_entries_helper.rb new file mode 100644 index 0000000..ca9b1f9 --- /dev/null +++ b/app/helpers/switchboard_entries_helper.rb @@ -0,0 +1,2 @@ +module SwitchboardEntriesHelper +end diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index cdb609d..74a2562 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -41,6 +41,8 @@ class SipAccount < ActiveRecord::Base has_many :call_legs, :class_name => 'Call' has_many :b_call_legs, :class_name => 'Call', :foreign_key => 'b_sip_account_id' + has_many :switchboard_entries, :dependent => :destroy + # Delegations: # delegate :host, :to => :sip_domain, :allow_nil => true diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb index cb0c70f..74e2767 100644 --- a/app/models/switchboard.rb +++ b/app/models/switchboard.rb @@ -7,6 +7,8 @@ class Switchboard < ActiveRecord::Base :uniqueness => {:scope => :user_id} belongs_to :user, :touch => true + has_many :switchboard_entries, :dependent => :destroy + has_many :sip_accounts, :through => :switchboard_entries def to_s self.name.to_s diff --git a/app/models/switchboard_entry.rb b/app/models/switchboard_entry.rb new file mode 100644 index 0000000..d1e9a0c --- /dev/null +++ b/app/models/switchboard_entry.rb @@ -0,0 +1,30 @@ +class SwitchboardEntry < ActiveRecord::Base + # https://github.com/rails/strong_parameters + include ActiveModel::ForbiddenAttributesProtection + + belongs_to :switchboard, :touch => true + belongs_to :sip_account, :touch => true + + validates :switchboard, + :presence => true + + validates :sip_account, + :presence => true + + validates :name, + :uniqueness => {:scope => :switchboard_id}, + :allow_blank => true, + :allow_nil => true + + acts_as_list :scope => [ :switchboard_id ] + + default_scope order(:position) + + def to_s + if self.name.blank? && !self.sip_account.to_s.blank? + self.sip_account.to_s + else + self.name.to_s + end + end +end diff --git a/app/views/switchboard_entries/_form.html.haml b/app/views/switchboard_entries/_form.html.haml new file mode 100644 index 0000000..b3d56ec --- /dev/null +++ b/app/views/switchboard_entries/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for([@switchboard, @switchboard_entry]) do |f| + = f.error_notification + + = render "form_core", :f => f + + .form-actions + = f.button :submit, conditional_t('switchboard_entries.form.submit') diff --git a/app/views/switchboard_entries/_form_core.html.haml b/app/views/switchboard_entries/_form_core.html.haml new file mode 100644 index 0000000..6f340c2 --- /dev/null +++ b/app/views/switchboard_entries/_form_core.html.haml @@ -0,0 +1,3 @@ +.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') diff --git a/app/views/switchboard_entries/_index_core.html.haml b/app/views/switchboard_entries/_index_core.html.haml new file mode 100644 index 0000000..406db71 --- /dev/null +++ b/app/views/switchboard_entries/_index_core.html.haml @@ -0,0 +1,16 @@ +%table.table.table-striped + %tr + %th + %th= t('switchboard_entries.index.sip_account_id') + %th= t('switchboard_entries.index.name') + %th + + %tbody{ :id => "switchboard_entries", :'data-update-url' => sort_switchboard_switchboard_entries_path(switchboard_entries.first.switchboard) } + - for switchboard_entry in switchboard_entries + = content_tag_for :tr, switchboard_entry do + %td + %span.handle + %i.icon-resize-vertical + %td= switchboard_entry.sip_account + %td= switchboard_entry.name + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => switchboard_entry.switchboard, :child => switchboard_entry} \ No newline at end of file diff --git a/app/views/switchboard_entries/edit.html.haml b/app/views/switchboard_entries/edit.html.haml new file mode 100644 index 0000000..8885e25 --- /dev/null +++ b/app/views/switchboard_entries/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("switchboard_entries.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/switchboard_entries/index.html.haml b/app/views/switchboard_entries/index.html.haml new file mode 100644 index 0000000..302b778 --- /dev/null +++ b/app/views/switchboard_entries/index.html.haml @@ -0,0 +1,6 @@ +- content_for :title, t("switchboard_entries.index.page_title") + +- if @switchboard_entries && @switchboard_entries.count > 0 + = render "index_core", :switchboard_entries => @switchboard_entries + += render :partial => 'shared/create_link', :locals => {:parent => @switchboard, :child_class => SwitchboardEntry} \ No newline at end of file diff --git a/app/views/switchboard_entries/new.html.haml b/app/views/switchboard_entries/new.html.haml new file mode 100644 index 0000000..0801a65 --- /dev/null +++ b/app/views/switchboard_entries/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("switchboard_entries.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/switchboard_entries/show.html.haml b/app/views/switchboard_entries/show.html.haml new file mode 100644 index 0000000..b519781 --- /dev/null +++ b/app/views/switchboard_entries/show.html.haml @@ -0,0 +1,22 @@ +- content_for :title, t("switchboard_entries.show.page_title") + +.row + .span6 + %table.table.table-striped + %tr + %td + %strong= t('switchboard_entries.show.sip_account_id') + ":" + %td + = @switchboard_entry.sip_account + %tr + %td + %strong= t('switchboard_entries.show.name') + ":" + %td + = @switchboard_entry.name + %tr + %td + %strong= t('switchboard_entries.show.position') + ":" + %td + = @switchboard_entry.position + + = render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @switchboard, :child => @switchboard_entry } \ No newline at end of file -- cgit v1.2.3 From 473fbe23f29278ac2384b2d3b3fc814dbb5ab9fc Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sat, 9 Mar 2013 01:26:27 -0500 Subject: sip_account.calls has become an array --- app/controllers/calls_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/calls_controller.rb b/app/controllers/calls_controller.rb index 9d85a10..6182ad8 100644 --- a/app/controllers/calls_controller.rb +++ b/app/controllers/calls_controller.rb @@ -31,7 +31,7 @@ class CallsController < ApplicationController end def create - @call = @sip_account.calls.create(params[:call]) + @call = @sip_account.call_legs.build(params[:call]) if @call && @call.call m = method( :"#{@parent.class.name.underscore}_calls_url" ) -- cgit v1.2.3 From bc450bb73fea9e8eb363f89e806e4f6084cf0511 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sat, 9 Mar 2013 03:01:56 -0500 Subject: perimeter control method added --- app/models/intruder.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app') diff --git a/app/models/intruder.rb b/app/models/intruder.rb index 9a1c39a..bdfa753 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -50,6 +50,17 @@ class Intruder < ActiveRecord::Base } end + def self.control(action, attributes={}) + require 'freeswitch_event' + event = FreeswitchEvent.new('CUSTOM') + event.add_header('Event-Subclass', 'perimeter::control') + event.add_header('action', action) + attributes.each do |name, value| + event.add_header(name, value) + end + return event.fire() + end + private def set_key_if_empty if self.key.blank? -- cgit v1.2.3 From cf506e96cfdd2f399934251f79c6f681503b7d5f Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sat, 9 Mar 2013 03:56:10 -0500 Subject: perimeter_db_rescan class, instance methods added --- app/models/intruder.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/models/intruder.rb b/app/models/intruder.rb index bdfa753..97120a7 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -50,13 +50,23 @@ class Intruder < ActiveRecord::Base } end - def self.control(action, attributes={}) + def perimeter_db_rescan + Intruder.perimeter_control(:db_rescan, :key => self.key) + end + + def self.perimeter_db_rescan(key=nil) + Intruder.perimeter_control(:db_rescan, :key => key) + end + + def self.perimeter_control(action, attributes={}) require 'freeswitch_event' event = FreeswitchEvent.new('CUSTOM') event.add_header('Event-Subclass', 'perimeter::control') event.add_header('action', action) attributes.each do |name, value| - event.add_header(name, value) + if !name.blank? && value then + event.add_header(name, value) + end end return event.fire() end -- cgit v1.2.3 From 4d11efbd7b0dc1c7e89210a56ea5ca77fe801c7e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sat, 9 Mar 2013 04:12:52 -0500 Subject: send perimeter event after_save --- app/models/intruder.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app') diff --git a/app/models/intruder.rb b/app/models/intruder.rb index 97120a7..9c01634 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -119,6 +119,7 @@ class Intruder < ActiveRecord::Base write_firewall_list restart_firewall end + self.perimeter_db_rescan end end @@ -129,6 +130,7 @@ class Intruder < ActiveRecord::Base restart_firewall end end + self.perimeter_db_rescan end def check_if_delete_relevant @@ -138,5 +140,6 @@ class Intruder < ActiveRecord::Base restart_firewall end end + self.perimeter_db_rescan end end -- cgit v1.2.3 From 595a48a91f8549b20109942e0b80df4f891d5999 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sat, 9 Mar 2013 05:45:39 -0500 Subject: status method added --- app/models/sip_account.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'app') diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index a5b8bad..bb45a4c 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -184,6 +184,33 @@ class SipAccount < ActiveRecord::Base return sip_accounts end + def status + states = Array.new + + SipAccount.last.call_legs.each do |call_leg| + states << { + :status => call_leg.callstate, + :caller => true, + :endpoint_name => call_leg.callee_name, + :endpoint_number => call_leg.destination, + :endpoint_sip_account_id => call_leg.b_sip_account_id, + :start_stamp => call_leg.start_stamp, + } + end + + SipAccount.last.b_call_legs.each do |call_leg| + states << { + :status => call_leg.callstate, + :caller => false, + :endpoint_name => call_leg.caller_id_name, + :endpoint_number => call_leg.caller_id_number, + :endpoint_sip_account_id => call_leg.sip_account_id, + :start_stamp => call_leg.start_stamp, + } + end + + return states + end private -- cgit v1.2.3 From 21d0843117c0962bd962fc50fccaf276a5b3067f Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 10 Mar 2013 08:43:23 +0100 Subject: Misc --- app/models/switchboard_entry.rb | 1 + app/views/switchboards/show.html.haml | 53 ++++++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 10 deletions(-) (limited to 'app') diff --git a/app/models/switchboard_entry.rb b/app/models/switchboard_entry.rb index d1e9a0c..76d002f 100644 --- a/app/models/switchboard_entry.rb +++ b/app/models/switchboard_entry.rb @@ -12,6 +12,7 @@ class SwitchboardEntry < ActiveRecord::Base :presence => true validates :name, + :length => { :maximum => 10 }, :uniqueness => {:scope => :switchboard_id}, :allow_blank => true, :allow_nil => true diff --git a/app/views/switchboards/show.html.haml b/app/views/switchboards/show.html.haml index 746e180..b81980c 100644 --- a/app/views/switchboards/show.html.haml +++ b/app/views/switchboards/show.html.haml @@ -1,12 +1,45 @@ -- content_for :title, t("switchboards.show.page_title") +- content_for :title, @switchboard.name + .row - .span6 - %table.table.table-striped - %tr - %td - %strong= t('switchboards.show.name') + ":" - %td - = @switchboard.name - -= render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @user, :child => @switchboard } \ No newline at end of file + .span12 + .well.pull-right + %p + =current_user + + %ul.thumbnails + - @switchboard.switchboard_entries.each do |switchboard_entry| + %li.span1 + %div.thumbnail + %a.thumbnail{:href => tenant_user_path(switchboard_entry.sip_account.sip_accountable.current_tenant, switchboard_entry.sip_account.sip_accountable)} + - if switchboard_entry.sip_account.sip_accountable.image? + = image_tag(switchboard_entry.sip_account.sip_accountable.image_url(:mini).to_s, :class => 'img-rounded') + - else + - if switchboard_entry.sip_account.sip_accountable.male? + = image_tag 'icons/user-male-16x.png', :class => 'img-rounded' + - else + = image_tag 'icons/user-female-16x.png', :class => 'img-rounded' + %p + %small + = truncate(switchboard_entry.to_s, :length => 10) + %span{:class => "label #{(switchboard_entry.sip_account.registration ? '' : 'label-inverse')}"} + - if !switchboard_entry.sip_account.registration + %i.icon-ban-circle.icon-white + - if switchboard_entry.sip_account.phone_numbers.count > 1 + - phone_numbers = [] + - switchboard_entry.sip_account.phone_numbers.order(:position).each do |phone_number| + - if phone_number.number.length < 6 + - phone_numbers << phone_number + - if phone_numbers.size == 0 + - phone_numbers = switchboard_entry.sip_account.phone_numbers.order(:position) + - else + - phone_numbers = switchboard_entry.sip_account.phone_numbers + = render 'phone_numbers/listing', :phone_numbers => phone_numbers + +- 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") -- cgit v1.2.3 From fc9b8e69e74a76d6727d5ddceebb018782027b16 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 10 Mar 2013 08:57:50 +0100 Subject: Added Private Pub stuff. https://github.com/ryanb/private_pub --- app/assets/javascripts/application.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app') diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index c6f4107..68a6e22 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -13,4 +13,5 @@ //= require jquery //= require jquery-ui //= require jquery_ujs +//= require private_pub //= require_tree . -- cgit v1.2.3 From 04730ba7acf55ed5310352eabf3876bf5b8d1f87 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 10 Mar 2013 09:52:08 +0100 Subject: Set the Ability for Switchboard and SwitchboardEntry. --- app/models/ability.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app') diff --git a/app/models/ability.rb b/app/models/ability.rb index fe67547..2dd96b8 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -183,6 +183,11 @@ class Ability # can :manage, VoicemailMessage can :manage, VoicemailSetting + + # Switchboard + # + can :read, Switchboard, :id => user.switchboard_ids + can :read, SwitchboardEntry, :switchboard_id => user.switchboard_ids end end else -- cgit v1.2.3 From 13e16223977966f9751e7b8e3fb587e2df0a0801 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 10 Mar 2013 09:52:31 +0100 Subject: Add a second configuration option. --- app/views/switchboards/edit.html.haml | 11 ++++++++++- app/views/users/_switchboards.html.haml | 7 +++++++ app/views/users/show.html.haml | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 app/views/users/_switchboards.html.haml (limited to 'app') diff --git a/app/views/switchboards/edit.html.haml b/app/views/switchboards/edit.html.haml index 1ab0efe..f2e69f4 100644 --- a/app/views/switchboards/edit.html.haml +++ b/app/views/switchboards/edit.html.haml @@ -1,3 +1,12 @@ - content_for :title, t("switchboards.edit.page_title") -= render "form" \ No newline at end of file +.row + .span12 + = render "form" + +.row + .span12 + - if @switchboard.switchboard_entries && @switchboard.switchboard_entries.count > 0 + = render "switchboard_entries/index_core", :switchboard_entries => @switchboard.switchboard_entries + + = render :partial => 'shared/create_link', :locals => {:parent => @switchboard, :child_class => SwitchboardEntry} \ No newline at end of file diff --git a/app/views/users/_switchboards.html.haml b/app/views/users/_switchboards.html.haml new file mode 100644 index 0000000..f79d6b8 --- /dev/null +++ b/app/views/users/_switchboards.html.haml @@ -0,0 +1,7 @@ +-# Switchboards +-# +- if (can?( :index, Switchboard ) && user.switchboards.any? ) || can?( :create, Switchboard ) + %h2= t('switchboards.index.page_title') + - if can?( :index, Switchboard ) && user.switchboards.count > 0 + = render :partial => "switchboards/index_core", :locals => {:switchboards => user.switchboards, :user => user} + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => Conference} \ No newline at end of file diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index ea90ab4..98f7cc6 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -87,3 +87,6 @@ - cache(['user_show_conferences_overview', I18n.locale, @user, @user.conferences]) do = render :partial => 'conferences', :locals => {:user => @user} + + - cache(['user_switchboards_overview', I18n.locale, @user, @user.switchboards]) do + = render :partial => 'switchboards', :locals => {:user => @user} \ No newline at end of file -- cgit v1.2.3 From c563859fa60defd2b40f17a0b7cf1c4912f72792 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 10 Mar 2013 12:06:06 +0100 Subject: added non_e164_phone_numbers method --- app/models/sip_account.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app') diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 930069d..cea5f0e 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -213,6 +213,11 @@ class SipAccount < ActiveRecord::Base return states end + def non_e164_phone_numbers + array_of_phone_numbers_as_strings = self.phone_numbers.map{ |phone_number| phone_number.number.to_s }.sort + self.phone_numbers.where(:number => array_of_phone_numbers_as_strings.select { |phone_number| phone_number[0] != '+' }) + end + private def save_value_of_to_s -- cgit v1.2.3 From f0932e38b890b08397020a5994ddde7110d7b8db Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 10 Mar 2013 10:50:49 +0100 Subject: refactoring --- app/controllers/switchboards_controller.rb | 1 + .../_switchboard_entry.html.haml | 26 +++++++++++++++++++ app/views/switchboards/show.html.haml | 29 +--------------------- 3 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 app/views/switchboard_entries/_switchboard_entry.html.haml (limited to 'app') diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb index 8f21d5e..98008c1 100644 --- a/app/controllers/switchboards_controller.rb +++ b/app/controllers/switchboards_controller.rb @@ -9,6 +9,7 @@ class SwitchboardsController < ApplicationController def show @switchboard = @user.switchboards.find(params[:id]) + @switchboard_entries = @switchboard.switchboard_entries spread_breadcrumbs end diff --git a/app/views/switchboard_entries/_switchboard_entry.html.haml b/app/views/switchboard_entries/_switchboard_entry.html.haml new file mode 100644 index 0000000..2902a83 --- /dev/null +++ b/app/views/switchboard_entries/_switchboard_entry.html.haml @@ -0,0 +1,26 @@ +%li.span1{:id => "switchboard_entry_id_#{switchboard_entry.id}"} + %div.thumbnail + %a.thumbnail{:href => tenant_user_path(switchboard_entry.sip_account.sip_accountable.current_tenant, switchboard_entry.sip_account.sip_accountable)} + - if switchboard_entry.sip_account.sip_accountable.image? + = image_tag(switchboard_entry.sip_account.sip_accountable.image_url(:mini).to_s, :class => 'img-rounded') + - else + - if switchboard_entry.sip_account.sip_accountable.male? + = image_tag 'icons/user-male-16x.png', :class => 'img-rounded' + - else + = image_tag 'icons/user-female-16x.png', :class => 'img-rounded' + %p + %small + = truncate(switchboard_entry.to_s, :length => 10) + %span{:class => "label #{(switchboard_entry.sip_account.registration ? '' : 'label-inverse')}"} + - if !switchboard_entry.sip_account.registration + %i.icon-ban-circle.icon-white + - if switchboard_entry.sip_account.phone_numbers.count > 1 + - phone_numbers = [] + - switchboard_entry.sip_account.phone_numbers.order(:position).each do |phone_number| + - if phone_number.number.length < 6 + - phone_numbers << phone_number + - if phone_numbers.size == 0 + - phone_numbers = switchboard_entry.sip_account.phone_numbers.order(:position) + - else + - phone_numbers = switchboard_entry.sip_account.phone_numbers + = render 'phone_numbers/listing', :phone_numbers => phone_numbers diff --git a/app/views/switchboards/show.html.haml b/app/views/switchboards/show.html.haml index b81980c..18671c2 100644 --- a/app/views/switchboards/show.html.haml +++ b/app/views/switchboards/show.html.haml @@ -1,6 +1,5 @@ - content_for :title, @switchboard.name - .row .span12 .well.pull-right @@ -8,33 +7,7 @@ =current_user %ul.thumbnails - - @switchboard.switchboard_entries.each do |switchboard_entry| - %li.span1 - %div.thumbnail - %a.thumbnail{:href => tenant_user_path(switchboard_entry.sip_account.sip_accountable.current_tenant, switchboard_entry.sip_account.sip_accountable)} - - if switchboard_entry.sip_account.sip_accountable.image? - = image_tag(switchboard_entry.sip_account.sip_accountable.image_url(:mini).to_s, :class => 'img-rounded') - - else - - if switchboard_entry.sip_account.sip_accountable.male? - = image_tag 'icons/user-male-16x.png', :class => 'img-rounded' - - else - = image_tag 'icons/user-female-16x.png', :class => 'img-rounded' - %p - %small - = truncate(switchboard_entry.to_s, :length => 10) - %span{:class => "label #{(switchboard_entry.sip_account.registration ? '' : 'label-inverse')}"} - - if !switchboard_entry.sip_account.registration - %i.icon-ban-circle.icon-white - - if switchboard_entry.sip_account.phone_numbers.count > 1 - - phone_numbers = [] - - switchboard_entry.sip_account.phone_numbers.order(:position).each do |phone_number| - - if phone_number.number.length < 6 - - phone_numbers << phone_number - - if phone_numbers.size == 0 - - phone_numbers = switchboard_entry.sip_account.phone_numbers.order(:position) - - else - - phone_numbers = switchboard_entry.sip_account.phone_numbers - = render 'phone_numbers/listing', :phone_numbers => phone_numbers + = render :partial => "switchboard_entries/switchboard_entry", :collection => @switchboard_entries - if can? :edit, @switchboard .row -- cgit v1.2.3 From 63339834ec520efae48f16f4d16b90d74e7bcdfd Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 10 Mar 2013 12:36:25 +0100 Subject: Added labels with the current status. --- .../_switchboard_entry.html.haml | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'app') diff --git a/app/views/switchboard_entries/_switchboard_entry.html.haml b/app/views/switchboard_entries/_switchboard_entry.html.haml index 2902a83..5608757 100644 --- a/app/views/switchboard_entries/_switchboard_entry.html.haml +++ b/app/views/switchboard_entries/_switchboard_entry.html.haml @@ -11,16 +11,22 @@ %p %small = truncate(switchboard_entry.to_s, :length => 10) - %span{:class => "label #{(switchboard_entry.sip_account.registration ? '' : 'label-inverse')}"} - - if !switchboard_entry.sip_account.registration + %br + - if !switchboard_entry.sip_account.registration + %span.label.label-inverse %i.icon-ban-circle.icon-white - - if switchboard_entry.sip_account.phone_numbers.count > 1 - - phone_numbers = [] - - switchboard_entry.sip_account.phone_numbers.order(:position).each do |phone_number| - - if phone_number.number.length < 6 - - phone_numbers << phone_number - - if phone_numbers.size == 0 - - phone_numbers = switchboard_entry.sip_account.phone_numbers.order(:position) - - else - - phone_numbers = switchboard_entry.sip_account.phone_numbers - = render 'phone_numbers/listing', :phone_numbers => phone_numbers + - 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.non_e164_phone_numbers.size == 0 + - phone_numbers = switchboard_entry.sip_account.phone_numbers + - else + - phone_numbers = switchboard_entry.sip_account.non_e164_phone_numbers + + - phone_numbers.each do |phone_number| + %span.label + = phone_number.number -- cgit v1.2.3 From b29f5e637816aeca6f5cc7c9acb3f380469d1630 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Sun, 10 Mar 2013 14:33:40 +0100 Subject: fix link --- app/views/users/_switchboards.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/users/_switchboards.html.haml b/app/views/users/_switchboards.html.haml index f79d6b8..8dca15f 100644 --- a/app/views/users/_switchboards.html.haml +++ b/app/views/users/_switchboards.html.haml @@ -4,4 +4,4 @@ %h2= t('switchboards.index.page_title') - if can?( :index, Switchboard ) && user.switchboards.count > 0 = render :partial => "switchboards/index_core", :locals => {:switchboards => user.switchboards, :user => user} - = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => Conference} \ No newline at end of file + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => Switchboard} \ No newline at end of file -- cgit v1.2.3 From b9aeac77779f7a9ae0e51b8d95adc7d542e09ece Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 10 Mar 2013 18:32:13 +0100 Subject: Small fixes. --- app/views/switchboard_entries/_index_core.html.haml | 19 ++++++++++--------- .../switchboard_entries/_switchboard_entry.html.haml | 11 +++-------- app/views/users/_switchboards.html.haml | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-) (limited to 'app') diff --git a/app/views/switchboard_entries/_index_core.html.haml b/app/views/switchboard_entries/_index_core.html.haml index 406db71..d647626 100644 --- a/app/views/switchboard_entries/_index_core.html.haml +++ b/app/views/switchboard_entries/_index_core.html.haml @@ -5,12 +5,13 @@ %th= t('switchboard_entries.index.name') %th - %tbody{ :id => "switchboard_entries", :'data-update-url' => sort_switchboard_switchboard_entries_path(switchboard_entries.first.switchboard) } - - for switchboard_entry in switchboard_entries - = content_tag_for :tr, switchboard_entry do - %td - %span.handle - %i.icon-resize-vertical - %td= switchboard_entry.sip_account - %td= switchboard_entry.name - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => switchboard_entry.switchboard, :child => switchboard_entry} \ No newline at end of file + - if switchboard_entries.any? + %tbody{ :id => "switchboard_entries", :'data-update-url' => sort_switchboard_switchboard_entries_path(switchboard_entries.first.switchboard) } + - for switchboard_entry in switchboard_entries + = content_tag_for :tr, switchboard_entry do + %td + %span.handle + %i.icon-resize-vertical + %td= switchboard_entry.sip_account + %td= switchboard_entry.name + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => switchboard_entry.switchboard, :child => switchboard_entry} \ No newline at end of file diff --git a/app/views/switchboard_entries/_switchboard_entry.html.haml b/app/views/switchboard_entries/_switchboard_entry.html.haml index 5608757..8d8e747 100644 --- a/app/views/switchboard_entries/_switchboard_entry.html.haml +++ b/app/views/switchboard_entries/_switchboard_entry.html.haml @@ -21,12 +21,7 @@ %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.non_e164_phone_numbers.size == 0 - - phone_numbers = switchboard_entry.sip_account.phone_numbers - - else - - phone_numbers = switchboard_entry.sip_account.non_e164_phone_numbers - - - phone_numbers.each do |phone_number| + %i.icon-bell.icon-white + - if switchboard_entry.sip_account.phone_numbers.any? %span.label - = phone_number.number + = switchboard_entry.sip_account.phone_numbers.first.number diff --git a/app/views/users/_switchboards.html.haml b/app/views/users/_switchboards.html.haml index 8dca15f..183b6ae 100644 --- a/app/views/users/_switchboards.html.haml +++ b/app/views/users/_switchboards.html.haml @@ -1,6 +1,6 @@ -# Switchboards -# -- if (can?( :index, Switchboard ) && user.switchboards.any? ) || can?( :create, Switchboard ) +- if SipAccount.any? && (can?( :index, Switchboard ) && user.switchboards.any? ) || can?( :create, Switchboard ) %h2= t('switchboards.index.page_title') - if can?( :index, Switchboard ) && user.switchboards.count > 0 = render :partial => "switchboards/index_core", :locals => {:switchboards => user.switchboards, :user => user} -- cgit v1.2.3 From beb9e66a5b4e2744435f2c1f301828b68a58c96a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 10 Mar 2013 19:11:13 +0100 Subject: Indicate a new voicemail in the navigation bar. --- app/controllers/trigger_controller.rb | 4 ++++ app/views/layouts/_navbar.html.haml | 4 ++++ app/views/layouts/application.html.haml | 1 + app/views/trigger/voicemail.html.erb | 4 ---- 4 files changed, 9 insertions(+), 4 deletions(-) delete mode 100644 app/views/trigger/voicemail.html.erb (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 5e836c4..1a5bfca 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -42,6 +42,10 @@ class TriggerController < ApplicationController end end + # Indicate a new voicemail in the navigation bar. + # + PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_indicator').hide.delay(250).show('slow').hide.delay(250).show('slow');") + render( :status => 200, :layout => false, diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 8004c0e..fe5f48f 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -22,7 +22,11 @@ =t("call_histories.index.page_title") %li %a{:href => sip_account_voicemail_messages_path(current_user.sip_accounts.first)} + %i.icon-star.icon-white{:id => 'new_voicemail_indicator'} =t("voicemail_messages.index.page_title") + :javascript + $("#new_voicemail_indicator").hide() + = subscribe_to "/users/#{current_user.id}/messages/new" - if current_user %ul.nav.pull-right diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index eab6096..027f837 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -36,4 +36,5 @@ .span12 %hr/ = render 'layouts/footer' + / /container diff --git a/app/views/trigger/voicemail.html.erb b/app/views/trigger/voicemail.html.erb deleted file mode 100644 index 9bafe17..0000000 --- a/app/views/trigger/voicemail.html.erb +++ /dev/null @@ -1,4 +0,0 @@ -

Trigger#voicemail

-

Find me in app/views/trigger/voicemail.html.erb

- -<%= debug(params) %> -- cgit v1.2.3 From 52079a2434c7bf33d8f59ebf29614bf681777d3d Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 11 Mar 2013 03:18:24 -0400 Subject: inbound_username, inbound_password settings added --- app/models/gateway_setting.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb index 381dde5..f353dee 100644 --- a/app/models/gateway_setting.rb +++ b/app/models/gateway_setting.rb @@ -5,11 +5,13 @@ class GatewaySetting < ActiveRecord::Base 'domain' => 'String', 'username' => 'String', 'password' => 'String', - 'contact' => 'String', 'register' => 'Boolean', 'auth_source' => 'String', 'auth_pattern' => 'String', + 'inbound_username' => 'String', + 'inbound_password' => 'String', 'number_source' => 'String', + 'contact' => 'String', 'profile' => 'String', }, 'xmpp' => { -- cgit v1.2.3 From 576471586e781ad1f7535e5931b1e41e25fad71b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 11 Mar 2013 05:57:32 -0400 Subject: dial_string setting added --- app/models/gateway_setting.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app') diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb index f353dee..b412bc6 100644 --- a/app/models/gateway_setting.rb +++ b/app/models/gateway_setting.rb @@ -12,6 +12,7 @@ class GatewaySetting < ActiveRecord::Base 'inbound_password' => 'String', 'number_source' => 'String', 'contact' => 'String', + 'dial_string' => 'String', 'profile' => 'String', }, 'xmpp' => { -- cgit v1.2.3 From 8cbf5e8f740383c56c1c92de85df3421b0e1a5d0 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 11 Mar 2013 11:37:27 +0100 Subject: Fax indicator test. --- app/controllers/trigger_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 1a5bfca..2e97711 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -110,6 +110,13 @@ class TriggerController < ApplicationController end if errors.count == 0 + # Indicate a new fax in the navigation bar. + # + if fax_document.fax_accountable.class == User + user = fax_document.fax_accountable + PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_indicator').hide.delay(250).show('slow').hide.delay(250).show('slow');") + end + render( :status => 200, :layout => false, -- cgit v1.2.3 From 685b8dc4987965e1450627e831ea40847bb5b19c Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 11 Mar 2013 11:52:01 +0100 Subject: JavaScript fix --- app/controllers/trigger_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 2e97711..7ab90c2 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -44,7 +44,7 @@ class TriggerController < ApplicationController # Indicate a new voicemail in the navigation bar. # - PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_indicator').hide.delay(250).show('slow').hide.delay(250).show('slow');") + PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_indicator').hide('fast').show('slow');") render( :status => 200, @@ -114,7 +114,7 @@ class TriggerController < ApplicationController # if fax_document.fax_accountable.class == User user = fax_document.fax_accountable - PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_indicator').hide.delay(250).show('slow').hide.delay(250).show('slow');") + PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_indicator').hide('fast').show('slow');") end render( -- cgit v1.2.3 From aa46f61cc84043a81f760c961ec53786671e7e50 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 11 Mar 2013 12:12:36 +0100 Subject: Moved the voicemail and fax indicator. --- app/controllers/trigger_controller.rb | 4 ++-- app/views/layouts/_navbar.html.haml | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 7ab90c2..db379f9 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -44,7 +44,7 @@ class TriggerController < ApplicationController # Indicate a new voicemail in the navigation bar. # - PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_indicator').hide('fast').show('slow');") + PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_or_fax_indicator').hide('fast').show('slow');") render( :status => 200, @@ -114,7 +114,7 @@ class TriggerController < ApplicationController # if fax_document.fax_accountable.class == User user = fax_document.fax_accountable - PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_indicator').hide('fast').show('slow');") + PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_or_fax_indicator').hide('fast').show('slow');") end render( diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index fe5f48f..3e1da1c 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -22,12 +22,8 @@ =t("call_histories.index.page_title") %li %a{:href => sip_account_voicemail_messages_path(current_user.sip_accounts.first)} - %i.icon-star.icon-white{:id => 'new_voicemail_indicator'} =t("voicemail_messages.index.page_title") - :javascript - $("#new_voicemail_indicator").hide() - = subscribe_to "/users/#{current_user.id}/messages/new" - + - if current_user %ul.nav.pull-right %li.display @@ -43,10 +39,18 @@ - if current_page?(tenant_user_path(current_user.current_tenant, current_user)) %li.active %a.navbar-link{:href => tenant_user_path(current_user.current_tenant, current_user)} + %i.icon-star.icon-white{:id => 'new_voicemail_or_fax_indicator'} + :javascript + $("#new_voicemail_or_fax_indicator").hide() + = subscribe_to "/users/#{current_user.id}/messages/new" = current_user - else %li %a.navbar-link{:href => tenant_user_path(current_user.current_tenant, current_user)} + %i.icon-star.icon-white{:id => 'new_voicemail_or_fax_indicator'} + :javascript + $("#new_voicemail_or_fax_indicator").hide() + = subscribe_to "/users/#{current_user.id}/messages/new" = current_user - if single_sign_on_system? == false -- cgit v1.2.3 From 64afdeacb1444b319abfcad6c9a8cfd656fe2dd4 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 11 Mar 2013 12:19:57 +0100 Subject: Reload FaxDocument#show when a fax was send. --- app/controllers/trigger_controller.rb | 4 ++++ app/views/fax_documents/show.html.haml | 3 +++ 2 files changed, 7 insertions(+) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index db379f9..0de9223 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -110,6 +110,10 @@ class TriggerController < ApplicationController end if errors.count == 0 + # Reload FaxDocument#show + # + PrivatePub.publish_to("/fax_documents/#{fax_document.id}", "location.reload();") + # Indicate a new fax in the navigation bar. # if fax_document.fax_accountable.class == User diff --git a/app/views/fax_documents/show.html.haml b/app/views/fax_documents/show.html.haml index b8f3e9e..f860143 100644 --- a/app/views/fax_documents/show.html.haml +++ b/app/views/fax_documents/show.html.haml @@ -65,3 +65,6 @@ .row .span12 = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @fax_document.fax_account, :child => @fax_document } + +- if @fax_document.state == 'sending' || @fax_document.state == 'queued_for_sending' + = subscribe_to "/fax_documents/#{@fax_document.id}" \ No newline at end of file -- cgit v1.2.3 From 3305624fc4b6de2dabaa292fa1480851ca141c96 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 11 Mar 2013 12:29:44 +0100 Subject: Fix the if. --- app/views/fax_documents/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/fax_documents/show.html.haml b/app/views/fax_documents/show.html.haml index f860143..af5552d 100644 --- a/app/views/fax_documents/show.html.haml +++ b/app/views/fax_documents/show.html.haml @@ -66,5 +66,5 @@ .span12 = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @fax_document.fax_account, :child => @fax_document } -- if @fax_document.state == 'sending' || @fax_document.state == 'queued_for_sending' +- if ['sending', 'queued_for_sending'].include? @fax_document.state = subscribe_to "/fax_documents/#{@fax_document.id}" \ No newline at end of file -- cgit v1.2.3 From 525c216dc6c64821d0273dd4a63b9716dc52e715 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 11 Mar 2013 13:14:13 +0100 Subject: Bugfix --- app/controllers/trigger_controller.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 0de9223..db379f9 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -110,10 +110,6 @@ class TriggerController < ApplicationController end if errors.count == 0 - # Reload FaxDocument#show - # - PrivatePub.publish_to("/fax_documents/#{fax_document.id}", "location.reload();") - # Indicate a new fax in the navigation bar. # if fax_document.fax_accountable.class == User -- cgit v1.2.3 From f274393cd7e9ed81084661ccefa1a2e53c49b50a Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 11 Mar 2013 13:46:24 +0100 Subject: Bugfix --- app/controllers/trigger_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index db379f9..a1bab65 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -91,6 +91,8 @@ class TriggerController < ApplicationController if fax_document.save Notifications.new_fax(fax_document).deliver + @last_fax_document = fax_document + begin File.delete(pdf_file) rescue => e @@ -112,8 +114,8 @@ class TriggerController < ApplicationController if errors.count == 0 # Indicate a new fax in the navigation bar. # - if fax_document.fax_accountable.class == User - user = fax_document.fax_accountable + if @last_fax_document.fax_account.fax_accountable.class == User + user = @last_fax_document.fax_account.fax_accountable PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_or_fax_indicator').hide('fast').show('slow');") end -- cgit v1.2.3 From 220e5e76996a4071c9645b3026abfc0592f6af0b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 11 Mar 2013 16:47:34 +0100 Subject: Bugfix for #236 --- app/controllers/trigger_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index a1bab65..fb53c37 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -16,6 +16,10 @@ class TriggerController < ApplicationController next end + # Indicate a new voicemail in the navigation bar. + # + PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_or_fax_indicator').hide('fast').show('slow');") + if user.email.blank? next end @@ -42,10 +46,6 @@ class TriggerController < ApplicationController end end - # Indicate a new voicemail in the navigation bar. - # - PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_or_fax_indicator').hide('fast').show('slow');") - render( :status => 200, :layout => false, -- cgit v1.2.3 From be03d6d4d629e17ea070212ffbb2b706bc7f1cf2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 12 Mar 2013 08:30:43 +0100 Subject: Removed caching for the sip_accounts table. #233 --- app/views/tenants/_table_of_sip_accounts.html.haml | 45 +++++++++++----------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'app') diff --git a/app/views/tenants/_table_of_sip_accounts.html.haml b/app/views/tenants/_table_of_sip_accounts.html.haml index 34eeb14..b2f2612 100644 --- a/app/views/tenants/_table_of_sip_accounts.html.haml +++ b/app/views/tenants/_table_of_sip_accounts.html.haml @@ -1,25 +1,24 @@ -- cache(['tenant_show_table_of_sip_accounts', I18n.locale, tenant, tenant.sip_accounts.count, SipAccount.count, tenant.sip_accounts.reorder(:updated_at).last]) do - .row - - if GsParameter.get('AUTO_ADMIN_ONLINE_HELP') == true && !SipAccount.any? - .span4 - -# SIP accounts - -# - %h2= t('sip_accounts.index.page_title') - - if tenant.sip_accounts.any? - = render "sip_accounts/index_core", :sip_accounts => tenant.sip_accounts - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount} +.row + - if GsParameter.get('AUTO_ADMIN_ONLINE_HELP') == true && !SipAccount.any? + .span4 + -# SIP accounts + -# + %h2= t('sip_accounts.index.page_title') + - if tenant.sip_accounts.any? + = render "sip_accounts/index_core", :sip_accounts => tenant.sip_accounts + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount} - .span8 - .well - %p - In der #{link_to 'Admin-Doku', page_help_path} finden Sie die Beschreibung wie ein neues Telefon mit einem SIP-Account eingerichtet werden kann. Dazu gibt es auch einen Screencast: - = render :partial => 'page/docu/screencast_list', :locals => {:screencast_name => 'firmen_sip_account_und_telefon_anlegen'} + .span8 + .well + %p + In der #{link_to 'Admin-Doku', page_help_path} finden Sie die Beschreibung wie ein neues Telefon mit einem SIP-Account eingerichtet werden kann. Dazu gibt es auch einen Screencast: + = render :partial => 'page/docu/screencast_list', :locals => {:screencast_name => 'firmen_sip_account_und_telefon_anlegen'} - - else - .span12 - -# SIP accounts - -# - %h2= t('sip_accounts.index.page_title') - - if tenant.sip_accounts.any? - = render "sip_accounts/index_core", :sip_accounts => tenant.sip_accounts - = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount} + - else + .span12 + -# SIP accounts + -# + %h2= t('sip_accounts.index.page_title') + - if tenant.sip_accounts.any? + = render "sip_accounts/index_core", :sip_accounts => tenant.sip_accounts + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => SipAccount} -- cgit v1.2.3 From 42c2396b485a3eaa0e8bdb995b3777c498b4f94d Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 12 Mar 2013 04:15:31 -0400 Subject: redirection fixed --- app/controllers/conference_invitees_controller.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/controllers/conference_invitees_controller.rb b/app/controllers/conference_invitees_controller.rb index e891ebc..cbe4790 100644 --- a/app/controllers/conference_invitees_controller.rb +++ b/app/controllers/conference_invitees_controller.rb @@ -35,10 +35,7 @@ class ConferenceInviteesController < ApplicationController end if @conference_invitee.save - # m = method( :"#{@parent_in_route.class.name.underscore}_path" ) - # redirect_to m.( @parent_in_route ), :notice => t('conference_invitees.controller.successfuly_created', :resource => @conference_invitees) - m = method( :"#{@conference_invitee.conference.conferenceable_type.underscore}_conference_path") - redirect_to m.( @conference_invitee.conference.conferenceable, @conference_invitee.conference), :notice => t('conference_invitees.controller.successfuly_created', :resource => @conference_invitees) + redirect_to conference_conference_invitees_url(@conference), :notice => t('conference_invitees.controller.successfuly_created') else render :new end @@ -50,7 +47,7 @@ class ConferenceInviteesController < ApplicationController def update if @conference_invitee.update_attributes(params[:conference_invitee]) - redirect_to @conference_invitee, :notice => t('conference_invitees.controller.successfuly_updated') + redirect_to conference_conference_invitees_url(@conference), :notice => t('conference_invitees.controller.successfuly_updated') else render :edit end -- cgit v1.2.3 From f9ab4cb6a477159e40bd7f48d9ed32ca077a8e34 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 12 Mar 2013 04:16:49 -0400 Subject: remove non decimal characters from pin --- app/models/conference.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/models/conference.rb b/app/models/conference.rb index aee75d5..6c89d60 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -7,6 +7,12 @@ class Conference < ActiveRecord::Base has_many :conference_invitees, :dependent => :destroy has_many :phone_numbers, :as => :phone_numberable, :dependent => :destroy + before_validation { + if !self.pin.blank? + self.pin = self.pin.to_s.gsub(/[^0-9]/, '') + end + } + validates_presence_of :conferenceable_type, :conferenceable_id validates_presence_of :conferenceable validates_presence_of :name @@ -21,15 +27,12 @@ class Conference < ActiveRecord::Base validates_inclusion_of :open_for_anybody, :in => [true, false] - validates_numericality_of :pin, :only_integer => true, - :greater_than => 0, - :allow_nil => true, - :allow_blank => true validates_length_of :pin, :minimum => (GsParameter.get('MINIMUM_PIN_LENGTH').nil? ? 4 : GsParameter.get('MINIMUM_PIN_LENGTH')), :allow_nil => true, :allow_blank => true validate :start_and_end_dates_must_make_sense, :if => Proc.new { |conference| !conference.start.blank? && !conference.end.blank? } + before_save :send_pin_email_when_pin_has_changed @@ -50,7 +53,6 @@ class Conference < ActiveRecord::Base private def start_and_end_dates_must_make_sense - errors.add(:start, 'must be in the future') if self.start < Time.now - 10.minutes errors.add(:end, 'must be later than the start') if self.end < self.start end -- cgit v1.2.3 From 1e2506e77d04d02b15f34cbdd83109ad579cc89e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 12 Mar 2013 04:17:06 -0400 Subject: remove non decimal characters from pin --- app/models/conference_invitee.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/models/conference_invitee.rb b/app/models/conference_invitee.rb index d6e3bac..6a1349e 100644 --- a/app/models/conference_invitee.rb +++ b/app/models/conference_invitee.rb @@ -1,21 +1,23 @@ class ConferenceInvitee < ActiveRecord::Base attr_accessible :pin, :speaker, :moderator, :phone_number, :phone_number_attributes - + belongs_to :conference belongs_to :phone_book_entry has_one :phone_number, :as => :phone_numberable, :dependent => :destroy accepts_nested_attributes_for :phone_number + before_validation { + if !self.pin.blank? + self.pin = self.pin.to_s.gsub(/[^0-9]/, '') + end + } + validates_presence_of :conference_id validates_presence_of :conference validates_presence_of :phone_number - validates_numericality_of :pin, :only_integer => true, - :greater_than => 0, - :allow_nil => true, - :allow_blank => true - validates_length_of :pin, :minimum => (GsParameter.get('MINIMUM_PIN_LENGTH').nil? ? 4 : GsParameter.get('MINIMUM_PIN_LENGTH')), - :allow_nil => true, - :allow_blank => true + validates_length_of :pin, :minimum => (GsParameter.get('MINIMUM_PIN_LENGTH').nil? ? 4 : GsParameter.get('MINIMUM_PIN_LENGTH')), + :allow_nil => true, + :allow_blank => true validates_inclusion_of :speaker, :in => [true, false] validates_inclusion_of :moderator, :in => [true, false] -- cgit v1.2.3 From 28a21a6fce2b46f44e0a08b2d9d3f7b69f6cba9b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 12 Mar 2013 04:22:49 -0400 Subject: conference softkey provisioning --- app/controllers/config_snom_controller.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index eb94038..ae58ab8 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -281,7 +281,30 @@ class ConfigSnomController < ApplicationController when 'log_in' @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "speed f-li-#{softkey.number}"}) when 'conference' - @softkeys.push({:context => sip_account_index, :label => softkey.label, :data => "blf |f-ta-"}) + conference = softkey.softkeyable + if conference.class == Conference + @softkeys.push({ + :context => sip_account_index, + :function => softkey.softkey_function.name, + :label => softkey.label, + :softkey => softkey, + :general_type => t("softkeys.functions.#{softkey.softkey_function.name}"), + :subscription => { + :to => "sip:conference#{conference.id}@#{sip_account.host}", + :for => "sip:conference#{conference.id}@#{sip_account.host}", + }, + :actions => [{ + :type => :dial, + :target => "f-ta-#{softkey.number}", + :when => 'on press', + :states => 'connected,holding', + },{ + :type => :dial, + :target => softkey.number, + :when => 'on press', + }], + }) + end when 'parking_stall' parking_stall = softkey.softkeyable if parking_stall.class == ParkingStall -- cgit v1.2.3 From 3c5a0511d228fb3dc00ae860ade1b8ff032cc42f Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 12 Mar 2013 11:23:20 +0100 Subject: Refactoring --- app/controllers/trigger_controller.rb | 12 +++++ app/views/fax_documents/_fax_document.html.haml | 66 +++++++++++++++++++++++++ app/views/fax_documents/show.html.haml | 66 +------------------------ 3 files changed, 79 insertions(+), 65 deletions(-) create mode 100644 app/views/fax_documents/_fax_document.html.haml (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index fb53c37..e3fc524 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -63,6 +63,18 @@ class TriggerController < ApplicationController end end + def fax_has_been_sent + fax_document = FaxDocument.find(params[:id]) + + if fax_document + # push the partial to the webbrowser + # + new_html = render_to_string("fax_documents/_fax_document", :layout => false, :locals => {:fax_document => fax_document}) + PrivatePub.publish_to("/fax_documents/#{fax_document.id}", "$('#fax_document_" + fax_document.id.to_s + "').replaceWith(escape_javascript(" + new_html + "));") + end + + end + def fax if !params[:fax_account_id].blank? fax_account = FaxAccount.where(:id => params[:fax_account_id].to_i).first diff --git a/app/views/fax_documents/_fax_document.html.haml b/app/views/fax_documents/_fax_document.html.haml new file mode 100644 index 0000000..1fd5270 --- /dev/null +++ b/app/views/fax_documents/_fax_document.html.haml @@ -0,0 +1,66 @@ +.div{:id => "fax_document_#{fax_document.id}"} + .row + .span12 + %table.table.table-striped + - case fax_document.state + - when 'unsuccessful' + - current_status = 'error' + - when 'sending' + - current_status = 'success' + - when 'queued_for_sending' + - current_status = 'warning' + - else + - current_status = '' + + %tr{:class => current_status} + %td + %strong= t('fax_documents.index.state') + ":" + %td + = t("fax_documents.states.#{fax_document.state}") + %tr + %td + %strong= t('fax_documents.index.result_code') + ":" + %td + = fax_document.result_code + %tr + %td + %strong= t('fax_documents.index.result_text') + ":" + %td + = t("fax_documents.result_codes.code_#{fax_document.result_code}") + %tr + %td + %strong= t('fax_documents.show.document_transferred_pages') + ":" + %td + = fax_document.document_transferred_pages + %tr + %td + %strong= t('fax_documents.show.remote_station_id') + ":" + %td + = fax_document.remote_station_id + %tr + %td + %strong= t('fax_documents.show.fax_resolution') + ":" + %td + = fax_document.fax_resolution + + - if fax_document.document? + %p + %a{:href => fax_account_fax_document_path(fax_document.fax_account, fax_document, :format => :pdf), :method => :get} + %i{:class => 'icon-download'} + = t("fax_documents.index.actions.download_pdf") + " (#{number_to_human_size(fax_document.document.size, :precision => 2)})" + + .row + .span12 + - if fax_document.fax_thumbnails.any? + %ul.thumbnails + - fax_document.fax_thumbnails.limit(50).each do |fax_thumbnail| + %li.span4 + %div.thumbnail + %a.thumbnail{:href => fax_thumbnail.thumbnail.url} + =image_tag(fax_thumbnail.thumbnail.url, :alt => "Page #{fax_thumbnail.position}") + %p + = "#{fax_thumbnail.position}/#{fax_document.fax_thumbnails.count}" + + .row + .span12 + = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => fax_document.fax_account, :child => fax_document } \ No newline at end of file diff --git a/app/views/fax_documents/show.html.haml b/app/views/fax_documents/show.html.haml index af5552d..6ae0ee1 100644 --- a/app/views/fax_documents/show.html.haml +++ b/app/views/fax_documents/show.html.haml @@ -1,70 +1,6 @@ - content_for :title, t("fax_documents.show.page_title") -.row - .span12 - %table.table.table-striped - - case @fax_document.state - - when 'unsuccessful' - - current_status = 'error' - - when 'sending' - - current_status = 'success' - - when 'queued_for_sending' - - current_status = 'warning' - - else - - current_status = '' - - %tr{:class => current_status} - %td - %strong= t('fax_documents.index.state') + ":" - %td - = t("fax_documents.states.#{@fax_document.state}") - %tr - %td - %strong= t('fax_documents.index.result_code') + ":" - %td - = @fax_document.result_code - %tr - %td - %strong= t('fax_documents.index.result_text') + ":" - %td - = t("fax_documents.result_codes.code_#{@fax_document.result_code}") - %tr - %td - %strong= t('fax_documents.show.document_transferred_pages') + ":" - %td - = @fax_document.document_transferred_pages - %tr - %td - %strong= t('fax_documents.show.remote_station_id') + ":" - %td - = @fax_document.remote_station_id - %tr - %td - %strong= t('fax_documents.show.fax_resolution') + ":" - %td - = @fax_document.fax_resolution - - - if @fax_document.document? - %p - %a{:href => fax_account_fax_document_path(@fax_account, @fax_document, :format => :pdf), :method => :get} - %i{:class => 'icon-download'} - = t("fax_documents.index.actions.download_pdf") + " (#{number_to_human_size(@fax_document.document.size, :precision => 2)})" - -.row - .span12 - - if @fax_document.fax_thumbnails.any? - %ul.thumbnails - - @fax_document.fax_thumbnails.limit(50).each do |fax_thumbnail| - %li.span4 - %div.thumbnail - %a.thumbnail{:href => fax_thumbnail.thumbnail.url} - =image_tag(fax_thumbnail.thumbnail.url, :alt => "Page #{fax_thumbnail.position}") - %p - = "#{fax_thumbnail.position}/#{@fax_document.fax_thumbnails.count}" - -.row - .span12 - = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @fax_document.fax_account, :child => @fax_document } += render :partial => 'fax_document', :locals => {:fax_document => @fax_document} - if ['sending', 'queued_for_sending'].include? @fax_document.state = subscribe_to "/fax_documents/#{@fax_document.id}" \ No newline at end of file -- cgit v1.2.3 From d11a8692e742720435c4286e3752c8c136cc88cf Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 12 Mar 2013 12:32:32 +0100 Subject: jquery replaceWith for FaxDocument#view after sending the fax --- app/controllers/trigger_controller.rb | 20 +++++++++++++++++--- app/views/fax_documents/_fax_document.html.haml | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index e3fc524..3bd75a1 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -69,10 +69,24 @@ class TriggerController < ApplicationController if fax_document # push the partial to the webbrowser # - new_html = render_to_string("fax_documents/_fax_document", :layout => false, :locals => {:fax_document => fax_document}) - PrivatePub.publish_to("/fax_documents/#{fax_document.id}", "$('#fax_document_" + fax_document.id.to_s + "').replaceWith(escape_javascript(" + new_html + "));") + new_html = ActionController::Base.helpers.escape_javascript(render_to_string("fax_documents/_fax_document", :layout => false, :locals => {:fax_document => fax_document})) + Rails.logger.debug new_html + PrivatePub.publish_to("/fax_documents/#{fax_document.id}", "$('#" + fax_document.id.to_s + ".fax_document').replaceWith('#{new_html}');") + + render( + :status => 200, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + else + render( + :status => 501, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) end - end def fax diff --git a/app/views/fax_documents/_fax_document.html.haml b/app/views/fax_documents/_fax_document.html.haml index 1fd5270..930a0c3 100644 --- a/app/views/fax_documents/_fax_document.html.haml +++ b/app/views/fax_documents/_fax_document.html.haml @@ -1,4 +1,4 @@ -.div{:id => "fax_document_#{fax_document.id}"} +.fax_document{:id => fax_document.id} .row .span12 %table.table.table-striped -- cgit v1.2.3 From f788a35cd1a70ba08effb3807bbb313744324c85 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 12 Mar 2013 13:17:44 +0100 Subject: Add a * to the page title when a new voicemail or fax was received. --- app/controllers/trigger_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 3bd75a1..df6f39f 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -19,6 +19,7 @@ class TriggerController < ApplicationController # Indicate a new voicemail in the navigation bar. # PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_or_fax_indicator').hide('fast').show('slow');") + PrivatePub.publish_to("/users/#{user.id}/messages/new", "document.title = '* ' + document.title.replace( '* ' , '');") if user.email.blank? next @@ -70,7 +71,6 @@ class TriggerController < ApplicationController # push the partial to the webbrowser # new_html = ActionController::Base.helpers.escape_javascript(render_to_string("fax_documents/_fax_document", :layout => false, :locals => {:fax_document => fax_document})) - Rails.logger.debug new_html PrivatePub.publish_to("/fax_documents/#{fax_document.id}", "$('#" + fax_document.id.to_s + ".fax_document').replaceWith('#{new_html}');") render( @@ -143,6 +143,7 @@ class TriggerController < ApplicationController if @last_fax_document.fax_account.fax_accountable.class == User user = @last_fax_document.fax_account.fax_accountable PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_or_fax_indicator').hide('fast').show('slow');") + PrivatePub.publish_to("/users/#{user.id}/messages/new", "document.title = '* ' + document.title.replace( '* ' , '');") end render( -- cgit v1.2.3 From 5d3eeec6962010eb0b9cbcb9d3bb87d016bce199 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 12 Mar 2013 13:40:18 +0100 Subject: Added sip_account_update trigger --- app/controllers/trigger_controller.rb | 25 +++++++++++++++++++++++++ app/views/switchboards/show.html.haml | 2 ++ 2 files changed, 27 insertions(+) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index df6f39f..3445802 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -89,6 +89,31 @@ class TriggerController < ApplicationController end end + def sip_account_update + sip_account = SipAccount.find(params[:id]) + + if sip_account + # push the partial to the webbrowser + # + # new_html = ActionController::Base.helpers.escape_javascript(render_to_string("fax_documents/_fax_document", :layout => false, :locals => {:fax_document => fax_document})) + # PrivatePub.publish_to("/fax_documents/#{fax_document.id}", "$('#" + fax_document.id.to_s + ".fax_document').replaceWith('#{new_html}');") + + render( + :status => 200, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + else + render( + :status => 501, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + end + end + def fax if !params[:fax_account_id].blank? fax_account = FaxAccount.where(:id => params[:fax_account_id].to_i).first diff --git a/app/views/switchboards/show.html.haml b/app/views/switchboards/show.html.haml index 18671c2..2932366 100644 --- a/app/views/switchboards/show.html.haml +++ b/app/views/switchboards/show.html.haml @@ -16,3 +16,5 @@ %i.icon-edit.icon-white %span.hidden-phone =t("switchboard_entries.index.page_title") + += subscribe_to "/switchboards/#{@switchboard.id}" \ No newline at end of file -- cgit v1.2.3 From 3ca9b0e7af3dd475c4e69512cf49abfef4ddd0aa Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 12 Mar 2013 14:31:37 +0100 Subject: Replace SwitchboardEntry when the SipAccount gets updated. --- app/controllers/trigger_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 3445802..b8db4c9 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -95,8 +95,10 @@ class TriggerController < ApplicationController if sip_account # push the partial to the webbrowser # - # new_html = ActionController::Base.helpers.escape_javascript(render_to_string("fax_documents/_fax_document", :layout => false, :locals => {:fax_document => fax_document})) - # PrivatePub.publish_to("/fax_documents/#{fax_document.id}", "$('#" + fax_document.id.to_s + ".fax_document').replaceWith('#{new_html}');") + 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 render( :status => 200, -- cgit v1.2.3 From 1a9b4ef6d9ebbe77ba113d960d85c7097ae3368c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 13 Mar 2013 06:49:40 -0400 Subject: transfer_blind method added --- app/models/call.rb | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/call.rb b/app/models/call.rb index 8f657fa..61d10ce 100644 --- a/app/models/call.rb +++ b/app/models/call.rb @@ -39,6 +39,30 @@ class Call < ActiveRecord::Base return FreeswitchAPI.execute('uuid_kill', self.uuid, true); end + def transfer_blind(destination, call_leg=:aleg, auth_account=nil) + if destination.blank? + return nil + end + + if call_leg == :bleg + channel_uuid = self.b_uuid + else + channel_uuid = self.uuid + end + + if channel_uuid.blank? + return nil + end + + if auth_account + FreeswitchAPI.api('uuid_setvar', channel_uuid, 'gs_auth_account_type', auth_account.class.name) + FreeswitchAPI.api('uuid_setvar', channel_uuid, 'gs_auth_account_uuid', auth_account.uuid) + end + + require 'freeswitch_event' + return FreeswitchAPI.api_result(FreeswitchAPI.api('uuid_transfer', channel_uuid, destination)) + end + def get_variable_from_uuid(channel_uuid, variable_name) if channel_uuid.blank? return nil @@ -61,5 +85,5 @@ class Call < ActiveRecord::Base def get_variable_bleg(variable_name) return get_variable_from_uuid(self.b_uuid, variable_name); end - + end -- cgit v1.2.3 From 3e1092b532d34141d77f1e9176831e2bf82845ac Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 13 Mar 2013 10:03:01 -0400 Subject: load freeswitch_event module before use --- app/models/call.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/models/call.rb b/app/models/call.rb index 61d10ce..a8a0d7f 100644 --- a/app/models/call.rb +++ b/app/models/call.rb @@ -54,12 +54,12 @@ class Call < ActiveRecord::Base return nil end + require 'freeswitch_event' if auth_account FreeswitchAPI.api('uuid_setvar', channel_uuid, 'gs_auth_account_type', auth_account.class.name) FreeswitchAPI.api('uuid_setvar', channel_uuid, 'gs_auth_account_uuid', auth_account.uuid) end - require 'freeswitch_event' return FreeswitchAPI.api_result(FreeswitchAPI.api('uuid_transfer', channel_uuid, destination)) end @@ -85,5 +85,5 @@ class Call < ActiveRecord::Base def get_variable_bleg(variable_name) return get_variable_from_uuid(self.b_uuid, variable_name); end - + end -- cgit v1.2.3 From d2cfd8203e0108db3b49d10a7ca3990f49667a9e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 13 Mar 2013 10:03:39 -0400 Subject: list_members method added --- app/models/conference.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/conference.rb b/app/models/conference.rb index 6c89d60..880b958 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -49,9 +49,27 @@ class Conference < ActiveRecord::Base def to_s name end + + def list_conference + require 'freeswitch_event' + result = FreeswitchAPI.api_result(FreeswitchAPI.api('conference', "conference#{self.id}", 'xml_list')) + if result =~ /^\<\?xml/ + return Hash.from_xml(result) + end + return nil + end + + def list_members + data = self.list_conference + if data.blank? + return {} + end + + return data.fetch('conferences',{}).fetch('conference',{}).fetch('members',{}).fetch('member',{}) + end + private - def start_and_end_dates_must_make_sense errors.add(:end, 'must be later than the start') if self.end < self.start end -- cgit v1.2.3 From c9dde701750d237a9a07c31ecf402940af2d7d18 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 13 Mar 2013 16:35:23 +0100 Subject: Bugfix. closes #239 --- app/models/user.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'app') diff --git a/app/models/user.rb b/app/models/user.rb index 6091e32..b74fc06 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -74,8 +74,6 @@ class User < ActiveRecord::Base has_many :fax_accounts, :as => :fax_accountable, :dependent => :destroy - has_many :system_messages, :dependent => :destroy - has_many :auto_destroy_access_authorization_phone_numbers, :class_name => 'PhoneNumber', :foreign_key => 'access_authorization_user_id', :dependent => :destroy belongs_to :current_tenant, :class_name => 'Tenant' -- cgit v1.2.3 From ff991ce3d6c999783b8a5d3cae7b8e4635406a83 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 13 Mar 2013 11:55:21 -0400 Subject: routing test method added --- app/models/call_route.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app') diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 6c54549..590d49b 100644 --- a/app/models/call_route.rb +++ b/app/models/call_route.rb @@ -253,4 +253,20 @@ class CallRoute < ActiveRecord::Base end end + + def self.test_route(table, caller) + arguments = ["'#{table}' table"] + caller.each do |key, value| + arguments << "'#{value}' '#{key}'" + end + + require 'freeswitch_event' + result = FreeswitchAPI.api_result(FreeswitchAPI.api('lua', 'test_route.lua', arguments.join(' '))) + if result.blank? then + return + end + + return JSON.parse(result) + end + end -- cgit v1.2.3 From dcdd37036f45d13b7402436ddb1af65c78052ca9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 13 Mar 2013 15:41:17 -0400 Subject: routing test view --- app/controllers/call_routes_controller.rb | 7 ++++ app/views/call_routes/test.html.haml | 55 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 app/views/call_routes/test.html.haml (limited to 'app') diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 2dcd648..50e7849 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -87,6 +87,13 @@ class CallRoutesController < ApplicationController end end + def test + sip_account = SipAccount.where(:id => params[:sip_account_id]).first; + destination_number = params[:destination_number] + routing_table = params[:routing_table] + @route_test = CallRoute.test_route(routing_table, {'caller.destination_number' => destination_number, 'caller.auth_account_type' => 'SipAccount', 'caller.auth_account_uuid' => sip_account.uuid}) + end + private def call_route_parameter_params params.require(:call_route).permit(:routing_table, :name, :endpoint_type, :endpoint_id, :position) diff --git a/app/views/call_routes/test.html.haml b/app/views/call_routes/test.html.haml new file mode 100644 index 0000000..0b0fba7 --- /dev/null +++ b/app/views/call_routes/test.html.haml @@ -0,0 +1,55 @@ +%h2= 'Routing Test' + +- if @route_test + - if @route_test['destination'] + %h3= 'Destination' + %table.table.table-striped + %thead + %tr + %td= 'number' + %td= 'type' + %td= 'ID' + + %tbody{ :id => "destination" } + %tr + %td= @route_test['destination']['number'] + %td= @route_test['destination']['type'] + %td= @route_test['destination']['id'] + -if @route_test['routes'] && @route_test['routes'].count > 0 + %h3= 'Routes' + %table.table.table-striped + %thead + %tr + %th + %th= 'ID' + %th= 'destination_number' + %th= 'endpoint' + + %tbody{ :id => "route_test" } + - @route_test['routes'].each do |index, route_entry| + %tr + %td= index + %td= route_entry['route_id'] + %td= route_entry['destination_number'] + %td= "#{route_entry['type']}=#{route_entry['id']}" + -if @route_test['log'] && @route_test['log'].count > 0 + %h3= 'Log' + %table.table.table-striped + %thead + %tr + %th + %tbody{ :id => "log" } + - @route_test['log'].each do |index, log_line| + - if log_line =~ /^ROUTE_NO_MATCH/ + - entry_class = 'table error' + - elsif log_line =~ /^ELEMENT_NO_MATCH/ + - entry_class = 'table warning' + - elsif log_line =~ /^ROUTE \d+ / + - entry_class = 'table success' + - elsif log_line =~ /^[A-Z_]+_MATCH/ + - entry_class = 'table info' + - else + - entry_class = nil + %tr{:class => entry_class} + %td= log_line + -- cgit v1.2.3 From 0840ee7eb193d838724de7227b19824abd5b2bf3 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 14 Mar 2013 03:47:54 -0400 Subject: gateway status methods --- app/models/gateway.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'app') diff --git a/app/models/gateway.rb b/app/models/gateway.rb index 2f17b57..bf391fb 100644 --- a/app/models/gateway.rb +++ b/app/models/gateway.rb @@ -27,7 +27,34 @@ class Gateway < ActiveRecord::Base "#{GATEWAY_PREFIX}#{self.id}" end + def status + if self.technology == 'sip' then + return status_sip + end + end + + def inbound_register + username = self.gateway_settings.where(:name => 'inbound_username').first.try(:value) + if username.blank? + return + end + + return SipRegistration.where(:sip_user => username).first + end + private + def status_sip + require 'freeswitch_event' + result = FreeswitchAPI.api_result(FreeswitchAPI.api('sofia', 'xmlstatus', 'gateway', "gateway#{self.id}")) + if result =~ /^\<\?xml/ + data = Hash.from_xml(result) + if data + return data.fetch('gateway', nil) + end + end + return nil + end + def downcase_technology self.technology = self.technology.downcase if !self.technology.blank? end -- cgit v1.2.3 From 25d58b40dfb51ddf6f566ded43c335146ac5fbb7 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 14 Mar 2013 03:48:16 -0400 Subject: show gateway status --- app/views/gateways/show.html.haml | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'app') diff --git a/app/views/gateways/show.html.haml b/app/views/gateways/show.html.haml index 6cf09ec..f2e9ab8 100644 --- a/app/views/gateways/show.html.haml +++ b/app/views/gateways/show.html.haml @@ -33,6 +33,81 @@ %td = @gateway.description + - if @gateway.technology.to_s == 'sip' + - status = @gateway.status + %tr + %td + %strong= t('gateways.show.status') + ":" + %td + = "#{status['status']} (#{status['state']})" + %tr + %td + %strong= t('gateways.show.identifier') + ":" + %td + = status['name'] + %tr + %td + %strong= t('gateways.show.profile') + ":" + %td + = status['profile'] + %tr + %td + %strong= t('gateways.show.username') + ":" + %td + = status['username'] + %tr + %td + %strong= t('gateways.show.password') + ":" + %td + = status['password'] + %tr + %td + %strong= t('gateways.show.realm') + ":" + %td + = status['realm'] + %tr + %td + %strong= t('gateways.show.contact') + ":" + %td + = status['contact'] + %tr + %td + %strong= t('gateways.show.from') + ":" + %td + = status['from'] + %tr + %td + %strong= t('gateways.show.to') + ":" + %td + = status['to'] + %tr + %td + %strong= t('gateways.show.proxy') + ":" + %td + = status['proxy'] + - registration = @gateway.inbound_register + - if !registration.blank? + %tr + %td + %strong= t('gateways.show.inbound_register_status') + ":" + %td + = registration.status + %tr + %td + %strong= t('gateways.show.inbound_register_contact') + ":" + %td + = registration.contact + %tr + %td + %strong= t('gateways.show.inbound_register_user_agent') + ":" + %td + = registration.user_agent + %tr + %td + %strong= t('gateways.show.inbound_register_network') + ":" + %td + = "#{registration.network_ip}:#{registration.network_port}" + = render :partial => 'shared/show_edit_destroy_part', :locals => { :child => @gateway } -- cgit v1.2.3 From 7c5c0f972b6127335bc1f9b3141b8df0c5d35fbf Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 14 Mar 2013 04:01:17 -0400 Subject: status record can be nil --- app/views/gateways/show.html.haml | 101 +++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 50 deletions(-) (limited to 'app') diff --git a/app/views/gateways/show.html.haml b/app/views/gateways/show.html.haml index f2e9ab8..19b1304 100644 --- a/app/views/gateways/show.html.haml +++ b/app/views/gateways/show.html.haml @@ -35,56 +35,57 @@ - if @gateway.technology.to_s == 'sip' - status = @gateway.status - %tr - %td - %strong= t('gateways.show.status') + ":" - %td - = "#{status['status']} (#{status['state']})" - %tr - %td - %strong= t('gateways.show.identifier') + ":" - %td - = status['name'] - %tr - %td - %strong= t('gateways.show.profile') + ":" - %td - = status['profile'] - %tr - %td - %strong= t('gateways.show.username') + ":" - %td - = status['username'] - %tr - %td - %strong= t('gateways.show.password') + ":" - %td - = status['password'] - %tr - %td - %strong= t('gateways.show.realm') + ":" - %td - = status['realm'] - %tr - %td - %strong= t('gateways.show.contact') + ":" - %td - = status['contact'] - %tr - %td - %strong= t('gateways.show.from') + ":" - %td - = status['from'] - %tr - %td - %strong= t('gateways.show.to') + ":" - %td - = status['to'] - %tr - %td - %strong= t('gateways.show.proxy') + ":" - %td - = status['proxy'] + - if !@gateway.status.blank? + %tr + %td + %strong= t('gateways.show.status') + ":" + %td + = "#{status['status']} (#{status['state']})" + %tr + %td + %strong= t('gateways.show.identifier') + ":" + %td + = status['name'] + %tr + %td + %strong= t('gateways.show.profile') + ":" + %td + = status['profile'] + %tr + %td + %strong= t('gateways.show.username') + ":" + %td + = status['username'] + %tr + %td + %strong= t('gateways.show.password') + ":" + %td + = status['password'] + %tr + %td + %strong= t('gateways.show.realm') + ":" + %td + = status['realm'] + %tr + %td + %strong= t('gateways.show.contact') + ":" + %td + = status['contact'] + %tr + %td + %strong= t('gateways.show.from') + ":" + %td + = status['from'] + %tr + %td + %strong= t('gateways.show.to') + ":" + %td + = status['to'] + %tr + %td + %strong= t('gateways.show.proxy') + ":" + %td + = status['proxy'] - registration = @gateway.inbound_register - if !registration.blank? %tr -- cgit v1.2.3 From 40d8290361bff123e0b44defa0f199708b89093b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 14 Mar 2013 18:34:57 +0100 Subject: Adds a new remote_ip_address methode to figure out the remote IP address. #245 --- app/controllers/application_controller.rb | 4 ++++ app/controllers/config_polycom_controller.rb | 4 ++-- app/controllers/config_siemens_controller.rb | 2 +- app/controllers/config_snom_controller.rb | 4 ++-- app/controllers/gs_nodes_controller.rb | 2 +- app/controllers/trigger_controller.rb | 2 +- app/views/switchboard_entries/_switchboard_entry.html.haml | 2 +- 7 files changed, 12 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d1d918e..12bea54 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -110,6 +110,10 @@ class ApplicationController < ActionController::Base redirect_to log_in_path, :alert => 'Access denied! You need to login first.' end end + + def request_remote_ip + request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip + end private diff --git a/app/controllers/config_polycom_controller.rb b/app/controllers/config_polycom_controller.rb index fd730e3..ca314c2 100644 --- a/app/controllers/config_polycom_controller.rb +++ b/app/controllers/config_polycom_controller.rb @@ -67,8 +67,8 @@ class ConfigPolycomController < ApplicationController if ! request.env['HTTP_USER_AGENT'].index('polycom') Rails.logger.info "---> User-Agent indicates not a Polycom phone (#{request.env['HTTP_USER_AGENT'].inspect})" else - Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request.remote_ip.inspect}" - @phone.update_attributes({ :ip_address => request.remote_ip }) + Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request_remote_ip.inspect}" + @phone.update_attributes({ :ip_address => request_remote_ip }) end xml_applications_url = "#{request.protocol}#{request.host_with_port}/config_polycom/#{@phone.id}/0" diff --git a/app/controllers/config_siemens_controller.rb b/app/controllers/config_siemens_controller.rb index 1966d49..7d5eb3f 100644 --- a/app/controllers/config_siemens_controller.rb +++ b/app/controllers/config_siemens_controller.rb @@ -146,7 +146,7 @@ class ConfigSiemensController < ApplicationController country = 'US' language = 'en' if ! @phone.nil? - @phone.update_attributes(:ip_address => request.remote_ip) + @phone.update_attributes(:ip_address => request_remote_ip) @sip_account = @phone.sip_accounts.where(:sip_accountable_type => @phone.phoneable_type, :sip_accountable_id => @phone.phoneable_id).first diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index ae58ab8..8db1d57 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -233,8 +233,8 @@ class ConfigSnomController < ApplicationController if ! request.env['HTTP_USER_AGENT'].index('snom') Rails.logger.info "---> User-Agent indicates not a Snom phone (#{request.env['HTTP_USER_AGENT'].inspect})" else - Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request.remote_ip.inspect}" - @phone.update_attributes({ :ip_address => request.remote_ip }) + Rails.logger.info "---> Phone #{@mac_address.inspect}, IP address #{request_remote_ip.inspect}" + @phone.update_attributes({ :ip_address => request_remote_ip }) end @softkeys = Array.new() diff --git a/app/controllers/gs_nodes_controller.rb b/app/controllers/gs_nodes_controller.rb index 17c9e8b..6a5e0a6 100644 --- a/app/controllers/gs_nodes_controller.rb +++ b/app/controllers/gs_nodes_controller.rb @@ -48,7 +48,7 @@ class GsNodesController < ApplicationController end def sync - if !GsNode.where(:ip_address => request.remote_ip).first + if !GsNode.where(:ip_address => request_remote_ip).first render( :status => 404, :layout => false, diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index b8db4c9..623ea94 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -97,7 +97,7 @@ class TriggerController < ApplicationController # 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}');") + PrivatePub.publish_to("/switchboards/#{switchboard_entry.switchboard.id}", "$('#switchboard_entry_id_" + switchboard_entry.id.to_s + "').replaceWith('#{new_html}');") end render( diff --git a/app/views/switchboard_entries/_switchboard_entry.html.haml b/app/views/switchboard_entries/_switchboard_entry.html.haml index 8d8e747..b2b6bff 100644 --- a/app/views/switchboard_entries/_switchboard_entry.html.haml +++ b/app/views/switchboard_entries/_switchboard_entry.html.haml @@ -2,7 +2,7 @@ %div.thumbnail %a.thumbnail{:href => tenant_user_path(switchboard_entry.sip_account.sip_accountable.current_tenant, switchboard_entry.sip_account.sip_accountable)} - if switchboard_entry.sip_account.sip_accountable.image? - = image_tag(switchboard_entry.sip_account.sip_accountable.image_url(:mini).to_s, :class => 'img-rounded') + = image_tag(switchboard_entry.sip_account.sip_accountable.image_url(:small).to_s, :class => 'img-rounded') - else - if switchboard_entry.sip_account.sip_accountable.male? = image_tag 'icons/user-male-16x.png', :class => 'img-rounded' -- cgit v1.2.3 From f476fb7648fd235642233b2bbe5bb90cb57e8549 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 14 Mar 2013 18:57:24 +0100 Subject: Bugfix --- app/controllers/trigger_controller.rb | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 623ea94..0c635b9 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -92,28 +92,21 @@ class TriggerController < ApplicationController def sip_account_update sip_account = SipAccount.find(params[:id]) - if sip_account + 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 - - render( - :status => 200, - :layout => false, - :content_type => 'text/plain', - :text => "", - ) - else - render( - :status => 501, - :layout => false, - :content_type => 'text/plain', - :text => "", - ) + end end + + render( + :status => 200, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) end def fax -- cgit v1.2.3 From 3a0ea10cdd6084a8beb235f5c1573c22a5d733f0 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 14 Mar 2013 20:21:59 +0100 Subject: Added a dashboard for Switchboard. --- app/controllers/trigger_controller.rb | 19 ++++++++------- .../_switchboard_entry.html.haml | 28 +++++++++++++--------- .../switchboards/_current_user_dashboard.html.haml | 26 ++++++++++++++++++++ app/views/switchboards/show.html.haml | 23 +++++++++--------- 4 files changed, 66 insertions(+), 30 deletions(-) create mode 100644 app/views/switchboards/_current_user_dashboard.html.haml (limited to 'app') 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 -- cgit v1.2.3 From 0b4e3dfd031b21c26f7bc9c7c05cd931950ecbd6 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 14 Mar 2013 21:34:06 +0100 Subject: Switchboard stuff --- app/controllers/trigger_controller.rb | 7 +++-- .../_switchboard_entry.html.haml | 34 +++++++++++++-------- .../switchboards/_current_user_dashboard.html.haml | 35 +++++++++++++--------- 3 files changed, 47 insertions(+), 29 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index fc0556b..a858e33 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -100,8 +100,11 @@ class TriggerController < ApplicationController 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}');") + if sip_account.call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any? || + sip_account.b_call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any? + 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 end render( diff --git a/app/views/switchboard_entries/_switchboard_entry.html.haml b/app/views/switchboard_entries/_switchboard_entry.html.haml index 8d4ee92..b82bb74 100644 --- a/app/views/switchboard_entries/_switchboard_entry.html.haml +++ b/app/views/switchboard_entries/_switchboard_entry.html.haml @@ -1,16 +1,16 @@ -%li.span1{:id => "switchboard_entry_id_#{switchboard_entry.id}"} +%li.span2{:id => "switchboard_entry_id_#{switchboard_entry.id}"} %div.thumbnail %a.thumbnail{:href => tenant_user_path(switchboard_entry.sip_account.sip_accountable.current_tenant, switchboard_entry.sip_account.sip_accountable)} - if switchboard_entry.sip_account.sip_accountable.image? - = image_tag(switchboard_entry.sip_account.sip_accountable.image_url(:small).to_s, :class => 'img-rounded') + = image_tag(switchboard_entry.sip_account.sip_accountable.image_url(:profile).to_s, :class => 'img-rounded', :style => 'width: 100px;') - else - if switchboard_entry.sip_account.sip_accountable.male? - = image_tag 'icons/user-male-16x.png', :class => 'img-rounded' + = image_tag('icons/user-male-16x.png', :class => 'img-rounded', :style => 'width: 100px;') - else - = image_tag 'icons/user-female-16x.png', :class => 'img-rounded' + = image_tag('icons/user-female-16x.png', :class => 'img-rounded', :style => 'width: 100px;') %p %small - = truncate(switchboard_entry.to_s, :length => 10) + = truncate(switchboard_entry.to_s, :length => 23) %br - if switchboard_entry.sip_account.phone_numbers.any? %span.label @@ -19,15 +19,23 @@ %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}" + - switchboard_entry.sip_account.call_legs.where(callstate: 'RINGING').each do |call_leg| + %span.label.label-warning + %i.icon-bell.icon-white + = "#{call_leg.caller_id_number}" + + - switchboard_entry.sip_account.call_legs.where(callstate: 'EARLY').each do |call_leg| + %span.label.label-info + = "calls #{call_leg.destination}" + + - switchboard_entry.sip_account.call_legs.where(callstate: 'ACTIVE').each do |call_leg| + %span.label.label-info + = "#{call_leg.b_caller_id_number} => #{call_leg.callee_number}" + + - switchboard_entry.sip_account.b_call_legs.where(b_callstate: 'ACTIVE').each do |b_call_leg| + %span.label.label-info + = "#{b_call_leg.b_caller_id_number} => #{b_call_leg.destination}" - - 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 index 1c57a0d..8dd75b9 100644 --- a/app/views/switchboards/_current_user_dashboard.html.haml +++ b/app/views/switchboards/_current_user_dashboard.html.haml @@ -4,23 +4,30 @@ %thead %tr %td - SIP Account - %td - Direction - %td - StartStamp %td Destination %td - CalleeName + Start + %td{:span => '2'} + Caller %tbody - - sip_account.calls.each do |call| + - sip_account.call_legs.where(callstate: 'RINGING').each do |call_leg| + %tr.warning + %td + %i.icon-bell + %td + %span.label.label-info + =sip_account.phone_numbers.first.to_s + %td=l Time.at(call_leg.start_stamp) + %td=call_leg.callee_name + %td=call_leg.callee_number + + - sip_account.b_call_legs.where(direction: 'inbound').each do |call_leg| %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 + %td + %span.label.label-info + =sip_account.phone_numbers.first.to_s + %td=l Time.at(call_leg.start_stamp) + %td=call_leg.b_caller_id_name + %td=call_leg.b_caller_id_number -- cgit v1.2.3 From 5ed3837a8688e46a33d3ad3b0eb0343eb1a5ba85 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 14 Mar 2013 21:41:33 +0100 Subject: Switchboard UI improvements. --- app/views/switchboard_entries/_switchboard_entry.html.haml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/views/switchboard_entries/_switchboard_entry.html.haml b/app/views/switchboard_entries/_switchboard_entry.html.haml index b82bb74..8c44153 100644 --- a/app/views/switchboard_entries/_switchboard_entry.html.haml +++ b/app/views/switchboard_entries/_switchboard_entry.html.haml @@ -12,7 +12,7 @@ %small = truncate(switchboard_entry.to_s, :length => 23) %br - - if switchboard_entry.sip_account.phone_numbers.any? + - if switchboard_entry.sip_account.phone_numbers.any? && !switchboard_entry.sip_account.call_legs.where(callstate: 'ACTIVE').any? && !switchboard_entry.sip_account.b_call_legs.where(b_callstate: 'ACTIVE').any? %span.label = switchboard_entry.sip_account.phone_numbers.first.number @@ -29,12 +29,16 @@ = "calls #{call_leg.destination}" - switchboard_entry.sip_account.call_legs.where(callstate: 'ACTIVE').each do |call_leg| + %span.label + = "#{switchboard_entry.sip_account.phone_numbers.first.number} => " %span.label.label-info - = "#{call_leg.b_caller_id_number} => #{call_leg.callee_number}" + = "#{call_leg.callee_number}" - switchboard_entry.sip_account.b_call_legs.where(b_callstate: 'ACTIVE').each do |b_call_leg| %span.label.label-info - = "#{b_call_leg.b_caller_id_number} => #{b_call_leg.destination}" + = "#{b_call_leg.b_caller_id_number} =>" + %span.label + = switchboard_entry.sip_account.phone_numbers.first.number - else %span.label.label-inverse -- cgit v1.2.3 From 910fcee54d7ce3460815d4535556d497a343ea99 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 15 Mar 2013 05:29:49 -0400 Subject: status fixed --- app/models/sip_account.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index cea5f0e..50124e9 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -188,25 +188,30 @@ class SipAccount < ActiveRecord::Base def status states = Array.new - SipAccount.last.call_legs.each do |call_leg| + self.call_legs.each do |call_leg| states << { - :status => call_leg.callstate, + :status => call_leg.b_callstate || call_leg.callstate, + :status_channel => call_leg.callstate, :caller => true, :endpoint_name => call_leg.callee_name, :endpoint_number => call_leg.destination, :endpoint_sip_account_id => call_leg.b_sip_account_id, :start_stamp => call_leg.start_stamp, + :secure => call_leg.secure, } end - SipAccount.last.b_call_legs.each do |call_leg| + self.b_call_legs.each do |call_leg| + call_status = states << { - :status => call_leg.callstate, + :status => call_leg.b_callstate, + :status_channel => call_leg.b_callstate, :caller => false, :endpoint_name => call_leg.caller_id_name, :endpoint_number => call_leg.caller_id_number, :endpoint_sip_account_id => call_leg.sip_account_id, :start_stamp => call_leg.start_stamp, + :secure => call_leg.b_secure, } end -- cgit v1.2.3 From baf86f285be7c02535c3bc1cd25bf8c69b3b2051 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 15 Mar 2013 06:02:44 -0400 Subject: Germans are serious about call progress tones --- app/controllers/gemeinschaft_setups_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app') diff --git a/app/controllers/gemeinschaft_setups_controller.rb b/app/controllers/gemeinschaft_setups_controller.rb index a62df99..4949fa7 100644 --- a/app/controllers/gemeinschaft_setups_controller.rb +++ b/app/controllers/gemeinschaft_setups_controller.rb @@ -62,6 +62,11 @@ class GemeinschaftSetupsController < ApplicationController GsParameter.where(:name => 'ringtone_url').first.update_attributes(:value => "http://#{@gemeinschaft_setup.sip_domain.host}") GsParameter.where(:name => 'user_image_url').first.update_attributes(:value => "http://#{@gemeinschaft_setup.sip_domain.host}/uploads/user/image") + # Set ringback_tone + if @gemeinschaft_setup.country.country_code.to_s == '49' + GsParameter.where(:entity => 'dialplan', :section => 'variables', :name => 'ringback').first.update_attributes(:value => '%(1000,4000,425.0)') + end + # Restart FreeSWITCH if Rails.env.production? require 'freeswitch_event' -- cgit v1.2.3 From 5f909eb79791c7ab232a8693712cce2583a6ee0b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 15 Mar 2013 08:42:30 -0400 Subject: display label --- app/views/softkeys/show.html.haml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app') diff --git a/app/views/softkeys/show.html.haml b/app/views/softkeys/show.html.haml index 7c068ae..64adbe6 100644 --- a/app/views/softkeys/show.html.haml +++ b/app/views/softkeys/show.html.haml @@ -1,5 +1,8 @@ - content_for :title, t("softkeys.show.page_title") +%p + %strong= t("softkeys.show.label") + ":" + =@softkey.label %p %strong= t("softkeys.functions.#{@softkey.softkey_function}") + ":" =@softkey.to_s -- cgit v1.2.3 From 5fdcf4e66f1b9d926ace0ab4a78db177b7487ad6 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 15 Mar 2013 08:43:29 -0400 Subject: test action --- app/controllers/call_routes_controller.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 50e7849..819b593 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -88,10 +88,17 @@ class CallRoutesController < ApplicationController end def test - sip_account = SipAccount.where(:id => params[:sip_account_id]).first; - destination_number = params[:destination_number] - routing_table = params[:routing_table] - @route_test = CallRoute.test_route(routing_table, {'caller.destination_number' => destination_number, 'caller.auth_account_type' => 'SipAccount', 'caller.auth_account_uuid' => sip_account.uuid}) + if !params[:sip_account_id].blank? + account = SipAccount.where(:id => params[:sip_account_id]).first + elsif !params[:hunt_group_id].blank? + account = HuntGroup.where(:id => params[:hunt_group_id]).first + end + + if account + destination_number = params[:destination_number] + routing_table = params[:routing_table] + @route_test = CallRoute.test_route(routing_table, {'caller.destination_number' => destination_number, 'caller.auth_account_type' => account.class.name, 'caller.auth_account_id' => account.id, 'caller.auth_account_uuid' => account.try(:uuid)}) + end end private -- cgit v1.2.3 From 87655b8f02c5cdefc44abbacea8e60deefaf77c4 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 17 Mar 2013 02:08:18 -0400 Subject: set caller account --- app/controllers/call_routes_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 819b593..e5cf56a 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -97,7 +97,15 @@ class CallRoutesController < ApplicationController if account destination_number = params[:destination_number] routing_table = params[:routing_table] - @route_test = CallRoute.test_route(routing_table, {'caller.destination_number' => destination_number, 'caller.auth_account_type' => account.class.name, 'caller.auth_account_id' => account.id, 'caller.auth_account_uuid' => account.try(:uuid)}) + @route_test = CallRoute.test_route(routing_table, { + 'caller.destination_number' => destination_number, + 'caller.auth_account_type' => account.class.name, + 'caller.auth_account_id' => account.id, + 'caller.auth_account_uuid' => account.try(:uuid), + 'caller.account_type' => account.class.name, + 'caller.account_id' => account.id, + 'caller.account_uuid' => account.try(:uuid), + }) end end -- cgit v1.2.3 From 0ed2894ca7371199788c202b61f53a3f73c4b03b Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 17 Mar 2013 12:44:33 +0100 Subject: Reduce the push load. --- app/controllers/trigger_controller.rb | 29 ++++++++++++++++++----------- app/models/sip_account.rb | 5 ----- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index a858e33..6b58d6a 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -92,19 +92,26 @@ class TriggerController < ApplicationController def sip_account_update sip_account = SipAccount.find(params[:id]) - # 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 + if sip_account.updated_at < Time.now - Switchboard.all.each do |switchboard| - if sip_account.call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any? || - sip_account.b_call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any? - 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}');") + # Push an update to sip_account.switchboard_entries + # + sip_account.switchboard_entries.each do |switchboard_entry| + escaped_switchboard_entry_partial = 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('#{escaped_switchboard_entry_partial}');") end + + # Push an update to the needed switchboards + # + Switchboard.where(:user_id => sip_account.sip_accountable.id).each do |switchboard| + if sip_account.call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any? || + sip_account.b_call_legs.where(:sip_account_id => switchboard.user.sip_account_ids).any? + escaped_switchboard_partial = 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('#{escaped_switchboard_partial}');") + end + end + + sip_account.touch end render( diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index cea5f0e..930069d 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -213,11 +213,6 @@ class SipAccount < ActiveRecord::Base return states end - def non_e164_phone_numbers - array_of_phone_numbers_as_strings = self.phone_numbers.map{ |phone_number| phone_number.number.to_s }.sort - self.phone_numbers.where(:number => array_of_phone_numbers_as_strings.select { |phone_number| phone_number[0] != '+' }) - end - private def save_value_of_to_s -- cgit v1.2.3 From 7cd62ec6d7e40da2d1882d3ec056dae40c2f7b80 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 18 Mar 2013 04:44:37 -0400 Subject: callto: url added --- app/controllers/sip_accounts_controller.rb | 5 ++++- app/views/sip_accounts/show.html.haml | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index b34172d..0d7cbfe 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -10,7 +10,10 @@ class SipAccountsController < ApplicationController end def show - @register_tel_protocol = "#{request.protocol}#{request.host_with_port}/sip_accounts/#{@sip_account.try(:id)}/calls/new?url=%s" + @register_protocols = { + :tel => "#{request.protocol}#{request.host_with_port}/sip_accounts/#{@sip_account.try(:id)}/calls/new?url=%s", + :callto => "#{request.protocol}#{request.host_with_port}/sip_accounts/#{@sip_account.try(:id)}/calls/new?url=%s", + } end def new diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml index 9f84c92..e79907f 100644 --- a/app/views/sip_accounts/show.html.haml +++ b/app/views/sip_accounts/show.html.haml @@ -60,12 +60,14 @@ = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @sip_account.sip_accountable, :child => @sip_account } -%p - %strong= t('sip_accounts.show.tel_protocol') + ':' -%p - %a.btn.btn-small.btn-default{ :href => '', :onclick => "navigator.registerProtocolHandler(\"tel\", \"#{@register_tel_protocol}\", \"#{@sip_account.to_s}\");" } - %i.icon-plus - = t('sip_accounts.show.register_tel_protocol') +- if @register_protocols.count > 0 + %p + %strong= t('sip_accounts.show.call_protocols') + ':' + %p + - @register_protocols.each do |protocol, url| + %a.btn.btn-small.btn-default{ :href => '', :onclick => "navigator.registerProtocolHandler(\"#{protocol}\", \"#{url}\", \"#{@sip_account.to_s}\");" } + %i.icon-plus + = t("sip_accounts.show.register_#{protocol}_protocol") %p %strong= t('ringtones.name') + ':' -- cgit v1.2.3 From 2470988e06ff861c92d3dc833755f4b262798a12 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 19 Mar 2013 01:57:10 -0400 Subject: members list view added --- app/views/conferences/_index_members.html.haml | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/views/conferences/_index_members.html.haml (limited to 'app') diff --git a/app/views/conferences/_index_members.html.haml b/app/views/conferences/_index_members.html.haml new file mode 100644 index 0000000..3837f25 --- /dev/null +++ b/app/views/conferences/_index_members.html.haml @@ -0,0 +1,40 @@ +%table.table.table-striped + %thead + %tr + %th= t('conferences.index_members.caller') + %th= t('conferences.index_members.join_time') + %th= t('conferences.index_members.talking') + %th= t('conferences.index_members.flags') + + + %tbody + - for member in members + %tr + %td + -if member[:call] + - if member[:call_bleg] + = member[:call].b_caller_id_name + = member[:call].b_caller_id_number + - else + = member[:call].caller_id_name + = member[:call].caller_id_number + %td + = member['join_time'] + %td + = member['flags']['talking'] + %td + - if member['flags']['can_hear'] == 'true' + %span.label + = t('conferences.index_members.can_hear') + - if member['flags']['can_speak'] == 'true' + %span.label + = t('conferences.index_members.can_speak') + - if member['flags']['is_moderator'] == 'true' + %span.label + = t('conferences.index_members.moderator') + - if member['flags']['has_floor'] == 'true' + %span.label + = t('conferences.index_members.has_floor') + - if member['flags']['has_video'] == 'true' + %span.label + = t('conferences.index_members.video') -- cgit v1.2.3 From e6e893009b763ac8013088a9f8d041e5e43c0bd3 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 19 Mar 2013 01:57:37 -0400 Subject: retrieve conference data --- app/models/conference.rb | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/models/conference.rb b/app/models/conference.rb index 880b958..a9d6708 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -54,18 +54,35 @@ class Conference < ActiveRecord::Base require 'freeswitch_event' result = FreeswitchAPI.api_result(FreeswitchAPI.api('conference', "conference#{self.id}", 'xml_list')) if result =~ /^\<\?xml/ - return Hash.from_xml(result) + data = Hash.from_xml(result) + if data + return data.fetch('conferences',{}).fetch('conference',{}) + end end return nil end - def list_members - data = self.list_conference + def list_members(data=self.list_conference()) if data.blank? return {} end - return data.fetch('conferences',{}).fetch('conference',{}).fetch('members',{}).fetch('member',{}) + members = data.fetch('members',{}).fetch('member',{}) + if members.class != Array + members = [members] + end + + members.each_with_index do |member, index| + members[index][:call] = Call.where(:uuid => member['uuid']).first + if !members[index][:call] + members[index][:call] = Call.where(:b_uuid => member['uuid']).first + if members[index][:call] + members[index][:call_bleg] = true; + end + end + end + + return members; end -- cgit v1.2.3 From 6f3629d352b05524cb7351d235d184802e381974 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 19 Mar 2013 01:58:21 -0400 Subject: list members --- app/views/conferences/show.html.haml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app') diff --git a/app/views/conferences/show.html.haml b/app/views/conferences/show.html.haml index 302f294..fcebb88 100644 --- a/app/views/conferences/show.html.haml +++ b/app/views/conferences/show.html.haml @@ -45,6 +45,24 @@ %strong= t('conferences.show.announce_left_member_by_name') + ":" %td = @conference.announce_left_member_by_name + - conference_data = @conference.list_conference + - if conference_data + %tr + %td + %strong= t('conferences.show.identifier') + ":" + %td + = conference_data['name'] + %tr + %td + %strong= t('conferences.show.member_count') + ":" + %td + = conference_data['member_count'] + %tr + %td + %strong= t('conferences.show.run_time') + ":" + %td + = conference_data['run_time'] + = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @parent, :child => @conference } @@ -54,6 +72,11 @@ = render :partial => 'shared/create_link', :locals => {:parent => @conference, :child_class => PhoneNumber} +- members = @conference.list_members(conference_data) +- if members && members.count > 0 + %h2= t("conferences.show.members") + = render "index_members", :members => members + %h2= t("conference_invitees.index.page_title") - if @conference.conference_invitees.count > 0 = render "conference_invitees/index_core", :conference_invitees => @conference.conference_invitees -- cgit v1.2.3 From 49549c7053700fb5444a2ae0835f879626d574cc Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 20 Mar 2013 12:19:03 +0100 Subject: possible_call_forwards fixed --- app/controllers/softkeys_controller.rb | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'app') diff --git a/app/controllers/softkeys_controller.rb b/app/controllers/softkeys_controller.rb index 6727de1..adb0e10 100644 --- a/app/controllers/softkeys_controller.rb +++ b/app/controllers/softkeys_controller.rb @@ -13,8 +13,6 @@ class SoftkeysController < ApplicationController def new @softkey = @sip_account.softkeys.build - - delete_call_forward_softkey_if_no_callforward_is_available end def create @@ -27,15 +25,12 @@ class SoftkeysController < ApplicationController end def edit - delete_call_forward_softkey_if_no_callforward_is_available end def update if @softkey.update_attributes(params[:softkey]) redirect_to sip_account_softkey_path(@softkey.sip_account, @softkey), :notice => t('softkeys.controller.successfuly_updated') else - delete_call_forward_softkey_if_no_callforward_is_available - render :edit end end @@ -57,10 +52,13 @@ class SoftkeysController < ApplicationController private def set_available_softkey_functions + @possible_call_forwards = @softkey.possible_call_forwards @softkey_functions = [] SoftkeyFunction.accessible_by(current_ability, :read).each do |softkey_function| if GuiFunction.display?("softkey_function_#{softkey_function.name.downcase}_field_in_softkey_form", current_user) - @softkey_functions << softkey_function + if softkey_function.name != 'call_forwarding' or @possible_call_forwards.count > 0 + @softkey_functions << softkey_function + end end end end @@ -78,12 +76,4 @@ class SoftkeysController < ApplicationController add_breadcrumb t('softkeys.index.page_title'), sip_account_softkeys_path(@sip_account) end end - - def delete_call_forward_softkey_if_no_callforward_is_available - # Don't display the call_forward option if there aren't any call_forwards to choose from. - # - if @softkey.sip_account.phone_numbers.map{|phone_number| phone_number.call_forwards}.flatten.count == 0 - @softkey_functions.delete_if { |softkey_function| softkey_function == SoftkeyFunction.find_by_name('call_forwarding') } - end - end end -- cgit v1.2.3 From f5d507f8db09f940d44aa97253a40b3cba3678c5 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 20 Mar 2013 12:19:41 +0100 Subject: possible_call_forwards fixed --- app/views/softkeys/_form_core.html.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/views/softkeys/_form_core.html.haml b/app/views/softkeys/_form_core.html.haml index 0e251f3..7bed1a5 100644 --- a/app/views/softkeys/_form_core.html.haml +++ b/app/views/softkeys/_form_core.html.haml @@ -7,8 +7,7 @@ .inputs = f.input :softkey_function_id, :as => :select, :collection => @softkey_functions.map {|x| [I18n.t("softkeys.functions.#{x}"), x.id] }, :label => t('softkeys.form.function.label'), :hint => conditional_hint('softkeys.form.function.hint'), :include_blank => false - - call_forwards = @softkey.possible_call_forwards - - if call_forwards && call_forwards.count > 0 - = f.input :softkeyable_id, :collection => call_forwards, :label => t('softkeys.form.call_forward.label'), :hint => conditional_hint('softkeys.form.call_forward.hint'), :include_blank => false + - if @possible_call_forwards && @possible_call_forwards.count > 0 + = f.input :softkeyable_id, :collection => @possible_call_forwards, :label => t('softkeys.form.call_forward.label'), :hint => conditional_hint('softkeys.form.call_forward.hint'), :include_blank => false = f.input :number, :label => t('softkeys.form.number.label'), :hint => conditional_hint('softkeys.form.number.hint') = f.input :label, :label => t('softkeys.form.label.label'), :hint => conditional_hint('softkeys.form.label.hint') -- cgit v1.2.3 From 706ffe50d3bb6270682783acc1e7817e8f7cf0f6 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 21 Mar 2013 11:53:13 +0100 Subject: phone_book_entry needs not to be unique --- app/models/conference_invitee.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'app') diff --git a/app/models/conference_invitee.rb b/app/models/conference_invitee.rb index 6a1349e..5b99ca4 100644 --- a/app/models/conference_invitee.rb +++ b/app/models/conference_invitee.rb @@ -23,7 +23,6 @@ class ConferenceInvitee < ActiveRecord::Base validates_inclusion_of :moderator, :in => [true, false] validate :uniqueness_of_phone_number_in_the_parent_conference - validates_uniqueness_of :phone_book_entry_id, :scope => :conference_id, :allow_nil => true def to_s "ID #{self.id}" -- cgit v1.2.3 From 68a4b0e40586aa6d11599b68b81e7e9c7f623f71 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 21 Mar 2013 12:00:22 +0100 Subject: destroy action redirect fixed --- app/controllers/sip_accounts_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 0d7cbfe..0d34109 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -75,7 +75,7 @@ class SipAccountsController < ApplicationController def destroy @sip_account.destroy m = method( :"#{@parent.class.name.underscore}_sip_accounts_url" ) - redirect_to :root, :notice => t('sip_accounts.controller.successfuly_destroyed') + redirect_to m.(@parent), :notice => t('sip_accounts.controller.successfuly_destroyed') end private -- cgit v1.2.3 From 0f27f97cac5ac9283a2b2e403effa3b71afa673b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 21 Mar 2013 12:46:19 +0100 Subject: whitespace --- app/models/softkey.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'app') diff --git a/app/models/softkey.rb b/app/models/softkey.rb index 7f77a25..27527f9 100644 --- a/app/models/softkey.rb +++ b/app/models/softkey.rb @@ -28,7 +28,6 @@ class Softkey < ActiveRecord::Base call_forwards = call_forwards + phone_number.call_forwards end - phone_numbers_ids = self.sip_account.phone_number_ids phone_numbers = PhoneNumber.where(:id => phone_numbers_ids).pluck(:number) -- cgit v1.2.3 From 844697e0398c128025df76810c6b091c2a3d4114 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 21 Mar 2013 12:46:39 +0100 Subject: to_s method --- app/models/ringtone.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/ringtone.rb b/app/models/ringtone.rb index 45ecd93..2b08c9f 100644 --- a/app/models/ringtone.rb +++ b/app/models/ringtone.rb @@ -24,6 +24,6 @@ class Ringtone < ActiveRecord::Base belongs_to :ringtoneable, :polymorphic => true def to_s - self.bellcore_id.to_s + CORE_RINGTONES_AVAILABLE.index(self.bellcore_id) end end -- cgit v1.2.3 From 61c91cccb00bbc04049d102150929874fc1a08e5 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 21 Mar 2013 12:47:26 +0100 Subject: breadcrumbs --- app/controllers/ringtones_controller.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/ringtones_controller.rb b/app/controllers/ringtones_controller.rb index e5a4f64..9dd253f 100644 --- a/app/controllers/ringtones_controller.rb +++ b/app/controllers/ringtones_controller.rb @@ -49,7 +49,18 @@ class RingtonesController < ApplicationController end def spread_breadcrumbs - if @parent.class == PhoneNumber && @parent.phone_numberable.class == SipAccount + if @parent.class == SipAccount + if @sip_account.sip_accountable.class == User + add_breadcrumb t("#{@sip_account.sip_accountable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore.pluralize}_path" ).(@sip_account.tenant) + add_breadcrumb @sip_account.sip_accountable, method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore}_path" ).(@sip_account.tenant, @sip_account.sip_accountable) + end + add_breadcrumb t("sip_accounts.index.page_title"), method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_accounts_path" ).(@sip_account.sip_accountable) + add_breadcrumb @sip_account, method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_account_path" ).(@sip_account.sip_accountable, @sip_account) + add_breadcrumb t("ringtones.index.page_title"), sip_account_ringtones_path(@sip_account) + if @ringtone && !@ringtone.new_record? + add_breadcrumb @ringtone + end + elsif @parent.class == PhoneNumber @sip_account = @parent.phone_numberable if @sip_account.sip_accountable.class == User add_breadcrumb t("#{@sip_account.sip_accountable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore.pluralize}_path" ).(@sip_account.tenant) @@ -61,7 +72,7 @@ class RingtonesController < ApplicationController add_breadcrumb @phone_number, sip_account_phone_number_path(@sip_account, @phone_number) add_breadcrumb t("ringtones.index.page_title"), phone_number_ringtones_path(@phone_number) if @ringtone && !@ringtone.new_record? - add_breadcrumb @ringtone, phone_number_ringtone_path(@phone_number, @ringtone) + add_breadcrumb @ringtone end end end -- cgit v1.2.3 From 1e43dc850a3b8bfb9a2df59e2575094baf5c9426 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 21 Mar 2013 12:57:04 +0100 Subject: breadcrumbs --- app/controllers/ringtones_controller.rb | 36 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'app') diff --git a/app/controllers/ringtones_controller.rb b/app/controllers/ringtones_controller.rb index 9dd253f..96e9c6d 100644 --- a/app/controllers/ringtones_controller.rb +++ b/app/controllers/ringtones_controller.rb @@ -61,18 +61,30 @@ class RingtonesController < ApplicationController add_breadcrumb @ringtone end elsif @parent.class == PhoneNumber - @sip_account = @parent.phone_numberable - if @sip_account.sip_accountable.class == User - add_breadcrumb t("#{@sip_account.sip_accountable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore.pluralize}_path" ).(@sip_account.tenant) - add_breadcrumb @sip_account.sip_accountable, method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore}_path" ).(@sip_account.tenant, @sip_account.sip_accountable) - end - add_breadcrumb t("sip_accounts.index.page_title"), method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_accounts_path" ).(@sip_account.sip_accountable) - add_breadcrumb @sip_account, method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_account_path" ).(@sip_account.sip_accountable, @sip_account) - add_breadcrumb t("phone_numbers.index.page_title"), sip_account_phone_numbers_path(@sip_account) - add_breadcrumb @phone_number, sip_account_phone_number_path(@sip_account, @phone_number) - add_breadcrumb t("ringtones.index.page_title"), phone_number_ringtones_path(@phone_number) - if @ringtone && !@ringtone.new_record? - add_breadcrumb @ringtone + if @parent.phone_numberable.class == SipAccount + @sip_account = @parent.phone_numberable + if @sip_account.sip_accountable.class == User + add_breadcrumb t("#{@sip_account.sip_accountable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore.pluralize}_path" ).(@sip_account.tenant) + add_breadcrumb @sip_account.sip_accountable, method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore}_path" ).(@sip_account.tenant, @sip_account.sip_accountable) + end + add_breadcrumb t("sip_accounts.index.page_title"), method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_accounts_path" ).(@sip_account.sip_accountable) + add_breadcrumb @sip_account, method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_account_path" ).(@sip_account.sip_accountable, @sip_account) + add_breadcrumb t("phone_numbers.index.page_title"), sip_account_phone_numbers_path(@sip_account) + add_breadcrumb @phone_number, sip_account_phone_number_path(@sip_account, @phone_number) + add_breadcrumb t("ringtones.index.page_title"), phone_number_ringtones_path(@phone_number) + if @ringtone && !@ringtone.new_record? + add_breadcrumb @ringtone + end + elsif @parent.phone_numberable.class == HuntGroup + @hunt_group = @parent.phone_numberable + add_breadcrumb t("hunt_groups.index.page_title"), method( :"#{@hunt_group.tenant.class.name.underscore}_hunt_groups_path" ).(@hunt_group.tenant) + add_breadcrumb @hunt_group, method( :"#{@hunt_group.tenant.class.name.underscore}_hunt_group_path" ).(@hunt_group.tenant, @hunt_group) + add_breadcrumb t("phone_numbers.index.page_title"), hunt_group_phone_numbers_path(@hunt_group) + add_breadcrumb @phone_number, hunt_group_phone_number_path(@hunt_group, @phone_number) + add_breadcrumb t("ringtones.index.page_title"), phone_number_ringtones_path(@phone_number) + if @ringtone && !@ringtone.new_record? + add_breadcrumb @ringtone + end end end end -- cgit v1.2.3 From a9b2c7f508bfdf6d67389e39036d038b3c77f547 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Sat, 23 Mar 2013 04:21:48 +0100 Subject: "nice -n 19" for backup related background tasks --- app/models/backup_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index 48dd27e..9cb4f53 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -37,7 +37,7 @@ class BackupJob < ActiveRecord::Base if tmp_backup_directory.blank? self.state = 'failed' else - system "cd #{backup_directory} && sudo /bin/tar czf #{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz #{File.basename(tmp_backup_directory)}" + system "cd #{backup_directory} && nice -n 19 sudo /bin/tar czf #{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz #{File.basename(tmp_backup_directory)}" require 'fileutils' FileUtils.rm_rf tmp_backup_directory file = File::Stat.new("#{backup_directory}/#{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz") -- cgit v1.2.3 From fc406e45e4a5ce26e0117ff94e632522fcfa066b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 24 Mar 2013 07:32:26 +0100 Subject: use call_legs to initiate call --- app/controllers/calls_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/calls_controller.rb b/app/controllers/calls_controller.rb index 6182ad8..ae0093c 100644 --- a/app/controllers/calls_controller.rb +++ b/app/controllers/calls_controller.rb @@ -17,11 +17,11 @@ class CallsController < ApplicationController if !params[:url].blank? protocol, separator, phone_number = params[:url].partition(':') if ! phone_number.blank? - @call = @parent.calls.new() + @call = @parent.call_legs.new() @call.destination = phone_number end elsif !params[:number].blank? - @call = @parent.calls.new() + @call = @parent.call_legs.new() @call.destination = params[:number] end end -- cgit v1.2.3