rocketjob_mission_control 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/rocket_job_mission_control/application.js +1 -0
- data/app/assets/javascripts/rocket_job_mission_control/dirmon_entries.js.coffee +5 -8
- data/app/assets/javascripts/rocket_job_mission_control/selectize.js.coffee +5 -0
- data/app/assets/stylesheets/rocket_job_mission_control/application.scss +2 -0
- data/app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb +58 -9
- data/app/controllers/rocket_job_mission_control/jobs_controller.rb +5 -1
- data/app/models/job_failures.rb +3 -0
- data/app/views/rocket_job_mission_control/dirmon_entries/_form.html.haml +13 -16
- data/app/views/rocket_job_mission_control/dirmon_entries/_properties.html.haml +38 -8
- data/app/views/rocket_job_mission_control/dirmon_entries/_status.html.haml +13 -8
- data/app/views/rocket_job_mission_control/jobs/running.html.haml +1 -2
- data/app/views/rocket_job_mission_control/jobs/show.html.haml +1 -1
- data/lib/rocket_job_mission_control/engine.rb +1 -0
- data/lib/rocket_job_mission_control/version.rb +1 -1
- data/spec/controllers/dirmon_entries_controller_spec.rb +90 -65
- data/spec/dummy/log/development.log +2 -0
- data/spec/dummy/log/test.log +12275 -0
- data/spec/rails_helper.rb +2 -2
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77e3e2d84930ed4d9f4f02099057948af722ee7c
|
4
|
+
data.tar.gz: 6ff14b67a5c4855d0c66d41d684a633f3a94c6d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18bc9dfc4e06fdd0f0a1d4b49ce6a9bfbb130c8e38402bdc8f124f3e322e7fb94dd240a46e3b6a286e067d69c393d7e71abcfca62fcac49839798b670d5dbd19
|
7
|
+
data.tar.gz: f50ac9b5b4dea01e2bbe28b21586970e981e5a69e52bc6c381af54f78d945e21ac8dcf30236136e47b69a432666026523fa29d38f91b38a1fa4595204e309db4
|
@@ -7,12 +7,9 @@ $(document).on 'ready', ->
|
|
7
7
|
window.location.href = window.location.href.replace( /[\?#].*|$/, param_string );
|
8
8
|
|
9
9
|
if $('#properties').length
|
10
|
-
$('#
|
11
|
-
$(
|
12
|
-
$('#
|
13
|
-
$('#properties').
|
14
|
-
|
15
|
-
$(this).hide()
|
16
|
-
$('#expand').show()
|
17
|
-
$('#properties').hide()
|
10
|
+
$('#properties').on 'click', ->
|
11
|
+
job_class_name = $('#rocket_job_dirmon_entry_job_class_name').val()
|
12
|
+
perform_method = $('#rocket_job_dirmon_entry_perform_method').val()
|
13
|
+
new_dirmon_path = $('#properties').data('url') + "?job_class_name=#{job_class_name}&perform_method=#{perform_method}"
|
14
|
+
window.location = new_dirmon_path
|
18
15
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'csv'
|
1
2
|
module RocketJobMissionControl
|
2
3
|
class DirmonEntriesController < RocketJobMissionControl::ApplicationController
|
3
4
|
before_filter :find_entry_or_redirect, except: [:index, :new, :create]
|
@@ -11,13 +12,21 @@ module RocketJobMissionControl
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def new
|
14
|
-
|
15
|
+
job_class_name = params[:job_class_name]
|
16
|
+
perform_method = params[:perform_method] || :perform
|
17
|
+
@dirmon_entry = RocketJob::DirmonEntry.new(arguments: nil, job_class_name: job_class_name, perform: perform_method)
|
18
|
+
@previous_job_class_names = RocketJob::DirmonEntry.distinct(:job_class_name)
|
19
|
+
|
20
|
+
if job_class_name && !@dirmon_entry.job_class
|
21
|
+
@dirmon_entry.errors.add(:job_class_name, 'Invalid Job Class')
|
22
|
+
end
|
15
23
|
end
|
16
24
|
|
17
25
|
def create
|
18
26
|
@dirmon_entry = RocketJob::DirmonEntry.new(dirmon_params)
|
19
27
|
|
20
28
|
parse_and_assign_arguments
|
29
|
+
parse_and_assign_properties
|
21
30
|
|
22
31
|
if @dirmon_entry.errors.empty? && @dirmon_entry.save
|
23
32
|
flash[:success] = t(:success, scope: [:dirmon_entry, :create])
|
@@ -39,8 +48,10 @@ module RocketJobMissionControl
|
|
39
48
|
end
|
40
49
|
|
41
50
|
def update
|
51
|
+
@dirmon_entry.attributes = dirmon_params
|
42
52
|
parse_and_assign_arguments
|
43
|
-
|
53
|
+
parse_and_assign_properties
|
54
|
+
if @dirmon_entry.errors.empty? && @dirmon_entry.save
|
44
55
|
flash[:success] = t(:success, scope: [:dirmon_entry, :update])
|
45
56
|
redirect_to(rocket_job_mission_control.dirmon_entry_path(@dirmon_entry))
|
46
57
|
else
|
@@ -55,7 +66,7 @@ module RocketJobMissionControl
|
|
55
66
|
flash[:success] = t(:success, scope: [:dirmon_entry, :enable])
|
56
67
|
redirect_to(rocket_job_mission_control.dirmon_entry_path(@dirmon_entry))
|
57
68
|
else
|
58
|
-
flash[:alert]
|
69
|
+
flash[:alert] = t(:failure, scope: [:dirmon_entry, :enable])
|
59
70
|
load_entries
|
60
71
|
render(:show)
|
61
72
|
end
|
@@ -67,22 +78,60 @@ module RocketJobMissionControl
|
|
67
78
|
flash[:success] = t(:success, scope: [:dirmon_entry, :disable])
|
68
79
|
redirect_to(rocket_job_mission_control.dirmon_entry_path(@dirmon_entry))
|
69
80
|
else
|
70
|
-
flash[:alert]
|
81
|
+
flash[:alert] = t(:failure, scope: [:dirmon_entry, :disable])
|
71
82
|
load_entries
|
72
83
|
render(:show)
|
73
84
|
end
|
74
85
|
end
|
75
86
|
|
87
|
+
def properties
|
88
|
+
@dirmon_entry = RocketJob::DirmonEntry.new(dirmon_params)
|
89
|
+
render json: @dirmon_entry
|
90
|
+
end
|
91
|
+
|
76
92
|
private
|
77
93
|
|
78
94
|
def parse_and_assign_arguments
|
79
|
-
arguments
|
80
|
-
arguments = arguments.
|
95
|
+
arguments = params[:rocket_job_dirmon_entry][:arguments] || []
|
96
|
+
@dirmon_entry.arguments = arguments.collect do |value|
|
97
|
+
cleansed = parse_array_element(value, :arguments, true)
|
98
|
+
@dirmon_entry.errors.add(:arguments, 'All arguments are mandatory') unless cleansed
|
99
|
+
cleansed
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def parse_and_assign_properties
|
104
|
+
properties = params[:rocket_job_dirmon_entry].fetch(:properties, {})
|
105
|
+
properties.each_pair do |property, value|
|
106
|
+
if key = @dirmon_entry.job_class.keys[property]
|
107
|
+
if key.type == Hash
|
108
|
+
begin
|
109
|
+
@dirmon_entry.properties[property] = JSON.parse(value)
|
110
|
+
rescue JSON::ParserError => e
|
111
|
+
@dirmon_entry.errors.add(:properties, e.message)
|
112
|
+
end
|
113
|
+
else
|
114
|
+
@dirmon_entry.properties[property] = value
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Returns [Array<String>] an array from the supplied string
|
121
|
+
# String can also be in JSON format
|
122
|
+
def parse_array_element(value, attribute, could_be_singleton = false)
|
123
|
+
return if value.blank?
|
81
124
|
begin
|
82
|
-
|
83
|
-
@dirmon_entry.arguments = arguments.kind_of?(Array) ? arguments : [arguments]
|
125
|
+
JSON.parse(value)
|
84
126
|
rescue JSON::ParserError => e
|
85
|
-
|
127
|
+
begin
|
128
|
+
values = CSV.parse(value).first.collect { |col| JSON.parse("[#{col.to_s.strip}]").first }
|
129
|
+
could_be_singleton && (values.size == 1) ? values.first : values
|
130
|
+
rescue Exception => exc
|
131
|
+
@dirmon_entry.errors.add(attribute, e.message)
|
132
|
+
@dirmon_entry.errors.add(attribute, exc.message)
|
133
|
+
value
|
134
|
+
end
|
86
135
|
end
|
87
136
|
end
|
88
137
|
|
@@ -88,7 +88,11 @@ module RocketJobMissionControl
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def error_occurred(exception)
|
91
|
-
|
91
|
+
if defined?(SemanticLogger::Logger) && logger.is_a?(SemanticLogger::Logger)
|
92
|
+
logger.error 'Error loading a job', exception
|
93
|
+
else
|
94
|
+
logger.error "Error loading a job. #{log.exception.class}: #{log.exception.message}\n#{(log.exception.backtrace || []).join("\n")}"
|
95
|
+
end
|
92
96
|
flash[:danger] = 'Error loading jobs.'
|
93
97
|
raise exception if Rails.env.development?
|
94
98
|
redirect_to :back
|
data/app/models/job_failures.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
- action ||= :create
|
2
2
|
- if @dirmon_entry.errors.present?
|
3
3
|
.alert.alert-alert
|
4
|
-
|
4
|
+
Invalid Dirmon entry!
|
5
5
|
- @dirmon_entry.errors.messages.each_pair do |field, message|
|
6
6
|
.message
|
7
7
|
= "#{field}: #{message}"
|
@@ -12,28 +12,25 @@
|
|
12
12
|
.path.form-group
|
13
13
|
= f.label :pattern
|
14
14
|
= f.text_field :pattern, class: 'form-control'
|
15
|
-
.path.form-group
|
16
|
-
= f.label :archive_directory
|
17
|
-
= f.text_field :archive_directory, class: 'form-control'
|
18
15
|
.job.form-group
|
19
16
|
= f.label :job_class_name
|
20
|
-
= f.text_field :job_class_name, class: 'form-control'
|
17
|
+
= f.text_field :job_class_name, class: 'form-control', disabled: action != :create
|
21
18
|
.job.form-group
|
22
19
|
= f.label :perform_method
|
23
|
-
= f.text_field :perform_method, class: 'form-control'
|
24
|
-
.
|
25
|
-
= f.label :
|
26
|
-
= f.
|
27
|
-
value: @dirmon_entry.arguments.empty? ? nil : @dirmon_entry.arguments.to_json,
|
28
|
-
rows: 10,
|
29
|
-
placeholder: '{"argument1"":"value1", "argument2":"value2", "argument3":"value3"}',
|
30
|
-
class: 'form-control'
|
20
|
+
= f.text_field :perform_method, class: 'form-control', disabled: action != :create
|
21
|
+
.path.form-group
|
22
|
+
= f.label :archive_directory
|
23
|
+
= f.text_field :archive_directory, class: 'form-control'
|
31
24
|
.row
|
32
|
-
.col-md-12
|
25
|
+
.col-md-12
|
33
26
|
= render partial: 'properties', locals: { f: f }
|
34
27
|
|
35
28
|
.buttons
|
36
29
|
= f.submit action, class: 'btn btn-primary'
|
37
30
|
= link_to 'cancel', :back, class: 'btn btn-default'
|
38
|
-
|
39
|
-
|
31
|
+
- if action == :create
|
32
|
+
= button_tag 'properties',
|
33
|
+
type: 'button',
|
34
|
+
class: 'btn btn-default',
|
35
|
+
id: 'properties',
|
36
|
+
data: { url: rocket_job_mission_control.new_dirmon_entry_path }
|
@@ -1,8 +1,38 @@
|
|
1
|
-
.
|
2
|
-
|
3
|
-
.form-group
|
4
|
-
=
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
- if @dirmon_entry.job_class
|
2
|
+
.arguments
|
3
|
+
.job_arguments.form-group
|
4
|
+
- count = @dirmon_entry.job_class.argument_count(@dirmon_entry.perform_method)
|
5
|
+
- count.times do |counter|
|
6
|
+
- argument = @dirmon_entry.arguments[counter]
|
7
|
+
= f.label "Argument #{counter + 1}:"
|
8
|
+
= f.text_field :arguments,
|
9
|
+
value: argument.is_a?(Hash) || argument.is_a?(Array) ? argument.to_json : argument,
|
10
|
+
name: 'rocket_job_dirmon_entry[arguments][]',
|
11
|
+
rows: 10,
|
12
|
+
placeholder: '{"argument1":"value1", "argument2":"value2", "argument3":"value3"}',
|
13
|
+
class: 'form-control'
|
14
|
+
= f.fields_for :properties do |properties|
|
15
|
+
- @dirmon_entry.job_class.rocket_job_properties.each do |property_name|
|
16
|
+
- next if [:arguments, :perform_method].include?(property_name)
|
17
|
+
- key = @dirmon_entry.job_class.keys[property_name.to_s]
|
18
|
+
- next unless key
|
19
|
+
- placeholder = key.default? ? key.default : nil
|
20
|
+
.form-group
|
21
|
+
= properties.label property_name.to_s
|
22
|
+
- case key.type.name
|
23
|
+
- when 'Integer'
|
24
|
+
= properties.number_field property_name, value: @dirmon_entry.properties[property_name], class: 'form-control', placeholder: placeholder
|
25
|
+
- when 'Array'
|
26
|
+
- options = Array(@dirmon_entry.properties[property_name])
|
27
|
+
= properties.select property_name, options_for_select(options, options), {include_hidden: false}, {class: 'selectize', multiple: true}
|
28
|
+
- when 'Boolean'
|
29
|
+
- name = "#{property_name}_true".to_sym
|
30
|
+
.radio-buttons
|
31
|
+
= properties.label name, 'true'
|
32
|
+
= properties.radio_button(property_name, 'true', checked: @dirmon_entry.properties[property_name] == 'true')
|
33
|
+
= properties.label name, 'false'
|
34
|
+
= properties.radio_button(property_name, 'false', checked: @dirmon_entry.properties[property_name] == 'false')
|
35
|
+
= properties.label name, 'none'
|
36
|
+
= properties.radio_button(property_name, '', checked: @dirmon_entry.properties[property_name].blank?)
|
37
|
+
- else
|
38
|
+
= properties.text_field property_name, value: @dirmon_entry.properties[property_name], class: 'form-control', placeholder: placeholder
|
@@ -13,14 +13,19 @@
|
|
13
13
|
%div
|
14
14
|
%label Archive Directory:
|
15
15
|
= @dirmon_entry.archive_directory
|
16
|
-
.
|
17
|
-
|
18
|
-
|
19
|
-
%
|
20
|
-
.
|
21
|
-
|
22
|
-
|
23
|
-
%
|
16
|
+
-if @dirmon_entry.arguments.size > 0
|
17
|
+
.parameters
|
18
|
+
%label Arguments:
|
19
|
+
%pre
|
20
|
+
%code= pretty_print_array_or_hash(@dirmon_entry.arguments)
|
21
|
+
- @dirmon_entry.properties.each_pair do |name, value|
|
22
|
+
.parameters
|
23
|
+
%label= "#{name.to_s.titleize}:"
|
24
|
+
- if value.is_a?(Array) || value.is_a?(Hash)
|
25
|
+
%pre
|
26
|
+
%code= pretty_print_array_or_hash(value)
|
27
|
+
- else
|
28
|
+
= value
|
24
29
|
.id
|
25
30
|
%label ID:
|
26
31
|
= @dirmon_entry.id
|
@@ -17,8 +17,7 @@
|
|
17
17
|
- if job.kind_of?(RocketJob::SlicedJob)
|
18
18
|
.slice_count
|
19
19
|
%label Slices Running:
|
20
|
-
|
21
|
-
= job.input.collection.aggregate([{ '$match' => { state: 'queued' } },{ '$group' => { _id: nil, count: { '$sum' => 1 } } }] )
|
20
|
+
= job.input.find_all { |s| s.state == :running }.count
|
22
21
|
- else
|
23
22
|
.worker
|
24
23
|
%label Worker:
|
@@ -46,7 +46,7 @@
|
|
46
46
|
- if valid_events.include?(:retry)
|
47
47
|
= job_action_link('retry', rocket_job_mission_control.retry_job_path(@job), :patch)
|
48
48
|
|
49
|
-
- if @job.failed? && @job.kind_of?(RocketJob::SlicedJob)
|
49
|
+
- if @job.failed? && @job.kind_of?(RocketJob::SlicedJob) && @job.input.failed_count > 0
|
50
50
|
= link_to("view errors", job_failures_path(@job), class: 'btn btn-default')
|
51
51
|
|
52
52
|
.clearfix
|