pghero 1.4.0 → 1.4.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.

Potentially problematic release.


This version of pghero might be problematic. Click here for more details.

@@ -4,390 +4,8 @@
4
4
  <title><%= [@databases.size > 1 ? @current_database.name : "PgHero", @title].compact.join(" / ") %></title>
5
5
 
6
6
  <meta charset="utf-8" />
7
-
8
- <style>
9
- body {
10
- margin: 0;
11
- padding: 20px;
12
- background-color: #eee;
13
- }
14
-
15
- body, textarea {
16
- font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
17
- font-size: 14px;
18
- line-height: 1.4;
19
- color: #333;
20
- }
21
-
22
- a, a:visited, a:active {
23
- color: #428bca;
24
- text-decoration: none;
25
- }
26
-
27
- a:hover {
28
- text-decoration: underline;
29
- }
30
-
31
- table {
32
- width: 100%;
33
- border-collapse: collapse;
34
- border-spacing: 0;
35
- margin-bottom: 20px;
36
- }
37
-
38
- th {
39
- text-align: left;
40
- border-bottom: solid 2px #ddd;
41
- }
42
-
43
- h1 {
44
- margin-top: 0;
45
- font-size: 20px;
46
- font-weight: bold;
47
- }
48
-
49
- h1, p {
50
- margin-bottom: 20px;
51
- }
52
-
53
- ul {
54
- list-style-type: none;
55
- padding: 0;
56
- margin: 0;
57
- }
58
-
59
- table td, table th {
60
- padding: 8px;
61
- }
62
-
63
- td {
64
- border-top: solid 1px #ddd;
65
- }
66
-
67
- pre {
68
- background-color: #eee;
69
- padding: 10px;
70
- white-space: pre-wrap;
71
- word-break: break-word;
72
- }
73
-
74
- textarea {
75
- width: 100%;
76
- height: 100px;
77
- border: solid 1px #ddd;
78
- padding: 10px;
79
- }
80
-
81
- hr {
82
- border: none;
83
- height: 0;
84
- border-top: solid 1px #ddd;
85
- margin-bottom: 15px;
86
- }
87
-
88
- .container {
89
- max-width: 1000px;
90
- margin-left: auto;
91
- margin-right: auto;
92
- }
93
-
94
- .text-muted {
95
- color: #999;
96
- }
97
-
98
- .text-right {
99
- text-align: right;
100
- }
101
-
102
- .percent {
103
- color: #999;
104
- font-size: 12px;
105
- margin-left: 6px;
106
- }
107
-
108
- .tiny {
109
- font-size: 12px;
110
- margin-left: 6px;
111
- }
112
-
113
- #status, .content, .alert {
114
- margin-bottom: 20px;
115
- }
116
-
117
- .content {
118
- padding: 20px 20px 1px 20px;
119
- background-color: #fff;
120
- }
121
-
122
- .queries td {
123
- vertical-align: middle;
124
- }
125
-
126
- #status div {
127
- margin-bottom: 0;
128
- }
129
-
130
- #slider-container {
131
- padding: 6px 140px 20px 140px;
132
- }
133
-
134
- .queries-table th a {
135
- color: inherit;
136
- }
137
-
138
- #slider {
139
- margin-bottom: 20px;
140
- }
141
-
142
- #range-start {
143
- min-height: 20px;
144
- }
145
-
146
- #range-end {
147
- float: right;
148
- }
149
-
150
- .queries-info {
151
- text-align: center;
152
- margin-top: 40px;
153
- }
154
-
155
- /* nav */
156
-
157
- .nav a {
158
- color: #333;
159
- text-decoration: none;
160
- display: block;
161
- padding: 12px 20px;
162
- }
163
-
164
- .nav li.active a {
165
- background-color: #ddd;
166
- }
167
-
168
- .nav a:hover {
169
- background-color: #ddd;
170
- }
171
-
172
- .nav li.active-database a {
173
- color: #999;
174
- }
175
-
176
- .nav-header {
177
- font-weight: bold;
178
- color: #333;
179
- padding: 12px 20px 12px 0;
180
- margin: 0;
181
- }
182
-
183
- /* buttons */
184
-
185
- .btn {
186
- display: inline-block;
187
- border: none;
188
- color: #fff;
189
- padding: 12px 20px;
190
- font-size: inherit;
191
- font-family: inherit;
192
- line-height: 1;
193
- cursor: pointer;
194
- outline: none;
195
- margin: 0;
196
- -webkit-appearance: none;
197
- -webkit-border-radius: 0;
198
- }
199
-
200
- .btn-danger {
201
- background-color: #d9534f;
202
- }
203
-
204
- .btn-info {
205
- background-color: #5bc0de;
206
- }
207
-
208
- /* alerts */
209
-
210
- .alert {
211
- padding: 12px 20px;
212
- color: #fff;
213
- }
214
-
215
- .alert-info {
216
- background-color: #5bc0de;
217
- }
218
-
219
- .alert-success {
220
- background-color: #5cb85c;
221
- }
222
-
223
- .alert-warning {
224
- background-color: #f0ad4e;
225
- }
226
-
227
- .alert-danger {
228
- background-color: #d9534f;
229
- }
230
-
231
- .alert a {
232
- color: #fff;
233
- text-decoration: none;
234
- }
235
-
236
- .button_to, .button_to div {
237
- display: inline;
238
- }
239
-
240
- /*
241
- Simple Grid
242
- Learn More - http://dallasbass.com/simple-grid-a-lightweight-responsive-css-grid/
243
- Project Page - http://thisisdallas.github.com/Simple-Grid/
244
- Author - Dallas Bass
245
- Site - dallasbass.com
246
- */
247
-
248
- *, *:after, *:before {
249
- -webkit-box-sizing: border-box;
250
- -moz-box-sizing: border-box;
251
- box-sizing: border-box;
252
- }
253
-
254
- body {
255
- margin: 0px;
256
- }
257
-
258
- [class*='col-'] {
259
- float: left;
260
- padding-right: 20px;
261
- }
262
-
263
- [class*='col-']:last-of-type {
264
- padding-right: 0px;
265
- }
266
-
267
- .grid {
268
- width: 100%;
269
-
270
- margin: 0 auto;
271
- overflow: hidden;
272
- }
273
-
274
- .grid:after {
275
- content: "";
276
- display: table;
277
- clear: both;
278
- }
279
-
280
- .grid-pad {
281
- padding: 20px 0 0px 20px;
282
- }
283
-
284
- .grid-pad > [class*='col-']:last-of-type {
285
- padding-right: 20px;
286
- }
287
-
288
- .push-right {
289
- float: right;
290
- }
291
-
292
- /* Content Columns */
293
-
294
- .col-1-1 {
295
- width: 100%;
296
- }
297
- .col-2-3, .col-8-12 {
298
- width: 66.66%;
299
- }
300
-
301
- .col-1-2, .col-6-12 {
302
- width: 50%;
303
- }
304
-
305
- .col-1-3, .col-4-12 {
306
- width: 33.33%;
307
- }
308
-
309
- .col-1-4, .col-3-12 {
310
- width: 25%;
311
- }
312
-
313
- .col-1-5 {
314
- width: 20%;
315
- }
316
-
317
- .col-1-6, .col-2-12 {
318
- width: 16.667%;
319
- }
320
-
321
- .col-1-7 {
322
- width: 14.28%;
323
- }
324
-
325
- .col-1-8 {
326
- width: 12.5%;
327
- }
328
-
329
- .col-1-9 {
330
- width: 11.1%;
331
- }
332
-
333
- .col-1-10 {
334
- width: 10%;
335
- }
336
-
337
- .col-1-11 {
338
- width: 9.09%;
339
- }
340
-
341
- .col-1-12 {
342
- width: 8.33%
343
- }
344
-
345
- /* Layout Columns */
346
-
347
- .col-11-12 {
348
- width: 91.66%
349
- }
350
-
351
- .col-10-12 {
352
- width: 83.333%;
353
- }
354
-
355
- .col-9-12 {
356
- width: 75%;
357
- }
358
-
359
- .col-5-12 {
360
- width: 41.66%;
361
- }
362
-
363
- .col-7-12 {
364
- width: 58.33%
365
- }
366
-
367
- @media handheld, only screen and (max-width: 767px) {
368
-
369
-
370
- .grid {
371
- width: 100%;
372
- min-width: 0;
373
- margin-left: 0px;
374
- margin-right: 0px;
375
- padding-left: 0px;
376
- padding-right: 0px;
377
- }
378
-
379
- [class*='col-'] {
380
- width: auto;
381
- float: none;
382
- margin-left: 0px;
383
- margin-right: 0px;
384
- margin-top: 10px;
385
- margin-bottom: 10px;
386
- padding-right: 0px;
387
- padding-left: 0px;
388
- }
389
- }
390
- </style>
7
+ <%= stylesheet_link_tag "pghero/application" %>
8
+ <%= javascript_include_tag "pghero/application" %>
391
9
  </head>
