rush_job 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/javascript/rush_job/application.js +12 -1
- data/app/assets/javascript/rush_job/controllers/rush_job_polling_controller.js +49 -0
- data/app/assets/javascript/rush_job/controllers/rush_job_reload_jobs_table_controller.js +7 -0
- data/app/assets/javascript/rush_job/controllers/rush_job_table_update_controller.js +19 -0
- data/app/assets/stylesheets/rush_job/pages/_index.scss +28 -1
- data/app/controllers/rush_job/rush_jobs_controller.rb +5 -0
- data/app/views/rush_job/rush_jobs/_jobs_table.html.erb +49 -0
- data/app/views/rush_job/rush_jobs/index.html.erb +37 -48
- data/app/views/rush_job/rush_jobs/index.js.erb +1 -0
- data/config/importmap.rb +2 -0
- data/config/locales/en.yml +3 -0
- data/lib/rush_job/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f24031055b7af192d199277995a02156d089d208ef07037c75d5ebcafabaaf1
|
4
|
+
data.tar.gz: 697f98385692da3bcbe8ff8b5971b222fcf93a1c3df34ef9e4544e86dc51fd6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9a83f701a00989f02da32d816bae209b90576eff5ab2ca3e2c0930f0a876294faf29dc88267847a65f82d6aa159e1ddce3e56839d5cf1f2df1c532d05e39fd8
|
7
|
+
data.tar.gz: '0810045ea1fee244ad1a5ec8bb2d71728546d4d760e0e344bca5d93292c7c1d775fdbff34f1094cc202290b50ef15655c8ce5ce5189782868367fe0bba2ce079'
|
data/README.md
CHANGED
@@ -1 +1,12 @@
|
|
1
|
-
import
|
1
|
+
import 'bootstrap'
|
2
|
+
import Rails from '@rails/ujs'
|
3
|
+
Rails.start();
|
4
|
+
|
5
|
+
import { Application } from '@hotwired/stimulus'
|
6
|
+
|
7
|
+
import RushJobPollingController from './controllers/rush_job_polling_controller'
|
8
|
+
import RushJobReloadJobsTableController from './controllers/rush_job_reload_jobs_table_controller'
|
9
|
+
|
10
|
+
window.Stimulus = Application.start()
|
11
|
+
Stimulus.register('rush-job-polling', RushJobPollingController)
|
12
|
+
Stimulus.register('rush-job-reload-jobs-table', RushJobReloadJobsTableController)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { RushJobTableUpdateController } from './rush_job_table_update_controller.js'
|
2
|
+
|
3
|
+
let intervalID
|
4
|
+
|
5
|
+
export default class extends RushJobTableUpdateController {
|
6
|
+
static targets = [ 'pollingTime', 'pollingTimeLabel', 'pollingSlide' ]
|
7
|
+
|
8
|
+
connect() {
|
9
|
+
this.pollingChange()
|
10
|
+
this.stopPolling()
|
11
|
+
}
|
12
|
+
|
13
|
+
pollingChange() {
|
14
|
+
const pollingLabelRegex = /\d+/;
|
15
|
+
let pollingLabelUpdate = this.pollingTimeLabelTarget.innerHTML.replace(pollingLabelRegex, this.pollingTime())
|
16
|
+
this.pollingTimeLabelTarget.innerHTML = pollingLabelUpdate
|
17
|
+
}
|
18
|
+
|
19
|
+
pollingToggle() {
|
20
|
+
let pollingSlide = this.pollingSlideTarget
|
21
|
+
|
22
|
+
if (pollingSlide.checked === true) {
|
23
|
+
this.startPolling()
|
24
|
+
} else {
|
25
|
+
this.stopPolling()
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
startPolling() {
|
30
|
+
this.updateJobs()
|
31
|
+
|
32
|
+
intervalID = setTimeout(() => {
|
33
|
+
this.startPolling()
|
34
|
+
}, this.pollingTime() * 1000)
|
35
|
+
}
|
36
|
+
|
37
|
+
stopPolling() {
|
38
|
+
if (intervalID) {
|
39
|
+
clearInterval(intervalID)
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
pollingTime() {
|
44
|
+
const pollingTimes = [3, 5, 8, 13, 21, 34, 55]
|
45
|
+
let pollingTime = this.pollingTimeTarget.value || 3
|
46
|
+
|
47
|
+
return pollingTimes[pollingTime]
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
import Rails from '@rails/ujs'
|
3
|
+
|
4
|
+
export class RushJobTableUpdateController extends Controller {
|
5
|
+
updateJobs() {
|
6
|
+
this.blurTable()
|
7
|
+
|
8
|
+
Rails.ajax({
|
9
|
+
url: document.location.href,
|
10
|
+
type: 'GET',
|
11
|
+
dataType: 'script'
|
12
|
+
})
|
13
|
+
}
|
14
|
+
|
15
|
+
blurTable() {
|
16
|
+
let jobs_container = document.getElementById('rush-job-jobs-container')
|
17
|
+
jobs_container.classList.add('table-refresh')
|
18
|
+
}
|
19
|
+
}
|
@@ -11,6 +11,29 @@
|
|
11
11
|
margin-top: 0.5rem;
|
12
12
|
}
|
13
13
|
|
14
|
+
.polling-container {
|
15
|
+
margin-left: 5%;
|
16
|
+
margin-right: 5%;
|
17
|
+
}
|
18
|
+
|
19
|
+
.polling-range-form-label-dark {
|
20
|
+
color: rgb(0, 0, 0);
|
21
|
+
margin-bottom: 0.5rem;
|
22
|
+
}
|
23
|
+
|
24
|
+
.polling-range-form-label-light {
|
25
|
+
color: rgb(255, 255, 255);
|
26
|
+
margin-bottom: 0.5rem;
|
27
|
+
}
|
28
|
+
|
29
|
+
.form-check-label-dark {
|
30
|
+
color: rgb(0, 0, 0);
|
31
|
+
}
|
32
|
+
|
33
|
+
.form-check-label-light {
|
34
|
+
color: rgb(255, 255, 255);
|
35
|
+
}
|
36
|
+
|
14
37
|
.jobs-container {
|
15
38
|
margin-left: 5%;
|
16
39
|
margin-right: 5%;
|
@@ -32,4 +55,8 @@
|
|
32
55
|
|
33
56
|
.page-item:last-child .page-link {
|
34
57
|
color: rgb(68, 110, 155);
|
35
|
-
}
|
58
|
+
}
|
59
|
+
|
60
|
+
.table-refresh {
|
61
|
+
opacity: 0.3;
|
62
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<div
|
2
|
+
id="rush-job-jobs-container"
|
3
|
+
class="jobs-container"
|
4
|
+
role="main"
|
5
|
+
>
|
6
|
+
<div class="table-responsive">
|
7
|
+
<table class="table
|
8
|
+
table-bordered
|
9
|
+
table-striped
|
10
|
+
table-<%= current_theme %>">
|
11
|
+
<thead>
|
12
|
+
<tr>
|
13
|
+
<th><%= sortable 'id' %><%= sort_arrow 'id' %></th>
|
14
|
+
<th><%= sortable 'priority' %><%= sort_arrow 'priority' %></th>
|
15
|
+
<th><%= sortable 'attempts' %><%= sort_arrow 'attempts' %></th>
|
16
|
+
<th><%= t :job_class %></th>
|
17
|
+
<th><%= t :arguments %></th>
|
18
|
+
<th><%= sortable 'last_error' %><%= sort_arrow 'last_error' %></th>
|
19
|
+
<th><%= sortable 'run_at' %><%= sort_arrow 'run_at' %></th>
|
20
|
+
<th><%= sortable 'locked_at' %><%= sort_arrow 'locked_at' %></th>
|
21
|
+
<th><%= sortable 'failed_at' %><%= sort_arrow 'failed_at' %></th>
|
22
|
+
<th><%= sortable 'locked_by' %><%= sort_arrow'locked_by' %></th>
|
23
|
+
<th><%= sortable 'queue' %><%= sort_arrow 'queue' %></th>
|
24
|
+
</tr>
|
25
|
+
</thead>
|
26
|
+
<tbody class="table-group-divider">
|
27
|
+
<% @rush_jobs.each do |job| %>
|
28
|
+
<tr>
|
29
|
+
<td><%= job.id %></td>
|
30
|
+
<td><%= job.priority %></td>
|
31
|
+
<td><%= job.attempts %></td>
|
32
|
+
<td><%= job.job_class %></td>
|
33
|
+
<td><%= job.job_arguments %></td>
|
34
|
+
<td><%= job.last_error %></td>
|
35
|
+
<td><%= job.run_at %></td>
|
36
|
+
<td><%= job.locked_at %></td>
|
37
|
+
<td><%= job.failed_at %></td>
|
38
|
+
<td><%= job.locked_by %></td>
|
39
|
+
<td><%= job.queue %></td>
|
40
|
+
</tr>
|
41
|
+
<% end %>
|
42
|
+
</tbody>
|
43
|
+
</table>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div class="footer-container">
|
48
|
+
<%== pagy_bootstrap_nav(@pagy) if @pagy.pages > 1 %>
|
49
|
+
</div>
|
@@ -6,13 +6,8 @@
|
|
6
6
|
<%= t :delayed_title %>
|
7
7
|
</h2>
|
8
8
|
</div>
|
9
|
-
<div class="col-3">
|
10
|
-
<button
|
11
|
-
type="button"
|
12
|
-
class="btn btn-primary"
|
13
|
-
onclick="location.reload();">
|
14
|
-
<%= t :reload %>
|
15
|
-
</button>
|
9
|
+
<div class="col-3" data-controller="rush-job-reload-jobs-table">
|
10
|
+
<button class="btn btn-primary" data-action="click->rush-job-reload-jobs-table#reloadJobs"><%= t :reload %></button>
|
16
11
|
</div>
|
17
12
|
<div class="col-3">
|
18
13
|
<%= form_with url: theme_path, method: 'patch' do |form| %>
|
@@ -23,48 +18,42 @@
|
|
23
18
|
</div>
|
24
19
|
</div>
|
25
20
|
|
26
|
-
<div class="
|
27
|
-
<div class="
|
28
|
-
<
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
<
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
<td><%= job.locked_by %></td>
|
60
|
-
<td><%= job.queue %></td>
|
61
|
-
</tr>
|
62
|
-
<% end %>
|
63
|
-
</tbody>
|
64
|
-
</table>
|
21
|
+
<div class="polling-container" data-controller="rush-job-polling">
|
22
|
+
<div class="row align-items-center">
|
23
|
+
<div class="col-3">
|
24
|
+
<label
|
25
|
+
for="rush-job-polling-range"
|
26
|
+
class="polling-range-form-label-<%= invert_theme %>"
|
27
|
+
data-rush-job-polling-target="pollingTimeLabel"
|
28
|
+
>
|
29
|
+
<%= t :polling_time %> 13 <%= t :polling_time_unit %>
|
30
|
+
</label>
|
31
|
+
<input
|
32
|
+
id="rush-job-polling-range"
|
33
|
+
type="range"
|
34
|
+
class="form-range"
|
35
|
+
min="0"
|
36
|
+
max="6"
|
37
|
+
data-rush-job-polling-target="pollingTime"
|
38
|
+
data-action="input->rush-job-polling#pollingChange"
|
39
|
+
>
|
40
|
+
</div>
|
41
|
+
<div class="col-3">
|
42
|
+
<div class="form-check form-switch">
|
43
|
+
<input
|
44
|
+
id="rush-job-polling"
|
45
|
+
class="form-check-input"
|
46
|
+
type="checkbox"
|
47
|
+
role="switch"
|
48
|
+
data-rush-job-polling-target="pollingSlide"
|
49
|
+
data-action="input->rush-job-polling#pollingToggle"
|
50
|
+
>
|
51
|
+
<label class="form-check-label-<%= invert_theme %>" for="rush-job-polling"><%= t :enable_polling %></label>
|
52
|
+
</div>
|
53
|
+
</div>
|
65
54
|
</div>
|
66
55
|
</div>
|
67
56
|
|
68
|
-
<div
|
69
|
-
|
57
|
+
<div id="rush-job-jobs-table">
|
58
|
+
<%= render 'jobs_table' %>
|
70
59
|
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
document.getElementById('rush-job-jobs-table').innerHTML = "<%= j (render partial: 'jobs_table') %>"
|
data/config/importmap.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
1
|
pin 'rush_job/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
|
+
pin '@hotwired/stimulus', to: 'https://ga.jspm.io/npm:@hotwired/stimulus@3.2.2/dist/stimulus.js'
|
data/config/locales/en.yml
CHANGED
@@ -2,6 +2,7 @@ en:
|
|
2
2
|
arguments: "Arguments"
|
3
3
|
attempts: "Attempts"
|
4
4
|
delayed_title: "Delayed jobs"
|
5
|
+
enable_polling: "Enable polling"
|
5
6
|
failed_at: "Failed at"
|
6
7
|
id: "Id"
|
7
8
|
invalid_page_notice: "No jobs on that page, redirected to first page."
|
@@ -9,6 +10,8 @@ en:
|
|
9
10
|
last_error: "Last error"
|
10
11
|
locked_at: "Locked at"
|
11
12
|
locked_by: "Locked by"
|
13
|
+
polling_time: "Polling time:"
|
14
|
+
polling_time_unit: "seconds"
|
12
15
|
priority: "Priority"
|
13
16
|
queue: "Queue"
|
14
17
|
reload: "Reload"
|
data/lib/rush_job/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rush_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JavaKoala
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -292,6 +292,9 @@ files:
|
|
292
292
|
- app/assets/images/rush_job/arrow-up-dark.svg
|
293
293
|
- app/assets/images/rush_job/arrow-up-light.svg
|
294
294
|
- app/assets/javascript/rush_job/application.js
|
295
|
+
- app/assets/javascript/rush_job/controllers/rush_job_polling_controller.js
|
296
|
+
- app/assets/javascript/rush_job/controllers/rush_job_reload_jobs_table_controller.js
|
297
|
+
- app/assets/javascript/rush_job/controllers/rush_job_table_update_controller.js
|
295
298
|
- app/assets/stylesheets/rush_job/application.scss
|
296
299
|
- app/assets/stylesheets/rush_job/pages/_index.scss
|
297
300
|
- app/assets/stylesheets/rush_job/themes/_dark.scss
|
@@ -305,7 +308,9 @@ files:
|
|
305
308
|
- app/models/rush_job/application_record.rb
|
306
309
|
- app/models/rush_job/rush_job.rb
|
307
310
|
- app/views/layouts/rush_job/application.html.erb
|
311
|
+
- app/views/rush_job/rush_jobs/_jobs_table.html.erb
|
308
312
|
- app/views/rush_job/rush_jobs/index.html.erb
|
313
|
+
- app/views/rush_job/rush_jobs/index.js.erb
|
309
314
|
- config/importmap.rb
|
310
315
|
- config/locales/en.yml
|
311
316
|
- config/routes.rb
|