mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add hourly option to Inject Node time interval mode,
Fix a few UI wrinkles when editing.
This commit is contained in:
parent
c4932e3cf9
commit
22329ca106
@ -60,6 +60,7 @@
|
|||||||
<option value="15">15</option>
|
<option value="15">15</option>
|
||||||
<option value="20">20</option>
|
<option value="20">20</option>
|
||||||
<option value="30">30</option>
|
<option value="30">30</option>
|
||||||
|
<option value="0">60</option>
|
||||||
</select> minutes<br/>
|
</select> minutes<br/>
|
||||||
between <select id="inject-time-interval-time-start" class="inject-time-times"></select>
|
between <select id="inject-time-interval-time-start" class="inject-time-times"></select>
|
||||||
and <select id="inject-time-interval-time-end" class="inject-time-times"></select><br/>
|
and <select id="inject-time-interval-time-end" class="inject-time-times"></select><br/>
|
||||||
@ -225,8 +226,6 @@
|
|||||||
|
|
||||||
$("#inject-time-time").injecttimespinner();
|
$("#inject-time-time").injecttimespinner();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var repeattype = "none";
|
var repeattype = "none";
|
||||||
if (this.repeat != "" && this.repeat != 0) {
|
if (this.repeat != "" && this.repeat != 0) {
|
||||||
repeattype = "interval";
|
repeattype = "interval";
|
||||||
@ -248,27 +247,29 @@
|
|||||||
$("#inject-time-time").val(time);
|
$("#inject-time-time").val(time);
|
||||||
$("#inject-time-type-select option").filter(function() {return $(this).val() == "s";}).attr('selected',true);
|
$("#inject-time-type-select option").filter(function() {return $(this).val() == "s";}).attr('selected',true);
|
||||||
$("#inject-time-time-days option").filter(function() {return $(this).val() == days;}).attr('selected',true);
|
$("#inject-time-time-days option").filter(function() {return $(this).val() == days;}).attr('selected',true);
|
||||||
|
}
|
||||||
} else if (cronparts[0] == "0") {
|
//else if (cronparts[0] == "0") {
|
||||||
// interval - hours
|
// // interval - hours
|
||||||
var hours = cronparts[1].slice(2);
|
// var hours = cronparts[1].slice(2);
|
||||||
repeattype = "interval";
|
// repeattype = "interval";
|
||||||
$("#inject-time-interval-days").prop("disabled",false);
|
// $("#inject-time-interval-days").prop("disabled",false);
|
||||||
$("#inject-time-interval-days option").filter(function() {return $(this).val() == days;}).attr('selected',true);
|
// $("#inject-time-interval-days option").filter(function() {return $(this).val() == days;}).attr('selected',true);
|
||||||
$("#inject-time-interval-count").val(hours)
|
// $("#inject-time-interval-count").val(hours)
|
||||||
$("#inject-time-interval-units option").filter(function() {return $(this).val() == "h";}).attr('selected',true);
|
// $("#inject-time-interval-units option").filter(function() {return $(this).val() == "h";}).attr('selected',true);
|
||||||
} else if (cronparts[1] == "*") {
|
//} else if (cronparts[1] == "*") {
|
||||||
// interval - minutes
|
// // interval - minutes
|
||||||
var minutes = cronparts[0].slice(2);
|
// var minutes = cronparts[0].slice(2);
|
||||||
repeattype = "interval";
|
// repeattype = "interval";
|
||||||
$("#inject-time-interval-days").prop("disabled",false);
|
// $("#inject-time-interval-days").prop("disabled",false);
|
||||||
$("#inject-time-interval-days option").filter(function() {return $(this).val() == days;}).attr('selected',true);
|
// $("#inject-time-interval-days option").filter(function() {return $(this).val() == days;}).attr('selected',true);
|
||||||
$("#inject-time-interval-count").val(minutes)
|
// $("#inject-time-interval-count").val(minutes)
|
||||||
$("#inject-time-interval-units option").filter(function() {return $(this).val() == "m";}).attr('selected',true);
|
// $("#inject-time-interval-units option").filter(function() {return $(this).val() == "m";}).attr('selected',true);
|
||||||
} else {
|
//}
|
||||||
|
else {
|
||||||
repeattype = "interval-time";
|
repeattype = "interval-time";
|
||||||
// interval - time period
|
// interval - time period
|
||||||
var minutes = cronparts[0].slice(2);
|
var minutes = cronparts[0].slice(2);
|
||||||
|
if (minutes === "") { minutes = "0"; }
|
||||||
$("#inject-time-interval-time-units").val(minutes);
|
$("#inject-time-interval-time-units").val(minutes);
|
||||||
$("#inject-time-interval-time-days option").filter(function() {return $(this).val() == days;}).attr('selected',true);
|
$("#inject-time-interval-time-days option").filter(function() {return $(this).val() == days;}).attr('selected',true);
|
||||||
var time = cronparts[1];
|
var time = cronparts[1];
|
||||||
@ -279,8 +280,14 @@
|
|||||||
// 0 or 0-10
|
// 0 or 0-10
|
||||||
var hours = timeparts[0].split("-");
|
var hours = timeparts[0].split("-");
|
||||||
if (hours.length == 1) {
|
if (hours.length == 1) {
|
||||||
start = hours[0];
|
if (hours[0] === "") {
|
||||||
end = Number(hours[0])+1;
|
start = "0";
|
||||||
|
end = "0";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
start = hours[0];
|
||||||
|
end = Number(hours[0])+1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
start = hours[0];
|
start = hours[0];
|
||||||
end = (Number(hours[1])+1)%24;
|
end = (Number(hours[1])+1)%24;
|
||||||
@ -356,7 +363,7 @@
|
|||||||
var startTime = Number($("#inject-time-interval-time-start option:selected").val());
|
var startTime = Number($("#inject-time-interval-time-start option:selected").val());
|
||||||
var endTime = Number($("#inject-time-interval-time-end option:selected").val());
|
var endTime = Number($("#inject-time-interval-time-end option:selected").val());
|
||||||
var days = $("#inject-time-interval-time-days option:selected").val();
|
var days = $("#inject-time-interval-time-days option:selected").val();
|
||||||
var timerange = "";
|
var timerange = "*";
|
||||||
if (startTime == endTime) {
|
if (startTime == endTime) {
|
||||||
//TODO: invalid
|
//TODO: invalid
|
||||||
repeat = "";
|
repeat = "";
|
||||||
@ -383,7 +390,12 @@
|
|||||||
timerange = startpart+","+endpart;
|
timerange = startpart+","+endpart;
|
||||||
}
|
}
|
||||||
repeat = "";
|
repeat = "";
|
||||||
crontab = "*/"+count+" "+timerange+" * * "+days;
|
if (count === "0") {
|
||||||
|
crontab = count+" "+timerange+" * * "+days;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
crontab = "*/"+count+" "+timerange+" * * "+days;
|
||||||
|
}
|
||||||
} else if (type == "time") {
|
} else if (type == "time") {
|
||||||
var time = $("#inject-time-time").val();
|
var time = $("#inject-time-time").val();
|
||||||
var days = $("#inject-time-time-days option:selected").val();
|
var days = $("#inject-time-time-days option:selected").val();
|
||||||
@ -399,8 +411,8 @@
|
|||||||
button: {
|
button: {
|
||||||
onclick: function() {
|
onclick: function() {
|
||||||
var label = (this.name||this.payload).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
|
var label = (this.name||this.payload).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
|
||||||
if (this.payloadType === "date") { label = "timestamp"; }
|
if (this.payloadType === "date") { label = "timestamp"; }
|
||||||
if (this.payloadType === "none") { label = "blank"; }
|
if (this.payloadType === "none") { label = "blank"; }
|
||||||
d3.xhr("inject/"+this.id).post(function(err,resp) {
|
d3.xhr("inject/"+this.id).post(function(err,resp) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.status == 404) {
|
if (err.status == 404) {
|
||||||
|
Loading…
Reference in New Issue
Block a user