rush_job_mongoid 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ea9484fa0b01542e93d912d9dc060a8d4fe79742ba2e0af06a1afda7c0bd496
4
- data.tar.gz: c5a14b81e1b257adfcd0ea74c13a1f8c86db7cdec89ec7413b15fd9c4474721a
3
+ metadata.gz: e76bab6e36e104771096dc0375e91ad5169b7de0bd5f459dec7a33399eaab02f
4
+ data.tar.gz: d2539734ed9936ce7290a81aae162b3480e58a0af81ffe1a7a80fcf17084c575
5
5
  SHA512:
6
- metadata.gz: bb917c0a28582f7872a68d67145a8f61e0bcb9c48df3e2686355efaeebf6e4ddda74d759f948ef6a0e8d02cc7a7fb9902d371edd00cb0a0a94cb4f5a14db10aa
7
- data.tar.gz: 3a67a4429fa491727a363a232ee88761d14b6bb9961d56b59c2fff6a269094a6975093c5959a2b2f4879daa64b223892ae67d5aeed952e7eb768446671b28009
6
+ metadata.gz: 7340d9f60d4d2c1de8293f029fe441d39e315a208fa4108bb21b52d3c5c3f270e50b151e0d01f6130e28d8a0de5ad5846431943ed23147f6eb2f4e31bd6d7903
7
+ data.tar.gz: 8ff687f743d53fa5bfba46d0b092ee2a49b56a31bd58b2d1390ca097e9b2abc937d9a3fffbf1994cc0ea4d7cb629b6742894191319e694de4a9bb3c0e7254840
data/README.md CHANGED
@@ -30,7 +30,7 @@ Queues on the dashboard are eager loaded. If there are lots of queues this can a
30
30
  Add this line to your Ruby on Rails application's Gemfile:
31
31
 
32
32
  ```ruby
33
- gem 'rush_job', '~> 1.0.1'
33
+ gem 'rush_job_mongoid', '~> 1.1.0'
34
34
  ```
35
35
 
36
36
  And then execute:
@@ -53,8 +53,8 @@ Open an issue or
53
53
  3. `bundle exec brakeman`
54
54
  4. Open pull request
55
55
 
56
- ## Upcoming
57
- 1. Remove dependency on Rails UJS and move to Hotwire and Turbo
56
+ ## Turbo
57
+ This gem uses turbo-rails, https://github.com/hotwired/turbo-rails. For Rails UJS fork from v1.0.2
58
58
 
59
59
  ## License
60
60
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,13 +1,13 @@
1
1
  import { Application } from '@hotwired/stimulus';
2
- import Rails from '@rails/ujs';
2
+ import RushJobMongoidConfirmController from './controllers/rush_job_mongoid_confirm_controller';
3
3
  import RushJobMongoidFiltersController from './controllers/rush_job_mongoid_filters_controller';
4
4
  import RushJobMongoidPollingController from './controllers/rush_job_mongoid_polling_controller';
5
5
  import RushJobMongoidReloadJobsTableController from './controllers/rush_job_mongoid_reload_jobs_table_controller';
6
6
  import 'bootstrap';
7
-
8
- Rails.start();
7
+ import '@hotwired/turbo-rails';
9
8
 
10
9
  window.Stimulus = Application.start();
10
+ Stimulus.register('rush-job-mongoid-confirm', RushJobMongoidConfirmController);
11
11
  Stimulus.register('rush-job-mongoid-filter', RushJobMongoidFiltersController);
12
12
  Stimulus.register('rush-job-mongoid-polling', RushJobMongoidPollingController);
13
13
  Stimulus.register('rush-job-mongoid-reload-jobs-table', RushJobMongoidReloadJobsTableController);
@@ -0,0 +1,11 @@
1
+ import { Controller } from '@hotwired/stimulus';
2
+
3
+ export default class RushJobMongoidConfirmController extends Controller {
4
+ displayConfirm(e) {
5
+ const confirmMessage = e.target.dataset.confirmMessage;
6
+
7
+ if (confirm(confirmMessage) !== true) {
8
+ e.preventDefault();
9
+ }
10
+ }
11
+ }
@@ -1,19 +1,23 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
- import Rails from '@rails/ujs';
3
2
 
