node-red-contrib-motechat
Version:
ultranet topic and payload communication
93 lines (87 loc) • 3.03 kB
HTML
<script type="text/x-red" data-template-name="send">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="sender">
</div>
<div class="form-row">
<label for="node-input-DDN"><i class="fa fa-tag"></i> DDN</label>
<input type="text" id="node-input-DDN" placeholder=""/>
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder=""/>
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('send', {
category: 'motechat',
color: '#A5C2DB',
defaults: {
DDN: { value: 'DDN', validate: RED.validators.typedInput("DDNType") },
DDNType : { value: 'msg'},
topic: { value: 'topic', validate: RED.validators.typedInput("topicType") },
topicType: { value: 'msg' },
name: { value: 'send' },
},
inputs: 1,
outputs: 2,
icon: "send.png",
label: function () {
return this.name || "send";
},
oneditprepare: function() {
const defaultTypes = ['msg','flow','global','str']
$("#node-input-DDN").typedInput({default: 'msg', types: defaultTypes})
$("#node-input-topic").typedInput({default: 'msg', types: defaultTypes})
$("#node-input-DDN").typedInput('type', this.DDNType)
$("#node-input-topic").typedInput('type', this.topicType)
},
oneditsave: function () {
this.DDNType = $("#node-input-DDN").typedInput('type');
this.topicType = $("#node-input-topic").typedInput('type');
}
});
</script>
<script type="text/x-red" data-help-name="send">
<p>Motechat send node.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">string | json object</span>
</dt>
<dd>The payload of message to send to the topics</dd>
<dt>topic
<span class="property-type">string</span>
</dt>
<dd>The topic of message that want to send.</dd>
<dt class="optional">name
<span class="property-type">string</span>
</dt>
<dd>The name of the node</dd>
<dt> DDN
<span class="property-type">string</span>
</dt>
<dd>
The DDN that want to send.
</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>hostDDN
<span class="property-type">string</span>
</dt>
<dd>The host DDN.</dd>
<dt>name
<span class="property-type">string</span>
</dt>
<dd>The name of the node.</dd>
<dt>payload
<span class="property-type">object</span>
</dt>
<dd>It contains1 the topic's DDN, and the <code>Reply</code> object that contains <code>ErrCode</code> and <code>ErrMsg</code></dd>
<dt>topic
<span class="property-type">string</span>
</dt>
<dd>The topic that the message be sent to.</dd>
</dl>
</script>