Sha256: 0ebf7f3e9f7228b22ee8d2b627d7df096044a4fe2562ebecee5fa2f33d0fa4cd

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

class UiJobWizardController < ::Api::V2::BaseController
  def categories
    job_categories = resource_scope
                     .search_for("job_category ~ \"#{params[:search]}\"")
                     .select(:job_category).distinct
                     .reorder(:job_category)
                     .pluck(:job_category)
    render :json => {:job_categories =>job_categories}
  end

  def template
    job_template = JobTemplate.authorized.find(params[:id])
    advanced_template_inputs, template_inputs = map_template_inputs(job_template.template_inputs_with_foreign).partition { |x| x["advanced"] }
    render :json => {
      :job_template => job_template,
      :effective_user => job_template.effective_user,
      :template_inputs => template_inputs,
      :advanced_template_inputs => advanced_template_inputs,
    }
  end

  def resource_name(nested_resource = nil)
    nested_resource || 'job_template'
  end

  def map_template_inputs(template_inputs_with_foreign)
    template_inputs_with_foreign.map { |input| input.attributes.merge({:resource_type => input.resource_type&.tableize }) }
  end

  def resource_class
    JobTemplate
  end

  def action_permission
    :view_job_templates
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
foreman_remote_execution-4.8.0 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-4.5.6 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-4.5.5 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-4.5.4 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-4.7.0 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-4.5.3 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-4.5.2 app/controllers/ui_job_wizard_controller.rb