Module: PolicyDashboardHelper

Defined in:
app/helpers/policy_dashboard_helper.rb

Constant Summary collapse

COLORS =
{
  :compliant_hosts => ArfReportDashboardHelper::COLORS[:passed],
  :incompliant_hosts => ArfReportDashboardHelper::COLORS[:failed],
  :inconclusive_hosts => ArfReportDashboardHelper::COLORS[:othered],
  :report_missing => '#92A8CD',
}.freeze

Instance Method Summary collapse

Instance Method Details

#assigned_icon(policy, arf_report) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/policy_dashboard_helper.rb', line 38

def assigned_icon(policy, arf_report)
  if arf_report.host.combined_policies.include? policy
    icon = 'check'
    tooltip_text = _('Host is assigned to policy')
  else
    icon = 'close'
    tooltip_text = _('Host is not assigned to policy but reports were found. You may want to delete the reports or assign the policy again.')
  end
  trunc_with_tooltip icon_text(icon, '', :kind => 'fa'), 32, tooltip_text, false
end

#compliance_widget(opts) ⇒ Object



29
30
31
32
33
34
35
36
# File 'app/helpers/policy_dashboard_helper.rb', line 29

def compliance_widget(opts)
  name = opts.delete(:name)
  template = opts.delete(:template)
  widget = Widget.new(opts)
  widget.name = name
  widget.template = template
  widget
end

#policy_breakdown_chart_data(report) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/policy_dashboard_helper.rb', line 9

def policy_breakdown_chart_data(report)
  categories = {
    :compliant_hosts =>  _('Compliant hosts'),
    :incompliant_hosts =>  _('Incompliant hosts'),
    :inconclusive_hosts => _('Inconclusive'),
    :report_missing =>  _('Not audited'),
  }

  breakdown_chart_data categories, report, COLORS
end


20
21
22
23
24
25
26
27
# File 'app/helpers/policy_dashboard_helper.rb', line 20

def status_link(name, label, path)
   :li do
    (:i, raw(' '), :class => 'label', :style => 'background-color:' + COLORS[label]) +
    raw(' ') +
    link_to(name, path, :class => 'dashboard-links') +
    (:h4, @report[label])
  end
end


49
50
51
52
53
54
55
56
57
58
59
# File 'app/helpers/policy_dashboard_helper.rb', line 49

def unassigned_hosts_link
  trunc_with_tooltip(
    link_to(
      _("Hosts no longer assigned: %s") % @report[:unassigned_hosts],
      hosts_path(:search => "removed_from_policy = \"#{@policy.name}\"")
    ),
    32,
    _("Total hosts with reports where policy is no longer assigned."),
    false
  )
end