-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from SoopSASM/feature/chart-data-formatting-node
[Add] create soop_data_format node
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |