From 13c49def80b1953cef278a1a517791cd3a3beed6 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 4 Jul 2024 20:36:02 +0300 Subject: [PATCH] fix SS status rendering improvements --- app/admin/cdr/cdrs.rb | 16 ++++++++++++++-- app/models/cdr/cdr.rb | 18 ++++++++++++++++-- db/custom_seeds/full_cdrs.rb | 6 ++++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/app/admin/cdr/cdrs.rb b/app/admin/cdr/cdrs.rb index 62975cffd..4677f99be 100644 --- a/app/admin/cdr/cdrs.rb +++ b/app/admin/cdr/cdrs.rb @@ -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 @@ -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 @@ -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 diff --git a/app/models/cdr/cdr.rb b/app/models/cdr/cdr.rb index e586153af..766638e13 100644 --- a/app/models/cdr/cdr.rb +++ b/app/models/cdr/cdr.rb @@ -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' @@ -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 diff --git a/db/custom_seeds/full_cdrs.rb b/db/custom_seeds/full_cdrs.rb index 608d7f3a3..a0af6a9ac 100644 --- a/db/custom_seeds/full_cdrs.rb +++ b/db/custom_seeds/full_cdrs.rb @@ -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)}") @@ -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