rocketjob_mission_control 6.0.1 → 6.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84a570cf369fd44402e1b75da05885a5497517f294933c9be28d9af18890fc97
4
- data.tar.gz: ae379e606dda477c472cb608094f83d2fae12ce36079a56e1c68c2ec9fd367f9
3
+ metadata.gz: 672b98f43803c00da5285184197598c13e6d68c66e9757f4fe34bde84e0f0949
4
+ data.tar.gz: e1dff7e6033aafdb33c1b326bc7756698cc17bd773c74410c9dca1e1f00f7b1c
5
5
  SHA512:
6
- metadata.gz: 212e74e81c88e9d9209de4fef00181529e35eda6dfed2ba209d3adf2b31647327e37bc6132713878a56459bd14cc85128bad4d390a9ca19491697b5066fa891a
7
- data.tar.gz: 925dad0840748a9a6342ee38f89aae830388696a34405b24726546e3272d92846e24f964ac395cb111e4925490139082795f89fb578feb3e6f7eec27e6aae897
6
+ metadata.gz: 2d13db013b7dbb66845a98eaa4d009c1e30029f0783bb58836d8da48e9a430b24ceb1d27f2fef91e93ac5f1b6312b42e10aeb5ef1520305c01cb9dc01d1454ec
7
+ data.tar.gz: d1ed38f093b515a0e3aba81f45386ee8b4f56290f1da9da882fd9412d6063bc83437e8f147a8c40ee39c00e0418890a208efc592f622546e578cfd2b17284e4d
@@ -289,7 +289,7 @@ module RocketJobMissionControl
289
289
 
290
290
  def job_params
