rails_pulse 0.2.3 → 0.2.4

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/controllers/concerns/chart_table_concern.rb +2 -3
  4. data/app/controllers/rails_pulse/application_controller.rb +10 -3
  5. data/app/controllers/rails_pulse/queries_controller.rb +1 -1
  6. data/app/controllers/rails_pulse/requests_controller.rb +2 -1
  7. data/app/controllers/rails_pulse/routes_controller.rb +1 -1
  8. data/app/helpers/rails_pulse/application_helper.rb +47 -2
  9. data/app/helpers/rails_pulse/chart_helper.rb +32 -2
  10. data/app/javascript/rails_pulse/application.js +3 -54
  11. data/app/javascript/rails_pulse/controllers/chart_controller.js +229 -0
  12. data/app/javascript/rails_pulse/controllers/index_controller.js +9 -14
  13. data/app/javascript/rails_pulse/controllers/pagination_controller.js +27 -33
  14. data/app/jobs/rails_pulse/backfill_summaries_job.rb +0 -2
  15. data/app/jobs/rails_pulse/cleanup_job.rb +0 -2
  16. data/app/jobs/rails_pulse/summary_job.rb +0 -2
  17. data/app/models/rails_pulse/queries/charts/average_query_times.rb +1 -1
  18. data/app/models/rails_pulse/requests/charts/average_response_times.rb +1 -1
  19. data/app/models/rails_pulse/routes/charts/average_response_times.rb +1 -1
  20. data/app/views/rails_pulse/components/_metric_card.html.erb +2 -2
  21. data/app/views/rails_pulse/components/_sparkline_stats.html.erb +1 -1
  22. data/app/views/rails_pulse/components/_table_pagination.html.erb +8 -6
  23. data/app/views/rails_pulse/csp_test/show.html.erb +1 -1
  24. data/app/views/rails_pulse/dashboard/charts/_bar_chart.html.erb +1 -1
  25. data/app/views/rails_pulse/dashboard/index.html.erb +4 -3
  26. data/app/views/rails_pulse/queries/index.html.erb +2 -1
  27. data/app/views/rails_pulse/queries/show.html.erb +2 -1
  28. data/app/views/rails_pulse/routes/index.html.erb +2 -1
  29. data/app/views/rails_pulse/routes/show.html.erb +2 -1
  30. data/config/importmap.rb +1 -1
  31. data/lib/rails_pulse/engine.rb +0 -30
  32. data/lib/rails_pulse/version.rb +1 -1
  33. data/public/rails-pulse-assets/csp-test.js +10 -10
  34. data/public/rails-pulse-assets/rails-pulse.js +48 -48
  35. data/public/rails-pulse-assets/rails-pulse.js.map +4 -4
  36. metadata +5 -25
  37. data/config/initializers/rails_charts_csp_patch.rb +0 -75
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_pulse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rails Pulse
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-31 00:00:00.000000000 Z
10
+ date: 2025-11-05 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -49,26 +49,6 @@ dependencies:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
51
  version: 1.1.4
52
- - !ruby/object:Gem::Dependency
53
- name: rails_charts
54
- requirement: !ruby/object:Gem::Requirement
55
- requirements:
56
- - - "~>"
57
- - !ruby/object:Gem::Version
58
- version: '0.0'
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: 0.0.6
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.0'
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: 0.0.6
72
52
  - !ruby/object:Gem::Dependency
73
53
  name: turbo-rails
74
54
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +100,7 @@ dependencies:
120
100
  version: '8'
121
101
  - - "<"
122
102
  - !ruby/object:Gem::Version
123
- version: '10'
103
+ version: '44'
124
104
  type: :runtime
125
105
  prerelease: false
126
106
  version_requirements: !ruby/object:Gem::Requirement
@@ -130,7 +110,7 @@ dependencies:
130
110
  version: '8'
131
111
  - - "<"
132
112
  - !ruby/object:Gem::Version
133
- version: '10'
113
+ version: '44'
134
114
  - !ruby/object:Gem::Dependency
135
115
  name: groupdate
136
116
  requirement: !ruby/object:Gem::Requirement
@@ -225,6 +205,7 @@ files:
225
205
  - app/helpers/rails_pulse/table_helper.rb
