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 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">
|
||||
<ul style="background: #fff; min-width: 600px; margin-bottom: 20px;" id="node-config-mqtt-broker-tabs"></ul>
|
||||
</div>
|
||||
@ -266,6 +270,7 @@
|
||||
RED.nodes.registerType('mqtt-broker',{
|
||||
category: 'config',
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
broker: {value:"",required:true},
|
||||
port: {value:1883,required:true,validate:RED.validators.number()},
|
||||
tls: {type:"tls-config",required: false},
|
||||
@ -296,9 +301,15 @@
|
||||
password: {type: "password"}
|
||||
},
|
||||
label: function() {
|
||||
var b = this.broker;
|
||||
if (b === "") { b = "undefined"; }
|
||||
return (this.clientid?this.clientid+"@":"")+b+":"+this.port;
|
||||
var lab = this.name;
|
||||
if ((lab === undefined) || (lab ==="")) {
|
||||
var b = this.broker;
|
||||
if (b === "") { b = "undefined"; }
|
||||
lab = (this.clientid?this.clientid+"@":"")+b+":"+this.port;
|
||||
}
|
||||
return lab;
|
||||
|
||||
|
||||
},
|
||||
oneditprepare: function () {
|
||||
var tabs = RED.tabs.create({
|
||||
|
Loading…
Reference in New Issue
Block a user