392
10
  <body>
393
11
  <div class="container">
@@ -4,173 +4,13 @@
4
4
  <div id="range-start"></div>
5
5
  </div>
6
6
 
7
- <%= stylesheet_link_tag "https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/6.2.0/jquery.nouislider.min.css" %>
8
- <%= javascript_include_tag "//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js", "https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/6.2.0/jquery.nouislider.min.js" %>
9
-
10
- <style>
11
- .noUi-connect {
12
- box-shadow: none;
13
- background: #5bc0de;
14
- }
15
-
16
- .noUi-handle {
17
- box-shadow: none;
18
- }
19
-
20
- .noUi-target {
21
- box-shadow: none;
22
- border-color: #eee;
23
- }
24
-
25
- .noUi-background {
26
- box-shadow: none;
27
- background-color: #eee;
28
- }
29
-
30
- .noUi-origin {
31
- border-radius: 0;
32
- }
33
- </style>
34
-
35
7
  <script>
36
- function roundTime(time) {
37
- var period = 1000 * 60 * 5;
38
- return new Date(Math.ceil(time.getTime() / period) * period);
39
- }
40
-
41
- function pad(num) {
42
- return (num < 10) ? "0" + num : num;
43
- }
44
-
45
8
  var sort = <%= @sort.to_json.html_safe %>;
