@gregoriusrippenstein/node-red-contrib-introspection 0.9.7 → 0.9.8

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,287 +1,28 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('Seeker',{
3
- color: '#e5e4ef',
4
- icon: "font-awesome/fa-ship",
5
- category: 'introspection',
6
- paletteLabel: "Seeker",
7
- defaults: {
8
- name: {
9
- value:"",
10
- },
11
- },
12
- inputs:0,
13
- outputs:1,
14
-
15
- label: function() {
16
- return (this.name || this._def.paletteLabel);
17
- },
18
-
19
- labelStyle: function() {
20
- return this.name?"node_label_italic":"";
21
- },
22
-
23
- oneditprepare: function() {
24
- var that = this;
25
-
26
- this._resize = function() {
27
- var rows = $("#dialog-form>div:not(.node-input-target-list-row)");
28
- var height = $("#dialog-form").height();
29
- for (var i=0;i<rows.length;i++) {
30
- height -= $(rows[i]).outerHeight(true);
31
- }
32
- var editorRow = $("#dialog-form>div.node-input-target-list-row");
33
- editorRow.css("height",height+"px");
34
- };
35
-
36
- var search = $("#node-input-seeker-target-filter").searchBox({
37
- style: "compact",
38
- delay: 300,
39
- change: function() {
40
- var val = $(this).val().trim().toLowerCase();
41
- if (val === "") {
42
- dirList.treeList("filter", null);
43
- search.searchBox("count","");
44
- } else {
45
- var count = dirList.treeList("filter", function(item) {
46
- return item.label.toLowerCase().indexOf(val) > -1 || item.node.type.toLowerCase().indexOf(val) > -1
47
- });
48
- search.searchBox("count",count+" / "+items.length);
49
- }
50
- }
51
- });
52
-
53
- var dirList = $("#node-input-seeker-target-container-div").css({
54
- width: "100%",
55
- height: "100%"
56
- }).treeList({
57
- multi:true
58
- }).on("treelistitemmouseover", function(e, item) {
59
- if ( item.node) {
60
- if ( item.children) {
61
- item.node.highlighted = true;
62
- item.node.dirty = true;
63
- item.children.forEach( function(n) {
64
- n.node.highlighted = true;
65
- n.node.dirty = true;
66
- });
67
- } else {
68
- item.node.highlighted = true;
69
- item.node.dirty = true;
70
- }
71
- RED.view.redraw();
72
- }
73
- }).on("treelistitemmouseout", function(e, item) {
74
-
75
- if ( item.node ) {
76
- if ( item.children ) {
77
- item.node.highlighted = false;
78
- item.node.dirty = true;
79
- item.children.forEach( function(n) {
80
- n.node.highlighted = false;
81
- n.node.dirty = true;
82
- });
83
- } else {
84
- item.node.highlighted = false;
85
- item.node.dirty = true;
86
- }
87
- RED.view.redraw();
88
- }
89
- }).on('treelistselect', function(event, item) {
90
- if ( item.node ) {
91
- if ( item.children) {
92
- var preselected = item.children.map(function(n) {
93
- return n.node.id
94
- });
95
-
96
- RED.tray.hide();
97
- RED.view.selectNodes({
98
- selected: preselected,
99
- onselect: function(selection) {
100
- RED.tray.show();
101
- },
102
- oncancel: function() {
103
- RED.tray.show();
104
- }
105
- });
106
-
107
- } else {
108
- RED.workspaces.show(item.node.z,false,false,true);
109
- item.node.highlighted = true;
110
- item.node.dirty = true;
111
- RED.view.reveal(item.node.id,true)
112
- }
113
-
114
- RED.view.redraw();
115
- }
116
- });
117
-
118
- var nodePaths = [];
119
-
120
- var traverse = function( node, nodeIds ) {
121
- if ( nodeIds.indexOf(node.id) < 0 ) {
122
-
123
- switch( node.type ) {
124
-
125
- case "link call":
126
- RED.nodes.getNodeLinks(node).forEach( function(l) {
127
- traverse( l.target, [...nodeIds, node.id] );
128
- });
129
-
130
- node.links.forEach( function(lnkNdeId) {
131
- var dNode = RED.nodes.node(lnkNdeId);
132
- if ( !dNode ) { return }
133
-
134
- traverse( dNode, [...nodeIds, node.id] );
135
- });
136
-
137
- break;
138
-
139
- case "link out":
140
- node.links.forEach( function(lnkNdeId) {
141
- var dNode = RED.nodes.node(lnkNdeId);
142
- if ( !dNode ) { return }
143
-
144
- traverse( dNode, [...nodeIds, node.id] );
145
- });
146
- break;
147
-
148
- case "Sink":
149
- nodePaths.push(nodeIds);
150
- break;
151
-
152
- default:
153
- RED.nodes.getNodeLinks(node).forEach( function(l) {
154
- traverse( l.target, [...nodeIds, node.id] );
155
- })
156
- }
157
- }
158
- };
159
-
160
- RED.nodes.getNodeLinks(that).forEach( function(l) {
161
- traverse(l.target, [])
162
- });
163
-
164
- var items = [];
165
- var nodeItemMap = {};
166
-
167
- var listOfNodes = function(nodePaths) {
168
- var lenNodePaths = nodePaths.length;
169
- if ( lenNodePaths > 25 ) {
170
- var rdmIdx = Math.floor( Math.random() * lenNodePaths );
171
- /* Avoid duplication by taking a random range of 25 nodes */
172
- return [...nodePaths, ...nodePaths.slice(0,30)].slice(
173
- rdmIdx, rdmIdx + 25
174
- )
175
- } else {
176
- return nodePaths;
177
- }
178
- }
179
-
180
- listOfNodes(nodePaths).forEach( function (path) {
181
- var n = RED.nodes.node(path[0]);
182
-
183
- var nodeDef = RED.nodes.getType(n.type);
184
- var label;
185
- var sublabel = "Nodes: " + path.length;
186
-
187
- if (nodeDef) {
188
- var l = nodeDef.label;
189
- label = (typeof l === "function" ? l.call(n) : l)||"";
190
-
191
- if (sublabel.indexOf("subflow:") === 0) {
192
- return;
193
- }
194
- }
195
-
196
- if (!nodeDef || !label) {
197
- label = n.type;
198
- }
199
-
200
- var children = [];
201
-
202
- path.forEach( function(nId) {
203
- var nde = RED.nodes.node(nId);
204
-
205
- /* junctions can be undefined */
206
- if ( nde === undefined ) { return }
207
-
208
- var ndeDef = RED.nodes.getType(nde.type);
209
- var labelStr = nde.type;
210
-
211
- if ( ndeDef ) {
212
- labelStr = (typeof ndeDef.label === "function" ?
213
- ndeDef.label.call(nde) : ndeDef.label) || nde.type ||"";
214
- }
215
-
216
- children.push(
217
- {
218
- "label": labelStr,
219
- "node": nde,
220
- "sublabel": nde.type
221
- }
222
- )
223
- });
224
-
225
- nodeItemMap[n.id] = {
226
- node: n,
227
- label: label,
228
- sublabel: sublabel,
229
- selected: false,
230
- checkbox: false,
231
- children: children
232
- };
233
- items.push(nodeItemMap[n.id]);
234
- });
235
-
236
- dirList.treeList('data',items);
237
-
238
- $("#node-input-seeker-target-select").on("click", function(e) {
239
- e.preventDefault();
240
- var preselected = dirList.treeList('selected').map(function(n) {
241
- return n.node.id
242
- });
243
-
244
- RED.tray.hide();
245
- RED.view.selectNodes({
246
- selected: preselected,
247
- onselect: function(selection) {
248
- RED.tray.show();
249
- },
250
- oncancel: function() {
251
- RED.tray.show();
252
- },
253
- filter: function(n) {
254
- return n.id !== that.id;
255
- }
256
- });
257
- })
258
- },
259
-
260
- oneditsave: function() {
261
- },
262
-
263
- oneditresize: function(size) {
264
- this._resize();
265
- }
266
-
267
- });
2
+ RED.nodes.registerType("Seeker",{color:"#e5e4ef",icon:"font-awesome/fa-ship",category:"introspection",paletteLabel:"Seeker",defaults:{name:{value:""}},inputs:0,outputs:1,label:function(){return this.name||this._def.paletteLabel},labelStyle:function(){return this.name?"node_label_italic":""},oneditprepare:function(){var t=this,o=$("#node-input-seeker-target-filter").searchBox({style:"compact",delay:300,change:function(){let t=$(this).val().trim().toLowerCase();var e,n=$("#node-input-seeker-target-container-div").treeList("data");""===t?($("#node-input-seeker-target-container-div").treeList("filter",null),o.searchBox("count","")):(e=$("#node-input-seeker-target-container-div").treeList("filter",function(e){return-1<e._label.toLowerCase().indexOf(t)||-1<e.node.type.toLowerCase().indexOf(t)||e.sublabel.toLowerCase().indexOf(t)}),o.searchBox("count",e+" / "+n.length))}});$("#node-input-seeker-target-container-div").css({width:"100%",height:"95%"}).treeList({multi:!1}).on("treelistitemmouseover",function(e,t){}).on("treelistitemmouseout",function(e,t){}).on("treelistconfirm",function(e,t){t.node&&!t.children&&(RED.view.reveal(t.node.id),RED.view.select(t.node.id),setTimeout(()=>{RED.editor.edit(t.node)},100))}).on("treelistselect",function(e,t){var n;t.node&&(t.children?(n=t.children.filter(e=>e.node.z==RED.workspaces.active()).map(e=>e.node.id),RED.tray.hide(),RED.view.selectNodes({selected:n,onselect:()=>{RED.tray.show()},oncancel:()=>{RED.tray.show()}})):(RED.workspaces.show(t.node.z,!1,!1,!0),RED.view.reveal(t.node.id,!0),RED.view.redraw()))});let e=e=>{var t=RED.nodes.node(e[e.length-1]);let n=[];return e.forEach(function(e){var t,e=RED.nodes.node(e);void 0!==e&&(t=RED.nodes.workspace(e.z)||RED.nodes.subflow(e.z),n.push({label:"",_label:RED.utils.getNodeLabel(e),node:e,sublabel:t&&RED.utils.getNodeLabel(t)||e.z,icon:RED.utils.createNodeIcon(e,!0)}))}),{node:t,label:RED.utils.getNodeLabel(t),_label:RED.utils.getNodeLabel(t),_pathlen:e.length,sublabel:"Length: "+e.length,selected:!1,checkbox:!1,children:n}};var i=function(t,n){if(n.indexOf(t.id)<0)switch(t.type){case"link call":RED.nodes.getNodeLinks(t).forEach(e=>{i(e.target,[...n,t.id])}),t.links.forEach(function(e){e=RED.nodes.node(e);e&&i(e,[...n,t.id])});break;case"link out":t.links.forEach(function(e){e=RED.nodes.node(e);e&&i(e,[...n,t.id])});break;case"Sink":n.push(t.id),window._introSpectionSeekerStack=[e(n),...window._introSpectionSeekerStack];break;default:RED.nodes.getNodeLinks(t).forEach(e=>{i(e.target,[...n,t.id])})}};$("#node-input-seeker-start-but").on("click",e=>{e&&e.preventDefault(),$("#node-input-seeker-start-but").prop("disabled",!0),$("#node-input-seeker-totalPaths").html(""),$("#node-input-seeker-spinner").show(),window._introSpectionSeekerStack=[],setTimeout(()=>{RED.nodes.getNodeLinks(t).forEach(e=>{i(e.target,[t.id])}),$("#node-input-seeker-start-but").prop("disabled",!1),$("#node-input-seeker-totalPaths").html(window._introSpectionSeekerStack.length),$("#node-input-seeker-spinner").hide(),$("#node-input-seeker-target-container-div").treeList("data",window._introSpectionSeekerStack.sort((e,t)=>e._pathlen<t._pathlen?-1:1)),delete window._introSpectionSeekerStack},500)})},oneditsave:function(){},oneditresize:function(e){for(var t=$("#dialog-form>div:not(.node-input-target-list-row)"),n=$("#dialog-form").height(),o=0;o<t.length;o++)n-=$(t[o]).outerHeight(!0);$("#dialog-form>div.node-input-target-list-row").css("height",n+"px")}});
268
3
  </script>
