rush_job 0.5.2 → 0.6.1
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 +9 -10
- data/app/assets/javascript/rush_job/controllers/rush_job_polling_controller.js +18 -17
- data/app/assets/javascript/rush_job/controllers/rush_job_reload_jobs_table_controller.js +2 -2
- data/app/assets/javascript/rush_job/controllers/rush_job_table_update_controller.js +7 -7
- data/app/controllers/rush_job/dashboard_controller.rb +13 -0
- data/app/controllers/rush_job/rush_jobs_controller.rb +0 -5
- data/app/controllers/rush_job/settings_controller.rb +18 -0
- data/app/helpers/rush_job/application_helper.rb +1 -7
- data/app/helpers/rush_job/settings_helper.rb +15 -0
- data/app/models/rush_job/rush_job.rb +5 -0
- data/app/services/rush_job/settings.rb +18 -0
- data/app/views/layouts/rush_job/_flash_messages.html.erb +5 -0
- data/app/views/layouts/rush_job/_navbar.html.erb +18 -2
- data/app/views/layouts/rush_job/application.html.erb +3 -5
- data/app/views/rush_job/dashboard/_dashboard_tables.html.erb +11 -0
- data/app/views/rush_job/dashboard/index.js.erb +1 -0
- data/app/views/rush_job/rush_jobs/index.js.erb +1 -0
- data/config/locales/en.yml +7 -0
- data/config/routes.rb +2 -1
- data/lib/rush_job/version.rb +1 -1
- metadata +7 -4
- data/app/controllers/rush_job/themes_controller.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f1f2016e98628b8ca8df65ab968afd510ae17cec5c27f1c32bb310d9e566cc7
|
4
|
+
data.tar.gz: 58461cac54f6376f5505ef433b100c17acb4059b267611b63b2284fec3868535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6bebec349e0ec4975275946490aff4908914c1cdc6420b05e5e8b8bb7977119fee0d8199cf8b69577646d591bb9bf124f13f40d43786f73762d87282da765b2
|
7
|
+
data.tar.gz: 0c9175a6c11f22a8b93f422bfa5d4346c10f5daed5d8e18a5d512146aa138cc126f2eb48f2f6f535ad68f5e3fe368c9a43c4ad6442df579027c4326e7318a497
|
data/README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
import '
|
2
|
-
import Rails from '@rails/ujs'
|
3
|
-
|
4
|
-
|
5
|
-
import
|
1
|
+
import { Application } from '@hotwired/stimulus';
|
2
|
+
import Rails from '@rails/ujs';
|
3
|
+
import RushJobPollingController from './controllers/rush_job_polling_controller';
|
4
|
+
import RushJobReloadJobsTableController from './controllers/rush_job_reload_jobs_table_controller';
|
5
|
+
import 'bootstrap';
|
6
6
|
|
7
|
-
|
8
|
-
import RushJobReloadJobsTableController from './controllers/rush_job_reload_jobs_table_controller'
|
7
|
+
Rails.start();
|
9
8
|
|
10
|
-
window.Stimulus = Application.start()
|
11
|
-
Stimulus.register('rush-job-polling', RushJobPollingController)
|
12
|
-
Stimulus.register('rush-job-reload-jobs-table', RushJobReloadJobsTableController)
|
9
|
+
window.Stimulus = Application.start();
|
10
|
+
Stimulus.register('rush-job-polling', RushJobPollingController);
|
11
|
+
Stimulus.register('rush-job-reload-jobs-table', RushJobReloadJobsTableController);
|
@@ -1,49 +1,50 @@
|
|
1
|
-
import
|
1
|
+
import { RushJobTableUpdateController } from './rush_job_table_update_controller';
|
2
2
|
|
3
|
-
let intervalID
|
3
|
+
let intervalID;
|
4
4
|
|
5
5
|
export default class extends RushJobTableUpdateController {
|
6
|
-
static targets = [
|
6
|
+
static targets = ['pollingTime', 'pollingTimeLabel', 'pollingSlide'];
|
7
7
|
|
8
8
|
connect() {
|
9
|
-
this.pollingChange()
|
10
|
-
this.stopPolling()
|
9
|
+
this.pollingChange();
|
10
|
+
this.stopPolling();
|
11
11
|
}
|
12
12
|
|
13
13
|
pollingChange() {
|
14
14
|
const pollingLabelRegex = /\d+/;
|
15
|
-
|
16
|
-
|
15
|
+
const pollingTimeTargetHtml = this.pollingTimeLabelTarget.innerHTML;
|
16
|
+
const pollingLabelUpdate = pollingTimeTargetHtml.replace(pollingLabelRegex, this.pollingTime());
|
17
|
+
this.pollingTimeLabelTarget.innerHTML = pollingLabelUpdate;
|
17
18
|
}
|
18
19
|
|
19
20
|
pollingToggle() {
|
20
|
-
|
21
|
+
const pollingSlide = this.pollingSlideTarget;
|
21
22
|
|
22
23
|
if (pollingSlide.checked === true) {
|
23
|
-
this.startPolling()
|
24
|
+
this.startPolling();
|
24
25
|
} else {
|
25
|
-
this.stopPolling()
|
26
|
+
this.stopPolling();
|
26
27
|
}
|
27
28
|
}
|
28
29
|
|
29
30
|
startPolling() {
|
30
|
-
this.updateJobs()
|
31
|
+
this.updateJobs();
|
31
32
|
|
32
33
|
intervalID = setTimeout(() => {
|
33
|
-
this.startPolling()
|
34
|
-
}, this.pollingTime() * 1000)
|
34
|
+
this.startPolling();
|
35
|
+
}, this.pollingTime() * 1000);
|
35
36
|
}
|
36
37
|
|
37
38
|
stopPolling() {
|
38
39
|
if (intervalID) {
|
39
|
-
clearInterval(intervalID)
|
40
|
+
clearInterval(intervalID);
|
40
41
|
}
|
41
42
|
}
|
42
43
|
|
43
44
|
pollingTime() {
|
44
|
-
const pollingTimes = [3, 5, 8, 13, 21, 34, 55]
|
45
|
-
|
45
|
+
const pollingTimes = [3, 5, 8, 13, 21, 34, 55];
|
46
|
+
const pollingTime = this.pollingTimeTarget.value || 3;
|
46
47
|
|
47
|
-
return pollingTimes[pollingTime]
|
48
|
+
return pollingTimes[pollingTime];
|
48
49
|
}
|
49
50
|
}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import
|
1
|
+
import { RushJobTableUpdateController } from './rush_job_table_update_controller';
|
2
2
|
|
3
3
|
export default class extends RushJobTableUpdateController {
|
4
4
|
reloadJobs() {
|
5
|
-
this.updateJobs()
|
5
|
+
this.updateJobs();
|
6
6
|
}
|
7
7
|
}
|
@@ -1,19 +1,19 @@
|
|
1
|
-
import { Controller } from '@hotwired/stimulus'
|
2
|
-
import Rails from '@rails/ujs'
|
1
|
+
import { Controller } from '@hotwired/stimulus';
|
2
|
+
import Rails from '@rails/ujs';
|
3
3
|
|
4
4
|
export class RushJobTableUpdateController extends Controller {
|
5
5
|
updateJobs() {
|
6
|
-
this.blurTable()
|
6
|
+
this.blurTable();
|
7
7
|
|
8
8
|
Rails.ajax({
|
9
9
|
url: document.location.href,
|
10
10
|
type: 'GET',
|
11
|
-
dataType: 'script'
|
12
|
-
})
|
11
|
+
dataType: 'script',
|
12
|
+
});
|
13
13
|
}
|
14
14
|
|
15
15
|
blurTable() {
|
16
|
-
|
17
|
-
|
16
|
+
const jobsContainer = document.getElementById('rush-job-jobs-container');
|
17
|
+
jobsContainer.classList.add('table-refresh');
|
18
18
|
}
|
19
19
|
}
|
@@ -15,6 +15,19 @@ module RushJob
|
|
15
15
|
page_param: :queue_page)
|
16
16
|
end
|
17
17
|
|
18
|
+
def destroy
|
19
|
+
RushJob.clear_queue(queue_params[:queue], queue_params[:priority])
|
20
|
+
|
21
|
+
flash[:success] = t(:cleared_queue, queue: queue_params[:queue])
|
22
|
+
redirect_to root_path, status: :see_other
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def queue_params
|
28
|
+
params.permit(:queue, :priority)
|
29
|
+
end
|
30
|
+
|
18
31
|
def redirect_to_first_page
|
19
32
|
redirect_to root_path, notice: t(:invalid_page_notice)
|
20
33
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RushJob
|
2
|
+
class SettingsController < ApplicationController
|
3
|
+
def update
|
4
|
+
change_setting if Settings::RUSH_JOB_SETTINGS[params[:setting]&.to_sym]
|
5
|
+
|
6
|
+
redirect_to root_path
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def change_setting
|
12
|
+
setting_param = params[:setting]
|
13
|
+
setting_cookie = "rush_job_#{setting_param}"
|
14
|
+
|
15
|
+
cookies.permanent[setting_cookie.to_sym] = Settings.change_setting(setting_param, cookies[setting_cookie.to_sym])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RushJob
|
2
|
+
module SettingsHelper
|
3
|
+
def current_theme
|
4
|
+
cookies[:rush_job_theme] == 'dark' ? 'dark' : 'light'
|
5
|
+
end
|
6
|
+
|
7
|
+
def invert_theme
|
8
|
+
cookies[:rush_job_theme] == 'dark' ? 'light' : 'dark'
|
9
|
+
end
|
10
|
+
|
11
|
+
def editing_enabled?
|
12
|
+
cookies[:rush_job_editing] == 'enabled'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -4,6 +4,11 @@ module RushJob
|
|
4
4
|
|
5
5
|
scope :locked_jobs, -> { where.not(locked_at: nil).order(locked_at: :desc) }
|
6
6
|
scope :queue_groups, -> { group(:queue, :priority).order(:priority).count }
|
7
|
+
scope :queue_group, ->(queue, priority) { where(queue:).and(where(priority:)) }
|
8
|
+
|
9
|
+
def self.clear_queue(queue, priority)
|
10
|
+
queue_group(queue, priority).delete_all
|
11
|
+
end
|
7
12
|
|
8
13
|
def job_class
|
9
14
|
job_data[:job_class]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RushJob
|
2
|
+
class Settings
|
3
|
+
RUSH_JOB_SETTINGS = {
|
4
|
+
theme: %w[light dark],
|
5
|
+
editing: %w[disabled enabled]
|
6
|
+
}.freeze
|
7
|
+
|
8
|
+
def self.change_setting(setting, value)
|
9
|
+
return unless RUSH_JOB_SETTINGS[setting.to_sym]
|
10
|
+
|
11
|
+
if RUSH_JOB_SETTINGS[setting.to_sym][1] == value
|
12
|
+
RUSH_JOB_SETTINGS[setting.to_sym][0]
|
13
|
+
else
|
14
|
+
RUSH_JOB_SETTINGS[setting.to_sym][1]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -22,8 +22,24 @@
|
|
22
22
|
<li class="nav-item">
|
23
23
|
<%= link_to t(:jobs), rush_jobs_path, class: "nav-link#{' active' if current_page?(rush_jobs_path)}" %>
|
24
24
|
</li>
|
25
|
-
<li class="nav-item">
|
26
|
-
|
25
|
+
<li class="nav-item dropdown">
|
26
|
+
<a class="nav-link dropdown-toggle"
|
27
|
+
data-bs-toggle="dropdown"
|
28
|
+
href="#" role="button"
|
29
|
+
aria-haspopup="true"
|
30
|
+
aria-expanded="false">
|
31
|
+
Options
|
32
|
+
</a>
|
33
|
+
<div class="dropdown-menu"
|
34
|
+
data-bs-popper="static">
|
35
|
+
<%= button_to t("#{invert_theme}_mode"), settings_path, class: "nav-link", method: :patch, params: { setting: 'theme' } %>
|
36
|
+
<%= button_to t("#{editing_enabled? ? 'disable_editing' : 'enable_editing'}"),
|
37
|
+
settings_path,
|
38
|
+
class: "nav-link",
|
39
|
+
method: :patch,
|
40
|
+
params: { setting: 'editing' },
|
41
|
+
data: { confirm: t("#{editing_enabled? ? 'disable_editing_confirmation' : 'enable_editing_confirmation'}") } %>
|
42
|
+
</div>
|
27
43
|
</li>
|
28
44
|
</ul>
|
29
45
|
</div>
|
@@ -12,11 +12,9 @@
|
|
12
12
|
</head>
|
13
13
|
<body class="background-color-<%= current_theme %>">
|
14
14
|
<%= render 'layouts/rush_job/navbar' %>
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
</div>
|
19
|
-
<% end %>
|
15
|
+
<div id="rush-job-flash-messages">
|
16
|
+
<%= render 'layouts/rush_job/flash_messages' %>
|
17
|
+
</div>
|
20
18
|
|
21
19
|
<%= yield %>
|
22
20
|
|
@@ -53,6 +53,9 @@
|
|
53
53
|
<th><%= t :name %></th>
|
54
54
|
<th><%= t :priority %></th>
|
55
55
|
<th><%= t :count %></th>
|
56
|
+
<% if editing_enabled? %>
|
57
|
+
<th><%= t :clear %></th>
|
58
|
+
<% end %>
|
56
59
|
</tr>
|
57
60
|
</thead>
|
58
61
|
<tbody class="table-group-divider">
|
@@ -61,6 +64,14 @@
|
|
61
64
|
<td><%= queue[0] %></td>
|
62
65
|
<td><%= queue[1] %></td>
|
63
66
|
<td><%= @queue_groups[queue] %></td>
|
67
|
+
<% if editing_enabled? %>
|
68
|
+
<td><%= button_to t(:clear),
|
69
|
+
dashboard_path,
|
70
|
+
class: "btn btn-danger btn-sm",
|
71
|
+
method: :delete,
|
72
|
+
params: { queue: queue[0], priority: queue[1] },
|
73
|
+
data: { confirm: t(:clear_queue_confirmation, queue: queue[0]) } %></td>
|
74
|
+
<% end %>
|
64
75
|
</tr>
|
65
76
|
<% end %>
|
66
77
|
</tbody>
|
data/config/locales/en.yml
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
en:
|
2
2
|
arguments: "Arguments"
|
3
3
|
attempts: "Attempts"
|
4
|
+
clear: "Clear"
|
5
|
+
clear_queue_confirmation: "Are you sure you want to clear queue %{queue}?"
|
6
|
+
cleared_queue: "Cleared queue %{queue}"
|
4
7
|
count: "Count"
|
5
8
|
dark_mode: "Dark Mode"
|
6
9
|
dashboard: "Dashboard"
|
7
10
|
delayed_title: "Delayed Jobs"
|
11
|
+
disable_editing: "Disable Editing"
|
12
|
+
disable_editing_confirmation: "Are you sure?"
|
13
|
+
enable_editing: "Enable Editing"
|
14
|
+
enable_editing_confirmation: "Are you sure? Verify workers are stopped before editing."
|
8
15
|
enable_polling: "Enable polling"
|
9
16
|
failed_at: "Failed at"
|
10
17
|
id: "Id"
|
data/config/routes.rb
CHANGED
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.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JavaKoala
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09
|
11
|
+
date: 2023-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -304,13 +304,16 @@ files:
|
|
304
304
|
- app/controllers/rush_job/application_controller.rb
|
305
305
|
- app/controllers/rush_job/dashboard_controller.rb
|
306
306
|
- app/controllers/rush_job/rush_jobs_controller.rb
|
307
|
-
- app/controllers/rush_job/
|
307
|
+
- app/controllers/rush_job/settings_controller.rb
|
308
308
|
- app/helpers/rush_job/application_helper.rb
|
309
309
|
- app/helpers/rush_job/dashboard_helper.rb
|
310
310
|
- app/helpers/rush_job/rush_jobs_helper.rb
|
311
|
+
- app/helpers/rush_job/settings_helper.rb
|
311
312
|
- app/helpers/rush_job/sort_helper.rb
|
312
313
|
- app/models/rush_job/application_record.rb
|
313
314
|
- app/models/rush_job/rush_job.rb
|
315
|
+
- app/services/rush_job/settings.rb
|
316
|
+
- app/views/layouts/rush_job/_flash_messages.html.erb
|
314
317
|
- app/views/layouts/rush_job/_navbar.html.erb
|
315
318
|
- app/views/layouts/rush_job/application.html.erb
|
316
319
|
- app/views/rush_job/dashboard/_dashboard_tables.html.erb
|
@@ -351,7 +354,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
351
354
|
- !ruby/object:Gem::Version
|
352
355
|
version: '0'
|
353
356
|
requirements: []
|
354
|
-
rubygems_version: 3.4.
|
357
|
+
rubygems_version: 3.4.20
|
355
358
|
signing_key:
|
356
359
|
specification_version: 4
|
357
360
|
summary: User interface for delayed_job
|