Sha256: 471e7fe5d09440b204535d3f1a46cf769d626a02881f47a8a186703cfa129870

Contents?: true

Size: 1.67 KB

Versions: 10

Compression:

Stored size: 1.67 KB

Contents

class UiJobWizardController < ApplicationController
  include FiltersHelper
  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, :with_katello => with_katello}
  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 map_template_inputs(template_inputs_with_foreign)
    template_inputs_with_foreign.map { |input| input.attributes.merge({:resource_type_tableize => input.resource_type&.tableize }) }
  end

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

  def with_katello
    !!defined?(::Katello)
  end

  def resource_class
    JobTemplate
  end

  def action_permission
    :view_job_templates
  end

  def resources
    resource_type = params[:resource]
    resource_list = resource_type.constantize.authorized("view_#{resource_type.underscore.pluralize}").all.map { |r| {:name => r.to_s, :id => r.id } }.select { |v| v[:name] =~ /#{params[:name]}/ }
    render :json => { :results =>
      resource_list.sort_by { |r| r[:name] }.take(100), :subtotal => resource_list.count}
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
foreman_remote_execution-5.0.8 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-5.0.7 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-5.0.6 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-5.0.5 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-5.0.4 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-5.0.3 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-5.0.2 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-5.1.0 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-5.0.1 app/controllers/ui_job_wizard_controller.rb
foreman_remote_execution-5.0.0 app/controllers/ui_job_wizard_controller.rb