panoptic 0.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.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +8 -0
  5. data/app/assets/config/panoptic_manifest.js +1 -0
  6. data/app/assets/stylesheets/panoptic/application.css +15 -0
  7. data/app/controllers/panoptic/application_controller.rb +4 -0
  8. data/app/controllers/panoptic/jobs_controller.rb +9 -0
  9. data/app/controllers/panoptic/processes_controller.rb +9 -0
  10. data/app/controllers/panoptic/queues_controller.rb +9 -0
  11. data/app/helpers/panoptic/application_helper.rb +4 -0
  12. data/app/jobs/panoptic/application_job.rb +4 -0
  13. data/app/mailers/panoptic/application_mailer.rb +6 -0
  14. data/app/models/panoptic/application_record.rb +5 -0
  15. data/app/models/panoptic/process.rb +9 -0
  16. data/app/views/layouts/panoptic/application.html.erb +20 -0
  17. data/app/views/panoptic/jobs/_job.html.erb +8 -0
  18. data/app/views/panoptic/jobs/index.html.erb +28 -0
  19. data/app/views/panoptic/kaminari/_first_page.html.erb +3 -0
  20. data/app/views/panoptic/kaminari/_gap.html.erb +3 -0
  21. data/app/views/panoptic/kaminari/_last_page.html.erb +3 -0
  22. data/app/views/panoptic/kaminari/_next_page.html.erb +3 -0
  23. data/app/views/panoptic/kaminari/_page.html.erb +9 -0
  24. data/app/views/panoptic/kaminari/_paginator.html.erb +17 -0
  25. data/app/views/panoptic/kaminari/_prev_page.html.erb +3 -0
  26. data/app/views/panoptic/processes/_process.html.erb +18 -0
  27. data/app/views/panoptic/processes/index.html.erb +15 -0
  28. data/app/views/panoptic/queues/_queue.html.erb +4 -0
  29. data/app/views/panoptic/queues/index.html.erb +11 -0
  30. data/app/views/shared/_navbar.html.erb +23 -0
  31. data/config/routes.rb +6 -0
  32. data/lib/panoptic/engine.rb +5 -0
  33. data/lib/panoptic/version.rb +3 -0
  34. data/lib/panoptic.rb +6 -0
  35. data/lib/tasks/panoptic_tasks.rake +4 -0
  36. metadata +122 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 243ea0a4585f5384dd5287ce50c678f830f4e3eff5186fd9974eaef89d40a448
