Commit 90037ed1 authored by Axel Bocciarelli's avatar Axel Bocciarelli
Browse files

Move ICAT+ URL to env

parent ebe8ef9e
#####
# REACT-APP CONFIGURATION
####
EXTEND_ESLINT=true
#####
# PORTAL CONFIGURATION
# For test and production overrides, see `.env.test` and `.env.production`.
# To override one of these variables in development, create a file called `.env.local`.
#####
# ICAT+ SERVER URL
REACT_APP_ICATPLUS_URL=http://localhost:8000
# ICAT+ SERVER URL
REACT_APP_ICATPLUS_URL=https://icatplus.esrf.fr
# ICAT+ SERVER URL
REACT_APP_ICATPLUS_URL=https://icatplus.test
......@@ -27,24 +27,23 @@ Currently, datahub depends on:
## Installation procedure
1. Download the source code from [gitlab](https://gitlab.esrf.fr/icat/E-DataPortal) repository
2. Install dependencies
1. Clone or download the project from [GitLab](https://gitlab.esrf.fr/icat/E-DataPortal)
2. Install the dependencies
```bash
npm install
```
3. Configure datahub app. See this [section](#configuration).
```bash
npm install
```
4. Run the app
3. [Configure the app](#configuration)
4. Start the app
```bash
npm start
```
```bash
npm start
```
# Configuration
Datahub configuration is spread among different files located in the folder **src/config**. These files are:
Datahub configuration is spread among different files located in <kbd>src/config</kbd>. These files are:
- [icat.js](#icatjs) : configure access to the metadata catalogue.
- [icatPlus.js](#icatplusjs) : configure access to the ICAT+ server
......@@ -52,13 +51,14 @@ Datahub configuration is spread among different files located in the folder **sr
- [gui.config.js](#guiconfigjs) : configuration file for the logbook (to be moved to config.js)
- [config.js](#configjs) : UI general configuration of the GUI
Example files for [icat.js](src/config/icat/icat.example.js) and [icatPlus.js](src/config/icat/icatPlus.example.js) are provided and needs to be copied in configuration file:
Some of the configuration options in these files are stored in [environment variables](#environment-variables).
Example file for [icat.js](src/config/icat/icat.example.js) is provided and needs to be copied in configuration file:
You can copy them manually:
You can copy it manually:
```bash
cp src/config/icat/icat.example.js src/config/icat/icat.js
cp src/config/icat/icatPlus.example.js src/config/icat/icatPlus.js
```
or run:
......@@ -67,6 +67,16 @@ or run:
npm run-script configure
```
## Environment variables
Environment variables are loaded automatically from [environment files](https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used) (`.env`, `.env.test`, etc.) Create React App reads the files based on the Node environment (`NODE_ENV`).
The following variable is currently loaded from the environment:
- `REACT_APP_ICATPLUS_URL` - the URL of the ICAT+ server (cf. <kbd>src/config/icatPlus.js</kbd>)
In development, you can override any of the portal variables defined in `.env` by creating a file called `.env.local`. This file will not be committed to version control.
## icat.js
Edit the file **icat.js** with your favorite text editor and set the configuration to access the metadata catalogue following the indications below.
......@@ -123,26 +133,6 @@ export default ICAT;
<!--END configurationICAT -->
## icatPlus.js
Edit the file **icatPlus.js** with your favorite text editor and set the configuration to access the ICAT+ application following the indications below.
<!--START configurationICATPlus -->
```js
/**
* icatPlus.example.js configuration file
*/
var ICATPLUS = {
/** URL of ICAT+ server */
server: 'https://icatplus.esrf.fr',
};
export default ICATPLUS;
```
<!--END configurationICATPlus -->
## techniques.js
The file [techniques.js](src/config/techniques/techniques.js) complements short named techniques as stored in ICAT metadata catalogue. It maps a short name to a description and display settings.
......
......@@ -9,7 +9,7 @@
},
"scripts": {
"build": "npm run configure && react-scripts build",
"configure": "echo 'Copying config/icat/icatPlus.example.js and config/icat/icat.example.js' && cp src/config/icat/icatPlus.example.js src/config/icat/icatPlus.js && cp src/config/icat/icat.example.js src/config/icat/icat.js",
"configure": "echo 'Copying config/icat/icat.example.js' && cp src/config/icat/icat.example.js src/config/icat/icat.js",
"start": "react-scripts start",
"test": "react-scripts test --env=jsdom-fourteen",
"doc": "npm run Readme:ConfigDoc:ICAT && npm run Readme:ConfigDoc:ICAT:ReplaceCodeSection && npm run Readme:ConfigDoc:ICATPlus && npm run Readme:ConfigDoc:ICATPlus:ReplaceCodeSection && npm run Readme:ConfigDoc:Config && npm run Readme:ConfigDoc:Config:ReplaceCodeSection",
......
/**
* icatPlus.example.js configuration file
*/
const ICATPLUS = {
/** URL of ICAT+ server */
server: 'https://icatplus.esrf.fr',
};
export default ICATPLUS;
const ICAT_PLUS = {
/** URL of ICAT+ server */
server: process.env.REACT_APP_ICATPLUS_URL,
};
export default ICAT_PLUS;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment