let tail node accept filename dynamically

This commit is contained in:
Dave Conway-Jones 2019-08-16 08:28:14 +01:00
parent 78972a68ab
commit d1cf309214
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
3 changed files with 6 additions and 12 deletions

View File

@ -48,10 +48,10 @@
filetype: {value:"text"},
split: {value:"[\\r]{0,1}\\n"},
filename: {value:""},
inputs: {value:1}
inputs: {value:0}
},
color:"BurlyWood",
inputs:1,
inputs:0,
outputs:1,
icon: "file.png",
label: function() {
@ -68,11 +68,8 @@
},
oneditsave: function() {
var that = this;
if($("#node-input-filename").val()===""){
that.inputs = 1;
} else {
that.inputs = 0;
}
if ($("#node-input-filename").val()==="") { that.inputs = 1; }
else { that.inputs = 0; }
}
});
</script>

View File

@ -30,7 +30,6 @@ module.exports = function(RED) {
}
else {
msg.payload = Buffer.from(data,"binary");
//msg.payload = data;
node.send(msg);
}
}
@ -55,8 +54,6 @@ module.exports = function(RED) {
node.on('input', function (msg) {
if (!msg.hasOwnProperty("filename")) {
node.error(RED._("tail.state.nofilename"));
}else if (msg.filename === node.filename) {
node.warn(RED._("tail.state.nofilechange"));
} else if (msg.filename === "") {
node.filename = "";
if (node.tail) { node.tail.unwatch(); }
@ -67,7 +64,7 @@ module.exports = function(RED) {
if (node.tail) { node.tail.unwatch(); }
if (!node.tout) { fileTail(); }
node.status({ fill: "green", text: node.filename });
}
}
});
}

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-tail",
"version": "0.0.3",
"version": "0.1.0",
"description": "A node to tail files for Node-RED",
"dependencies": {
"tail": "^2.0.2"