mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add new msg.delay option to delay node
and msg.reset to clear/fluch existing delays
This commit is contained in:
@@ -15,17 +15,18 @@
|
||||
-->
|
||||
|
||||
<script type="text/x-red" data-template-name="delay">
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-pauseType"><i class="fa fa-tasks"></i> <span data-i18n="delay.action"></span></label>
|
||||
<select id="node-input-pauseType" style="width:270px !important">
|
||||
<option value="delay" data-i18n="delay.delaymsg"></option>
|
||||
<option value="delayv" data-i18n="delay.delayvarmsg"></option>
|
||||
<option value="random" data-i18n="delay.randomdelay"></option>
|
||||
<option value="rate" data-i18n="delay.limitrate"></option>
|
||||
<option value="queue" data-i18n="delay.fairqueue"></option>
|
||||
<option value="timed" data-i18n="delay.timedqueue"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="delay-details" class="form-row">
|
||||
<label for="node-input-timeout"><i class="fa fa-clock-o"></i> <span data-i18n="delay.for"></span></label>
|
||||
<input type="text" id="node-input-timeout" placeholder="Time" style="text-align:end; width:50px !important">
|
||||
@@ -53,7 +54,6 @@
|
||||
<div id="node-input-dr"><input style="margin: 20px 0 20px 100px; width: 30px;" type="checkbox" id="node-input-drop"><label style="width: 250px;" for="node-input-drop"><span data-i18n="delay.dropmsg"></span></label></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="random-details" class="form-row">
|
||||
<label for="node-input-randomFirst"><i class="fa fa-clock-o"></i> <span data-i18n="delay.between"></span></label>
|
||||
<input type="text" id="node-input-randomFirst" placeholder="" style="text-align:end; width:30px !important">
|
||||
@@ -72,7 +72,6 @@
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
||||
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="delay">
|
||||
@@ -80,6 +79,7 @@
|
||||
<p>The default delay is 5 seconds and rate limit of 1 msg/second, but both can be configured.</p>
|
||||
<p>When set to rate limit messages, they are spread across the configured time period. It can
|
||||
also be set to discard any intermediate messages that arrive.</p>
|
||||
<p>If configured to use <code>msg.delay</code> the delay is specified in milliseconds.</p>
|
||||
<p>The "topic based fair queue" adds messages to a release queue tagged by their <code>msg.topic</code> property.
|
||||
At each "tick", derived from the rate, the next "topic" is released.
|
||||
Any messages arriving on the same topic before release replace those in that position in the queue.
|
||||
@@ -110,15 +110,17 @@
|
||||
outputs:1,
|
||||
icon: "timer.png",
|
||||
label: function() {
|
||||
if (this.pauseType == "delay") {
|
||||
var units = this.timeoutUnits ? this.timeoutUnits.charAt(0) : "s";
|
||||
if (this.timeoutUnits == "milliseconds") { units = "ms"; }
|
||||
return this.name||this._("delay.label.delay")+" "+this.timeout+" "+units;
|
||||
if (this.pauseType == "delayv") {
|
||||
return this.name||this._("delay.label.variable");
|
||||
} else if (this.pauseType == "delay") {
|
||||
var units = this.timeoutUnits ? this.timeoutUnits.charAt(0) : "s";
|
||||
if (this.timeoutUnits == "milliseconds") { units = "ms"; }
|
||||
return this.name||this._("delay.label.delay")+" "+this.timeout+" "+units;
|
||||
} else if (this.pauseType == "rate") {
|
||||
var units = this.rateUnits ? (this.nbRateUnits > 1 ? this.nbRateUnits : '') + this.rateUnits.charAt(0) : "s";
|
||||
return this.name||this._("delay.label.limit")+" "+this.rate+" msg/"+units;
|
||||
var units = this.rateUnits ? (this.nbRateUnits > 1 ? this.nbRateUnits : '') + this.rateUnits.charAt(0) : "s";
|
||||
return this.name||this._("delay.label.limit")+" "+this.rate+" msg/"+units;
|
||||
} else if (this.pauseType == "random") {
|
||||
return this.name || this._("delay.label.random");
|
||||
return this.name || this._("delay.label.random");
|
||||
}
|
||||
else if (this.pauseType == "timed") {
|
||||
var units = '';
|
||||
@@ -154,10 +156,10 @@
|
||||
var $this = $(this);
|
||||
var val = parseInt($this.val());
|
||||
var type = "singular";
|
||||
if(val > 1) {
|
||||
if (val > 1) {
|
||||
type = "plural";
|
||||
}
|
||||
if($this.attr("data-type") == type) {
|
||||
if ($this.attr("data-type") == type) {
|
||||
return;
|
||||
}
|
||||
$this.attr("data-type", type);
|
||||
@@ -166,16 +168,19 @@
|
||||
var key = "delay.label.units." + $option.val() + "." + type;
|
||||
$option.attr('data-i18n', 'node-red:' + key);
|
||||
$option.html(node._(key));
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (this.pauseType == "delay") {
|
||||
$("#delay-details").show();
|
||||
$("#rate-details").hide();
|
||||
$("#random-details").hide();
|
||||
$("#node-input-dr").hide();
|
||||
} else if (this.pauseType == "delayv") {
|
||||
$("#delay-details").hide();
|
||||
$("#rate-details").hide();
|
||||
$("#random-details").hide();
|
||||
$("#node-input-dr").hide();
|
||||
} else if (this.pauseType == "rate") {
|
||||
$("#delay-details").hide();
|
||||
$("#rate-details").show();
|
||||
@@ -216,12 +221,17 @@
|
||||
$("#rate-details").hide();
|
||||
$("#random-details").hide();
|
||||
$("#node-input-dr").hide();
|
||||
} else if (this.value == "delayv") {
|
||||
$("#delay-details").hide();
|
||||
$("#rate-details").hide();
|
||||
$("#random-details").hide();
|
||||
$("#node-input-dr").hide();
|
||||
} else if (this.value == "rate") {
|
||||
$("#delay-details").hide();
|
||||
$("#rate-details").show();
|
||||
$("#random-details").hide();
|
||||
$("#node-input-dr").show();
|
||||
} else if (this.value == "random") {
|
||||
} else if (this.value == "random") {
|
||||
$("#delay-details").hide();
|
||||
$("#rate-details").hide();
|
||||
$("#random-details").show();
|
||||
|
Reference in New Issue
Block a user