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
52
53
54
55
56
57
58
59
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 52
def abort
if @dynflow_task.abort
flash[:info] = _('Trying to abort the task')
else
flash[:warning] = _('The task cannot be aborted at the moment.')
end
redirect_back(:fallback_location => foreman_tasks_task_path(@dynflow_task))
end
|
#cancel ⇒ Object
44
45
46
47
48
49
50
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 44
def cancel
if @dynflow_task.cancel
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|
#cancel_step ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 35
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
90
91
92
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 90
def controller_name
'foreman_tasks_tasks'
end
|
#force_unlock ⇒ Object
79
80
81
82
83
84
85
86
87
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 79
def force_unlock
if @dynflow_task.pending?
@dynflow_task.halt
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|
#index ⇒ Object
14
15
16
17
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 14
def index
params[:order] ||= 'started_at DESC'
respond_with_tasks resource_base
end
|
#resource_class ⇒ Object
94
95
96
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 94
def resource_class
ForemanTasks::Task
end
|
#resume ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 61
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
|
#show ⇒ Object
9
10
11
12
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 9
def show
@task = resource_base.find(params[:id])
render :layout => !request.xhr?
end
|
#sub_tasks ⇒ Object
29
30
31
32
33
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 29
def sub_tasks
@task = resource_base.find(params[:id])
respond_with_tasks @task.sub_tasks
end
|
#summary ⇒ Object
19
20
21
22
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 19
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
24
25
26
27
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 24
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
70
71
72
73
74
75
76
77
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 70
def unlock
if @dynflow_task.paused?
@dynflow_task.halt
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|