Module: ComplianceHostsHelper

Defined in:
app/helpers/compliance_hosts_helper.rb

Instance Method Summary collapse

Instance Method Details

#compliance_host_multiple_actionsObject



22
23
24
25
26
27
28
29
30
# File 'app/helpers/compliance_hosts_helper.rb', line 22

def compliance_host_multiple_actions
  return [] unless User.current.can?(:edit_hosts)

  [
    { :action => [_('Assign Compliance Policy'), select_multiple_hosts_policies_path], :priority => 1210 },
    { :action => [_('Unassign Compliance Policy'), disassociate_multiple_hosts_policies_path], :priority => 1211 },
    { :action => [_('Change OpenSCAP Proxy'), select_multiple_openscap_proxy_hosts_path], :priority => 1212 },
  ]
end

#compliance_host_overview_button(host) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/compliance_hosts_helper.rb', line 32

def compliance_host_overview_button(host)
  return [] if host.arf_reports.none?
  [
    {
      :button => link_to_if_authorized(
        _('Compliance'),
        hash_for_compliance_host_path(host.id),
        :title => _("Host compliance details"),
        :class => 'btn btn-default'
      ),
      :priority => 1000
    }
  ]
end

#host_arf_reports_chart_data(policy_id) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/compliance_hosts_helper.rb', line 2

def host_arf_reports_chart_data(policy_id)
  passed = []
  failed = []
  othered = []
  date = []
  @host.arf_reports.of_policy(policy_id).each do |report|
    passed  << report.passed
    failed  << report.failed
    othered << report.othered
    date << report.created_at.to_i * 1000
  end
  data = [
    [_("Passed"), passed, ArfReportDashboardHelper::COLORS[:passed]],
    [_("Failed"), failed, ArfReportDashboardHelper::COLORS[:failed]],
    [_("Othered"), othered, ArfReportDashboardHelper::COLORS[:othered]],
    ['dates', date, nil]
  ]
  { :data => data, :xAxisDataLabel => 'dates', :config => 'timeseries' }
end