mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add second output to trigger node
and add tests
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<script type="text/x-red" data-template-name="trigger">
|
||||
<script type="text/html" data-template-name="trigger">
|
||||
<div class="form-row">
|
||||
<label data-i18n="trigger.send" for="node-input-op1"></label>
|
||||
<input type="hidden" id="node-input-op1type">
|
||||
@@ -47,6 +47,10 @@
|
||||
<input type="hidden" id="node-input-op2type">
|
||||
<input style="width: 70%" type="text" id="node-input-op2" placeholder="0">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label></label>
|
||||
<input type="checkbox" id="node-input-second" style="margin-left: 0px; vertical-align: top; width: auto !important;"> <label style="width:auto !important;" for="node-input-second" data-i18n="trigger.second"></label>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label data-i18n="trigger.label.reset" style="width:auto"></label>
|
||||
<div style="display:inline-block; width:70%;vertical-align:top">
|
||||
@@ -80,9 +84,11 @@
|
||||
op2type: {value:"val"},
|
||||
duration: {value:"250",required:true,validate:RED.validators.number()},
|
||||
extend: {value:"false"},
|
||||
second: {value:false},
|
||||
units: {value:"ms"},
|
||||
reset: {value:""},
|
||||
bytopic: {value: "all"},
|
||||
bytopic: {value:"all"},
|
||||
outputs: {value:1},
|
||||
name: {value:""}
|
||||
},
|
||||
inputs:1,
|
||||
@@ -103,6 +109,15 @@
|
||||
return this.name?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
var that = this;
|
||||
$("#node-input-second").change(function() {
|
||||
if ($("#node-input-second").is(":checked")) {
|
||||
that.outputs = 2;
|
||||
}
|
||||
else {
|
||||
that.outputs = 1;
|
||||
}
|
||||
});
|
||||
$("#node-then-type").on("change", function() {
|
||||
if ($(this).val() == "block") {
|
||||
$(".node-type-wait").hide();
|
||||
|
@@ -24,6 +24,7 @@ module.exports = function(RED) {
|
||||
this.op2 = n.op2 || "0";
|
||||
this.op1type = n.op1type || "str";
|
||||
this.op2type = n.op2type || "str";
|
||||
this.second = n.second || false;
|
||||
|
||||
if (this.op1type === 'val') {
|
||||
if (this.op1 === 'true' || this.op1 === 'false') {
|
||||
@@ -188,7 +189,8 @@ module.exports = function(RED) {
|
||||
promise.then(() => {
|
||||
msg2.payload = node.topics[topic].m2;
|
||||
delete node.topics[topic];
|
||||
node.send(msg2);
|
||||
if (node.second === true) { node.send([null,msg2]); }
|
||||
else { node.send(msg2); }
|
||||
node.status({});
|
||||
}).catch(err => {
|
||||
node.error(err);
|
||||
@@ -238,7 +240,8 @@ module.exports = function(RED) {
|
||||
}
|
||||
delete node.topics[topic];
|
||||
node.status({});
|
||||
node.send(msg2);
|
||||
if (node.second === true) { node.send([null,msg2]); }
|
||||
else { node.send(msg2); }
|
||||
}).catch(err => {
|
||||
node.error(err);
|
||||
});
|
||||
|
Reference in New Issue
Block a user