Module: ArfReportsHelper

Defined in:
app/helpers/arf_reports_helper.rb

Instance Method Summary collapse

Instance Method Details

#arf_report_breadcrumbsObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/arf_reports_helper.rb', line 16

def arf_report_breadcrumbs
  if @arf_report && @arf_report.host
    breadcrumbs(:resource_url => api_compliance_arf_reports_path,
                :switchable => false,
                :items => [
                  { :caption => _('Compliance Reports'),
                    :url => url_for(arf_reports_path) },
                  { :caption => @arf_report.host.name,
                    :url => (arf_report_path(@arf_report) if authorized_for(hash_for_arf_report_path(@arf_report))) }
                ])
  end
end

#host_search_by_rule_result_buttons(source) ⇒ Object



82
83
84
85
86
# File 'app/helpers/arf_reports_helper.rb', line 82

def host_search_by_rule_result_buttons(source)
  action_buttons(display_link_if_authorized(_('Hosts failing this rule'), hash_for_hosts_path(:search => "fails_xccdf_rule = #{source}")),
                 display_link_if_authorized(_('Hosts passing this rule'), hash_for_hosts_path(:search => "passes_xccdf_rule = #{source}")),
                 display_link_if_authorized(_('Hosts othering this rule'), hash_for_hosts_path(:search => "others_xccdf_rule = #{source}")))
end

#multiple_actions_arf_reportObject



55
56
57
58
59
# File 'app/helpers/arf_reports_helper.rb', line 55

def multiple_actions_arf_report
  actions = [
    [_('Delete reports'), delete_multiple_arf_reports_path]
  ]
end

#multiple_actions_arf_report_selectObject



61
62
63
64
65
66
67
# File 'app/helpers/arf_reports_helper.rb', line 61

def multiple_actions_arf_report_select
  select_action_button(_("Select Action"), { :id => 'submit_multiple' },
                       multiple_actions_arf_report.map do |action|
                         link_to_function(action[0], "buildArfModal(this, '#{action[1]}')",
                                          :'data-dialog-title' => _("%s - The following compliance reports are about to be changed") % action[0])
                       end.flatten)
end


69
70
71
72
# File 'app/helpers/arf_reports_helper.rb', line 69

def openscap_proxy_link(arf_report)
  return _("No proxy found!") unless arf_report.openscap_proxy
  display_link_if_authorized(arf_report.openscap_proxy.name, hash_for_smart_proxy_path(:id => arf_report.openscap_proxy_id))
end

#report_arf_column(event, style = "") ⇒ Object



2
3
4
5
# File 'app/helpers/arf_reports_helper.rb', line 2

def report_arf_column(event, style = "")
  style = "label-default" if event == 0
  (:span, event, :class => 'label ' + style)
end

#reported_info(arf_report) ⇒ Object



74
75
76
77
78
79
80
# File 'app/helpers/arf_reports_helper.rb', line 74

def reported_info(arf_report)
  msg = _("Reported at %s") % date_time_absolute(arf_report.reported_at)
  msg << _(" for policy %s") % display_link_if_authorized(arf_report.policy.name, hash_for_edit_policy_path(:id => arf_report.policy.id)) if arf_report.policy
  return msg.html_safe unless arf_report.openscap_proxy
  msg += _(" through %s") % openscap_proxy_link(arf_report)
  msg.html_safe
end

#result_tag(level) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/arf_reports_helper.rb', line 29

def result_tag(level)
  tag = case level
        when 'pass'
          "success"
        when 'fail'
          "danger"
        else
          "warning"
        end
  "class='label label-#{tag} result-filter-tag'".html_safe
end

#severity_tag(level) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/arf_reports_helper.rb', line 41

def severity_tag(level)
  tag = case level.downcase.to_sym
        when :low
          "info"
        when :medium
          "warning"
        when :high
          "danger"
        else
          "default"
        end
  "class='label label-#{tag}'".html_safe
end

#show_logsObject



7
8
9
10
11
12
13
14
# File 'app/helpers/arf_reports_helper.rb', line 7

def show_logs
  return if @arf_report.logs.empty?
  form_tag arf_report_path(@arf_report), :id => 'level_filter', :method => :get, :class => "form form-horizontal" do
    (:span, _("Show log messages:") + ' ') +
    select(nil, 'level', [[_('All messages'), 'info'], [_('Failed and Othered'), 'warning'], [_('Failed only'), 'error']],
           {}, { :class => "col-md-1 form-control", :onchange => "filter_by_level(this);" })
  end
end