Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ 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_led` - converted to Dashboard 2.0's `ui-led`. This is not a core node, but can be installed through the [Node-RED Palette Manager](https://flows.nodered.org/node/@flowfuse/node-red-dashboard-2-ui-led)
- `ui_numeric` - converted to Dashboard 2.0's `ui-numeric-input`

### Config Nodes

- `ui_tab` - converted to Dashboard 2.0's `ui-page`
Expand Down
94 changes: 63 additions & 31 deletions tests/flows/basic-layout-after.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,38 +231,70 @@
]
},
{
"id": "940a12ce19bf2212",
"type": "ui-number-input",
"z": "94d6d107f1742efb",
"name": "",
"label": "numeric",
"tooltip": "",
"group": "f663864dda246564",
"order": 13,
"width": 0,
"height": 0,
"passthru": true,
"topic": "topic",
"topicType": "msg",
"min": 0,
"max": 10,
"step": 1,
"className": "",
"x": 320,
"y": 440,
"wires": [
[
"id": "71985e85957f8be3",
"type": "ui-led",
"z": "78ee589ecd091670",
"name": "My Led",
"group": "f663864dda246564",
"order": 8,
"width": 0,
"height": 0,
"label": "My Led",
"labelPlacement": "left",
"labelAlignment": "left",
"states": [
{
"value": "false",
"valueType": "bool",
"color": "#ff0000"
},
{
"value": "true",
"valueType": "bool",
"color": "#00ff00"
}
],
"allowColorForValueInMessage": false,
"shape": "circle",
"showBorder": true,
"showGlow": true,
"x": 990,
"y": 200,
"wires": []
},
{
"id": "940a12ce19bf2212",
"type": "ui-number-input",
"z": "94d6d107f1742efb",
"name": "",
"label": "numeric",
"tooltip": "",
"group": "f663864dda246564",
"order": 13,
"width": 0,
"height": 0,
"passthru": true,
"topic": "topic",
"topicType": "msg",
"min": 0,
"max": 10,
"step": 1,
"className": "",
"x": 320,
"y": 440,
"wires": [
[

]
],
"sendOnBlur": true,
"sendOnEnter": true,
"clearable": false,
"icon": "",
"iconPosition": "left",
"iconInnerPosition": "inside",
"spinner": "default"
},
]
],
"sendOnBlur": true,
"sendOnEnter": true,
"clearable": false,
"icon": "",
"iconPosition": "left",
"iconInnerPosition": "inside",
"spinner": "default"
},
{
"id": "856a31bba370e7fc",
"type": "ui-group",
Expand Down
33 changes: 33 additions & 0 deletions tests/flows/basic-layout-before.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,39 @@
]
},
{
"id": "ddca2be4bd1c8726",
"type": "ui_led",
"z": "78ee589ecd091670",
"order": 8,
"group": "856a31bba370e7fc",
"width": 0,
"height": 0,
"label": "My Led",
"labelPlacement": "left",
"labelAlignment": "left",
"colorForValue": [
{
"color": "#ff0000",
"value": "false",
"valueType": "bool"
},
{
"color": "#00ff00",
"value": "true",
"valueType": "bool"
}
],
"allowColorForValueInMessage": false,
"shape": "circle",
"showGlow": true,
"name": "My Led",
"x": 990,
"y": 200,
"wires": [
[]
]
},
{
"id": "b52c292d531874a6",
"type": "ui_numeric",
"z": "94d6d107f1742efb",
Expand Down
13 changes: 13 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ describe('Dashboard Migration Script', function () {
}
})
})
describe('UI LED:', function () {
const input = utils.getByType(migratedFlow, 'ui-led')[0]
const input1 = utils.getByType(basicLayoutAfter, 'ui-led')[0]

const excludeFromChecks = ['id', 'group']
Object.keys(input).forEach((prop) => {
if (!excludeFromChecks.includes(prop)) {
it('should set ' + prop + ' correctly ', function () {
input[prop].should.eql(input1[prop])
})
}
})
})

describe('UI Switch:', function () {
const swtch = utils.getByType(migratedFlow, 'ui-switch')[0]
Expand Down
1 change: 1 addition & 0 deletions transformers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ module.exports = {
uiSwitch: require('./nodes/ui-switch'),
uiText: require('./nodes/ui-text'),
uiTextInput: require('./nodes/ui-text-input'),
uiLed: require('./nodes/ui-led'),
uiNumeric: require('./nodes/ui-numeric')
}
1 change: 1 addition & 0 deletions transformers/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"ui_switch": "uiSwitch",
"ui_text": "uiText",
"ui_text_input": "uiTextInput",
"ui_led" : "uiLed",
"ui_numeric": "uiNumeric"
}
13 changes: 13 additions & 0 deletions transformers/nodes/ui-led.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = function (node, baseId, themeId) {
node.type = 'ui-led'

// update properties
node.states = node.colorForValue

// new properties
node.showBorder = true

// remove properties
delete node.colorForValue
return node
}
Loading