Skip to content

Commit

Permalink
admin api: active-calls resource improvements (#1641)
Browse files Browse the repository at this point in the history
* admin api: active-calls resource improvements
* upgrade rails-html-sanitizer
* add more attibutes active calls page
  • Loading branch information
dmitry-sinina authored Dec 4, 2024
1 parent 7540c7d commit b807973
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ gem 'jquery-rails'
gem 'jquery-tablesorter'
gem 'jquery-ui-rails', github: 'jquery-ui-rails/jquery-ui-rails', tag: 'v7.0.0'
gem 'mini_racer'
gem 'rails-html-sanitizer', '~> 1.0'
gem 'rails-html-sanitizer', '>= 1.6.1'
gem 'sass-globbing'
gem 'uglifier', '>= 1.3'

Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
locale (2.1.2)
loofah (2.22.0)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
Expand Down Expand Up @@ -442,7 +442,7 @@ GEM
net-protocol
netstring (0.0.3)
nio4r (2.5.9)
nokogiri (1.16.7)
nokogiri (1.16.8)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
oj (3.11.2)
Expand Down Expand Up @@ -684,9 +684,9 @@ GEM
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
rails-html-sanitizer (1.6.1)
loofah (~> 2.21)
nokogiri (~> 1.14)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.0.8.5)
actionpack (= 7.0.8.5)
activesupport (= 7.0.8.5)
Expand Down Expand Up @@ -916,7 +916,7 @@ DEPENDENCIES
pundit
rack (~> 2.2.6)
rails (~> 7.0)
rails-html-sanitizer (~> 1.0)
rails-html-sanitizer (>= 1.6.1)
ransack
responders
rspec-rails
Expand Down
44 changes: 32 additions & 12 deletions app/admin/realtime_data/active_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,28 +164,38 @@ def apply_pagination(chain)
row :connect_time
row :duration
row :time_limit

row :src_prefix_in
row :src_prefix_routing
row :src_prefix_out

row :dst_prefix_in
row :dst_prefix_routing
row :lrn
row :dst_prefix_out
row :src_prefix_in
row :src_prefix_routing
row :src_prefix_out

row :diversion_in
row :diversion_out
row :src_country, &:src_country_link
row :src_network, &:src_network_link
row :dst_country, &:dst_country_link
row :dst_network, &:dst_network_link
row :customer, &:customer_link
row :vendor, &:vendor_link
row :customer_acc, &:customer_acc_link
row :vendor_acc, &:vendor_acc_link
row :customer_auth, &:customer_auth_link
row :destination, &:destination_link
row :dialpeer, &:dialpeer_link

row :orig_gw, &:orig_gw_link
row :term_gw, &:term_gw_link
row :routing_group, &:routing_group_link

row :rateplan, &:rateplan_link
row :destination, &:destination_link

row :routing_plan, &:routing_plan_link
row :routing_group, &:routing_group_link
row :dialpeer, &:dialpeer_link

row :destination_initial_rate
row :destination_next_rate
row :destination_initial_interval
Expand Down Expand Up @@ -237,28 +247,38 @@ def apply_pagination(chain)
column :connect_time
column :duration
column :time_limit

column :src_prefix_in
column :src_prefix_routing
column :src_prefix_out

column :dst_prefix_in
column :dst_prefix_routing
column :lrn
column :dst_prefix_out
column :src_prefix_in
column :src_prefix_routing
column :src_prefix_out

column :diversion_in
column :diversion_out
column :src_country, :src_country_link
column :src_network, :src_network_link
column :dst_country, :dst_country_link
column :dst_network, :dst_network_link
column :customer, :customer_link
column :vendor, :vendor_link
column :customer_acc, :customer_acc_link
column :vendor_acc, :vendor_acc_link
column :customer_auth, :customer_auth_link
column :destination, :destination_link
column :dialpeer, :dialpeer_link

column :orig_gw, :orig_gw_link
column :term_gw, :term_gw_link
column :routing_group, :routing_group_link

column :rateplan, :rateplan_link
column :destination, :destination_link

column :routing_plan, :routing_plan_link
column :routing_group, :routing_group_link
column :dialpeer, :dialpeer_link

