rails_mini_profiler 0.2.1 → 0.3.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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/rails_mini_profiler.js +1 -78
  3. data/app/assets/stylesheets/rails_mini_profiler/application.css +1 -171
  4. data/app/controllers/rails_mini_profiler/profiled_requests_controller.rb +10 -1
  5. data/app/helpers/rails_mini_profiler/application_helper.rb +9 -0
  6. data/app/{assets/images/rails_mini_profiler → javascript/images}/bookmark.svg +0 -0
  7. data/app/{assets/images/rails_mini_profiler → javascript/images}/chart.svg +0 -0
  8. data/app/{assets/images/rails_mini_profiler → javascript/images}/delete.svg +0 -0
  9. data/app/{assets/images/rails_mini_profiler → javascript/images}/graph.svg +0 -0
  10. data/app/{assets/images/rails_mini_profiler → javascript/images}/logo.svg +0 -0
  11. data/app/{assets/images/rails_mini_profiler → javascript/images}/logo_variant.svg +0 -0
  12. data/app/{assets/images/rails_mini_profiler → javascript/images}/search.svg +0 -0
  13. data/app/{assets/images/rails_mini_profiler → javascript/images}/setting.svg +0 -0
  14. data/app/{assets/images/rails_mini_profiler → javascript/images}/show.svg +0 -0
  15. data/app/javascript/packs/rails-mini-profiler.js +80 -0
  16. data/app/javascript/stylesheets/flamegraph.scss +9 -0
  17. data/app/{assets/stylesheets/rails_mini_profiler/flashes.css → javascript/stylesheets/flashes.scss} +0 -0
  18. data/app/{assets/stylesheets/rails_mini_profiler/navbar.css → javascript/stylesheets/navbar.scss} +2 -2
  19. data/app/{assets/stylesheets/rails_mini_profiler/profiled_requests.css → javascript/stylesheets/profiled_requests.scss} +1 -7
  20. data/app/javascript/stylesheets/rails-mini-profiler.scss +175 -0
  21. data/app/{assets/stylesheets/rails_mini_profiler/traces.css → javascript/stylesheets/traces.scss} +0 -5
  22. data/app/presenters/rails_mini_profiler/profiled_request_presenter.rb +2 -2
  23. data/app/views/layouts/rails_mini_profiler/application.html.erb +1 -8
  24. data/app/views/layouts/rails_mini_profiler/flamegraph.html.erb +1 -8
  25. data/app/views/rails_mini_profiler/badge.html.erb +1 -1
  26. data/app/views/rails_mini_profiler/profiled_requests/index.html.erb +3 -3
  27. data/app/views/rails_mini_profiler/shared/_head.erb +13 -0
  28. data/app/views/rails_mini_profiler/shared/_navbar.html.erb +1 -1
  29. data/lib/generators/rails_mini_profiler/install_generator.rb +13 -0
  30. data/lib/generators/rails_mini_profiler/templates/rails_mini_profiler.js.erb +13 -0
  31. data/lib/rails_mini_profiler/badge.rb +4 -1
  32. data/lib/rails_mini_profiler/engine.rb +5 -1
  33. data/lib/rails_mini_profiler/version.rb +4 -1
  34. data/vendor/assets/images/bookmark.svg +10 -0
  35. data/vendor/assets/images/chart.svg +12 -0
  36. data/vendor/assets/images/delete.svg +9 -0
  37. data/vendor/assets/images/graph.svg +11 -0
  38. data/vendor/assets/images/logo.svg +18 -0
  39. data/vendor/assets/images/logo_variant.svg +32 -0
  40. data/vendor/assets/images/search.svg +10 -0
  41. data/vendor/assets/images/setting.svg +10 -0
  42. data/vendor/assets/images/show.svg +11 -0
  43. data/vendor/assets/javascripts/rails-mini-profiler.css +1 -0
  44. data/vendor/assets/javascripts/rails-mini-profiler.js +1 -0
  45. metadata +31 -22
  46. data/app/assets/fonts/rails_mini_profiler/LICENSE.txt +0 -202
  47. data/app/assets/fonts/rails_mini_profiler/OpenSans-Bold.ttf +0 -0
  48. data/app/assets/fonts/rails_mini_profiler/OpenSans-Regular.ttf +0 -0
  49. data/app/assets/fonts/rails_mini_profiler/OpenSans-SemiBold.ttf +0 -0
  50. data/app/assets/stylesheets/rails_mini_profiler/flamegraph.css +0 -14
  51. data/vendor/assets/javascripts/popper.js +0 -6
  52. data/vendor/assets/javascripts/tippy.js +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0024a0bf06919b656615d69145f2f68cbd18cca28a1ff1358aa0a06ab0bf2955
