mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Allow trigger node to use other than msg.topic to separate streams
and add test
This commit is contained in:
@@ -62,10 +62,13 @@
|
||||
<br/>
|
||||
<div class="form-row">
|
||||
<label data-i18n="trigger.for" for="node-input-bytopic"></label>
|
||||
<select id="node-input-bytopic">
|
||||
<select id="node-input-bytopic" style="width:120px;">
|
||||
<option value="all" data-i18n="trigger.alltopics"></option>
|
||||
<option value="topic" data-i18n="trigger.bytopics"></option>
|
||||
</select>
|
||||
<span class="form-row" id="node-trigger-property">
|
||||
<input type="text" id="node-input-property" style="width:46%;"/>
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
||||
@@ -78,6 +81,7 @@
|
||||
category: 'function',
|
||||
color:"#E6E0F8",
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
op1: {value:"1", validate: RED.validators.typedInput("op1type")},
|
||||
op2: {value:"0", validate: RED.validators.typedInput("op2type")},
|
||||
op1type: {value:"val"},
|
||||
@@ -89,7 +93,7 @@
|
||||
reset: {value:""},
|
||||
bytopic: {value:"all"},
|
||||
outputs: {value:1},
|
||||
name: {value:""}
|
||||
property: {value:"topic",required:true}
|
||||
},
|
||||
inputs:1,
|
||||
outputs:1,
|
||||
@@ -110,6 +114,19 @@
|
||||
},
|
||||
oneditprepare: function() {
|
||||
var that = this;
|
||||
if (this.property === undefined) {
|
||||
$("#node-input-property").val("topic");
|
||||
}
|
||||
$("#node-input-property").typedInput({default:'msg',types:['msg']});
|
||||
$("#node-input-bytopic").on("change", function() {
|
||||
console.log("BYT",$("#node-input-bytopic").val());
|
||||
if ($("#node-input-bytopic").val() === "all") {
|
||||
$("#node-trigger-property").hide();
|
||||
} else {
|
||||
$("#node-trigger-property").show();
|
||||
}
|
||||
});
|
||||
|
||||
$("#node-input-second").change(function() {
|
||||
if ($("#node-input-second").is(":checked")) {
|
||||
that.outputs = 2;
|
||||
@@ -191,8 +208,6 @@
|
||||
if ($("#node-then-type").val() == "loop") {
|
||||
$("#node-input-duration").val($("#node-input-duration").val() * -1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@@ -25,6 +25,7 @@ module.exports = function(RED) {
|
||||
this.op1type = n.op1type || "str";
|
||||
this.op2type = n.op2type || "str";
|
||||
this.second = n.second || false;
|
||||
this.property = n.property || "topic";
|
||||
|
||||
if (this.op1type === 'val') {
|
||||
if (this.op1 === 'true' || this.op1 === 'false') {
|
||||
@@ -112,7 +113,7 @@ module.exports = function(RED) {
|
||||
});
|
||||
|
||||
var processMessage = function(msg) {
|
||||
var topic = msg.topic || "_none";
|
||||
var topic = RED.util.getMessageProperty(msg,node.property) || "_none";
|
||||
var promise;
|
||||
if (node.bytopic === "all") { topic = "_none"; }
|
||||
node.topics[topic] = node.topics[topic] || {};
|
||||
|
Reference in New Issue
Block a user