269
4
 
270
5
  <script type="text/html" data-template-name="Seeker">
271
6
 
7
+ <div class="form-row">
8
+ <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name">Name</span></label>
9
+ <input type="text" id="node-input-name" placeholder="Name">
10
+ </div>
11
+
272
12
  <div class="form-row node-input-target-row">
273
- <button id="node-input-seeker-target-select" class="red-ui-button">Show Selected</button>
13
+ <button id="node-input-seeker-start-but" class="red-ui-button"><span><i class="fa fa-refresh"></i> Find Pathways</span></button>
274
14
  </div>
275
15
 
276
- <div class="form-row node-input-target-row node-input-target-list-row" style="position: relative; min-height: 100px">
16
+ <div class="form-row node-input-target-row node-input-target-list-row" style="margin-top: 40px; position: relative; min-height: 100px">
277
17
  <div style="position: absolute; top: -30px; right: 0;"><input type="text" id="node-input-seeker-target-filter"></div>
278
18
 
279
19
  <div id="node-input-seeker-target-container-div"></div>
280
20
  </div>
281
21
 
282
- <div class="form-row">
283
- <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name">Name</span></label>
284
- <input type="text" id="node-input-name" placeholder="Name">
22
+ <div class="form-row" style="margin-top: -40px;">
23
+ <label style="float: right;">Total Paths:
24
+ <span id="node-input-seeker-totalPaths"></span><img class='hide' id="node-input-seeker-spinner" src='red/images/spin.svg'/>
25
+ </label>
285
26
  </div>
