Sha256: a17627a2d9b022c029710a3370e4386af49817fd0c17126277569f384fa6eacf

Contents?: true

Size: 918 Bytes

Versions: 9

Compression:

Stored size: 918 Bytes

Contents

class JobTemplatesController < ::TemplatesController
  def load_vars_from_template
    return unless @template

    @locations        = @template.locations
    @organizations    = @template.organizations
  end

  def auto_complete_job_name
    @job_names = resource_base.where(['job_name LIKE ?', "%#{params[:search]}%"]).pluck(:job_name).uniq
  end

  def preview
    base = Host.authorized(:view_hosts)
    host = params[:preview_host_id].present? ? base.find(params[:preview_host_id]) : base.first
    @template.template = params[:template]
    renderer = InputTemplateRenderer.new(@template, host)
    if (output = renderer.preview)
      render :text => output
    else
      render :status => 406, :text => renderer.error_message
    end
  end

  private

  def action_permission
    case params[:action]
      when 'auto_complete_job_name'
        :view_job_templates
      else
        super
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_remote_execution-0.0.10 app/controllers/job_templates_controller.rb
foreman_remote_execution-0.0.8 app/controllers/job_templates_controller.rb
foreman_remote_execution-0.0.7 app/controllers/job_templates_controller.rb
foreman_remote_execution-0.0.6 app/controllers/job_templates_controller.rb
foreman_remote_execution-0.0.5 app/controllers/job_templates_controller.rb
foreman_remote_execution-0.0.4 app/controllers/job_templates_controller.rb
foreman_remote_execution-0.0.3 app/controllers/job_templates_controller.rb
foreman_remote_execution-0.0.2 app/controllers/job_templates_controller.rb
foreman_remote_execution-0.0.1 app/controllers/job_templates_controller.rb