rocketjob_mission_control 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/rocket_job_mission_control/datatable.js.coffee +2 -0
  3. data/app/assets/stylesheets/rocket_job_mission_control/base.scss +19 -7
  4. data/app/controllers/rocket_job_mission_control/dirmon_entries_controller.rb +1 -3
  5. data/app/controllers/rocket_job_mission_control/jobs/index_filters_controller.rb +7 -7
  6. data/app/controllers/rocket_job_mission_control/jobs_controller.rb +1 -0
  7. data/app/datatables/rocket_job_mission_control/jobs_datatable.rb +4 -2
  8. data/app/datatables/rocket_job_mission_control/workers_datatable.rb +1 -1
  9. data/app/interactors/rocket_job_mission_control/dirmon_entries/search.rb +1 -1
  10. data/app/interactors/rocket_job_mission_control/jobs/search.rb +1 -1
  11. data/app/interactors/rocket_job_mission_control/workers/search.rb +1 -1
  12. data/app/models/job_sanitizer.rb +17 -0
  13. data/app/views/layouts/rocket_job_mission_control/application.html.haml +1 -1
  14. data/app/views/layouts/rocket_job_mission_control/partials/_header.html.haml +1 -1
  15. data/app/views/rocket_job_mission_control/jobs/edit.html.haml +5 -5
  16. data/app/views/rocket_job_mission_control/jobs/show.html.haml +4 -3
  17. data/app/views/rocket_job_mission_control/workers/index.html.haml +1 -1
  18. data/app/views/rocket_job_mission_control/workers/index_filters/paused.html.haml +2 -2
  19. data/app/views/rocket_job_mission_control/workers/index_filters/running.html.haml +2 -2
  20. data/app/views/rocket_job_mission_control/workers/index_filters/starting.html.haml +2 -2
  21. data/app/views/rocket_job_mission_control/workers/index_filters/stopping.html.haml +2 -2
  22. data/config/locales/en.yml +10 -10
  23. data/lib/rocket_job_mission_control/version.rb +1 -1
  24. data/spec/controllers/dirmon_entries/index_filters_controller_spec.rb +15 -10
  25. data/spec/controllers/jobs/index_filters_controller_spec.rb +2 -1
  26. data/spec/controllers/jobs_controller_spec.rb +8 -1
  27. data/spec/controllers/workers/index_filters_controller_spec.rb +1 -1
  28. data/spec/dummy/Rakefile +2 -1
  29. data/spec/dummy/config.ru +1 -1
  30. data/spec/dummy/config/application.rb +4 -3
  31. data/spec/dummy/config/environment.rb +3 -3
  32. data/spec/dummy/config/environments/test.rb +20 -22
  33. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  34. data/spec/dummy/config/routes.rb +2 -3
  35. data/spec/dummy/{public/favicon.ico → db/test.sqlite3} +0 -0
  36. data/spec/dummy/log/development.log +0 -0
  37. data/spec/dummy/log/test.log +29861 -2625
  38. data/spec/interactors/jobs/search_spec.rb +35 -0
  39. data/spec/models/job_sanitizer_spec.rb +16 -0
  40. data/spec/rails_helper.rb +1 -3
  41. metadata +13 -44
  42. data/spec/dummy/README.rdoc +0 -28
  43. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  44. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  45. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  46. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  47. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  48. data/spec/dummy/bin/bundle +0 -3
  49. data/spec/dummy/bin/rails +0 -4
  50. data/spec/dummy/bin/rake +0 -4
  51. data/spec/dummy/config/environments/development.rb +0 -34
  52. data/spec/dummy/config/initializers/assets.rb +0 -8
  53. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  54. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  55. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  56. data/spec/dummy/config/initializers/inflections.rb +0 -16
  57. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  58. data/spec/dummy/config/locales/en.yml +0 -23
  59. data/spec/dummy/public/404.html +0 -67
  60. data/spec/dummy/public/422.html +0 -67
  61. data/spec/dummy/public/500.html +0 -66
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffb6fd358569ee47288a00a2f5d909bc37ffb7fe
4
- data.tar.gz: 20914808b3f576db0c45b607e72cb1998bad3327
3
+ metadata.gz: 7962e3b8e27b8b98e946fedd53bfba833a92769f
4
+ data.tar.gz: 6bf9aa56d4c51a47c459b0f13c33c604161f3b1a
5
5
  SHA512:
