Intial Commit
This commit is contained in:
58
nodered/rootfs/data/node_modules/node-red-node-tail/28-tail.html
generated
vendored
Normal file
58
nodered/rootfs/data/node_modules/node-red-node-tail/28-tail.html
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<script type="text/x-red" data-template-name="tail">
|
||||
<div class="form-row">
|
||||
<label for="node-input-filename"><i class="fa fa-file"></i> <span data-i18n="tail.label.filename"></span></label>
|
||||
<input id="node-input-filename" type="text">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-filetype"><i class="fa fa-file-text-o"></i> <span data-i18n="tail.label.type"></span></label>
|
||||
<select type="text" id="node-input-filetype">
|
||||
<option value="text" data-i18n="tail.action.text"></option>
|
||||
<option value="binary" data-i18n="tail.action.binary"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row" id="node-tail-split">
|
||||
<!-- <label> </label>
|
||||
<input type="checkbox" id="node-input-split" placeholder="Name" style="display: inline-block; width: auto; vertical-align: top;">
|
||||
<label for="node-input-split" style="width: 70%;"><span data-i18n="tail.label.splitlines"></span></label> -->
|
||||
<label for="node-input-split"><i class="fa fa-tag"></i> <span data-i18n="tail.label.splitlines"></span></label>
|
||||
<input type="text" id="node-input-split" data-i18n="[placeholder]tail.label.regex">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="tail.label.name"></span></label>
|
||||
<input type="text" id="node-input-name" data-i18n="[placeholder]tail.label.name">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('tail',{
|
||||
category: 'storage-input',
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
filetype: {value:"text"},
|
||||
split: {value:"[\\r]{0,1}\\n"},
|
||||
filename: {value:""},
|
||||
inputs: {value:0}
|
||||
},
|
||||
color:"BurlyWood",
|
||||
inputs:0,
|
||||
outputs:1,
|
||||
icon: "file.png",
|
||||
label: function() {
|
||||
return this.name||this.filename||this._("tail.tail");
|
||||
},
|
||||
labelStyle: function() {
|
||||
return this.name?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
$("#node-input-filetype").on("change",function() {
|
||||
if (this.value === "text") { $("#node-tail-split").show(); }
|
||||
else { $("#node-tail-split").hide(); }
|
||||
});
|
||||
},
|
||||
oneditsave: function() {
|
||||
var that = this;
|
||||
if ($("#node-input-filename").val()==="") { that.inputs = 1; }
|
||||
else { that.inputs = 0; }
|
||||
}
|
||||
});
|
||||
</script>
|
||||
80
nodered/rootfs/data/node_modules/node-red-node-tail/28-tail.js
generated
vendored
Normal file
80
nodered/rootfs/data/node_modules/node-red-node-tail/28-tail.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
module.exports = function(RED) {
|
||||
"use strict";
|
||||
var fs = require('fs');
|
||||
var Tail = require('tail').Tail;
|
||||
|
||||
function TailNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
|
||||
this.filename = n.filename || "";
|
||||
this.filetype = n.filetype || "text";
|
||||
this.split = new RegExp(n.split.replace(/\\r/g,'\r').replace(/\\n/g,'\n').replace(/\\t/g,'\t') || "[\r]{0,1}\n");
|
||||
var node = this;
|
||||
|
||||
var fileTail = function() {
|
||||
if (fs.existsSync(node.filename)) {
|
||||
if (node.filetype === "text") {
|
||||
node.tail = new Tail(node.filename,{separator:node.split, flushAtEOF:true});
|
||||
}
|
||||
else {
|
||||
node.tail = new Tail(node.filename,{separator:null, flushAtEOF:true, encoding:"binary"});
|
||||
}
|
||||
|
||||
node.tail.on("line", function(data) {
|
||||
if (data.length > 0) {
|
||||
var msg = { topic:node.filename };
|
||||
if (node.filetype === "text") {
|
||||
msg.payload = data.toString();
|
||||
node.send(msg);
|
||||
}
|
||||
else {
|
||||
msg.payload = Buffer.from(data,"binary");
|
||||
node.send(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
node.tail.on("error", function(err) {
|
||||
node.status({ fill: "red",shape:"ring", text: "node-red:common.status.error" });
|
||||
node.error(err.toString());
|
||||
});
|
||||
}
|
||||
else {
|
||||
node.tout = setTimeout(function() { fileTail(); },10000);
|
||||
node.warn(RED._("tail.errors.filenotfound") + ": "+node.filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.filename !== "") {
|
||||
node.status({});
|
||||
fileTail();
|
||||
} else {
|
||||
node.status({ fill: "grey", text: "tail.state.stopped" });
|
||||
node.on('input', function (msg) {
|
||||
if (!msg.hasOwnProperty("filename")) {
|
||||
node.error(RED._("tail.state.nofilename"));
|
||||
} else if (msg.filename === "") {
|
||||
node.filename = "";
|
||||
if (node.tail) { node.tail.unwatch(); }
|
||||
if (node.tout) { clearTimeout(node.tout); }
|
||||
node.status({ fill: "grey", text: "tail.state.stopped" });
|
||||
} else {
|
||||
node.filename = msg.filename;
|
||||
if (node.tail) { node.tail.unwatch(); }
|
||||
if (!node.tout) { fileTail(); }
|
||||
node.status({ fill: "green", text: node.filename });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
node.on("close", function() {
|
||||
/* istanbul ignore else */
|
||||
if (node.tail) { node.tail.unwatch(); }
|
||||
delete node.tail;
|
||||
if (node.tout) { clearTimeout(node.tout); }
|
||||
});
|
||||
}
|
||||
|
||||
RED.nodes.registerType("tail",TailNode);
|
||||
}
|
||||
14
nodered/rootfs/data/node_modules/node-red-node-tail/LICENSE
generated
vendored
Normal file
14
nodered/rootfs/data/node_modules/node-red-node-tail/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
Copyright 2016 JS Foundation and other contributors, https://js.foundation/
|
||||
Copyright 2013-2016 IBM Corp.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
17
nodered/rootfs/data/node_modules/node-red-node-tail/README.md
generated
vendored
Normal file
17
nodered/rootfs/data/node_modules/node-red-node-tail/README.md
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
node-red-node-tail
|
||||
==================
|
||||
|
||||
A Node-Red node to tail a file and inject the contents into the flow.
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
Either use the Menu - Manage palette option, or run the following command in your Node-RED user directory - typically `~/.node-red`
|
||||
|
||||
npm install node-red-node-tail
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Allows
|
||||
15
nodered/rootfs/data/node_modules/node-red-node-tail/locales/en-US/28-tail.html
generated
vendored
Normal file
15
nodered/rootfs/data/node_modules/node-red-node-tail/locales/en-US/28-tail.html
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<script type="text/html" data-help-name="tail">
|
||||
<p>Tails (watches for things to be added) to the configured file.</p>
|
||||
<p>Note: On Windows you may need to close the file between writes for any updates to be registered.</p>
|
||||
<h3>Input</h3>
|
||||
<dl class="message-properties">
|
||||
<dt class="optional">filename <span class="property-type">string</span></dt>
|
||||
<dd>If not configured in the node, this optional property sets the name of the file to be tailed.
|
||||
If an empty string <code>""</code> is received, the tailing will stop.</dd>
|
||||
</dl>
|
||||
<h3>Outputs</h3>
|
||||
<ul>
|
||||
<li>Text (UTF-8) files will be returned as strings.</li>
|
||||
<li>Binary files will be returned as Buffer objects.</li>
|
||||
</ul>
|
||||
</script>
|
||||
24
nodered/rootfs/data/node_modules/node-red-node-tail/locales/en-US/28-tail.json
generated
vendored
Normal file
24
nodered/rootfs/data/node_modules/node-red-node-tail/locales/en-US/28-tail.json
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"tail": {
|
||||
"tail": "tail",
|
||||
"label": {
|
||||
"filename": "Filename",
|
||||
"type": "File type",
|
||||
"splitlines": "Split on",
|
||||
"name": "Name",
|
||||
"regex": "split character or regex"
|
||||
},
|
||||
"action": {
|
||||
"text": "Text - returns String",
|
||||
"binary": "Binary - returns Buffer"
|
||||
},
|
||||
"errors": {
|
||||
"windowsnotsupport": "Not currently supported on Windows.",
|
||||
"filenotfound": "File not found"
|
||||
},
|
||||
"state":{
|
||||
"stopped": "stopped",
|
||||
"nofilename":"Missing filename on input"
|
||||
}
|
||||
}
|
||||
}
|
||||
25
nodered/rootfs/data/node_modules/node-red-node-tail/locales/ja/28-tail.html
generated
vendored
Normal file
25
nodered/rootfs/data/node_modules/node-red-node-tail/locales/ja/28-tail.html
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
Copyright JS Foundation and other contributors, http://js.foundation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<script type="text/html" data-help-name="tail">
|
||||
<p>設定したファイルの末尾を出力(追加されたデータを監視)します.</p>
|
||||
<p>注: Windowsでは、追加されたデータを出力するには、書き込みと書き込みの間にファイルを閉じる必要があります。</p>
|
||||
<h3>出力</h3>
|
||||
<ul>
|
||||
<li>(UTF-8形式の)テキストファイルは文字列を返却。</li>
|
||||
<li>バイナルファイルはバッファオブジェクトを返却。</li>
|
||||
</ul>
|
||||
</script>
|
||||
24
nodered/rootfs/data/node_modules/node-red-node-tail/locales/ja/28-tail.json
generated
vendored
Normal file
24
nodered/rootfs/data/node_modules/node-red-node-tail/locales/ja/28-tail.json
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"tail": {
|
||||
"tail": "tail",
|
||||
"label": {
|
||||
"filename": "ファイル名",
|
||||
"type": "ファイル形式",
|
||||
"splitlines": "改行でメッセージを分割",
|
||||
"name": "名前",
|
||||
"regex": "正規表現を使用"
|
||||
},
|
||||
"action": {
|
||||
"text": "文字列",
|
||||
"binary": "バイナリバッファ"
|
||||
},
|
||||
"errors": {
|
||||
"windowsnotsupport": "現在Windows上での動作は対応していません",
|
||||
"filenotfound": "ファイルが見つかりませんでした"
|
||||
},
|
||||
"state":{
|
||||
"stopped": "停止",
|
||||
"nofilename":"ファイル名の指定がありません"
|
||||
}
|
||||
}
|
||||
}
|
||||
17
nodered/rootfs/data/node_modules/node-red-node-tail/locales/zh-CN/28-tail.json
generated
vendored
Normal file
17
nodered/rootfs/data/node_modules/node-red-node-tail/locales/zh-CN/28-tail.json
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"tail": {
|
||||
"tail": "tail",
|
||||
"label": {
|
||||
"filename": "文件名",
|
||||
"type": "文件类型",
|
||||
"splitlines": "以\\n来拆分行?"
|
||||
},
|
||||
"action": {
|
||||
"text": "文本 - 返回字符串",
|
||||
"binary": "二进制 - 返回Buffer"
|
||||
},
|
||||
"errors": {
|
||||
"windowsnotsupport": "Windows目前不支持."
|
||||
}
|
||||
}
|
||||
}
|
||||
53
nodered/rootfs/data/node_modules/node-red-node-tail/package.json
generated
vendored
Normal file
53
nodered/rootfs/data/node_modules/node-red-node-tail/package.json
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"_from": "node-red-node-tail@0.1.1",
|
||||
"_id": "node-red-node-tail@0.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-j1g/VtSCI2tBrBnCD+u8iSo9tH0nvn70k1O1SxkHk3+qx7tHUyOKQc7wNc4rUs9J1PkGngUC3qEDd5cL7Z/klg==",
|
||||
"_location": "/node-red-node-tail",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "node-red-node-tail@0.1.1",
|
||||
"name": "node-red-node-tail",
|
||||
"escapedName": "node-red-node-tail",
|
||||
"rawSpec": "0.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/node-red-node-tail/-/node-red-node-tail-0.1.1.tgz",
|
||||
"_shasum": "eb14c39119d05fb0304a0a2e485911432c745ba3",
|
||||
"_spec": "node-red-node-tail@0.1.1",
|
||||
"_where": "/data",
|
||||
"author": {
|
||||
"name": "Dave Conway-Jones",
|
||||
"email": "ceejay@vnet.ibm.com",
|
||||
"url": "http://nodered.org"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"tail": "^2.0.3"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "A node to tail files for Node-RED",
|
||||
"keywords": [
|
||||
"node-red",
|
||||
"tail"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"name": "node-red-node-tail",
|
||||
"node-red": {
|
||||
"nodes": {
|
||||
"tail": "28-tail.js"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/node-red/node-red-nodes/storage/tail/"
|
||||
},
|
||||
"version": "0.1.1"
|
||||
}
|
||||
Reference in New Issue
Block a user