dev_panel 0.2.7 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/devpanel/extension.rb +34 -0
- data/lib/devpanel/middleware.rb +52 -12
- data/lib/devpanel/rails.rb +0 -1
- metadata +1 -1
data/lib/devpanel/extension.rb
CHANGED
@@ -23,6 +23,39 @@ module DevPanel
|
|
23
23
|
success: function(response) {
|
24
24
|
$jq("#DevPanel").html(response);
|
25
25
|
#{hide_container};
|
26
|
+
$jq("#consoleButton").click(function(e){
|
27
|
+
$("#console").toggle();
|
28
|
+
$jq("#console").css('top', e.pageY + 10 + 'px');
|
29
|
+
$jq("#console").css('left', e.pageX + 10 + 'px');
|
30
|
+
})
|
31
|
+
|
32
|
+
previous = null;
|
33
|
+
|
34
|
+
$jq("#consoleInput").keydown(function(e) {
|
35
|
+
if(event.keyCode == 38) {
|
36
|
+
$jq("#consoleInput").val(previous);
|
37
|
+
}
|
38
|
+
|
39
|
+
if(event.which == 13) {
|
40
|
+
|
41
|
+
if($jq("#consoleInput").val() == "") {
|
42
|
+
$jq("#consoleResults").append("><br>");
|
43
|
+
return "";
|
44
|
+
$jq("#consoleResults")[0].scrollTop = $jq("#consoleResults")[0].scrollHeight
|
45
|
+
}
|
46
|
+
$jq.ajax({
|
47
|
+
url: "/__DevPanel/console?query=" + $jq("#consoleInput").val(),
|
48
|
+
success: function(results) {
|
49
|
+
previous = $jq("#consoleInput").val()
|
50
|
+
$jq("#consoleResults").append(">" + results + "<br>");
|
51
|
+
$jq("#consoleInput").val("");
|
52
|
+
$jq("#consoleResults")[0].scrollTop = $jq("#consoleResults")[0].scrollHeight
|
53
|
+
}
|
54
|
+
|
55
|
+
})
|
56
|
+
}
|
57
|
+
})
|
58
|
+
|
26
59
|
$jq("#viewTime").click(function(e) {
|
27
60
|
$jq("#partialList").css('top', e.pageY + 10 + 'px');
|
28
61
|
$jq("#partialList").css('left', e.pageX + 10 + 'px');
|
@@ -31,6 +64,7 @@ module DevPanel
|
|
31
64
|
$jq("#devPanelHider").on("click", function(s) {
|
32
65
|
$jq("#devPanelContainer").slideToggle(110);
|
33
66
|
$jq("#partialList").hide();
|
67
|
+
$jq("#console").hide();
|
34
68
|
$jq.get("/__DevPanel/set_options?visible=" + $jq("#devPanelContainer").is(":visible"));
|
35
69
|
});
|
36
70
|
$jq("#devPanelWindow").draggable({stop: function() {
|
data/lib/devpanel/middleware.rb
CHANGED
@@ -11,6 +11,10 @@ module DevPanel
|
|
11
11
|
params = Rack::Utils.parse_query(env['QUERY_STRING'], "&")
|
12
12
|
Stats.set_by_params(params)
|
13
13
|
[200, { "Content-Type" => "text/plain; charset=utf-8" }, ["#{Stats.show?} #{Stats.left} #{Stats.top}"]]
|
14
|
+
elsif env["REQUEST_URI"] =~ /__DevPanel\/console/
|
15
|
+
params = Rack::Utils.parse_query(env['QUERY_STRING'], "&")
|
16
|
+
query = params["query"]
|
17
|
+
[200, { "Content-Type" => "text/plain; charset=utf-8" }, ["#{CGI::escapeHTML(eval(query).to_s)}"]]
|
14
18
|
else
|
15
19
|
@app.call(env)
|
16
20
|
end
|
@@ -117,6 +121,37 @@ module DevPanel
|
|
117
121
|
z-index: 500000001;
|
118
122
|
}
|
119
123
|
|
124
|
+
#console {
|
125
|
+
position: absolute;
|
126
|
+
top: 0px;
|
127
|
+
left: 0px;
|
128
|
+
background: #F1F1F1;
|
129
|
+
border: 2px solid #000;
|
130
|
+
background-color: #fff;
|
131
|
+
box-shadow: inset 3px 3px 3px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
132
|
+
font-family: arial;
|
133
|
+
font-size: 10px;
|
134
|
+
overflow: hidden;
|
135
|
+
padding: 6px 10px;
|
136
|
+
border-top-left-radius: 2px;
|
137
|
+
border-top-right-radius: 2px;
|
138
|
+
display: none;
|
139
|
+
z-index: 500000001;
|
140
|
+
width: 600px;
|
141
|
+
}
|
142
|
+
|
143
|
+
#consoleResults {
|
144
|
+
width: 97%;
|
145
|
+
height: 250px;
|
146
|
+
font-size: 13px;
|
147
|
+
overflow-x: scroll;
|
148
|
+
}
|
149
|
+
|
150
|
+
#consoleInput {
|
151
|
+
width: 97%;
|
152
|
+
height: 20px;
|
153
|
+
}
|
154
|
+
|
120
155
|
.green { background: #21D61A !important}
|
121
156
|
.yellow { background: #BEBE00 !important }
|
122
157
|
.orange { background: #F0A811 !important }
|
@@ -129,6 +164,11 @@ module DevPanel
|
|
129
164
|
def html_containers
|
130
165
|
<<-html_code
|
131
166
|
<div id='partialList'>#{partial_list}</div>
|
167
|
+
<div id='console'>
|
168
|
+
<div id="consoleResults">></div>
|
169
|
+
<input id="consoleInput" type="text" placeholder="Type Command">
|
170
|
+
|
171
|
+
</div>
|
132
172
|
<div id="devPanelWindow" style="top: #{Stats.top.to_s}px; left: #{Stats.left.to_s}px;" >
|
133
173
|
<div id="devPanelHider" class="#{heat_color}"><a class="hider-color" href="#">#{stats(:controller)}##{stats(:action)}</a> / <span class="hider-color" style="font-size: 10px">#{Stats.data[:action_controller].duration.round(0).to_s}ms</span></div>
|
134
174
|
<div id="devPanelContainer">
|
@@ -145,8 +185,7 @@ module DevPanel
|
|
145
185
|
"orange"
|
146
186
|
else
|
147
187
|
"red"
|
148
|
-
|
149
|
-
|
188
|
+
end
|
150
189
|
end
|
151
190
|
|
152
191
|
def stats(symbol)
|
@@ -155,16 +194,17 @@ module DevPanel
|
|
155
194
|
|
156
195
|
def html_table
|
157
196
|
table_rows = rowify([
|
158
|
-
first_td("
|
159
|
-
first_td("
|
160
|
-
first_td("
|
161
|
-
first_td("
|
162
|
-
first_td("
|
163
|
-
first_td("
|
164
|
-
first_td("
|
165
|
-
first_td("
|
166
|
-
first_td("
|
167
|
-
first_td("
|
197
|
+
first_td("Tools:") + td("<a href='#' id='consoleButton'>Console</a>"),
|
198
|
+
first_td("Total:") + td("#{Stats.total_duration.to_s}ms"),
|
199
|
+
first_td("Controller:") + td("#{Stats.controller_duration.to_s}ms (#{Stats.controller_duration_percent}%)"),
|
200
|
+
first_td("View:") + td("#{Stats.view_duration.to_s}ms (#{Stats.view_duration_percent}%)"),
|
201
|
+
first_td("Partials:") + td(partial_count),
|
202
|
+
first_td("Response:") + td(stats(:status)),
|
203
|
+
first_td("Controller:") + td(stats(:controller)),
|
204
|
+
first_td("Action:") + td(stats(:action)),
|
205
|
+
first_td("Method:") + td(stats(:method)),
|
206
|
+
first_td("Params:") + td(stats(:params)),
|
207
|
+
first_td("Log:") + td(Stats.data[:log])
|
168
208
|
])
|
169
209
|
|
170
210
|
"<table style='margin: auto; table-layout: fixed'>#{table_rows}</table></div></div>"
|
data/lib/devpanel/rails.rb
CHANGED