6
- metadata.gz: cc99088dbcaff508741d44553f8003c3c471030925219d7c38cf647e62d76a67c491e4f3adc195a1cd0ba89af34c0b9804b0b090bd0d1036ce97a21a2a8efd10
7
- data.tar.gz: e9f4f0278190e8fb8f6d0cbe567e305ac7a3b6363a45b3a7671f3f562bbee998ca6cfa4366df2ce43cf75995011240c15928ff82758f6a26158e3ccd73d0677e
6
+ metadata.gz: fba1711a8c000adf050fe6dbf840c7aaa70ae189276696bc41edc615280572f7019242633d6b46d99d8e6a95f4c01ebc483b717bf793cac4bde91166ac49f405
7
+ data.tar.gz: a1f334a2c43f79a67b0b3b98c417957518ac862107b02287c129577fbb31173195ece72303fb78e8678e56b6f468d82ad0c624a7e6a6b8159a6a5796e0753f52
@@ -4,6 +4,7 @@ class @RjmcDatatable
4
4
  @columns = columns
5
5
  @ordering = opts.ordering ? true
6
6
  @searching = opts.searching ? true
7
+ @pageLength = opts.pageLength ? 100
7
8
  @order = opts.order ? []
8
9
  @reload = $("[data-behavior='reload']")
9
10
  @initializeTable()
@@ -12,6 +13,7 @@ class @RjmcDatatable
12
13
  initializeTable: ->
13
14
  @data = @table.DataTable
14
15
  pagingType: 'full_numbers'
16
+ pageLength: @pageLength
15
17
  responsive: true
16
18
  ajax: @table.data('source')
17
19
  processing: true
@@ -31,17 +31,29 @@ table.datatable {
31
31
  margin: 1em 0;
32
32
  }
33
33
 
34
+ table.dataTable thead .sorting:after {
35
+ content: "\f0c9";
36
+ }
37
+
34
38
  table.dataTable thead .sorting_asc:after {
35
- content: "\e155";
39
+ content: "\f160";
40
+ }
41
+
42
+ table.dataTable thead .sorting_desc:after {
43
+ content: "\f161";
36
44
  }
37
45
 
38
46
  table.dataTable thead .sorting:after, table.dataTable thead .sorting_asc:after, table.dataTable thead .sorting_desc:after {
39
- position: absolute;
40
- top: 8px;
41
- left: 8px;
42
- display: block;
43
- font-family: 'Glyphicons Halflings';
44
- opacity: 0.5;
47
+ position: absolute;
48
+ top: 8px;
49
+ left: 8px;
50
+ display: block;
51
+ // display: inline-block;
52
+ font: normal normal normal 14px/1 FontAwesome;
53
+ font-size: inherit;
54
+ text-rendering: auto;
55
+ -webkit-font-smoothing: antialiased;
56
+ -moz-osx-font-smoothing: grayscale;
45
57
  }
46
58
 
