From b0117b5b0a41dc989bf724371a0d58c204260473 Mon Sep 17 00:00:00 2001 From: Connor KD9LSV Date: Mon, 23 Dec 2024 16:26:51 -0600 Subject: [PATCH 1/3] Update Audio Control --- README.md | 4 ++-- transformers/index.js | 3 ++- transformers/map.json | 4 +++- transformers/nodes/ui-audio.js | 21 +++++++++++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 transformers/nodes/ui-audio.js 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/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..74c0c13 --- /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 +} From dbd0aa74364c0f08f26dbf37888093f701a1b7e8 Mon Sep 17 00:00:00 2001 From: Connor KD9LSV Date: Tue, 24 Dec 2024 14:42:08 -0600 Subject: [PATCH 2/3] Lint Clean --- transformers/nodes/ui-audio.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/transformers/nodes/ui-audio.js b/transformers/nodes/ui-audio.js index 74c0c13..fc87f45 100644 --- a/transformers/nodes/ui-audio.js +++ b/transformers/nodes/ui-audio.js @@ -3,15 +3,15 @@ module.exports = function (node, baseId, themeId) { // update properties // NONE - node.autoplay=node.always + node.autoplay = node.always // new properties - node.loop="off" - node.muted="off" - node.src="" - node.order=0 - node.width=0 - node.height=0 + node.loop = 'off' + node.muted = 'off' + node.src = '' + node.order = 0 + node.width = 0 + node.height = 0 // remove properties // NONE From fac38e2df35921b891ea6c6d65fc39ad7468bce0 Mon Sep 17 00:00:00 2001 From: Connor Dickey Date: Fri, 10 Jan 2025 09:39:15 -0600 Subject: [PATCH 3/3] Add Test Parameters --- tests/flows/basic-layout-after.json | 19 +++++++++++++++++++ tests/flows/basic-layout-before.json | 12 ++++++++++++ tests/index.js | 14 ++++++++++++++ 3 files changed, 45 insertions(+) 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]