291
291
  params.require(:job).permit(
292
- @job.class.user_editable_fields,
292
+ job_fields,
293
293
  input_categories_attributes: [
294
294
  :id,
295
295
  :name,
@@ -310,6 +310,13 @@ module RocketJobMissionControl
310
310
  )
311
311
  end
312
312
 
313
+ def job_fields
314
+ @job.class.user_editable_fields.collect do |field_name|
315
+ field = @job.class.fields[field_name.to_s]
316
+ field.type.name == "Array" ? {field_name.to_sym => []} : field_name.to_sym
317
+ end
318
+ end
319
+
313
320
  def error_occurred(exception)
314
321
  if defined?(SemanticLogger::Logger) && logger.is_a?(SemanticLogger::Logger)
315
322
  logger.error "Error loading a job", exception
@@ -92,8 +92,8 @@ module RocketJobMissionControl
92
92
  "[JSON Hash]\n".html_safe +
93
93
  f.text_field(field_name, value: value ? value.to_json : "", class: "form-control", placeholder: '{"key1":"value1", "key2":"value2", "key3":"value3"}')
94
94
  when "Array"
95
- options = Array(value)
96
- f.text_field(field_name, {class: "selectize form-control", multiple: true})
95
+ options = value.present? ? Array(value) : []
96
+ f.select(field_name, options_for_select(options, options), {include_hidden: true}, {class: "selectize form-control", multiple: true})
97
97
  else
98
98
  "[#{field.type.name}]".html_safe +
99
99
  f.text_field(field_name, value: value, class: "form-control", placeholder: placeholder)
@@ -34,6 +34,12 @@ module RocketJobMissionControl
34
34
  value = value.blank? ? nil : JSON.parse(value)
35
35
  rescue JSON::ParserError => e
36
36
  target.errors.add(:properties, e.message)
37
+ value = nil
38
+ end
39
+ when "Array"
40
+ # remove blank entries from rails converted arrays when using multi-select input
41
+ if !value.blank?
42
+ value.reject! { |v| v.empty? }
37
43
  end
38
44
  end
39
45
 
@@ -20,7 +20,7 @@
20
20
  </div>
21
21
  </div>
22
22
 
23
- <table class='table datatable active-workers-datatable' data-source='<%= active_workers_url(format: 'json') %>' style='width: 100%'>
23
+ <table class='table datatable active-workers-datatable' data-turbolinks='false' data-source='<%= active_workers_url(format: 'json') %>' style='width: 100%'>
24
24
  <thead>
25
25
  <tr>
26
26
  <th>Worker Name</th>
@@ -0,0 +1,33 @@
1
+ <div class='lead'>Details:</div>
2
+ <div class='row'>
3
+ <div class='col-md-12 job-status'>
4
+ <table>
5
+ <tr>
6
+ <td><label>State:</label></td>
7
+ <td>
8
+ <div class='job-state inline-block'>
9
+ <div class='left'>State</div>
10
+ <div class="<%= @dirmon_entry.state %> right"><%= @dirmon_entry.state %></div>
11
+ </div>
12
+ </td>
13
+ </tr>
14
+ <tr>
15
+ <td><label>Job Class:</label></td>
16
+ <td><%= @dirmon_entry.job_class_name %></td>
17
+ </tr>
18
+ <tr>
19
+ <td><label>Pattern:</label></td>
20
+ <td><%= @dirmon_entry.pattern %></td>
21
+ </tr>
22
+ <tr>
23
+ <td><label>Archive Directory:</label></td>
24
+ <td><%= @dirmon_entry.archive_directory %></td>
25
+ </tr>
26
+ <tr>
27
+ <td><label>ID:</label></td>
28
+ <td><%= @dirmon_entry.id %></td>
29
+ </tr>
30
+ </table>
31
+ </div>
32
+ </div>
33
+ <br/>
@@ -0,0 +1,22 @@
1
+ <div class='lead'>Exception:</div>
2
+ <div class='row'>
3
+ <div class='col-md-12'>
4
+ <table>
5
+ <tr>
6
+ <td><label>Exception:</label></td>
7
+ <td><%= @dirmon_entry.exception.class_name %></td>
8
+ </tr>
9
+ <tr>
10
+ <td><label>Message:</label></td>
11
+ <td><%= @dirmon_entry.exception.message %></td>
12
+ </tr>
13
+ <% if @dirmon_entry.exception.backtrace.present? %>
14
+ <tr>
15
+ <td><label>Backtrace:</label></td>
16
+ <td><%= @dirmon_entry.exception.backtrace.ai(html: true, plain: true) %></td>
17
+ </tr>
18
+ <% end %>
19
+ </table>
20
+ </div>
21
+ </div>
22
+ <br/>
@@ -0,0 +1,28 @@
1
+ <div class='lead'>Properties:</div>
2
+ <div class='row'>
3
+ <div class='col-md-12'>
4
+ <table>
5
+ <% @dirmon_entry.properties.keys.sort.each do |key| %>
6
+ <%
7
+ value = @dirmon_entry.properties[key]
8
+ key = key.to_s.titleize
9
+ %>
10
+ <tr>
11
+ <td><label><%= key %>:</label></td>
12
+ <% if value.nil? %>
13
+ <td><label>nil</label></td>
14
+ <% else %>
15
+ <td>
16
+ <% if value.is_a?(String) %>
17
+ <pre><code><%= simple_format(value) %></code></pre>
18
+ <% else %>
19
+ <%= value.ai(html: true, plain: true) %>
20
+ <% end %>
21
+ </td>
22
+ <% end %>
23
+ </tr>
24
+ <% end %>
25
+ </table>
26
+ </div>
27
+ </div>
28
+ <br/>
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
  </div>
14
14
 
15
- <table class='table datatable dirmon-datatable' data-source='<%= @data_table_url %>' style='width: 100%'>
15
+ <table class='table datatable dirmon-datatable' data-turbolinks='false' data-source='<%= @data_table_url %>' style='width: 100%'>
16
16
  <thead>
17
17
  <tr>
18
18
  <th>Name</th>
@@ -1,43 +1,36 @@
1
- <div class='col-md-12 job-status'>
1
+ <div class='row'>
2
2
  <div id='job'>
3
- <div class='lead'><%= @dirmon_entry.name %></div>
4
-
5
- <div class='job-state inline-block'>
6
- <div class='left'>status</div>
7
- <div class="<%= @dirmon_entry.state %> right"><%= @dirmon_entry.state %></div>
8
- </div>
9
-
10
- <div class='btn-toolbar job-actions'>
11
- <div class='btn-group'>
12
- <% if (@dirmon_entry.disabled? || @dirmon_entry.pending?) && can?(:enable, @dirmon_entry) %>
13
- <%= link_to 'Enable', enable_dirmon_entry_path(@dirmon_entry.id), method: :put, class: 'btn btn-default' %>
14
- <% end %>
15
- <% if @dirmon_entry.enabled? && can?(:disable, @dirmon_entry)%>
16
- <%= link_to 'Disable', disable_dirmon_entry_path(@dirmon_entry.id), method: :put, class: 'btn btn-default', data: { confirm: 'Are you sure?' } %>
17
- <% end %>
18
- </div>
3
+ <div class='lead'><%= image_tag('rocket_job_mission_control/rocket-icon-64x64.png') %><%= @dirmon_entry.name %>
19
4
 
5
+ <div class='btn-toolbar job-actions'>
6
+ <div class='btn-group'>
7
+ <% if @dirmon_entry.may_enable? && can?(:enable, @dirmon_entry) %>
8
+ <%= link_to 'Enable', enable_dirmon_entry_path(@dirmon_entry.id), method: :put, class: 'btn btn-default', data: {confirm: 'Are you sure you want to enable this Dirmon Entry?'} %>
9
+ <% end %>
10
+ <% if @dirmon_entry.may_disable? && can?(:disable, @dirmon_entry) %>
11
+ <%= link_to 'Disable', disable_dirmon_entry_path(@dirmon_entry.id), method: :put, class: 'btn btn-default', data: {confirm: 'Are you sure you want to disable this Dirmon Entry?'} %>
12
+ <% end %>
13
+ </div>
20
14
 
21
- <div class='btn-group'>
22
- <% if can?(:destroy, @dirmon_entry)%>
23
- <%= link_to 'Destroy', dirmon_entry_path(@dirmon_entry), method: :delete, class: 'btn btn-default', data: { confirm: 'Are you sure?' } %>
24
- <% end %>
25
- </div>
26
- <%# It shows the Copy button in each Dirmon%>
27
- <div class='btn-group'>
28
- <% if can?(:copy, @dirmon_entry)%>
29
- <%= link_to 'Copy', copy_dirmon_entry_path(@dirmon_entry), class: 'btn btn-default' %>
30
- <% end %>
31
- </div>
32
- <div class='btn-group'>
33
- <% if can?(:edit, @dirmon_entry)%>
34
- <%= link_to 'Edit', edit_dirmon_entry_path(@dirmon_entry), class: 'btn btn-default' %>
35
- <% end %>
15
+ <div class='btn-group'>
16
+ <% if can?(:destroy, @dirmon_entry) %>
17
+ <%= link_to 'Destroy', dirmon_entry_path(@dirmon_entry), method: :delete, class: 'btn btn-default', data: {confirm: 'Are you sure?'} %>
18
+ <% end %>
19
+ </div>
20
+ <div class='btn-group'>
21
+ <% if can?(:copy, @dirmon_entry) %>
22
+ <%= link_to 'Copy', copy_dirmon_entry_path(@dirmon_entry), class: 'btn btn-default' %>
23
+ <% end %>
24
+ </div>
25
+ <div class='btn-group'>
26
+ <% if can?(:edit, @dirmon_entry) %>
27
+ <%= link_to 'Edit', edit_dirmon_entry_path(@dirmon_entry), class: 'btn btn-default' %>
28
+ <% end %>
29
+ </div>
36
30
  </div>
37
31
  </div>
38
-
39
- <div class='clearfix'></div>
40
-
41
- <%= render partial: 'status', locals: {dirmon_entry: @job} %>
42
32
  </div>
43
33
  </div>
34
+ <%= render partial: 'details', locals: {dirmon_entry: @dirmon_entry} %>
35
+ <%= render partial: 'properties', locals: {dirmon_entry: @dirmon_entry} %>
36
+ <%= render partial: 'exception', locals: {dirmon_entry: @dirmon_entry} if @dirmon_entry.exception %>
@@ -1,4 +1,4 @@
1
- <table class='table datatable jobs-datatable' data-source='<%= jobs_url(format: 'json') %>' style='width: 100%'>
1
+ <table class='table datatable jobs-datatable' data-turbolinks='false' data-source='<%= jobs_url(format: 'json') %>' style='width: 100%'>
2
2
  <thead>
3
3
  <tr>
4
4
  <th>Count</th>
@@ -16,7 +16,7 @@
16
16
  </div>
17
17
 
18
18
  <div class="panel-body">
19
- <table class='table datatable jobs-datatable' data-source='<%= @data_table_url %>' style='width: 100%'>
19
+ <table class='table datatable jobs-datatable' data-turbolinks='false' data-source='<%= @data_table_url %>' style='width: 100%'>
20
20
  <thead>
21
21
  <tr>
22
22
  <% @columns.each do |column| %>
@@ -35,7 +35,7 @@
35
35
  </div>
36
36
  </div>
37
37
 
38
- <table class='table datatable servers-datatable' data-source='<%= @data_table_url %>' style='width: 100%'>
38
+ <table class='table datatable servers-datatable' data-turbolinks='false' data-source='<%= @data_table_url %>' style='width: 100%'>
39
39
  <thead>
40
40
  <tr>
41
41
  <th>Hostname : PID</th>
@@ -1,3 +1,3 @@
1
1
  module RocketJobMissionControl
2
- VERSION = "6.0.1".freeze
2
+ VERSION = "6.0.5".freeze
3
3
  end
@@ -15,9 +15,9 @@ module RocketJobMissionControl
15
15
 
16
16
  let :existing_dirmon_entry do
17
17
  RocketJob::DirmonEntry.create!(
18
- name: "Test",
18
+ name: "Existing path test",
19
19
  job_class_name: job_class_name,
20
- pattern: "the_path"
20
+ pattern: "existing_path"
21
21
  )
22
22
  end
23
23
 
@@ -26,9 +26,9 @@ module RocketJobMissionControl
26
26
  let :one_dirmon_entry_for_every_state do
27
27
  dirmon_entry_states.collect do |state|
28
28
  RocketJob::DirmonEntry.create!(
29
- name: "Test",
29
+ name: "Test_for_state_#{state}",
30
30
  job_class_name: job_class_name,
31
- pattern: "the_path",
31
+ pattern: "path_for_state_#{state}",
32
32
  state: state
33
33
  )
34
34
  end
@@ -375,27 +375,27 @@ module RocketJobMissionControl
375
375
  json = JSON.parse(response.body)
376
376
  expected_data = {
377
377
  pending: {
378
- "0" => " <a href=\"/dirmon_entries/#{RocketJob::DirmonEntry.pending.first.id}\">\n <i class=\"fas fa-inbox pending\" style=\"font-size: 75%\" title=\"pending\"></i>\n Test\n </a>\n",
378
+ "0" => " <a href=\"/dirmon_entries/#{RocketJob::DirmonEntry.pending.first.id}\">\n <i class=\"fas fa-inbox pending\" style=\"font-size: 75%\" title=\"pending\"></i>\n Test_for_state_pending\n </a>\n",
379
379
  "1" => "RocketJob::Jobs::SimpleJob",
380
- "2" => "the_path",
380
+ "2" => "path_for_state_pending",
381
381
  "DT_RowClass" => "card callout callout-pending"
382
382
  },
383
383
  enabled: {
384
- "0" => " <a href=\"/dirmon_entries/#{RocketJob::DirmonEntry.enabled.first.id}\">\n <i class=\"fas fa-check enabled\" style=\"font-size: 75%\" title=\"enabled\"></i>\n Test\n </a>\n",
384
+ "0" => " <a href=\"/dirmon_entries/#{RocketJob::DirmonEntry.enabled.first.id}\">\n <i class=\"fas fa-check enabled\" style=\"font-size: 75%\" title=\"enabled\"></i>\n Test_for_state_enabled\n </a>\n",
385
385
  "1" => "RocketJob::Jobs::SimpleJob",
386
- "2" => "the_path",
386
+ "2" => "path_for_state_enabled",
387
387
  "DT_RowClass" => "card callout callout-enabled"
388
388
  },
389
389
  failed: {
390
- "0" => " <a href=\"/dirmon_entries/#{RocketJob::DirmonEntry.failed.first.id}\">\n <i class=\"fas fa-exclamation-triangle failed\" style=\"font-size: 75%\" title=\"failed\"></i>\n Test\n </a>\n",
390
+ "0" => " <a href=\"/dirmon_entries/#{RocketJob::DirmonEntry.failed.first.id}\">\n <i class=\"fas fa-exclamation-triangle failed\" style=\"font-size: 75%\" title=\"failed\"></i>\n Test_for_state_failed\n </a>\n",
391
391
  "1" => "RocketJob::Jobs::SimpleJob",
392
- "2" => "the_path",
392
+ "2" => "path_for_state_failed",
393
393
  "DT_RowClass" => "card callout callout-failed"
394
394
  },
395
395
  disabled: {
396
- "0" => " <a href=\"/dirmon_entries/#{RocketJob::DirmonEntry.disabled.first.id}\">\n <i class=\"fas fa-stop disabled\" style=\"font-size: 75%\" title=\"disabled\"></i>\n Test\n </a>\n",
396
+ "0" => " <a href=\"/dirmon_entries/#{RocketJob::DirmonEntry.disabled.first.id}\">\n <i class=\"fas fa-stop disabled\" style=\"font-size: 75%\" title=\"disabled\"></i>\n Test_for_state_disabled\n </a>\n",
397
397
  "1" => "RocketJob::Jobs::SimpleJob",
398
- "2" => "the_path",
398
+ "2" => "path_for_state_disabled",
399
399
  "DT_RowClass" => "card callout callout-disabled"
400
400
  }
401
401
  }
@@ -404,7 +404,7 @@ module RocketJobMissionControl
404
404
  assert_equal 0, json["draw"]
405
405
  assert_equal 4, json["recordsTotal"]
406
406
  assert_equal 4, json["recordsFiltered"]
407
- assert_equal [expected_data[:pending], expected_data[:enabled], expected_data[:failed], expected_data[:disabled]], json["data"]
407
+ assert_equal [expected_data[:disabled], expected_data[:enabled], expected_data[:failed], expected_data[:pending]], json["data"]
408
408
  else
409
409
  assert_equal 0, json["draw"]
410
410
  assert_equal 1, json["recordsTotal"]
@@ -81,7 +81,7 @@ class JobSanitizerTest < Minitest::Test
81
81
  assert_equal error.first, :properties
82
82
  assert error.second.include?("unexpected token"), error
83
83
  end
84
- assert_equal({hash_field: "{ bad json }", string: "hello"}, cleansed)
84
+ assert_equal({string: "hello"}, cleansed)
85
85
  end
86
86
 
87
87
  it "Keeps empty JSON Hash" do
@@ -92,6 +92,15 @@ class JobSanitizerTest < Minitest::Test
92
92
  assert_equal 0, @job.errors.count
93
93
  assert_equal({hash_field: {}}, cleansed)
94
94
  end
95
+
96
+ it "removes blank entries from rails converted arrays when using multi-select input" do
97
+ properties = {
98
+ array: ["", "rf@exp.com", "rm@exp.com", "lb@exp.com"]
99
+ }
100
+ cleansed = RocketJobMissionControl::JobSanitizer.sanitize(properties, @job.class, @job, false)
101
+ assert_equal 0, @job.errors.count
102
+ assert_equal({array: ["rf@exp.com", "rm@exp.com", "lb@exp.com"]}, cleansed)
103
+ end
95
104
  end
96
105
  end
97
106
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocketjob_mission_control
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 6.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Cloutier
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-09-20 00:00:00.000000000 Z
14
+ date: 2021-11-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: access-granted
@@ -166,13 +166,15 @@ files:
166
166
  - app/views/layouts/rocket_job_mission_control/partials/_header.html.erb
167
167
  - app/views/layouts/rocket_job_mission_control/partials/_sidebar.html.erb
168
168
  - app/views/rocket_job_mission_control/active_workers/index.html.erb
169
+ - app/views/rocket_job_mission_control/dirmon_entries/_details.html.erb
170
+ - app/views/rocket_job_mission_control/dirmon_entries/_exception.html.erb
169
171
  - app/views/rocket_job_mission_control/dirmon_entries/_form.html.erb
170
172
  - app/views/rocket_job_mission_control/dirmon_entries/_input_categories.html.erb
171
173
  - app/views/rocket_job_mission_control/dirmon_entries/_input_category_fields.html.erb
172
174
  - app/views/rocket_job_mission_control/dirmon_entries/_output_categories.html.erb
173
175
  - app/views/rocket_job_mission_control/dirmon_entries/_output_category_fields.html.erb
176
+ - app/views/rocket_job_mission_control/dirmon_entries/_properties.html.erb
174
177
  - app/views/rocket_job_mission_control/dirmon_entries/_sidebar.html.erb
175
- - app/views/rocket_job_mission_control/dirmon_entries/_status.html.erb
176
178
  - app/views/rocket_job_mission_control/dirmon_entries/copy.html.erb
177
179
  - app/views/rocket_job_mission_control/dirmon_entries/edit.html.erb
178
180
  - app/views/rocket_job_mission_control/dirmon_entries/index.html.erb
@@ -1,26 +0,0 @@
1
- <div class='row'>
2
- <div class='col-md-12'>
3
- <div><label>Job Class:</label><%= @dirmon_entry.job_class_name %></div>
4
- <div><label>Pattern:</label><%= @dirmon_entry.pattern %></div>
5
- <div><label>Archive Directory:</label><%= @dirmon_entry.archive_directory %></div>
6
- <div class='id'><label>ID:</label><%= @dirmon_entry.id %></div>
7
- </div>
8
- </div>
9
-
10
- <div class='lead'>Properties</div>
11
- <div class='row'>
12
- <div class='col-md-12'>
13
- <% @dirmon_entry.properties.keys.sort.each do |name| %>
14
- <% value = @dirmon_entry.properties[name] %>
15
- <div class='parameters'>
16
- <label><%= name.to_s.titleize %>:</label>
17
-
18
- <% if value.is_a?(Array) || value.is_a?(Hash) %>
19
- <pre><code><%= pretty_print_array_or_hash(value) %></code></pre>
20
- <% else %>
21
- <%= value %>
22
- <% end %>
23
- </div>
24
- <% end %>
25
- </div>
26
- </div>