Sample App: File Relations

Started by philippe28, August 06, 2017, 09:19:25 PM

Previous topic - Next topic

philippe28

Playing with "Sample App: File Relations", with a Master image which shows 2 Versions images, the app gives me this result:
id: 55583
Version flags: [1]
Versions: 55583
See attached file. The Versions files have been set through "Refresh Relation..." based on Preferences/Detection rules.
Instead of having the Master id for Versions field I should have the ids of the two Versions files. Am I wrong ?

I've a second related question.
The v1/files/relations documentation says the supported types are: 'masters', 'versions', 'buddies'.
Using 'masters' type on a selected Version image, will I get the id of the Master image ?
Thanks
Philippe

ubacher

There seems to be a problem with the code .
I replaced the code at line 206 with:
                           if (response.files.length > 0) {
                                //console.log('len:'+response.files[0].versions.files.length)
                                for (var x = 0; x < response.files[0].versions.files.length; x++) {
                                    //console.log('id :' + JSON.stringify(response.files[0].versions.files[x].id, null, 2))
                                    if (versions != '') versions += ',';
                                    versions += response.files[0].versions.files[x].id
                                }
                            }

which will give you the list of version ids.

( I had struggled with this before in a script thus I recognized the problem)

Mario

So this is not a problem in the file relations. It's just that the sample script does not output the data Phillipe is looking for?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Mario

Ah, I see. Bug in the sample app.    
Fixed for next version. New code is:


                                var versions = '';
                                response.files.forEach(function(f) {
                                    f.versions.files.forEach(function(v) {
                                        if (versions != '') versions += ',';
                                        versions += v.id;                                       
                                    }, this);
                                }, this);


-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

philippe28

Thanks Mario & Ubacher.
With the patch I can see now the 2 Versions (see attached file). That's also matter to study the language ! :-)
My next step is to try to see the Master of a Version...

philippe28

With some changes in the code to add the Version case, I can get the Version's Master id !
That's great !
Thanks again.