mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
mqtt: Add 'name' to mqtt-broker node, and label it by this if it is set. (#1364)
This allows you to easily distinguish between broker nodes which are talking to the same server but with different credentials.
This commit is contained in:
parent
96a0dbea2d
commit
e09efba313
@ -165,6 +165,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-template-name="mqtt-broker">
|
<script type="text/x-red" data-template-name="mqtt-broker">
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-config-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
||||||
|
<input type="text" id="node-config-input-name" data-i18n="[placeholder]common.label.name">
|
||||||
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<ul style="background: #fff; min-width: 600px; margin-bottom: 20px;" id="node-config-mqtt-broker-tabs"></ul>
|
<ul style="background: #fff; min-width: 600px; margin-bottom: 20px;" id="node-config-mqtt-broker-tabs"></ul>
|
||||||
</div>
|
</div>
|
||||||
@ -266,6 +270,7 @@
|
|||||||
RED.nodes.registerType('mqtt-broker',{
|
RED.nodes.registerType('mqtt-broker',{
|
||||||
category: 'config',
|
category: 'config',
|
||||||
defaults: {
|
defaults: {
|
||||||
|
name: {value:""},
|
||||||
broker: {value:"",required:true},
|
broker: {value:"",required:true},
|
||||||
port: {value:1883,required:true,validate:RED.validators.number()},
|
port: {value:1883,required:true,validate:RED.validators.number()},
|
||||||
tls: {type:"tls-config",required: false},
|
tls: {type:"tls-config",required: false},
|
||||||
@ -296,9 +301,15 @@
|
|||||||
password: {type: "password"}
|
password: {type: "password"}
|
||||||
},
|
},
|
||||||
label: function() {
|
label: function() {
|
||||||
var b = this.broker;
|
var lab = this.name;
|
||||||
if (b === "") { b = "undefined"; }
|
if ((lab === undefined) || (lab ==="")) {
|
||||||
return (this.clientid?this.clientid+"@":"")+b+":"+this.port;
|
var b = this.broker;
|
||||||
|
if (b === "") { b = "undefined"; }
|
||||||
|
lab = (this.clientid?this.clientid+"@":"")+b+":"+this.port;
|
||||||
|
}
|
||||||
|
return lab;
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
oneditprepare: function () {
|
oneditprepare: function () {
|
||||||
var tabs = RED.tabs.create({
|
var tabs = RED.tabs.create({
|
||||||
|
Loading…
Reference in New Issue
Block a user