rush_job 0.4.0 → 0.5.1

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: 9f24031055b7af192d199277995a02156d089d208ef07037c75d5ebcafabaaf1
4
- data.tar.gz: 697f98385692da3bcbe8ff8b5971b222fcf93a1c3df34ef9e4544e86dc51fd6f
3
+ metadata.gz: 2656877c04c7bf364e6b009dde59e1b4169ec229cb011c8b973587f07185026b
4
+ data.tar.gz: d91245e38016a4a0be1e35ee9c8085d6a75580d4bf858cd37c88383e119f33f9
5
5
  SHA512:
6
- metadata.gz: b9a83f701a00989f02da32d816bae209b90576eff5ab2ca3e2c0930f0a876294faf29dc88267847a65f82d6aa159e1ddce3e56839d5cf1f2df1c532d05e39fd8
7
- data.tar.gz: '0810045ea1fee244ad1a5ec8bb2d71728546d4d760e0e344bca5d93292c7c1d775fdbff34f1094cc202290b50ef15655c8ce5ce5189782868367fe0bba2ce079'
6
+ metadata.gz: 3c5b8bf4ef1138187b56cd5081aa8ff64a2cf73b3d05222501f7330bbd7f2816c30df2b7e696fd03b4a0442bde77990fdf00c6a8d863e1485218d274806192a9
7
+ data.tar.gz: 174ced87e1345741f9ffc26e8c5819c67b7d943a5b28ddf9e28afc225c65c2bbf477b9eafae11aba923c9bc554a8652fc4a834bf8bfcf0843536f0d693647aa6
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # RushJob
2
2
  User interface for Delayed Job (https://github.com/collectiveidea/delayed_job) in Ruby on Rails
3
3
 
4
+ <img width="656" alt="Dashboard" src="docs/assets/dashboard.png">
5
+ <img width="1244" alt="Jobs" src="docs/assets/jobs.png">
6
+
4
7
  ### Note
5
8
  - This has only been tested with SQLite and Postgresql.
6
9
  - This app uses cookies to store the dark mode selection.
@@ -14,7 +17,7 @@ Navigate to the `/rush_job` route in your application to see the Delayed Jobs. L
14
17
  Add this line to your Ruby on Rails application's Gemfile:
15
18
 
16
19
  ```ruby
17
- gem 'rush_job', '~> 0.4.0'
20
+ gem 'rush_job', '~> 0.5.1'
18
21
  ```
19
22
 
20
23
  And then execute:
@@ -12,6 +12,8 @@
12
12
  *
13
13
  */
14
14
  @import "../../../vendor/stylesheets/rush_job/bootstrap";
15
+ @import "components/pagination";
16
+ @import "components/polling";
15
17
  @import "themes/dark";
16
18
  @import "themes/light";
17
- @import "pages/index";
19
+ @import "pages/rush_jobs_index";
@@ -0,0 +1,15 @@
1
+ .page-link.disabled, .disabled > .page-link {
2
+ color: rgb(68, 110, 155);
3
+ }
4
+
5
+ .page-item:first-child .page-link {
6
+ color: rgb(68, 110, 155);
7
+ }
8
+
9
+ .page-item:last-child .page-link {
10
+ color: rgb(68, 110, 155);
11
+ }
12
+
13
+ .page-link {
14
+ color: rgb(68, 110, 155);
15
+ }
@@ -0,0 +1,26 @@
1
+ .polling-container {
2
+ margin-left: 5%;
3
+ margin-right: 5%;
4
+ }
5
+
6
+ .polling-range-form-label-dark {
7
+ color: rgb(0, 0, 0);
8
+ margin-bottom: 0.5rem;
9
+ }
10
+
11
+ .polling-range-form-label-light {
12
+ color: rgb(255, 255, 255);
13
+ margin-bottom: 0.5rem;
14
+ }
15
+
16
+ .form-check-label-dark {
17
+ color: rgb(0, 0, 0);
18
+ }
19
+
20
+ .form-check-label-light {
21
+ color: rgb(255, 255, 255);
22
+ }
23
+
24
+ .table-refresh {
25
+ opacity: 0.3;
26
+ }
@@ -0,0 +1,10 @@
1
+ .jobs-container {
2
+ margin-left: 5%;
3
+ margin-right: 5%;
4
+ }
5
+
6
+ .footer-container {
7
+ margin-left: 5%;
8
+ margin-right: 5%;
9
+ float: right;
10
+ }
@@ -1,3 +1,7 @@
1
1
  .background-color-dark {
2
2
  background-color: #000;
3
3
  }
4
+
5
+ .color-dark {
6
+ color: #000;
7
+ }
@@ -1,3 +1,7 @@
1
1
  .background-color-light {
2
2
  background-color: #fff;
3
3
  }
4
+
5
+ .color-light {
6
+ color: #fff;
7
+ }
@@ -0,0 +1,22 @@
1
+ module RushJob
2
+ class DashboardController < ApplicationController
3
+ include Pagy::Backend
4
+
5
+ rescue_from Pagy::OverflowError, with: :redirect_to_first_page
6
+
7
+ def index
8
+ @pagy_locked_jobs, @locked_jobs = pagy(RushJob.locked_jobs,
9
+ items: 10,
10
+ page_param: :locked_jobs_page)
11
+
12
+ @queue_groups = RushJob.queue_groups
13
+ @pagy_queue, @job_queues = pagy_array(@queue_groups.keys,
14
+ items: 10,
15
+ page_param: :queue_page)
16
+ end
17
+
18
+ def redirect_to_first_page
19
+ redirect_to root_path, notice: t(:invalid_page_notice)
20
+ end
21
+ end
22
+ end
@@ -17,7 +17,7 @@ module RushJob
17
17
  private
18
18
 
19
19
  def redirect_to_first_page
20
- redirect_to root_path, notice: t(:invalid_page_notice)
20
+ redirect_to rush_jobs_path, notice: t(:invalid_page_notice)
21
21
  end
22
22
  end
23
23
  end
@@ -0,0 +1,5 @@
1
+ module RushJob
2
+ module DashboardHelper
3
+ include Pagy::Frontend
4
+ end
5
+ end
@@ -6,7 +6,7 @@ module RushJob
6
6
 
7
7
  def sortable(column)
8
8
  direction = column == sort_column && sort_direction == 'asc' ? 'desc' : 'asc'
9
- link_to t(column), rush_job.root_path({ sort: column, direction: }), class: "link-#{invert_theme}"
9
+ link_to t(column), rush_job.rush_jobs_path({ sort: column, direction: }), class: "link-#{invert_theme}"
10
10
  end
11
11
 
12
12
  def sort_arrow(column)
@@ -2,6 +2,9 @@ module RushJob
2
2
  class RushJob < ApplicationRecord
3
3
  self.table_name = 'delayed_jobs'
4
4
 
5
+ scope :locked_jobs, -> { where.not(locked_at: nil).order(locked_at: :desc) }
6
+ scope :queue_groups, -> { group(:queue, :priority).order(:priority).count }
7
+
5
8
  def job_class
6
9
  job_data[:job_class]
7
10
  end
@@ -0,0 +1,32 @@
1
+ <div class="bs-component mb-1">
2
+ <nav class="navbar navbar-expand-lg bg-primary"
3
+ data-bs-theme="dark"
4
+ aria-label="Navigation">
5
+ <div class="container-fluid">
6
+ <%= link_to t(:delayed_title), root_path, class: "navbar-brand" %>
7
+ <button class="navbar-toggler"
8
+ type="button"
9
+ data-bs-toggle="collapse"
10
+ data-bs-target="#rush-job-navbar-links"
11
+ aria-controls="rush-job-navbar-links"
12
+ aria-expanded="false"
13
+ aria-label="Toggle navigation">
14
+ <span class="navbar-toggler-icon"></span>
15
+ </button>
16
+
17
+ <div class="collapse navbar-collapse" id="rush-job-navbar-links">
18
+ <ul class="navbar-nav me-auto">
19
+ <li class="nav-item">
20
+ <%= link_to t(:dashboard), root_path, class: "nav-link" %>
21
+ </li>
22
+ <li class="nav-item">
23
+ <%= link_to t(:jobs), rush_jobs_path, class: "nav-link" %>
24
+ </li>
25
+ <li class="nav-item">
26
+ <%= link_to t("#{invert_theme}_mode"), theme_path, class: "nav-link", method: :patch %>
27
+ </li>
28
+ </ul>
29
+ </div>
30
+ </div>
31
+ </nav>
32
+ </div>
@@ -11,6 +11,7 @@
11
11
  <%= stylesheet_link_tag "rush_job/application", media: "all" %>
12
12
  </head>
13
13
  <body class="background-color-<%= current_theme %>">
14
+ <%= render 'layouts/rush_job/navbar' %>
14
15
  <% flash.each do |type, msg| %>
15
16
  <div class="alert alert-<%= invert_theme %>" role="alert">
16
17
  <%= msg %>
@@ -0,0 +1,75 @@
1
+ <div id="rush-job-jobs-container"
2
+ class="jobs-container"
3
+ role="main">
4
+ <div class="d-flex justify-content-left">
5
+ <h2 class="color-<%= invert_theme %>"><%= t :locked_jobs %></h2>
6
+ </div>
7
+ <div id="rush-job-dashboard-locked-jobs" class="mb-2 d-flex justify-content-left">
8
+ <div class="table-responsive">
9
+ <table class="table
10
+ table-bordered
11
+ table-striped
12
+ table-<%= current_theme %>">
13
+ <thead>
14
+ <tr>
15
+ <th><%= t :id %></th>
16
+ <th><%= t :locked_at %></th>
17
+ <th><%= t :locked_by %></th>
18
+ <th><%= t :job_class %></th>
19
+ <th><%= t :arguments %></th>
20
+ </tr>
21
+ </thead>
22
+ <tbody class="table-group-divider">
23
+ <% @locked_jobs.each do |job| %>
24
+ <tr>
25
+ <td><%= job.id %></td>
26
+ <td><%= job.locked_at %></td>
27
+ <td><%= job.locked_by %></td>
28
+ <td><%= job.job_class %></td>
29
+ <td><%= job.job_arguments %></td>
30
+ </tr>
31
+ <% end %>
32
+ </tbody>
33
+ </table>
34
+ </div>
35
+ </div>
36
+ <div id="rush-job-locked-job-pagination"
37
+ class="d-flex justify-content-left"
38
+ data-bs-theme="<%= current_theme %>">
39
+ <%== pagy_bootstrap_nav(@pagy_locked_jobs) if @pagy_locked_jobs.pages > 1 %>
40
+ </div>
41
+
42
+ <div class="d-flex justify-content-left">
43
+ <h2 class="color-<%= invert_theme %>"><%= t :queues %></h2>
44
+ </div>
45
+ <div id="rush-job-dashboard-queues" class="d-flex justify-content-left">
46
+ <div class="table-responsive">
47
+ <table class="table
48
+ table-bordered
49
+ table-striped
50
+ table-<%= current_theme %>">
51
+ <thead>
52
+ <tr>
53
+ <th><%= t :name %></th>
54
+ <th><%= t :priority %></th>
55
+ <th><%= t :count %></th>
56
+ </tr>
57
+ </thead>
58
+ <tbody class="table-group-divider">
59
+ <% @job_queues.each do |queue| %>
60
+ <tr>
61
+ <td><%= queue[0] %></td>
62
+ <td><%= queue[1] %></td>
63
+ <td><%= @queue_groups[queue] %></td>
64
+ </tr>
65
+ <% end %>
66
+ </tbody>
67
+ </table>
68
+ </div>
69
+ </div>
70
+ <div id="rush-job-locked-queue-pagination"
71
+ class="d-flex justify-content-left"
72
+ data-bs-theme="<%= current_theme %>">
73
+ <%== pagy_bootstrap_nav(@pagy_queue) if @pagy_queue.pages > 1 %>
74
+ </div>
75
+ </div>
@@ -0,0 +1,5 @@
1
+ <%= render 'rush_job/shared/polling' %>
2
+
3
+ <div id="rush-job-jobs">
4
+ <%= render 'dashboard_tables' %>
5
+ </div>
@@ -0,0 +1 @@
1
+ document.getElementById('rush-job-jobs').innerHTML = "<%= j (render partial: 'dashboard_tables') %>"
@@ -1,8 +1,6 @@
1
- <div
2
- id="rush-job-jobs-container"
3
- class="jobs-container"
4
- role="main"
5
- >
1
+ <div id="rush-job-jobs-container"
2
+ class="jobs-container"
3
+ role="main">
6
4
  <div class="table-responsive">
7
5
  <table class="table
8
6
  table-bordered
@@ -44,6 +42,6 @@
44
42
  </div>
45
43
  </div>
46
44
 
47
- <div class="footer-container">
45
+ <div class="footer-container" data-bs-theme="<%= current_theme %>">
48
46
  <%== pagy_bootstrap_nav(@pagy) if @pagy.pages > 1 %>
49
47
  </div>
@@ -1,59 +1,5 @@
1
- <div class="header-container" role="heading" aria-level="1">
2
- <div class="container text-center">
3
- <div class="row align-items-center">
4
- <div class="col-6" role="banner">
5
- <h2 class="delayed_title">
6
- <%= t :delayed_title %>
7
- </h2>
8
- </div>
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>
11
- </div>
12
- <div class="col-3">
13
- <%= form_with url: theme_path, method: 'patch' do |form| %>
14
- <%= form.button "#{invert_theme.titleize} Mode", class: "btn btn-#{invert_theme}" %>
15
- <% end %>
16
- </div>
17
- </div>
18
- </div>
19
- </div>
20
-
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>
54
- </div>
55
- </div>
1
+ <%= render 'rush_job/shared/polling' %>
56
2
 
57
- <div id="rush-job-jobs-table">
3
+ <div id="rush-job-jobs">
58
4
  <%= render 'jobs_table' %>
59
5
  </div>
@@ -1 +1 @@
1
- document.getElementById('rush-job-jobs-table').innerHTML = "<%= j (render partial: 'jobs_table') %>"
1
+ document.getElementById('rush-job-jobs').innerHTML = "<%= j (render partial: 'jobs_table') %>"
@@ -0,0 +1,32 @@
1
+ <div class="polling-container" data-controller="rush-job-polling">
2
+ <div class="row align-items-center">
3
+ <div class="col-3">
4
+ <label for="rush-job-polling-range"
5
+ class="polling-range-form-label-<%= invert_theme %>"
6
+ data-rush-job-polling-target="pollingTimeLabel">
7
+ <%= t :polling_time %> 13 <%= t :polling_time_unit %>
8
+ </label>
9
+ <input id="rush-job-polling-range"
10
+ type="range"
11
+ class="form-range"
12
+ min="0"
13
+ max="6"
14
+ data-rush-job-polling-target="pollingTime"
15
+ data-action="input->rush-job-polling#pollingChange">
16
+ </div>
17
+ <div class="col-3">
18
+ <div class="form-check form-switch">
19
+ <input id="rush-job-polling"
20
+ class="form-check-input"
21
+ type="checkbox"
22
+ role="switch"
23
+ data-rush-job-polling-target="pollingSlide"
24
+ data-action="input->rush-job-polling#pollingToggle">
25
+ <label class="form-check-label-<%= invert_theme %>" for="rush-job-polling"><%= t :enable_polling %></label>
26
+ </div>
27
+ </div>
28
+ <div class="col-3" data-controller="rush-job-reload-jobs-table">
29
+ <button class="btn btn-primary" data-action="click->rush-job-reload-jobs-table#reloadJobs"><%= t :reload %></button>
30
+ </div>
31
+ </div>
32
+ </div>
@@ -1,18 +1,26 @@
1
1
  en:
2
2
  arguments: "Arguments"
3
3
  attempts: "Attempts"
4
- delayed_title: "Delayed jobs"
4
+ count: "Count"
5
+ dark_mode: "Dark Mode"
6
+ dashboard: "Dashboard"
7
+ delayed_title: "Delayed Jobs"
5
8
  enable_polling: "Enable polling"
6
9
  failed_at: "Failed at"
7
10
  id: "Id"
8
11
  invalid_page_notice: "No jobs on that page, redirected to first page."
9
12
  job_class: "Job class"
13
+ jobs: "Jobs"
10
14
  last_error: "Last error"
15
+ light_mode: "Light Mode"
11
16
  locked_at: "Locked at"
12
17
  locked_by: "Locked by"
18
+ locked_jobs: "Locked Jobs"
19
+ name: "Name"
13
20
  polling_time: "Polling time:"
14
21
  polling_time_unit: "seconds"
15
22
  priority: "Priority"
16
23
  queue: "Queue"
24
+ queues: "Queues"
17
25
  reload: "Reload"
18
- run_at: "Run at"
26
+ run_at: "Run at"
data/config/routes.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  RushJob::Engine.routes.draw do
2
- root 'rush_jobs#index'
2
+ root 'dashboard#index'
3
+ get '/rush_jobs', to: 'rush_jobs#index'
3
4
  patch '/theme', to: 'themes#update'
4
5
  end
@@ -1,6 +1,7 @@
1
1
  module RushJob
2
2
  require 'importmap-rails'
3
3
  require 'pagy'
4
+ require 'pagy/extras/array'
4
5
  require 'pagy/extras/bootstrap'
5
6
  require 'sassc-rails'
6
7
 
@@ -1,3 +1,3 @@
1
1
  module RushJob
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.1'.freeze
3
3
  end
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.0
4
+ version: 0.5.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-08-20 00:00:00.000000000 Z
11
+ date: 2023-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -212,28 +212,28 @@ dependencies:
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '2.20'
215
+ version: '2.21'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: '2.20'
222
+ version: '2.21'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: selenium-webdriver
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '4.10'
229
+ version: '4.12'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '4.10'
236
+ version: '4.12'
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: simplecov
239
239
  requirement: !ruby/object:Gem::Requirement
@@ -296,21 +296,30 @@ files:
296
296
  - app/assets/javascript/rush_job/controllers/rush_job_reload_jobs_table_controller.js
297
297
  - app/assets/javascript/rush_job/controllers/rush_job_table_update_controller.js
298
298
  - app/assets/stylesheets/rush_job/application.scss
299
- - app/assets/stylesheets/rush_job/pages/_index.scss
299
+ - app/assets/stylesheets/rush_job/components/_pagination.scss
300
+ - app/assets/stylesheets/rush_job/components/_polling.scss
301
+ - app/assets/stylesheets/rush_job/pages/_rush_jobs_index.scss
300
302
  - app/assets/stylesheets/rush_job/themes/_dark.scss
301
303
  - app/assets/stylesheets/rush_job/themes/_light.scss
302
304
  - app/controllers/rush_job/application_controller.rb
305
+ - app/controllers/rush_job/dashboard_controller.rb
303
306
  - app/controllers/rush_job/rush_jobs_controller.rb
304
307
  - app/controllers/rush_job/themes_controller.rb
305
308
  - app/helpers/rush_job/application_helper.rb
309
+ - app/helpers/rush_job/dashboard_helper.rb
306
310
  - app/helpers/rush_job/rush_jobs_helper.rb
307
311
  - app/helpers/rush_job/sort_helper.rb
308
312
  - app/models/rush_job/application_record.rb
309
313
  - app/models/rush_job/rush_job.rb
314
+ - app/views/layouts/rush_job/_navbar.html.erb
310
315
  - app/views/layouts/rush_job/application.html.erb
316
+ - app/views/rush_job/dashboard/_dashboard_tables.html.erb
317
+ - app/views/rush_job/dashboard/index.html.erb
318
+ - app/views/rush_job/dashboard/index.js.erb
311
319
  - app/views/rush_job/rush_jobs/_jobs_table.html.erb
312
320
  - app/views/rush_job/rush_jobs/index.html.erb
313
321
  - app/views/rush_job/rush_jobs/index.js.erb
322
+ - app/views/rush_job/shared/_polling.html.erb
314
323
  - config/importmap.rb
315
324
  - config/locales/en.yml
316
325
  - config/routes.rb
@@ -1,62 +0,0 @@
1
- .header-container {
2
- background-color: #d3d3d3;
3
- border-radius: 10px;
4
- margin-top: 1em;
5
- margin-bottom: 1em;
6
- margin-left: 5%;
7
- margin-right: 5%;
8
- }
9
-
10
- .delayed_title {
11
- margin-top: 0.5rem;
12
- }
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
-
37
- .jobs-container {
38
- margin-left: 5%;
39
- margin-right: 5%;
40
- }
41
-
42
- .footer-container {
43
- margin-left: 5%;
44
- margin-right: 5%;
45
- float: right;
46
- }
47
-
48
- .page-link.disabled, .disabled > .page-link {
49
- color: rgb(68, 110, 155);
50
- }
51
-
52
- .page-item:first-child .page-link {
53
- color: rgb(68, 110, 155);
54
- }
55
-
56
- .page-item:last-child .page-link {
57
- color: rgb(68, 110, 155);
58
- }
59
-
60
- .table-refresh {
61
- opacity: 0.3;
62
- }