mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Tweaks to timer node - limit delays/rate to +ve numbers... add bit more info, slight tidy up.
This commit is contained in:
parent
81d6a4b04f
commit
426444b042
@ -14,14 +14,12 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- First, the content of the edit dialog is defined. -->
|
||||
<script type="text/x-red" data-template-name="delay">
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-pauseType"><i class="icon-tasks"></i> Action</label>
|
||||
<select id="node-input-pauseType" style="width:270px !important">
|
||||
<option value="delay">Delay message</option>
|
||||
<option value="rate">Limit rate to</option>
|
||||
<option value="rate">Limit message rate</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="delay-details" class="form-row">
|
||||
@ -35,11 +33,10 @@
|
||||
<option value="days">Days</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="rate-details" class="form-row">
|
||||
<label for="node-input-rate"><i class="icon-time"></i> To</label>
|
||||
<input type="text" id="node-input-rate" placeholder="1" style="direction:rtl; width:50px !important">
|
||||
<label for="node-input-reateUnits">message(s) per</label>
|
||||
<input type="text" id="node-input-rate" placeholder="1" style="direction:rtl; width:40px !important">
|
||||
<label for="node-input-rateUnits" style="width:120px !important">message(s) per</label>
|
||||
<select id="node-input-rateUnits" style="width:140px !important">
|
||||
<option value="second">Second</option>
|
||||
<option value="minute">Minute</option>
|
||||
@ -47,37 +44,35 @@
|
||||
<option value="day">Day</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Next, some simple help text is provided for the node. -->
|
||||
|
||||
<script type="text/x-red" data-help-name="delay">
|
||||
<p>Introduces a delay into a flow or rate limts messges</p>
|
||||
<p>Default delay is 5 seconds and rate limit of 1 msg/second, but both can be configured</p>
|
||||
<p>Introduces a delay into a flow or rate limits messages</p>
|
||||
<p>Default delay is 5 seconds or rate limit of 1 message/second, but both can be configured</p>
|
||||
<p>The rate limiter will delay messages by buffering in a time released queue. A warning is generated if the buffer is larger than 1000 items.</p>
|
||||
</script>
|
||||
|
||||
<!-- Finally, the node type is registered along with all of its properties -->
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('delay',{
|
||||
category: 'function', // the palette category
|
||||
category: 'function',
|
||||
color:"#E6E0F8",
|
||||
defaults: { // defines the editable properties of the node
|
||||
name: {value:""}, // along with default values.
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
pauseType: {value:"delay", required:true},
|
||||
timeout: {value:"5", required:true, validate:RED.validators.number()},
|
||||
timeoutUnits: {value:"seconds"},
|
||||
rate: {value:"1", required:true, validate:RED.validators.number()},
|
||||
rateUnits: {value: "second"}
|
||||
},
|
||||
inputs:1, // set the number of inputs - only 0 or 1
|
||||
outputs:1, // set the number of outputs - 0 to n
|
||||
icon: "arrow-in.png", // set the icon (held in public/icons)
|
||||
label: function() { // sets the default label contents
|
||||
inputs:1,
|
||||
outputs:1,
|
||||
icon: "timer.png",
|
||||
label: function() {
|
||||
if (this.pauseType == "delay") {
|
||||
var units = this.timeoutUnits ? this.timeoutUnits.charAt(0) : "s";
|
||||
return this.name||"delay "+this.timeout+" " + units;
|
||||
@ -85,14 +80,14 @@
|
||||
var units = this.rateUnits ? this.rateUnits.charAt(0) : "s";
|
||||
return this.name||"limit "+this.rate+" msg/"+ units;
|
||||
}
|
||||
return "foo";
|
||||
return "";
|
||||
},
|
||||
labelStyle: function() { // sets the class to apply to the label
|
||||
labelStyle: function() {
|
||||
return this.name?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
$( "#node-input-timeout" ).spinner();
|
||||
$( "#node-input-rate" ).spinner();
|
||||
$( "#node-input-timeout" ).spinner({ min:1, max:60 });
|
||||
$( "#node-input-rate" ).spinner({ min:1});
|
||||
|
||||
if (this.pauseType == "delay") {
|
||||
$("#delay-details").show();
|
||||
|
@ -16,10 +16,8 @@
|
||||
|
||||
// Simple node to introduce a pause into a flow
|
||||
|
||||
// Require main module
|
||||
var RED = require("../../red/red");
|
||||
|
||||
// main node definition
|
||||
function DelayNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
|
||||
@ -101,9 +99,4 @@ function DelayNode(n) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// register node
|
||||
RED.nodes.registerType("delay",DelayNode);
|
||||
|
||||
|
BIN
public/icons/timer.png
Normal file
BIN
public/icons/timer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Loading…
Reference in New Issue
Block a user