Hi there, I'm the lead developer for https://github.com/balenalabs/balena-sound/.
We have a very rudimentary local ui on the project which was only added as a proof of concept, it let's you manage the device, set dtoverlays and has a volume slider, nothing too fancy so I want to replace it with this awesome device-ui sauce which is basically the same thing but 100x times better, and free of maintenance (at least for me :P). Here is how it looks:
![Screen Shot 2022-03-31 at 16 37 49](https://user-images.githubusercontent.com/3076185/161135865-58470c2f-96e5-439f-a301-82dbca110acb.png)
What problem do you want to solve?
I would love to be able to add custom components to handle application specific logic. At the moment the volume slider is the only custom thing we have but I want to add a lot more. Ideally the component gets added to the sidebar and has it's own page.
What do you think is the correct solution to this problem?
I've been talking to @nucleardreamer about this and we discussed a few options.
We talked about the possibility of allowing users to provide their component in a .vue
file plus some sort of manifest config file, but that presents a lot of problems like you need to rebuild the vue application, you need to consider what extra npm modules the custom component needs, translations, etc. There might be a way forward with this if you extend the device-ui dockerfile, copy over the files, manually install the modules and use something like this https://github.com/FranckFreiburger/vue3-sfc-loader, but it seems to be very complicated approach and error prone. Also this type of solution would mean anyone wanting to add a custom screen would need to write vue code, which reduces the audience.
So we came up with another idea which is adding custom components via iframes. The user would extend the dockerfile and add a configuration file. This can be json, yaml, whatever. The file would contain basic metadata required to add the component to the sidebar, basically a name and a URL to load. Then the app would read this file and add the necessary custom components on the fly.
There is an additional problem with this approach which is that the page we are rendering via iframes might be using API's internal to the device. This is the case in balenaSound for example. The existing UI uses an API that's provided by the sound-supervisor
service. To solve this we could add dynamic routing to the app serving device-ui, some logic that maps requests that come in for instance /audio/volume
would be transformed into http://sound-supervisor:3000/audio/volume
. The specifics of the mappings involved would also need to be provided via config file described previously.
Are you willing to submit a pull request to implement this change?
Sure! And I bet @nucleardreamer is willing to help :P