diff options
author | Peter Kozak <spag@golwen.net> | 2013-03-13 15:41:17 -0400 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-03-13 15:41:17 -0400 |
commit | dcdd37036f45d13b7402436ddb1af65c78052ca9 (patch) | |
tree | ee858c02b50684975d45021a258742d9292c9ce7 /app | |
parent | 1ea544f5d29d3bc43bf1d7ddfd1f7692f5cbcdda (diff) |
routing test view
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/call_routes_controller.rb | 7 | ||||
-rw-r--r-- | app/views/call_routes/test.html.haml | 55 |
2 files changed, 62 insertions, 0 deletions
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 + |