@node-red/nodes 2.1.2 → 2.2.0-beta.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.
Files changed (59) hide show
  1. package/core/common/20-inject.html +10 -8
  2. package/core/common/20-inject.js +2 -8
  3. package/core/common/21-debug.js +13 -1
  4. package/core/function/10-function.html +6 -4
  5. package/core/function/10-function.js +1 -2
  6. package/core/function/89-delay.js +1 -0
  7. package/core/function/90-exec.js +3 -3
  8. package/core/function/rbe.js +1 -1
  9. package/core/network/21-httprequest.js +8 -10
  10. package/core/network/22-websocket.html +6 -2
  11. package/core/network/22-websocket.js +22 -14
  12. package/core/network/31-tcpin.html +126 -20
  13. package/core/network/31-tcpin.js +162 -29
  14. package/core/parsers/70-JSON.js +5 -1
  15. package/core/storage/10-file.js +1 -3
  16. package/examples/common/link/03 - Link call.json +156 -0
  17. package/examples/storage/{file/01 - Write string to a file.json → read file/01 - Read string from a file.json } +22 -22
  18. package/examples/storage/{file-in → read file}/02 - Read data in specified encoding.json +23 -22
  19. package/examples/storage/{file-in → read file}/03 - Read data breaking lines into messages.json +25 -25
  20. package/examples/storage/{file-in → read file}/04 - Create a message stream.json +37 -37
  21. package/examples/storage/{file-in/01 - Read string from a file.json → write file/01 - Write string to a file.json } +15 -15
  22. package/examples/storage/{file → write file}/02 - Write string to a file specified by property.json +22 -22
  23. package/examples/storage/{file → write file}/03 - Delete a file.json +16 -16
  24. package/examples/storage/{file → write file}/04 - Specify encoding of written data.json +23 -23
  25. package/locales/de/common/20-inject.html +2 -2
  26. package/locales/de/common/21-debug.html +6 -6
  27. package/locales/de/common/24-complete.html +2 -2
  28. package/locales/de/common/25-catch.html +4 -4
  29. package/locales/de/common/60-link.html +2 -2
  30. package/locales/de/function/10-function.html +1 -1
  31. package/locales/de/function/10-switch.html +1 -1
  32. package/locales/de/function/90-exec.html +3 -3
  33. package/locales/de/messages.json +12 -12
  34. package/locales/de/network/10-mqtt.html +2 -2
  35. package/locales/de/network/21-httpin.html +3 -3
  36. package/locales/de/parsers/70-JSON.html +3 -3
  37. package/locales/de/sequence/17-split.html +6 -6
  38. package/locales/de/sequence/18-sort.html +2 -2
  39. package/locales/de/storage/10-file.html +1 -1
  40. package/locales/en-US/function/80-template.html +1 -1
  41. package/locales/en-US/function/89-delay.html +1 -1
  42. package/locales/en-US/function/rbe.html +2 -2
  43. package/locales/en-US/messages.json +8 -5
  44. package/locales/en-US/network/10-mqtt.html +1 -1
  45. package/locales/en-US/network/21-httprequest.html +1 -1
  46. package/locales/en-US/sequence/17-split.html +1 -1
  47. package/locales/ja/common/60-link.html +9 -0
  48. package/locales/ja/function/80-template.html +2 -0
  49. package/locales/ja/function/89-delay.html +5 -2
  50. package/locales/ja/function/rbe.html +1 -1
  51. package/locales/ja/messages.json +34 -7
  52. package/locales/ja/network/10-mqtt.html +65 -4
  53. package/locales/ja/parsers/70-CSV.html +1 -1
  54. package/locales/ja/sequence/17-split.html +5 -2
  55. package/locales/ko/messages.json +2 -2
  56. package/locales/ru/messages.json +2 -2
  57. package/locales/zh-CN/messages.json +2 -2
  58. package/locales/zh-TW/messages.json +2 -2
  59. package/package.json +8 -8
@@ -353,14 +353,16 @@
353
353
  },
