diff --git a/nodes/core/core/20-inject.html b/nodes/core/core/20-inject.html index ac653b3f9..4090fdbbd 100644 --- a/nodes/core/core/20-inject.html +++ b/nodes/core/core/20-inject.html @@ -28,9 +28,9 @@
By default, the node is triggered manually by clicking on its button within the editor. It can also be set to inject at regular intervals or according to a schedule.
It can also be configured to inject once each time the flows are started.
+The maximum Interval that can be specified is about 596 hours / 24 days. However if you are looking at intervals +greater than one day you should consider using a scheduler node that can cope with power outages and restarts.
Note: The "Interval between times" and "at a specific time" options use the standard cron system. This means that 20 minutes will be at the next hour, 20 minutes past and 40 minutes past - not in 20 minutes time. If you want every 20 minutes from now - use the "interval" option.
@@ -182,7 +187,7 @@ If you want every 20 minutes from now - use the "interval" option. topic: {value:""}, payload: {value:"", validate: RED.validators.typedInput("payloadType")}, payloadType: {value:"date"}, - repeat: {value:"", validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0))) }}, + repeat: {value:"", validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0) && (v <= 2147483))) }}, crontab: {value:""}, once: {value:false}, onceDelay: {value:0.1} @@ -275,6 +280,10 @@ If you want every 20 minutes from now - use the "interval" option. } }); + $("#node-input-once").change(function() { + $("#node-input-onceDelay").attr('disabled', !$("#node-input-once").prop('checked')); + }) + $(".inject-time-times").each(function() { for (var i=0; i<24; i++) { var l = (i<10?"0":"")+i+":00"; @@ -303,35 +312,6 @@ If you want every 20 minutes from now - use the "interval" option. min:1 }); - $.widget( "ui.injecttimespinner", $.ui.spinner, { - options: { - // seconds - step: 60 * 1000, - // hours - page: 60 - }, - _parse: function( value ) { - if ( typeof value === "string" ) { - // already a timestamp - if ( Number( value ) == value ) { - return Number( value ); - } - var p = value.split(":"); - var offset = new Date().getTimezoneOffset(); - return ((Number(p[0])*60)+Number(p[1])+offset)*60*1000; - } - return value; - }, - _format: function( value ) { - var d = new Date(value); - var h = d.getHours(); - var m = d.getMinutes(); - return ((h < 10)?"0":"")+h+":"+((m < 10)?"0":"")+m; - } - }); - - $("#inject-time-time").injecttimespinner(); - var repeattype = "none"; if (this.repeat != "" && this.repeat != 0) { repeattype = "interval"; @@ -448,7 +428,7 @@ If you want every 20 minutes from now - use the "interval" option. var count = $("#inject-time-interval-time-units").val(); var startTime = Number($("#inject-time-interval-time-start").val()); var endTime = Number($("#inject-time-interval-time-end").val()); - var days = $('#inject-time-interval-time-days input[type=checkbox]:checked').map(function(_, el) { + var days = $('#inject-time-interval-time-days input[type=checkbox]:checked').map(function(_, el) { return $(el).val() }).get(); if (days.length == 0) { @@ -501,8 +481,13 @@ If you want every 20 minutes from now - use the "interval" option. days = days.join(","); } var parts = time.split(":"); - repeat = ""; - crontab = parts[1]+" "+parts[0]+" * * "+days; + if (parts.length === 2) { + repeat = ""; + parts[1] = ("00" + (parseInt(parts[1]) % 60)).substr(-2); + parts[0] = ("00" + (parseInt(parts[0]) % 24)).substr(-2); + crontab = parts[1]+" "+parts[0]+" * * "+days; + } + else { crontab = ""; } } } diff --git a/nodes/core/core/20-inject.js b/nodes/core/core/20-inject.js index a5099769b..9e6eb62a8 100644 --- a/nodes/core/core/20-inject.js +++ b/nodes/core/core/20-inject.js @@ -27,9 +27,14 @@ module.exports = function(RED) { this.crontab = n.crontab; this.once = n.once; this.onceDelay = (n.onceDelay || 0.1) * 1000; - var node = this; this.interval_id = null; this.cronjob = null; + var node = this; + + if (node.repeat > 2147483) { + node.error(RED._("inject.errors.toolong", this)); + delete node.repeat; + } node.repeaterSetup = function () { if (this.repeat && !isNaN(this.repeat) && this.repeat > 0) { diff --git a/nodes/core/locales/en-US/messages.json b/nodes/core/locales/en-US/messages.json index dcf639f59..e373d8cf5 100644 --- a/nodes/core/locales/en-US/messages.json +++ b/nodes/core/locales/en-US/messages.json @@ -62,10 +62,11 @@ "on": "on", "onstart": "Inject once after", "onceDelay": "seconds, then", - "tip": "Note: \"interval between times\" and \"at a specific time\" will use cron.