Module: ForemanTeamdynamix::HostsHelperExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/helpers/concerns/foreman_teamdynamix/hosts_helper_extensions.rb

Constant Summary collapse

DEFAULT_TD_PANE_FIELDS =
{ 'Asset ID' => 'ID',
'Owner' => 'OwningCustomerName',
'Parent Asset' => 'ParentID' }.freeze

Instance Method Summary collapse

Instance Method Details

#teamdynamix_fieldsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/concerns/foreman_teamdynamix/hosts_helper_extensions.rb', line 12

def teamdynamix_fields
  td_pane_fields = SETTINGS[:teamdynamix][:fields] || DEFAULT_TD_PANE_FIELDS
  return [[_('Asset'), 'None Associated or error from Team Dynamix']] unless @host.teamdynamix_asset

  @asset = @host.teamdynamix_asset

  # display a link to the asset if url set
  fields = asset_uri(td_pane_fields)

  td_pane_fields.except(:url).each do |field_name, asset_attr|
    asset_attr_val = @asset.key?(asset_attr) ? @asset[asset_attr] : get_nested_attrib_val(asset_attr)
    fields += [[_(field_name.to_s), asset_attr_val]] if asset_attr_val.present?
  end
  fields
rescue StandardError => e
  [[_('Error'), e.message]]
end

#teamdynamix_titleObject



8
9
10
# File 'app/helpers/concerns/foreman_teamdynamix/hosts_helper_extensions.rb', line 8

def teamdynamix_title
  SETTINGS[:teamdynamix][:title] || 'TeamDynamix'
end