354
354
  oneditprepare: function() {
355
355
  var node = this;
356
+ var payloadType = node.payloadType;
357
+
356
358
  if (node.payloadType == null) {
357
359
  if (node.payload == "") {
358
- node.payloadType = "date";
360
+ payloadType = "date";
359
361
  } else {
360
- node.payloadType = "str";
362
+ payloadType = "str";
361
363
  }
362
364
  } else if (node.payloadType === 'string' || node.payloadType === 'none') {
363
- node.payloadType = "str";
365
+ payloadType = "str";
364
366
  }
365
367
 
366
368
  $("#inject-time-type-select").on("change", function() {
@@ -557,7 +559,7 @@
557
559
  var payload = {
558
560
  p:'payload',
559
561
  v: node.payload ? node.payload : '',
560
- vt:node.payloadType ? node.payloadType : 'date'
562
+ vt:payloadType ? payloadType : 'date'
561
563
  };
562
564
  var topic = {
563
565
  p:'topic',
@@ -573,7 +575,7 @@
573
575
  if (newProp.v === undefined) {
574
576
  if (prop.p === 'payload') {
575
577
  newProp.v = node.payload ? node.payload : '';
576
- newProp.vt = node.payloadType ? node.payloadType : 'date';
578
+ newProp.vt = payloadType ? payloadType : 'date';
577
579
  } else if (prop.p === 'topic' && prop.vt === "str") {
578
580
  newProp.v = node.topic ? node.topic : '';
579
581
  }
@@ -688,9 +690,9 @@
688
690
  this.topic = "";
689
691
  var result = getProps(items, true);
690
692
  this.props = result.props;
691
- if(result.payloadType) { this.payloadType = result.payloadType; };
692
- if(result.payload) { this.payload = result.payload; };
693
- if(result.topic) { this.topic = result.topic; };
693
+ if(result.hasOwnProperty('payloadType')) { this.payloadType = result.payloadType; };
694
+ if(result.hasOwnProperty('payload')) { this.payload = result.payload; };
695
+ if(result.hasOwnProperty('topic')) { this.topic = result.topic; };
694
696
  },
695
697
  button: {
696
698
  enabled: function() {
@@ -75,16 +75,12 @@ module.exports = function(RED) {
75
75
  node.repeaterSetup = function () {
76
76
  if (this.repeat && !isNaN(this.repeat) && this.repeat > 0) {
77
77
  this.repeat = this.repeat * 1000;
78
- if (RED.settings.verbose) {
79
- this.log(RED._("inject.repeat", this));
80
- }
78
+ this.debug(RED._("inject.repeat", this));
81
79
  this.interval_id = setInterval(function() {
82
80
  node.emit("input", {});
83
81
  }, this.repeat);
84
82
  } else if (this.crontab) {
85
- if (RED.settings.verbose) {
86
- this.log(RED._("inject.crontab", this));
87
- }
83
+ this.debug(RED._("inject.crontab", this));
88
84
  this.cronjob = scheduleTask(this.crontab,() => { node.emit("input", {})});
89
85
  }
90
86
  };
@@ -148,10 +144,8 @@ module.exports = function(RED) {
148
144
  }
149
145
  if (this.interval_id != null) {
150
146
  clearInterval(this.interval_id);
151
- if (RED.settings.verbose) { this.log(RED._("inject.stopped")); }
152
147
  } else if (this.cronjob != null) {
153
148
  this.cronjob.stop();
154
- if (RED.settings.verbose) { this.log(RED._("inject.stopped")); }
155
149
  delete this.cronjob;
156
150
  }
157
151
  };
@@ -280,6 +280,18 @@ module.exports = function(RED) {
280
280
  root: path.join(__dirname,"lib","debug"),
281
281
  dotfiles: 'deny'
282
282
  };
283
- res.sendFile(req.params[0], options);
283
+ try {
284
+ res.sendFile(
285
+ req.params[0],
286
+ options,
287
+ err => {
288
+ if (err) {
289
+ res.sendStatus(404);
290
+ }
291
+ }
292
+ )
293
+ } catch(err) {
294
+ res.sendStatus(404);
295
+ }
284
296
  });
285
297
  };
@@ -91,21 +91,21 @@
91
91
  <div id="func-tab-init" style="display:none">
92
92
  <div class="form-row node-text-editor-row" style="position:relative">
93
93
  <div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-init-editor" ></div>
94
- <div style="position: absolute; right:0; bottom: calc(100% - 20px); z-Index: 5;"><button id="node-init-expand-js" class="red-ui-button red-ui-button-small"><i class="fa fa-expand"></i></button></div>
94
+ <div style="position: absolute; right:0; bottom: calc(100% - 20px); z-Index: 10;"><button id="node-init-expand-js" class="red-ui-button red-ui-button-small"><i class="fa fa-expand"></i></button></div>
95
95
  </div>
96
96
  </div>
97
97
 
98
98
  <div id="func-tab-body" style="display:none">
99
99
  <div class="form-row node-text-editor-row" style="position:relative">
100
100
  <div style="height: 220px; min-height:150px;" class="node-text-editor" id="node-input-func-editor" ></div>
101
- <div style="position: absolute; right:0; bottom: calc(100% - 20px); z-Index: 5;"><button id="node-function-expand-js" class="red-ui-button red-ui-button-small"><i class="fa fa-expand"></i></button></div>
101
+ <div style="position: absolute; right:0; bottom: calc(100% - 20px); z-Index: 10;"><button id="node-function-expand-js" class="red-ui-button red-ui-button-small"><i class="fa fa-expand"></i></button></div>
102
102
  </div>
103
103
  </div>
104
104
 
105
105
  <div id="func-tab-finalize" style="display:none">
106
106
  <div class="form-row node-text-editor-row" style="position:relative">
107
107
  <div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-finalize-editor" ></div>
108
- <div style="position: absolute; right:0; bottom: calc(100% - 20px); z-Index: 5;"><button id="node-finalize-expand-js" class="red-ui-button red-ui-button-small"><i class="fa fa-expand"></i></button></div>
108
+ <div style="position: absolute; right:0; bottom: calc(100% - 20px); z-Index: 10;"><button id="node-finalize-expand-js" class="red-ui-button red-ui-button-small"><i class="fa fa-expand"></i></button></div>
109
109
  </div>
110
110
  </div>
111
111
 
@@ -512,6 +512,7 @@
512
512
  return function(e) {
513
513
  e.preventDefault();
514
514
  var value = editor.getValue();
515
+ var extraLibs = that.libs || [];
515
516
  RED.editor.editJavaScript({
516
517
  value: value,
517
518
  width: "Infinity",
@@ -523,7 +524,8 @@
523
524
  setTimeout(function() {
524
525
  editor.focus();
525
526
  },300);
526
- }
527
+ },
528
+ extraLibs: extraLibs
527
529
  })
528
530
  }
529
531
  }
