Skip to content

Commit

Permalink
[modify] change variables for react
Browse files Browse the repository at this point in the history
  • Loading branch information
lea-hwang committed Oct 2, 2022
1 parent 8867adc commit 4e1d018
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 37 deletions.
8 changes: 4 additions & 4 deletions dashboard/nodes/soop_chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
height: { value: 1, validate: RED.validators.number(), required: true },
widgetX: { value: 0, validate: RED.validators.number(), required: true },
widgetY: { value: 0, validate: RED.validators.number(), required: true },
label: { value: "chart_name" },
title: { value: "chart_name" },
chartType: { value: "line" },
xAxisFormat: { value: "HH:mm:ss" },
customValue: { value: "" },
Expand Down Expand Up @@ -133,7 +133,7 @@
return `${this.chartType} chart data`;
},
label: function () {
return this.name || (~this.label.indexOf("{{") ? null : this.label) || "new_chart";
return this.name || (~this.title.indexOf("{{") ? null : this.title) || "new_chart";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
Expand Down Expand Up @@ -226,8 +226,8 @@
</div>
</div>
<div class="form-row">
<label for="node-input-label"><i class="fa fa-i-cursor"></i> Label</label>
<input type="text" id="node-input-label" />
<label for="node-input-title"><i class="fa fa-i-cursor"></i> Label</label>
<input type="text" id="node-input-title" />
</div>
<div class="form-row">
<label for="node-input-chartType"><i class="fa fa-line-chart"></i> Type</label>
Expand Down
35 changes: 2 additions & 33 deletions dashboard/nodes/soop_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,22 @@ module.exports = function (RED) {
const node = this;
RED.nodes.createNode(node, config);

const group = RED.nodes.getNode(config.group);
if (!group) {
return;
}
var tab = RED.nodes.getNode(group.config.tab);
if (!tab) {
return;
}
const chartType = config.chartType;
let state = {
nodeId: node.id,
nodeType: "chart",
group: group,
tab: tab,
size: [+config.width, +config.height, +config.widgetX, +config.widgetY],
title: config.label,
chartType: config.chartType,
legend: config.legend === "true" ? true : false,
blankLabel: config.blankLabel,
isTimeSeries: config.isTimeSeries,
};

if (chartType === "line" || chartType === "bar") {
state = Object.assign(state, {
xAxisFormat: config.xAxisFormat,
yMin: config.yMin ? +config.yMin : "",
yMax: config.yMax ? +config.yMax : "",
customValue: config.xAxisFormat === "custom" ? config.customValue : "",
});
}
// send state to dashboard
dashboard.emitState(state, config.isTimeSeries);
node.on("input", function (msg, done) {
if (isNaN(msg.payload)) {
node.error("Payload is not a number.");
return;
}
dashboard.emitState(
{
node_id: node.id,
nodeId: node.id,
data: {
[msg.label]: {
value: +msg.payload,
},
},
},
config.isTimeSeries,
true,
);
// done
if (done) done();
Expand Down

0 comments on commit 4e1d018

Please sign in to comment.