4
+ data.tar.gz: 1ccae354aed4823252e3fc8c943ca5d3fb53b5e143c0f6ee0994b22a665a0c27
5
+ SHA512:
6
+ metadata.gz: b926aef681978c208c42ae9420d98e2211e7dd79fbcc6920368317f3e7fac9564736005ceb0cdd38a8ed4aba60d98153bdf2122650402c9a66d6634de996794f
7
+ data.tar.gz: 54cc316be3314aa9d935be5b44d7739ef5fd475c10d3dcef1e89b90a2f8afcd883c5b200debb17ba9b5acc1c12080666d5687e43c277673002e4a34a96096704
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright Vincent Rolea
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Panoptic
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "panoptic"
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install panoptic
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/panoptic .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module Panoptic
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Panoptic
4
+ class JobsController < ApplicationController
5
+ def index
6
+ @jobs = SolidQueue::Job.order(created_at: :asc).page(params[:page])
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Panoptic
4
+ class ProcessesController < ApplicationController
5
+ def index
6
+ @hosts = Process.supervisors.includes(:forks)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Panoptic
4
+ class QueuesController < ApplicationController
5
+ def index
6
+ @queues = SolidQueue::Queue.all
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ module Panoptic
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Panoptic
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Panoptic
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Panoptic
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Panoptic
4
+ class Process
5
+ def self.supervisors
6
+ SolidQueue::Process.where(supervisor_id: nil)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Panoptic</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "panoptic/application", media: "all" %>
9
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
10
+ </head>
11
+ <body>
12
+ <%= render "shared/navbar" %>
13
+
14
+ <main class="container mt-2">
15
+ <%= yield %>
16
+ </main>
17
+
18
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
19
+ </body>
20
+ </html>
@@ -0,0 +1,8 @@
1
+ <tr>
2
+ <th scope="row"><%= job.id %></th>
3
+ <td scope="col"><%= job.class_name %></td>
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>
8
+ </tr>
@@ -0,0 +1,28 @@
1
+ <h1>Jobs</h1>
2
+
3
+ <div class="d-flex justify-content-end">
4
+ <div>
5
+ <%= page_entries_info @jobs %>
6
+ </div>
7
+ </div>
8
+
9
+ <table class="table">
10
+ <thead>
11
+ <tr>
12
+ <th scope="col">#</th>
13
+ <th scope="col">Class</th>
14
+ <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>
18
+ </tr>
19
+ </thead>
20
+
21
+ <tbody>
22
+ <%= render partial: "job", collection: @jobs %>
23
+ </tbody>
24
+ </table>
25
+
26
+ <div class="d-flex justify-content-center">
27
+ <%= paginate @jobs, views_prefix: "panoptic" %>
28
+ </div>
@@ -0,0 +1,3 @@
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>
@@ -0,0 +1,3 @@
1
+ <li class='page-item disabled'>
2
+ <%= link_to raw(t 'views.pagination.truncate'), '#', class: 'page-link' %>
3
+ </li>
@@ -0,0 +1,3 @@
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>
@@ -0,0 +1,3 @@
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>
@@ -0,0 +1,9 @@
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 %>
@@ -0,0 +1,17 @@
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 %>
@@ -0,0 +1,3 @@
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>
@@ -0,0 +1,18 @@
1
+ <li class="list-group-item">
2
+ <h5><%= process.kind %></h5>
3
+
4
+ <div>
5
+ <span class="badge text-bg-primary">PID: <%= process.pid %></span>
6
+ <span class="badge text-bg-secondary">Created: <%= time_ago_in_words process.created_at %></span>
7
+ <span class="badge text-bg-secondary">Last heartbeat: <%= time_ago_in_words process.last_heartbeat_at %></span>
8
+ </div>
9
+
10
+ <div class="mt-2">
11
+ <% process.metadata.each do |setting, value| %>
12
+ <div class="d-flex justify-content-between">
13
+ <div><%= setting %></div>
14
+ <div><%= value %></div>
15
+ </div>
16
+ <% end %>
17
+ </div>
18
+ </li>
@@ -0,0 +1,15 @@
1
+ <h1>Processes</h1>
2
+
3
+ <div class="d-grid gap-3">
4
+ <% @hosts.each do |host| %>
5
+ <div class="card">
6
+ <div class="card-header">
7
+ <b>Host:</b> <%= host.hostname %>
8
+ </div>
9
+
10
+ <ul class="list-group list-group-flush">
11
+ <%= render partial: "process", collection: host.forks %>
12
+ </ul>
13
+ </div>
14
+ <% end %>
15
+ </div>
@@ -0,0 +1,4 @@
1
+ <li class="list-group-item">
2
+ <b><%= queue.name %></b>
3
+ <span class="badge text-bg-primary">Size: <%= queue.size %></span>
4
+ </li>
@@ -0,0 +1,11 @@
1
+ <h1>Queues</h1>
2
+
3
+ <div class="card">
4
+ <div class="card-header">
5
+ Queue name
6
+ </div>
7
+
8
+ <ul class="list-group list-group-flush">
9
+ <%= render partial: "queue", collection: @queues %>
10
+ </ul>
11
+ </div>
@@ -0,0 +1,23 @@
1
+ <nav class="navbar navbar-expand-lg bg-body-tertiary">
2
+ <div class="container-fluid">
3
+ <%= link_to "Panoptic", root_path, class: "navbar-brand" %>
4
+ <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
5
+ <span class="navbar-toggler-icon"></span>
6
+ </button>
7
+ <div class="collapse navbar-collapse" id="navbarNav">
8
+ <ul class="navbar-nav">
9
+ <li class="nav-item">
10
+ <%= link_to "Processes", root_path, class: class_names("nav-link", "active": current_page?(root_path)) %>
11
+ </li>
12
+
13
+ <li class="nav-item">
14
+ <%= link_to "Queues", queues_path, class: class_names("nav-link", "active": current_page?(queues_path)) %>
15
+ </li>
16
+
17
+ <li class="nav-item">
18
+ <%= link_to "Jobs", jobs_path, class: class_names("nav-link", "active": current_page?(jobs_path)) %>
19
+ </li>
20
+ </ul>
21
+ </div>
22
+ </div>
23
+ </nav>
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ Panoptic::Engine.routes.draw do
2
+ root to: "processes#index"
3
+
4
+ resources :queues, only: [:index]
5
+ resources :jobs, only: [:index]
6
+ end
@@ -0,0 +1,5 @@
1
+ module Panoptic
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Panoptic
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Panoptic
2
+ VERSION = "0.1.0"
3
+ end
data/lib/panoptic.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "panoptic/version"
2
+ require "panoptic/engine"
3
+
4
+ module Panoptic
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :panoptic do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: panoptic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vincent Rolea
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '7.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: solid_queue
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: kaminari
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
55
+ description: Web interface for the SoldiQueue queuing backend
56
+ email:
57
+ - 3525369+virolea@users.noreply.github.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/assets/config/panoptic_manifest.js
66
+ - app/assets/stylesheets/panoptic/application.css
67
+ - app/controllers/panoptic/application_controller.rb
68
+ - app/controllers/panoptic/jobs_controller.rb
69
+ - app/controllers/panoptic/processes_controller.rb
70
+ - app/controllers/panoptic/queues_controller.rb
71
+ - app/helpers/panoptic/application_helper.rb
72
+ - app/jobs/panoptic/application_job.rb
73
+ - app/mailers/panoptic/application_mailer.rb
74
+ - app/models/panoptic/application_record.rb
75
+ - app/models/panoptic/process.rb
76
+ - app/views/layouts/panoptic/application.html.erb
77
+ - app/views/panoptic/jobs/_job.html.erb
78
+ - app/views/panoptic/jobs/index.html.erb
79
+ - app/views/panoptic/kaminari/_first_page.html.erb
80
+ - app/views/panoptic/kaminari/_gap.html.erb
81
+ - app/views/panoptic/kaminari/_last_page.html.erb
82
+ - app/views/panoptic/kaminari/_next_page.html.erb
83
+ - app/views/panoptic/kaminari/_page.html.erb
84
+ - app/views/panoptic/kaminari/_paginator.html.erb
85
+ - app/views/panoptic/kaminari/_prev_page.html.erb
86
+ - app/views/panoptic/processes/_process.html.erb
87
+ - app/views/panoptic/processes/index.html.erb
88
+ - app/views/panoptic/queues/_queue.html.erb
89
+ - app/views/panoptic/queues/index.html.erb
90
+ - app/views/shared/_navbar.html.erb
91
+ - config/routes.rb
92
+ - lib/panoptic.rb
93
+ - lib/panoptic/engine.rb
94
+ - lib/panoptic/version.rb
95
+ - lib/tasks/panoptic_tasks.rake
96
+ homepage: https://github.com/virolea/panoptic
97
+ licenses:
98
+ - MIT
99
+ metadata:
100
+ homepage_uri: https://github.com/virolea/panoptic
101
+ source_code_uri: https://github.com/virolea/panoptic
102
+ changelog_uri: https://github.com/virolea/panoptic/blob/main/CHANGELOG.md
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.3.26
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Web interface for the SoldiQueue queuing backend
122
+ test_files: []