diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-03-25 10:27:27 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-03-25 10:27:27 +0100 |
commit | df6e17e48995f25e72509986f30700d778b179b6 (patch) | |
tree | f432c24b8e4ad81009188650dabfd99194883265 /app | |
parent | 11f186a118285fbc87a536af26730780a9ad01f5 (diff) | |
parent | cce94a74aa5c9691f9b37cd9be5a6831f8063812 (diff) |
Merge branch 'develop'5.1.2
Diffstat (limited to 'app')
74 files changed, 1189 insertions, 184 deletions
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 . 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/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/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/call_routes_controller.rb b/app/controllers/call_routes_controller.rb index 2dcd648..e5cf56a 100644 --- a/app/controllers/call_routes_controller.rb +++ b/app/controllers/call_routes_controller.rb @@ -87,6 +87,28 @@ class CallRoutesController < ApplicationController end end + def test + 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), + 'caller.account_type' => account.class.name, + 'caller.account_id' => account.id, + 'caller.account_uuid' => account.try(:uuid), + }) + end + end + private def call_route_parameter_params params.require(:call_route).permit(:routing_table, :name, :endpoint_type, :endpoint_id, :position) diff --git a/app/controllers/calls_controller.rb b/app/controllers/calls_controller.rb index 9d85a10..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 @@ -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" ) 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 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 eb94038..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() @@ -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 <sip:#{softkey.number}@#{sip_account.host}>|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 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' 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/ringtones_controller.rb b/app/controllers/ringtones_controller.rb index e5a4f64..96e9c6d 100644 --- a/app/controllers/ringtones_controller.rb +++ b/app/controllers/ringtones_controller.rb @@ -49,19 +49,42 @@ class RingtonesController < ApplicationController end def spread_breadcrumbs - if @parent.class == PhoneNumber && @parent.phone_numberable.class == SipAccount - @sip_account = @parent.phone_numberable + 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("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) + add_breadcrumb t("ringtones.index.page_title"), sip_account_ringtones_path(@sip_account) if @ringtone && !@ringtone.new_record? - add_breadcrumb @ringtone, phone_number_ringtone_path(@phone_number, @ringtone) + add_breadcrumb @ringtone + end + elsif @parent.class == PhoneNumber + 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 diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index b34172d..0d34109 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 @@ -72,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 diff --git a/app/controllers/softkeys_controller.rb b/app/controllers/softkeys_controller.rb index 9179d8c..adb0e10 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 @@ -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,14 +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 @@ -56,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 @@ -77,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 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/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb new file mode 100644 index 0000000..98008c1 --- /dev/null +++ b/app/controllers/switchboards_controller.rb @@ -0,0 +1,66 @@ +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]) + @switchboard_entries = @switchboard.switchboard_entries + 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/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 5e836c4..6b58d6a 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -16,6 +16,11 @@ 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');") + PrivatePub.publish_to("/users/#{user.id}/messages/new", "document.title = '* ' + document.title.replace( '* ' , '');") + if user.email.blank? next end @@ -59,6 +64,64 @@ 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 = 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 => "<!-- OK -->", + ) + else + render( + :status => 501, + :layout => false, + :content_type => 'text/plain', + :text => "<!-- ERRORS: #{errors.join(', ')} -->", + ) + end + end + + def sip_account_update + sip_account = SipAccount.find(params[:id]) + + if sip_account.updated_at < Time.now + + # 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( + :status => 200, + :layout => false, + :content_type => 'text/plain', + :text => "<!-- OK -->", + ) + end + def fax if !params[:fax_account_id].blank? fax_account = FaxAccount.where(:id => params[:fax_account_id].to_i).first @@ -87,6 +150,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 @@ -106,6 +171,14 @@ class TriggerController < ApplicationController end if errors.count == 0 + # Indicate a new fax in the navigation bar. + # + 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( :status => 200, :layout => false, 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/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/ability.rb b/app/models/ability.rb index 3cd1d4d..2dd96b8 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 @@ -178,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 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/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/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") diff --git a/app/models/call.rb b/app/models/call.rb index 8f657fa..a8a0d7f 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 + + 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 + + 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 diff --git a/app/models/call_route.rb b/app/models/call_route.rb index 8bc811a..590d49b 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, @@ -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 diff --git a/app/models/conference.rb b/app/models/conference.rb index aee75d5..a9d6708 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 @@ -46,11 +49,45 @@ 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/ + 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()) + if data.blank? + return {} + end + + 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 + 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 diff --git a/app/models/conference_invitee.rb b/app/models/conference_invitee.rb index d6e3bac..5b99ca4 100644 --- a/app/models/conference_invitee.rb +++ b/app/models/conference_invitee.rb @@ -1,27 +1,28 @@ 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] 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}" 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 diff --git a/app/models/gateway_setting.rb b/app/models/gateway_setting.rb index 381dde5..b412bc6 100644 --- a/app/models/gateway_setting.rb +++ b/app/models/gateway_setting.rb @@ -5,11 +5,14 @@ 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', + 'dial_string' => 'String', 'profile' => 'String', }, 'xmpp' => { 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/models/intruder.rb b/app/models/intruder.rb index 9a1c39a..9c01634 100644 --- a/app/models/intruder.rb +++ b/app/models/intruder.rb @@ -50,6 +50,27 @@ class Intruder < ActiveRecord::Base } end + 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| + if !name.blank? && value then + event.add_header(name, value) + end + end + return event.fire() + end + private def set_key_if_empty if self.key.blank? @@ -98,6 +119,7 @@ class Intruder < ActiveRecord::Base write_firewall_list restart_firewall end + self.perimeter_db_rescan end end @@ -108,6 +130,7 @@ class Intruder < ActiveRecord::Base restart_firewall end end + self.perimeter_db_rescan end def check_if_delete_relevant @@ -117,5 +140,6 @@ class Intruder < ActiveRecord::Base restart_firewall end end + self.perimeter_db_rescan end end 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 diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index cdb609d..0c923be 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -41,6 +41,9 @@ 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 + has_many :switchboard_entries, :dependent => :destroy + # Delegations: # delegate :host, :to => :sip_domain, :allow_nil => true @@ -160,12 +163,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 @@ -178,6 +185,38 @@ class SipAccount < ActiveRecord::Base return sip_accounts end + def status + states = Array.new + + self.call_legs.each do |call_leg| + states << { + :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 + + self.b_call_legs.each do |call_leg| + call_status = + states << { + :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 + + return states + end private diff --git a/app/models/softkey.rb b/app/models/softkey.rb index 6063017..27527f9 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 @@ -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) @@ -43,7 +42,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 +81,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/models/switchboard.rb b/app/models/switchboard.rb new file mode 100644 index 0000000..74e2767 --- /dev/null +++ b/app/models/switchboard.rb @@ -0,0 +1,16 @@ +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 + has_many :switchboard_entries, :dependent => :destroy + has_many :sip_accounts, :through => :switchboard_entries + + def to_s + self.name.to_s + end +end diff --git a/app/models/switchboard_entry.rb b/app/models/switchboard_entry.rb new file mode 100644 index 0000000..76d002f --- /dev/null +++ b/app/models/switchboard_entry.rb @@ -0,0 +1,31 @@ +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, + :length => { :maximum => 10 }, + :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/models/user.rb b/app/models/user.rb index 913d75f..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' @@ -94,6 +92,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/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/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 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 + 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') 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 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..930a0c3 --- /dev/null +++ b/app/views/fax_documents/_fax_document.html.haml @@ -0,0 +1,66 @@ +.fax_document{:id => 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 b8f3e9e..6ae0ee1 100644 --- a/app/views/fax_documents/show.html.haml +++ b/app/views/fax_documents/show.html.haml @@ -1,67 +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 = '' += render :partial => 'fax_document', :locals => {:fax_document => @fax_document} - %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 } +- if ['sending', 'queued_for_sending'].include? @fax_document.state + = subscribe_to "/fax_documents/#{@fax_document.id}"
\ No newline at end of file diff --git a/app/views/gateways/show.html.haml b/app/views/gateways/show.html.haml index 6cf09ec..19b1304 100644 --- a/app/views/gateways/show.html.haml +++ b/app/views/gateways/show.html.haml @@ -33,6 +33,82 @@ %td = @gateway.description + - if @gateway.technology.to_s == 'sip' + - status = @gateway.status + - 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 + %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 } 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 diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 8004c0e..3e1da1c 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -23,7 +23,7 @@ %li %a{:href => sip_account_voicemail_messages_path(current_user.sip_accounts.first)} =t("voicemail_messages.index.page_title") - + - if current_user %ul.nav.pull-right %li.display @@ -39,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 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/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml index 365aea8..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') + ':' @@ -99,3 +101,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 } diff --git a/app/views/softkeys/_form_core.html.haml b/app/views/softkeys/_form_core.html.haml index f447aa6..7bed1a5 100644 --- a/app/views/softkeys/_form_core.html.haml +++ b/app/views/softkeys/_form_core.html.haml @@ -4,10 +4,10 @@ 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 + - 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') 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,6 +1,9 @@ - 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 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..d647626 --- /dev/null +++ b/app/views/switchboard_entries/_index_core.html.haml @@ -0,0 +1,17 @@ +%table.table.table-striped + %tr + %th + %th= t('switchboard_entries.index.sip_account_id') + %th= t('switchboard_entries.index.name') + %th + + - 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 new file mode 100644 index 0000000..8c44153 --- /dev/null +++ b/app/views/switchboard_entries/_switchboard_entry.html.haml @@ -0,0 +1,45 @@ +%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(: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', :style => 'width: 100px;') + - else + = image_tag('icons/user-female-16x.png', :class => 'img-rounded', :style => 'width: 100px;') + %p + %small + = truncate(switchboard_entry.to_s, :length => 23) + %br + - 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 + + %br + + - if switchboard_entry.sip_account.registration + - 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 + = "#{switchboard_entry.sip_account.phone_numbers.first.number} => " + %span.label.label-info + = "#{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} =>" + %span.label + = switchboard_entry.sip_account.phone_numbers.first.number + + - else + %span.label.label-inverse + %i.icon-ban-circle.icon-white 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 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..8dd75b9 --- /dev/null +++ b/app/views/switchboards/_current_user_dashboard.html.haml @@ -0,0 +1,33 @@ +.dashboard + - current_user.sip_accounts.each do |sip_account| + %table.table.table-striped + %thead + %tr + %td + %td + Destination + %td + Start + %td{:span => '2'} + Caller + %tbody + - 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 + %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 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..f2e69f4 --- /dev/null +++ b/app/views/switchboards/edit.html.haml @@ -0,0 +1,12 @@ +- content_for :title, t("switchboards.edit.page_title") + +.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/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..a825806 --- /dev/null +++ b/app/views/switchboards/show.html.haml @@ -0,0 +1,21 @@ +- content_for :title, "Switchboard #{@switchboard.name}" + +.row + .span12 + = 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") + + .span6 + + += subscribe_to "/switchboards/#{@switchboard.id}"
\ No newline at end of file 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} 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 @@ -<h1>Trigger#voicemail</h1> -<p>Find me in app/views/trigger/voicemail.html.erb</p> - -<%= debug(params) %> diff --git a/app/views/users/_switchboards.html.haml b/app/views/users/_switchboards.html.haml new file mode 100644 index 0000000..183b6ae --- /dev/null +++ b/app/views/users/_switchboards.html.haml @@ -0,0 +1,7 @@ +-# Switchboards +-# +- 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} + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => Switchboard}
\ 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 |