@@ -234,8 +234,7 @@ module.exports = function(RED) {
234
234
  },
235
235
  env: {
236
236
  get: function(envVar) {
237
- var flow = node._flow;
238
- return flow.getSetting(envVar);
237
+ return RED.util.getSetting(node, envVar);
239
238
  }
240
239
  },
241
240
  setTimeout: function () {
@@ -372,6 +372,7 @@ module.exports = function(RED) {
372
372
  hit = false;
373
373
  for (var b in node.buffer) { // check if already in queue
374
374
  if (msg.topic === node.buffer[b].msg.topic) {
375
+ if (node.outputs === 2) { send([null,node.buffer[b].msg]) }
375
376
  node.buffer[b].done();
376
377
  node.buffer[b] = {msg, send, done}; // if so - replace existing entry
377
378
  hit = true;
@@ -86,7 +86,7 @@ module.exports = function(RED) {
86
86
  });
87
87
  var cmd = arg.shift();
88
88
  /* istanbul ignore else */
89
- if (RED.settings.verbose) { node.log(cmd+" ["+arg+"]"); }
89
+ node.debug(cmd+" ["+arg+"]");
90
90
  child = spawn(cmd,arg,node.spawnOpt);
91
91
  node.status({fill:"blue",shape:"dot",text:"pid:"+child.pid});
92
92
  var unknownCommand = (child.pid === undefined);
@@ -136,7 +136,7 @@ module.exports = function(RED) {
136
136
  }
137
137
  else {
138
138
  /* istanbul ignore else */
139
- if (RED.settings.verbose) { node.log(arg); }
139
+ node.debug(arg);
140
140
  child = exec(arg, node.execOpt, function (error, stdout, stderr) {
141
141
  var msg2, msg3;
142
142
  delete msg.payload;
@@ -155,7 +155,7 @@ module.exports = function(RED) {
155
155
  if (error.signal) { msg3.payload.signal = error.signal; }
156
156
  if (error.code === null) { node.status({fill:"red",shape:"dot",text:"killed"}); }
157
157
  else { node.status({fill:"red",shape:"dot",text:"error:"+error.code}); }
158
- if (RED.settings.verbose) { node.log('error:' + error); }
158
+ node.debug('error:' + error);
159
159
  }
160
160
  else if (node.oldrc === "false") {
161
161
  msg3 = RED.util.cloneMessage(msg);
@@ -58,7 +58,7 @@ module.exports = function(RED) {
58
58
  else {
59
59
  var n = parseFloat(value);
60
60
  if (!isNaN(n)) {
61
- if ((typeof node.previous[t] === 'undefined') && (this.func === "narrowband")) {
61
+ if ((typeof node.previous[t] === 'undefined') && (this.func === "narrowband" || this.func === "narrowbandEq")) {
62
62
  if (node.start === '') { node.previous[t] = n; }
63
63
  else { node.previous[t] = node.start; }
64
64
  }
@@ -298,18 +298,16 @@ in your Node-RED user directory (${RED.settings.userDir}).
298
298
  }
299
299
  if (Object.keys(this.credentials).length != 0) {
300
300
  if (this.authType === "basic") {
301
- // Workaround for https://github.com/sindresorhus/got/issues/1169
302
- var cred = ""
303
- if (this.credentials.user) {
304
- // opts.username = this.credentials.user;
305
- cred = this.credentials.user
306
- }
307
- if (this.credentials.password) {
308
- // opts.password = this.credentials.password;
309
- cred += ":" + this.credentials.password
301
+ // Workaround for https://github.com/sindresorhus/got/issues/1169 (fixed in got v12)
302
+ // var cred = ""
303
+ if (this.credentials.user || this.credentials.password) {
304
+ // cred = `${this.credentials.user}:${this.credentials.password}`;
305
+ if (this.credentials.user === undefined) { this.credentials.user = ""}
306
+ if (this.credentials.password === undefined) { this.credentials.password = ""}
307
+ opts.headers.Authorization = "Basic " + Buffer.from(`${this.credentials.user}:${this.credentials.password}`).toString("base64");
310
308
  }
311
309
  // build own basic auth header
312
- opts.headers.Authorization = "Basic " + Buffer.from(cred).toString("base64");
310
+ // opts.headers.Authorization = "Basic " + Buffer.from(cred).toString("base64");
313
311
  } else if (this.authType === "digest") {
314
312
  let digestCreds = this.credentials;
315
313
  let sentCreds = false;
@@ -177,7 +177,8 @@
177
177
  path: {value:"",required:true,validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/)},
178
178
  tls: {type:"tls-config",required: false},
179
179
  wholemsg: {value:"false"},
180
- hb: {value: "", validate: RED.validators.number(/*blank allowed*/true) }
180
+ hb: {value: "", validate: RED.validators.number(/*blank allowed*/true) },
181
+ subprotocol: {value:"",required: false}
181
182
  },
182
183
  inputs:0,
183
184
  outputs:0,
@@ -265,7 +266,10 @@
265
266
  <label for="node-config-input-tls" data-i18n="httpin.tls-config"></label>
266
267
  <input type="text" id="node-config-input-tls">
267
268
  </div>
268
-
269
+ <div class="form-row">
270
+ <label for="node-config-input-subprotocol"><i class="fa fa-tag"></i> <span data-i18n="websocket.label.subprotocol"></span></label>
271
+ <input type="text" id="node-config-input-subprotocol">
272
+ </div>
269
273
  <div class="form-row">
270
274
  <label for="node-config-input-wholemsg" data-i18n="websocket.sendrec"></label>
271
275
  <select type="text" id="node-config-input-wholemsg" style="width: 70%;">
@@ -46,6 +46,12 @@ module.exports = function(RED) {
46
46
 
47
47
  // Store local copies of the node configuration (as defined in the .html)
48
48
  node.path = n.path;
49
+ if (typeof n.subprotocol === "string") {
50
+ // Split the string on comma and trim each result
51
+ node.subprotocol = n.subprotocol.split(",").map(v => v.trim())
52
+ } else {
53
+ node.subprotocol = [];
54
+ }
49
55
  node.wholemsg = (n.wholemsg === "true");
50
56
 
51
57
  node._inputNodes = []; // collection of nodes that want to receive events
@@ -92,7 +98,7 @@ module.exports = function(RED) {
92
98
  tlsNode.addTLSOptions(options);
93
99
  }
94
100
  }
95
- var socket = new ws(node.path,options);
101
+ var socket = new ws(node.path,node.subprotocol,options);
96
102
  socket.setMaxListeners(0);
97
103
  node.server = socket; // keep for closing
98
104
  handleConnection(socket);
@@ -105,22 +111,24 @@ module.exports = function(RED) {
105
111
  if (node.isServer) {
106
112
  node._clients[id] = socket;
107
113
  node.emit('opened',{count:Object.keys(node._clients).length,id:id});
108
- } else {
109
- if (node.heartbeat) {
110
- node.heartbeatInterval = setInterval(function() {
111
- if (socket.nrPendingHeartbeat) {
112
- // No pong received
113
- socket.terminate();
114
- socket.nrErrorHandler(new Error("timeout"));
115
- return;
116
- }
117
- socket.nrPendingHeartbeat = true;
118
- socket.ping();
119
- },node.heartbeat);
120
- }
121
114
  }
122
115
  socket.on('open',function() {
123
116
  if (!node.isServer) {
117
+ if (node.heartbeat) {
118
+ clearInterval(node.heartbeatInterval);
119
+ node.heartbeatInterval = setInterval(function() {
120
+ if (socket.nrPendingHeartbeat) {
121
+ // No pong received
122
+ socket.terminate();
123
+ socket.nrErrorHandler(new Error("timeout"));
124
+ return;
125
+ }
126
+ socket.nrPendingHeartbeat = true;
127
+ try {
128
+ socket.ping();
129
+ } catch(err) {}
130
+ },node.heartbeat);
131
+ }
124
132
  node.emit('opened',{count:'',id:id});
125
133
  }
126
134
  });
@@ -23,9 +23,17 @@
23
23
  </select>
24
24
  <span data-i18n="tcpin.label.port"></span> <input type="text" id="node-input-port" style="width:65px">
25
25
  </div>
26
- <div class="form-row hidden" id="node-input-host-row" style="padding-left: 110px;">
26
+ <div class="form-row hidden" id="node-input-host-row" style="padding-left:110px;">
27
27
  <span data-i18n="tcpin.label.host"></span> <input type="text" id="node-input-host" placeholder="localhost" style="width: 60%;">
28
28
  </div>
29
+ <div class="form-row" id="node-input-tls-enable">
30
+ <label> </label>
31
+ <input type="checkbox" id="node-input-usetls" style="display: inline-block; width:auto; vertical-align:top;">
32
+ <label for="node-input-usetls" style="width:auto" data-i18n="httpin.use-tls"></label>
33
+ <div id="node-row-tls" class="hide">
34
+ <label style="width:auto; margin-left:20px; margin-right:10px;" for="node-input-tls"><span data-i18n="httpin.tls-config"></span></label><input type="text" style="width: 300px" id="node-input-tls">
35
+ </div>
36
+ </div>
29
37
 
30
38
  <div class="form-row">
31
39
  <label><i class="fa fa-sign-out"></i> <span data-i18n="tcpin.label.output"></span></label>
@@ -42,7 +50,7 @@
42
50
  </div>
43
51
 
44
52
  <div id="node-row-newline" class="form-row hidden" style="padding-left:110px;">
45
- <span data-i18n="tcpin.label.delimited"></span> <input type="text" id="node-input-newline" style="width:110px;">
53
+ <span data-i18n="tcpin.label.delimited"></span> <input type="text" id="node-input-newline" style="width:110px;" data-i18n="[placeholder]tcpin.label.optional">
46
54
  </div>
47
55
 
48
56
  <div class="form-row">
@@ -58,17 +66,18 @@
58
66
  <script type="text/javascript">
59
67
  RED.nodes.registerType('tcp in',{
60
68
  category: 'network',
61
- color:"Silver",
69
+ color: "Silver",
62
70
  defaults: {
63
71
  name: {value:""},
64
- server: {value:"server",required:true},
65
- host: {value:"",validate:function(v) { return (this.server == "server")||v.length > 0;} },
66
- port: {value:"",required:true,validate:RED.validators.number()},
72
+ server: {value:"server", required:true},
73
+ host: {value:"", validate:function(v) { return (this.server == "server")||v.length > 0;} },
74
+ port: {value:"", required:true, validate:RED.validators.number()},
67
75
  datamode:{value:"stream"},
68
76
  datatype:{value:"buffer"},
69
77
  newline:{value:""},
70
78
  topic: {value:""},
71
- base64: {/*deprecated*/ value:false,required:true}
79
+ base64: {/*deprecated*/ value:false, required:true},
80
+ tls: {type:"tls-config", value:'', required:false}
72
81
  },
73
82
  inputs:0,
74
83
  outputs:1,
@@ -77,7 +86,7 @@
77
86
  return this.name || "tcp:"+(this.host?this.host+":":"")+this.port;
78
87
  },
79
88
  labelStyle: function() {
80
- return this.name?"node_label_italic":"";
89
+ return this.name ? "node_label_italic" : "";
81
90
  },
82
91
  oneditprepare: function() {
83
92
  var updateOptions = function() {
@@ -103,6 +112,27 @@
103
112
  $("#node-input-server").change(updateOptions);
104
113
  $("#node-input-datatype").change(updateOptions);
105
114
  $("#node-input-datamode").change(updateOptions);
115
+ function updateTLSOptions() {
116
+ if ($("#node-input-usetls").is(':checked')) {
117
+ $("#node-row-tls").show();
118
+ } else {
119
+ $("#node-row-tls").hide();
120
+ }
121
+ }
122
+ if (this.tls) {
123
+ $('#node-input-usetls').prop('checked', true);
124
+ } else {
125
+ $('#node-input-usetls').prop('checked', false);
126
+ }
127
+ updateTLSOptions();
128
+ $("#node-input-usetls").on("click",function() {
129
+ updateTLSOptions();
130
+ });
131
+ },
132
+ oneditsave: function() {
133
+ if (!$("#node-input-usetls").is(':checked')) {
134
+ $("#node-input-tls").val("_ADD_");
135
+ }
106
136
  }
107
137
  });
108
138
  </script>
@@ -123,6 +153,15 @@
123
153
  <span data-i18n="tcpin.label.host"></span> <input type="text" id="node-input-host" style="width: 60%;">
124
154
  </div>
125
155
 
156
+ <div class="form-row" id="node-input-tls-enable">
157
+ <label> </label>
158
+ <input type="checkbox" id="node-input-usetls" style="display: inline-block; width: auto; vertical-align: top;">
159
+ <label for="node-input-usetls" style="width: auto" data-i18n="httpin.use-tls"></label>
160
+ <div id="node-row-tls" class="hide">
161
+ <label style="width: auto; margin-left: 20px; margin-right: 10px;" for="node-input-tls"><span data-i18n="httpin.tls-config"></span></label><input type="text" style="width: 300px" id="node-input-tls">
162
+ </div>
163
+ </div>
164
+
126
165
  <div class="form-row hidden" id="node-input-end-row">
127
166
  <label>&nbsp;</label>
128
167
  <input type="checkbox" id="node-input-end" style="display: inline-block; width: auto; vertical-align: top;">
@@ -144,14 +183,15 @@
144
183
  <script type="text/javascript">
145
184
  RED.nodes.registerType('tcp out',{
146
185
  category: 'network',
147
- color:"Silver",
186
+ color: "Silver",
148
187
  defaults: {
188
+ name: {value:""},
149
189
  host: {value:"",validate:function(v) { return (this.beserver != "client")||v.length > 0;} },
150
190
  port: {value:"",validate:function(v) { return (this.beserver == "reply")||RED.validators.number()(v); } },
151
- beserver: {value:"client",required:true},
152
- base64: {value:false,required:true},
153
- end: {value:false,required:true},
154
- name: {value:""}
191
+ beserver: {value:"client", required:true},
192
+ base64: {value:false, required:true},
193
+ end: {value:false, required:true},
194
+ tls: {type:"tls-config", value:'', required:false}
155
195
  },
156
196
  inputs:1,
157
197
  outputs:0,
@@ -170,18 +210,42 @@
170
210
  $("#node-input-port-row").hide();
171
211
  $("#node-input-host-row").hide();
172
212
  $("#node-input-end-row").hide();
213
+ $("#node-input-tls-enable").hide();
173
214
  } else if (sockettype == "client"){
174
215
  $("#node-input-port-row").show();
175
216
  $("#node-input-host-row").show();
176
217
  $("#node-input-end-row").show();
218
+ $("#node-input-tls-enable").show();
177
219
  } else {
178
220
  $("#node-input-port-row").show();
179
221
  $("#node-input-host-row").hide();
180
222
  $("#node-input-end-row").show();
223
+ $("#node-input-tls-enable").show();
181
224
  }
182
225
  };
183
226
  updateOptions();
184
227
  $("#node-input-beserver").change(updateOptions);
228
+ function updateTLSOptions() {
229
+ if ($("#node-input-usetls").is(':checked')) {
230
+ $("#node-row-tls").show();
231
+ } else {
232
+ $("#node-row-tls").hide();
233
+ }
234
+ }
235
+ if (this.tls) {
236
+ $('#node-input-usetls').prop('checked', true);
237
+ } else {
238
+ $('#node-input-usetls').prop('checked', false);
239
+ }
240
+ updateTLSOptions();
241
+ $("#node-input-usetls").on("click",function() {
242
+ updateTLSOptions();
243
+ });
244
+ },
245
+ oneditsave: function() {
246
+ if (!$("#node-input-usetls").is(':checked')) {
247
+ $("#node-input-tls").val("_ADD_");
248
+ }
185
249
  }
186
250
  });
187
251
  </script>
@@ -194,15 +258,23 @@
194
258
  <span data-i18n="tcpin.label.port"></span>
195
259
  <input type="text" id="node-input-port" style="width:60px">
196
260
  </div>
261
+ <div class="form-row" id="node-input-tls-enable">
262
+ <label> </label>
263
+ <input type="checkbox" id="node-input-usetls" style="display: inline-block; width: auto; vertical-align: top;">
264
+ <label for="node-input-usetls" style="width: auto" data-i18n="httpin.use-tls"></label>
265
+ <div id="node-row-tls" class="hide">
266
+ <label style="width: auto; margin-left: 20px; margin-right: 10px;" for="node-input-tls"><span data-i18n="httpin.tls-config"></span></label><input type="text" style="width: 300px" id="node-input-tls">
267
+ </div>
268
+ </div>
197
269
  <div class="form-row">
198
- <label for="node-input-out"><i class="fa fa-sign-out"></i> <span data-i18n="tcpin.label.return"></span></label>
270
+ <label for="node-input-ret"><i class="fa fa-sign-out"></i> <span data-i18n="tcpin.label.return"></span></label>
199
271
  <select type="text" id="node-input-ret" style="width:54%;">
200
272
  <option value="buffer" data-i18n="tcpin.output.buffer"></option>
201
273
  <option value="string" data-i18n="tcpin.output.string"></option>
202
274
  </select>
203
275
  </div>
204
276
  <div class="form-row">
205
- <label for="node-input-out"> </label>
277
+ <label for="node-input-out"><i class="fa fa-sign-out fa-rotate-90"></i> <span data-i18n="tcpin.label.close"></span></label>
206
278
  <select type="text" id="node-input-out" style="width:54%;">
207
279
  <option value="time" data-i18n="tcpin.return.timeout"></option>
208
280
  <option value="char" data-i18n="tcpin.return.character"></option>
@@ -213,6 +285,9 @@
213
285
  <input type="text" id="node-input-splitc" style="width:50px;">
214
286
  <span id="node-units"></span>
215
287
  </div>
288
+ <div id="node-row-newline" class="form-row hidden" style="padding-left:162px;">
289
+ <span data-i18n="tcpin.label.delimited"></span> <input type="text" id="node-input-newline" style="width:110px;" data-i18n="[placeholder]tcpin.label.optional">
290
+ </div>
216
291
  <div class="form-row">
217
292
  <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
218
293
  <input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
@@ -222,14 +297,16 @@
222
297
  <script type="text/javascript">
223
298
  RED.nodes.registerType('tcp request',{
224
299
  category: 'network',
225
- color:"Silver",
300
+ color: "Silver",
226
301
  defaults: {
302
+ name: {value:""},
227
303
  server: {value:""},
228
- port: {value:"",validate:RED.validators.regex(/^(\d*|)$/)},
229
- out: {value:"time",required:true},
304
+ port: {value:"", validate:RED.validators.regex(/^(\d*|)$/)},
305
+ out: {value:"time", required:true},
230
306
  ret: {value:"buffer"},
231
- splitc: {value:"0",required:true},
232
- name: {value:""}
307
+ splitc: {value:"0", required:true},
308
+ newline: {value:""},
309
+ tls: {type:"tls-config", value:'', required:false}
233
310
  },
234
311
  inputs:1,
235
312
  outputs:1,
@@ -246,6 +323,14 @@
246
323
  $("#node-input-ret").val("buffer");
247
324
  this.ret = "buffer";
248
325
  }
326
+ $("#node-input-ret").on("change", function() {
327
+ if ($("#node-input-ret").val() === "string" && $("#node-input-out").val() === "sit") { $("#node-row-newline").show(); }
328
+ else { $("#node-row-newline").hide(); }
329
+ });
330
+ $("#node-input-out").on("change", function() {
331
+ if ($("#node-input-ret").val() === "string" && $("#node-input-out").val() === "sit") { $("#node-row-newline").show(); }
332
+ else { $("#node-row-newline").hide(); }
333
+ });
249
334
  $("#node-input-out").on('focus', function () { previous = this.value; }).on("change", function() {
250
335
  $("#node-input-splitc").show();
251
336
  if (previous === null) { previous = $("#node-input-out").val(); }
@@ -272,6 +357,27 @@
272
357
  $("#node-input-splitc").hide();
273
358
  }
274
359
  });
360
+ function updateTLSOptions() {
361
+ if ($("#node-input-usetls").is(':checked')) {
362
+ $("#node-row-tls").show();
363
+ } else {
364
+ $("#node-row-tls").hide();
365
+ }
366
+ }
367
+ if (this.tls) {
368
+ $('#node-input-usetls').prop('checked', true);
369
+ } else {
370
+ $('#node-input-usetls').prop('checked', false);
371
+ }
372
+ updateTLSOptions();
373
+ $("#node-input-usetls").on("click",function() {
374
+ updateTLSOptions();
375
+ });
376
+ },
377
+ oneditsave: function() {
378
+ if (!$("#node-input-usetls").is(':checked')) {
379
+ $("#node-input-tls").val("_ADD_");
380
+ }
275
381
  }
276
382
  });
277
383
  </script>