@gregoriusrippenstein/node-red-contrib-introspection 0.8.0 → 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.
@@ -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
 
@@ -36,6 +49,44 @@ module.exports = function(RED) {
36
49
  }
37
50
  RED.nodes.registerType("ClientCode", ClientCodeFunctionality);
38
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
+
39
90
  RED.httpAdmin.post("/ClientCode/:id",
40
91
  RED.auth.needsPermission("ClientCode.write"),
41
92
  (req,res) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gregoriusrippenstein/node-red-contrib-introspection",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "dependencies": {
5
5
  "got": "^13",
6
6
  "uglify-js": "^3.17.4",
@@ -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 -->