286
27
 
287
28
  </script>
@@ -1,25 +1,5 @@
1
1
  <script type="text/javascript">
2
- RED.nodes.registerType('Sink',{
3
- color: '#e5e4ef',
4
- icon: "font-awesome/fa-anchor",
5
- category: 'introspection',
6
- paletteLabel: "Sink",
7
- defaults: {
8
- name: {
9
- value:"",
10
- },
11
- },
12
- inputs:1,
13
- outputs:0,
14
-
15
- label: function() {
16
- return (this.name || this._def.paletteLabel);
17
- },
18
-
19
- labelStyle: function() {
20
- return this.name?"node_label_italic":"";
21
- },
22
- });
2
+ RED.nodes.registerType("Sink",{color:"#e5e4ef",icon:"font-awesome/fa-anchor",category:"introspection",paletteLabel:"Sink",defaults:{name:{value:""}},inputs:1,outputs:0,label:function(){return this.name||this._def.paletteLabel},labelStyle:function(){return this.name?"node_label_italic":""},oneditprepare:function(){var t=this;let i=1;var o=$("#node-input-sink-target-filter").searchBox({style:"compact",delay:300,change:function(){let t=$(this).val().trim().toLowerCase();var e,n=$("#node-input-sink-target-container-div").treeList("data");""===t?($("#node-input-sink-target-container-div").treeList("filter",null),o.searchBox("count","")):(e=$("#node-input-sink-target-container-div").treeList("filter",function(e){return-1<e._label.toLowerCase().indexOf(t)||-1<e.node.type.toLowerCase().indexOf(t)||e.sublabel.toLowerCase().indexOf(t)}),o.searchBox("count",e+" / "+n.length))}});$("#node-input-sink-target-container-div").css({width:"100%",height:"95%"}).treeList({multi:!1}).on("treelistitemmouseover",function(e,t){}).on("treelistitemmouseout",function(e,t){}).on("treelistconfirm",function(e,t){t.node&&!t.children&&(RED.view.reveal(t.node.id),RED.view.select(t.node.id),setTimeout(()=>{RED.editor.edit(t.node)},100))}).on("treelistselect",function(e,t){var n;t.node&&(t.children?(n=t.children.filter(e=>e.node.z==RED.workspaces.active()).map(e=>e.node.id),RED.tray.hide(),RED.view.selectNodes({selected:n,onselect:()=>{RED.tray.show()},oncancel:()=>{RED.tray.show()}})):(RED.workspaces.show(t.node.z,!1,!1,!0),RED.view.reveal(t.node.id,!0),RED.view.redraw()))});let e=e=>{var t=RED.nodes.node(e[e.length-1]);let n=[];return e.forEach(function(e){var t,e=RED.nodes.node(e);void 0!==e&&(t=RED.nodes.workspace(e.z)||RED.nodes.subflow(e.z),n.push({label:"",_label:RED.utils.getNodeLabel(e),node:e,sublabel:t&&RED.utils.getNodeLabel(t)||e.z,icon:RED.utils.createNodeIcon(e,!0)}))}),{node:t,label:RED.utils.getNodeLabel(t),_label:RED.utils.getNodeLabel(t),_pathlen:e.length,sublabel:"Length: "+e.length,selected:!1,checkbox:!1,children:n}};var s=function(t,n){if(n.indexOf(t.id)<0)switch(t.type){case"link in":t.links.forEach(function(e){e=RED.nodes.node(e);e&&s(e,[...n,t.id])});break;case"Seeker":n.push(t.id),window._introSpectionsinkStack=[e(n),...window._introSpectionsinkStack];break;default:RED.nodes.getNodeLinks(t,i).forEach(e=>{s(e.source,[...n,t.id])})}};$("#node-input-sink-start-but").on("click",e=>{e&&e.preventDefault(),$("#node-input-sink-start-but").prop("disabled",!0),$("#node-input-sink-totalPaths").html(""),$("#node-input-sink-spinner").show(),window._introSpectionsinkStack=[],setTimeout(()=>{RED.nodes.getNodeLinks(t,i).forEach(e=>{s(e.source,[t.id])}),$("#node-input-sink-start-but").prop("disabled",!1),$("#node-input-sink-totalPaths").html(window._introSpectionsinkStack.length),$("#node-input-sink-spinner").hide(),$("#node-input-sink-target-container-div").treeList("data",window._introSpectionsinkStack.sort((e,t)=>e._pathlen<t._pathlen?-1:1)),delete window._introSpectionsinkStack},500)})},oneditsave:function(){},oneditresize:function(e){for(var t=$("#dialog-form>div:not(.node-input-target-list-row)"),n=$("#dialog-form").height(),i=0;i<t.length;i++)n-=$(t[i]).outerHeight(!0);$("#dialog-form>div.node-input-target-list-row").css("height",n+"px")}});
23
3
  </script>
