Module: ForemanRemoteExecution::HostsHelperExtensions

Defined in:
app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb

Instance Method Summary collapse

Instance Method Details

#host_overview_buttons(host) ⇒ Object



3
4
5
6
7
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 3

def host_overview_buttons(host)
  [
    { :button => link_to_if_authorized(_("Jobs"), hash_for_job_invocations_path(search: "host=#{host.name}"), :title => _("Job invocations"), :class => 'btn btn-default'), :priority => 200 },
  ]
end

#host_title_actions(*args) ⇒ Object



40
41
42
43
44
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 40

def host_title_actions(*args)
  title_actions(button_group(schedule_job_multi_button(*args)),
    button_group(web_console_button(*args)))
  super(*args)
end

#multiple_actionsObject



9
10
11
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 9

def multiple_actions
  super + [ [_('Schedule Remote Job'), new_job_invocation_path, false] ]
end

#rex_host_features(*args) ⇒ Object



23
24
25
26
27
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 23

def rex_host_features(*args)
  RemoteExecutionFeature.with_host_action_button.order(:label).map do |feature|
    link_to(_('%s') % feature.name, job_invocations_path(:host_ids => [args.first.id], :feature => feature.label), :method => :post)
  end
end

#schedule_job_button(*args) ⇒ Object



29
30
31
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 29

def schedule_job_button(*args)
  link_to(_('Schedule Remote Job'), new_job_invocation_path(:host_ids => [args.first.id]), :id => :run_button, :class => 'btn btn-default')
end

#schedule_job_multi_button(*args) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 13

def schedule_job_multi_button(*args)
  host_features = rex_host_features(*args)

  if host_features.present?
    action_buttons(schedule_job_button(*args), *host_features)
  else
    schedule_job_button(*args)
  end
end

#web_console_button(host, *args) ⇒ Object



33
34
35
36
37
38
# File 'app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb', line 33

def web_console_button(host, *args)
  return unless authorized_for(permission: 'cockpit_hosts', auth_object: host)

  url = SSHExecutionProvider.cockpit_url_for_host(host.name)
  url ? link_to(_('Web Console'), url, :class => 'btn btn-default', :id => :'web-console-button', :target => '_new') : nil
end