Module: ForemanColumnView::HostsHelperExtension::Overrides
- Defined in:
- app/helpers/foreman_column_view/hosts_helper_extension.rb
Instance Method Summary collapse
-
#overview_fields(host) ⇒ Object
Extend core HostsHelper to add rows to Properties on hosts/show.
Instance Method Details
#overview_fields(host) ⇒ Object
Extend core HostsHelper to add rows to Properties on hosts/show
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/foreman_column_view/hosts_helper_extension.rb', line 7 def overview_fields(host) fields = super return fields unless SETTINGS[:column_view] valid_views = [:hosts_properties] SETTINGS[:column_view].reject { |k,v| !valid_views.include?(v[:view]) }.keys.sort.map do |k| after = SETTINGS[:column_view][k.to_sym][:after] conditional = SETTINGS[:column_view][k.to_sym][:conditional] if conditional.present? method = conditional[0].to_sym args = conditional.drop(1) end begin next unless (conditional.present? && host.respond_to?(method) && host.send(method, *args)) || (conditional.nil?) rescue ArgumentError Rails.logger.warn("Foreman_column_view: Your are supplying the wrong kind/number of arguments to your conditional method. Host #{host} , method - #{method} - arguments - #{args.join(', ')} ") next end # This won't work well with i18n, use row numbers instead after = fields.find_index { |r| r[0].include? after } unless after.is_a? Fixnum eval_content = SETTINGS[:column_view][k.to_sym][:eval_content] content = eval_content ? eval(SETTINGS[:column_view][k.to_sym][:content]) : fcv_content(host, k) fields.insert(after || -1, [fcv_title(k), content]) end fields end |