226
206
  - app/helpers/rails_pulse/tags_helper.rb
227
207
  - app/javascript/rails_pulse/application.js
208
+ - app/javascript/rails_pulse/controllers/chart_controller.js
228
209
  - app/javascript/rails_pulse/controllers/collapsible_controller.js
229
210
  - app/javascript/rails_pulse/controllers/color_scheme_controller.js
230
211
  - app/javascript/rails_pulse/controllers/context_menu_controller.js
@@ -332,7 +313,6 @@ files:
332
313
  - app/views/rails_pulse/skeletons/_table.html.erb
333
314
  - app/views/rails_pulse/tags/_tag_manager.html.erb
334
315
  - config/importmap.rb
335
- - config/initializers/rails_charts_csp_patch.rb
336
316
  - config/initializers/rails_pulse.rb
337
317
  - config/routes.rb
338
318
  - db/migrate/20250930105043_install_rails_pulse_tables.rb
@@ -1,75 +0,0 @@
1
- # CSP patch for RailsCharts gem
2
- # Adds nonce attributes to script tags generated by RailsCharts for CSP compliance
3
-
4
- if defined?(RailsCharts)
5
- module RailsCharts
6
- module CspPatch
7
- def line_chart(data_source, options = {})
8
- chart_html = super(data_source, options)
9
- add_csp_nonce_to_chart(chart_html)
10
- end
11
-
12
- def bar_chart(data_source, options = {})
13
- chart_html = super(data_source, options)
14
- add_csp_nonce_to_chart(chart_html)
15
- end
16
-
17
- private
18
-
19
- def add_csp_nonce_to_chart(chart_html)
20
- return chart_html unless chart_html.present?
21
-
22
- nonce = get_csp_nonce
23
- return chart_html unless nonce.present?
24
-
25
- # Add nonce to script tags and mark as safe
26
- modified_html = add_nonce_to_scripts(chart_html.to_s, nonce)
27
- modified_html.html_safe if modified_html.respond_to?(:html_safe)
28
- end
29
-
30
- def get_csp_nonce
31
- # Try common CSP nonce sources in order of preference
32
- if respond_to?(:content_security_policy_nonce)
33
- content_security_policy_nonce
34
- elsif respond_to?(:csp_nonce)
35
- csp_nonce
36
- elsif defined?(request) && request
37
- request.env["action_dispatch.content_security_policy_nonce"] ||
38
- request.env["secure_headers.content_security_policy_nonce"] ||
39
- request.env["csp_nonce"]
40
- elsif respond_to?(:controller) && controller.respond_to?(:content_security_policy_nonce)
41
- controller.content_security_policy_nonce
42
- elsif defined?(@view_context) && @view_context.respond_to?(:content_security_policy_nonce)
43
- @view_context.content_security_policy_nonce
44
- else
45
- Thread.current[:rails_pulse_csp_nonce] ||
46
- (defined?(RequestStore) && RequestStore.store[:rails_pulse_csp_nonce])
47
- end
48
- end
49
-
50
- def add_nonce_to_scripts(html, nonce)
51
- html.gsub(/<script(?![^>]*\snonce=)([^>]*)>/i) do |match|
52
- attributes = $1
53
- if attributes.strip.empty?
54
- "<script nonce=\"#{nonce}\">"
55
- else
56
- "<script#{attributes} nonce=\"#{nonce}\">"
57
- end
58
- end
59
- end
60
- end
61
- end
62
- end
63
-
64
- # Apply the CSP patch only to Rails Pulse helpers, not the entire application
65
- # By prepending to ChartHelper instead of ApplicationHelper, we scope the patch to RailsPulse
66
- # namespace only, avoiding conflicts with any chart libraries in the host application
67
- # (Chartkick, Highcharts, Google Charts, ApexCharts, custom helpers, etc.)
68
- Rails.application.config.to_prepare do
69
- if defined?(RailsCharts) && defined?(RailsPulse::ChartHelper)
70
- # Prepend CSP patch to RailsPulse::ChartHelper
71
- # This wraps only the rails_charts methods, ensuring clean CSP nonce injection
72
- # without affecting the host application's chart helpers
73
- RailsPulse::ChartHelper.prepend(RailsCharts::CspPatch)
74
- end
75
- end