24
4
 
25
5
  <script type="text/html" data-template-name="Sink">
@@ -27,6 +7,24 @@
27
7
  <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name">Name</span></label>
28
8
  <input type="text" id="node-input-name" placeholder="Name">
29
9
  </div>
10
+
11
+ <div class="form-row node-input-target-row">
12
+ <button id="node-input-sink-start-but" class="red-ui-button"><i class="fa fa-refresh"></i> Find Pathways</button>
13
+ </div>
14
+
15
+ <div class="form-row node-input-target-row node-input-target-list-row" style="margin-top: 40px; position: relative; min-height: 100px">
16
+ <div style="position: absolute; top: -30px; right: 0;"><input type="text" id="node-input-sink-target-filter"></div>
17
+
18
+ <div id="node-input-sink-target-container-div"></div>
19
+ </div>
20
+
21
+ <div class="form-row" style="margin-top: -40px;">
22
+ <label style="float: right;">Total Paths:
23
+ <span id="node-input-sink-totalPaths"></span><img id="node-input-sink-spinner" class="hide" src='red/images/spin.svg'/>
24
+ </label>
25
+ </div>
26
+
27
+
30
28
  </script>
31
29
 
32
30
  <script type="text/html" data-help-name="Sink">
@@ -14,7 +14,7 @@ function handleClientCodeFrontend(event,data){var doSend,doStatus,doError,nodeid
14
14
  value:"",
15
15
  },