4
3
  export class RushJobMongoidTableUpdateController extends Controller {
5
4
  updateJobs() {
5
+ const headers = { 'Accept': 'text/vnd.turbo-stream.html' };
6
+
6
7
  this.blurTable();
8
+ this.clearFlash();
7
9
 
8
- Rails.ajax({
9
- url: document.location.href,
10
- type: 'GET',
11
- dataType: 'script',
12
- });
10
+ fetch(document.location.href, { headers: headers })
11
+ .then(response => response.text())
12
+ .then(html => Turbo.renderStreamMessage(html));
13
13
  }
14
14
 
15
15
  blurTable() {
16
16
  const jobsContainer = document.getElementById('rush-job-mongoid-jobs');
17
17
  jobsContainer.classList.add('table-refresh');
18
18
  }
19
+
20
+ clearFlash() {
21
+ document.getElementById('rush-job-mongoid-flash-messages').innerHTML = '';
22
+ }
19
23
  }
@@ -6,6 +6,11 @@ module RushJobMongoid
6
6
  @locked_jobs_presenter = PaginationPresenter.new(params[:locked_jobs_page])
7
7
  @locked_jobs = LockedJobs.new(filter_params)
8
8
  @queues_presenter = QueueGroupsPresenter.new(params[:queue_groups_page]) if queue_groups_enabled?
9
+
10
+ respond_to do |format|
11
+ format.html
12
+ format.turbo_stream
13
+ end
9
14
  end
10
15
 
11
16
  def destroy
@@ -5,6 +5,11 @@ module RushJobMongoid
5
5
  def index
6
6
  @pagination_presenter = PaginationPresenter.new(params[:page])
7
7
  @rush_jobs = RushJob.filter(filter_params).locked_by_desc.paginate(@pagination_presenter.page, 20)
8
+
9
+ respond_to do |format|
10
+ format.html
11
+ format.turbo_stream
12
+ end
8
13
  end
9
14
 
10
15
  def edit
@@ -19,7 +19,7 @@ module RushJobMongoid
19
19
  private
20
20
 
21
21
  def queue_groups_from_presener
22
- @rush_job_queue_groups[(@queue_groups_presenter.page - 1) * 10, 10]
22
+ @rush_job_queue_groups[(@queue_groups_presenter.page - 1) * 10, 10] || []
23
23
  end
24
24
  end
25
25
  end
@@ -49,18 +49,28 @@
49
49
  </a>
50
50
  <div class="dropdown-menu"
51
51
  data-bs-popper="static">
52
- <%= button_to t("#{invert_theme}_mode"), settings_path, class: "nav-link", method: :patch, params: { setting: 'theme' } %>
52
+ <%= button_to t("#{invert_theme}_mode"),
53
+ settings_path, class: "nav-link",
54
+ method: :patch,
55
+ params: { setting: 'theme' },
56
+ data: { turbo: false } %>
53
57
  <%= button_to t("#{editing_enabled? ? 'disable_editing' : 'enable_editing'}"),
54
58
  settings_path,
55
59
  class: "nav-link",
56
60
  method: :patch,
57
61
  params: { setting: 'editing' },
58
- data: { confirm: t("#{editing_enabled? ? 'disable_editing_confirmation' : 'enable_editing_confirmation'}") } %>
62
+ data: {
63
+ turbo: false,
64
+ controller: 'rush-job-mongoid-confirm',
65
+ action: 'click->rush-job-mongoid-confirm#displayConfirm',
66
+ confirm_message: t("#{editing_enabled? ? 'disable_editing_confirmation' : 'enable_editing_confirmation'}")
67
+ } %>
59
68
  <%= button_to t("#{queue_groups_enabled? ? 'disable_queues' : 'enable_queues'}"),
60
69
  settings_path,
61
70
  class: "nav-link",
62
71
  method: :patch,
63
- params: { setting: 'queue_groups_presenter' } %>
72
+ params: { setting: 'queue_groups_presenter' },
73
+ data: { turbo: false } %>
64
74
  </div>
65
75
  </li>
66
76
  </ul>