4
- data.tar.gz: 9d3eb7af567564dc6458125cde850d8dd5db1117e50b4bf298bc07024f2cc533
3
+ metadata.gz: c0dfb74da2ecab593753e57b0b23c131ffb7857d5c22ce167185a8ba29aa013b
4
+ data.tar.gz: cc0d40ee213af658df6475062054814be1dcbec8471e894dd7fc13c8633dd734
5
5
  SHA512:
6
- metadata.gz: 7c24ccb1d9c71acc7fa565f51d3832844e78969438080d5f849ca79734b9cbe77be0de055067f077ed07ec6f5a5d85d6e0a9ab8906adb361b126ac07bd4aa9ab
7
- data.tar.gz: 9a440fb88d0066f1caf5d89115c1e3479dfa44bf01fe0b617f79ddc87a6ddba80365ca02a39d9154b101fc479dd3255d01ba34a6f0939ab68274a4a9390a3f68
6
+ metadata.gz: f21f840089c68cd189c75bd00428d3f9f23a9b84a9c3e48de1fe2236d798ece02e7869a0bc4b265a6bb26018c347cc73d0e089d64d96bcf163ecf5bcda157f7e
7
+ data.tar.gz: 8185fec8a94783a448f7340e395e3278d3eecc4b801acfd3b321a1ff2255c5d902037ecff71001b78e74371f94eabb76efed986d15a9decc307feec0a45779f2
@@ -12,81 +12,4 @@
12
12
  //
13
13
  //= require rails-ujs
14
14
  //= require_tree .
15
- //= require popper
16
- //= require tippy
17
-
18
- function setupRequestSearch() {
19
- const profiledRequestNameSearch = document.getElementById('profiled-request-search')
20
- if (profiledRequestNameSearch) {
21
- profiledRequestNameSearch.addEventListener('keyup', function (event) {
22
- if (event.key === 'Enter') {
23
- event.preventDefault()
24
- document.getElementById('profiled-request-search-form').submit()
25
- }
26
- })
27
- }
28
- }
29
-
30
- function setupTraceSearch() {
31
- const traceNameSearch = document.getElementById('trace-search')
32
- if (traceNameSearch) {
33
- traceNameSearch.addEventListener('keyup', function (event) {
34
- if (event.key === 'Enter') {
35
- event.preventDefault()
36
- document.getElementById('trace-form').submit()
37
- }
38
- })
39
- }
40
- }
41
-
42
- function setupRequestTable() {
43
- const profiledRequestTable = document.getElementById('profiled-requests-table');
44
- if (profiledRequestTable) {
45
- const rows = profiledRequestTable.getElementsByTagName('tr')
46
- for (let i = 0; i < rows.length; i++) {
47
- const currentRow = profiledRequestTable.rows[i]
48
- const link = currentRow.dataset.link
49
- const createClickHandler = function (currentRow) {
50
- return function () {
51
- window.location.href = link
52
- }
53
- }
54
- currentRow.onclick = createClickHandler(currentRow)
55
- }
56
- }
57
- }
58
-
59
- function setupTraceBars () {
60
- const traceBars = document.querySelectorAll('.trace-bar')
61
- traceBars.forEach((bar) => {
62
- const popover = bar.children[0]
63
- tippy(bar, {
64
- trigger: 'click',
65
- content: popover,
66
- theme: 'rmp',
67
- maxWidth: '700px',
68
- placement: 'bottom',
69
- interactive: true,
70
- onShow (instance) {
71
- instance.popper.querySelector('.popover-close').addEventListener('click', () => {
72
- instance.hide()
73
- })
74
- },
75
- onHide (instance) {
76
- instance.popper.querySelector('.popover-close').removeEventListener('click', () => {
77
- instance.hide()
78
- })
79
- },
80
- })
81
- })
82
- }
83
-
84
-
85
- // Trace Bar Popovers
86
- document.addEventListener('DOMContentLoaded', () => {
87
- setupRequestTable();
88
- setupRequestSearch();
89
- setupTraceBars();
90
- setupTraceSearch();
91
- }, false)
92
-
15
+ //= require rails-mini-profiler
@@ -12,175 +12,5 @@
12
12
  *
13
13
  *= require_tree .
14
14
  *= require_self
15
+ *= require rails-mini-profiler
15
16
  */
