mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Change inject node to use tick boxes for days of week instead of select.
This commit is contained in:
parent
5e5a220f68
commit
84e6417877
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
Copyright 2013 IBM Corp.
|
||||
Copyright 2013,2015 IBM Corp.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -17,26 +17,26 @@
|
||||
<script type="text/x-red" data-template-name="inject">
|
||||
<div class="form-row node-input-payload">
|
||||
<label for="node-input-payloadType"><i class="fa fa-envelope"></i> Payload</label>
|
||||
<select id="node-input-payloadType" style="width:125px !important">
|
||||
<select id="node-input-payloadType" style="width:73%">
|
||||
<option value="date">timestamp</option>
|
||||
<option value="none">blank</option>
|
||||
<option value="string">string</option>
|
||||
<option value="none">blank</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="node-input-row-payload">
|
||||
<label for="node-input-payload"></label>
|
||||
<input type="text" id="node-input-payload" placeholder="payload">
|
||||
<input type="text" id="node-input-payload" placeholder="payload" style="width:70%">
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
|
||||
<input type="text" id="node-input-topic" placeholder="topic">
|
||||
<input type="text" id="node-input-topic" placeholder="topic" style="width: 70%x">
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for=""><i class="fa fa-repeat"></i> Repeat</label>
|
||||
<select id="inject-time-type-select" style="width: 288px"><option value="none">none</option><option value="interval">interval</option><option value="interval-time">interval between times</option><option value="time">at a specific time</option></select>
|
||||
<select id="inject-time-type-select" style="width: 73%"><option value="none">none</option><option value="interval">interval</option><option value="interval-time">interval between times</option><option value="time">at a specific time</option></select>
|
||||
<input type="hidden" id="node-input-repeat" placeholder="payload">
|
||||
<input type="hidden" id="node-input-crontab" placeholder="payload">
|
||||
</div>
|
||||
@ -64,12 +64,35 @@
|
||||
</select> minutes<br/>
|
||||
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/>
|
||||
on <select id="inject-time-interval-time-days" class="inject-time-days"></select>
|
||||
<!-- on <select id="inject-time-interval-time-days" class="inject-time-days"></select> -->
|
||||
<div id="inject-time-interval-time-days" class="inject-time-days">
|
||||
<table style="width:100% !important"><tr><td valign="top">on </td><td valign="top">
|
||||
<label><input type='checkbox' class="cb1" value='1'/> Monday</label>
|
||||
<label><input type='checkbox' class="cb1" value='2'/> Tuesday</label>
|
||||
<label><input type='checkbox' class="cb1" value='3'/> Wednesday</label>
|
||||
<label><input type='checkbox' class="cb1" value='4'/> Thursday</label>
|
||||
<label><input type='checkbox' class="cb1" value='5'/> Friday</label>
|
||||
<label><input type='checkbox' class="cb1" value='6'/> Saturday</label>
|
||||
<label><input type='checkbox' class="cb1" value='0'/> Sunday</label>
|
||||
<!-- <div><input type='checkbox' id="cb1selectall" value='*'/> Everyday</div> -->
|
||||
</td></tr></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row inject-time-row hidden" id="inject-time-row-time">
|
||||
at <input id="inject-time-time" value="12:00"></input><br/>
|
||||
on <select id="inject-time-time-days" class="inject-time-days"></select>
|
||||
<!-- on <select id="inject-time-time-days" class="inject-time-days"></select> -->
|
||||
<div id="inject-time-time-days" class="inject-time-days">
|
||||
<table style="width:100% !important"><tr><td valign="top">on </td><td valign="top">
|
||||
<label><input type='checkbox' class="cb2" value='1'/> Monday</label>
|
||||
<label><input type='checkbox' class="cb2" value='2'/> Tuesday</label>
|
||||
<label><input type='checkbox' class="cb2" value='3'/> Wednesday</label>
|
||||
<label><input type='checkbox' class="cb2" value='4'/> Thursday</label>
|
||||
<label><input type='checkbox' class="cb2" value='5'/> Friday</label>
|
||||
<label><input type='checkbox' class="cb2" value='6'/> Saturday</label>
|
||||
<label><input type='checkbox' class="cb2" value='0'/> Sunday</label>
|
||||
</td></tr></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="node-once">
|
||||
@ -92,9 +115,9 @@
|
||||
.inject-time-row select {
|
||||
margin: 3px 0;
|
||||
}
|
||||
.inject-time-days {
|
||||
width: 262px;
|
||||
}
|
||||
//.inject-time-days {
|
||||
// width: 262px;
|
||||
//}
|
||||
.inject-time-times {
|
||||
width: 90px;
|
||||
}
|
||||
@ -168,24 +191,35 @@
|
||||
}
|
||||
});
|
||||
|
||||
var days = [
|
||||
{v:"*",t:"every day"},
|
||||
{v:"1-5",t:"Mondays to Fridays"},
|
||||
{v:"0,6",t:"Saturdays and Sundays"},
|
||||
{v:"1",t:"Mondays"},
|
||||
{v:"2",t:"Tuesdays"},
|
||||
{v:"3",t:"Wednesdays"},
|
||||
{v:"4",t:"Thursdays"},
|
||||
{v:"5",t:"Fridays"},
|
||||
{v:"6",t:"Saturdays"},
|
||||
{v:"0",t:"Sundays"}
|
||||
];
|
||||
//$("#cb1selectall").click(function () {
|
||||
// $('.cb1').attr('checked', this.checked);
|
||||
//});
|
||||
//$(".cb1").click(function(){
|
||||
// if($(".cb1:checked").length == 7) {
|
||||
// $("#cb1selectall").attr("checked", "checked");
|
||||
// } else {
|
||||
// $("#cb1selectall").removeAttr("checked");
|
||||
// }
|
||||
//});
|
||||
|
||||
$(".inject-time-days").each(function() {
|
||||
for (var d in days) {
|
||||
$(this).append($("<option></option>").val(days[d].v).text(days[d].t));
|
||||
}
|
||||
});
|
||||
//var days = [
|
||||
// {v:"*",t:"every day"},
|
||||
// {v:"1-5",t:"Mondays to Fridays"},
|
||||
// {v:"0,6",t:"Saturdays and Sundays"},
|
||||
// {v:"1",t:"Mondays"},
|
||||
// {v:"2",t:"Tuesdays"},
|
||||
// {v:"3",t:"Wednesdays"},
|
||||
// {v:"4",t:"Thursdays"},
|
||||
// {v:"5",t:"Fridays"},
|
||||
// {v:"6",t:"Saturdays"},
|
||||
// {v:"0",t:"Sundays"}
|
||||
//];
|
||||
|
||||
//$(".inject-time-days").each(function() {
|
||||
// for (var d in days) {
|
||||
// $(this).append($("<option></option>").val(days[d].v).text(days[d].t));
|
||||
// }
|
||||
//});
|
||||
|
||||
$(".inject-time-times").each(function() {
|
||||
for (var i=0;i<24;i++) {
|
||||
@ -254,7 +288,13 @@
|
||||
var time = cronparts[1]+":"+cronparts[0];
|
||||
$("#inject-time-time").val(time);
|
||||
$("#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);
|
||||
if (days == "*") { days = "1,2,3,4,5,6,0"; }
|
||||
var daya = days.split(",");
|
||||
for(var i = 0; i < daya.length; i++) {
|
||||
$("#inject-time-time-days [value=" + daya[i] + "]").attr("checked", "checked");
|
||||
}
|
||||
|
||||
}
|
||||
//else if (cronparts[0] == "0") {
|
||||
// // interval - hours
|
||||
@ -279,7 +319,13 @@
|
||||
var minutes = cronparts[0].slice(2);
|
||||
if (minutes === "") { minutes = "0"; }
|
||||
$("#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);
|
||||
if (days == "*") { days = "1,2,3,4,5,6,0"; }
|
||||
var daya = days.split(",");
|
||||
for(var i = 0; i < daya.length; i++) {
|
||||
$("#inject-time-interval-time-days [value=" + daya[i] + "]").attr("checked", "checked");
|
||||
}
|
||||
|
||||
var time = cronparts[1];
|
||||
var timeparts = time.split(",");
|
||||
var start;
|
||||
@ -354,7 +400,7 @@
|
||||
} else if (type == "interval") {
|
||||
var count = $("#inject-time-interval-count").val();
|
||||
var units = $("#inject-time-interval-units option:selected").val();
|
||||
var days = $("#inject-time-interval-days option:selected").val();
|
||||
//var days = $("#inject-time-interval-days option:selected").val();
|
||||
if (units == "s") {
|
||||
repeat = count;
|
||||
} else {
|
||||
@ -370,8 +416,13 @@
|
||||
var count = $("#inject-time-interval-time-units").val();
|
||||
var startTime = Number($("#inject-time-interval-time-start 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 timerange = "*";
|
||||
//var days = $("#inject-time-interval-time-days option:selected").val();
|
||||
var days = $('.cb1:checked').map(function(_, el) {
|
||||
return $(el).val()
|
||||
}).get();
|
||||
if (days.length == 7) { days="*"; }
|
||||
else { days = days.join(","); }
|
||||
var timerange = "";
|
||||
if (startTime == endTime) {
|
||||
//TODO: invalid
|
||||
repeat = "";
|
||||
@ -406,7 +457,12 @@
|
||||
}
|
||||
} else if (type == "time") {
|
||||
var time = $("#inject-time-time").val();
|
||||
var days = $("#inject-time-time-days option:selected").val();
|
||||
//var days = $("#inject-time-time-days option:selected").val();
|
||||
var days = $('.cb2:checked').map(function(_, el) {
|
||||
return $(el).val()
|
||||
}).get();
|
||||
if (days.length == 7) { days="*"; }
|
||||
else { days = days.join(","); }
|
||||
var parts = time.split(":");
|
||||
repeat = "";
|
||||
crontab = parts[1]+" "+parts[0]+" * * "+days;
|
||||
|
@ -15,6 +15,7 @@
|
||||
**/
|
||||
|
||||
module.exports = function(RED) {
|
||||
"use strict";
|
||||
var cron = require("cron");
|
||||
|
||||
function InjectNode(n) {
|
||||
@ -54,7 +55,7 @@ module.exports = function(RED) {
|
||||
|
||||
this.on("input",function(msg) {
|
||||
var msg = {topic:this.topic};
|
||||
if ( (this.payloadType == null && this.payload == "") || this.payloadType == "date") {
|
||||
if ( (this.payloadType == null && this.payload === "") || this.payloadType === "date") {
|
||||
msg.payload = Date.now();
|
||||
} else if (this.payloadType == null || this.payloadType === "string") {
|
||||
msg.payload = this.payload;
|
||||
|
@ -340,8 +340,8 @@ li.open #btn-sidemenu {
|
||||
height: 30px;
|
||||
box-sizing:border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
|
||||
}
|
||||
|
||||
#palette-search input:focus {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
@ -760,6 +760,16 @@ g.link_unknown path.link_line {
|
||||
.form-row input {
|
||||
width:70%;
|
||||
}
|
||||
.form-row label .cb1 {
|
||||
display: inline !important;
|
||||
width: auto !important;
|
||||
vertical-align: top !important;
|
||||
}
|
||||
.form-row label .cb2 {
|
||||
display: inline !important;
|
||||
width: auto !important;
|
||||
vertical-align: top !important;
|
||||
}
|
||||
|
||||
input.input-append-left {
|
||||
border-top-right-radius: 0px;
|
||||
@ -1241,5 +1251,3 @@ i.spinner {
|
||||
#header ul#btn-deploy-options-submenu li a > i.fa {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user