@@ -1,34 +1,38 @@
1
- <div id="rush-job-mongoid-dashboard-locked-jobs">
2
- <div class="d-flex justify-content-left">
3
- <div class="table-responsive">
4
- <table class="table table-bordered table-striped">
5
- <thead>
6
- <tr>
7
- <th><%= t :id %></th>
8
- <th><%= t :locked_at %></th>
9
- <th><%= t :locked_by %></th>
10
- <th><%= t :job_class %></th>
11
- <th><%= t :arguments %></th>
12
- </tr>
13
- </thead>
14
- <tbody>
15
- <% @locked_jobs.paginate(@locked_jobs_presenter.page).each do |job| %>
16
- <tr>
17
- <td><%= job.id %></td>
18
- <td><%= job.locked_at %></td>
19
- <td><%= job.locked_by %></td>
20
- <td><%= job.job_class %></td>
21
- <td><%= job.job_arguments %></td>
22
- </tr>
23
- <% end %>
24
- </tbody>
25
- </table>
26
- </div>
27
- </div>
1
+ <%= turbo_frame_tag 'rush_job_mongoid_dashboard_frame' do %>
2
+ <div id="rush-job-mongoid-jobs">
3
+ <div id="rush-job-mongoid-dashboard-locked-jobs">
4
+ <div class="d-flex justify-content-left">
5
+ <div class="table-responsive">
6
+ <table class="table table-bordered table-striped">
7
+ <thead>
8
+ <tr>
9
+ <th><%= t :id %></th>
10
+ <th><%= t :locked_at %></th>
11
+ <th><%= t :locked_by %></th>
12
+ <th><%= t :job_class %></th>
13
+ <th><%= t :arguments %></th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <% @locked_jobs.paginate(@locked_jobs_presenter.page).each do |job| %>
18
+ <tr>
19
+ <td><%= job.id %></td>
20
+ <td><%= job.locked_at %></td>
21
+ <td><%= job.locked_by %></td>
22
+ <td><%= job.job_class %></td>
23
+ <td><%= job.job_arguments %></td>
24
+ </tr>
25
+ <% end %>
26
+ </tbody>
27
+ </table>
28
+ </div>
29
+ </div>
28
30
 
29
- <%= render 'rush_job_mongoid/shared/pagination', controller: 'dashboard', pagination_param: 'locked_jobs_page', pages_count: @locked_jobs_presenter.pages(@locked_jobs.jobs.count, 10), page: @locked_jobs_presenter.page %>
30
- </div>
31
+ <%= render 'rush_job_mongoid/shared/pagination', controller: 'dashboard', pagination_param: 'locked_jobs_page', pages_count: @locked_jobs_presenter.pages(@locked_jobs.jobs.count, 10), page: @locked_jobs_presenter.page %>
32
+ </div>
31
33
 
32
- <% if queue_groups_enabled? %>
33
- <%= render 'queues_table' %>
34
+ <% if queue_groups_enabled? %>
35
+ <%= render 'queues_table' %>
36
+ <% end %>
37
+ </div>
34
38
  <% end %>
@@ -26,7 +26,12 @@
26
26
  class: "btn btn-danger btn-sm",
27
27
  method: :delete,
28
28
  params: { queue: group[:queue], priority: group[:priority] },
29
- data: { confirm: t(:clear_queue_confirmation, queue: group[:queue]) } %></td>
29
+ data: {
30
+ turbo: false,
31
+ controller: 'rush-job-mongoid-confirm',
32
+ action: 'click->rush-job-mongoid-confirm#displayConfirm',
33
+ confirm_message: t(:clear_queue_confirmation, queue: group[:queue])
34
+ } %></td>
30
35
  <% end %>
31
36
  </tr>
32
37
  <% end %>
@@ -2,6 +2,4 @@
2
2
 
3
3
  <h3 class="text-body"><%= t :locked_jobs %></h3>
4
4
 