16
-
17
- @font-face {
18
- font-family: 'Open Sans';
19
- font-weight: 400;
20
- font-style: normal;
21
- src: url('OpenSans-Regular.ttf') format("truetype");
22
- }
23
-
24
- @font-face {
25
- font-family: 'Open Sans';
26
- font-weight: 600;
27
- font-style: normal;
28
- src: url('OpenSans-SemiBold.ttf') format("truetype");
29
- }
30
-
31
- @font-face {
32
- font-family: 'Open Sans';
33
- font-weight: 700;
34
- font-style: normal;
35
- src: url('OpenSans-Bold.ttf') format("truetype");
36
- }
37
-
38
- html {
39
- width: 100%;
40
- height: 100%;
41
- margin: 0;
42
- padding: 0;
43
-
44
- --grey-50: #F9FAFB;
45
- --grey-100: #F3F4F6;
46
- --grey-200: #E5E7EB;
47
- --grey-400: #9CA3AF;
48
- --grey-500: #6B7280;
49
- --grey-700: #374151;
50
- --grey-900: #111827;
51
-
52
- --red-400: #F87171;
53
- --red-500: #EF4444;
54
- --red-600: #DC2626;
55
-
56
- --yellow-400: #FBBF24;
57
- --yellow-500: #F59E0B;
58
-
59
- --green-300: #6EE7B7;
60
- --green-400: #34D399;
61
- --green-500: #10B981;
62
-
63
- --blue-400: #60A5FA;
64
- --blue-500: #3B82F6;
65
-
66
- --main-width: 1056px;
67
-
68
- --primary: var(--red-600);
69
-
70
- --border-color: var(--grey-200);
71
- --text-color: var(--grey-900);
72
-
73
- font-family: 'Open Sans', monospace;
74
-
75
- }
76
-
77
- body {
78
- width: 100%;
79
- height: 100%;
80
- margin: 0;
81
- padding: 0;
82
-
83
- color: var(--text-color)
84
- }
85
-
86
- h1 {
87
- padding: 2rem 0 1rem;
88
- }
89
-
90
- button {
91
- border: none;
92
- border-radius: .25rem;
93
- padding: 0.5em .5em;
94
- text-align: center;
95
- text-decoration: none;
96
- display: inline-block;
97
- font-size: 1rem;
98
- cursor: pointer;
99
- }
100
-
101
- button:hover {
102
- box-shadow: 0 .25rem .25rem 0 var(--grey-50);
103
- }
104
-
105
- /* --------------------------------------- */
106
-
107
- .text-left {
108
- text-align: left;
109
- }
110
-
111
- .text-right {
112
- text-align: right;
113
- }
114
-
115
- /* --------------------------------------- */
116
-
117
- .pill {
118
- margin: .2rem 0;
119
- padding: .1rem .4rem;
120
- border-radius: 5px;
121
-
122
- font-size: .9rem;
123
- font-weight: 600;
124
- letter-spacing: .1rem;
125
-
126
- background: var(--grey-200);
127
- }
128
-
129
- /* --------------------------------------- */
130
-
131
- .popover {
132
- display: flex;
133
- flex-direction: column;
134
- width: 600px;
135
- padding: 1em;
136
- color: black;
137
- }
138
-
139
- .popover-header {
140
- display: flex;
141
- padding-bottom: 1em;
142
- flex-direction: row;
143
- justify-content: space-between;
144
- align-items: center;
145
- }
146
-
147
- .popover-description {
148
- margin: 0;
149
- padding: 0;
150
- }
151
-
152
- .popover-close {
153
- background: transparent;
154
- padding: 0;
155
- font-weight: 700;
156
- font-size: 20px;
157
- color: var(--grey-400);
158
- }
159
-
160
- .popover-body {
161
- padding: 1em 0;
162
- }
163
-
164
- .popover-footer {
165
- border-top: 1px solid var(--grey-50);
166
- }
167
-
168
- .tippy-box[data-theme~='rmp'] {
169
- background: white;
170
- box-shadow: 8px 0 30px 4px rgba(0, 0, 0, .2), 8px 4px 10px 0 rgba(0, 0, 0, .05);
171
- border-radius: 3px;
172
-
173
- transition: all cubic-bezier(.19,1,.22,1) .2s;
174
- }
175
- .tippy-box[data-theme~='rmp'][data-placement^='top'] > .tippy-arrow::before {
176
- border-top-color: white;
177
- }
178
- .tippy-box[data-theme~='rmp'][data-placement^='bottom'] > .tippy-arrow::before {
179
- border-bottom-color: white;
180
- }
181
- .tippy-box[data-theme~='rmp'][data-placement^='left'] > .tippy-arrow::before {
182
- border-left-color: white;
183
- }
184
- .tippy-box[data-theme~='rmp'][data-placement^='right'] > .tippy-arrow::before {
185
- border-right-color: white;
186
- }
@@ -16,7 +16,7 @@ module RailsMiniProfiler
16
16
 
17
17
  def show
18
18
  @traces = @profiled_request.traces
19
- @traces = @traces.where('payload LIKE ?', "%#{params[:search]}%") if params[:search]
19
+ @traces = @traces.where("#{payload_column} LIKE ?", "%#{params[:search]}%") if params[:search]
20
20
  @traces = @traces
