mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge branch 'pr_1719'
This commit is contained in:
commit
63e6e64ad3
@ -212,48 +212,84 @@
|
|||||||
<input type="password" id="node-config-input-password">
|
<input type="password" id="node-config-input-password">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="mqtt-broker-tab-birth" style="display:none">
|
<div id="mqtt-broker-tab-messages" style="display:none">
|
||||||
<div class="form-row">
|
<div id="mqtt-broker-section-birth">
|
||||||
<label for="node-config-input-birthTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
<div class="palette-header">
|
||||||
<input type="text" id="node-config-input-birthTopic" data-i18n="[placeholder]mqtt.placeholder.birth-topic">
|
<i class="fa fa-angle-down"></i><span data-i18n="mqtt.sections-label.birth-message"></span>
|
||||||
|
</div>
|
||||||
|
<div class="section-content" style="padding:10px 0 0 10px">
|
||||||
|
<div class="form-row">
|
||||||
|
<label style="width: 100px !important;" for="node-config-input-birthTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
||||||
|
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-birthTopic" data-i18n="[placeholder]mqtt.placeholder.birth-topic">
|
||||||
|
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-birthRetain"><i class="fa fa-history"></i> <span data-i18n="mqtt.label.retain"></span></label>
|
||||||
|
<select id="node-config-input-birthRetain" style="width:75px !important">
|
||||||
|
<option value="false" data-i18n="mqtt.false"></option>
|
||||||
|
<option value="true" data-i18n="mqtt.true"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label style="width: 100px !important;" for="node-config-input-birthPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
||||||
|
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-birthPayload" style="width:300px" data-i18n="[placeholder]common.label.payload">
|
||||||
|
<label style="margin-left: 10px; width: 90px !important;" 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:75px !important">
|
||||||
|
<option value="0">0</option>
|
||||||
|
<option value="1">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div id="mqtt-broker-section-close">
|
||||||
<label for="node-config-input-birthQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
<div class="palette-header">
|
||||||
<select id="node-config-input-birthQos" style="width:125px !important">
|
<i class="fa fa-angle-down"></i><span data-i18n="mqtt.sections-label.close-message"></span>
|
||||||
<option value="0">0</option>
|
</div>
|
||||||
<option value="1">1</option>
|
<div class="section-content" style="padding:10px 0 0 10px">
|
||||||
<option value="2">2</option>
|
<div class="form-row">
|
||||||
</select>
|
<label style="width: 100px !important;" for="node-config-input-closeTopic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
||||||
<i class="fa fa-history"></i> <span data-i18n="mqtt.retain"></span> <select id="node-config-input-birthRetain" style="width:125px !important">
|
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-closeTopic" style="width:300px" data-i18n="[placeholder]mqtt.placeholder.close-topic">
|
||||||
<option value="false" data-i18n="mqtt.false"></option>
|
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-closeRetain"><i class="fa fa-history"></i> <span data-i18n="mqtt.label.retain"></span></label>
|
||||||
<option value="true" data-i18n="mqtt.true"></option>
|
<select id="node-config-input-closeRetain" style="width:75px !important">
|
||||||
</select>
|
<option value="false" data-i18n="mqtt.false"></option>
|
||||||
|
<option value="true" data-i18n="mqtt.true"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label style="width: 100px !important;" for="node-config-input-closePayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
||||||
|
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-closePayload" style="width:300px" data-i18n="[placeholder]common.label.payload">
|
||||||
|
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-closeQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
||||||
|
<select id="node-config-input-closeQos" style="width:75px !important">
|
||||||
|
<option value="0">0</option>
|
||||||
|
<option value="1">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div id="mqtt-broker-section-will">
|
||||||
<label for="node-config-input-birthPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
<div class="palette-header">
|
||||||
<input type="text" id="node-config-input-birthPayload" data-i18n="[placeholder]common.label.payload">
|
<i class="fa fa-angle-down"></i><span data-i18n="mqtt.sections-label.will-message"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="section-content" style="padding:10px 0 0 10px">
|
||||||
<div id="mqtt-broker-tab-will" style="display:none">
|
<div class="form-row">
|
||||||
<div class="form-row">
|
<label style="width: 100px !important;" 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 style="width: calc(100% - 300px) !important" type="text" id="node-config-input-willTopic" style="width:300px" data-i18n="[placeholder]mqtt.placeholder.will-topic">
|
||||||
<input type="text" id="node-config-input-willTopic" data-i18n="[placeholder]mqtt.placeholder.will-topic">
|
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-willRetain"><i class="fa fa-history"></i> <span data-i18n="mqtt.label.retain"></span></label>
|
||||||
</div>
|
<select id="node-config-input-willRetain" style="width:75px !important">
|
||||||
<div class="form-row">
|
<option value="false" data-i18n="mqtt.false"></option>
|
||||||
<label for="node-config-input-willQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
<option value="true" data-i18n="mqtt.true"></option>
|
||||||
<select id="node-config-input-willQos" style="width:125px !important">
|
</select>
|
||||||
<option value="0">0</option>
|
</div>
|
||||||
<option value="1">1</option>
|
<div class="form-row">
|
||||||
<option value="2">2</option>
|
<label style="width: 100px !important;" for="node-config-input-willPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
||||||
</select>
|
<input style="width: calc(100% - 300px) !important" type="text" id="node-config-input-willPayload" style="width:300px" data-i18n="[placeholder]common.label.payload">
|
||||||
<i class="fa fa-history"></i> <span data-i18n="mqtt.retain"></span> <select id="node-config-input-willRetain" style="width:125px !important">
|
<label style="margin-left: 10px; width: 90px !important;" for="node-config-input-willQos"><i class="fa fa-empire"></i> <span data-i18n="mqtt.label.qos"></span></label>
|
||||||
<option value="false" data-i18n="mqtt.false"></option>
|
<select id="node-config-input-willQos" style="width:75px !important">
|
||||||
<option value="true" data-i18n="mqtt.true"></option>
|
<option value="0">0</option>
|
||||||
</select>
|
<option value="1">1</option>
|
||||||
</div>
|
<option value="2">2</option>
|
||||||
<div class="form-row">
|
</select>
|
||||||
<label for="node-config-input-willPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload"></span></label>
|
</div>
|
||||||
<input type="text" id="node-config-input-willPayload" data-i18n="[placeholder]common.label.payload">
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -269,6 +305,9 @@
|
|||||||
<h4>Birth Message</h4>
|
<h4>Birth Message</h4>
|
||||||
<p>This is a message that will be published on the configured topic whenever the
|
<p>This is a message that will be published on the configured topic whenever the
|
||||||
connection is established.</p>
|
connection is established.</p>
|
||||||
|
<h4>Close Message</h4>
|
||||||
|
<p>This is a message that will be published on the configured topic before the
|
||||||
|
connection is closed normally, either by re-deploying the node, or by shutting down.</p>
|
||||||
<h4>Will Message</h4>
|
<h4>Will Message</h4>
|
||||||
<p>This is a message that will be published by the broker in the event the node
|
<p>This is a message that will be published by the broker in the event the node
|
||||||
unexpectedly loses its connection.</p>
|
unexpectedly loses its connection.</p>
|
||||||
@ -300,14 +339,18 @@
|
|||||||
compatmode: { value: true},
|
compatmode: { value: true},
|
||||||
keepalive: {value:60,validate:RED.validators.number()},
|
keepalive: {value:60,validate:RED.validators.number()},
|
||||||
cleansession: {value: true},
|
cleansession: {value: true},
|
||||||
willTopic: {value:""},
|
|
||||||
willQos: {value:"0"},
|
|
||||||
willRetain: {value:false},
|
|
||||||
willPayload: {value:""},
|
|
||||||
birthTopic: {value:""},
|
birthTopic: {value:""},
|
||||||
birthQos: {value:"0"},
|
birthQos: {value:"0"},
|
||||||
birthRetain: {value:false},
|
birthRetain: {value:false},
|
||||||
birthPayload: {value:""}
|
birthPayload: {value:""},
|
||||||
|
closeTopic: {value:""},
|
||||||
|
closeQos: {value:"0"},
|
||||||
|
closeRetain: {value:false},
|
||||||
|
closePayload: {value:""},
|
||||||
|
willTopic: {value:""},
|
||||||
|
willQos: {value:"0"},
|
||||||
|
willRetain: {value:false},
|
||||||
|
willPayload: {value:""}
|
||||||
},
|
},
|
||||||
credentials: {
|
credentials: {
|
||||||
user: {type:"text"},
|
user: {type:"text"},
|
||||||
@ -343,14 +386,39 @@
|
|||||||
id: "mqtt-broker-tab-security",
|
id: "mqtt-broker-tab-security",
|
||||||
label: this._("mqtt.tabs-label.security")
|
label: this._("mqtt.tabs-label.security")
|
||||||
});
|
});
|
||||||
|
|
||||||
tabs.addTab({
|
tabs.addTab({
|
||||||
id: "mqtt-broker-tab-birth",
|
id: "mqtt-broker-tab-messages",
|
||||||
label: this._("mqtt.tabs-label.birth")
|
label: this._("mqtt.tabs-label.messages")
|
||||||
});
|
|
||||||
tabs.addTab({
|
|
||||||
id: "mqtt-broker-tab-will",
|
|
||||||
label: this._("mqtt.tabs-label.will")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function setUpSection(sectionId, isExpanded) {
|
||||||
|
var birthMessageSection = $(sectionId);
|
||||||
|
var paletteHeader = birthMessageSection.find('.palette-header');
|
||||||
|
var twistie = paletteHeader.find('i');
|
||||||
|
var sectionContent = birthMessageSection.find('.section-content');
|
||||||
|
|
||||||
|
function toggleSection(expanded) {
|
||||||
|
twistie.toggleClass('expanded', expanded);
|
||||||
|
sectionContent.toggle(expanded);
|
||||||
|
}
|
||||||
|
paletteHeader.click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var isExpanded = twistie.hasClass('expanded');
|
||||||
|
toggleSection(!isExpanded);
|
||||||
|
});
|
||||||
|
toggleSection(isExpanded);
|
||||||
|
}
|
||||||
|
|
||||||
|
// show first section if none are set so the user gets the idea
|
||||||
|
var showBirthSection = this.birthTopic !== ""
|
||||||
|
|| this.willTopic === ""
|
||||||
|
&& this.birthTopic === ""
|
||||||
|
&& this.closeTopic == "";
|
||||||
|
setUpSection('#mqtt-broker-section-birth', showBirthSection);
|
||||||
|
setUpSection('#mqtt-broker-section-close', this.closeTopic !== "");
|
||||||
|
setUpSection('#mqtt-broker-section-will', this.willTopic !== "");
|
||||||
|
|
||||||
setTimeout(function() { tabs.resize(); },0);
|
setTimeout(function() { tabs.resize(); },0);
|
||||||
if (typeof this.cleansession === 'undefined') {
|
if (typeof this.cleansession === 'undefined') {
|
||||||
this.cleansession = true;
|
this.cleansession = true;
|
||||||
@ -368,14 +436,18 @@
|
|||||||
this.keepalive = 15;
|
this.keepalive = 15;
|
||||||
$("#node-config-input-keepalive").val(this.keepalive);
|
$("#node-config-input-keepalive").val(this.keepalive);
|
||||||
}
|
}
|
||||||
if (typeof this.willQos === 'undefined') {
|
|
||||||
this.willQos = "0";
|
|
||||||
$("#node-config-input-willQos").val("0");
|
|
||||||
}
|
|
||||||
if (typeof this.birthQos === 'undefined') {
|
if (typeof this.birthQos === 'undefined') {
|
||||||
this.birthQos = "0";
|
this.birthQos = "0";
|
||||||
$("#node-config-input-birthQos").val("0");
|
$("#node-config-input-birthQos").val("0");
|
||||||
}
|
}
|
||||||
|
if (typeof this.closeQos === 'undefined') {
|
||||||
|
this.willQos = "0";
|
||||||
|
$("#node-config-input-willQos").val("0");
|
||||||
|
}
|
||||||
|
if (typeof this.willQos === 'undefined') {
|
||||||
|
this.willQos = "0";
|
||||||
|
$("#node-config-input-willQos").val("0");
|
||||||
|
}
|
||||||
|
|
||||||
function updateTLSOptions() {
|
function updateTLSOptions() {
|
||||||
if ($("#node-config-input-usetls").is(':checked')) {
|
if ($("#node-config-input-usetls").is(':checked')) {
|
||||||
|
@ -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,17 +333,22 @@
|
|||||||
"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",
|
||||||
"will": "Will Message",
|
"messages": "Messages"
|
||||||
"birth": "Birth Message"
|
|
||||||
},
|
},
|
||||||
"placeholder": {
|
"placeholder": {
|
||||||
"clientid": "Leave blank for auto generated",
|
"clientid": "Leave blank for auto generated",
|
||||||
"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 disable close message"
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
"connected": "Connected to broker: __broker__",
|
"connected": "Connected to broker: __broker__",
|
||||||
|
Loading…
Reference in New Issue
Block a user