How does one configure the package.json, and respective js and html files to have multiple nodes defined in one module/package?
I took a crack at it, and I am getting a really, at least to me odd error in the manage palette view. It states the package has 9 nodes, i.e. 3 copies of each of my 3 nodes? No clue why or how that is happening.
All my nodes work, and I see them fine in the editor, I have something definitely wrong in my configuration.
package.json...
{
"name": "node-red-contrib-raspberry-pi-hardware",
"version": "0.0.1",
"description": "",
"main": "pi.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"node-red": {
"nodes": {
"pi-processor": "pi.js",
"pi-configuration": "pi.js",
"pi-frequency": "pi.js"
}
}
}
pi.js...
module.exports = function(RED) {
function PiConfigurationNode(config) {
RED.nodes.createNode(this,config);
var node = this;
node.on('input', function(msg) {
msg.payload = 'pi-configuration node under construction';
node.send(msg);
});
}
RED.nodes.registerType("pi-configuration",PiConfigurationNode);
function PiFrequencyNode(config) {
RED.nodes.createNode(this,config);
var node = this;
node.on('input', function(msg) {
msg.payload = 'pi-frequency node under construction';
node.send(msg);
});
}
RED.nodes.registerType("pi-frequency",PiFrequencyNode);
function PiProcessorNode(config) {
RED.nodes.createNode(this,config);
var node = this;
node.on('input', function(msg) {
msg.payload = 'pi-processor node under construction';
node.send(msg);
});
}
RED.nodes.registerType("pi-processor",PiProcessorNode);
}
pi.html...
<script type="text/javascript">
RED.nodes.registerType('pi-configuration',{
category: 'function',
color: '#a6bbcf',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
icon: "file.png",
label: function() {
return this.name||"pi-configuration";
}
});
</script>
<script type="text/html" data-template-name="pi-configuration">
<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>
<script type="text/html" data-help-name="pi-configuration">
<p>A simple node that provides visibility to the raspberry pi start configuration</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('pi-frequency',{
category: 'function',
color: '#a6bbcf',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
icon: "file.png",
label: function() {
return this.name||"pi-frequency";
}
});
</script>
<script type="text/html" data-template-name="pi-frequency">
<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>
<script type="text/html" data-help-name="pi-frequency">
<p>A simple node that provides visibility to the raspberry pi processor frequency state</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('pi-processor',{
category: 'function',
color: '#a6bbcf',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
icon: "file.png",
label: function() {
return this.name||"pi-processor";
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('pi-processor',{
category: 'function',
color: '#a6bbcf',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
icon: "file.png",
label: function() {
return this.name||"pi-processor";
}
});
</script>
<script type="text/html" data-template-name="pi-processor">
<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>
<script type="text/html" data-help-name="pi-processor">
<p>A simple node that provides visibility to the raspberry pi processor information</p>
</script>
Oh, the node code is in a single js file because the nodes will have common requirements and functions. I know there is some discussion on split things out to multiple js files, but for this question, can we limit the discussion to how to do things correct in a single js file for now, thanks.
And... how does one define a section in the node palette? I notice that some packages place nodes under function section, some have their own, I guess, custom sections, if you will?