UNPKG

prisme-flow

Version:

prisme platform flow engine

177 lines (162 loc) 7.3 kB
<!-- 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"> RED.nodes.registerType('fs-file-lister',{ category: 'storage', // the palette category color: '#E6E0F8', defaults: { // defines the editable properties of the node name: {value:''}, // along with default values. start: {value:'/'}, // Start folder ext: {value:'.json'},// Extension (optional) sub: {value:false}, // Check sub-folders too? path: {value:true}, // Output full path? single: {value:false} // Out a single array instead of multiple messages }, 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: 'file.png', // saved in icons/myicon.png label: function() { // sets the default label contents return this.name||this.topic||'File Lister'; }, 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-lister"> <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-row"> <label for="node-input-ext"><i class="fa fa-arrow-left"></i> Extension</label> <input type="text" id="node-input-ext" style="width: 53%;" placeholder=".json"> </div> <div class="form-row" id="node-reg-row"> <label>&nbsp;</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>&nbsp;</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" id="node-reg-row"> <label>&nbsp;</label> <input type="checkbox" id="node-input-sub" style="display: inline-block; width: auto; vertical-align: top;"> <label for="node-input-sub" style="width: 70%;">Search sub-folders? (Not yet working)</label> </div> <!-- By convention, most nodes have a 'name' property. The following div --> <!-- provides the necessary field. 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-lister"> <h2> Filing System Utilities: File Lister </h2> <p><b>**WARNING** This node *will* get replaced. The new node will have the same name but different parameters. This needs a different library & will be in the live release.</b></p> <h3>To Do</h3> <ul> <li> Implement the subfolder processing </li> <li> Replace raw fs module with a better module that can recurse and use wildcards (globbing) </li> <li> Allow inputs from recieved msg </li> </ul> <h3>What does this node do?</h3> <p> This node searches a folder (and optionally sub-folders) for files. optionally may filter on a specific file extension. </p> <p> The folder and files come from the computer and operating dystem that is running Node-Red. </p> <h3>Outputs</h3> <p> By default, returns one message for each file found. The filename will be in the msg.payload. unless the <i>Output Single Message</i> option is chosen. </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> <h3>Inputs</h3> <ul> <li> <b>Start Folder</b> 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. </li> <li> <b>Extension</b> String that will be matched to the <i>end</i> of any filenames found. Filenames <i>not</i> matching will be filtered out. Defaults to '.json', leave blank to get all files. </li> <li> <b>Search sub-folders</b> Checkbox. If selected, sub-folders under the start folder will also 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> </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>&nbsp;</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> -->