oda-hub / frontend-tab-generator

0 stars 0 forks source link

Load fits file when passed from URL #47

Closed burnout87 closed 1 month ago

burnout87 commented 2 months ago

As discussed with Marco, for photoz, this would also be usefule.

so the user can make up the list of filters starting from a fits file, that can not only be read from once loaded as a file, but also if provided as a URL.

burnout87 commented 2 months ago

An idea would be to have a "reload" button next to the URL input textfield that basically tries to download the file.

What do you think?

burnout87 commented 2 months ago

The result would be something like that

image

dsavchenko commented 2 months ago

The functionality of this button is not clearly evident, at least a tooltip is needed, I guess, stating something like "Get list of columns". There is no need to download a whole file, but just a header. Does the lib of @francoismg support this mode? The original one had something like this

burnout87 commented 2 months ago

A more appropriate button is now added to the url textfield for the link to the fits file

2024:08:28:12:23:52

dsavchenko commented 2 months ago

Nice, it's now more evident. Another two alternatives that come to mind are "down arrow" button icon or a button on the level of filters table fields.

burnout87 commented 2 months ago

While testing I managed to load few times a fits file using its url, but very weirdly, it's not always working.

The majority of the time I get the header "Access-Control-Allow-Origin" is missing.

And I tried with different urls...any ideas @francoismg ?

Thanks

francoismg commented 2 months ago

While testing I managed to load few times a fits file using its url, but very weirdly, it's not always working.

The majority of the time I get the header "Access-Control-Allow-Origin" is missing.

And I tried with different urls...any ideas @francoismg ?

Thanks

When you say "not always working" and "tried with different urls" do you mean that it's consistently working for some urls and always failling for others? or that some urls are sometimes working and sometimes failling?

If it's the first one and given the "access control allow origin" thing it seems like a cors issue but maybe I'm missing something.

When I was serving fits files in php and accessing them with remote javascript I had to do something like this header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");

Does that make sense or am I missing something?

burnout87 commented 2 months ago

When you say "not always working" and "tried with different urls" do you mean that it's consistently working for some urls and always failling for others?

yes

I tested even further and it seems like that certain urls return this message, but if I try to download the file via another way (browser, wget) then I can download the file without any issue.

When I was serving fits files in php and accessing them with remote javascript I had to do something like this header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");

But this is something you were doing on the php side right ?

Then it simply might be an issue on the side that serves the file

francoismg commented 2 months ago

I tested even further and it seems like that certain urls return this message, but if I try to download the file via another way (browser, wget) then I can download the file without any issue.

cors policies are only enforced by the browser on the js side so if you use something "external" like wget or if you directly use the url in the browser like any normal link it will work fine

But this is something you were doing on the php side right ?

Then it simply might be an issue on the side that serves the file

yes you have to set the header on the server side

it's not really an issue in itself it's more like standard cors behavior, if you want to bypass that for user provided urls (if I understand your previous screenshot correctly) you will have to use your backend as some kind of man in the middle proxy server to load the url content from your server and then stream it to your js code (there's also free third party services that offer that)

burnout87 commented 2 months ago

Thanks for your help @francoismg .

With https://github.com/oda-hub/dispatcher-app/pull/708 there will be a dedicated restful endpoint in charge of requesting the fits file using its url, and returning the content back to the frontend, which will then process the content the same way it processes a file input by the user.