47
59
  table.dataTable thead > tr > th {
@@ -161,9 +161,7 @@ module RocketJobMissionControl
161
161
  def dirmon_params
162
162
  params
163
163
  .fetch(:rocket_job_dirmon_entry, {})
164
- .permit(:name, :archive_directory, :pattern, :job_class_name).tap do |whitelist|
165
- whitelist[:properties] = params[:rocket_job_dirmon_entry][:properties] if params.fetch(:rocket_job_dirmon_entry, {})[:properties]
166
- end
164
+ .permit(:name, :archive_directory, :pattern, :job_class_name)
167
165
  end
168
166
  end
169
167
  end
@@ -4,7 +4,7 @@ module RocketJobMissionControl
4
4
  before_filter :show_sidebar
5
5
 
6
6
  def running
7
- @jobs = RocketJob::Job.where(state: :running).sort(_id: :desc)
7
+ @jobs = RocketJob::Job.where(state: :running).sort(started_at: :desc)
8
8
  respond_to do |format|
9
9
  format.html
10
10
  format.json { render(json: RunningJobsDatatable.new(view_context, @jobs)) }
@@ -12,7 +12,7 @@ module RocketJobMissionControl
12
12
  end
13
13
 
14
14
  def paused
15
- @jobs = RocketJob::Job.where(state: :paused).sort(_id: :desc)
15
+ @jobs = RocketJob::Job.where(state: :paused).sort(completed_at: :desc)
16
16
  respond_to do |format|
17
17
  format.html
18
18
  format.json { render(json: InterruptedJobsDatatable.new(view_context, @jobs)) }
@@ -20,7 +20,7 @@ module RocketJobMissionControl
20
20
  end
21
21
 
22
22
  def completed
23
- @jobs = RocketJob::Job.where(state: :completed).sort(_id: :desc)
23
+ @jobs = RocketJob::Job.where(state: :completed).sort(completed_at: :desc)
24
24
  respond_to do |format|
25
25
  format.html
26
26
  format.json { render(json: CompletedJobsDatatable.new(view_context, @jobs)) }
@@ -28,7 +28,7 @@ module RocketJobMissionControl
28
28
  end
29
29
 
30
30
  def aborted
31
- @jobs = RocketJob::Job.where(state: :aborted).sort(_id: :desc)
31
+ @jobs = RocketJob::Job.where(state: :aborted).sort(completed_at: :desc)
32
32
  respond_to do |format|
33
33
  format.html
34
34
  format.json { render(json: InterruptedJobsDatatable.new(view_context, @jobs)) }
@@ -36,7 +36,7 @@ module RocketJobMissionControl
36
36
  end
37
37
 
38
38
  def failed
39
- @jobs = RocketJob::Job.where(state: :failed).sort(_id: :desc)
39
+ @jobs = RocketJob::Job.where(state: :failed).sort(completed_at: :desc)
40
40
  respond_to do |format|
41
41
  format.html
42
42
  format.json { render(json: InterruptedJobsDatatable.new(view_context, @jobs)) }
@@ -44,7 +44,7 @@ module RocketJobMissionControl
44
44
  end
45
45
 
46
46
  def queued
47
- @jobs = RocketJob::Job.queued_now.sort(_id: :desc)
47
+ @jobs = RocketJob::Job.queued_now.sort(created_at: :desc)
48
48
  respond_to do |format|
49
49
  format.html
50
50
  format.json { render(json: QueuedJobsDatatable.new(view_context, @jobs)) }
@@ -52,7 +52,7 @@ module RocketJobMissionControl
52
52
  end
53
53
 
54
54
  def scheduled
55
- @jobs = RocketJob::Job.scheduled.sort(_id: :desc)
55
+ @jobs = RocketJob::Job.scheduled.sort(run_at: :asc)
56
56
  respond_to do |format|
57
57
  format.html
58
58
  format.json { render(json: ScheduledJobsDatatable.new(view_context, @jobs)) }
@@ -13,6 +13,7 @@ module RocketJobMissionControl
13
13
  end
14
14
 
15
15
  def update
16
+ JobSanitizer.new(params).sanitize
16
17
  if @job.update_attributes(job_params)
17
18
  redirect_to job_path(@job)
18
19
  else
@@ -62,7 +62,9 @@ module RocketJobMissionControl
62
62
  def action_buttons(job)
63
63
  events = valid_events(job)
64
64
  buttons = "<div class='inline-job-actions'>"
65
- buttons += "#{ link_to( 'Edit', edit_job_path(job), class: 'btn btn-default', title: 'Edit job') }"
65
+ unless job.completed? || job.aborted?
66
+ buttons += "#{ link_to( 'Edit', edit_job_path(job), class: 'btn btn-default', title: 'Edit job') }"
67
+ end
66
68
  if job.scheduled?
67
69
  buttons += "#{ job_action_link('Run', run_now_job_path(job), :patch) }"
68
70
  end
@@ -85,7 +87,7 @@ module RocketJobMissionControl
85
87
  buttons += "#{ job_action_link('Retry', retry_job_path(job), :patch) }"
86
88
  end
87
89
  if job.respond_to?(:input) && job.input.failed_count > 0
88
- buttons += "#{ link_to('view errors', job_failures_path(job), class: 'btn btn-default') }"
90
+ buttons += "#{ link_to('View Errors', job_failures_path(job), class: 'btn btn-default') }"
89
91
  end
90
92
  buttons += "</div>"
91
93
  end
@@ -80,7 +80,7 @@ module RocketJobMissionControl
80
80
 
81
81
  def filter_records(records)
82
82
  return records unless (params[:search].present? && params[:search][:value].present?)
83
- conditions = params[:search][:value]#build_conditions_for(params[:search][:value])
83
+ conditions = params[:search][:value]
84
84
  records = RocketJobMissionControl::Workers::Search.new(conditions, records).execute if conditions
85
85
  records
86
86
  end
@@ -4,7 +4,7 @@ module RocketJobMissionControl
4
4
  attr_reader :results, :search_term
5
5
 
6
6
  def initialize(search_term, search_subset)
7
- @search_term = search_term
7
+ @search_term = Regexp.escape(search_term)
8
8
  @results = search_subset
9
9
  end
10
10
 
@@ -4,7 +4,7 @@ module RocketJobMissionControl
4
4
  attr_reader :results, :search_term
5
5
 
6
6
  def initialize(search_term, search_subset)
7
- @search_term = search_term
7
+ @search_term = Regexp.escape(search_term)
8
8
  @results = search_subset
9
9
  end
10
10
 
@@ -4,7 +4,7 @@ module RocketJobMissionControl
4
4
  attr_reader :results, :search_term
5
5
 
6
6
  def initialize(search_term, search_subset)
7
- @search_term = search_term
7
+ @search_term = Regexp.escape(search_term)
8
8
  @results = search_subset
9
9
  end
10
10
 
@@ -0,0 +1,17 @@
1
+ class JobSanitizer
2
+ attr_reader :params
3
+
4
+ def initialize(params)
5
+ @params = params
6
+ end
7
+
8
+ def sanitize
9
+ sanitize_log_level
10
+ params
11
+ end
12
+
13
+ private
14
+ def sanitize_log_level
15
+ params[:job][:log_level] = nil if params[:job][:log_level].blank?
16
+ end
17
+ end
@@ -18,7 +18,7 @@
18
18
 
19
19
  = csrf_meta_tag
20
20
 
21
- %link{href: "//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css", rel: "stylesheet"}/
21
+ %link{href: "https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css", rel: "stylesheet"}/
22
22
 
23
23
  %body.rocket_job
24
24
  #wrapper
@@ -18,7 +18,7 @@
18
18
  %li
19
19
  = link_to workers_path, class: active_page(workers_path) do
20
20
  %i.fa.fa-database
21
- Workers
21
+ Servers
22
22
  %li
23
23
  = link_to active_processes_path, class: active_page(active_processes_path) do
24
24
  %i.fa.fa-circle-o-notch
@@ -18,15 +18,15 @@
18
18
  = f.number_field :priority, value: @job.priority, class: 'form-control'
19
19
  .col-md-4
20
20
  = f.label :log_level
21
- = f.select :log_level, ['', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'], {}, { class: 'form-control' }
22
- - if @job.method_exists?(:max_active_workers)
21
+ = f.select :log_level, ['trace', 'debug', 'info', 'warn', 'error', 'fatal'], { include_blank: true }, { class: 'form-control' }
22
+ - if @job.respond_to?(:max_active_workers)
23
23
  .col-md-4
24
24
  = f.label :max_active_workers
25
- = f.number_field :max_active_workers, class: 'form-control'
26
- - if @job.method_exists?(:cron_schedule)
25
+ = f.number_field :max_active_workers, value: @job.max_active_workers, min: 0, class: 'form-control'
26
+ - if @job.respond_to?(:cron_schedule)
27
27
  .col-md-4
28
28
  = f.label :cron_schedule
29
- = f.text_field :cron_schedule, class: 'form-control'
29
+ = f.text_field :cron_schedule, value: @job.cron_schedule, class: 'form-control'
30
30
  .row
31
31
  .col-md-12
32
32
  .buttons
@@ -30,9 +30,10 @@
30
30
  = job_action_link('Retry', rocket_job_mission_control.retry_job_path(@job), :patch)
31
31
 
32
32
  - if @job.respond_to?(:input) && @job.input.failed_count > 0
33
- = link_to('view errors', job_failures_path(@job), class: 'btn btn-default')
34
- .btn-group
35
- = link_to "Edit", edit_job_path(@job), class: "btn btn-default"
33
+ = link_to('View Errors', job_failures_path(@job), class: 'btn btn-default')
34
+ - unless @job.completed? || @job.aborted?
35
+ .btn-group
36
+ = link_to "Edit", edit_job_path(@job), class: "btn btn-default"
36
37
 
37
38
  .col-md-12
38
39
  = render partial: 'status', locals: { job: @job }
@@ -3,7 +3,7 @@
3
3
  .list
4
4
  .row
5
5
  .col-md-6
6
- %h2 Worker Processes
6
+ %h2 Servers
7
7
  .col-md-6
8
8
  .col-sm-10
9
9
  .worker-collection-actions
@@ -3,7 +3,7 @@
3
3
  .list
4
4
  .row
5
5
  .col-md-6
6
- %h2 Paused Worker Processes
6
+ %h2 Paused Servers
7
7
  .col-md-6
8
8
  .col-sm-10
9
9
  .worker-collection-actions
@@ -33,5 +33,5 @@
33
33
  jQuery(function() {
34
34
  new RjmcDatatable(
35
35
  $('.workers-datatable'),
36
- [{data: '0'}, {data: '1', orderable: false}, {data: '2', orderable: false}, {data: '3', orderable: false}, {data: '4', orderable: false}]);
36
+ [{data: '0'}, {data: '1', orderable: false}, {data: '2'}, {data: '3'}, {data: '4', orderable: false}]);
37
37
  });
@@ -3,7 +3,7 @@
3
3
  .list
4
4
  .row
5
5
  .col-md-6
6
- %h2 Running Worker Processes
6
+ %h2 Running Servers
7
7
  .col-md-6
8
8
  .col-sm-10
9
9
  .worker-collection-actions
@@ -33,5 +33,5 @@
33
33
  jQuery(function() {
34
34
  new RjmcDatatable(
35
35
  $('.workers-datatable'),
36
- [{data: '0'}, {data: '1', orderable: false}, {data: '2', orderable: false}, {data: '3', orderable: false}, {data: '4', orderable: false}]);
36
+ [{data: '0'}, {data: '1', orderable: false}, {data: '2'}, {data: '3'}, {data: '4', orderable: false}]);
37
37
  });
