prisme-flow
Version:
prisme platform flow engine
195 lines (178 loc) • 7.93 kB
HTML
<!--
Created by prisme.io on 09/06/2017.
@author <a href="mailto:hello@prisme.io">savane vamara</a> (prisme.io)
-->
<!-- This creates and configures the onscreen elements of the node -->
<script type="text/javascript">
// Module name must match this nodes html file
// Use the same name in the data-template-name entries
var moduleName = 'fs-file-copier'
RED.nodes.registerType(moduleName,{
category: 'storage', // the palette category
color: '#E6E0F8',
defaults: { // defines the editable properties of the node
name: {value:''}, // along with default values.
start: {value:'/', required:true}, // Start folder
pattern: {value:'*'}, // Extension (optional)
path: {value:true}, // Output full path?
single: {value:false}, // Output a single array instead of multiple messages
depth: {value:0, validate:RED.validators.number()}, // Max recursion depth
stat: {value:false}, // If true, return file meta-data
},
inputs:1, // set the number of inputs - only 0 or 1
outputs:1, // set the number of outputs - 0 to n
// set the icon (held in icons dir below where you save the node)
icon: 'fileinject.png', // saved in icons/myicon.png
label: function() { // sets the default label contents
return this.name||this.topic||'File Copier';
},
labelStyle: function() { // sets the class to apply to the label
return this.name ? 'node_label_italic' : '';
}
})
</script>
<!-- First, the content of the edit dialog is defined. -->
<!-- data-template-name identifies the node type this is for -->
<script type="text/x-red" data-template-name="fs-file-copier">
<div class="form-row" title="Start (root) folder for search">
<label for="node-input-start"><i class="fa fa-folder"></i> Start Folder</label>
<input type="text" id="node-input-start" placeholder="Start Folder">
</div>
<div class="form-row">
<label for="node-input-pattern"><i class="fa fa-file-code-o"></i> File Pattern</label>
<input type="text" id="node-input-pattern" placeholder="*">
</div>
<div class="form-row" id="node-reg-row">
<label> </label>
<input type="checkbox" id="node-input-path" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-path" style="width: 70%;">Include full path in output?</label>
</div>
<div class="form-row" id="node-reg-row">
<label> </label>
<input type="checkbox" id="node-input-single" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-single" style="width: 70%;">Output single message (array)?</label>
</div>
<div class="form-row" title="Set to >0 to search sub-folders.">
<label for="node-input-depth"><i class="fa fa-level-down"></i> Max. search depth</label>
<input type="text" id="node-input-depth" placeholder="0 = no recursion">
</div>
<div class="form-row" id="node-reg-row">
<label> </label>
<input type="checkbox" id="node-input-stat" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-stat" style="width: 70%;">Return file details?</label>
</div>
<!-- Most nodes have a 'name' property. Should always be the last option -->
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<!-- Next, some simple help text is provided for the node. -->
<!-- The first <p> is used as the pop-up tool tip when hovering over pallette -->
<script type="text/x-red" data-help-name="fs-file-copier">
<h2>
Filing System Utilities: File Copier
</h2>
<h3>To Do</h3>
<ul>
<li>
Allow other overrides to be passed in.
</li>
</ul>
<h3>What does this node do?</h3>
<p>
This node copies a file or set of files.
</p>
<p>
The folder and files come from the computer and operating system that is
running prisme-flow. AKA, the "host".
</p>
<h3>Side Effects</h3>
<p>
Copied files.
</p>
<h3>Outputs</h3>
<p>
A single message who's payload contains a list of file names copied or
false.
</p>
<p>
If the <i>Output Single Message</i> option is chosen, the msg.payload will
contain an <i>array</i> of filenames.
</p>
<p>
Output filenames will contain the full file path if the <i>Full Path</i>
option is selected.
</p>
<p>
If the "Return file details" option is selected, each file output will be
an object. {"name":[filename], "stat": {"size":[fsize], ...}}
</p>
<h3>Inputs</h3>
<ul>
<li>
<b>Start Folder</b> [start] String containing the start folder location to search
for files. Without a leading '/', will search from the location the node
is installed which is not terribly useful so it is preferred to use
absolute paths. e.g. /home/pi<br />
Windows path names are also accepted. On Windows, you can use either form.
There is no need to escape backslashes.
Max path length is 1024
</li>
<li>
<b>File Pattern</b> [pattern] String that will be matched against the filenames.
Standard "glob" file patterns are allowed. Defaults to '*' which will return all files.
Max length is 1024
</li>
<li>
<b>Search sub-folders</b> Checkbox. If selected, sub-folders under the
start folder will also be searched.
</li>
<li>
<b>Sub-folder Depth</b> Integer. Default 0 only searches the start folder.
Limits the depth of sub-folders that will be searched.
</li>
<li>
<b>Include full path in output</b> Checkbox. If selected (the default),
the output payload will have the folder path prepended to the filename.
</li>
<li>
<b>Single</b> Checkbox. If selected, only one msg will be sent; the
msg.payload will contain an array of filenames.<br />
Otherwise, the default output is a single msg for each file found with
the msg.payload a string containing the filename.
</li>
</ul>
<p>
To override the configured options, pass in a msg with msg.payload like:
<code>{"start":"/my/folder","pattern":"*.json"}</code>
Any missing options will be picked up from the configured node. Only those 2
overrides are currently available.
</p>
</script>
<!-- Each of the following divs creates a field in the edit dialog. -->
<!-- Generally, there should be an input for each property of the node. -->
<!-- The for and id attributes identify the corresponding property -->
<!-- (with the 'node-input-' prefix). -->
<!-- The available icon classes are defined Twitter Bootstrap glyphicons -->
<!-- ** Unused templates for input types...
<div class="form-row">
<select id="node-input-action" style="width:95%; margin-right:5px;">
<option value="replace">Set the value of the message property</option>
<option value="change">Search/replace the value of the message property</option>
<option value="delete">Delete the message property</option>
</div>
</select>
<div class="form-row" id="node-reg-row">
<label> </label>
<input type="checkbox" id="node-input-reg" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-reg" style="width: 70%;">Use regular expressions</label>
</div>
<div class="form-row">
<label for="node-input-start"><i class="fa fa-tasks"></i> Start Folder</label>
<input type="text" id="node-input-start" placeholder="Start Folder">
</div>
<div class="form-tips">
Some info.
</div>
-->