21
21
  .order(:start)
22
22
  .map { |trace| present(trace, profiled_request: @profiled_request) }
@@ -51,5 +51,14 @@ module RailsMiniProfiler
51
51
  def configuration
52
52
  @configuration ||= RailsMiniProfiler.configuration
53
53
  end
54
+
55
+ def payload_column
56
+ if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
57
+ # Cast json field to text to have access to the LIKE operator
58
+ 'payload::text'
59
+ else
60
+ 'payload'
61
+ end
62
+ end
54
63
  end
55
64
  end
@@ -8,5 +8,14 @@ module RailsMiniProfiler
8
8
  yield(presenter) if block_given?
9
9
  presenter
10
10
  end
11
+
12
+ def inline_svg(path, options = {})
13
+ if defined?(Webpacker::Engine)
14
+ path = "media/images/#{path}"
15
+ inline_svg_pack_tag(path, options)
16
+ else
17
+ inline_svg_tag(path, options)
18
+ end
19
+ end
11
20
  end
12
21
  end
@@ -0,0 +1,80 @@
1
+ import '../stylesheets/rails-mini-profiler.scss'
2
+
3
+ import tippy from 'tippy.js'
4
+ import 'tippy.js/dist/tippy.css'
5
+
6
+ function setupRequestSearch() {
7
+ const profiledRequestNameSearch = document.getElementById('profiled-request-search')
8
+ if (profiledRequestNameSearch) {
9
+ profiledRequestNameSearch.addEventListener('keyup', function (event) {
10
+ if (event.key === 'Enter') {
11
+ event.preventDefault()
12
+ document.getElementById('profiled-request-search-form').submit()
13
+ }
14
+ })
15
+ }
16
+ }
17
+
18
+ function setupTraceSearch() {
19
+ const traceNameSearch = document.getElementById('trace-search')
20
+ if (traceNameSearch) {
21
+ traceNameSearch.addEventListener('keyup', function (event) {
22
+ if (event.key === 'Enter') {
23
+ event.preventDefault()
24
+ document.getElementById('trace-form').submit()
25
+ }
26
+ })
27
+ }
28
+ }
29
+
30
+ function setupRequestTable() {
31
+ const profiledRequestTable = document.getElementById('profiled-requests-table');
32
+ if (profiledRequestTable) {
33
+ const rows = profiledRequestTable.getElementsByTagName('tr')
34
+ for (let i = 0; i < rows.length; i++) {
35
+ const currentRow = profiledRequestTable.rows[i]
36
+ const link = currentRow.dataset.link
37
+ const createClickHandler = function () {
38
+ return function () {
39
+ window.location.href = link
40
+ }
41
+ }
42
+ currentRow.onclick = createClickHandler(currentRow)
43
+ }
44
+ }
45
+ }
46
+
47
+ function setupTraceBars () {
48
+ const traceBars = document.querySelectorAll('.trace-bar')
49
+ traceBars.forEach((bar) => {
50
+ const popover = bar.children[0]
51
+ tippy(bar, {
52
+ trigger: 'click',
53
+ content: popover,
54
+ theme: 'rmp',
55
+ maxWidth: '700px',
56
+ placement: 'bottom',
57
+ interactive: true,
58
+ onShow (instance) {
59
+ instance.popper.querySelector('.popover-close').addEventListener('click', () => {
60
+ instance.hide()
61
+ })
62
+ },
63
+ onHide (instance) {
64
+ instance.popper.querySelector('.popover-close').removeEventListener('click', () => {
65
+ instance.hide()
66
+ })
67
+ },
68
+ })
69
+ })
70
+ }
71
+
72
+
73
+ // Trace Bar Popovers
74
+ document.addEventListener('DOMContentLoaded', () => {
75
+ setupRequestTable();
76
+ setupRequestSearch();
77
+ setupTraceBars();
78
+ setupTraceSearch();
79
+ }, false)
80
+
@@ -0,0 +1,9 @@
1
+ #wrapper {
2
+ height: 100vh;
3
+ width: 100%;
4
+ }
5
+
6
+ #speedscope-iframe {
7
+ width: 100%;
8
+ height: 100%;
9
+ border: none; }
@@ -5,13 +5,13 @@
5
5
  display: flex;
6
6
  justify-content: center;
7
7
 
8
- box-shadow: 0 0 20px 0 rgba(0,0,0,.2);
8
+ box-shadow: 0 0 20px 0 rgba(0, 0, 0, .2);
9
9
 
10
10
  background: var(--primary);
11
11
  }
12
12
 
13
13
  .header a {
14
- color:white;
14
+ color: white;
15
15
  text-decoration: none;
16
16
  }
17
17