@gregoriusrippenstein/node-red-contrib-introspection 0.7.9 → 0.8.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.
- package/nodes/60-client-code.js +59 -0
- package/package.json +1 -1
- package/plugins/sidebar.html +31 -0
package/nodes/60-client-code.js
CHANGED
|
@@ -2,6 +2,19 @@ module.exports = function(RED) {
|
|
|
2
2
|
let UglifyJS = require('uglify-js');
|
|
3
3
|
let CleanCSS = require('clean-css');
|
|
4
4
|
|
|
5
|
+
const OnReceiveHookName = "onReceive.introspectionMsgTracer"
|
|
6
|
+
const OnPreuninstallHookName = "preUninstall.introspectionMsgTracer"
|
|
7
|
+
|
|
8
|
+
function msgTracerOnReceiveHook(evnt) {
|
|
9
|
+
try {
|
|
10
|
+
let nde = RED.nodes.getNode(evnt.destination.id)
|
|
11
|
+
nde.status({ fill: "green", shape: "ring", text: "msg received" })
|
|
12
|
+
setTimeout(() => { nde.status({}) }, 1000)
|
|
13
|
+
} catch (ex) {
|
|
14
|
+
console.error(ex)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
5
18
|
function ClientCodeFunctionality(config) {
|
|
6
19
|
RED.nodes.createNode(this,config);
|
|
7
20
|
|
|
@@ -13,6 +26,14 @@ module.exports = function(RED) {
|
|
|
13
26
|
});
|
|
14
27
|
|
|
15
28
|
node.on("input", function(msg, send, done) {
|
|
29
|
+
// msg object may cause problem if there are circular references, so
|
|
30
|
+
// do a pre-stringify before erroring out.
|
|
31
|
+
try {
|
|
32
|
+
JSON.stringify(msg)
|
|
33
|
+
} catch (e) {
|
|
34
|
+
msg = `[Error in JSON.stringify(msg)]\n${e}\n[End Error]\n`
|
|
35
|
+
}
|
|
36
|
+
|
|
16
37
|
RED.comms.publish(
|
|
17
38
|
"introspect:client-code-perform",
|
|
18
39
|
RED.util.encodeObject({
|
|
@@ -28,6 +49,44 @@ module.exports = function(RED) {
|
|
|
28
49
|
}
|
|
29
50
|
RED.nodes.registerType("ClientCode", ClientCodeFunctionality);
|
|
30
51
|
|
|
52
|
+
|
|
53
|
+
RED.httpAdmin.post("/ClientCode/msgtracer/on",
|
|
54
|
+
RED.auth.needsPermission("ClientCode.write"),
|
|
55
|
+
(req, res) => {
|
|
56
|
+
try {
|
|
57
|
+
RED.hooks.remove(OnReceiveHookName)
|
|
58
|
+
RED.hooks.add(OnReceiveHookName, msgTracerOnReceiveHook)
|
|
59
|
+
|
|
60
|
+
// add hook on uninstall package so that the hook for the
|
|
61
|
+
// message tracer is removed on uninstall of this package.
|
|
62
|
+
RED.hooks.remove(OnPreuninstallHookName)
|
|
63
|
+
RED.hooks.add(OnPreuninstallHookName, (evnt) => {
|
|
64
|
+
if (evnt.module == "@gregoriusrippenstein/node-red-contrib-introspection") {
|
|
65
|
+
RED.hooks.remove(OnReceiveHookName)
|
|
66
|
+
RED.hooks.remove(OnPreuninstallHookName)
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
res.sendStatus(200);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
res.sendStatus(500);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
RED.httpAdmin.post("/ClientCode/msgtracer/off",
|
|
77
|
+
RED.auth.needsPermission("ClientCode.write"),
|
|
78
|
+
(req, res) => {
|
|
79
|
+
try {
|
|
80
|
+
|
|
81
|
+
RED.hooks.remove(OnReceiveHookName)
|
|
82
|
+
RED.hooks.remove(OnPreuninstallHookName)
|
|
83
|
+
|
|
84
|
+
res.sendStatus(200);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
res.sendStatus(500);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
31
90
|
RED.httpAdmin.post("/ClientCode/:id",
|
|
32
91
|
RED.auth.needsPermission("ClientCode.write"),
|
|
33
92
|
(req,res) => {
|
package/package.json
CHANGED
package/plugins/sidebar.html
CHANGED
|
@@ -238,6 +238,28 @@
|
|
|
238
238
|
$('.red-ui-linkcall-link-indicator').remove()
|
|
239
239
|
})
|
|
240
240
|
|
|
241
|
+
$('#node-input-msgtracer-toggle').on("change", function (e) {
|
|
242
|
+
$.ajax({
|
|
243
|
+
url: "ClientCode/msgtracer/" + ($('#node-input-msgtracer-toggle').is(":checked") ? "on" : "off"),
|
|
244
|
+
type: "POST",
|
|
245
|
+
contentType: "application/json; charset=utf-8",
|
|
246
|
+
data: {},
|
|
247
|
+
success: function (resp) {
|
|
248
|
+
RED.notify("Message tracing succeed", {
|
|
249
|
+
type: "success",
|
|
250
|
+
timeout: 3000
|
|
251
|
+
})
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
error: function (jqXHR, textStatus, errorThrown) {
|
|
255
|
+
RED.notify("Message tracing failed: " +textStatus, {
|
|
256
|
+
type: "error",
|
|
257
|
+
timeout: 3000
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
})
|
|
262
|
+
|
|
241
263
|
RED.actions.add( "introspection:show-link-call-links", highlightAllLinkCalls)
|
|
242
264
|
|
|
243
265
|
$('#node-input-linkcalls-find-btn').on('click', (e) => {
|
|
@@ -358,6 +380,15 @@
|
|
|
358
380
|
<button id="node-input-orphan-clear-workspace-btn"
|
|
359
381
|
class="red-ui-button">Clear dots</button>
|
|
360
382
|
</div>
|
|
383
|
+
|
|
384
|
+
<div class="form-row" style="margin-left: 10px; margin-top: 40px">
|
|
385
|
+
<label for="node-input-msgtracer-toggle" class="w-30">
|
|
386
|
+
<i class="fa fa-tag"></i>
|
|
387
|
+
<span>Trace Messages?</span>
|
|
388
|
+
</label>
|
|
389
|
+
<input type="checkbox" id="node-input-msgtracer-toggle"
|
|
390
|
+
style="display:inline-block; width:15px; vertical-align:baseline;">
|
|
391
|
+
</div>
|
|
361
392
|
</div>
|
|
362
393
|
|
|
363
394
|
<!-- Obfuscation Tab in Sidebar -->
|