@@ -3,7 +3,7 @@
3
3
  .list
4
4
  .row
5
5
  .col-md-6
6
- %h2 Starting Worker Processes
6
+ %h2 Starting Servers
7
7
  .col-md-6
8
8
  .col-sm-10
9
9
  .worker-collection-actions
@@ -33,5 +33,5 @@
33
33
  jQuery(function() {
34
34
  new RjmcDatatable(
35
35
  $('.workers-datatable'),
36
- [{data: '0'}, {data: '1', orderable: false}, {data: '2', orderable: false}, {data: '3', orderable: false}, {data: '4', orderable: false}]);
36
+ [{data: '0'}, {data: '1', orderable: false}, {data: '2'}, {data: '3'}, {data: '4', orderable: false}]);
37
37
  });
@@ -3,7 +3,7 @@
3
3
  .list
4
4
  .row
5
5
  .col-md-6
6
- %h2 Stopping Worker Processes
6
+ %h2 Stopping Servers
7
7
  .col-md-6
8
8
  .col-sm-10
9
9
  .worker-collection-actions
@@ -33,5 +33,5 @@
33
33
  jQuery(function() {
34
34
  new RjmcDatatable(
35
35
  $('.workers-datatable'),
36
- [{data: '0'}, {data: '1', orderable: false}, {data: '2', orderable: false}, {data: '3', orderable: false}, {data: '4', orderable: false}]);
36
+ [{data: '0'}, {data: '1', orderable: false}, {data: '2'}, {data: '3'}, {data: '4', orderable: false}]);
37
37
  });
