Class: ForemanTasks::TasksController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ForemanTasks::TasksController
show all
- Includes:
- Foreman::Controller::AutoCompleteSearch, Foreman::Controller::CsvResponder, FindTasksCommon
- Defined in:
- app/controllers/foreman_tasks/tasks_controller.rb
Instance Method Summary
collapse
#current_taxonomy_search, #search_query
Instance Method Details
#abort ⇒ Object
47
48
49
50
51
52
53
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 47
def abort
if @dynflow_task.abort
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|
#cancel ⇒ Object
39
40
41
42
43
44
45
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 39
def cancel
if @dynflow_task.cancel
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|
#cancel_step ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 30
def cancel_step
result = ForemanTasks.dynflow.world.event(@dynflow_task.external_id, params[:step_id].to_i, ::Dynflow::Action::Cancellable::Cancel).wait
if result.rejected?
render json: { error: result.reason }, status: :bad_request
else
render json: { statusText: 'OK' }
end
end
|
#controller_name ⇒ Object
we need do this to make the Foreman helpers working properly
84
85
86
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 84
def controller_name
'foreman_tasks_tasks'
end
|
#force_unlock ⇒ Object
73
74
75
76
77
78
79
80
81
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 73
def force_unlock
if @dynflow_task.pending?
@dynflow_task.halt
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|
#index ⇒ Object
9
10
11
12
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 9
def index
params[:order] ||= 'started_at DESC'
respond_with_tasks resource_base
end
|
#resource_class ⇒ Object
88
89
90
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 88
def resource_class
ForemanTasks::Task
end
|
#resume ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 55
def resume
if @dynflow_task.resumable?
ForemanTasks.dynflow.world.execute(@dynflow_task.execution_plan.id)
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|
#sub_tasks ⇒ Object
24
25
26
27
28
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 24
def sub_tasks
@task = resource_base.find(params[:id])
respond_with_tasks @task.sub_tasks
end
|
#summary ⇒ Object
14
15
16
17
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 14
def summary
scope = resource_base.search_for(current_taxonomy_search).select(:id)
render json: Task::Summarizer.new(Task.where(:id => scope), params[:recent_timeframe].to_i).summary
end
|
#summary_sub_tasks ⇒ Object
19
20
21
22
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 19
def summary_sub_tasks
filtered_scope = resource_base.find(params[:id]).sub_tasks
render :json => Task::Summarizer.new(filtered_scope, params[:recent_timeframe].to_i).summary
end
|
#unlock ⇒ Object
64
65
66
67
68
69
70
71
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 64
def unlock
if @dynflow_task.paused?
@dynflow_task.halt
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|