Closed NicolasCARPi closed 1 year ago
Hi Nicolas,
I am a member of the NMRium team but not a developer. Some methods of simply opening Files in NMRium via URL are described here: Loading files from URL.
Maybe that already helps in what you are trying?
Kind regards, Johannes Liermann
@NicolasCARPi If the documentation is not clear just tell us but it should be relatively straightforward.
Thank you. The problem with that approach is that your server needs to access the content via URL, and most of the time eLab is installed on the internal network and cannot be accessed from outside. That's why having the possibility to directly insert content in the URL would solve this problem.
Example of such service: link to json crack with all data in URL
I really like that you considered privacy and added the URL in the hash/anchor part of the URL. :+1:
There are also issues with CORS policy.
If you can already fetch JSON, I believe it would be trivial to directly interpret JSON, maybe with a rawjson
parameter, or detect if the value starts with http to determine if it needs to be fetched. What do you think?
@NicolasCARPi
As a temporary solution, you can use this project https://github.com/NFDI4Chem/nmrium-react-wrapper which works as a wrapper for the NMRium, you can use the iframe to embed the NMrium (https://nmrium.nmrxiv.org/), and contact with the NMrium by custom event
yourIframe.contentWindow.postMessage({ type: 'nmr-wrapper:load', {
data: [File1,File2, ..... File n],
type: "file"
}}, '*');
Hope this solves your problem.
That's why having the possibility to directly insert content in the URL would solve this problem.
I'm not sure that's really feasible. For example, Chrome limits the length of the URL to 2MB and Safari to 80'000 characters.
Thank you. The problem with that approach is that your server needs to access the content via URL, and most of the time eLab is installed on the internal network and cannot be accessed from outside. That's why having the possibility to directly insert content in the URL would solve this problem.
It is not the server that needs to access the data but the client. All the data are processed in NMRium on the client.
@hamed-musallam , thanks I'll look into that. My app uses Docker, so maybe having an nmrium docker side process could be a solution here. But that's not my preference.
I'm not sure that's really feasible. For example, Chrome limits the length of the URL to 2MB and Safari to 80'000 characters.
I do not support Safari, and 2 Mb is already quite a lot, no? How big are typical files? Also, it would be easy to propose the link for smaller files and not big ones, or display a message that the user needs to upload it manually.
It is not the server that needs to access the data but the client
I see. So one issue is with CORS. Your examples from the doc work because the response headers contain access-control-allow-origin: *
. Which is not something I'd want to add to my responses.
Another issue is that even if this CORS setting is added, the request is blocked by the login page because cookies are not sent (SameSite attribute is set to Lax). And again, that's not something I can change without impacting security.
So I still think having the possibility to directly encode the file in the URL would be a good help. I currently don't see other approaches that would work.
@NicolasCARPi
As far as I know, I'm afraid to say that the 2 MB is not enough, for example, if we have a single spectrum (1H) and export it as JSON, The size of the JSON is more than 2.3 MB which is not constant and it changes based on the experiment.
A jcamp-dx for 1D is ok and we could check how to implement this on www.nmrium.org
It is now possible to have the link in the URL. The documentation is available here:
https://docs.nmrium.org/for-developers/using-nmrium#loading-an-inline-jcamp-dx
@lpatiny This is great and I have added a button to load into NMRium when the uploaded file is .jdx:
Seems to work fine on the test file I have. :tada:
Are there other extensions/file formats that could be loaded this way?
Great ! For the extensions the other file format are binaries or a zip file containing many files so you should check what you have for NMR spectra in your database.
Hello,
I am the lead dev of eLabFTW, an electronic lab notebook.
In my software, users can attach files to their experimental results. I'm thinking it would be great to:
What do you think about this workflow and is it something that would be feasible?
The other option would be to integrate nmrium into eLabFTW but I honestly don't want to add all the required dependencies into the software, I'd rather use an external service for that.
Best, ~Nico