5
- <div id="rush-job-mongoid-jobs">
6
- <%= render 'dashboard_tables' %>
7
- </div>
5
+ <%= render 'dashboard_tables' %>
@@ -0,0 +1,7 @@
1
+ <%= turbo_stream.replace 'rush_job_mongoid_dashboard_frame',
2
+ partial: 'dashboard_tables',
3
+ locals: {
4
+ locked_jobs_presenter: @locked_jobs_presenter,
5
+ pagination_presenter: @pagination_presenter,
6
+ queues_presenter: @queues_presenter
7
+ } %>
@@ -1,43 +1,51 @@
1
- <table class="table table-bordered table-striped">
2
- <thead>
3
- <tr>
4
- <% if editing_enabled? %>
5
- <th></th>
6
- <% end %>
7
- <th><%= t :priority %></th>
8
- <th><%= t :attempts %></th>
9
- <th><%= t :job_class %></th>
10
- <th><%= t :arguments %></th>
11
- <th><%= t :run_at %></th>
12
- <th><%= t :locked_at %></th>
13
- <th><%= t :locked_by %></th>
14
- <th><%= t :failed_at %></th>
15
- <th><%= t :last_error %></th>
16
- <th><%= t :queue %></th>
17
- </tr>
18
- </thead>
19
- <tbody>
20
- <% @rush_jobs.each do |job| %>
21
- <tr>
22
- <% if editing_enabled? %>
23
- <td><%= link_to image_tag("rush_job_mongoid/pencil-square-#{invert_theme}.svg", id: "rush-job-mongoid-pencil-square-#{job.id}", alt: 'pencil square'), edit_rush_job_path(job.id) %></td>
1
+ <%= turbo_frame_tag 'rush_job_mongoid_jobs_frame' do %>
2
+ <div id="rush-job-mongoid-jobs">
3
+ <table class="table table-bordered table-striped">
4
+ <thead>
5
+ <tr>
6
+ <% if editing_enabled? %>
7
+ <th></th>
8
+ <% end %>
9
+ <th><%= t :priority %></th>
10
+ <th><%= t :attempts %></th>
11
+ <th><%= t :job_class %></th>
12
+ <th><%= t :arguments %></th>
13
+ <th><%= t :run_at %></th>
14
+ <th><%= t :locked_at %></th>
15
+ <th><%= t :locked_by %></th>
16
+ <th><%= t :failed_at %></th>
17
+ <th><%= t :last_error %></th>
18
+ <th><%= t :queue %></th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% @rush_jobs.each do |job| %>
23
+ <tr>
24
+ <% if editing_enabled? %>
25
+ <td><%= link_to image_tag("rush_job_mongoid/pencil-square-#{invert_theme}.svg",
26
+ id: "rush-job-mongoid-pencil-square-#{job.id}",
27
+ alt: 'pencil square'), edit_rush_job_path(job.id),
28
+ target: '_top' %>
29
+ </td>
30
+ <% end %>
31
+ <td><%= job.priority %></td>
32
+ <td><%= job.attempts %></td>
33
+ <td><%= job.job_class %></td>
34
+ <td><%= job.job_arguments %></td>
35
+ <td><%= job.run_at %></td>
36
+ <td><%= job.locked_at %></td>
37
+ <td><%= job.locked_by %></td>
38
+ <td><%= job.failed_at %></td>
39
+ <td><%= job.last_error %></td>
40
+ <td><%= job.queue %></td>
41
+ </tr>
24
42
  <% end %>
25
- <td><%= job.priority %></td>
26
- <td><%= job.attempts %></td>
27
- <td><%= job.job_class %></td>
28
- <td><%= job.job_arguments %></td>
29
- <td><%= job.run_at %></td>
30
- <td><%= job.locked_at %></td>
31
- <td><%= job.locked_by %></td>
32
- <td><%= job.failed_at %></td>
33
- <td><%= job.last_error %></td>
34
- <td><%= job.queue %></td>
35
- </tr>
36
- <% end %>
37
- </tbody>
38
- </table>
43
+ </tbody>
44
+ </table>
39
45
 
40
- <%= render 'rush_job_mongoid/shared/pagination', controller: 'rush_jobs',
41
- pagination_param: 'page',
42
- pages_count: @pagination_presenter.pages(RushJobMongoid::RushJob.filter(filter_param_query).count, 20),
43
- page: @pagination_presenter.page %>
46
+ <%= render 'rush_job_mongoid/shared/pagination', controller: 'rush_jobs',
47
+ pagination_param: 'page',
48
+ pages_count: @pagination_presenter.pages(RushJobMongoid::RushJob.filter(filter_param_query).count, 20),
49
+ page: @pagination_presenter.page %>
50
+ </div>
51
+ <% end %>
@@ -39,7 +39,7 @@
39
39
  <%= form.label :queue, t(:queue), class: 'form-label' %>
40
40
  <%= form.text_field :queue, class: 'form-control' %>
41
41
  </div>
42
- <%= form.submit t(:update), class: 'btn btn-primary' %>
42
+ <%= form.submit t(:update), class: 'btn btn-primary', data: { turbo: false } %>
43
43
  <% end %>
44
44
 
45
45
  <div class="mt-3">
@@ -47,5 +47,10 @@
47
47
  rush_job_url(@job),
48
48
  class: "btn btn-danger",
49
49
  method: :delete,
50
- data: { confirm: t(:delete_job_confirmation, job_id: @job.id) } %>
50
+ data: {
51
+ turbo: false,
52
+ controller: 'rush-job-mongoid-confirm',
53
+ action: 'click->rush-job-mongoid-confirm#displayConfirm',
54
+ confirm_message: t(:delete_job_confirmation, job_id: @job.id)
55
+ } %>
51
56
  </div>
@@ -2,6 +2,4 @@
2
2
 
3
3
  <%= render 'rush_job_mongoid/shared/polling' %>
4
4
 
