mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Trigger node - hide second outpiut option when not appropriate
Update status to better reflect multiple streams in flight
This commit is contained in:
parent
fbd911ed27
commit
b6e0568e76
@ -47,7 +47,7 @@
|
|||||||
<input type="hidden" id="node-input-op2type">
|
<input type="hidden" id="node-input-op2type">
|
||||||
<input style="width:70%" type="text" id="node-input-op2" placeholder="0">
|
<input style="width:70%" type="text" id="node-input-op2" placeholder="0">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row" id="node-second-output">
|
||||||
<label></label>
|
<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>
|
<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>
|
||||||
@ -138,15 +138,22 @@
|
|||||||
if ($(this).val() == "block") {
|
if ($(this).val() == "block") {
|
||||||
$(".node-type-wait").hide();
|
$(".node-type-wait").hide();
|
||||||
$(".node-type-duration").hide();
|
$(".node-type-duration").hide();
|
||||||
|
$("#node-second-output").hide();
|
||||||
|
$("#node-input-second").prop('checked', false);
|
||||||
|
that.outputs = 1;
|
||||||
}
|
}
|
||||||
else if ($(this).val() == "loop") {
|
else if ($(this).val() == "loop") {
|
||||||
if ($("#node-input-duration").val() == 0) { $("#node-input-duration").val(250); }
|
if ($("#node-input-duration").val() == 0) { $("#node-input-duration").val(250); }
|
||||||
$(".node-type-wait").hide();
|
$(".node-type-wait").hide();
|
||||||
$(".node-type-duration").show();
|
$(".node-type-duration").show();
|
||||||
|
$("#node-second-output").hide();
|
||||||
|
$("#node-input-second").prop('checked', false);
|
||||||
|
that.outputs = 1;
|
||||||
} else {
|
} else {
|
||||||
if ($("#node-input-duration").val() == 0) { $("#node-input-duration").val(250); }
|
if ($("#node-input-duration").val() == 0) { $("#node-input-duration").val(250); }
|
||||||
$(".node-type-wait").show();
|
$(".node-type-wait").show();
|
||||||
$(".node-type-duration").show();
|
$(".node-type-duration").show();
|
||||||
|
$("#node-second-output").show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -113,6 +113,13 @@ module.exports = function(RED) {
|
|||||||
processMessageQueue(msg);
|
processMessageQueue(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var stat = function() {
|
||||||
|
var l = Object.keys(node.topics).length;
|
||||||
|
if (l === 0) { return {} }
|
||||||
|
else if (l === 1) { return {fill:"blue",shape:"dot"} }
|
||||||
|
else return {fill:"blue",shape:"dot",text:l};
|
||||||
|
}
|
||||||
|
|
||||||
var processMessage = function(msg) {
|
var processMessage = function(msg) {
|
||||||
var topic = RED.util.getMessageProperty(msg,node.topic) || "_none";
|
var topic = RED.util.getMessageProperty(msg,node.topic) || "_none";
|
||||||
var promise;
|
var promise;
|
||||||
@ -122,7 +129,7 @@ module.exports = function(RED) {
|
|||||||
if (node.loop === true) { clearInterval(node.topics[topic].tout); }
|
if (node.loop === true) { clearInterval(node.topics[topic].tout); }
|
||||||
else { clearTimeout(node.topics[topic].tout); }
|
else { clearTimeout(node.topics[topic].tout); }
|
||||||
delete node.topics[topic];
|
delete node.topics[topic];
|
||||||
node.status({});
|
node.status(stat());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (node.op2type === "payl") { npay[topic] = RED.util.cloneMessage(msg); }
|
if (node.op2type === "payl") { npay[topic] = RED.util.cloneMessage(msg); }
|
||||||
@ -201,19 +208,19 @@ module.exports = function(RED) {
|
|||||||
else { node.send(msg2); }
|
else { node.send(msg2); }
|
||||||
}
|
}
|
||||||
delete node.topics[topic];
|
delete node.topics[topic];
|
||||||
node.status({});
|
node.status(stat());
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
node.error(err);
|
node.error(err);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
delete node.topics[topic];
|
delete node.topics[topic];
|
||||||
node.status({});
|
node.status(stat());
|
||||||
}
|
}
|
||||||
|
|
||||||
}, node.duration);
|
}, node.duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node.status({fill:"blue",shape:"dot",text:" "});
|
node.status(stat());
|
||||||
if (node.op1type !== "nul") { node.send(RED.util.cloneMessage(msg)); }
|
if (node.op1type !== "nul") { node.send(RED.util.cloneMessage(msg)); }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -249,7 +256,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete node.topics[topic];
|
delete node.topics[topic];
|
||||||
node.status({});
|
node.status(stat());
|
||||||
if (node.second === true) { node.send([null,msg2]); }
|
if (node.second === true) { node.send([null,msg2]); }
|
||||||
else { node.send(msg2); }
|
else { node.send(msg2); }
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
@ -272,7 +279,7 @@ module.exports = function(RED) {
|
|||||||
delete node.topics[t];
|
delete node.topics[t];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node.status({});
|
node.status(stat());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("trigger",TriggerNode);
|
RED.nodes.registerType("trigger",TriggerNode);
|
||||||
|
@ -42,4 +42,6 @@
|
|||||||
is reset by a received message.</p>
|
is reset by a received message.</p>
|
||||||
<p>Optionally, the node can be configured to treat messages as if they are separate streams,
|
<p>Optionally, the node can be configured to treat messages as if they are separate streams,
|
||||||
using a msg property to identify each stream. Default <code>msg.topic</code>.</p>
|
using a msg property to identify each stream. Default <code>msg.topic</code>.</p>
|
||||||
|
<p>The status indicates the node is currently active. If multiple streams are used the status
|
||||||
|
indicates the number of streams being held.</p>
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user