46
9
  var minAverageTime = <%= @min_average_time.to_json %>;
47
10
  var minCalls = <%= @min_calls.to_json %>;
48
11
  var debug = <%= @debug.to_json %>;
49
-
50
- var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
51
-
52
- var days = 1;
53
- var now = new Date();
54
- var sliderStartAt = roundTime(now) - days * 24 * 60 * 60 * 1000;
55
- var sliderMax = 24 * 12 * days;
56
-
57
- var startAt = <%= params[:start_at] ? @start_at.to_i * 1000 : "sliderStartAt" %>;
58
- var min = (startAt > 0) ? (startAt - sliderStartAt) / (1000 * 60 * 5) : 0;
59
-
12
+ var startAt = <%= params[:start_at] ? @start_at.to_i * 1000 : "null" %>;
60
13
  var endAt = <%= @end_at.to_i %> * 1000;
61
- var max = (endAt > 0) ? (endAt - sliderStartAt) / (1000 * 60 * 5) : sliderMax;
62
-
63
- var $slider = $("#slider");
64
-
65
- $slider.noUiSlider({
66
- range: {
67
- min: 0,
68
- max: sliderMax
69
- },
70
- step: 1,
71
- connect: true,
72
- start: [min, max]
73
- });
74
-
75
- function updateText() {
76
- var values = $slider.val();
77
- setText("#range-start", values[0]);
78
- setText("#range-end", values[1]);
79
- }
80
-
81
- function setText(selector, offset) {
82
- var time = timeAt(offset);
83
-
84
- var html = "";
85
- if (time == now) {
86
- if (selector == "#range-end") {
87
- html = "Now";
88
- }
89
- } else {
90
- html = months[time.getMonth()] + " " + time.getDate() + ", " + pad(time.getHours()) + ":" + pad(time.getMinutes());
91
- }
92
- $(selector).html(html);
93
- }
94
-
95
- function timeAt(offset) {
96
- var time = new Date(sliderStartAt + (offset * 5) * 60 * 1000);
97
- return (time > now) ? now : time;
98
- }
99
-
100
- function timeParam(time) {
101
- return time.toISOString();
102
- }
103
-
104
- function queriesPath(params) {
105
- var path = "queries";
106
- if (params.start_at || params.end_at || params.sort || params.min_average_time || params.min_calls || params.debug) {
107
- path += "?" + $.param(params);
108
- }
109
- return path;
110
- }
111
-
112
- function refreshStats(push) {
113
- var values = $slider.val();
114
- var startAt = push ? timeAt(values[0]) : new Date(window.startAt);
115
- var endAt = timeAt(values[1]);
116
-
117
- var params = {}
118
- if (startAt.getTime() != sliderStartAt) {
119
- params.start_at = timeParam(startAt);
120
- }
121
- if (endAt < now) {
122
- params.end_at = timeParam(endAt);
123
- }
124
- if (sort) {
125
- params.sort = sort;
126
- }
127
- if (minAverageTime) {
128
- params.min_average_time = minAverageTime;
129
- }
130
- if (minCalls) {
131
- params.min_calls = minCalls;
132
- }
133
- if (debug) {
134
- params.debug = debug;
135
- }
136
-
137
- var path = queriesPath(params);
138
-
139
- $(".queries-table th a").each( function () {
140
- var p = $.extend({}, params, {sort: $(this).data("sort"), min_average_time: minAverageTime, min_calls: minCalls, debug: debug});
141
- if (!p.sort) {
142
- delete p.sort;
143
- }
144
- if (!p.min_average_time) {
145
- delete p.min_average_time;
146
- }
147
- if (!p.min_calls) {
148
- delete p.min_calls;
149
- }
150
- if (!p.debug) {
151
- delete p.debug;
152
- }
153
- $(this).attr("href", queriesPath(p));
154
- });
155
-
156
-
157
- var callback = function (response, status, xhr) {
158
- if (status === "error" ) {
159
- $(".queries-info").css("color", "red").html(xhr.status + " " + xhr.statusText);
160
- }
161
- };
162
- $("#queries").html('<tr><td colspan="3"><p class="queries-info text-muted">...</p></td></tr>').load(path, callback);
163
-
164
- if (push && history.pushState) {
165
- history.pushState(null, null, path);
166
- }
167
- }
168
14
 
169
- $slider.on("slide", updateText).on("change", function () {
170
- refreshStats(true);
171
- });
172
- updateText();
173
- $( function () {
174
- refreshStats(false);
175
- });
15
+ initSlider();
176
16
  </script>