Module: SesDashboard::ApplicationHelper
- Defined in:
- app/helpers/ses_dashboard/application_helper.rb
Constant Summary collapse
- STATUS_BADGE_CLASSES =
{ "sent" => "badge-sent", "delivered" => "badge-delivered", "bounced" => "badge-bounced", "complained" => "badge-complained", "rejected" => "badge-rejected", "failed" => "badge-failed" }.freeze
Instance Method Summary collapse
- #chart_data_tag(data) ⇒ Object
- #date_range_link(label, days) ⇒ Object
- #format_destination(destination) ⇒ Object
- #format_event_type(type) ⇒ Object
- #pagination_link(label, page, params_override = {}) ⇒ Object
- #status_badge(status) ⇒ Object
- #webhook_url_for(project) ⇒ Object
Instance Method Details
#chart_data_tag(data) ⇒ Object
29 30 31 32 |
# File 'app/helpers/ses_dashboard/application_helper.rb', line 29 def chart_data_tag(data) content_tag(:script, data.to_json.html_safe, id: "chart-data", type: "application/json") end |
#date_range_link(label, days) ⇒ Object
34 35 36 37 38 39 |
# File 'app/helpers/ses_dashboard/application_helper.rb', line 34 def date_range_link(label, days) from = days.days.ago.beginning_of_day to = Time.current.end_of_day link_to label, request.path + "?from=#{from.iso8601}&to=#{to.iso8601}", class: "date-preset-link" end |
#format_destination(destination) ⇒ Object
25 26 27 |
# File 'app/helpers/ses_dashboard/application_helper.rb', line 25 def format_destination(destination) Array(destination).join(", ") end |
#format_event_type(type) ⇒ Object
17 18 19 |
# File 'app/helpers/ses_dashboard/application_helper.rb', line 17 def format_event_type(type) type.to_s.gsub("_", " ").capitalize end |
#pagination_link(label, page, params_override = {}) ⇒ Object
41 42 43 44 45 |
# File 'app/helpers/ses_dashboard/application_helper.rb', line 41 def pagination_link(label, page, params_override = {}) return content_tag(:span, label, class: "pagination-disabled") unless page link_to label, request.path + "?" + request.query_parameters.merge(params_override.merge(page: page)).to_query, class: "pagination-link" end |
#status_badge(status) ⇒ Object
12 13 14 15 |
# File 'app/helpers/ses_dashboard/application_helper.rb', line 12 def status_badge(status) css = STATUS_BADGE_CLASSES.fetch(status.to_s, "badge-unknown") content_tag(:span, status.to_s.capitalize, class: "badge #{css}") end |
#webhook_url_for(project) ⇒ Object
21 22 23 |
# File 'app/helpers/ses_dashboard/application_helper.rb', line 21 def webhook_url_for(project) ses_dashboard.webhook_url(project.token) end |