Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Audio Control #48

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions tests/flows/basic-layout-after.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions tests/flows/basic-layout-before.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion transformers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
4 changes: 3 additions & 1 deletion transformers/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
"ui_slider": "uiSlider",
"ui_switch": "uiSwitch",
"ui_text": "uiText",
"ui_text_input": "uiTextInput"
"ui_text_input": "uiTextInput",
"ui_audio": "uiAudio"

}
21 changes: 21 additions & 0 deletions transformers/nodes/ui-audio.js
Original file line number Diff line number Diff line change
@@ -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
}