mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
move to two lines, add publish on close
This commit is contained in:
parent
f478d7c9f0
commit
44a75c1291
@ -215,84 +215,82 @@
|
|||||||
<div id="mqtt-broker-tab-messages" style="display:none">
|
<div id="mqtt-broker-tab-messages" style="display:none">
|
||||||
<div id="mqtt-broker-section-birth">
|
<div id="mqtt-broker-section-birth">
|
||||||
<div class="palette-header">
|
<div class="palette-header">
|
||||||
<i class="fa fa-angle-down expanded"></i><span>Message sent on connection (birth message)</span>
|
<i class="fa fa-angle-down expanded"></i><span data-i18n="mqtt.sections-label.birth-message"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-content" style="padding: 12px">
|
<div class="section-content" style="padding: 12px">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-birthTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
<label for="node-config-input-birthTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
||||||
<input type="text" id="node-config-input-birthTopic" data-i18n="[placeholder]mqtt.placeholder.birth-topic">
|
<input type="text" id="node-config-input-birthTopic" data-i18n="[placeholder]mqtt.placeholder.birth-topic" style="width:300px !important">
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<i class="fa fa-history"></i> <span data-i18n="mqtt.label.retain"></span> <select id="node-config-input-birthRetain" style="float: right; width:75px !important">
|
||||||
<label for="node-config-input-birthQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
|
||||||
<select id="node-config-input-birthQos" style="width:125px !important">
|
|
||||||
<option value="0">0</option>
|
|
||||||
<option value="1">1</option>
|
|
||||||
<option value="2">2</option>
|
|
||||||
</select>
|
|
||||||
<i class="fa fa-history"></i> <span data-i18n="mqtt.retain"></span> <select id="node-config-input-birthRetain" style="width:125px !important">
|
|
||||||
<option value="false" data-i18n="mqtt.false"></option>
|
<option value="false" data-i18n="mqtt.false"></option>
|
||||||
<option value="true" data-i18n="mqtt.true"></option>
|
<option value="true" data-i18n="mqtt.true"></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-birthPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
<label for="node-config-input-birthPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
||||||
<input type="text" id="node-config-input-birthPayload" data-i18n="[placeholder]common.label.payload">
|
<input type="text" id="node-config-input-birthPayload" style="width:300px" data-i18n="[placeholder]common.label.payload">
|
||||||
|
|
||||||
|
<i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
||||||
|
<select id="node-config-input-birthQos" style="float: right; width:75px !important">
|
||||||
|
<option value="0">0</option>
|
||||||
|
<option value="1">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="mqtt-broker-section-will">
|
<div id="mqtt-broker-section-will">
|
||||||
<div class="palette-header">
|
<div class="palette-header">
|
||||||
<i class="fa fa-angle-down expanded"></i><span>Message sent on an unexpected disconnection (will message)</span>
|
<i class="fa fa-angle-down expanded"></i><span data-i18n="mqtt.sections-label.will-message"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-content" style="padding: 12px">
|
<div class="section-content" style="padding: 12px">
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-willTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
<label for="node-config-input-willTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
||||||
<input type="text" id="node-config-input-willTopic" data-i18n="[placeholder]mqtt.placeholder.will-topic">
|
<input type="text" id="node-config-input-willTopic" style="width:300px" data-i18n="[placeholder]mqtt.placeholder.will-topic">
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<i class="fa fa-history"></i> <span data-i18n="mqtt.label.retain"></span> <select id="node-config-input-willRetain" style="float:right; width:75px !important">
|
||||||
<label for="node-config-input-willQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
|
||||||
<select id="node-config-input-willQos" style="width:125px !important">
|
|
||||||
<option value="0">0</option>
|
|
||||||
<option value="1">1</option>
|
|
||||||
<option value="2">2</option>
|
|
||||||
</select>
|
|
||||||
<i class="fa fa-history"></i> <span data-i18n="mqtt.retain"></span> <select id="node-config-input-willRetain" style="width:125px !important">
|
|
||||||
<option value="false" data-i18n="mqtt.false"></option>
|
<option value="false" data-i18n="mqtt.false"></option>
|
||||||
<option value="true" data-i18n="mqtt.true"></option>
|
<option value="true" data-i18n="mqtt.true"></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-willPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
<label for="node-config-input-willPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
||||||
<input type="text" id="node-config-input-willPayload" data-i18n="[placeholder]common.label.payload">
|
<input type="text" id="node-config-input-willPayload" style="width:300px" data-i18n="[placeholder]common.label.payload">
|
||||||
|
|
||||||
|
<i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
||||||
|
<select id="node-config-input-willQos" style="float:right; width:75px !important">
|
||||||
|
<option value="0">0</option>
|
||||||
|
<option value="1">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="mqtt-broker-section-close">
|
<div id="mqtt-broker-section-close">
|
||||||
<div class="palette-header">
|
<div class="palette-header">
|
||||||
<i class="fa fa-angle-down"></i><span>Message sent before disconnecting (close message)</span>
|
<i class="fa fa-angle-down"></i><span data-i18n="mqtt.sections-label.close-message"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-content" style="padding: 12px; display:none">
|
<div class="section-content" style="display:none; padding: 12px">
|
||||||
<div style="padding: 12px;">
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-willTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
<label for="node-config-input-willTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
||||||
<input type="text" id="node-config-input-willTopic" data-i18n="[placeholder]mqtt.placeholder.will-topic">
|
<input type="text" id="node-config-input-willTopic" style="width:300px" data-i18n="[placeholder]mqtt.placeholder.close-topic">
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<i class="fa fa-history"></i> <span data-i18n="mqtt.label.retain"></span> <select id="node-config-input-closeRetain" style="float:right; width:75px !important">
|
||||||
<label for="node-config-input-willQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
|
||||||
<select id="node-config-input-willQos" style="width:125px !important">
|
|
||||||
<option value="0">0</option>
|
|
||||||
<option value="1">1</option>
|
|
||||||
<option value="2">2</option>
|
|
||||||
</select>
|
|
||||||
<i class="fa fa-history"></i> <span data-i18n="mqtt.retain"></span> <select id="node-config-input-willRetain" style="width:125px !important">
|
|
||||||
<option value="false" data-i18n="mqtt.false"></option>
|
<option value="false" data-i18n="mqtt.false"></option>
|
||||||
<option value="true" data-i18n="mqtt.true"></option>
|
<option value="true" data-i18n="mqtt.true"></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-config-input-willPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
<label for="node-config-input-closePayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
||||||
<input type="text" id="node-config-input-willPayload" data-i18n="[placeholder]common.label.payload">
|
<input type="text" id="node-config-input-willPayload" style="width:300px" data-i18n="[placeholder]common.label.payload">
|
||||||
</div>
|
|
||||||
|
<i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
||||||
|
<select id="node-config-input-closeQos" style="float:right; width:75px !important">
|
||||||
|
<option value="0">0</option>
|
||||||
|
<option value="1">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -320,29 +318,6 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-template-name="mqtt-broker-section-birth">
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-config-input-birthTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
|
||||||
<input type="text" id="node-config-input-birthTopic" data-i18n="[placeholder]mqtt.placeholder.birth-topic">
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-config-input-birthQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
|
||||||
<select id="node-config-input-birthQos" style="width:125px !important">
|
|
||||||
<option value="0">0</option>
|
|
||||||
<option value="1">1</option>
|
|
||||||
<option value="2">2</option>
|
|
||||||
</select>
|
|
||||||
<i class="fa fa-history"></i> <span data-i18n="mqtt.retain"></span> <select id="node-config-input-birthRetain" style="width:125px !important">
|
|
||||||
<option value="false" data-i18n="mqtt.false"></option>
|
|
||||||
<option value="true" data-i18n="mqtt.true"></option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-config-input-birthPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
|
||||||
<input type="text" id="node-config-input-birthPayload" data-i18n="[placeholder]common.label.payload">
|
|
||||||
</div>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('mqtt-broker',{
|
RED.nodes.registerType('mqtt-broker',{
|
||||||
category: 'config',
|
category: 'config',
|
||||||
@ -373,9 +348,9 @@
|
|||||||
birthRetain: {value:false},
|
birthRetain: {value:false},
|
||||||
birthPayload: {value:""},
|
birthPayload: {value:""},
|
||||||
closeTopic: {value:""},
|
closeTopic: {value:""},
|
||||||
closeTopic: {value:"0"},
|
closeQos: {value:"0"},
|
||||||
closeTopic: {value:false},
|
closeRetain: {value:false},
|
||||||
closeTopic: {value:""}
|
closePayload: {value:""}
|
||||||
},
|
},
|
||||||
credentials: {
|
credentials: {
|
||||||
user: {type:"text"},
|
user: {type:"text"},
|
||||||
|
@ -60,6 +60,15 @@ module.exports = function(RED) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (n.closeTopic) {
|
||||||
|
this.closeMessage = {
|
||||||
|
topic: n.closeTopic,
|
||||||
|
payload: n.closePayload || "",
|
||||||
|
qos: Number(n.closeQos||0),
|
||||||
|
retain: n.closeRetain=="true"|| n.closeRetain===true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (this.credentials) {
|
if (this.credentials) {
|
||||||
this.username = this.credentials.user;
|
this.username = this.credentials.user;
|
||||||
this.password = this.credentials.password;
|
this.password = this.credentials.password;
|
||||||
@ -314,6 +323,10 @@ module.exports = function(RED) {
|
|||||||
this.on('close', function(done) {
|
this.on('close', function(done) {
|
||||||
this.closing = true;
|
this.closing = true;
|
||||||
if (this.connected) {
|
if (this.connected) {
|
||||||
|
// Send close message
|
||||||
|
if (node.closeMessage) {
|
||||||
|
node.publish(node.closeMessage);
|
||||||
|
}
|
||||||
this.client.once('close', function() {
|
this.client.once('close', function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -323,6 +323,7 @@
|
|||||||
"broker": "Server",
|
"broker": "Server",
|
||||||
"example": "e.g. localhost",
|
"example": "e.g. localhost",
|
||||||
"qos": "QoS",
|
"qos": "QoS",
|
||||||
|
"retain": "Retain",
|
||||||
"clientid": "Client ID",
|
"clientid": "Client ID",
|
||||||
"port": "Port",
|
"port": "Port",
|
||||||
"keepalive": "Keep alive time (s)",
|
"keepalive": "Keep alive time (s)",
|
||||||
@ -332,6 +333,11 @@
|
|||||||
"verify-server-cert":"Verify server certificate",
|
"verify-server-cert":"Verify server certificate",
|
||||||
"compatmode": "Use legacy MQTT 3.1 support"
|
"compatmode": "Use legacy MQTT 3.1 support"
|
||||||
},
|
},
|
||||||
|
"sections-label":{
|
||||||
|
"birth-message": "Message sent on connection (birth message)",
|
||||||
|
"will-message":"Message sent on an unexpected disconnection (will message)",
|
||||||
|
"close-message":"Message sent before disconnecting (close message)"
|
||||||
|
},
|
||||||
"tabs-label": {
|
"tabs-label": {
|
||||||
"connection": "Connection",
|
"connection": "Connection",
|
||||||
"security": "Security",
|
"security": "Security",
|
||||||
@ -342,7 +348,7 @@
|
|||||||
"clientid-nonclean":"Must be set for non-clean sessions",
|
"clientid-nonclean":"Must be set for non-clean sessions",
|
||||||
"will-topic": "Leave blank to disable will message",
|
"will-topic": "Leave blank to disable will message",
|
||||||
"birth-topic": "Leave blank to disable birth message",
|
"birth-topic": "Leave blank to disable birth message",
|
||||||
"close-topic": "Leave blank to use the will message on close"
|
"close-topic": "Leave blank to disable close message"
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
"connected": "Connected to broker: __broker__",
|
"connected": "Connected to broker: __broker__",
|
||||||
|
Loading…
Reference in New Issue
Block a user