Skip to content

Commit

Permalink
Merge pull request #1498 from dmitry-sinina/ss_status_ui_improvements
Browse files Browse the repository at this point in the history
fix SS status rendering improvements
  • Loading branch information
dmitry-sinina committed Jul 4, 2024
2 parents 631575c + 13c49de commit 9e67911
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
16 changes: 14 additions & 2 deletions app/admin/cdr/cdrs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ def scoped_collection
filter :sign_term_local_ip, filters: %i[equals contains starts_with ends_with]
filter :sign_term_ip, filters: %i[equals contains starts_with ends_with]
filter :customer_auth_external_type_eq, as: :string, label: 'CUSTOMER AUTH EXTERNAL TYPE'
filter :lega_ss_status_id_eq, label: 'LegA SS status', as: :select, collection: Cdr::Cdr::SS_STATUSES.invert, input_html: { class: 'chosen' }
filter :legb_ss_status_id_eq, label: 'LegB SS status', as: :select, collection: Cdr::Cdr::SS_STATUSES.invert, input_html: { class: 'chosen' }

acts_as_filter_by_routing_tag_ids routing_tag_ids_covers: false

Expand Down Expand Up @@ -612,8 +614,12 @@ def scoped_collection
tab :identity do
attributes_table do
row :lega_identity
row :lega_ss_status
row :legb_ss_status
row :lega_ss_status do
status_tag(cdr.lega_ss_status.to_s, class: cdr.lega_ss_status_class) unless cdr.lega_ss_status_id.nil?
end
row :legb_ss_status do
status_tag(cdr.legb_ss_status.to_s, class: cdr.legb_ss_status_class) unless cdr.legb_ss_status_id.nil?
end
end
end
end
Expand Down Expand Up @@ -675,6 +681,12 @@ def scoped_collection
column :dst_prefix_in
column :to_domain
column :ruri_domain

column('S/S Status') do |cdr|
status_tag(cdr.lega_ss_status.to_s, class: cdr.lega_ss_status_class) unless cdr.lega_ss_status_id.nil?
status_tag(cdr.legb_ss_status.to_s, class: cdr.legb_ss_status_class) unless cdr.legb_ss_status_id.nil?
end

column :src_prefix_routing
column :src_area
column :dst_prefix_routing
Expand Down
18 changes: 16 additions & 2 deletions app/models/cdr/cdr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ class Cdr::Cdr < Cdr::Base
SS_STATUS_C = 3

SS_STATUSES = {
SS_STATUS_INVALID => 'Validation failed',
SS_STATUS_NONE => 'No identity',
SS_STATUS_INVALID => 'Invalid',
SS_STATUS_NONE => 'None',
SS_STATUS_A => 'A',
SS_STATUS_B => 'B',
SS_STATUS_C => 'C'
Expand Down Expand Up @@ -325,10 +325,24 @@ def lega_ss_status
lega_ss_status_id.nil? ? nil : SS_STATUSES[lega_ss_status_id]
end

def lega_ss_status_class
return :red if lega_ss_status_id == -1
return :grey if lega_ss_status_id == 0

:green
end

def legb_ss_status
legb_ss_status_id.nil? ? nil : SS_STATUSES[legb_ss_status_id]
end

def legb_ss_status_class
return :red if legb_ss_status_id == -1
return :grey if legb_ss_status_id == 0

:green
end

def has_dump?
!dump_level_id.nil? and dump_level_id > 0
end
Expand Down
6 changes: 4 additions & 2 deletions db/custom_seeds/full_cdrs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
customer_gw = Gateway.find_or_create_by!(name: 'seed_customer_gw2', contractor: customer, allow_origination: true, allow_termination: false, enabled: true, incoming_auth_password: 'pw', incoming_auth_username: 'us')
customer_auth = CustomersAuth.find_or_create_by!(name: 'seed_customer_acc', customer: customer, account: customer_acc, gateway: customer_gw, routing_plan: routing_plan, rateplan: rate_plan, require_incoming_auth: true)
pop = Pop.find_or_create_by!(id: 100_500, name: 'seed-UA')
package_counter = Billing::PackageCounter.find_or_create_by!(account_id: customer_acc.id, exclude: false, duration: 1200)
package_counter = Billing::PackageCounter.find_or_create_by!(account_id: customer_acc.id, exclude: false, duration: 1200, prefix: 'test')

100.times do
Routing::Area.find_or_create_by!(name: "Area #{rand(200)}")
Expand Down Expand Up @@ -106,6 +106,8 @@
routing_delay: 0.1223456,
pdd: 0.1245678,
rtt: 0.987654321,
lega_identity: '[{"header":{"alg":"ES256","ppt":"shaken","typ":"passport","x5u":"http://127.0.0.1/share/test.pem"},"parsed":true,"payload":{"attest":"C","dest":{"tn":"456","uri":"sip:456"},"iat":1622830203,"orig":{"tn":"123","uri":"sip:123"},"origid":"8-000F7304-60BA6C7B000B6828-A43657C0"},"verified":true},{"error_code":4,"error_reason":"Incorrect Identity Header Value","parsed":false},{"error_code":-1,"error_reason":"certificate is not available","header":{"alg":"ES256","ppt":"shaken","typ":"passport","x5u":"http://127.0.0.1/share/test2.pem"},"parsed":true,"payload":{"attest":"C","dest":{"tn":"13"},"iat":1622831252,"orig":{"tn":"42"},"origid":"8-000F7304-60BA7094000207EC-2B5F27C0"},"verified":false}]'
lega_identity: '[{"header":{"alg":"ES256","ppt":"shaken","typ":"passport","x5u":"http://127.0.0.1/share/test.pem"},"parsed":true,"payload":{"attest":"C","dest":{"tn":"456","uri":"sip:456"},"iat":1622830203,"orig":{"tn":"123","uri":"sip:123"},"origid":"8-000F7304-60BA6C7B000B6828-A43657C0"},"verified":true},{"error_code":4,"error_reason":"Incorrect Identity Header Value","parsed":false},{"error_code":-1,"error_reason":"certificate is not available","header":{"alg":"ES256","ppt":"shaken","typ":"passport","x5u":"http://127.0.0.1/share/test2.pem"},"parsed":true,"payload":{"attest":"C","dest":{"tn":"13"},"iat":1622831252,"orig":{"tn":"42"},"origid":"8-000F7304-60BA7094000207EC-2B5F27C0"},"verified":false}]',
lega_ss_status_id: [nil, -1, 0, 1, 2, 3].sample,
legb_ss_status_id: [nil, -1, 0, 1, 2, 3].sample
)
end

0 comments on commit 9e67911

Please sign in to comment.