@@ -38,21 +38,21 @@ en:
38
38
  other: "%{count} years" # default was: "almost %{count} years"
39
39
  worker:
40
40
  stop:
41
- success: "Worker successfully stopped."
42
- failure: "Error attempting to stop worker."
41
+ success: "Server successfully stopped."
42
+ failure: "Error attempting to stop server."
43
43
  destroy:
44
- success: "Worker successfully destroyed."
45
- failure: "Error attempting to destroy worker."
44
+ success: "Server successfully destroyed."
45
+ failure: "Error attempting to destroy server."
46
46
  pause:
47
- success: "Worker successfully paused."
48
- failure: "Error attempting to pause worker."
47
+ success: "Server successfully paused."
48
+ failure: "Error attempting to pause server."
49
49
  resume:
50
- success: "Worker successfully resumed."
51
- failure: "Error attempting to resume worker."
50
+ success: "Server successfully resumed."
51
+ failure: "Error attempting to resume server."
52
52
  update_all:
53
- success: "Workers have been %{worker_action}."
53
+ success: "Servers have been %{worker_action}."
54
54
  invalid: "Action not allowed."
55
- confirm: "Are you sure you want to %{action} workers?"
55
+ confirm: "Are you sure you want to %{action} servers?"
56
56
  job:
57
57
  find:
