Hi, I am trying to create a custom node and the only item I am struggling with is the config node. I have created the files ' anna.js / anna.html /anna-config.js/anna-config.html and a package.json; I've mentioned the nodes in my package.json under node-red/nodes, referenced the property of my ' remote server' in the input of the anna.html, called the node in the anna.js; and the node is showing in NR under the category I have set, I can see the config node in the pallette, but when I open the node, there is no configuration option given. I am sure I am overlooking something simple, but I can't seem to find it. Any hints are appreciated. Files are below:
anna-config.html
<script type="text/javascript">
RED.nodes.registerType('anna-config',{
category: 'config',
color: '#af3',
defaults: {
host: {value:"",required:true},
ip: {value:"", required: true},
},
credentials:{
{username:"",required: true, type :"text"},
{password:"", required: true, type:"password"},
},
label : function() {
return this.host+":"+this.ip;
}
});
</script>
<script type="text/html" data-template-name="anna-config">
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-host" placeholder="smile">
</div>
<div class="form-row">
<label for="node-config-input-ip"><i class="fa fa-tag"></i> ip adres</label>
<input type="text" id="node-config-input-ip" placeholder="">
</div>
<div class="form-row">
<label for="node-config-input-username"><i class="fa fa-tag"></i> smile</label>
<input type="text" id="node-config-input-username" placeholder="">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-tag"></i> password</label>
<input type="text" id="node-config-input-password" placeholder="">
</div>
</script>
<script type="text/html" data-help-name="anna-config">
<p>A simple node that converts the message payloads into all lower-case characters</p>
</script>
anna-config.js
module.exports = function(RED){
function smile(config) {
RED.nodes.createNode(this,config);
this.host = config.host;
this.ip = config.ip;
}
RED.nodes.registerType("anna-config", smile);
}
anna.html
<script type="text/javascript">
RED.nodes.registerType('anna',{
category: 'Thermostaat',
color: '#af3',
defaults: {
name: {value:""},
smile: {value:"", type:"anna-config"},
},
inputs:1,
outputs:1,
icon: "file.png",
label: function() {
return this.smile||"anna";
}
});
</script>
<script type="text/html" data-template-name="anna">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="naam">
</div>
<div class="form-row">
<label for="node-input-smile"><i class="icon-tag"></i>Smile</label>
<input type="text" id="node-input-smile" placeholder="">
</div>
</script>
<script type="text/html" data-help-name="anna">
<p>A simple node that converts the message payloads into all lower-case characters</p>
</script>
anna.js
module.exports = function(RED){
function anna(config){
RED.nodes.createNode(this,config);
this.smile = RED.nodes.getNode(config.smile);
if (this.smile) {
// Do something with:
// this.server.host
// this.server.port
} else {
// No config node configured
}
}
RED.nodes.registerType("anna", anna);
}
package.json
{
"name": "node-red-contrib-anna",
"version": "1.0.0",
"description": "anna",
"node-red" : {
"nodes": {
"anna": "anna.js",
"anna-config": "anna-config.js"
}
}
}