Class: Naf::HistoricalJobsController
Constant Summary
ApplicationHelper::NAF_ALL_VISIBLE_RESOURCES, ApplicationHelper::NAF_CREATE_BLOCKED_RESOURCES, ApplicationHelper::NAF_DESTROY_BLOCKED_RESOURCES, ApplicationHelper::NAF_READ_ONLY_RESOURCES
Instance Method Summary
collapse
#add_color, #http_protocol, #naf_display_job_search_link?, #naf_generate_back_link, #naf_generate_child_resources_link, #naf_generate_create_link, #naf_generate_destroy_link, #naf_generate_edit_link, #naf_generate_index_link, #naf_highlight_tab?, #naf_last_queued_at_link, #naf_link_to_add_fields, #naf_link_to_remove_fields, #naf_make_header, #naf_model_name, #naf_nested_resource_index?, #naf_parent_resource_link, #naf_table_title, #naf_tabs
Instance Method Details
#create ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'app/controllers/naf/historical_jobs_controller.rb', line 46
def create
@historical_job = Naf::HistoricalJob.new(params[:historical_job])
if params[:historical_job][:application_id] && app = Naf::Application.find(params[:historical_job][:application_id])
if schedule = app.application_schedule
@historical_job = Logical::Naf::JobCreator.new.queue_application_schedule(schedule)
if @historical_job.blank?
render json: { success: false,
title: ::Naf::Application.find_by_id(params[:historical_job][:application_id]).title }.to_json
return
end
else
@historical_job.command = app.command
@historical_job.application_type_id = app.application_type_id
@historical_job.application_run_group_restriction_id = Naf::ApplicationRunGroupRestriction.no_limit.id
@queued_job = ::Naf::QueuedJob.new
end
else
@queued_job = ::Naf::QueuedJob.new
end
if @queued_job.present?
@queued_job.application_type_id = @historical_job.application_type_id
@queued_job.command = @historical_job.command
@queued_job.application_run_group_restriction_id = @historical_job.application_run_group_restriction_id
@queued_job.application_run_group_name = @historical_job.application_run_group_name
@queued_job.application_run_group_limit = @historical_job.application_run_group_limit
@queued_job.priority = @historical_job.priority
end
respond_to do |format|
format.json do
if @historical_job.save
if @queued_job.present?
@queued_job.id = @historical_job.id
@queued_job.save
end
render json: { success: true,
title: @historical_job.title,
command: @historical_job.command }.to_json
end
end
format.html do
if @historical_job.save
if @queued_job.present?
@queued_job.id = @historical_job.id
@queued_job.save
end
redirect_to(@historical_job,
notice: "Job '#{@historical_job.command}' was successfully created.")
else
render action: "new"
end
end
end
end
|
#index ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/naf/historical_jobs_controller.rb', line 9
def index
respond_to do |format|
format.html
format.json do
set_page
set_status
params[:search][:direction] = params['sSortDir_0']
params[:search][:order] = Logical::Naf::Job::ORDER[params['iSortCol_0']]
params[:search][:limit] = params['iDisplayLength']
params[:search][:offset] = @page - 1
@total_display_records = Logical::Naf::Job.total_display_records(params[:search])
@total_records = Naf::HistoricalJob.count(:all)
@historical_jobs = []
job =[]
Logical::Naf::Job.search(params[:search]).map(&:to_hash).map do |hash|
add_urls(hash).map do |key, value|
value ||= ''
job << value
end
@historical_jobs << job
job = []
end
render layout: 'naf/layouts/jquery_datatables'
end
end
end
|
#new ⇒ Object
43
44
|
# File 'app/controllers/naf/historical_jobs_controller.rb', line 43
def new
end
|
#show ⇒ Object
38
39
40
41
|
# File 'app/controllers/naf/historical_jobs_controller.rb', line 38
def show
@historical_job = Naf::HistoricalJob.find(params[:id])
@logical_job = Logical::Naf::Job.new(@historical_job)
end
|
#update ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'app/controllers/naf/historical_jobs_controller.rb', line 106
def update
respond_to do |format|
@historical_job = Naf::HistoricalJob.find(params[:id])
if @historical_job.update_attributes(params[:historical_job])
if params[:historical_job][:request_to_terminate].present?
if queued_job = ::Naf::QueuedJob.find_by_id(params[:id])
@historical_job.finished_at = Time.zone.now
@historical_job.save!
queued_job.delete
end
if running_job = ::Naf::RunningJob.find_by_id(params[:id])
running_job.update_attributes(request_to_terminate: true)
@historical_job.update_attributes(request_to_terminate: true)
end
end
format.html do
redirect_to(@historical_job, notice: "Job '#{@historical_job.command}' was successfully updated.")
end
format.json do
render json: { success: true,
title: @historical_job.title,
command: @historical_job.command }.to_json
end
else
format.html do
render action: "edit"
end
format.json do
render json: { success: false }.to_json
end
end
end
end
|