@node-red/nodes 4.1.7 → 4.1.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.
@@ -351,6 +351,27 @@
351
351
  return _libs;
352
352
  }
353
353
 
354
+ function getEditorValue(editor, defaultValue) {
355
+ var val = editor.getValue();
356
+ if (defaultValue && val.trim() === defaultValue.trim()) {
357
+ return "";
358
+ } else {
359
+ return val;
360
+ }
361
+ }
362
+
363
+ function getEditorErrorCount(editor) {
364
+ const annot = editor.getSession().getAnnotations();
365
+ let count = 0
366
+ for (var k=0; k < annot.length; k++) {
367
+ if (annot[k].type === "error") {
368
+ count += annot.length;
369
+ break;
370
+ }
371
+ }
372
+ return count
373
+ }
374
+
354
375
  RED.nodes.registerType('function',{
355
376
  color:"#fdd0a2",
356
377
  category: 'function',
@@ -427,6 +448,7 @@
427
448
  } else if (that.finalizeEditor.getDomNode() == editor[0]) {
428
449
  that.finalizeEditor.focus();
429
450
  }
451
+ updateTabBadges();
430
452
  }
431
453
  }
432
454
  });
@@ -451,6 +473,28 @@
451
473
 
452
474
  tabs.activateTab("func-tab-body");
453
475
 
476
+
477
+ const updateTabBadge = (tabId, editorName, defaultValue) => {
478
+ const editor = this[editorName]
479
+ const hasContent = getEditorValue(editor, defaultValue) !== ''
480
+ // This doesn't work as the annotations appear to be cleared when the editor isn't active
481
+ // TODO: add a badge for tabs with errors
482
+ // const hasErrors = getEditorErrorCount(editor) > 0
483
+ const badgeSpan = $(`#red-ui-tab-${tabId} .red-ui-tabs-badges`)
484
+ badgeSpan.find('i').remove()
485
+ $(`#red-ui-tab-${tabId} .red-ui-tabs-badges i`).remove()
486
+ if (hasContent) {
487
+ $('<i style="display: inline" class="fa fa-file-code-o"></i>').appendTo(badgeSpan)
488
+ }
489
+
490
+ }
491
+
492
+ const updateTabBadges = function () {
493
+ updateTabBadge("func-tab-body", "editor", "")
494
+ updateTabBadge("func-tab-init", "initEditor", RED._("node-red:function.text.initialize"))
495
+ updateTabBadge("func-tab-finalize", "finalizeEditor", RED._("node-red:function.text.finalize"))
496
+ }
497
+
454
498
  $( "#node-input-outputs" ).spinner({
455
499
  min: 0,
456
500
  max: 500,
@@ -593,27 +637,18 @@
593
637
  if (RED.settings.functionExternalModules !== false) {
594
638
  prepareLibraryConfig(that);
595
639
  }
640
+
641
+ updateTabBadges();
596
642
  },
597
643
  oneditsave: function() {
598
- var node = this;
599
- var noerr = 0;
644
+ const node = this;
645
+ let noerr = 0;
600
646
  $("#node-input-noerr").val(0);
601
647
 
602
- var disposeEditor = function(editorName,targetName,defaultValue) {
603
- var editor = node[editorName];
604
- var annot = editor.getSession().getAnnotations();
605
- for (var k=0; k < annot.length; k++) {
606
- if (annot[k].type === "error") {
607
- noerr += annot.length;
608
- break;
609
- }
610
- }
611
- var val = editor.getValue();
612
- if (defaultValue) {
613
- if (val.trim() == defaultValue.trim()) {
614
- val = "";
615
- }
616
- }
648
+ const disposeEditor = function(editorName,targetName,defaultValue) {
649
+ const editor = node[editorName];
650
+ noerr += getEditorErrorCount(editor)
651
+ const val = getEditorValue(editor, defaultValue)
617
652
  editor.destroy();
618
653
  delete node[editorName];
619
654
  $("#"+targetName).val(val);
@@ -111,7 +111,7 @@ module.exports = function(RED) {
111
111
  client = tls.connect(node.port, connOpts, function() {
112
112
  buffer = (node.datatype == 'buffer') ? Buffer.alloc(0) : "";
113
113
  node.connected = true;
114
- node.log(RED._("status.connected", {host: node.host, port: node.port}));
114
+ node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
115
115
  node.status({fill:"green",shape:"dot",text:"common.status.connected",_session:{type:"tcp",id:id}});
116
116
  });
117
117
  }
@@ -349,7 +349,7 @@ module.exports = function(RED) {
349
349
  client = tls.connect(node.port, connOpts, function() {
350
350
  // buffer = (node.datatype == 'buffer') ? Buffer.alloc(0) : "";
351
351
  node.connected = true;
352
- node.log(RED._("status.connected", {host: node.host, port: node.port}));
352
+ node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
353
353
  node.status({fill:"green",shape:"dot",text:"common.status.connected"});
354
354
  });
355
355
  }
@@ -15,7 +15,7 @@
15
15
  -->
16
16
 
17
17
  <script type="text/html" data-help-name="link in">
18
- <p>Crée des liens virtuelles entre les flux.</p>
18
+ <p>Crée des liens virtuels entre les flux.</p>
19
19
  <h3>Détails</h3>
20
20
  <p>Le noeud peut être connecté à n'importe quel noeud <code>Link out</code> qui existe sur n'importe quel onglet.
21
21
  Une fois connectés, ils se comportent comme s'ils étaient câblés ensemble.</p>
@@ -63,4 +63,4 @@
63
63
  </p>
64
64
  Le flux connecté à ce noeud doit se terminer par un noeud <code>Link out</code> configuré
65
65
  en mode 'retour'.</p>
66
- </script>
66
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/nodes",
3
- "version": "4.1.7",
3
+ "version": "4.1.8",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",