diff --git a/README.md b/README.md index 34e74a7..f815b5f 100644 --- a/README.md +++ b/README.md @@ -19,7 +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_audio` - converted to Dashboard 2.0's `ui-audio` + - `TTS` is not supported ### Config Nodes - `ui_tab` - converted to Dashboard 2.0's `ui-page` @@ -37,7 +38,6 @@ Please note that this script does not cover everything, see below for a list of - `ui_colour_picker` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/23) - `ui_gauge` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/26) - `ui_chart` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/27) -- `ui_audio` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/28) - `ui_toast` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/29) - `ui_control` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/30) - `ui_template` - [link](https://github.com/FlowFuse/node-red-dashboard-2-migration/issues/31) diff --git a/tests/flows/basic-layout-after.json b/tests/flows/basic-layout-after.json index 6b64e84..48744fa 100644 --- a/tests/flows/basic-layout-after.json +++ b/tests/flows/basic-layout-after.json @@ -230,6 +230,25 @@ [] ] }, + { + "id": "d640dcf00ab9a978", + "type": "ui-audio", + "z": "94d6d107f1742efb", + "group": "b191960874c7c44e", + "name": "My Audio Out", + "order": 1, + "width": 0, + "height": 0, + "src": "", + "autoplay": "", + "loop": "off", + "muted": "off", + "x": 340, + "y": 80, + "wires": [ + [] + ] + }, { "id": "856a31bba370e7fc", "type": "ui-group", diff --git a/tests/flows/basic-layout-before.json b/tests/flows/basic-layout-before.json index 5efea68..6f4f8c6 100644 --- a/tests/flows/basic-layout-before.json +++ b/tests/flows/basic-layout-before.json @@ -223,6 +223,18 @@ [] ] }, + { + "id": "199ff7a2c674e737", + "type": "ui_audio", + "z": "94d6d107f1742efb", + "name": "My Audio Out", + "group": "856a31bba370e7fc", + "voice": "urn:moz-tts:sapi:Microsoft David - English (United States)?en-US", + "always": "", + "x": 340, + "y": 80, + "wires": [] + }, { "id": "856a31bba370e7fc", "type": "ui_group", diff --git a/tests/index.js b/tests/index.js index 5f6a8e1..14c3461 100644 --- a/tests/index.js +++ b/tests/index.js @@ -205,6 +205,20 @@ describe('Dashboard Migration Script', function () { }) }) + describe('UI Audio:', function () { + const input = utils.getByType(migratedFlow, 'ui-audio')[0] + const input1 = utils.getByType(basicLayoutAfter, 'ui-audio')[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('Unsupported UI Nodes:', function () { it('should should be disabled in the NR Editor', function () { const template0 = utils.getByType(migratedFlow, 'ui_template')[0] diff --git a/transformers/index.js b/transformers/index.js index 7a54aae..733ac8d 100644 --- a/transformers/index.js +++ b/transformers/index.js @@ -7,5 +7,6 @@ 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'), + uiAudio: require('./nodes/ui-audio') } diff --git a/transformers/map.json b/transformers/map.json index 53eb2cb..dd4f9fc 100644 --- a/transformers/map.json +++ b/transformers/map.json @@ -7,5 +7,7 @@ "ui_slider": "uiSlider", "ui_switch": "uiSwitch", "ui_text": "uiText", - "ui_text_input": "uiTextInput" + "ui_text_input": "uiTextInput", + "ui_audio": "uiAudio" + } diff --git a/transformers/nodes/ui-audio.js b/transformers/nodes/ui-audio.js new file mode 100644 index 0000000..fc87f45 --- /dev/null +++ b/transformers/nodes/ui-audio.js @@ -0,0 +1,21 @@ +module.exports = function (node, baseId, themeId) { + node.type = 'ui-audio' + + // update properties + // NONE + node.autoplay = node.always + + // new properties + node.loop = 'off' + node.muted = 'off' + node.src = '' + node.order = 0 + node.width = 0 + node.height = 0 + + // remove properties + // NONE + delete node.always + + return node +}