@gregoriusrippenstein/node-red-contrib-introspection 0.4.1 → 0.4.3
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.html +21 -13
- package/nodes/60-client-code.js +2 -1
- package/package.json +1 -1
- package/nodes/__55-trigger-import.html +0 -158
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
RED.comms.subscribe('introspect:client-code-perform', (event,data) => {
|
|
4
4
|
if ( data.msg == "execfunc" ) {
|
|
5
5
|
|
|
6
|
-
var doSend = (data, nodeid) => {
|
|
6
|
+
var doSend = (data, nodeid, _msg) => {
|
|
7
|
+
if ( typeof data == "object" ) {
|
|
8
|
+
data = {
|
|
9
|
+
..._msg,
|
|
10
|
+
...data
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
$.ajax({
|
|
8
15
|
url: "ClientCode/" + nodeid,
|
|
9
16
|
type: "POST",
|
|
@@ -24,24 +31,27 @@
|
|
|
24
31
|
});
|
|
25
32
|
};
|
|
26
33
|
|
|
27
|
-
var doError = (msg,nodeid) => {
|
|
34
|
+
var doError = (msg, nodeid, _msg) => {
|
|
28
35
|
RED.notify("ClientCode Failed: " + nodeid + ": " + msg, {
|
|
29
36
|
type: "error",
|
|
30
37
|
id: nodeid,
|
|
31
38
|
timeout: 3000
|
|
32
39
|
});
|
|
33
|
-
|
|
40
|
+
|
|
41
|
+
console.log( "ClientCode: Error with node: " + nodeid + ": " + msg);
|
|
34
42
|
};
|
|
35
43
|
|
|
36
44
|
var nodeid = data.nodeid;
|
|
45
|
+
var _msg = data._msg;
|
|
37
46
|
|
|
38
47
|
var node = {
|
|
39
48
|
send: (dt) => {
|
|
40
|
-
doSend(dt, nodeid)
|
|
49
|
+
doSend(dt, nodeid, _msg)
|
|
41
50
|
},
|
|
42
51
|
error: (mg) => {
|
|
43
|
-
doError(mg, nodeid)
|
|
44
|
-
}
|
|
52
|
+
doError(mg, nodeid, _msg)
|
|
53
|
+
},
|
|
54
|
+
id: data.nodeid
|
|
45
55
|
};
|
|
46
56
|
|
|
47
57
|
var payload = data.payload;
|
|
@@ -64,7 +74,7 @@
|
|
|
64
74
|
value: ""
|
|
65
75
|
},
|
|
66
76
|
format: {
|
|
67
|
-
value: ""
|
|
77
|
+
value: "javascript"
|
|
68
78
|
}
|
|
69
79
|
},
|
|
70
80
|
inputs:1,
|
|
@@ -95,13 +105,11 @@
|
|
|
95
105
|
|
|
96
106
|
this.editor = RED.editor.createEditor({
|
|
97
107
|
id: 'node-input-clientcode-editor',
|
|
98
|
-
mode: 'ace/mode/
|
|
108
|
+
mode: 'ace/mode/javascript',
|
|
99
109
|
stateId: stateId,
|
|
100
|
-
value: $("#node-input-
|
|
110
|
+
value: $("#node-input-clientcode").val()
|
|
101
111
|
});
|
|
102
112
|
|
|
103
|
-
this.editor.setValue( that.clientcode );
|
|
104
|
-
|
|
105
113
|
$("#node-input-format").on("change", function() {
|
|
106
114
|
var mod = "ace/mode/"+$("#node-input-format").val();
|
|
107
115
|
that.editor.getSession().setMode({
|
|
@@ -160,7 +168,6 @@
|
|
|
160
168
|
<label for="node-input-clientcode">
|
|
161
169
|
<i class="fa fa-file-code-o"></i> Client Code
|
|
162
170
|
</label>
|
|
163
|
-
<input type="hidden" id="node-input-clientcode" autofocus="autofocus">
|
|
164
171
|
|
|
165
172
|
<div style="position: absolute; right:0;display:inline-block; text-align: right; font-size: 0.8em;">
|
|
166
173
|
Syntax:
|
|
@@ -189,7 +196,8 @@
|
|
|
189
196
|
class="node-text-editor"
|
|
190
197
|
id="node-input-clientcode-editor" ></div>
|
|
191
198
|
</div>
|
|
192
|
-
|
|
199
|
+
|
|
200
|
+
<input type="hidden" id="node-input-clientcode" autofocus="autofocus">
|
|
193
201
|
</script>
|
|
194
202
|
|
|
195
203
|
<script type="text/html" data-help-name="ClientCode">
|
package/nodes/60-client-code.js
CHANGED
package/package.json
CHANGED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
<script type="text/javascript">
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* How to connect nodes:
|
|
5
|
-
var namesToId = {}
|
|
6
|
-
|
|
7
|
-
RED.nodes.eachNode((n) => {
|
|
8
|
-
if ( n._def.category == "rssfeeds") {
|
|
9
|
-
namesToId[n.name] = n.id
|
|
10
|
-
}
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
RED.nodes.eachNode((n) => {
|
|
14
|
-
if ( n._def.category == "rssfeeds" && n._def.label() == "Hacker News: New Comments") {
|
|
15
|
-
var title = n.name.match(/^New[ ]+comment[ ]+by.+\"(.*)\"/)[1];
|
|
16
|
-
var tgtId = namesToId[title];
|
|
17
|
-
if ( tgtId ) {
|
|
18
|
-
var t = RED.nodes.node(tgtId);
|
|
19
|
-
RED.nodes.addLink( { source: n, sourcePort: 0, target: t});
|
|
20
|
-
RED.view.select([t,n])
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
* How to move
|
|
26
|
-
|
|
27
|
-
var t = RED.nodes.node("23e18922a0b896f1")
|
|
28
|
-
t.x = XXXX;
|
|
29
|
-
t.y = YYYY;
|
|
30
|
-
t.dirty = true;
|
|
31
|
-
RED.view.redraw(true)
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
RED.comms.subscribe('introspect:trigger-import-delete', (event,data) => {
|
|
36
|
-
if ( data.msg == "delete-old-nodes" ) {
|
|
37
|
-
RED.view.select(false)
|
|
38
|
-
|
|
39
|
-
// close any dialog that explains that there are duplicates and therefore
|
|
40
|
-
// only a copy can be imported, hit the cancel button on that one.
|
|
41
|
-
// Five clicks should do the job ...
|
|
42
|
-
for ( var idx = 0 ; idx < 5; idx++ ) {
|
|
43
|
-
$($('.ui-dialog-buttonset').find("button")[0]).trigger('click')
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
var allSelectNodes = [];
|
|
47
|
-
|
|
48
|
-
RED.nodes.eachNode( function(e) {
|
|
49
|
-
if ( e._def && e.env && e.env[1] &&
|
|
50
|
-
e._def.category == data.payload.category &&
|
|
51
|
-
(Date.parse(e.env[1].value) <
|
|
52
|
-
(new Date().getTime() - parseInt(data.payload.old_than_ms))) ) {
|
|
53
|
-
allSelectNodes.push(e)
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
RED.view.select({ nodes: allSelectNodes })
|
|
58
|
-
setTimeout( () => {
|
|
59
|
-
RED.actions.invoke("core:delete-selection")
|
|
60
|
-
}, 1500);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
RED.comms.subscribe('introspect:trigger-import-tripped', (event,data) => {
|
|
65
|
-
if ( data.msg == "import-flow" ) {
|
|
66
|
-
var content = data.flowContent;
|
|
67
|
-
|
|
68
|
-
if ( data.removeduplicates ) {
|
|
69
|
-
content = content.filter( (elem) => {
|
|
70
|
-
return RED.nodes.node(elem.id) == undefined
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if ( content.length == 0 ) {
|
|
75
|
-
RED.notify("No new content", {
|
|
76
|
-
type: "ok",
|
|
77
|
-
id: "TriggerImport",
|
|
78
|
-
timeout: 2000
|
|
79
|
-
});
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
RED.clipboard.import();
|
|
83
|
-
|
|
84
|
-
setTimeout( () => {
|
|
85
|
-
$('#red-ui-clipboard-dialog-import-text').val(
|
|
86
|
-
JSON.stringify(content)
|
|
87
|
-
).trigger("paste");
|
|
88
|
-
|
|
89
|
-
if ( data.autoimport ) {
|
|
90
|
-
setTimeout( () => {
|
|
91
|
-
$('#red-ui-clipboard-dialog-ok').trigger('click');
|
|
92
|
-
}, 435);
|
|
93
|
-
}
|
|
94
|
-
}, 300);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
RED.nodes.registerType('TriggerImport',{
|
|
99
|
-
color: '#e5e4ef',
|
|
100
|
-
icon: "icons/subflow.svg",
|
|
101
|
-
category: 'introspection',
|
|
102
|
-
paletteLabel: "TriggerImport",
|
|
103
|
-
defaults: {
|
|
104
|
-
name: {
|
|
105
|
-
value:"",
|
|
106
|
-
},
|
|
107
|
-
autoimport: {
|
|
108
|
-
value: false
|
|
109
|
-
},
|
|
110
|
-
removeduplicates: {
|
|
111
|
-
value: false
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
inputs:1,
|
|
115
|
-
outputs:1,
|
|
116
|
-
|
|
117
|
-
label: function() {
|
|
118
|
-
return (this.name || this._def.paletteLabel);
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
labelStyle: function() {
|
|
122
|
-
return this.name?"node_label_italic":"";
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
</script>
|
|
126
|
-
|
|
127
|
-
<script type="text/html" data-template-name="TriggerImport">
|
|
128
|
-
<div class="form-row">
|
|
129
|
-
<label for="node-input-name">
|
|
130
|
-
<i class="fa fa-tag"></i>
|
|
131
|
-
<span data-i18n="common.label.name">Name</span>
|
|
132
|
-
</label>
|
|
133
|
-
<input type="text" id="node-input-name" placeholder="Name">
|
|
134
|
-
</div>
|
|
135
|
-
|
|
136
|
-
<div class="form-row">
|
|
137
|
-
<label for="node-input-autoimport" style="width: 150px !important;">
|
|
138
|
-
<span>Automatic Import?</span>
|
|
139
|
-
</label>
|
|
140
|
-
<input type="checkbox"
|
|
141
|
-
id="node-input-autoimport"
|
|
142
|
-
style="display:inline-block; width:15px; vertical-align:baseline;">
|
|
143
|
-
</div>
|
|
144
|
-
|
|
145
|
-
<div class="form-row">
|
|
146
|
-
<label for="node-input-removeduplicates" style="width: 150px !important;">
|
|
147
|
-
<span>Remove duplicates?</span>
|
|
148
|
-
</label>
|
|
149
|
-
<input type="checkbox"
|
|
150
|
-
id="node-input-removeduplicates"
|
|
151
|
-
style="display:inline-block; width:15px; vertical-align:baseline;">
|
|
152
|
-
</div>
|
|
153
|
-
|
|
154
|
-
</script>
|
|
155
|
-
|
|
156
|
-
<script type="text/html" data-help-name="TriggerImport">
|
|
157
|
-
<p>Trigger import opens the flow import dialog with data that came from the server.</p>
|
|
158
|
-
</script>
|