panoptic 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2139703571c494d033de27157820fd5a897cc8ea964b51ef526a15c2df009fde
4
- data.tar.gz: 1bc481cbaa03329579c5fdc7a58501b2ab00b09afc4952fea960572f787f3c29
3
+ metadata.gz: 7765d548dafa03735d2dc25e0319bb04857aeaff9b4b8394eec1f1f524674eee
4
+ data.tar.gz: a2aa9f24af59985caff5c0d4650f474f727819d247964d54175da407fd5fd3dd
5
5
  SHA512:
6
- metadata.gz: bd1d0d3a182541129e3a84885c69b48ed9145055baeced6df8809fc269c2a62c5479f4253f7ed36fbd420082613c37513ebc92a2bc66b4fa55186ad5f082015c
7
- data.tar.gz: eac99da9fcafbb3be1a2282fbf9e72ce242cc2a0dfd70b58e243de8f31184c4879b701088b144f670687d21359e5eb0971a46ef24614fad9a8085f2c123a174c
6
+ metadata.gz: 0e65e09ed7d09a7e3543e03b04f7c6fb12536b37fab220ce4c5e9170cdcd94093f6dd8105c0f998ee9333817b6ea11372627708c412c9f088e22e1278a14a546
7
+ data.tar.gz: a5ad871749df301daf5e13561cfafe05ae5d1bc8f1a67030560f027c92c4ba4d962beb386ce44a2716411673100ff8c2c6f821b4d9be5d66c20ba932a72aa183
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Panoptic
2
- Short description and motivation.
3
2
 