58
58
  failure: "Could not find job with id: %{id}!"
@@ -1,3 +1,3 @@
1
1
  module RocketJobMissionControl
2
- VERSION = '2.1.0'
2
+ VERSION = '2.1.1'
3
3
  end
@@ -35,23 +35,28 @@ module RocketJobMissionControl
35
35
 
36
36
  describe "with #{state} dirmons" do
37
37
  let(:not_state) { states[i-1] }
38
- let!(:state_dirmon) { RocketJob::DirmonEntry.create!(state: state,
39
- pattern: '21',
40
- arguments: ['42'],
41
- job_class_name: 'AJob') }
38
+ let!(:state_dirmon) {
39
+ RocketJob::DirmonEntry.create!(
40
+ state: state,
41
+ pattern: '21',
42
+ arguments: ['42'],
43
+ job_class_name: 'AJob'
44
+ )
45
+ }
42
46
 
43
47
  before do
44
48
  RocketJob::DirmonEntry.create!(
45
- name: 'Test',
46
- state: not_state,
47
- arguments: ['42'],
48
- pattern: '21',
49
- job_class_name: 'AJob')
49
+ name: 'Test',
50
+ state: not_state,
51
+ arguments: ['42'],
52
+ pattern: '21',
53
+ job_class_name: 'AJob'
54
+ )
50
55
  get state.to_sym
51
56
  end
52
57
 
53
58
  after do
54
- DatabaseCleaner.clean
59
+ RocketJob::DirmonEntry.delete_all
55
60
  end
56
61
 
57
62
  it "succeeds" do
@@ -43,7 +43,8 @@ module RocketJobMissionControl
43
43
  end
44
44
 
45
45
  after do
46
- DatabaseCleaner.clean
46
+ RocketJob::Worker.delete_all
47
+ RocketJob::Job.delete_all
47
48
  end
48
49
 
49
50
  it "succeeds" do