Fragments exporting/importing

Just want to check I'm understanding this right.

  1. Create a panel of buttons and export.

image

  1. Custom module
var widgetData = loadJSON('export.json')

app.on('sessionOpened', (data,client)=>{
    receive('/EDIT', 'import_panel', JSON.stringify(widgetData), {clientId: client.id})
    })
  1. On opening the session, my panel changes itself to fragment

image

and the debug shows it has imported something

image

Unfortunately the panel of buttons does not appear, so I must be doing something wrong.

That's no how you're supposed to load a fragment (the intended way is to use a fragment widget). If you really want to do it that, then you must use widgetData.content

Ok, thanks for your reply. I must say I don't really understand this then:

https://openstagecontrol.discourse.group/t/clone-external-json/

Has this become outdated now? It seems it converts any container to a fragment.

It's partly outdated, session files and fragment files now hold the widget data in the "content" key (it used to be "session" before 1.9).

Hello @jean-emmanuel,

As I read this, I wonder what the best solution is for me for the following question:

I have a big jsfile (30000 lines) that loads instruments articulations and synth UI depending on the incoming midicc input.
I use this syntax in the js file :

if (args[1].value == 116 && args[2].value == 16) 
{ receive('/EDIT', 'UI_widget,{
      "widgets": [
        { "type": "panel", all my data widget............

I would like to split it into several files to be able to navigate and edit each instrument more easily.
something like : UI_synth1.json, UI_synth2.json ...etc

I misunderstand the documentation.
Should I use Fragment files or Fragment widgets?
... and as you wrote "It's partly outdated"...
What command should I use to call a specific external file in a js to populate my widget?

Hi, I made test with this but nothing append... :thinking:
Is this code ok and the var widgetData in the right place ?

if (args[1].value == 116 && args[2].value == 16) 
      {
var widgetData = loadJSON('UI_synth1.json')
app.on('sessionOpened', function(data, client) {
    receive('/EDIT', 'UI_widget', JSON.stringify(widgetData), {clientId: client.id})

})

Using loadJSON is correct ! But you should do it only once at the beginning of your file and it doesn't make sense to bind app's sessionOpened in the the oscInFilter function (this should be done once at the beginning of the file as well).

Thank you for your answer @jean-emmanuel
I may have phrased my question incorrectly...
if I put the var at the beginning of the file :

var widgetData = loadJSON('UI_synth1.json')
var widgetData = loadJSON('UI_synth2.json')
...etc

How do I recall them in my export module according to the conditions?

module.exports = {  
    oscInFilter:function(data)
	{
if (args[1].value == 116 && args[2].value == 16) 
      {receive('/EDIT', 'UI_widget', // How to reference UI_synth1.json here to populate UI_widget ??? )
return 
       }
else if (args[1].value == 116 && args[2].value == 4)
{receive('/EDIT', 'UI_widget', // How to reference UI_synth2.json here to populate UI_widget ??? 
)return 
        }
else if....

Solved for me with this :

at the beginning of .js

var FM8Panel = loadJSON('./panels/FM8.json')
var absynthPanel = loadJSON('./panels/absynth.json')
etc...

and in module.exports

if (args[1].value == 116 && args[2].value == 1) 
      { receive('/EDIT', 'UI_Panel', JSON.stringify(FM8Panel.content)).....

if (args[1].value == 116 && args[2].value == 2) 
      { receive('/EDIT', 'UI_Panel', JSON.stringify(absynthPanel.content))....
etc....
1 Like