@strato-automation/node-red-contrib-strato-automation
Version:
Strato Automation Official Node Red Library
130 lines (112 loc) • 4.57 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('input-topic', {
category: 'Strato Automation',
color: '#f3b567',
defaults: {
name: { value: "", label: "Name" },
topic: { value: "default", required: true, label: "Topic" },
},
inputs: 1,
outputs: 1,
icon: "font-awesome/fa-level-up",
paletteLabel: function() {
return "Input Topic";
},
label: function () {
return (this.name || this.topic)
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
outputLabels: function (index) {
return this.topic;
},
oneditprepare: function () {
var node = this;
$("#node-input-topic").typedInput({
types: [
{
value: "",
options: topics()
}
]
})
}
});
</script>
<script type="text/html" data-template-name="input-topic">
<!-- Basic Settings -->
<div class="form-tips" style="margin-bottom: 20px;">
<b>Basic Settings</b>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-bookmark"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Optional name for this converter">
</div>
<!-- Topic Settings -->
<div class="form-tips" style="margin: 20px 0;">
<b>Topic Settings</b>
</div>
<div style="padding-left: 10px; border-left: 3px solid #ddd;">
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tags"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Select output topic">
</div>
</div>
<div class="form-tips" style="margin-top: 20px;">
<p><i class="fa fa-info-circle"></i> Tip: Use this node to route messages or change their topic while preserving the payload.</p>
</div>
</script>
<script type="text/html" data-help-name="input-topic">
<p>A node that changes the topic of incoming messages while preserving their payload and other properties.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">any</span></dt>
<dd>Any input payload (passed through unchanged)</dd>
<dt>topic <span class="property-type">string</span></dt>
<dd>Input topic (will be replaced with configured topic)</dd>
<dt>other properties</dt>
<dd>All other message properties are preserved</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">any</span></dt>
<dd>Same as input payload (unchanged)</dd>
<dt>topic <span class="property-type">string</span></dt>
<dd>The configured topic name</dd>
<dt>__srcid <span class="property-type">string</span></dt>
<dd>The node's identifier</dd>
<dt>other properties</dt>
<dd>All other input message properties are preserved</dd>
</dl>
<h3>Configuration</h3>
<dl class="message-properties">
<dt>Name <span class="property-type">string</span></dt>
<dd>Optional name to identify the node in the flow</dd>
<dt>Topic <span class="property-type">string</span></dt>
<dd>The topic to assign to outgoing messages</dd>
</dl>
<h3>Status</h3>
<dl class="message-properties">
<dt>Grey dot</dt>
<dd>Shows the configured topic name</dd>
</dl>
<h3>Details</h3>
<p>This node is useful for message routing and topic management in flows. Common use cases include:</p>
<h4>Use Cases</h4>
<ul>
<li>Routing messages to specific flow branches based on topic</li>
<li>Standardizing topics from different sources</li>
<li>Creating topic hierarchies</li>
<li>Preparing messages for specific node requirements</li>
</ul>
<h4>Operation</h4>
<p>The node:</p>
<ul>
<li>Preserves all input message properties</li>
<li>Replaces the topic with the configured value</li>
<li>Adds a source identifier (__srcid)</li>
<li>Passes the message immediately (no delay)</li>
</ul>
<p>This node is particularly useful when working with nodes that rely on specific topic patterns or when organizing message flows in larger systems.</p>
</script>