5
- <div id="rush-job-mongoid-jobs">
6
- <%= render 'jobs_table' %>
7
- </div>
5
+ <%= render 'jobs_table' %>
@@ -0,0 +1,6 @@
1
+ <%= turbo_stream.replace 'rush_job_mongoid_jobs_frame',
2
+ partial: 'jobs_table',
3
+ locals: {
4
+ rush_jobs: @rush_jobs,
5
+ locked_jobs: @locked_jobs
6
+ } %>
@@ -1,3 +1,6 @@
1
1
  <li class="page-item">
2
- <%= link_to link_display, { controller: controller, params: request.parameters.merge(pagination_param => page) }, class: link_class %>
3
- </li>
2
+ <%= link_to link_display,
3
+ { controller: controller, params: request.parameters.merge(pagination_param => page) },
4
+ class: link_class,
5
+ target: '_top' %>
6
+ </li>
data/config/importmap.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  pin 'rush_job_mongoid/application', preload: true
2
2
  pin 'bootstrap', to: 'https://ga.jspm.io/npm:bootstrap@5.3.1/dist/js/bootstrap.esm.js'
3
3
  pin '@popperjs/core', to: 'https://ga.jspm.io/npm:@popperjs/core@2.11.8/lib/index.js'
4
- pin '@rails/ujs', to: 'https://ga.jspm.io/npm:@rails/ujs@7.0.6/lib/assets/compiled/rails-ujs.js'
5
4
  pin '@hotwired/stimulus', to: 'https://ga.jspm.io/npm:@hotwired/stimulus@3.2.2/dist/stimulus.js'
5
+ pin '@hotwired/turbo-rails', to: 'turbo.min.js', preload: true
@@ -1,3 +1,3 @@
1
1
  module RushJobMongoid
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rush_job_mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JavaKoala
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-28 00:00:00.000000000 Z
11
+ date: 2024-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: turbo-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: delayed_job
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -278,6 +292,7 @@ files:
278
292
  - app/assets/images/rush_job_mongoid/pencil-square-dark.svg
279
293
  - app/assets/images/rush_job_mongoid/pencil-square-light.svg
280
294
  - app/assets/javascript/rush_job_mongoid/application.js
295
+ - app/assets/javascript/rush_job_mongoid/controllers/rush_job_mongoid_confirm_controller.js
281
296
  - app/assets/javascript/rush_job_mongoid/controllers/rush_job_mongoid_filters_controller.js
282
297
  - app/assets/javascript/rush_job_mongoid/controllers/rush_job_mongoid_polling_controller.js
283
298
  - app/assets/javascript/rush_job_mongoid/controllers/rush_job_mongoid_reload_jobs_table_controller.js
@@ -304,11 +319,11 @@ files:
304
319
  - app/views/rush_job_mongoid/dashboard/_dashboard_tables.html.erb
305
320
  - app/views/rush_job_mongoid/dashboard/_queues_table.html.erb
306
321
  - app/views/rush_job_mongoid/dashboard/index.html.erb
307
- - app/views/rush_job_mongoid/dashboard/index.js.erb
322
+ - app/views/rush_job_mongoid/dashboard/index.turbo_stream.erb
308
323
  - app/views/rush_job_mongoid/rush_jobs/_jobs_table.html.erb
309
324
  - app/views/rush_job_mongoid/rush_jobs/edit.html.erb
310
325
  - app/views/rush_job_mongoid/rush_jobs/index.html.erb
311
- - app/views/rush_job_mongoid/rush_jobs/index.js.erb
326
+ - app/views/rush_job_mongoid/rush_jobs/index.turbo_stream.erb
312
327
  - app/views/rush_job_mongoid/shared/_pagination.html.erb
313
328
  - app/views/rush_job_mongoid/shared/_pagination_link.html.erb
314
329
  - app/views/rush_job_mongoid/shared/_polling.html.erb
@@ -1,3 +0,0 @@
1
- document.getElementById('rush-job-mongoid-flash-messages').innerHTML = "<%= j (render partial: 'layouts/rush_job_mongoid/flash_messages') %>"
2
- document.getElementById('rush-job-mongoid-jobs').innerHTML = "<%= j (render partial: 'dashboard_tables') %>"
3
- document.getElementById('rush-job-mongoid-jobs').classList.remove('table-refresh');
@@ -1,3 +0,0 @@
1
- document.getElementById('rush-job-mongoid-flash-messages').innerHTML = "<%= j (render partial: 'layouts/rush_job_mongoid/flash_messages') %>"
2
- document.getElementById('rush-job-mongoid-jobs').innerHTML = "<%= j (render partial: 'jobs_table') %>"
3
- document.getElementById('rush-job-mongoid-jobs').classList.remove('table-refresh');