Class: Para::Admin::JobsController

Inherits:
ComponentController show all
Includes:
ResourceControllerConcerns
Defined in:
app/controllers/para/admin/jobs_controller.rb

Direct Known Subclasses

ExportsController, ImportsController

Instance Method Summary collapse

Methods inherited from BaseController

#current_ability, #current_admin

Methods included from BaseHelper

#find_partial_for, #find_relation_name_for, #flash_message, #flash_shared_key, #registered_components_options, #resource_title_for, #template_path_lookup

Methods included from Helpers::ResourceName

#resource_name

Methods inherited from Para::ApplicationController

#admin?

Instance Method Details

#showObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/para/admin/jobs_controller.rb', line 33

def show
  @status = ActiveJob::Status.get(params[:id])

  respond_to do |format|
    format.json do
      if @status.failed?
        render json: { status: @status.status }, status: 422
      else
        render json: { status: @status.status, progress: @status.progress * 100 }
      end
    end

    format.html do
      @job = @status[:job_type].constantize.new
      # Assign job id to allow status to be retrieved, which in our case
      # allows data persistence though the `#store` method
      @job.job_id = params[:id]

      render layout: false
    end
  end
end