Module: RemoteExecutionHelper
- Defined in:
- app/helpers/remote_execution_helper.rb
Instance Method Summary collapse
- #host_counter(label, count) ⇒ Object
- #invocation_count(invocation, options = {}) ⇒ Object
- #job_invocation_chart(invocation) ⇒ Object
- #job_invocation_status(invocation) ⇒ Object
- #job_invocation_task_buttons(task) ⇒ Object
- #link_to_invocation_task_if_authorized(invocation) ⇒ Object
- #providers_options ⇒ Object
- #template_input_types_options ⇒ Object
- #template_invocation_status(task) ⇒ Object
Instance Method Details
#host_counter(label, count) ⇒ Object
38 39 40 41 42 |
# File 'app/helpers/remote_execution_helper.rb', line 38 def host_counter(label, count) content_tag(:div, :class => 'host_counter') do content_tag(:div, label, :class => 'header') + content_tag(:div, count.to_s, :class => 'count') end end |
#invocation_count(invocation, options = {}) ⇒ Object
84 85 86 87 |
# File 'app/helpers/remote_execution_helper.rb', line 84 def invocation_count(invocation, = {}) = { :unknown_string => 'N/A' }.merge() (invocation.last_task.try(:output) || {}).fetch([:output_key], [:unknown_string]) end |
#job_invocation_chart(invocation) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/remote_execution_helper.rb', line 10 def job_invocation_chart(invocation) = { :class => 'statistics-pie small', :expandable => true, :border => 0, :show_title => true } if (bulk_task = invocation.last_task) success = bulk_task.output['success_count'] || 0 failed = bulk_task.output['failed_count'] || 0 pending = (bulk_task.output['pending_count'] || 0) flot_pie_chart('status', job_invocation_status(invocation), [{:label => _('Success'), :data => success, :color => '#5CB85C'}, {:label => _('Failed'), :data => failed, :color => '#D9534F'}, {:label => _('Pending'), :data => pending, :color => '#DEDEDE'}], ) else content_tag(:h4, job_invocation_status(invocation)) end end |
#job_invocation_status(invocation) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/remote_execution_helper.rb', line 28 def job_invocation_status(invocation) if invocation.last_task.blank? _('Job not started yet 0%') else label = invocation.last_task.pending ? _('Running') : _('Finished') label + ' ' + (invocation.last_task.progress * 100).to_i.to_s + '%' end end |
#job_invocation_task_buttons(task) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/helpers/remote_execution_helper.rb', line 57 def (task) = [] << link_to(_('Refresh'), {}, :class => 'btn btn-default', :title => _('Refresh this page')) if (:permission => :view_foreman_tasks, :auth_object => task) << link_to(_("Last Job Task"), foreman_tasks_task_path(task), :class => "btn btn-default", :title => _('See the last task details')) end if (:permission => :edit_foreman_tasks, :auth_object => task) << link_to(_("Cancel Job"), cancel_foreman_tasks_task_path(task), :class => "btn btn-danger", :title => _('Try to cancel the job'), :disabled => !task.cancellable?, :method => :post) end return (*) end |
#link_to_invocation_task_if_authorized(invocation) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'app/helpers/remote_execution_helper.rb', line 75 def (invocation) if invocation.last_task.present? job_invocation_status(invocation), hash_for_foreman_tasks_task_path(invocation.last_task).merge(:auth_object => invocation.last_task, :permission => :view_foreman_tasks) else job_invocation_status(invocation) end end |
#providers_options ⇒ Object
2 3 4 |
# File 'app/helpers/remote_execution_helper.rb', line 2 def RemoteExecutionProvider.providers.map { |key, provider| [ key, _(provider) ] } end |
#template_input_types_options ⇒ Object
6 7 8 |
# File 'app/helpers/remote_execution_helper.rb', line 6 def TemplateInput::TYPES.map { |key, name| [ _(name), key ] } end |
#template_invocation_status(task) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/helpers/remote_execution_helper.rb', line 44 def template_invocation_status(task) case task.result when 'warning', 'error' content_tag(:i, ' '.html_safe, :class => 'glyphicon glyphicon-exclamation-sign') + content_tag(:span, _('failed'), :class => 'status-error') when 'success' content_tag(:i, ' '.html_safe, :class => 'glyphicon glyphicon-ok-sign') + content_tag(:span, _('success'), :class => 'status-ok') when 'pending' content_tag(:i, ' '.html_safe, :class => 'glyphicon glyphicon-question-sign') + content_tag(:span, _('pending')) else task.result end end |