Newer
Older
This section will allow you to launch a proper local environment of the Ecolyo application
First, clone [Ecolyo](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo)
Install required node modules, open a terminal on the root folder of the project and type the following command:
If the application starts successfully you should obtain the following message:
Once the application is started, run the easy-cozy stack with docker.
:::note If you have an access denied issue
`docker login registry.forge.grandlyon.com`
:::
> Everything is setup. Go to http://ecolyo.cozy.tools:8080/
Once successful you can launch your local cozy with following url: [Cozy local url](http://cozy.tools:8080/). The password of this instance is set to *"cozy"* by default.
Local database can also be consulted at the following url: [Cozy local DB](http://localhost:5984/_utils/)
## Use local konnectors
In most case you will use mocked konnectors with mock data, but for some testing goals you will need real accounts.
In local, it is possible to run EGL en SGE-Enedis konnectors, with real accounts, but it needs some specific manipulation as well as you'll need to use api secrets that are, of course, basically not available in the project. If you need to use konnectors with real accounts in testing goals, please follow the following steps. Otherwise, refer to the next two sections 'Import Mock Data' et 'Simulate konnector connections'.
First step, make sure your stack is running. Then open your [CouchDB](http://localhost:5984/_utils/) and look for the `secrets/io-cozy-account_types` entry.
Then add a new document like this :
EGL Example
{
"_id": "eglgrandlyon",
"grant_mode": "secret",
"slug": "eglgrandlyon",
"secret": {
"eglBaseURL": "******",
"eglAPIAuthKey": "*****"
}
}
```
{
"_id": "enedis-sge-grandlyon",
"grant_mode": "secret",
"slug": "enedis-sge-grandlyon",
"secret": {
"loginUtilisateur": "******",
"wso2BaseUrl": "*****",
"contractId": "*****",
"apiToken": "*****"
}
}
```
You'll need to use konnector slug as is to make it work properly
You can contact an administrator in order to get the proper information to fill in your secret.
Once it is done, you will be able to use these 2 Konnectors with real accounts.
:::warning You might see this message before trying to log with SGE Account
Make sure you have the person's consent to use their PDL number, as it is sensitive data.
Your dev stack should be running to import the mock data
yarn global add cozy-ach
```
Next create the "config.js" file based on the "config.template.js"
:::info You can change the period of data generated by changing the following lines:
```js title="config.js"
const startingDate = DateTime.local()
// highlight-next-line
.plus({ days: -120 })
.startOf('day')
const endingDate = DateTime.local()
.plus({ days: -1 })
.startOf('day')
```
Just replace -120 by the value needed
Next launch the script `createDayDataFiles.js` available into the `scripts` folder
Json files with data will be created into `scripts/data` folder.
ACH script `importData.bat` will load the content of the file into your CouchDB (database of your dev stack). Launch it using following commands:
```sh
cd scripts
./importData.sh
```
If you cannot execute `ACH` after this command, it may be because you do not have the directory where yarn stores its symbolic links in your `PATH`. Edit it to append the result of `yarn global bin` by executing the following command:
```sh
export PATH="$PATH:`yarn global bin`"
```
You'll be prompted for a **cozysessid**, you can get it in the web console : in the `application` tab, look for the cookies and just copy the cozysessid value.
A new browser windows will open and asking you approval to import data. Just click on **Approve**
Finally your data is loaded in the Ecolyo Application !
## Simulate konnectors connection
Your dev stack should be running to import data needed to simulate konnectors connection
When using local environment, konnectors are not able to connect as in production.
To simulate the connection you can use the script **createConnection.js** available in **scripts** folder.
First update the authorization and cookie information from the "config.js" file (if not created just create it from the "config.template.js" file):
const authorization = 'Bearer xxxxxxxxxxx';
const cookie = 'cozysessid=xxxxxxxxxxx';
To obtain your own Bearer and cozysessid you need to have the application launched and display the web console (F12) in your navigator and select the **Network tab**. Just select one request and retrieve information for Request Header:
Your data is now loaded and you can refresh the application to see your konnector connected.