o2r-project / o2r-UI

User interface for creating and examining Executable Research Compendia (ERC)
https://o2r.uni-muenster.de/
Apache License 2.0
3 stars 5 forks source link

Add support for config.json file #218

Closed nuest closed 3 years ago

nuest commented 3 years ago

We need a way to configure the server endpoint for the production build, too. So in a way similar to the standalone HTML we discussed for OJS today.

Before the build, we had a config.json file, see https://github.com/o2r-project/ansible/blob/master/provisioning/roles/docker-ui/templates/config.json.j2

The values are taken from this configuration file: https://github.com/o2r-project/ansible/blob/master/provisioning/host_vars/ubsvirt148.uni-muenster.de/vars.yml

@NJaku01 @Fmazin Can you please take a look and decide how to proceed? Ideally the values are taken form an external .json file that is loaded into index.html, because that is easier to configure on the server than replacing a chunk within the HTML file (so what we decided @tnier01 will do for the OJS plugin).

If an external config JSON file is possible, maybe that should also be the way then for OJS?

njakuschona commented 3 years ago

I identified a way how we could archive that.. However, it was not possible to create a JSON File. The problem is that until the JS in the HTML loads the JSON File, the React App already crashes. I have created a config.js https://github.com/NJaku01/o2r-UI/blob/ojsVIew/ui/public/config.js, which stays untouched during the build. This file can then be changed. I added already that the Erc Id and ojsView have to be set in this config.js. The config.js is indeed loaded into the index.html.

What are your opinions to this approch?

Full commit overview: https://github.com/NJaku01/o2r-UI/commit/7bd1cbe4f1532eeb18b3a9ad089599193f5c539d

nuest commented 3 years ago

Looks good to me!

tnier01 commented 3 years ago

So is it then the idea that also the OJS plugin only adjusts the values in the config.js, and this script is then loaded by the HTML, i.e. in the OJS galley?

njakuschona commented 3 years ago

Yes, right. In the new build (https://github.com/NJaku01/o2r-UI/releases/download/0.4.0/build.zip) there is a index.html and a config.js. You must include the complete folder and can load the index.html in the OJS galley. You can then adjust the config.js or even replace it completely. However the variables baseUrl, ercURl and title have to be defined.