16
16
  clientcode: {
17
- value: ""
17
+ value: "node.send(msg)"
18
18
  },
19
19
  format: {
20
20
  value: "javascript"
@@ -0,0 +1 @@
1
+ <svg width="40" height="60" viewBox="0, 0, 40, 60" xmlns="http://www.w3.org/2000/svg"><g fill="rgb(136, 136, 136)"><path d="M12.787 26.432L9.5 18.003h-4.5v-5h8l2.286 6.286m5.357 14.286l3.357 8.428h4v-8l7 10.5-7 10.5v-8h-7.5l-2.357-6.286"/><path d="M13.001 47.003l10.857-29h4.143v8l7-10.5-7-10.5v8h-7.5l-11 29h-4.5v5z"/></g></svg>
@@ -0,0 +1 @@
1
+ <svg width="40" height="60" viewBox="0, 0, 40, 60" xmlns="http://www.w3.org/2000/svg"><path d="M5.001 27.006v6l10.12-.014 3.023 7.728 2.357 6.286h7.5v8l7-10.5-7-10.5v8h-4l-3.357-8.429c-.475-1.267-.93-2.435-1.295-3.601l4.51-11.97H28v8l7-10.5-7-10.5v8h-7.5L15.098 27z" fill="rgb(136, 136, 136)" stroke="none"/></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gregoriusrippenstein/node-red-contrib-introspection",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "dependencies": {
5
5
  "got": "^13",
6
6
  "uglify-js": "^3.17.4",
@@ -304,7 +304,18 @@
304
304
  .ml-30 {
305
305
  margin-left: 30px !important;
306
306
  }
307
-
307
+ .icon-button {
308
+ height: 24px;
309
+ width: 18px;
310
+ display: inline-block;
311
+ background-size: 100% 100%;
312
+ top: 4px;
313
+ position: relative;
314
+ }
315
+ .icon-button-text {
316
+ position: relative;
317
+ top: -4px;
318
+ }
308
319
  </style>
309
320
 
310
321
  <!-- The html for the right sidebar plugin screen -->
@@ -374,7 +385,7 @@
374
385
  <button id="node-input-orphan-clear-workspace-btn"
375
386
  class="red-ui-button">Clear dots</button>
376
387
  <button id="node-input-transform-inject-to-change-btn"
377
- class="red-ui-button"><i class="fa fa-retweet"></i> Inj-&gt;Chg</button>
388
+ class="red-ui-button"><i class='icon-button' style="background-image: url('icons/@gregoriusrippenstein/node-red-contrib-introspection/swap-inject-to-change.svg');"></i><span class='icon-button-text'>Inj-&gt;Chg</span></button>
378
389
  <button id="node-input-statistics-btn"
379
390
  class="red-ui-button"><i class="fa fa-pie-chart"></i> Stats</button>
380
391
  </div>