Skip to content

Commit a7d02ba

Browse files
committed
Initial debug pop-out window
1 parent c58c45c commit a7d02ba

6 files changed

Lines changed: 98 additions & 56 deletions

File tree

Gruntfile.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ module.exports = function(grunt) {
150150
"public/vendor/vendor.css": [
151151
// TODO: resolve relative resource paths in
152152
// bootstrap/FA/jquery
153+
],
154+
"public/vendor/vendor-jquery.js": [
155+
"editor/vendor/jquery/js/jquery-1.11.3.min.js",
156+
"editor/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js",
157+
"editor/vendor/jquery/js/jquery.ui.touch-punch.min.js",
153158
]
154159
}
155160
}

nodes/core/core/58-debug.html

Lines changed: 18 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
</script>
4747

4848
<script type="text/javascript">
49-
49+
(function() {
50+
var subWindow = null;
5051
RED.nodes.registerType('debug',{
5152
category: 'output',
5253
defaults: {
@@ -104,7 +105,8 @@
104105
'<a class="sidebar-header-button-toggle selected" id="debug-tab-filter-all" href="#"><span data-i18n="node-red:debug.sidebar.filterAll"></span></a>'+
105106
'<a class="sidebar-header-button-toggle" id="debug-tab-filter-current" href="#"><span data-i18n="node-red:debug.sidebar.filterCurrent"></span></a> '+
106107
'</span>'+
107-
'<span><a id="debug-tab-clear" title="clear log" class="sidebar-header-button" href="#"><i class="fa fa-trash"></i></a></span></div>').appendTo(content);
108+
'<span class="button-group"><a id="debug-tab-open" title="open in new window" class="sidebar-header-button" href="#"><i class="fa fa-desktop"></i></a></span> ' +
109+
'<span class="button-group"><a id="debug-tab-clear" title="clear log" class="sidebar-header-button" href="#"><i class="fa fa-trash"></i></a></span></div>').appendTo(content);
108110

109111
var messages = $('<div id="debug-content"/>').appendTo(content);
110112
content.i18n();
@@ -143,6 +145,14 @@
143145
}
144146

145147
this.handleDebugMessage = function(t,o) {
148+
149+
if (subWindow) {
150+
try {
151+
subWindow.postMessage(JSON.stringify(o),"*")
152+
} catch(err) {
153+
console.log(err);
154+
}
155+
}
146156
var msg = document.createElement("div");
147157

148158
var sourceNode = RED.nodes.node(o.id) || RED.nodes.node(o.z);
@@ -245,7 +255,10 @@
245255
}
246256
});
247257
RED.events.on("workspace:change", refreshMessageList);
248-
258+
$("#debug-tab-open").click(function(e) {
259+
e.preventDefault();
260+
subWindow = window.open(document.location.toString().replace(/#$/,"")+"debug/view/view.html","nodeREDDebugView","menubar=no,location=no,toolbar=no,chrome,height=500,width=600");
261+
});
249262
},
250263
onpaletteremove: function() {
251264
RED.comms.unsubscribe("debug",this.handleDebugMessage);
@@ -282,58 +295,7 @@
282295
}
283296

284297
});
298+
})();
285299
</script>
286300

287-
<style>
288-
#debug-content {
289-
position: absolute;
290-
top: 43px;
291-
bottom: 0px;
292-
left:0px;
293-
right: 0px;
294-
overflow-y: scroll;
295-
}
296-
.debug-message {
297-
cursor: pointer;
298-
border-bottom: 1px solid #eee;
299-
border-left: 8px solid #eee;
300-
border-right: 8px solid #eee;
301-
padding: 2px;
302-
}
303-
.debug-message-date {
304-
background: #fff;
305-
font-size: 9px;
306-
color: #aaa;
307-
padding: 1px 5px 1px 1px;
308-
}
309-
.debug-message-topic {
310-
display: block;
311-
background: #fff;
312-
padding: 1px;
313-
font-size: 10px;
314-
color: #a66;
315-
}
316-
.debug-message-name {
317-
background: #fff;
318-
padding: 1px 5px;
319-
font-size: 9px;
320-
color: #aac;
321-
}
322-
.debug-message-payload {
323-
display: block;
324-
padding: 2px;
325-
background: #fff;
326-
}
327-
.debug-message-level-log {
328-
border-left-color: #eee;
329-
border-right-color: #eee;
330-
}
331-
.debug-message-level-30 {
332-
border-left-color: #ffdf9d;
333-
border-right-color: #ffdf9d;
334-
}
335-
.debug-message-level-20 {
336-
border-left-color: #f99;
337-
border-right-color: #f99;
338-
}
339-
</style>
301+
<link rel="stylesheet" href="debug/view/style.css">

nodes/core/core/58-debug.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = function(RED) {
1818
"use strict";
1919
var util = require("util");
2020
var events = require("events");
21+
var path = require("path");
2122
var debuglength = RED.settings.debugMaxLength||1000;
2223
var useColors = false;
2324
// util.inspect.styles.boolean = "red";
@@ -153,4 +154,13 @@ module.exports = function(RED) {
153154
res.sendStatus(404);
154155
}
155156
});
157+
158+
RED.httpAdmin.get("/debug/view/*",RED.auth.needsPermission("debug.read"),function(req,res) {
159+
var options = {
160+
root: __dirname + '/lib/debug/',
161+
dotfiles: 'deny'
162+
};
163+
console.log("SERVING UP",req.params[0]);
164+
res.sendFile(req.params[0], options);
165+
});
156166
};

nodes/core/core/lib/debug/debug.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$(function() {
2+
window.addEventListener('message',function(evt) {
3+
console.log(evt.data);
4+
$('<div>').text(evt.data).appendTo(document.body);
5+
},false)
6+
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#debug-content {
2+
position: absolute;
3+
top: 43px;
4+
bottom: 0px;
5+
left:0px;
6+
right: 0px;
7+
overflow-y: scroll;
8+
}
9+
.debug-message {
10+
cursor: pointer;
11+
border-bottom: 1px solid #eee;
12+
border-left: 8px solid #eee;
13+
border-right: 8px solid #eee;
14+
padding: 2px;
15+
}
16+
.debug-message-date {
17+
background: #fff;
18+
font-size: 9px;
19+
color: #aaa;
20+
padding: 1px 5px 1px 1px;
21+
}
22+
.debug-message-topic {
23+
display: block;
24+
background: #fff;
25+
padding: 1px;
26+
font-size: 10px;
27+
color: #a66;
28+
}
29+
.debug-message-name {
30+
background: #fff;
31+
padding: 1px 5px;
32+
font-size: 9px;
33+
color: #aac;
34+
}
35+
.debug-message-payload {
36+
display: block;
37+
padding: 2px;
38+
background: #fff;
39+
}
40+
.debug-message-level-log {
41+
border-left-color: #eee;
42+
border-right-color: #eee;
43+
}
44+
.debug-message-level-30 {
45+
border-left-color: #ffdf9d;
46+
border-right-color: #ffdf9d;
47+
}
48+
.debug-message-level-20 {
49+
border-left-color: #f99;
50+
border-right-color: #f99;
51+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<head>
3+
<link rel="stylesheet" href="style.css">
4+
</head>
5+
<body></body>
6+
<script src="../../vendor/vendor-jquery.js"></script>
7+
<script src="debug.js"></script>
8+
</html>

0 commit comments

Comments
 (0)