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
60
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 52
def abort
task = find_dynflow_task
if 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(task))
end
|
#cancel ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 43
def cancel
task = find_dynflow_task
if task.cancel
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|
#cancel_step ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 33
def cancel_step
task = find_dynflow_task
result = ForemanTasks.dynflow.world.event(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
91
92
93
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 91
def controller_name
'foreman_tasks_tasks'
end
|
#force_unlock ⇒ Object
83
84
85
86
87
88
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 83
def force_unlock
task = find_dynflow_task
task.state = :stopped
task.save!
render json: { statusText: 'OK' }
end
|
#index ⇒ Object
12
13
14
15
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 12
def index
params[:order] ||= 'started_at DESC'
respond_with_tasks resource_base
end
|
#resource_class ⇒ Object
95
96
97
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 95
def resource_class
ForemanTasks::Task
end
|
#resume ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 62
def resume
task = find_dynflow_task
if task.resumable?
ForemanTasks.dynflow.world.execute(task.execution_plan.id)
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|
#show ⇒ Object
7
8
9
10
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 7
def show
@task = resource_base.find(params[:id])
render :layout => !request.xhr?
end
|
#sub_tasks ⇒ Object
27
28
29
30
31
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 27
def sub_tasks
@task = resource_base.find(params[:id])
respond_with_tasks @task.sub_tasks
end
|
#summary ⇒ Object
17
18
19
20
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 17
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
22
23
24
25
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 22
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
72
73
74
75
76
77
78
79
80
81
|
# File 'app/controllers/foreman_tasks/tasks_controller.rb', line 72
def unlock
task = find_dynflow_task
if task.paused?
task.state = :stopped
task.save!
render json: { statusText: 'OK' }
else
render json: {}, status: :bad_request
end
end
|