From 647ca179039eedd2e86d493ac0b9b26508876433 Mon Sep 17 00:00:00 2001 From: kd9lsv Date: Tue, 24 Sep 2024 21:43:18 -0500 Subject: [PATCH 1/5] add Chart conversion --- README.md | 1 + transformers/index.js | 4 +++- transformers/map.json | 3 ++- transformers/nodes/ui-chart.js | 42 ++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 transformers/nodes/ui-chart.js diff --git a/README.md b/README.md index 34e74a7..83ec103 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Please note that this script does not cover everything, see below for a list of - `ui_slider` - converted to Dashboard 2.0's `ui-slider` - `ui_text_input` - converted to Dashboard 2.0's `ui-text-input` - `.tooltip` is not supported +- `ui_chart` - converted to Dashboard 2.0's `ui-chart` ### Config Nodes diff --git a/transformers/index.js b/transformers/index.js index 7a54aae..4f4d064 100644 --- a/transformers/index.js +++ b/transformers/index.js @@ -7,5 +7,7 @@ module.exports = { uiSlider: require('./nodes/ui-slider'), uiSwitch: require('./nodes/ui-switch'), uiText: require('./nodes/ui-text'), - uiTextInput: require('./nodes/ui-text-input') + uiTextInput: require('./nodes/ui-text-input'), + uiChart: require('./nodes/ui-chart') } + diff --git a/transformers/map.json b/transformers/map.json index 53eb2cb..61c5adf 100644 --- a/transformers/map.json +++ b/transformers/map.json @@ -7,5 +7,6 @@ "ui_slider": "uiSlider", "ui_switch": "uiSwitch", "ui_text": "uiText", - "ui_text_input": "uiTextInput" + "ui_text_input": "uiTextInput", + "ui_chart": "uiChart" } diff --git a/transformers/nodes/ui-chart.js b/transformers/nodes/ui-chart.js new file mode 100644 index 0000000..9794ba0 --- /dev/null +++ b/transformers/nodes/ui-chart.js @@ -0,0 +1,42 @@ +module.exports = function (node, baseId, themeId) { + node.type = 'ui-chart' + + // update properties + // NONE + node.xAxisFormatType=node.xformat + node.showLegend=node.legend + // new properties + node.category="topic" + node.categoryType="msg" + node.xAxisLabel="" + node.xAxisFormat="" + node.xAxisProperty="", + node.xAxisPropertyType="property" + node.xAxisType="time" + node.yAxisLabel="", + node.yAxisProperty="", + node.textColor=["#666666"] + node.textColorDefault=true + node.gridColor=["#e5e5e5"] + node.gridColorDefault=true + node.action="append" + node.stackSeries=false + node.pointShape="circle" + node.pointRadius=4 + + // remove properties + delete node.dot + delete node.useUTC + delete node.useDifferentColor + delete node.interpolate + delete node.nodata + delete node.cutout + delete node.useOneColor + delete node.outputs + //remove old properties + delete node.xformat + delete node.legend + + return node +} + From 87cf92cc2bd96a3ba55af999602a669f5f648380 Mon Sep 17 00:00:00 2001 From: kd9lsv Date: Tue, 24 Sep 2024 22:08:33 -0500 Subject: [PATCH 2/5] Add objects to test flow. --- tests/flows/basic-layout-after.json | 57 ++++++++++++++++++++++++++++ tests/flows/basic-layout-before.json | 45 ++++++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/tests/flows/basic-layout-after.json b/tests/flows/basic-layout-after.json index 6b64e84..fa8f536 100644 --- a/tests/flows/basic-layout-after.json +++ b/tests/flows/basic-layout-after.json @@ -230,6 +230,63 @@ [] ] }, + { + "id": "1831c1945f33a193", + "type": "ui-chart", + "z": "b210791026f9bf3f", + "group": "856a31bba370e7fc", + "name": "My Favorite Chart", + "label": "My Favorite Chart", + "order": 4, + "chartType": "line", + "category": "topic", + "categoryType": "msg", + "xAxisLabel": "", + "xAxisProperty": "", + "xAxisPropertyType": "property", + "xAxisType": "time", + "xAxisFormat": "", + "xAxisFormatType": "HH:mm:ss", + "yAxisLabel": "", + "yAxisProperty": "", + "ymin": "", + "ymax": "", + "action": "append", + "stackSeries": false, + "pointShape": "circle", + "pointRadius": 4, + "showLegend": true, + "removeOlder": 1, + "removeOlderUnit": "3600", + "removeOlderPoints": "", + "colors": [ + "#0095ff", + "#ff0000", + "#ff7f0e", + "#2ca02c", + "#a347e1", + "#d62728", + "#ff9896", + "#9467bd", + "#c5b0d5" + ], + "textColor": [ + "#666666" + ], + "textColorDefault": true, + "gridColor": [ + "#e5e5e5" + ], + "gridColorDefault": true, + "width": 6, + "height": "4", + "className": "", + "x": 760, + "y": 160, + "wires": [ + [] + ] + }, { "id": "856a31bba370e7fc", "type": "ui-group", diff --git a/tests/flows/basic-layout-before.json b/tests/flows/basic-layout-before.json index 5efea68..3f1452d 100644 --- a/tests/flows/basic-layout-before.json +++ b/tests/flows/basic-layout-before.json @@ -223,6 +223,51 @@ [] ] }, + { + "id": "58d1200d4648ff7b", + "type": "ui_chart", + "z": "b210791026f9bf3f", + "d": true, + "name": "My Favorite Chart", + "group": "856a31bba370e7fc", + "order": 3, + "width": 6, + "height": 4, + "label": "My Favorite Chart", + "chartType": "line", + "legend": "false", + "xformat": "HH:mm:ss", + "interpolate": "linear", + "nodata": "", + "dot": false, + "ymin": "", + "ymax": "", + "removeOlder": 1, + "removeOlderPoints": "", + "removeOlderUnit": "3600", + "cutout": 0, + "useOneColor": false, + "useUTC": false, + "colors": [ + "#1f77b4", + "#aec7e8", + "#ff7f0e", + "#2ca02c", + "#98df8a", + "#d62728", + "#ff9896", + "#9467bd", + "#c5b0d5" + ], + "outputs": 1, + "useDifferentColor": false, + "className": "abcd", + "x": 550, + "y": 160, + "wires": [ + [] + ] + }, { "id": "856a31bba370e7fc", "type": "ui_group", From 3e26a3d38e546676d8b7b2004eaf533532eb2962 Mon Sep 17 00:00:00 2001 From: Connor Dickey Date: Tue, 24 Sep 2024 22:20:13 -0500 Subject: [PATCH 3/5] Add UI Chart to Test --- tests/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/index.js b/tests/index.js index 5f6a8e1..1841792 100644 --- a/tests/index.js +++ b/tests/index.js @@ -205,6 +205,20 @@ describe('Dashboard Migration Script', function () { }) }) + describe('UI Chart', function () { + const chart = utils.getByType(migratedFlow, 'ui-chart')[0] + const chart1 = utils.getByType(basicLayoutAfter, 'ui-chart')[0] + + const excludeFromChecks = ['id', 'group'] + Object.keys(chart).forEach((prop) => { + if (!excludeFromChecks.includes(prop)) { + it('should set ' + prop + ' correctly ', function () { + chart[prop].should.eql(chart1[prop]) + }) + } + }) + }) + describe('Unsupported UI Nodes:', function () { it('should should be disabled in the NR Editor', function () { const template0 = utils.getByType(migratedFlow, 'ui_template')[0] From 6eb62923dee2f8b8dc1ff3fa98255deac9309efc Mon Sep 17 00:00:00 2001 From: Connor KD9LSV Date: Tue, 24 Dec 2024 14:43:36 -0600 Subject: [PATCH 4/5] Lint Cleaning --- transformers/index.js | 1 - transformers/nodes/ui-chart.js | 45 +++++++++++++++++----------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/transformers/index.js b/transformers/index.js index 4f4d064..bfcfc82 100644 --- a/transformers/index.js +++ b/transformers/index.js @@ -10,4 +10,3 @@ module.exports = { uiTextInput: require('./nodes/ui-text-input'), uiChart: require('./nodes/ui-chart') } - diff --git a/transformers/nodes/ui-chart.js b/transformers/nodes/ui-chart.js index 9794ba0..02f5425 100644 --- a/transformers/nodes/ui-chart.js +++ b/transformers/nodes/ui-chart.js @@ -3,27 +3,27 @@ module.exports = function (node, baseId, themeId) { // update properties // NONE - node.xAxisFormatType=node.xformat - node.showLegend=node.legend - // new properties - node.category="topic" - node.categoryType="msg" - node.xAxisLabel="" - node.xAxisFormat="" - node.xAxisProperty="", - node.xAxisPropertyType="property" - node.xAxisType="time" - node.yAxisLabel="", - node.yAxisProperty="", - node.textColor=["#666666"] - node.textColorDefault=true - node.gridColor=["#e5e5e5"] - node.gridColorDefault=true - node.action="append" - node.stackSeries=false - node.pointShape="circle" - node.pointRadius=4 - + node.xAxisFormatType = node.xformat + node.showLegend = node.legend + // new properties + node.category = 'topic' + node.categoryType = 'msg' + node.xAxisLabel = '' + node.xAxisFormat = '' + node.xAxisProperty = '' + node.xAxisPropertyType = 'property' + node.xAxisType = 'time' + node.yAxisLabel = '' + node.yAxisProperty = '' + node.textColor = ['#666666'] + node.textColorDefault = true + node.gridColor = ['#e5e5e5'] + node.gridColorDefault = true + node.action = 'append' + node.stackSeries = false + node.pointShape = 'circle' + node.pointRadius = 4 + // remove properties delete node.dot delete node.useUTC @@ -33,10 +33,9 @@ module.exports = function (node, baseId, themeId) { delete node.cutout delete node.useOneColor delete node.outputs - //remove old properties + // remove old properties delete node.xformat delete node.legend return node } - From ae3fecb4cf5153b03a92c2e7c75b1367a87d4393 Mon Sep 17 00:00:00 2001 From: Connor Dickey Date: Sat, 1 Mar 2025 10:08:32 -0600 Subject: [PATCH 5/5] Clean Lint Spacing --- tests/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/index.js b/tests/index.js index a5374ce..7dd2edd 100644 --- a/tests/index.js +++ b/tests/index.js @@ -218,8 +218,7 @@ describe('Dashboard Migration Script', function () { } }) }) - - + describe('UI Number Input', function () { const input = utils.getByType(migratedFlow, 'ui-number-input')[0] const input1 = utils.getByType(basicLayoutAfter, 'ui-number-input')[0]