@gregoriusrippenstein/node-red-contrib-introspection 0.8.6 → 0.9.0

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.
@@ -1,124 +1,8 @@
1
1
  <script type="text/javascript">
2
2
 
3
- RED.comms.subscribe('msgtracer:node-received', (event,data) => {
4
- if ( data.nodeid) {
5
- let node = RED.nodes.node(data.nodeid)
6
- let olddata = $("#node-input-msgtracer-trace-treelist").treeList('data')
7
- let foundItem = false;
8
-
9
- olddata.forEach( itm => {
10
- if ( itm.id == node.id ) {
11
- foundItem = true
12
- itm.sublabel = "" + (parseInt(itm.sublabel) + 1)
13
- }
14
- })
15
-
16
- if ( !foundItem ) {
17
- let nodeDef = RED.nodes.getType(node.type);
18
- let label;
19
-
20
- if (nodeDef) {
21
- let l = nodeDef.label;
22
- label = (typeof l === "function" ? l.call(node) : l) || node.type;
23
- } else {
24
- label = node.type
25
- }
26
-
27
- let newitem = {
28
- id: node.id,
29
- label: label,
30
- sublabel: "1",
31
- selected: false,
32
- checkbox: false,
33
- node: node
34
- }
35
-
36
- $("#node-input-msgtracer-trace-treelist").treeList('data',[newitem, ...olddata])
37
- } else {
38
- $("#node-input-msgtracer-trace-treelist").treeList('data',olddata)
39
- }
40
- }
41
- })
3
+ function handleMsgTracePacket(e,r){if(r.nodeid){let a=RED.nodes.node(r.nodeid);if(a){r=$("#node-input-msgtracer-trace-treelist").treeList("data");let t=!1;if(r.forEach(e=>{e.id==a.id&&(t=!0,e.seenCounter+=1,e.sublabel=e.seenCounter+" @ "+e.workspaceLabel)}),t)$("#node-input-msgtracer-trace-treelist").treeList("data",r);else{var l=RED.nodes.getType(a.type);let e;e=l&&("function"==typeof(l=l.label)?l.call(a):l)||a.type;l={id:a.id,label:e,seenCounter:1,workspaceLabel:(RED.nodes.workspace(a.z)||{label:a.z}).label,sublabel:"1 @ "+(RED.nodes.workspace(a.z)||{label:a.z}).label,selected:!1,checkbox:!1,node:a};$("#node-input-msgtracer-trace-treelist").treeList("data",[l,...r])}}}}RED.comms.subscribe("msgtracer:node-received",(e,t)=>{try{handleMsgTracePacket(e,t)}catch(e){console.error(e)}});
42
4
 
