diff --git a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html index d1a783ee0..45d6a2707 100644 --- a/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html +++ b/packages/node_modules/@node-red/nodes/core/network/10-mqtt.html @@ -76,15 +76,27 @@ +
+ + +
+ +
@@ -110,16 +122,6 @@
-
- - -
@@ -135,9 +137,9 @@ qos: {value: "2"}, datatype: {value:"auto",required:true}, broker: {type:"mqtt-broker", required:true}, - userPropertiesType: {value:"json"}, - userProperties: {value:"{}"}, - subscriptionIdentifier: {value:0}, + // userProperties: {value:"userProperties"}, + // userPropertiesType: {value:"none"}, + // subscriptionIdentifier: {value:0}, nl: {value:false}, rap: {value:true}, rh: {value:0}, @@ -168,11 +170,12 @@ if (this.datatype === undefined) { $("#node-input-datatype").val("auto"); } - $("#node-input-userProperties").typedInput({ - default: "json", - types:['json','flow','global'], - typeField: $("#node-input-userPropertiesType") - }); + // FUTURE + // $("#node-input-userProperties").typedInput({ + // default: "none", + // types:[{ value: 'none', label: 'None', hasValue: false },'flow','global','json'], + // typeField: $("#node-input-userPropertiesType") + // }); } }); @@ -203,33 +206,38 @@
+
+ + + +
- + +
-
- - - -
- + +
- + + +
+
@@ -257,16 +265,19 @@ topic: {value:""}, qos: {value:""}, retain: {value:""}, - responseTopic: {value:""}, - contentType: {value:""}, + responseTopic: {value:"responseTopic"}, + responseTopicType: {value:'none'}, + contentType: {value:"contentType"}, + contentTypeType: {value:'none'}, userProperties: {value:'userProperties'}, - userPropertiesType: {value:'msg'}, + userPropertiesType: {value:'none'}, correlationData: {value:'correlationData'}, - correlationDataType: {value:'msg'}, - topicAlias: {value:0}, - messageExpiryInterval: {value:0}, - payloadFormatIndicator: {value:false}, - subscriptionIdentifier: {value:0}, + correlationDataType: {value:'none'}, + messageExpiryInterval: {value:"messageExpiryInterval"}, + messageExpiryIntervalType: {value:'none'}, + // FUTURE topicAlias: {value:0}, + // FUTURE payloadFormatIndicator: {value:false}, + // FUTURE subscriptionIdentifier: {value:0}, broker: {type:"mqtt-broker", required:true} }, color:"#d8bfd8", @@ -275,10 +286,13 @@ icon: "bridge.svg", align: "right", label: function() { - return this.name||this.topic||(this.topicAlias ? "@"+this.topicAlias : "mqtt"); + return this.name||this.topic||"mqtt"; + // FUTURE return this.name||this.topic||(this.topicAlias ? "@"+this.topicAlias : "mqtt"); }, oneditprepare: function() { - $("#node-input-broker").change(function(d){ + var typedInputNoneOpt = { value: 'none', label: 'None', hasValue: false }; + + function showHideDynamicFields() { var confNode = RED.nodes.node($("#node-input-broker").val()); var v5 = confNode && confNode.protocolVersion == "5"; if(v5) { @@ -286,17 +300,99 @@ } else { $("div.form-row.mqtt5").hide(); } - }); - $("#node-input-correlationData").typedInput({ - default: "none", - types:[{ value:"none", label: "None", hasValue:false },'bin','msg','flow','global'], + var t = $("#node-input-responseTopic").typedInput("type"); + if (t == 'none') { + $("#node-input-correlationData").parent().hide(); + } else { + $("#node-input-correlationData").parent().show(); + } + } + + $("#node-input-broker").change(function(d){ + showHideDynamicFields(); + }); + + var responseTopicTI = $("#node-input-responseTopic").typedInput({ + default: 'none', + types: [typedInputNoneOpt, 'msg', 'flow', 'global', 'str'], + typeField: $("#node-input-responseTopicType") + }); + + var correlationDataTI = $("#node-input-correlationData").typedInput({ + default: 'none', + types: [typedInputNoneOpt, 'msg', 'flow', 'global', 'bin'], typeField: $("#node-input-correlationDataType") }); + //show / hide correlation data depending on responseTopic + responseTopicTI.on("change", function() { + showHideDynamicFields(); + }); + responseTopicTI.triggerHandler("change"); + $("#node-input-userProperties").typedInput({ - default: "msg", - types:['msg','flow','global','json'], + default: 'none', + types: [typedInputNoneOpt, 'msg', 'flow', 'global', 'json'], typeField: $("#node-input-userPropertiesType") }); + + $("#node-input-messageExpiryInterval").typedInput({ + default: 'none', + types: [typedInputNoneOpt, 'msg', 'flow', 'global', 'num'], + typeField: $("#node-input-messageExpiryIntervalType") + }); + + var makeTypedInputOpt = function(value, label, tooltip){ + return { + label: label, + value: value || label, + title: tooltip, + multiple: true + } + } + //TODO: i18n + var commonOpts = [ + makeTypedInputOpt("application/gzip", "application/gzip", "GZip Compressed Archive"), + makeTypedInputOpt("application/json", "application/json", "JSON format"), + makeTypedInputOpt("application/octet-stream", "application/octet-stream", "Any kind of binary data"), + makeTypedInputOpt("application/ogg", "application/ogg", "OGG"), + makeTypedInputOpt("application/pdf", "application/pdf", "AdobeĀ Portable Document FormatĀ (PDF)"), + makeTypedInputOpt("application/zip", "application/zip", "ZIP archive"), + makeTypedInputOpt("audio/aac", "audio/aac", "AAC audio"), + makeTypedInputOpt("audio/midi", "audio/midi", "Musical Instrument Digital Interface (MIDI)"), + makeTypedInputOpt("audio/x-midi", "audio/x-midi", "Musical Instrument Digital Interface (MIDI)"), + makeTypedInputOpt("audio/mpeg", "audio/mpeg", "MP3 audio"), + makeTypedInputOpt("audio/ogg", "audio/ogg", "OGG audio"), + makeTypedInputOpt("audio/wav", "audio/wav", "Waveform Audio Format"), + makeTypedInputOpt("audio/webm", "audio/webm", "WEBM audio"), + makeTypedInputOpt("image/bmp", "image/bmp", "Windows OS/2 Bitmap Graphics"), + makeTypedInputOpt("image/gif", "image/gif", "Graphics Interchange Format (GIF)"), + makeTypedInputOpt("image/jpeg", "image/jpeg", "JPEG images"), + makeTypedInputOpt("image/png", "image/png", "Portable Network Graphics"), + makeTypedInputOpt("image/tiff", "image/tiff", "Tagged Image File Format (TIFF)"), + makeTypedInputOpt("image/webp", "image/webp", "WEBP image"), + makeTypedInputOpt("text/csv", "text/csv", "Comma-separated values (CSV)"), + makeTypedInputOpt("text/html", "text/html", "HyperText Markup Language (HTML)"), + makeTypedInputOpt("text/plain", "text/plain", "Text, (generally ASCII or ISO 8859-n)"), + makeTypedInputOpt("video/mpeg", "video/mpeg", "MPEG Video"), + makeTypedInputOpt("video/ogg", "video/ogg", "OGG video"), + makeTypedInputOpt("video/webm", "video/webm", "WEBM video"), + ]; + $("#node-input-contentType").typedInput({ + default: 'none', + types: [ + typedInputNoneOpt, + { + value: "preset", + label: "Preset", + title: "Preset Content-Types", + icon: "fa fa-list", + showLabel: false, + multiple: false, + options: commonOpts, + default: "application/json" + }, 'msg', 'flow', 'global', 'str'], + typeField: $("#node-input-contentTypeType") + }); }, labelStyle: function() { return this.name?"node_label_italic":""; @@ -353,7 +449,8 @@ -
+
+