Module: NdrError::ErrorsHelper
- Defined in:
- app/helpers/ndr_error/errors_helper.rb
Overview
Error-specific view helpers
Instance Method Summary collapse
- #digest_for(fingerprint, search) ⇒ Object
- #downstream_fingerprint_link(print) ⇒ Object
- #edit_button_for(fingerprint) ⇒ Object
- #highlighted_trace_for(error) ⇒ Object
- #latest_timestamp_for(fingerprint) ⇒ Object
- #latest_user_for(fingerprint, search) ⇒ Object
- #link_to_fingerprint(fingerprint, latest) ⇒ Object
- #multiple_occurrences_badge_for(fingerprint) ⇒ Object
- #next_button_for(error) ⇒ Object
- #previous_button_for(error) ⇒ Object
- #purge_button_for(fingerprint) ⇒ Object
- #search_matches(string, keywords) ⇒ Object
- #similar_error_link(error) ⇒ Object
- #sorted_parameters_for(error) ⇒ Object
- #ticket_link_for(fingerprint, small = false) ⇒ Object
Instance Method Details
#digest_for(fingerprint, search) ⇒ Object
111 112 113 114 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 111 def digest_for(fingerprint, search) digest = search_matches(fingerprint.id, search) content_tag(:span, digest, class: 'text-muted') end |
#downstream_fingerprint_link(print) ⇒ Object
52 53 54 55 56 57 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 52 def downstream_fingerprint_link(print) hash = content_tag(:span, print.id, class: 'text-muted') text = print.error_logs.first.try(:error_class) || 'N/A' bootstrap_list_link_to hash + ' - ' + text, error_fingerprint_path(print) end |
#edit_button_for(fingerprint) ⇒ Object
68 69 70 71 72 73 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 68 def (fingerprint) css = 'btn btn-default' text = glyphicon_tag('pencil') + ' Edit Ticket' link_to(text, edit_error_fingerprint_path(fingerprint), class: css) end |
#highlighted_trace_for(error) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 9 def highlighted_trace_for(error) highlighting = error.application_trace error.backtrace.map do |line| css_classes = 'trace-item' css_classes << ' stack-only' unless highlighting.include?(line) content_tag(:span, line, class: css_classes) end end |
#latest_timestamp_for(fingerprint) ⇒ Object
20 21 22 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 20 def (fingerprint) fingerprint.updated_at.to_formatted_s(:db) end |
#latest_user_for(fingerprint, search) ⇒ Object
24 25 26 27 28 29 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 24 def latest_user_for(fingerprint, search) latest = fingerprint.latest_occurrence text = latest ? search_matches(latest.user_id, search) : 'N/A' content_tag(:span, text, class: 'text-muted') end |
#link_to_fingerprint(fingerprint, latest) ⇒ Object
106 107 108 109 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 106 def link_to_fingerprint(fingerprint, latest) text = truncate(latest.error_string, length: 120) link_to search_matches(text, @keywords), error_fingerprint_path(fingerprint) end |
#multiple_occurrences_badge_for(fingerprint) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 31 def multiple_occurrences_badge_for(fingerprint) return unless fingerprint.count > 1 text = "+ #{fingerprint.count - 1}" opts = { 'class' => 'badge badge-info', 'data-toggle' => 'tooltip', 'data-placement' => 'right', 'title' => "Since #{fingerprint.created_at.to_formatted_s(:db)}" } content_tag(:span, text, opts) end |
#next_button_for(error) ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 97 def (error) css = 'btn btn-default' css << ' disabled' if error.nil? text = glyphicon_tag('chevron-right') path = error.nil? ? '#' : error_fingerprint_path(error.error_fingerprint, log_id: error) link_to(text, path, class: css) end |
#previous_button_for(error) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 88 def (error) css = 'btn btn-default' css << ' disabled' if error.nil? text = glyphicon_tag('chevron-left') path = error.nil? ? '#' : error_fingerprint_path(error.error_fingerprint, log_id: error) link_to(text, path, class: css) end |
#purge_button_for(fingerprint) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 75 def (fingerprint) css = 'btn btn-danger' text = glyphicon_tag('trash icon-white') + ' Purge' = { 'method' => :delete, 'class' => css, 'data-confirm' => 'Delete all logs of this error? - only the fingerprint will be kept.' } link_to(text, error_fingerprint_path(fingerprint), ) end |
#search_matches(string, keywords) ⇒ Object
4 5 6 7 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 4 def search_matches(string, keywords) return string if keywords.blank? highlight(string.to_s, keywords, highlighter: '<strong class="text-danger">\1</strong>') end |
#similar_error_link(error) ⇒ Object
45 46 47 48 49 50 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 45 def similar_error_link(error) user = error.user_id && content_tag(:span, error.user_id, class: 'text-muted') text = safe_join([user, error.created_at.to_formatted_s(:db)].compact, ' - ') bootstrap_list_link_to text, error_fingerprint_path(error.error_fingerprint, log_id: error) end |
#sorted_parameters_for(error) ⇒ Object
116 117 118 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 116 def sorted_parameters_for(error) error.parameters.to_a.sort_by { |key, _value| key.to_s } end |
#ticket_link_for(fingerprint, small = false) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'app/helpers/ndr_error/errors_helper.rb', line 59 def ticket_link_for(fingerprint, small = false) text = glyphicon_tag('asterisk') + ' View ticket' css = 'btn btn-default' css << ' btn-xs' if small url = fingerprint.ticket_url link_to(text, /^http/i =~ url ? url : "http://#{url}", class: css) end |