43
- RED.comms.subscribe('introspect:client-code-perform', (event,data) => {
44
- if ( data.msg == "execfunc" ) {
45
-
46
- var doSend = (data, nodeid, _msg) => {
47
- if ( typeof data == "object" ) {
48
- data = {
49
- ..._msg,
50
- ...data
51
- };
52
- }
53
-
54
- $.ajax({
55
- url: "ClientCode/" + nodeid,
56
- type: "POST",
57
- contentType: "application/json; charset=utf-8",
58
- data: JSON.stringify(data),
59
-
60
- success: function (resp) {
61
- },
62
-
63
- error: function (jqXHR, textStatus, errorThrown) {
64
- RED.notify("ClientCode Communcation Failure: " +
65
- nodeid + ": " + textStatus, {
66
- type: "error",
67
- id: nodeid,
68
- timeout: 3000
69
- });
70
- }
71
- });
72
- };
73
-
74
- var doStatus = (sts, nodeid, _msg) => {
75
- $.ajax({
76
- url: "ClientCode/" + nodeid + "/status",
77
- type: "POST",
78
- contentType: "application/json; charset=utf-8",
79
- data: JSON.stringify(sts),
80
-
81
- success: function (resp) {
82
- },
83
-
84
- error: function (jqXHR, textStatus, errorThrown) {
85
- RED.notify("ClientCode Communcation Failure: " +
86
- nodeid + ": " + textStatus, {
87
- type: "error",
88
- id: nodeid,
89
- timeout: 3000
90
- });
91
- }
92
- });
93
- }
94
-
95
- var doError = (msg, nodeid, _msg) => {
96
- RED.notify("ClientCode Failed: " + nodeid + ": " + msg, {
97
- type: "error",
98
- id: nodeid,
99
- timeout: 3000
100
- });
101
-
102
- console.log( "ClientCode: Error with node: " + nodeid + ": " + msg);
103
- };
104
-
105
- var nodeid = data.nodeid;
106
- var _msg = data._msg;
107
- var msg = data._msg;
108
-
109
- var node = {
110
- id: data.nodeid,
111
- send: (dt) => { doSend(dt, nodeid, _msg) },
112
- error: (mg) => { doError(mg, nodeid, _msg) },
113
- status: (sts) => { doStatus(sts, nodeid, _msg) }
114
- };
115
-
116
- var payload = data.payload;
117
- var topic = data.topic;
118
-
119
- eval( data.func );
120
- }
121
- });
5
+ function handleClientCodeFrontend(event,data){var doSend,doStatus,doError,nodeid,_msg,msg,node,payload,topic;"execfunc"==data.msg&&(doSend=(o,d,e)=>{"object"==typeof o&&(o={...e,...o}),$.ajax({url:"ClientCode/"+d,type:"POST",contentType:"application/json; charset=utf-8",data:JSON.stringify(o),success:function(o){},error:function(o,e,t){RED.notify("ClientCode Communcation Failure: "+d+": "+e,{type:"error",id:d,timeout:3e3})}})},doStatus=(o,d,e)=>{$.ajax({url:"ClientCode/"+d+"/status",type:"POST",contentType:"application/json; charset=utf-8",data:JSON.stringify(o),success:function(o){},error:function(o,e,t){RED.notify("ClientCode Communcation Failure: "+d+": "+e,{type:"error",id:d,timeout:3e3})}})},doError=(o,e,t)=>{RED.notify("ClientCode Failed: "+e+": "+o,{type:"error",id:e,timeout:3e3}),console.log("ClientCode: Error with node: "+e+": "+o)},nodeid=data.nodeid,_msg=data._msg,msg=data._msg,node={id:data.nodeid,send:o=>{doSend(o,nodeid,_msg)},error:o=>{doError(o,nodeid,_msg)},status:o=>{doStatus(o,nodeid,_msg)}},payload=data.payload,topic=data.topic,eval(data.func))}RED.comms.subscribe("introspect:client-code-perform",(o,e)=>{try{handleClientCodeFrontend(o,e)}catch(o){console.error(o)}});
122
6
 
