@inteli.city/node-red-contrib-exec-collection 1.0.3 → 1.0.5

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/thread.queue.html DELETED
@@ -1,311 +0,0 @@
1
- <!--* header -->
2
- <script type="text/markdown" data-help-name="thread.queue">
3
- ## Overview
4
- Runs system commands on a queue and returns its output.
5
-
6
- ## How to use
7
- The template text on this node works exactly the same as the template node. On the `Command` input it allows you to use the command line. The template text written is a file called `$file`. Below there are some possible commands to run with it (considering these commands are installed on the system):
8
-
9
- * `bash $file`
10
- * `node $file`
11
- * `python3 $file`
12
- * `python3 -u $file` (spawn)
13
- * `Rscript $file`
14
- * `awk -f $file`
15
- * `psql postgresql://user:passwds@host:port/database -f $file`
16
- * `ogr2ogr -f GEOJSON /vsistdout/ PG:"host=host port=portnumber user=user password=password dbname=dbname" -sql "@$file"`
17
- * `ogr2ogr -f GEOJSON /vsistdout/ WFS:"http://wfspage" layername -sql "@$file"`
18
- * `cat $file | ssh -i /path/key user@ip bash -s`
19
- * `cat $file | ssh -i /path/key user@ip node -s`
20
- * `cat $file | ssh -i /path/key user@ip python3 -s`
21
- * `mv $file $file.mjs; node $file.mjs; rm $file.mjs`
22
- * `/usr/bin/time bash $file`
23
- * `valgrind bash $file`
24
-
25
- See more examples [here](https://www.npmjs.com/package/node-red-contrib-thread.queue).
26
- </script>
27
- <!--* node-design -->
28
- <script type="text/html" data-template-name="thread.queue">
29
- <div class="form-row">
30
- <label for="node-input-name">
31
- <i class="fa fa-tag"></i>
32
- <span data-i18n="node-red:common.label.name"></span>
33
- </label>
34
-
35
- <div style="display: inline-block; width: calc(100% - 105px)">
36
- <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
37
- </div>
38
-
39
- </div>
40
-
41
- <div class="form-row">
42
- <label for="node-input-command">
43
- <i class="fa fa-file"></i>
44
- <span data-i18n="node-red:exec.label.command"></span>
45
- </label>
46
- <input style="display: inline-block; width: calc(100% - 108px);" type="text" id="node-input-command" data-i18n="[placeholder]node-red:exec.label.command">
47
-
48
- </div>
49
-
50
- <div class="form-row" style="position: relative;">
51
- <label>
52
- <i class="fa fa-sign-out"></i>
53
- <span>Queue</span>
54
- </label>
55
- <input style="width:60px" type="number" id="node-input-queue" value="1">
56
-
57
- <div style="position: absolute; right:0;display:inline-block; text-align: right; font-size: 0.8em;">
58
-
59
- <span style="margin-right:10px;font-size:9px;">No Output</span>
60
- <input type="checkbox" id="node-input-outputEmpty" style="display:inline-block; width:auto;margin-right:30px;">
61
-
62
- <span style="margin-right:10px;font-size:9px;">Cmd Template</span>
63
- <!-- <input type="checkbox" id="node-input-addpayCB" style="display:inline-block; width:auto;margin-right:30px;"> -->
64
- <input type="checkbox" id="node-input-cmdTemplate" style="display:inline-block; width:auto;margin-right:30px;">
65
-
66
- <input type="hidden" id="node-input-template" autofocus="autofocus">
67
-
68
- <span style="font-size:9px;" data-i18n="node-red:template.label.format"></span>:
69
- <select id="node-input-format" style="width:110px; font-size: 10px !important; height: 24px; padding:0;">
70
- <option value="handlebars">Mustache</option>
71
- <option value="javascript">Javascript</option>
72
- <option value="python">Python</option>
73
- <option value="sh">Shell</option>
74
- <option value="r">R</option>
75
- <option value="pgsql">PGSQL</option>
76
- <option value="nginx">NGINX</option>
77
- <option value="apache_conf">Apache</option>
78
- <option value="dockerfile">Dockerfile</option>
79
- <option value="terraform">Terraform</option>
80
- <option value="text" data-i18n="node-red:template.label.none"></option>
81
- </select>
82
- <button id="node-template-expand-editor" class="red-ui-button red-ui-button-small"><i class="fa fa-expand"></i></button>
83
- </div>
84
- </div>
85
- <div class="form-row node-text-editor-row">
86
- <div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-template-editor" ></div>
87
- </div>
88
-
89
- <div class="form-row" style="margin-bottom:0px;">
90
- <label for="node-input-output"><i class="fa fa-long-arrow-right"></i> <span data-i18n="node-red:template.label.output"></span></label>
91
- <select id="node-input-output" style="width:170px;">
92
- <option value="str">Plain text</option>
93
- <option value="parsedJSON">Parsed JSON</option>
94
- <option value="parsedYAML">Parsed YAML</option>
95
- <option value="parsedXML">Parsed XML</option>
96
- </select>
97
-
98
-
99
- <label style="margin-left: 25px;">
100
- <i class="fa fa-sign-out"></i>
101
- <span>Mode</span>
102
- </label>
103
- <select type="text" id="node-input-useSpawn" style="width:12%;margin-left:-30px;">
104
- <option value="false">exec mode- when the command is complete</option>
105
- <option value="true">spawn mode- while the command is running</option>
106
- </select>
107
-
108
- <label style="margin-left: 25px;" for="node-input-field"><i class="fa fa-ellipsis-h"></i> <span data-i18n="node-red:common.label.property"></span></label>
109
- <input style="margin-left:-20px;width:130px;"type="text" id="node-input-field" placeholder="payload" >
110
- <input style="margin-left:-20px;width:130px;"type="hidden" id="node-input-fieldType">
111
-
112
- <span style="margin-left:20px;font-size:11px;">Split \n</span>
113
- <input type="checkbox" id="node-input-splitLine" style="display:inline-block; width:auto;margin-left:10px;">
114
- </div>
115
-
116
- </script>
117
- <!--* javascript -->
118
- <script type="text/javascript">
119
- //** defining-variables
120
- RED.nodes.registerType('thread.queue',{
121
- //color:"rgb(180, 100, 100)",
122
- color:"rgb(195, 168, 205)",
123
- category: 'function',
124
- defaults: {
125
- name: {value:""},
126
- currentLine: {row:0, column:0},
127
- command: {value:"node $file"},
128
- outputs: {value: 1},
129
- useSpawn: {value:"false"},
130
- field: {value:"payload", validate:RED.validators.typedInput("fieldType")},
131
- fieldType: {value:"msg"},
132
- format: {value:"javascript"},
133
- template: {value:`console.log(\`\n{\n\t"value": "thread.queue",\n\t"purpose":"putting the ideas from the exec, template and queue nodes together"\n}\n\`)`},
134
- output: {value:"str"},
135
- outputEmpty: {value:false},
136
- queue: {value:1},
137
- cmdTemplate: {value:true},
138
- splitLine: {value:false},
139
- cleanQueue: {value:false}
140
- },
141
- inputs:1,
142
- outputs: 1,
143
- icon: "cog.png",
144
- //** function: label
145
- label: function() {
146
- return this.name||this._("thread.queue");;
147
- },
148
- //** function: labelStyle
149
- labelStyle: function() {
150
- return this.name?"node_label_italic":"";
151
- },
152
- //** function: oneditprepare
153
- oneditprepare: function() {
154
- var that = this;
155
-
156
- if (!this.field) {
157
- this.field = 'payload';
158
- $("#node-input-field").val("payload");
159
- }
160
- if (!this.fieldType) {
161
- this.fieldType = 'msg';
162
- }
163
- $("#node-input-field").typedInput({
164
- default: 'msg',
165
- types: ['msg','flow','global'],
166
- typeField: $("#node-input-fieldType")
167
- });
168
-
169
- $("#node-input-field").typedInput({
170
- default: 'msg',
171
- types: ['msg','flow','global'],
172
- typeField: $("#node-input-fieldType")
173
- });
174
-
175
- if (this.cmdTemplate === "true" || this.cmdTemplate === true) {
176
- $("#node-input-cmdTemplate").prop("checked",true);
177
- } else {
178
- $("#node-input-cmdTemplate").prop("checked",false);
179
- }
180
-
181
- this.editor = RED.editor.createEditor({
182
- id: 'node-input-template-editor',
183
- mode: 'ace/mode/html',
184
- value: $("#node-input-template").val()
185
- });
186
-
187
- RED.library.create({
188
- url:"templates", // where to get the data from
189
- type:"template", // the type of object the library is for
190
- editor:that.editor, // the field name the main text body goes to
191
- fields:['name','format','output'],
192
- ext: "txt"
193
- });
194
- this.editor.focus();
195
-
196
- $("#node-input-format").on("change", function() {
197
- var mod = "ace/mode/"+$("#node-input-format").val();
198
- that.editor.getSession().setMode({
199
- path: mod,
200
- v: Date.now()
201
- });
202
- });
203
-
204
-
205
- //registerController = Vim.getRegisterController()
206
- //RegisterController.pushText(registerController)
207
- /* let firstTime_vimMode = true
208
- * $("#node-input-vimMode").on("change", function() {
209
- * try {
210
- * if ( that.vimMode === "true" || that.vimMode === true ){
211
- * if ( firstTime_vimMode ){
212
- * that.editor.setKeyboardHandler("ace/keyboard/vim")
213
- * } else {
214
- * that.vimMode = false
215
- * that.editor.setKeyboardHandler(null)
216
- * }
217
- * } else {
218
- * if ( firstTime_vimMode ){
219
- * that.editor.setKeyboardHandler(null)
220
- * } else {
221
- * that.vimMode = true
222
- * that.editor.setKeyboardHandler("ace/keyboard/vim")
223
- * }
224
- * }
225
- * } catch (e) {
226
- * console.log("Vim Mode only works with the Ace editor")
227
- * }
228
- setTimeout(function() {
229
- let panel = $(".ace_text-input");
230
- panel.focus();
231
- firstTime_vimMode = false
232
- }, 600);
233
- * });
234
- */
235
- let firstTime_outputEmpty = true
236
- $("#node-input-outputEmpty").on("change", function() {
237
- if ( that.outputEmpty === "true" || that.outputEmpty === true ){
238
- if ( firstTime_outputEmpty ){
239
- that.outputs = 0
240
- } else {
241
- that.outputEmpty = false
242
- that.outputs = 1
243
- }
244
- } else {
245
- if ( firstTime_outputEmpty ){
246
- that.outputs = 1
247
- } else {
248
- that.outputEmpty = true
249
- that.outputs = 0
250
- }
251
- }
252
- setTimeout(function() {
253
- firstTime_outputEmpty = false
254
- }, 600);
255
- });
256
-
257
- if ( this.currentLine === undefined ){ this.currentLine = 1 }
258
- this.editor.resize(true);
259
- this.editor.scrollToLine(this.currentLine.row+1, true, true, function () {});
260
- this.editor.gotoLine(this.currentLine.row+1,this.currentLine.column+1,true);
261
- RED.popover.tooltip($("#node-template-expand-editor"), RED._("node-red:common.label.expand"));
262
- $("#node-template-expand-editor").on("click", function(e) {
263
- e.preventDefault();
264
- var value = that.editor.getValue();
265
- RED.editor.editText({
266
- mode: $("#node-input-format").val(),
267
- value: value,
268
- width: "Infinity",
269
- cursor: that.editor.getCursorPosition(),
270
- complete: function(v,cursor) {
271
- that.editor.setValue(v, -1);
272
- that.editor.gotoLine(cursor.row+1,cursor.column,false);
273
- setTimeout(function() {
274
- that.editor.focus();
275
- try {
276
- that.editor.setKeyboardHandler("ace/keyboard/vim")
277
- } catch (e) {
278
- console.log("Vim Mode only works with the Ace editor")
279
- }
280
- }, 300);
281
- }
282
- })
283
- })
284
- },
285
- //** function: oneditsave
286
- oneditsave: function() {
287
- this.cleanQueue = true
288
- this.currentLine = this.editor.getCursorPosition()
289
- $("#node-input-template").val(this.editor.getValue());
290
- this.editor.destroy();
291
- delete this.editor;
292
- },
293
- //** function: oneditcancel
294
- oneditcancel: function() {
295
- this.editor.destroy();
296
- delete this.editor;
297
- },
298
- //** function: oneditresize
299
- oneditresize: function(size) {
300
- var rows = $("#dialog-form>div:not(.node-text-editor-row)");
301
- var height = $("#dialog-form").height();
302
- for (var i=0; i<rows.length; i++) {
303
- height -= $(rows[i]).outerHeight(true);
304
- }
305
- var editorRow = $("#dialog-form>div.node-text-editor-row");
306
- height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
307
- $(".node-text-editor").css("height",height+"px");
308
- this.editor.resize();
309
- }
310
- });
311
- </script>