Module: ForemanAnsible::AnsibleRolesHelper

Defined in:
app/helpers/foreman_ansible/ansible_roles_helper.rb

Overview

Small convenience to list all roles in the UI

Instance Method Summary collapse

Instance Method Details

#ansible_proxy_import(hash) ⇒ Object



28
29
30
31
32
# File 'app/helpers/foreman_ansible/ansible_roles_helper.rb', line 28

def ansible_proxy_import(hash)
  select_action_button(_('Import'),
                       { :primary => true, :class => 'roles-import' },
                       ansible_proxy_links(hash))
end


6
7
8
9
10
11
12
# File 'app/helpers/foreman_ansible/ansible_roles_helper.rb', line 6

def ansible_proxy_links(hash, classes = nil)
  SmartProxy.with_features('Ansible').map do |proxy|
    display_link_if_authorized(_('Import from %s') % proxy.name,
                               hash.merge(:proxy => proxy),
                               :class => classes)
  end.flatten
end

#ansible_role_select(f, persisted) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/foreman_ansible/ansible_roles_helper.rb', line 14

def ansible_role_select(f, persisted)
  blank_opt = persisted ? {} : { :include_blank => true }
  select_items = persisted ? [f.object.ansible_role] : AnsibleRole.order(:name)
  select_f f,
           :ansible_role_id,
           select_items,
           :id,
           :to_label,
           blank_opt,
           :label => _("Ansible Role"),
           :disabled => persisted,
           :required => true
end

#import_time(role) ⇒ Object



34
35
36
# File 'app/helpers/foreman_ansible/ansible_roles_helper.rb', line 34

def import_time(role)
  _('%s ago') % time_ago_in_words(role.updated_at)
end

#roles_attrs(roles) ⇒ Object



38
39
40
# File 'app/helpers/foreman_ansible/ansible_roles_helper.rb', line 38

def roles_attrs(roles)
  roles.map { |item| { :id => item.id, :name => item.name } }
end