summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/sip_accounts_controller.rb32
-rw-r--r--app/views/sip_accounts/show.html.haml4
2 files changed, 36 insertions, 0 deletions
diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb
index b5c3ae4..022858c 100644
--- a/app/controllers/sip_accounts_controller.rb
+++ b/app/controllers/sip_accounts_controller.rb
@@ -1,6 +1,7 @@
class SipAccountsController < ApplicationController
load_resource :user
load_resource :tenant
+ #load_resource :sip_account
load_and_authorize_resource :sip_account, :through => [:user, :tenant ]
before_filter :set_and_authorize_parent
@@ -10,6 +11,7 @@ class SipAccountsController < ApplicationController
end
def show
+ @register_tel_protocol = "#{request.protocol}#{request.host_with_port}/sip_accounts/#{@sip_account.try(:id)}/call?url=%s"
end
def new
@@ -74,6 +76,36 @@ class SipAccountsController < ApplicationController
redirect_to :root, :notice => t('sip_accounts.controller.successfuly_destroyed')
end
+ def call
+ if !params[:url].blank?
+ protocol, separator, phone_number = params[:url].partition(':')
+ if ! phone_number.blank?
+ @sip_account.call(phone_number)
+ render(
+ :status => 200,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- CALL -->",
+ )
+ return;
+ end
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Number not found -->",
+ )
+ return;
+ end
+
+ render(
+ :status => 404,
+ :layout => false,
+ :content_type => 'text/plain',
+ :text => "<!-- Call URL not found -->",
+ )
+ end
+
private
def set_and_authorize_parent
@parent = @user || @tenant
diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml
index ede5150..12e54c3 100644
--- a/app/views/sip_accounts/show.html.haml
+++ b/app/views/sip_accounts/show.html.haml
@@ -61,6 +61,10 @@
= render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @sip_account.sip_accountable, :child => @sip_account }
%p
+ %strong= t('sip_accounts.show.tel_protocol') + ':'
+ %a{:href => '', :onclick => "navigator.registerProtocolHandler(\"tel\", \"#{@register_tel_protocol}\", \"#{@sip_account.to_s}\");" }= t('sip_accounts.show.register_tel_protocol')
+
+%p
%strong= t('ringtones.name') + ':'
- if @sip_account.ringtones.count > 0
= link_to @sip_account.ringtones.first, sip_account_ringtone_path(@sip_account, @sip_account.ringtones.first)