Class: JobInvocationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- JobInvocationsController
- Includes:
- Foreman::Controller::AutoCompleteSearch, ForemanTasks::Concerns::Parameters::Triggering
- Defined in:
- app/controllers/job_invocations_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #preview_hosts ⇒ Object
-
#refresh ⇒ Object
refreshes the form.
- #rerun ⇒ Object
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/job_invocations_controller.rb', line 32 def create @composer = prepare_composer if @composer.trigger redirect_to job_invocation_path(@composer.job_invocation) else @composer.job_invocation.description_format = nil if params.fetch(:job_invocation, {}).key?(:description_override) render :action => 'new' end end |
#index ⇒ Object
54 55 56 |
# File 'app/controllers/job_invocations_controller.rb', line 54 def index @job_invocations = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page]).with_task.order('job_invocations.id DESC') end |
#new ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/job_invocations_controller.rb', line 5 def new ui_params = { :host_ids => params[:host_ids], :targeting => { :targeting_type => Targeting::STATIC_TYPE, :bookmark_id => params[:bookmark_id] } } if (template = JobTemplate.find_by(id: params[:template_id])) ui_params[:job_invocation] = { :job_category => template.job_category, :providers => { template.provider_type => {:job_template_id => template.id} } } end @composer = JobInvocationComposer.from_ui_params(ui_params) end |
#preview_hosts ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/job_invocations_controller.rb', line 64 def preview_hosts composer = prepare_composer @hosts = composer.targeted_hosts.limit(Setting[:entries_per_page]) @additional = composer.targeted_hosts.count - Setting[:entries_per_page] @dynamic = composer.targeting.dynamic? @query = composer.displayed_search_query render :partial => 'job_invocations/preview_hosts_list' end |
#refresh ⇒ Object
refreshes the form
59 60 61 62 |
# File 'app/controllers/job_invocations_controller.rb', line 59 def refresh params[:job_invocation].delete :description_format if params[:job_invocation].key?(:description_override) @composer = prepare_composer end |
#rerun ⇒ Object
26 27 28 29 30 |
# File 'app/controllers/job_invocations_controller.rb', line 26 def rerun job_invocation = resource_base.find(params[:id]) @composer = JobInvocationComposer.from_job_invocation(job_invocation, params) render :action => 'new' end |
#show ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/job_invocations_controller.rb', line 42 def show @job_invocation = resource_base.includes(:template_invocations => :run_host_job_task).find(params[:id]) @auto_refresh = @job_invocation.task.try(:pending?) hosts_base = @job_invocation.targeting.hosts.(:view_hosts, Host) # There's no need to do the joining if we're not filtering unless params[:search].nil? hosts_base = hosts_base.joins(:template_invocations) .where(:template_invocations => { :job_invocation_id => @job_invocation.id}) end @hosts = hosts_base.search_for(params[:search], :order => params[:order] || 'name ASC').paginate(:page => params[:page]) end |