Clone external Json?

I guess this is not possible, but I was wondering if there is a way to use a external json as content of the clone container (or any applicable container as a panel)
Reason is, its difficult for two people or more work simultaneously in the same json and if new content is being added only one person can edit at same time or it is needed merges.
Instead if we use a container that his content makes reference to a external json and fill the content of the container, this could be avoided.
For example the container could contain 30 sound buttons that are stored in a external json and changed in any moment without modifying the main file, as that container only makes reference to that external file. The buttons simply need to be in a space that fits the main window (if we don’t want scroll bars)
I guess, as a web page, you want to have sometimes the pages separated in different files etc to avoid becoming all centralized in a single file.
I notice a post that suggest a relation with this, but to be honest I don’t understand it. What I suggesting here is display in a container a external json file.

I created a ticket for this.

1 Like

Thanks. It quite difficult to collaborate several people in the same file. We need to update the content frequently it’s super easy to overwrite the work of others.

I forgot to mention it’s already possible to achieve what you describe using a custom module:

var widgetData = loadJSON('widget-data.json')

app.on('sessionOpened', function(data, client) {

    receive('/EDIT', 'widget_id', JSON.stringify(widgetData), {clientId: client.id})

})

Resources:

1 Like

Thanks
I have created test file called “testme”. Then I have added a panel in that file called “testpanel”
Added these lines for testing to panels, clones and tabs but none seem to work. Not sure what to modify/add appart of the name of the file and widget. The testme.json is located in the root of the “load” open stage control config and as relative path

var widgetData = loadJSON(‘testme.json’)

app.on(‘sessionOpened’, function(data, client) {

receive('/EDIT', 'testpanel', JSON.stringify(widgetData), {clientId: client.id})

})

Oh that is really great, thank you for this example, exactly what i needed!! :slight_smile:

i successfully managed to get key/values pairs of a nested object.

Object.keys(widgetData.session.tabs[5].widgets[15].widgets[1].widgets[1].values).forEach(function (key) {
var valuess = widgetData.session.tabs[5].widgets[15].widgets[1].widgets[1].values[key];
});
// on tab 6 on panel widget nr.15 get modal widget with nr.1 the witch widget with number 1 the key value pairs
-> i don’t managed to get theses by name… how to do that ?

And i couldn’t get the widget alone, just the whole session ???

in my case i have not to deal with different clients, i left out the clientid (i am pretty sure you have to fill in a valid client id, not the example code)

And where I can find the client.id? I mean, I simply cloning another json, Im running one client only (if client means an opened OpenStageControl file). And even so I don’t know where the client.id appears as I don’t see anything related to that in the Open Stage Control config-log screen

i guess it should be:
if you start a browser like this
http://server-ip:port?id=12345

you can service this client with id 12345 other than client xxxx ?
maybe to react on different client resolution, etc. etc.

No difference, that is simply the ip of the computer Im running both server and client.
Added to a panel and also a clone container and a tab

oh you use it in the css property!
It does not work in a css property (i successfully managed to get it in a custom module, in my case i left out clientid as whole)

If you mean this, it doesn’t work either :open_mouth:

yes, i just gave it a try and edited my previous post.

And where you add custom modules? I know there is a help section about it but not idea if it is a external file or a code you add in the json (and where on it)

when you start the server, you have it clearly labeled, you just need to make an *.JS file and load it.

Start with the minimal skeleton, and write your code above it.

module.exports = {

init: function(){
    // this will be executed once when the osc server starts
},

oscInFilter:function(data){
    // Filter incoming osc messages

    var {address, args, host, port} = data

    // do what you want

    // address = string
    // args = array of {value, type} objects
    // host = string
    // port = integer

    // return data if you want the message to be processed
    return {address, args, host, port}

},

oscOutFilter:function(data){
    // Filter outgoing osc messages

    var {address, args, host, port, clientId} = data

    // same as oscInFilter

    // return data if you want the message to be and sent
    return {address, args, host, port}
}

}

Thanks for clarifying the custom module part @abstrus. Just to be clear, in the example I gave the client id usage works as is and aims to only send the widget data to the client that loaded the session (as opposed to sending the data to every connected client even if the data has already been sent to it).

@jean-emmanuel as stated 2 posts down, i can’t get just the json from one widget, but of the whole session, is this also doable here ? (way to much data…)

It seems you got close ! In your example widgetData.session.tabs[5].widgets[15].widgets[1].widgets[1] contains the widget’s data.

yes i made it down the road, but that gives me the whole session json, do i need to use ‘/edit/get’ here to get just one widgets values object , or just ‘/get’ ?

What gives you the whole session exactly ?