Module: FactValuesHelper

Defined in:
app/helpers/fact_values_helper.rb

Instance Method Summary collapse

Instance Method Details


24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/helpers/fact_values_helper.rb', line 24

def create_fact_name_link(parent, current_name, host_id, value, value_name, memo)
  return current_name if parent.present? && h(parent.name) == memo
  if value_name != memo || value.compose
    parameters = { :parent_fact => memo }
    url = host_parent_fact_facts_path(parameters.merge({ :host_id => host_id || value.host.name }))
    link_to(current_name, url,
      :title => _("Show all %s children fact values") % memo)
  else
    link_to(current_name, fact_values_path(:search => "name = #{value_name}"),
      :title => _("Show %s fact values for all hosts") % value_name)
  end
end

#escaped_warning_contextObject


80
81
82
# File 'app/helpers/fact_values_helper.rb', line 80

def escaped_warning_context
  _("Search may fail or give you wrong results since it contains special characters that are query keywords such as < and >")
end

#escaped_warning_titleObject


76
77
78
# File 'app/helpers/fact_values_helper.rb', line 76

def escaped_warning_title
  _("contains special characters")
end

#fact_breadcrumbsObject


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/helpers/fact_values_helper.rb', line 55

def fact_breadcrumbs
  breadcrumbs(
    items: [
      {
        caption: _("Facts Values"),
        url: (fact_values_path if authorized_for(hash_for_fact_values_path)),
      },
      {
        caption: params[:host_id],
      },
    ],
    resource_url: api_hosts_path(thin: true),
    switcher_item_url: host_facts_path(':name'),
    switchable: true
  )
end

#fact_from(record) ⇒ Object


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

def fact_from(record)
  date_time_relative(record.updated_at)
rescue
  _("N/A")
end

#fact_name(value, parent) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/fact_values_helper.rb', line 8

def fact_name(value, parent)
  value_name = name = value.name
  memo       = ''
  name.split(FactName::SEPARATOR).map do |current_name|
    memo = memo.empty? ? current_name : memo + FactName::SEPARATOR + current_name
    (:li) do
      if value.compose && current_name == name.split(FactName::SEPARATOR).last
        url = host_parent_fact_facts_path(:parent_fact => value_name, :host_id => params[:host_id] || value.host.name)
        link_to(icon_text('angle-down', '', :kind => 'fa', :title => _('Expand nested items')), url) + ' ' + create_fact_name_link(parent, current_name, params[:host_id], value, value_name, memo)
      else
        create_fact_name_link(parent, current_name, params[:host_id], value, value_name, memo)
      end
    end
  end.join.html_safe
end

#fact_origin_icon(origin, icon_path) ⇒ Object

Return fact icon image tag. Stub is used in some cases because of legal requirements. Make sure to get legal advice prior putting any logos into our git repository.


51
52
53
# File 'app/helpers/fact_values_helper.rb', line 51

def fact_origin_icon(origin, icon_path)
  image_tag(icon_path, title: origin, size: '16x16')
end

#is_escaped_value(value) ⇒ Object


72
73
74
# File 'app/helpers/fact_values_helper.rb', line 72

def is_escaped_value(value)
  value != CGI.escapeHTML(value)
end

84
85
86
# File 'app/helpers/fact_values_helper.rb', line 84

def print_escape_warning(column)
  fact_contains_escaped_values
end

#show_full_fact_value(fact_value) ⇒ Object


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

def show_full_fact_value(fact_value)
  (:div, :class => 'replace-hidden-value') do
    link_to_function(icon_text('plus', '', :class => 'small'), 'replace_value_control(this)',
      :title => _('Show full value'),
      :class => 'replace-hidden-value pull-right') +
        (:span, :class => 'full-value') do
          fact_value
        end
  end.html_safe
end