column :destination_initial_rate
column :destination_next_rate
column :destination_initial_interval
Expand Down
6 changes: 6 additions & 0 deletions app/models/realtime_data/active_call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def query_builder_collection(includes:, filters:, **_)
attribute :src_prefix_out
attribute :diversion_in
attribute :diversion_out
attribute :src_country_id, :integer
attribute :src_network_id, :integer
attribute :dst_country_id, :integer
attribute :dst_network_id, :integer
attribute :customer_id, :integer
Expand All @@ -44,6 +46,7 @@ def query_builder_collection(includes:, filters:, **_)
attribute :dialpeer_id, :integer
attribute :orig_gw_id, :integer
attribute :term_gw_id, :integer
attribute :routing_plan_id, :integer
attribute :routing_group_id, :integer
attribute :rateplan_id, :integer
attribute :destination_initial_rate
Expand Down Expand Up @@ -81,7 +84,10 @@ def query_builder_collection(includes:, filters:, **_)
has_one :orig_gw, class_name: 'Gateway', foreign_key: :orig_gw_id
has_one :term_gw, class_name: 'Gateway', foreign_key: :term_gw_id
has_one :routing_group, class_name: 'Routing::RoutingGroup', foreign_key: :routing_group_id
has_one :routing_plan, class_name: 'Routing::RoutingPlan', foreign_key: :routing_plan_id
has_one :rateplan, class_name: 'Routing::Rateplan', foreign_key: :rateplan_id
has_one :src_country, class_name: 'System::Country', foreign_key: :src_country_id
has_one :src_network, class_name: 'System::Network', foreign_key: :src_network_id
has_one :dst_country, class_name: 'System::Country', foreign_key: :dst_country_id
has_one :dst_network, class_name: 'System::Network', foreign_key: :dst_network_id
has_one :node, class_name: 'Node', foreign_key: :node_id
Expand Down
46 changes: 23 additions & 23 deletions app/resources/api/rest/admin/active_call_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ class Api::Rest::Admin::ActiveCallResource < ::BaseResource
:src_prefix_out,
:diversion_in,
:diversion_out,
:dst_country_id,
:dst_network_id,
:customer_id,
:vendor_id,
:customer_acc_id,
:vendor_acc_id,
:customer_auth_id,
:destination_id,
:dialpeer_id,
:orig_gw_id,
:term_gw_id,
:routing_group_id,
:rateplan_id,
:destination_initial_rate,
:destination_next_rate,
:destination_initial_interval,
Expand All @@ -52,32 +39,45 @@ class Api::Rest::Admin::ActiveCallResource < ::BaseResource
:legB_local_port,
:term_call_id,
:legB_remote_ip,
:legB_remote_port,
:node_id,
:pop_id
:legB_remote_port

has_one :customer, class_name: 'Contractor'
has_one :vendor, class_name: 'Contractor'
has_one :customer_acc, class_name: 'Account'
has_one :vendor_acc, class_name: 'Account'
has_one :customer_auth, class_name: 'CustomersAuth'
has_one :rateplan, class_name: 'Rateplan'
has_one :destination, class_name: 'Destination'
has_one :routing_group, class_name: 'RoutingGroup'
has_one :routing_plan, class_name: 'RoutingGroup'
has_one :dialpeer, class_name: 'Dialpeer'
has_one :orig_gw, class_name: 'Gateway'
has_one :term_gw, class_name: 'Gateway'
has_one :routing_group, class_name: 'RoutingGroup'
has_one :rateplan, class_name: 'Rateplan'
has_one :src_country, class_name: 'Country', foreign_key: :src_country_id
has_one :src_network, class_name: 'Network', foreign_key: :src_network_id
has_one :dst_country, class_name: 'Country', foreign_key: :dst_country_id
has_one :dst_network, class_name: 'Network', foreign_key: :dst_network_id
has_one :pop, class_name: 'Pop', foreign_key: :node_id
has_one :node, class_name: 'Node', foreign_key: :node_id

filter :node_id_eq
filter :dst_country_id_eq
filter :dst_network_id_eq
filter :vendor_id_eq
filter :customer_id_eq
filter :vendor_acc_id_eq
filter :vendor_id_eq
filter :customer_acc_id_eq
filter :vendor_acc_id_eq
filter :customer_auth_id_eq
filter :rateplan_id_eq
filter :destination_id_eq
filter :routing_group_id_eq
filter :routing_plan_id_eq
filter :dialpeer_id_eq
filter :orig_gw_id_eq
filter :term_gw_id_eq
filter :src_country_id_eq
filter :src_network_id_eq
filter :dst_country_id_eq
filter :dst_network_id_eq
filter :pop_id_eq
filter :node_id_eq
filter :duration_equals
filter :duration_greater_than
filter :duration_less_than
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/api/rest/admin/active_calls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@

rels = %i[
customer vendor customer-acc vendor-acc customer-auth destination dialpeer
orig-gw term-gw routing-group rateplan node
orig-gw term-gw routing-plan routing-group rateplan node pop src-country src-network dst-country dst-network
]

it_behaves_like :json_api_admin_check_authorization do
Expand Down

0 comments on commit b807973

Please sign in to comment.