mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
360b0d9997
commit
d8a3d2793f
@ -172,8 +172,7 @@
|
|||||||
}
|
}
|
||||||
else if ((this.duration * 1) < 0) {
|
else if ((this.duration * 1) < 0) {
|
||||||
$("#node-then-type").val("loop");
|
$("#node-then-type").val("loop");
|
||||||
this.duration = this.duration * -1;
|
$("#node-input-duration").val(this.duration*-1);
|
||||||
$("#node-input-duration").val(this.duration);
|
|
||||||
} else {
|
} else {
|
||||||
$("#node-then-type").val("wait");
|
$("#node-then-type").val("wait");
|
||||||
}
|
}
|
||||||
@ -194,6 +193,7 @@
|
|||||||
$("#node-input-duration").val($("#node-input-duration").val() * -1);
|
$("#node-input-duration").val($("#node-input-duration").val() * -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -47,7 +47,10 @@ module.exports = function(RED) {
|
|||||||
this.extend = n.extend || "false";
|
this.extend = n.extend || "false";
|
||||||
this.units = n.units || "ms";
|
this.units = n.units || "ms";
|
||||||
this.reset = n.reset || '';
|
this.reset = n.reset || '';
|
||||||
this.duration = n.duration || 250;
|
this.duration = parseInt(n.duration);
|
||||||
|
if (isNaN(this.duration)) {
|
||||||
|
this.duration = 250;
|
||||||
|
}
|
||||||
if (this.duration < 0) {
|
if (this.duration < 0) {
|
||||||
this.loop = true;
|
this.loop = true;
|
||||||
this.duration = this.duration * -1;
|
this.duration = this.duration * -1;
|
||||||
|
@ -47,7 +47,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to set delay in seconds", function(done) {
|
it("should be able to set delay in seconds", function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", units:"s", duration:1, "wires":[[]]}];
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", units:"s", duration:"1", "wires":[[]]}];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
n1.should.have.property('duration', 1000);
|
n1.should.have.property('duration', 1000);
|
||||||
@ -56,7 +56,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to set delay in minutes", function(done) {
|
it("should be able to set delay in minutes", function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", units:"min", duration:1, "wires":[[]]}];
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", units:"min", duration:"1", "wires":[[]]}];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
n1.should.have.property('duration', 60000);
|
n1.should.have.property('duration', 60000);
|
||||||
@ -65,7 +65,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to set delay in hours", function(done) {
|
it("should be able to set delay in hours", function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", units:"hr", duration:1, "wires":[[]]}];
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", units:"hr", duration:"1", "wires":[[]]}];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
n1.should.have.property('duration', 3600000);
|
n1.should.have.property('duration', 3600000);
|
||||||
@ -74,7 +74,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should output 1 then 0 when triggered (default)', function(done) {
|
it('should output 1 then 0 when triggered (default)', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", duration:20, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", duration:"20", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -95,7 +95,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should ignore any other inputs while triggered if extend is false', function(done) {
|
it('should ignore any other inputs while triggered if extend is false', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", duration:50,wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", duration:"50",wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -137,7 +137,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle true and false as strings and delay of 0', function(done) {
|
it('should handle true and false as strings and delay of 0', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1:"true",op1type:"val",op2:"false",op2type:"val",duration:30, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1:"true",op1type:"val",op2:"false",op2type:"val",duration:"30", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -162,7 +162,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to not output anything on first trigger', function(done) {
|
it('should be able to not output anything on first trigger', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1type:"nul", op1:"true",op2:"false",op2type:"val",duration:30, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1type:"nul", op1:"true",op2:"false",op2type:"val",duration:"30", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -180,7 +180,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to not output anything on second edge', function(done) {
|
it('should be able to not output anything on second edge', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op2type:"nul", op1:"true",op1type:"val", op2:"false", duration:30, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op2type:"nul", op1:"true",op1type:"val", op2:"false", duration:"30", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -199,7 +199,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to extend the delay', function(done) {
|
it('should be able to extend the delay', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"pay", op1:"false", op2:"true", duration:100, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"pay", op1:"false", op2:"true", duration:"100", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -226,7 +226,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to extend the delay (but with no 2nd output)', function(done) {
|
it('should be able to extend the delay (but with no 2nd output)', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"pay", op2type:"nul", op1:"false", op2:"true", duration:50, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"pay", op2type:"nul", op1:"false", op2:"true", duration:"50", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -256,7 +256,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to extend the delay and output the 2nd payload', function(done) {
|
it('should be able to extend the delay and output the 2nd payload', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"nul", op2type:"payl", op1:"false", op2:"true", duration:50, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"nul", op2type:"payl", op1:"false", op2:"true", duration:"50", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -285,7 +285,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able output the 2nd payload', function(done) {
|
it('should be able output the 2nd payload', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"false", op1type:"nul", op2type:"payl", op1:"false", op2:"true", duration:50, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"false", op1type:"nul", op2type:"payl", op1:"false", op2:"true", duration:"50", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -314,7 +314,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to apply mustache templates to payloads', function(done) {
|
it('should be able to apply mustache templates to payloads', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1type:"val", op2type:"val", op1:"{{payload}}", op2:"{{topic}}", duration:50, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1type:"val", op2type:"val", op1:"{{payload}}", op2:"{{topic}}", duration:"50", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -335,7 +335,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle string null as null', function(done) {
|
it('should handle string null as null', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1type:"val", op2type:"pay", op1:"null", op2:"null", duration:40, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", op1type:"val", op2type:"pay", op1:"null", op2:"null", duration:"40", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -356,7 +356,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to set infinite timeout, and clear timeout', function(done) {
|
it('should be able to set infinite timeout, and clear timeout', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", duration:0, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", duration:"0", extend: false, wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -368,6 +368,9 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
if (c === 2) { done(); }
|
if (c === 2) { done(); }
|
||||||
|
else {
|
||||||
|
done(new Error("Too many messages received"));
|
||||||
|
}
|
||||||
},20);
|
},20);
|
||||||
n1.emit("input", {payload:null}); // trigger
|
n1.emit("input", {payload:null}); // trigger
|
||||||
n1.emit("input", {payload:null}); // blocked
|
n1.emit("input", {payload:null}); // blocked
|
||||||
@ -378,7 +381,7 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to set infinite timeout, and clear timeout by message', function(done) {
|
it('should be able to set infinite timeout, and clear timeout by message', function(done) {
|
||||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", reset:"boo", duration:0, wires:[["n2"]] },
|
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", reset:"boo", duration:"0", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"} ];
|
{id:"n2", type:"helper"} ];
|
||||||
helper.load(triggerNode, flow, function() {
|
helper.load(triggerNode, flow, function() {
|
||||||
var n1 = helper.getNode("n1");
|
var n1 = helper.getNode("n1");
|
||||||
@ -390,6 +393,9 @@ describe('trigger node', function() {
|
|||||||
});
|
});
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
if (c === 2) { done(); }
|
if (c === 2) { done(); }
|
||||||
|
else {
|
||||||
|
done(new Error("Too many messages received"));
|
||||||
|
}
|
||||||
},20);
|
},20);
|
||||||
n1.emit("input", {payload:null}); // trigger
|
n1.emit("input", {payload:null}); // trigger
|
||||||
n1.emit("input", {payload:null}); // blocked
|
n1.emit("input", {payload:null}); // blocked
|
||||||
|
Loading…
Reference in New Issue
Block a user