123
7
  RED.nodes.registerType('ClientCode',{
124
8
  color: '#e5e4ef',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gregoriusrippenstein/node-red-contrib-introspection",
3
- "version": "0.8.6",
3
+ "version": "0.9.0",
4
4
  "dependencies": {
5
5
  "got": "^13",
6
6
  "uglify-js": "^3.17.4",
@@ -14,7 +14,7 @@
14
14
 
15
15
  function setupTreelistAllLinksForLinkIn(e){e=collectAllLinksNodes(e);if(0==e.length){RED.notify("No links found",{type:"error",timeout:2e3});try{$("#node-input-orphan-target-container-div").treeList("empty")}catch(e){}}else{try{$("#node-input-orphan-target-container-div").treeList("empty")}catch(e){$("#node-input-orphan-target-container-div").css({width:"100%",height:"calc(100%)"}).treeList({multi:!1}).on("treelistitemmouseover",function(e,t){}).on("treelistitemmouseout",function(e,t){}).on("treelistselect",function(e,t){t.node&&(RED.workspaces.show(t.node.z,!1,!1,!0),RED.view.reveal(t.node.id,!0),RED.view.redraw())}).on("treelistconfirm",function(e,t){var n;t.node&&(n=t.node.id,setTimeout(()=>{var e=RED.nodes.node(n);e&&(RED.view.reveal(e.id),RED.view.select(e.id),RED.editor.edit(e,"editor-tab-description")),n==RED.workspaces.active()&&RED.workspaces.edit()},50))}),$("#node-input-orphan-target-filter").show();var n=$("#node-input-orphan-target-filter").searchBox({style:"compact",delay:300,change:function(){var e,t=$(this).val().trim().toLowerCase();""===t?($("#node-input-orphan-target-container-div").treeList("filter",null),n.searchBox("count","")):(e=$("#node-input-orphan-target-container-div").treeList("filter",function(e){return-1<e.label.toLowerCase().indexOf(t)||-1<e.node.type.toLowerCase().indexOf(t)}),n.searchBox("count",e+" / "+$("#node-input-orphan-target-container-div").treeList("data").length))}})}$("#node-input-orphan-target-container-div").treeList("data",e.sort((e,t)=>e.node.z>t.node.z))}}function collectAllLinksNodes(t){let n=[];RED.nodes.eachNode(e=>{"link call"!=e.type&&"link out"!=e.type||-1<e.links.indexOf(t)&&n.push(e)});var i=[],r={};return n.forEach(function(e){var t=RED.nodes.getType(e.type);if(t){var n,o=t.label,o=("function"==typeof o?o.call(e):o)||"";if(0===(n=e.type).indexOf("subflow:"))return}t&&o||(o=e.type),r[e.id]={node:e,label:o,sublabel:n,selected:!1,checkbox:!1},i.push(r[e.id])}),i}function collectNodeStats(){let t={},n=[],o={workspaces:0,junctions:0,subflows:0,configs:0,groups:0,wires:0,nodes:0},i=(RED.nodes.eachConfig(e=>{o.configs+=1}),RED.nodes.eachLink(e=>{o.wires+=1}),RED.nodes.eachJunction(e=>{o.junctions+=1}),RED.nodes.eachGroup(e=>{o.groups+=1}),RED.nodes.eachWorkspace(e=>{o.workspaces+=1}),RED.nodes.eachSubflow(e=>{o.subflows+=1}),RED.nodes.eachNode(e=>{o.nodes+=1,t[e.type]=(t[e.type]||0)+1}),Object.keys(t).forEach(e=>{n.push({label:e,sublabel:t[e],selected:!1,checkbox:!1})}),[]),r=0;return Object.keys(o).forEach(e=>{r+=o[e],i.push({label:e,sublabel:o[e],selected:!1,checkbox:!1})}),[{label:"__ TOTALS",sublabel:r,selected:!1,checkbox:!1,children:i}].concat(n.sort((e,t)=>e.label>t.label))}function setupTreeListForNodeStats(){var e=collectNodeStats();try{$("#node-input-orphan-target-container-div").treeList("empty")}catch(e){$("#node-input-orphan-target-container-div").css({width:"100%",height:"calc(100%)"}).treeList({multi:!1}).on("treelistitemmouseover",function(e,t){}).on("treelistitemmouseout",function(e,t){}).on("treelistselect",function(e,t){}).on("treelistconfirm",function(e,t){}),$("#node-input-orphan-target-filter").show();var n=$("#node-input-orphan-target-filter").searchBox({style:"compact",delay:300,change:function(){var e,t=$(this).val().trim().toLowerCase();""===t?($("#node-input-orphan-target-container-div").treeList("filter",null),n.searchBox("count","")):(e=$("#node-input-orphan-target-container-div").treeList("filter",function(e){return-1<e.label.toLowerCase().indexOf(t)}),n.searchBox("count",e+" / "+$("#node-input-orphan-target-container-div").treeList("data").length))}})}$("#node-input-orphan-target-container-div").treeList("data",e)}
16
16
 
17
- function setupTreeMsgTracerlist(){try{$("#node-input-msgtracer-trace-treelist").treeList("empty"),$("#node-input-msgtracer-trace-treelist").treeList("data",[])}catch(e){$("#node-input-msgtracer-trace-treelist").css({width:"100%",height:"calc(100%)"}).treeList({multi:!1}).on("treelistitemmouseover",function(e,t){}).on("treelistitemmouseout",function(e,t){}).on("treelistselect",function(e,t){t.node&&(RED.workspaces.show(t.node.z,!1,!1,!0),RED.view.reveal(t.node.id,!0),RED.view.redraw())}).on("treelistconfirm",function(e,t){var r;t.node&&(r=t.node.id,setTimeout(()=>{var e=RED.nodes.node(r);e&&(RED.view.reveal(e.id),RED.view.select(e.id),RED.editor.edit(e)),r==RED.workspaces.active()&&RED.workspaces.edit()},50))}),$("#node-input-msgtracer-trace-treelist-filter").show();var r=$("#node-input-msgtracer-trace-treelist-filter").searchBox({style:"compact",delay:300,change:function(){var e,t=$(this).val().trim().toLowerCase();""===t?($("#node-input-msgtracer-trace-treelist").treeList("filter",null),r.searchBox("count","")):(e=$("#node-input-msgtracer-trace-treelist").treeList("filter",function(e){return-1<e.label.toLowerCase().indexOf(t)||-1<e.node.type.toLowerCase().indexOf(t)}),r.searchBox("count",e+" / "+$("#node-input-msgtracer-trace-treelist").treeList("data").length))}})}}function toggleMsgTracingInBackend(e){let t=$("#node-input-msgtracer-toggle").is(":checked"),r=$("#node-input-msgtracer-msgtodebug").is(":checked");$.ajax({url:"MsgTracer/msgtracing/"+(t?"on":"off"),type:"POST",contentType:"application/json; charset=utf-8",data:JSON.stringify({withDebug:r}),success:function(e){RED.notify("Message tracing is <b>"+(t?"on":"off")+"</b> and msg to debug is <b>"+(r?"on":"off")+"</b>",{type:"success",timeout:3e3})},error:function(e,t,r){RED.notify("Message tracing failed: "+t,{type:"error",timeout:3e3})}})}function handleMsgTracerToggles(e){$("#node-input-msgtracer-toggle").is(":checked")&&setupTreeMsgTracerlist(),toggleMsgTracingInBackend(e)}
17
+ function setupTreeMsgTracerlist(){try{$("#node-input-msgtracer-trace-treelist").treeList("empty"),$("#node-input-msgtracer-trace-treelist").treeList("data",[])}catch(e){$("#node-input-msgtracer-trace-treelist").css({width:"100%",height:"calc(100%)"}).treeList({multi:!1}).on("treelistitemmouseover",function(e,t){}).on("treelistitemmouseout",function(e,t){}).on("treelistselect",function(e,t){t.node&&(RED.workspaces.show(t.node.z,!1,!1,!0),RED.view.reveal(t.node.id,!0),RED.view.redraw())}).on("treelistconfirm",function(e,t){var r;t.node&&(r=t.node.id,setTimeout(()=>{var e=RED.nodes.node(r);e&&(RED.view.reveal(e.id),RED.view.select(e.id),RED.editor.edit(e)),r==RED.workspaces.active()&&RED.workspaces.edit()},50))}),$("#node-input-msgtracer-trace-treelist-filter").show();var r=$("#node-input-msgtracer-trace-treelist-filter").searchBox({style:"compact",delay:300,change:function(){var e,t=$(this).val().trim().toLowerCase();""===t?($("#node-input-msgtracer-trace-treelist").treeList("filter",null),r.searchBox("count","")):(e=$("#node-input-msgtracer-trace-treelist").treeList("filter",function(e){return-1<e.label.toLowerCase().indexOf(t)||-1<e.node.type.toLowerCase().indexOf(t)||-1<e.node.id.toLowerCase().indexOf(t)}),r.searchBox("count",e+" / "+$("#node-input-msgtracer-trace-treelist").treeList("data").length))}})}}function toggleMsgTracingInBackend(e){let t=$("#node-input-msgtracer-toggle").is(":checked"),r=$("#node-input-msgtracer-msgtodebug").is(":checked");$.ajax({url:"MsgTracer/msgtracing/"+(t?"on":"off"),type:"POST",contentType:"application/json; charset=utf-8",data:JSON.stringify({withDebug:r}),success:function(e){RED.notify("Message tracing is <b>"+(t?"on":"off")+"</b> and msg to debug is <b>"+(r?"on":"off")+"</b>",{type:"success",timeout:3e3})},error:function(e,t,r){RED.notify("Message tracing failed: "+t,{type:"error",timeout:3e3})}})}function handleMsgTracerToggles(e){$("#node-input-msgtracer-toggle").is(":checked")&&setupTreeMsgTracerlist(),toggleMsgTracingInBackend(e)}
18
18
 
19
19
  // Add your plugin as a new tabsheet in the right sidebar AFTER the flow editor is completely started
20
20
  var initialiseConfigNodeOnce = () => {
@@ -240,6 +240,12 @@
240
240
  $('.red-ui-linkcall-link-indicator').remove()
241
241
  })
242
242
 
243
+ $('#node-input-msgtrace-clear-debug-btn').on('click', (e) => {
244
+ if ( e ) { e.preventDefault() }
245
+ // from [debug node](https://github.com/node-red/node-red/blob/2854351909dee9f92597faba3f37239134294eec/packages/node_modules/%40node-red/nodes/core/common/21-debug.html#L437)
246
+ RED.actions.invoke("core:clear-debug-messages")
247
+ })
248
+
243
249
  $('#node-input-msgtrace-clear-trace-btn').on('click', (e) => {
244
250
  if ( e ) { e.preventDefault() }
245
251
  setupTreeMsgTracerlist()
@@ -392,6 +398,8 @@
392
398
 
393
399
  <button id="node-input-msgtrace-clear-trace-btn" style="margin-left: 10px;"
394
400
  class="red-ui-button">Clear Trace</button>
401
+ <button id="node-input-msgtrace-clear-debug-btn" style="margin-left: 10px;"
402
+ class="red-ui-button">Clear Debug</button>
395
403
  </div>
396
404
 
397
405
  <div class="form-row"