4
- ## Usage
5
- How to use my plugin.
3
+ [![Gem Version](https://badge.fury.io/rb/panoptic.svg)](https://badge.fury.io/rb/panoptic)
4
+
5
+ Panoptic is a web interface for the [SolidQueue](https://github.com/basecamp/solid_queue) queuing backend.
6
+
7
+ ![](./images/demo.png)
8
+
9
+ While MissionControl is getting ready for release, this gem offers a visual interface for testing purposes with SolidQueue.
6
10
 
7
11
  ## Installation
8
12
  Add this line to your application's Gemfile:
@@ -11,18 +15,23 @@ Add this line to your application's Gemfile:
11
15
  gem "panoptic"
12
16
  ```
13
17
 
14
- And then execute:
15
- ```bash
16
- $ bundle
17
- ```
18
+ Then mount the engine in your `config/routes.rb` file
18
19
 
19
- Or install it yourself as:
20
- ```bash
21
- $ gem install panoptic
20
+ ```ruby
21
+ mount Panoptic::Engine => "/panoptic"
22
22
  ```
23
23
 
24
- ## Contributing
25
- Contribution directions go here.
24
+ ## Usage
25
+
26
+ Once the gem is installed and the Engine mounted, visit your engine route to access Panoptic. For now, it offers three views:
27
+ - Processes
28
+ - Queues
29
+ - A first version of the jobs view
30
+
31
+ In the near future, the following features could be implemented:
32
+ - Pause and clear queues
33
+ - Advanced jobs view, with filters for executed, failed and scheduled jobs
34
+ - Search and retries
26
35
 
27
36
  ## License
28
37
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,4 +1,5 @@
1
1
  module Panoptic
2
2
  class ApplicationController < ActionController::Base
3
+ include Pagy::Backend
3
4
  end
4
5
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Panoptic
4
+ class Jobs::FailedController < ApplicationController
5
+ def index
6
+ # TODO: use the `failed` scope available in SolidQueue next release
7
+ @pagy, @jobs = pagy(
8
+ SolidQueue::Job.joins(:failed_execution).order(created_at: :asc)
9
+ )
10
+
11
+ render "panoptic/jobs/index"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Panoptic
4
+ class Jobs::ScheduledController < ApplicationController
5
+ def index
6
+ # TODO: use the `scheduled` scope available in SolidQueue next release
7
+ @pagy, @jobs = pagy(
8
+ SolidQueue::Job.joins(:scheduled_execution).order(created_at: :asc)
9
+ )
10
+
11
+ render "panoptic/jobs/index"
12
+ end
13
+ end
14
+ end
@@ -3,7 +3,7 @@
3
3
  module Panoptic
4
4
  class JobsController < ApplicationController
5
5
  def index
6
- @jobs = SolidQueue::Job.order(created_at: :asc).page(params[:page])
6
+ @pagy, @jobs = pagy(SolidQueue::Job.order(created_at: :asc))
7
7
  end
8
8
  end
9
9
  end
@@ -1,4 +1,6 @@
1
1
  module Panoptic
2
2
  module ApplicationHelper
3
+ include Pagy::Frontend
4
+ include DateTimeHelper
3
5
  end
4
6
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Panoptic
4
+ module DateTimeHelper
5
+ def safe_time_tag(date_or_time, *args, &block)
6
+ return "-" unless date_or_time
7
+
8
+ time_tag(date_or_time, *args, &block)
9
+ end
10
+ end
11
+ end
@@ -2,7 +2,6 @@
2
2
  <th scope="row"><%= job.id %></th>
3
3
  <td scope="col"><%= job.class_name %></td>
4
4
  <td scope="col"><%= job.queue_name %></td>
5
- <td scope="col"><%= job.arguments %></td>
6
- <td scope="col"><% job.scheduled_at %></td>
7
- <td scope="col"><% job.finished_at %></td>
5
+ <td scope="col"><%= safe_time_tag job.scheduled_at %></td>
6
+ <td scope="col"><%= safe_time_tag job.finished_at %></td>
8
7
  </tr>
@@ -1,9 +1,19 @@
1
1
  <h1>Jobs</h1>
2
2
 
3
+ <ul class="nav nav-underline">
4
+ <li class="nav-item">
5
+ <%= link_to "All", jobs_path, class: class_names("nav-link", "active": current_page?(jobs_path)) %>
6
+ </li>
7
+ <li class="nav-item">
8
+ <%= link_to "Scheduled", scheduled_jobs_path, class: class_names("nav-link", "active": current_page?(scheduled_jobs_path)) %>
9
+ </li>
10
+ <li class="nav-item">
11
+ <%= link_to "Failed", failed_jobs_path, class: class_names("nav-link", "active": current_page?(failed_jobs_path)) %>
12
+ </li>
13
+ </ul>
14
+
3
15
  <div class="d-flex justify-content-end">
4
- <div>
5
- <%= page_entries_info @jobs %>
6
- </div>
16
+ <%== pagy_info(@pagy) %>
7
17
  </div>
8
18
 
9
19
  <table class="table">
@@ -12,17 +22,16 @@
12
22
  <th scope="col">#</th>
13
23
  <th scope="col">Class</th>
14
24
  <th scope="col">Queue</th>
15
- <th scope="col">Arguments</th>
16
- <th scope="col">Scheduled at</th>
17
- <th scope="col">Finished at</th>
25
+ <th scope="col">Scheduled</th>
26
+ <th scope="col">Finished</th>
18
27
  </tr>
19
28
  </thead>
20
29
 
21
30
  <tbody>
22
- <%= render partial: "job", collection: @jobs %>
31
+ <%= render partial: "panoptic/jobs/job", collection: @jobs %>
23
32
  </tbody>
24
33
  </table>
25
34
 
26
35
  <div class="d-flex justify-content-center">
27
- <%= paginate @jobs, views_prefix: "panoptic" %>
36
+ <%== pagy_bootstrap_nav(@pagy) if @pagy.pages > 1 %>
28
37
  </div>
@@ -0,0 +1 @@
1
+ require "pagy/extras/bootstrap"
data/config/routes.rb CHANGED
@@ -2,5 +2,13 @@ Panoptic::Engine.routes.draw do
2
2
  root to: "processes#index"
3
3
 
4
4
  resources :queues, only: [:index]
5
- resources :jobs, only: [:index]
5
+
6
+ scope "jobs" do
7
+ get "all", to: "jobs#index", as: "jobs"
8
+
9
+ scope module: "jobs" do
10
+ resources :scheduled, only: :index, as: :scheduled_jobs
11
+ resources :failed, only: :index, as: :failed_jobs
12
+ end
13
+ end
6
14
  end
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pagy"
4
+
1
5
  module Panoptic
2
6
  class Engine < ::Rails::Engine
3
7
  isolate_namespace Panoptic
@@ -1,3 +1,3 @@
1
1
  module Panoptic
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panoptic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Rolea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-28 00:00:00.000000000 Z
11
+ date: 2023-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.1'
41
41
  - !ruby/object:Gem::Dependency
42
- name: kaminari
42
+ name: pagy
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.2'
47
+ version: '6.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.2'
54
+ version: '6.2'
55
55
  description: Web interface for the SoldiQueue queuing backend
56
56
  email:
57
57
  - 3525369+virolea@users.noreply.github.com
@@ -63,10 +63,13 @@ files:
63
63
  - README.md
64
64
  - Rakefile
65
65
  - app/controllers/panoptic/application_controller.rb
66
+ - app/controllers/panoptic/jobs/failed_controller.rb
67
+ - app/controllers/panoptic/jobs/scheduled_controller.rb
66
68
  - app/controllers/panoptic/jobs_controller.rb
67
69
  - app/controllers/panoptic/processes_controller.rb
68
70
  - app/controllers/panoptic/queues_controller.rb
69
71
  - app/helpers/panoptic/application_helper.rb
72
+ - app/helpers/panoptic/date_time_helper.rb
70
73
  - app/jobs/panoptic/application_job.rb
71
74
  - app/mailers/panoptic/application_mailer.rb
72
75
  - app/models/panoptic/application_record.rb
@@ -74,18 +77,12 @@ files:
74
77
  - app/views/layouts/panoptic/application.html.erb
75
78
  - app/views/panoptic/jobs/_job.html.erb
76
79
  - app/views/panoptic/jobs/index.html.erb
77
- - app/views/panoptic/kaminari/_first_page.html.erb
78
- - app/views/panoptic/kaminari/_gap.html.erb
79
- - app/views/panoptic/kaminari/_last_page.html.erb
80
- - app/views/panoptic/kaminari/_next_page.html.erb
81
- - app/views/panoptic/kaminari/_page.html.erb
82
- - app/views/panoptic/kaminari/_paginator.html.erb
83
- - app/views/panoptic/kaminari/_prev_page.html.erb
84
80
  - app/views/panoptic/processes/_process.html.erb
85
81
  - app/views/panoptic/processes/index.html.erb
86
82
  - app/views/panoptic/queues/_queue.html.erb
87
83
  - app/views/panoptic/queues/index.html.erb
88
84
  - app/views/shared/_navbar.html.erb
85
+ - config/initializers/pagy.rb
89
86
  - config/routes.rb
90
87
  - lib/panoptic.rb
91
88
  - lib/panoptic/engine.rb
@@ -1,3 +0,0 @@
1
- <li class="page-item">
2
- <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote, class: 'page-link' %>
3
- </li>
@@ -1,3 +0,0 @@
1
- <li class='page-item disabled'>
2
- <%= link_to raw(t 'views.pagination.truncate'), '#', class: 'page-link' %>
3
- </li>
@@ -1,3 +0,0 @@
1
- <li class="page-item">
2
- <%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, remote: remote, class: 'page-link' %>
3
- </li>
@@ -1,3 +0,0 @@
1
- <li class="page-item">
2
- <%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote, class: 'page-link' %>
3
- </li>
@@ -1,9 +0,0 @@
1
- <% if page.current? %>
2
- <li class="page-item active">
3
- <%= content_tag :a, page, data: { remote: remote }, rel: page.rel, class: 'page-link' %>
4
- </li>
5
- <% else %>
6
- <li class="page-item">
7
- <%= link_to page, url, remote: remote, rel: page.rel, class: 'page-link' %>
8
- </li>
9
- <% end %>
@@ -1,17 +0,0 @@
1
- <%= paginator.render do %>
2
- <nav>
3
- <ul class="pagination">
4
- <%= first_page_tag unless current_page.first? %>
5
- <%= prev_page_tag unless current_page.first? %>
6
- <% each_page do |page| %>
7
- <% if page.left_outer? || page.right_outer? || page.inside_window? %>
8
- <%= page_tag page %>
9
- <% elsif !page.was_truncated? -%>
10
- <%= gap_tag %>
11
- <% end %>
12
- <% end %>
13
- <%= next_page_tag unless current_page.last? %>
14
- <%= last_page_tag unless current_page.last? %>
15
- </ul>
16
- </nav>
17
- <% end %>
@@ -1,3 +0,0 @@
1
- <li class="page-item">
2
- <%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote, class: 'page-link' %>
3
- </li>