Skip to content

Commit

Permalink
Merge pull request #46 from SoopSASM/feature/chart-data-formatting-node
Browse files Browse the repository at this point in the history
[Add] create  soop_data_format node
  • Loading branch information
lea-hwang authored Oct 2, 2022
2 parents cf4708d + bce60e9 commit 82e9c64
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
56 changes: 56 additions & 0 deletions dashboard/nodes/soop_data_format.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<script type="text/javascript">
RED.nodes.registerType("soop_data_format", {
category: "soop-dashboard",
color: "#a6bbcf", // 수정 필요
defaults: {
label: { value: "dataset1", validate: RED.validators.typedInput("labelType") },
labelType: { value: "str" },
name: { value: "" },
},
inputs: 1,
outputs: 1,
icon: "font-awesome/fa-bookmark",
label: function () {
return this.name || "soop_data_format";
},
oneditprepare: function () {
$("#node-input-label").typedInput({
default: "str",
typeField: $("#node-input-labelType"),
types: ["str", "msg", "flow", "global"],
});
},
});
</script>

<script type="text/html" data-template-name="soop_data_format">
<div class="form-row">
<label for="node-input-label"><i class="fa fa-bookmark"></i> Label </label>
<input type="text" id="node-input-label" style="width:70%" />
<input type="hidden" id="node-input-labelType" />
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name" />
</div>
</script>

<script type="text/html" data-help-name="soop_data_format">
<p>Label on data for chart node</p>
<h3>Inputs</h3>
<dt>payload <span class="property-type">number</span></dt>
<dd>a data of dataset</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dl class="message-properties">
<dt>label <span class="property-type">string</span></dt>
<dd>the name of dataset</dd>
<dt>payload <span class="property-type">number</span></dt>
<dd>a data of dataset</dd>
</dl>
<h3>Details</h3>
<p>
Write label field to name on a dataset for chart node.
</p>
</script>
16 changes: 16 additions & 0 deletions dashboard/nodes/soop_data_format.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = function (RED) {
function SoopDataFormatNode(config) {
RED.nodes.createNode(this, config);
const node = this;
node.on("input", function (msg) {
RED.util.setMessageProperty(
msg,
"label",
RED.util.evaluateNodeProperty(config.label, config.labelType, node, msg),
true,
);
node.send(msg);
});
}
RED.nodes.registerType("soop_data_format", SoopDataFormatNode);
};

0 comments on commit 82e9c64

Please sign in to comment.