diff --git a/docs/cozystack/index.md b/docs/cozystack/index.md index 8bb1eac1ae622f6d146496e5f690ad9875733f79..69408c50d82ceba85d450d64fa847c72bb39034d 100644 --- a/docs/cozystack/index.md +++ b/docs/cozystack/index.md @@ -1,8 +1,10 @@ +# Introduction + {: .center} ## What is Cozy-Stack -It is the core server of the Cozy platform. It consists of a single process, *the Cozy stack*. +It is the core server of the Cozy platform. It consists of a single process, *the Cozy stack*. [Full Cozy-Stack documentation here](https://docs.cozy.io/en/cozy-stack/). @@ -10,22 +12,22 @@ The Cozy-Stack is in charge of serving the Web applications users have installed It provides its services through a REST API that allows to: - - create, update, delete documents inside the database; - - authenticate users and client applications; - - send emails; - - launch jobs on the server. Connectors that import data from remote websites are some sort of jobs. Jobs can be one time tasks (sending a message) or periodic tasks. Some jobs, like the connectors, that require executing third party code on the server side, are sandboxed (we use `nsjail` for now). - - … +- create, update, delete documents inside the database; +- authenticate users and client applications; +- send emails; +- launch jobs on the server. Connectors that import data from remote websites are some sort of jobs. Jobs can be one time tasks (sending a message) or periodic tasks. Some jobs, like the connectors, that require executing third party code on the server side, are sandboxed (we use `nsjail` for now). +- … The Cozy-Stack also allows to access the database replication API, allowing to sync documents between the server and local databases, for example in mobile clients. Two authentication methods are available: - - Web applications running on the server get a session token when the user log in; - - OAuth2 for other applications. +- Web applications running on the server get a session token when the user log in; +- OAuth2 for other applications. Feel free to [open an issue](https://github.com/cozy/cozy-stack/issues/new) for questions and suggestions. ## Why we use it ? -Without that stack we are not able to properly interact with all cozy apps and data. That's why we are using it. For local development we are using the official cozy-stack repo with some packaging updates, and for our test env we are using [Easy cozy](../easycozy/index.md) \ No newline at end of file +Without that stack we are not able to properly interact with all cozy apps and data. That's why we are using it. For local development we are using the official cozy-stack repo with some packaging updates, and for our test env we are using [Easy cozy](../easycozy/index.md) diff --git a/docs/cozystack/local.md b/docs/cozystack/local.md index 24c5650ff9531ee52f7d8b018cdad7bffda45b8d..2fa66aa13679cd55d05a346115cb4625bbcccab9 100644 --- a/docs/cozystack/local.md +++ b/docs/cozystack/local.md @@ -1,14 +1,14 @@ -## Local stack +# Local stack  [cozy-stack](https://forge.grandlyon.com/web-et-numerique/llle_project/cozy-stack) -### Why are we cloning the official repo ? +## Why are we cloning the official repo ? Cozy Cloud has chosen to not maintain the official [docker image](https://hub.docker.com/r/cozy/cozy-app-dev) properly. This is why we have a mirroring version of their official repository with some custom docker configuration improving: - + * CouchDB version 3.2.2 -### What changes should be done by cozy in order to upgrade their image ? +## What changes should be done by cozy in order to upgrade their image ? Cozy should upgrade their CouchDB version inside their image. But unfortunately, the base image `debian:stretch-slim` does not support ERLANG/OTP>=19, and CouchDB need at least a version >=20 for their `3.2.2` version, see [official doc](https://docs.couchdb.org/en/stable/whatsnew/3.2.html#id2). @@ -16,7 +16,7 @@ As a consequence they should upgrade their base image to at least `debian:buster That's why we took the shortcut of using an official [CouchDB image](https://hub.docker.com/_/couchdb) -### How to build new version of the stack ? +## How to build new version of the stack ? If we want to build a new stack version it's easy! A manual pipeline has been created. You just need to run the following steps: diff --git a/docs/easycozy/commands.md b/docs/easycozy/commands.md index f8310797d694d8d5615a21461a370aa04ab29361..a6dd012593f5ab1e15e52670309974dc6cbefbfd 100644 --- a/docs/easycozy/commands.md +++ b/docs/easycozy/commands.md @@ -1,6 +1,7 @@ # :computer: Commands This section includes all common commands used on dev environment. These commands should be runned in `easy-cozy` directory. + ```sh cd easy-cozy ``` @@ -34,6 +35,7 @@ $ cd /easy-cozy $ docker-compose exec cozy ./cozy konnectors update grdfgrandlyon --domain "[name].cozy.self-data.alpha.grandlyon.com" grdfgrandlyon has been upgraded to 0.1.5-d4bbe7350ecf13d13734f559c538e3c0ee8dc7ae ``` + ### Run a konnector from the stack ```bash @@ -93,10 +95,11 @@ Update version in the Dockerfile on gitlab. We have replaced debian:stable-slim with ubuntu:20.10 as installer for our docker build: [https://forge.grandlyon.com/pocs/cozy/easy-cozy/-/commit/48a30a03f209169e0f1ebb0d106bb4361e7cd167](https://forge.grandlyon.com/pocs/cozy/easy-cozy/-/commit/48a30a03f209169e0f1ebb0d106bb4361e7cd167) ### Manipulate data + To read/write data from the stack you can run the following commands + ```sh docker-compose exec db curl -u [USER]:[PASSWORD] -X [METHOD] http://127.0.0.1:5984/[DATABASE] ``` :warning: When updating a document, make sure to remove the `_id` and to add `_rev` fields - diff --git a/docs/easycozy/config.md b/docs/easycozy/config.md index 66432856f1eb962992f750ad0c51b505b417a2e4..b8403eebae67a747e99abdd2bdb6efe8faaffb6d 100644 --- a/docs/easycozy/config.md +++ b/docs/easycozy/config.md @@ -1,11 +1,14 @@ -### :gear: Configuration +# Configuration + +## :gear: Configuration This section includes all configurations available for the stack. -#### Configuration File +### Configuration File The stack's configuration file is located at `.easy-cozy/cozystack/cozy.yml`. It can be edited in order to changes various parameters, smtp, logs ... -#### SMTP + +### SMTP Modify the `cozy.yml` responsible for the configuration : @@ -31,6 +34,7 @@ mail: !!! warning "known issue" A known cozy-stack issue [here](https://github.com/cozy/cozy-stack/issues/2009) causes you to have to change the above configuration with: + ```yml mail: # mail smtp port - flags: --mail-port @@ -40,6 +44,7 @@ mail: ``` After updating configuration don't forget to restart your cozy-stack : + ```bash docker-compose restart cozy ``` diff --git a/docs/easycozy/index.md b/docs/easycozy/index.md index cd139e99141c0f0b2e510e8408eb3f3e1d90128c..3be485383e0d4046492ba577f886852a746d37d7 100644 --- a/docs/easycozy/index.md +++ b/docs/easycozy/index.md @@ -1,4 +1,5 @@ -{: .center} +# Introduction +{: .center}  [easy-cozy](https://forge.grandlyon.com/pocs/cozy/easy-cozy) diff --git a/docs/easycozy/known_errors.md b/docs/easycozy/known_errors.md index f356f4075e09fed686c0c755f7c59ada0330846e..46217e2b6ec8acb08b534a7dae9a5cc0112a54ca 100644 --- a/docs/easycozy/known_errors.md +++ b/docs/easycozy/known_errors.md @@ -1,4 +1,6 @@ -### :construction: Oops... +# Known errors + +## :construction: Oops Sometime the stack get stuck when we reset several instances, overflowing our message broker rabbitmq. The following screen is then obtained when trying to access an instance:  @@ -9,7 +11,7 @@ On the server, we can see that the server is underwater by using "top" command: To fix this issue, just restart the service on the server with "docker-compose down / docker-compose up -d" in the easy-cozy folder:  -### Impossible instance delete +## Delete instance impossible When you get this issue after trying to delete instance : @@ -18,9 +20,10 @@ When you get this issue after trying to delete instance : You have to remove it from db, in order to do that follow this steps : 1. Get instance UUID -```sh -docker-compose exec cozy ./cozy instances show-db-prefix --host 0.0.0.0 demo.cozy.self-data.alpha.grandlyon.com -``` + + ```sh + docker-compose exec cozy ./cozy instances show-db-prefix --host 0.0.0.0 demo.cozy.self-data.alpha.grandlyon.com + ``` 2. Connect to database with ssh port forwarding or use curl requests diff --git a/docs/easycozy/scripts.md b/docs/easycozy/scripts.md index 68f6e0cb96dc2e7fce5c70a98b9da15615401c59..53711c87331beb7fb2a2aecd747ae01835c431e4 100644 --- a/docs/easycozy/scripts.md +++ b/docs/easycozy/scripts.md @@ -1,16 +1,13 @@ -### :robot: Scripts +# :robot: Scripts -Easy cozy project comes with 2 main scripts: - -- create-instance.sh: used to create an instance for a user -- remove-instance.sh: used to remove an instance for a specific user - -In addition of these scripts we have added custom scripts for some specific needs. All these scripts are available in the "ecolyo-infra-scripts/admin_scripts" folder +Easy cozy project comes with 2 main scripts available in the `ecolyo-infra-scripts/admin_scripts` folder. ## Scripts for instances | Scripts | Args | Description | |-------------------|-------------------|----------------------------------------------------------| +| create-instance.sh | instance_username | Create an instance for a user | +| remove-instance.sh | instance_username | Remove an instance for a specific user | | reset_instance.sh | instance_username | Remove and recreate again the instance for a given user | ## Scripts for applications @@ -30,4 +27,3 @@ In addition of these scripts we have added custom scripts for some specific need |---------------------------------|-------------------|----------------------------------------------------------------------------------------| | update_enedis_konnector_prod.sh | instance_username | update Enedis konnector with last version from build branch on a specific instance | | update_enedis_konnector_dev.sh | instance_username | update Enedis konnector with last version from build-dev branch on a specific instance | - diff --git a/docs/easycozy/tips.md b/docs/easycozy/tips.md index d64c2c5644b45d9d313c5d519a7ea641e19a3ff7..86faf1cc282108d19509399f9598cad0c736c604 100644 --- a/docs/easycozy/tips.md +++ b/docs/easycozy/tips.md @@ -1,13 +1,11 @@ -### :bulb: Tips +# :bulb: Tips - - -### Query data from an instance +## Query data from an instance For maintenance reason, we sometime need to check data on a specific instance. For that we use postman to send get / post / delete data. All possibility are described in the [data section of Cozy documentation](https://docs.cozy.io/en/cozy-stack/data-system/). -**Example** +### Get example The example will describe how to query userChallenge data from "ecolyotest" instance. First, you need to be able to connect to the instance in order to retrieve the bearer and the cozysessid. @@ -15,6 +13,7 @@ First, you need to be able to connect to the instance in order to retrieve the b  Then use postman to query the data: + ``` Verb: GET Request: https://ecolyotest.cozy.self-data.alpha.grandlyon.com/data/com.grandlyon.ecolyo.userchallenge/_all_docs?include_docs=true @@ -25,7 +24,8 @@ Header: Cookie: cozysessid=xxxxxxxxxxx The result will then be retrieve by postman: -``` + +```json { "total_rows": 1, "offset": 0, @@ -38,26 +38,23 @@ The result will then be retrieve by postman: } ``` - ## Delete a doctype from a instance -You can use ACH to delete a doctype. +You can use ACH to delete a doctype. Please find the [ACH documentation](https://npm.io/package/cozy-ach) to see all commands -**Example** +### Delete example The example will describe how to drop userChallenge doctype from "ecolyotest" instance. the token provided is the one present in the cozysessid. +```sh +ach -t xxxxxxxxxxx -u https://ecolyotest.cozy.self-data.alpha.grandlyon.com drop com.grandlyon.ecolyo.userchallenge ``` -$ ach -t xxxxxxxxxxx -u https://ecolyotest.cozy.self-data.alpha.grandlyon.com drop com.grandlyon.ecolyo.userchallenge -This doctypes will be removed. -* com.grandlyon.ecolyo.userchallenge +The doctype `com.grandlyon.ecolyo.userchallenge` will be removed. Type `yes` to continue. -A browser window will be opened asking for authorization to access to your file. +A browser window will be opened asking for authorization to access to your file. Just click on "Authorize" to keep on with the doctype dropping. - - diff --git a/docs/ecolyo/application/deploy.md b/docs/ecolyo/application/deploy.md index 2b0dcf91cc67bedd8cde134645aa66e7578b1039..29c556a5361a5e44dcc7b5348722e72863deda1e 100644 --- a/docs/ecolyo/application/deploy.md +++ b/docs/ecolyo/application/deploy.md @@ -11,7 +11,7 @@ This section will show you how to deploy your project on different environments. - **build-test**: reflect a temporary build which can be used for test purpose !!! info "Windows users" - Some command did not run on Windows. Please use your Linux distribution installed on your WSL. For more information about it see the [Install WSL section](../getting_started/setup_your_environment.md) + Some command did not run on Windows. Please use your Linux distribution installed on your WSL. For more information about it see the [Install WSL section](../../wsl.md) Make sure that: @@ -20,18 +20,20 @@ Make sure that: - you node modules are up to date First build the application : -``` -$ yarn build + +```sh +yarn build ``` Next you can deploy the build to the target branch: -``` + +```sh # deploy on build-test branch -$ yarn deploy-test +yarn deploy-test # deploy on build-dev branch -$ yarn deploy-dev +yarn deploy-dev # deploy on build branch -$ yarn deploy +yarn deploy ``` ## Auto deploy for dev @@ -58,16 +60,16 @@ For more information you can check for [Easy Cozy scripts](../../../easycozy/com You can deploy content of build branch into Cozy registry by using the cozy-app-publish command after replacing following value: -- $REGISTRY_TOKEN : token provided by Cozy team +- $COZY_TOKEN : token provided by Cozy team - $VERSION_NUMBER: version of the application -- $COZY_SPACE: space of the Cozy +- $COZY_SPACE: space of the Cozy ```sh -$ yarn cozy-app-publish \ ---token $REGISTRY_TOKEN \ +yarn cozy-app-publish \ +--token $COZY_TOKEN \ --build-url https://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo/-/archive/build/ecolyo-build.tar.gz \ --manual-version $VERSION_NUMBER \ --space $COZY_SPACE ``` -More information at [cozy-app-publish](https://docs.cozy.io/en/cozy-app-publish) +More information at [cozy-app-publish](https://docs.cozy.io/en/cozy-app-publish/#manual-usage-not-recommended) diff --git a/docs/ecolyo/application/description.md b/docs/ecolyo/application/description.md deleted file mode 100644 index d8768bb26e67fa0784d7963cc2ffddd5b296f105..0000000000000000000000000000000000000000 --- a/docs/ecolyo/application/description.md +++ /dev/null @@ -1 +0,0 @@ -Ecolyo is a [Cozy](https://docs.cozy.io/en/) application that allows users to connect their energy accounts such as **EGL**, **ENEDIS** and **GRDF**, using cozy [konnectors](https://docs.cozy.io/en/cozy-stack/konnectors/) diff --git a/docs/ecolyo/application/gitflow.md b/docs/ecolyo/application/gitflow.md index 7a1478be94fde39f3403acffbf76152b724b020c..cc96e5ba8cef105ba5dcb3b700442583d530c6f8 100644 --- a/docs/ecolyo/application/gitflow.md +++ b/docs/ecolyo/application/gitflow.md @@ -1,3 +1,5 @@ +# Gitflow + ## Initialize - Create a new project in gitlab and take note of its url @@ -12,19 +14,19 @@ This will prevent anyone to push on the master branch, the only way to add code - Retrieve the project on your computer, open a command line and execute. -``` +```sh git clone https://forge.grandlyon.com/web-et-numerique/llle.git ``` - Create the development branch -``` +```sh git checkout -b dev ``` - Init your project and then type any time you want to commit changes: -``` +```sh git add . git commit -m "Commit changes" git push origin dev @@ -36,7 +38,7 @@ For any other development you should create a branch from the development branch First make sure to be on the **_dev_** branch, type: -``` +```sh git branch ``` @@ -47,26 +49,26 @@ git branch The commit contains the following structural **types**: - fix -- feature +- feat In our team organisation we are using Icescrum to keep track of our User Stories (US). Each US is identified by a number. In order to easily identify the commit that refers to the US, a `feature` branch name should follow this structure: -- _features/<number of the User Story\>-<title_of_the_user_story\>_ +- _feat/USXX-<title_of_the_user_story\>_ You can create the branch by typing: -``` -git checkout -b features/<number of the User Story>-<title_of_the_user_story> +```sh +git checkout -b feat/USXX-<title_of_the_user_story> ``` -> Note that the **feature** type is the only one with a dedicated folder (features/-US). +> Note that the **feat** type is the only one with a dedicated folder (feat/-US). -Each fix branch should be named as the following _fix-\<title_of_the_fix\>_. +Each fix branch should be named as the following _fix/<title_of_the_fix\>_. You can create the branch by typing: -``` -git checkout -b fix-<title_of_the_fix> +```sh +git checkout -b fix/-<title_of_the_fix> ``` **Breaking Change** @@ -76,7 +78,7 @@ Appends a `!` before the title of the commit to notify that a breaking change ha **add tag** -``` +```sh git tag -a 1.0.0 -m "complementary message" ``` diff --git a/docs/ecolyo/application/mail.md b/docs/ecolyo/application/mail.md index df6739f16ee96e1e8ae6342848b6c8cb72301181..5a1b47135398044fd3bfb178dcbbf2a1fc0673fd 100644 --- a/docs/ecolyo/application/mail.md +++ b/docs/ecolyo/application/mail.md @@ -1,6 +1,9 @@ +# Mail + ## Explanation A templating system was needed for the app. In order to make it easy to use and also responsive, two libraries has been used : + - [Handlebars](https://handlebarsjs.com/) - [MJML](https://mjml.io/) @@ -17,9 +20,10 @@ Mails templates can be found inside `src/notifications`. All reusable parts can All stylesheet must be include inside `style.hbs`. ### Create your template -Simply create your template file : `template.hbs` inside the notifications folder. -``` +Simply create your template file `template.hbs` inside the notifications folder. + +```xml <mj-hero background-color="radial-gradient(96.2% 96.2% at 50% 3.8%, #343641 0%, #1B1C22 100%)" padding="17px"> <mj-text align="center" color="white" padding-top="20px" font-size="24px" font-family="Lato" font-weight="normal"> <img style="vertical-align: middle; margin-right: 12px" src="https://ecolyo.com/assets/ecolyo-icon.svg" alt="Ecolyo"/> @@ -34,19 +38,21 @@ Simply create your template file : `template.hbs` inside the notifications folde 1) Import the mjml lib in order to compile the template. -``` +```js import mjml2html from 'mjml' ``` 2) Link all the info mandatory to render your email : -``` - const template = monthlyReportTemplate({ + +```js +const template = monthlyReportTemplate({ title: 'Du nouveau dans votre espace Ecolyo !', }) ``` 3) Build the email and send it: -``` + +```js const mailData = { mode: 'noreply', subject: '[Ecolyo] - Votre bilan mensuel', @@ -61,12 +67,13 @@ import mjml2html from 'mjml' ``` #### Inside the app + It's very similar to service usage, but because we use react, the app rendering is done in the user browser. That's why we need to change the import for mjml lib into : -``` +```js const mjml2html = require('mjml-browser') ``` - ### Useful links + - [Mjml live editor](https://mjml.io/try-it-live/bohYnxKkCq-) diff --git a/docs/ecolyo/application/redux.md b/docs/ecolyo/application/redux.md index bbcdb851e10912277ea208407aaf860d1f9355ce..47b405585b0fff31eb7f70a1e214641440fc49bb 100644 --- a/docs/ecolyo/application/redux.md +++ b/docs/ecolyo/application/redux.md @@ -7,7 +7,7 @@ There are two main store created for this app: For a better state management, combineReducers(reducers) is used to split the reducing function into separate functions. So, each managing independent parts of the state. -### Ecolyo Store Structure +## Ecolyo Store Structure | Reducer | Type | Description | | --------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | @@ -19,7 +19,7 @@ For a better state management, combineReducers(reducers) is used to split the re | modal | ModalState | store opening state of the feedback modal <br><br>ModalState enum<br>- _isFeedbacksOpen = boolean_ | | challenge | ChallengeState | store challenge state such as: list of user challenge, data load and current challenge <br><br>ChallengeState enum<br>- _userChallengeList = UserChallenge[]_<br>- _currentChallenge = UserChallenge_<br>- _currentDataload = Dataload[]_ | -### Updating state process +## Updating state process Redux-thunk middleware is configured. For now, it is used only for updating the profile. To update a state, a webservice method is called before trigger a state change inside the store. diff --git a/docs/ecolyo/application/release.md b/docs/ecolyo/application/release.md index 54eb81abc1bb595fa1b5d76ea07475d0a7b23a29..f01935e20ea277f7248eee2b96bda53b4e860a2d 100644 --- a/docs/ecolyo/application/release.md +++ b/docs/ecolyo/application/release.md @@ -38,14 +38,15 @@ To create a new release, you have to : yarn run release --release-as X.X.X # replace with version number (ex: 1.2.0) ``` -4. once the command has finished, push with +4. once the command has finished, push with -``` +```sh git push --follow-tags origin dev ``` + :warning: Do not push with VS Code -5. Finally, add release notes in gitlab in your project -> repository -> [tags](https://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo/-/tags) -> **edit release notes** +5. Finally, add release notes in gitlab in your [project -> repository -> tags](https://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo/-/tags) -> **edit release notes** You can copy paste the last changes in [CHANGELOG.MD](https://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo/-/blob/dev/CHANGELOG.md) @@ -55,7 +56,7 @@ If you see a bug in the Changelog (the last version doesn't compare without the You can list the annotated tag with the following command -``` +```sh git tag -n ``` @@ -68,7 +69,7 @@ v2.2.0 chore(release): 2.2.0 If you see some mistakes in tag annotation you can change it with the following command : -``` +```sh git tag -a v2.1.3 COMMIT_SHA -m 'chore(release): 2.1.3' -f ``` diff --git a/docs/ecolyo/application/scaffolding.md b/docs/ecolyo/application/scaffolding.md index 1ff32297278a993235b53bae45050e816069af5b..5e605eee8274321f4f3ed3b38d749387e3e86932 100644 --- a/docs/ecolyo/application/scaffolding.md +++ b/docs/ecolyo/application/scaffolding.md @@ -1,6 +1,8 @@ +# Scaffolding + In this section, you will find information about the project file structure and the purpose of the main folders. -##Source Files +## Source Files | Folder/File | Purpose | | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -24,7 +26,7 @@ In this section, you will find information about the project file structure and | types | | utils | In this folder you'll find utilities methods | -##Configuration Files +## Configuration Files | Folder/File | Purpose | | --------------- | ---------------------------------------------------------------------------------------------------------------------- | diff --git a/docs/ecolyo/ecolyo-agent/development/backup.md b/docs/ecolyo/ecolyo-agent/development/backup.md index 26410239bc3845860abd5d3eee91746417519b99..beb421c477075ab47dd9cc92c8cb702fb60a30a8 100644 --- a/docs/ecolyo/ecolyo-agent/development/backup.md +++ b/docs/ecolyo/ecolyo-agent/development/backup.md @@ -1,3 +1,5 @@ +# Backup + ## Principles In the docker-compose.yml, there is a service called "database-backup" whose only purpose is to run automatic backups of the database. @@ -10,9 +12,9 @@ The location of the backup folder on the server is specified in the volumes of t ## Backup manually -To backup manually, run this command : +To backup manually, run this command : -``` +```sh docker exec -it ecolyo-agent_database-backup_1 sh /etc/cron.d/backup.sh ``` @@ -20,6 +22,6 @@ docker exec -it ecolyo-agent_database-backup_1 sh /etc/cron.d/backup.sh To restore a specific dump, run this command replacing YEAR etc.. by the date of the wanted backup : -``` +```sh docker exec -it ecolyo-agent_database-backup_1 sh /etc/cron.d/restore.sh ecolyo-agent-YEAR-MONTH-DAY-HOUR-MINUTE-SECOND -``` \ No newline at end of file +``` diff --git a/docs/ecolyo/ecolyo-agent/development/deploy.md b/docs/ecolyo/ecolyo-agent/development/deploy.md index 81e2d38c831a8c3c9797920a235adee46fb9f31f..97c15daf8587313f9e1bf10f342ac37d1df0e3cc 100644 --- a/docs/ecolyo/ecolyo-agent/development/deploy.md +++ b/docs/ecolyo/ecolyo-agent/development/deploy.md @@ -1,3 +1,5 @@ +# Deploy + This section will allow you to properly deploy Ecolyo-Agent in a production environment ## Deploy Ecolyo-Agent application @@ -6,134 +8,11 @@ To deploy ecolyo-agent application in a production environment, you need to crea ### docker-compose.yml -``` -version: '3.7' -services: - nginx: - image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client:dev - restart: unless-stopped - ports: - - 8080:8080 - depends_on: - - backend - networks: - backoffice: - volumes: - - ./site.conf:/etc/nginx/conf.d/default.conf - - ./image-lib:/usr/share/nginx/html/lib - - database-agent: - image: mysql:5 - ports: - - 3306:3306 - networks: - backoffice: - restart: always - environment: - MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD} - MYSQL_DATABASE: ${DATABASE_NAME} - healthcheck: - test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD - interval: 5s - timeout: 10s - retries: 60 - - database-backup: - image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:db-backup - networks: - backoffice: - environment: - MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD} - MYSQL_DATABASE: ${DATABASE_NAME} - volumes: - - /mnt/local/data/backup:/backup - restart: unless-stopped - depends_on: - database-agent: - condition: service_healthy - - backend: - image: registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server:dev - networks: - backoffice: - depends_on: - database-agent: - condition: service_healthy - restart: unless-stopped - volumes: - - /etc/localtime:/etc/localtime:ro - - ./configs:/app/configs - - ./letsencrypt_cache:/app/letsencrypt_cache - - ./data:/app/data - - ./${IMAGE_FOLDER}:/app/${IMAGE_FOLDER} - ports: - - ${HTTPS_PORT}:${HTTPS_PORT} - - 8190:8090 - environment: - - HOSTNAME=${HOSTNAME} - - HTTPS_PORT=${HTTPS_PORT} - - ADMIN_ROLE=${ADMIN_ROLE} - - REDIRECT_URL=${REDIRECT_URL} - - CLIENT_ID=${CLIENT_ID} - - CLIENT_SECRET=${CLIENT_SECRET} - - AUTH_URL=${AUTH_URL} - - IMAGE_FOLDER=${IMAGE_FOLDER} - - MOCK_OAUTH2=${MOCK_OAUTH2} - - TOKEN_URL=${TOKEN_URL} - - USERINFO_URL=${USERINFO_URL} - - DEBUG_MODE=${DEBUG_MODE} - - DATABASE_USER=${DATABASE_USER} - - DATABASE_NAME=${DATABASE_NAME} - - DATABASE_PASSWORD=${DATABASE_PASSWORD} - - DATABASE_HOST=database-agent -networks: - backoffice: -``` +Example [here](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client/-/blob/dev/docker-compose.yml) ### site.conf -``` -server { - listen 8080; - server_name ecolyo-agent.grandlyon.com; - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html =404; - } - location /api { - proxy_pass https://backend:1443/api; - } - location /OAuth2Login { - proxy_pass https://backend:1443/OAuth2Login; - } - location /OAuth2Callback { - proxy_pass https://backend:1443/OAuth2Callback; - } - location /Logout { - proxy_pass https://backend:1443/Logout; - } - location /swagger { - proxy_pass https://backend:1443/swagger; - } - location /imageNames { - proxy_pass https://backend:1443/api/admin/imageNames; - } - # cozy-doctypes workaround - location /email { - # if ($arg_serviceName != overview) { return 404; } if ($arg_param !~ "^\d+$") { return 404; } if ($arg_serviceName = "image") { rewrite ^ /usr/share/nginx/html/lib/$arg_param? permanent; - #} - proxy_pass https://backend:1443/api/common/monthlyReport/$arg_param; - # rewrite ^ /usr/share/nginx/html/lib/$arg_param? permanent; - } - location ~ ^/assets/(.+\.(?:gif|jpe?g|svg|png))$ { - alias /usr/share/nginx/html/lib/$1; - gzip_static on; - expires max; - add_header Cache-Control public; - } -} -``` +Find exemples [here](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client/-/tree/dev/nginx) ### .env @@ -143,44 +22,26 @@ To use OAuth2 login ask your client ID and client secret Here is the config to run the app -``` +```env NODE_TLS_REJECT_UNAUTHORIZED = '0' HTTPS=true SSL_CRT_FILE=cert.pem SSL_KEY_FILE=key.pem -# Common settings -HOSTNAME=your_url.com -ADMIN_ROLE=****** -DEBUG_MODE=false -MOCK_OAUTH2=false -HTTPS_PORT=1443 -IMAGE_FOLDER=image-lib - -# Needed to user OAuth2 authentication : -REDIRECT_URL=https://${HOSTNAME}:443/OAuth2Callback -CLIENT_ID=**get one from your IDP** -CLIENT_SECRET=**get one from your IDP** -AUTH_URL=**get it from your IDP** -TOKEN_URL=**get it from your IDP** -USERINFO_URL=**get it from your IDP** -LOGOUT_URL=/ - -# Access to the database -DATABASE_USER=****** -DATABASE_PASSWORD=******* -DATABASE_NAME=backoffice ``` +Complete with this example [here](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server/-/blob/dev/.env.template) + ## Start the application Then start the app by launching the command : -``` +```sh docker-compose up -d ``` To check if the application starts successfully, launch the command -``` + +```sh docker logs backoffice-client_backend_1 ``` diff --git a/docs/ecolyo/ecolyo-agent/development/handle_assets.md b/docs/ecolyo/ecolyo-agent/development/handle_assets.md index 1a872a0ffc9164f7ceb35c5a3971c08e7943aee4..a6ec0ce06e1ea776aa010c638cc83ad858285ff4 100644 --- a/docs/ecolyo/ecolyo-agent/development/handle_assets.md +++ b/docs/ecolyo/ecolyo-agent/development/handle_assets.md @@ -1,47 +1,15 @@ -This section will allow you to import the assets used in the newsletter from Ecolyo +# Handle assets +This section will allow you to import the assets used in the newsletter from Ecolyo ## Import assets -In the rec or prod server, in the folder ```scripts```, there is the following script, named ```import-convert-assets.sh``` . - -```bash -#!/bin/bash - -# Get env variables -. ../.env -EMAIL_ASSETS_PATH="src/assets/icons/email" -ECOGESTURE_ASSETS_PATH="src/assets/icons/visu/ecogesture" -EXPORT_FORMAT=".png" -pwd=$(pwd) - -# Fetch and convert email assets -curl "https://forge.grandlyon.com/api/v4/projects/409/repository/archive?path=${EMAIL_ASSETS_PATH}" --output email.tar.gz -tar -xf email.tar.gz -cd *-email/$EMAIL_ASSETS_PATH && for file in *.svg; do inkscape -h 200 -w 200 -e $(echo "$file" | sed "s/.svg/$EXPORT_FORMAT/") $file; done && rm *.svg -cd $pwd - -# Fetch and convert ecogesture assets -curl "https://forge.grandlyon.com/api/v4/projects/409/repository/archive?path=$ECOGESTURE_ASSETS_PATH" --output ecogesture.tar.gz -tar -xf ecogesture.tar.gz -cd *-ecogesture/$ECOGESTURE_ASSETS_PATH && for file in *.svg; do inkscape -h 200 -w 200 -e $(echo "$file" | sed "s/.svg/$EXPORT_FORMAT/") ${file}; done && rm *.svg +In the rec or prod server, in the folder `scripts`, there is the following script, named [`import-convert-assets.sh`](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client/-/blob/dev/scripts/import-convert-assets.sh). -# Cleanup -cd $pwd -rm -rf ../$IMAGE_FOLDER -mv *-email/$EMAIL_ASSETS_PATH ../$IMAGE_FOLDER -mv *-ecogesture/$ECOGESTURE_ASSETS_PATH ../$IMAGE_FOLDER/ecogesture -rm -rf email.tar.gz ecogesture.tar.gz *-email *-ecogesture +To import assets for the ecogesture images, run it -# Give ownership to container user -chown -R 1000:1000 ../$IMAGE_FOLDER -``` - -To import assets for the ecogesture images, run (inside of ```scripts``` folder) -``` +```sh sudo sh import-convert-assets.sh ``` - Check that a "image-lib" folder has been created, that it contains a "ecogesture" folder and some PNG images and that the owner of the "image-lib" folder is the user id 1000. - diff --git a/docs/ecolyo/ecolyo-agent/functionalities/authentication.md b/docs/ecolyo/ecolyo-agent/functionalities/authentication.md index a34c0c1db121807d74fa707bb64fef77685a7a88..9dd6cc42089b855d2933e27a6ea9d3b0c413e731 100644 --- a/docs/ecolyo/ecolyo-agent/functionalities/authentication.md +++ b/docs/ecolyo/ecolyo-agent/functionalities/authentication.md @@ -7,4 +7,4 @@ The protocol used to login is OAuth2 with the Authorization Code grant type ([mo Once an admin is connected, he must call the /whoAmI route to access his XSRF-TOKEN and add it in a header named "XSRF-TOKEN" for all requests going to the backend. The only routes that can be accessed without authentication are /monthlyReport/year/month and /monthlyReport with GET. -They will return all the different sections of a specific or the current newsletter in a single JSON. \ No newline at end of file +They will return all the different sections of a specific or the current newsletter in a single JSON. diff --git a/docs/ecolyo/ecolyo-agent/functionalities/general.md b/docs/ecolyo/ecolyo-agent/functionalities/general.md index cfe7d3ae72ee77c75f04849c9d9b73d98308e7e8..9678023e9c6e4457bb04fc5debdc276c526b8654 100644 --- a/docs/ecolyo/ecolyo-agent/functionalities/general.md +++ b/docs/ecolyo/ecolyo-agent/functionalities/general.md @@ -1,6 +1,7 @@ # Introduction ## Newsletter + The goal is to send newsletters following this design :  @@ -28,8 +29,8 @@ This section manages the prices for each fluid in the ecolyo application. - The next price to create is automatically pre-selected by default - Only the 2 last prices plus the one to create are editable, the others are just searchable -- Each fluid has its own date frequency : +- Each fluid has its own date frequency : - Electricity : one new price every 6 month (February and August) - Water : one new price every year - Gas : one new price every month -- When user creates a new price, the previous price's endDate is set to the new startDate minus 1 minute, so every prices keeps following in time. \ No newline at end of file +- When user creates a new price, the previous price's endDate is set to the new startDate minus 1 minute, so every prices keeps following in time. diff --git a/docs/ecolyo/ecolyo-agent/functionalities/routes.md b/docs/ecolyo/ecolyo-agent/functionalities/routes.md index 14159b354aba6e9ccacb2014ac0f1106f47fdc92..3ef6961c8524b66598d85c3de9a6d20625d3d0fc 100644 --- a/docs/ecolyo/ecolyo-agent/functionalities/routes.md +++ b/docs/ecolyo/ecolyo-agent/functionalities/routes.md @@ -1,4 +1,6 @@ # Routes +:warning: WIP :warning: + The different routes exposed by the backend are described by Swagger documentation. Once the api deployed, the documentation is accessible at https://HOSTNAME/swagger/index.html \ No newline at end of file diff --git a/docs/ecolyo/ecolyo-agent/getting_started/launch_local_application.md b/docs/ecolyo/ecolyo-agent/getting_started/launch_local_application.md index c2133c78d6a92ecc40a88c1f042f508baa4842ca..ca0fbbcecbe368396b34f050ad34634674469b36 100644 --- a/docs/ecolyo/ecolyo-agent/getting_started/launch_local_application.md +++ b/docs/ecolyo/ecolyo-agent/getting_started/launch_local_application.md @@ -1,29 +1,26 @@ -This section will allow you to launch a proper local environment for Ecolyo-Agent +# Launch Ecoylo Agent -## Initialisation of the project +This section will allow you to launch a proper local environment for Ecolyo-Agent -### Clone the project repository +## Local usage +### Initialisation of the project -Use following commands in your favorite terminal to clone the project: +Clone the projects using thefollowing commands -``` +```sh git clone https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client git clone https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server ``` -## Installation of the project - -### Installation of node modules +### Installation of the project -To install required node module, open a terminal on the root folder of the backoffice-client project and type the following command: +To install required node modules, open a terminal on the root folder of the backoffice-client project and type the following command: -``` +```sh yarn install ``` -## Local usage - -Before launching the application, ensure you've properly filled the .env file according to the template. If needed please refer to a team member. +Before launching the application, ensure you've properly filled the `.env` file according to the template. If needed please refer to a team member. In order to launch the project in local with the backend working launch the following command @@ -49,49 +46,50 @@ Do not use the app with the port 3000, you won't be able to login. > :warning: **If you are launching the project from a Windows OS** : Make sure to comment the 'extra_hosts' lines in the docker-compose.local file. Otherwise, you you won't be able to access your machine's localhost from the docker container. -## Backend and Database +#### Backend and Database -In order to get Backend documentation, please refer directly to the [backend project](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server) +In order to get Backend documentation, please refer directly to the [backend readme](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server/-/blob/dev/README.md) -## Nginx +#### Nginx The nginx server redirects https requests from front-end to the backend on port 1443. It has two configuration files : -- nginx/site.conf, used for local development -- nginx/site.prod.conf, used for production +- `nginx/site.conf`, used for local development +- `nginx/site.prod.conf`, used for production The nginx server needs local ssl certificates in order to run an interact with backend, these certificates are present in the project. +#### Check success -## Check success +To check if the application starts successfully, launch the command -To check if the application starts successfully, launch the command ```bash docker logs backoffice-client_backend_1 ``` You should obtain the following messages: -> --- Server is starting --- +> --- Server is starting --- > Token signing key set > Mock OAuth2 server Listening on: http://localhost:8090 -Once the application is started, you can access it here: https://localhost +Once the application is started, you can access it here: [localhost](https://localhost) -## Test on alpha +## Alpha usage In order to test the app on alpha you can do the following steps: - Build locally your docker image for the client and/or the server -``` +```sh docker build . -t registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-<server/client>:your-tag ``` + - Push the image -``` +```sh docker push registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-<server/client>:your-tag ``` @@ -99,46 +97,44 @@ docker push registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffic - Then launch the app, it will pull automatically the new images -``` +```sh docker-compose up -d ``` - If you have access denied issue, try to docker login -``` +```sh docker login registry.forge.grandlyon.com/web-et-numerique/llle_project/ ``` -- If you want to update alpha using the same image tag with edited image, just pull manually your new image and rebuild the concerned image +- If you want to update alpha using the same image tag with edited image, just pull manually your new image and rebuild the concerned image -``` +```sh docker pull registry.forge.grandlyon.com/web-et-numerique/llle_project/backoffice-<server/client>:your-tag docker-compose up -d ``` -If you need to work with prices on alpha, you will need to init the prices database. +If you need to work with prices on alpha, you will need to init the prices database. - First get the mysql container id -``` +```sh docker ps ``` - Then get into the container -``` +```sh docker exec -it <container-id> bash ``` - Then execute the mysql script that imports all the prices in DB -``` +```sh mysql --local-infile=1 -uroot -p backoffice < /dbinit/dbinit.sql ``` You will be prompted for the admin password, use the db password set in the .env file. Now you're ready to edit your prices on alpha ! - - diff --git a/docs/ecolyo/ecolyo-agent/getting_started/libraries.md b/docs/ecolyo/ecolyo-agent/getting_started/libraries.md index 7858efcc3f34ac7149747ad1edead2081e7c5648..af4082fbff2d2b2bc75b1f9d295c789e3a6fa3f7 100644 --- a/docs/ecolyo/ecolyo-agent/getting_started/libraries.md +++ b/docs/ecolyo/ecolyo-agent/getting_started/libraries.md @@ -44,7 +44,7 @@ It allows us to create variables, nested rules, mixins, functions, and do mathem Package for Go that implements a request router and dispatcher for matching incoming requests to their respective handler. -It allows us to easily create and manage routes/APIs +It allows us to easily create and manage routes/APIs ## Swag diff --git a/docs/ecolyo/ecolyo-agent/getting_started/setup_your_environment.md b/docs/ecolyo/ecolyo-agent/getting_started/setup_your_environment.md deleted file mode 100644 index 20af1cb935cffd9d99ec053fbc7c8f9e710c375a..0000000000000000000000000000000000000000 --- a/docs/ecolyo/ecolyo-agent/getting_started/setup_your_environment.md +++ /dev/null @@ -1,100 +0,0 @@ -This section will allow you to install a proper local environment step by step for Ecolyo-Agent using VSCode IDE. - -## VSCode - -### Install VSCode - -Installation for VSCode can be found here: [Installation of VSCode](https://code.visualstudio.com/). - -### Extensions - -Installation of Extension is explained here: [Installation of Extensions](https://code.visualstudio.com/docs/editor/extension-gallery). - -Here are the list of important extensions to install: - -- Prettier - Code formatter -- ES7 React/Redux/GraphQL/React-Native snippets -- GitLens - Git supercharged -- Markdown Preview -- Go - -Optional extensions: - -- Bracket Pair Colorizer 2 -- CSS Peek -- Auto Rename Tag -- indent-rainbow -- TabOut -- Liveshare (pair programming extension) - -### User settings - -Open the project with VSCode and add the following code into .vscode/settings.json: - -``` -{ - "workbench.colorCustomizations": { - /* Put anything you like here */ - }, - "editor.snippetSuggestions": "top", - "editor.tabSize": 2, - "editor.formatOnSave": true, - "diffEditor.ignoreTrimWhitespace": false, - "window.zoomLevel": 0, - "gitlens.advanced.messages": { - "suppressShowKeyBindingsNotice": true - }, - "breadcrumbs.enabled": true, - "workbench.settings.editor": "json", - "editor.tabSize": 2, - "editor.formatOnSave": true, - "editor.formatOnPaste": true -} -``` - -If this file is not empty, you can simply add the following lines to it: - -``` - "gitlens.advanced.messages": { - "suppressShowKeyBindingsNotice": true - }, - "breadcrumbs.enabled": true, - "workbench.settings.editor": "json", - "editor.formatOnSave": true, - "diffEditor.ignoreTrimWhitespace": false, - "window.zoomLevel": 0, -``` - -## Git - -The project is using Gitlab, you will need to install Git to checkout the project. -Installation for Git can be found here: [Installation of Git](https://git-scm.com/) (current version : 1.17) - -## Node - -For this project, Node version 14 is required.Download [node-v14](https://nodejs.org/en/download/). - -Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. - -## Yarn - -Yarn is used as package manager for this project. Feel free to use the one you prefer but we advice to install yarn as all the documentation is described with this package manager. -Installation for yarn can be found here: [Installation of Yarn](https://classic.yarnpkg.com/fr/docs/install/). - -## Docker - -Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code. - -### Install Docker - -Installation of Docker can be found here: [Installation of Docker](https://www.docker.com/get-started). - -### Install Docker-Compose - -Installation of Docker-Compose (according to your OS) is explained here: [Installation of Docker-Compose](https://docs.docker.com/compose/install/). - -## Golang - -Golang (or Go for short) is an open source programming language that makes it easy to build simple, reliable, and efficient software. It is used in this project for the backend. - -Installation of Go (according to your OS) is explained here: [Installation of Go](https://golang.org/doc/install) (current version: 1.17). diff --git a/docs/ecolyo/ecolyo-agent/introduction.md b/docs/ecolyo/ecolyo-agent/introduction.md index c1489cafe37073c932d366227d6dce5fe65a898c..87da5375c00c754b2c534e9921592eeb7fdb1ef6 100644 --- a/docs/ecolyo/ecolyo-agent/introduction.md +++ b/docs/ecolyo/ecolyo-agent/introduction.md @@ -1,12 +1,14 @@ -Ecolyo-Agent is a backoffice for the Ecolyo app that allows to create and edit content for the newsletters sent to the users +# Ecolyo Agent -This project is split into two parts: backend and front-end; each has its own repository +Ecolyo-Agent is a backoffice for the Ecolyo app that allows to create and edit content for the newsletters sent to the users. + +This project is split between a backend and frontend; each project has its own repository. !!! info "" - If you are a new developer tasked to work on this project, check the [setup your environment](./getting_started/setup_your_environment.md) and [launch the application on local](./getting_started/launch_local_application.md) to start the application. + If you are a new developer tasked to work on this project, check the [setup your environment](../../setup_your_environment.md) and [launch the application on local](./getting_started/launch_local_application.md) to start the application. -## Repositories +##  Repositories [Ecolyo-Agent backend gitlab repository](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server) -[Ecolyo-Agent front-end gitlab repository](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client) \ No newline at end of file +[Ecolyo-Agent front-end gitlab repository](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client) diff --git a/docs/ecolyo/functionalities/analysis.md b/docs/ecolyo/functionalities/analysis.md index 8a311049bbdaba5f8c0bc0c6e574979b9171f7c5..2ada2304a201fd00b0f282a73efe20521fefcbd4 100644 --- a/docs/ecolyo/functionalities/analysis.md +++ b/docs/ecolyo/functionalities/analysis.md @@ -1,3 +1,5 @@ +# Analysis + This section explains the analysis screen and how information are displayed. ## Description diff --git a/docs/ecolyo/functionalities/challenge.md b/docs/ecolyo/functionalities/challenge.md index 373589e97bb410615329ca03aecc91fb560fd57e..493988b31f6d95bd46a9ba811e34bdf3878da257 100644 --- a/docs/ecolyo/functionalities/challenge.md +++ b/docs/ecolyo/functionalities/challenge.md @@ -1,3 +1,5 @@ +# Challenge + This section explain all the functionalities in the challenge part ## Quiz @@ -52,8 +54,8 @@ Calculation of custom question is done by combination of all parameters: Retrieve the **date** of day/month/year (define by _timeStep_) from the last week, month, year (define by _interval_), if there is no data in this interval, then it will go back to a previous interval, up to a maximum of 6 months -``` -example: What day did I consumme the most on the last week ? +```js +// example: What day did I consumme the most on the last week ? type = CustomQuestionType.DATA timeStep = TimeStep.DAY interval = TimeStep.WEEK @@ -61,8 +63,8 @@ period = {} singleFluid = false ``` -``` -example: What day did I consumme the most #fluid in #unit on the last week ? +```js +// example: What day did I consumme the most #fluid in #unit on the last week ? type = CustomQuestionType.DATA timeStep = TimeStep.DAY interval = TimeStep.WEEK @@ -74,8 +76,8 @@ singleFluid = true Retrieve the **date** of day/month/year (define by _timeStep_) from a week, month, year (define by _interval_) of _period_ -``` -example: What month did I consumme the most on year 2020 ? +```js +// example: What month did I consumme the most on year 2020 ? type = CustomQuestionType.DATA timeStep = TimeStep.MONTH interval = TimeStep.YEAR @@ -89,8 +91,8 @@ singleFluid = false Retrieve the **maxload** value of day/month/year (define by _timeStep_) from the last week, month, year (define by _interval_). -``` -example: Which is your daily max consumption on the last week ? +```js +// example: Which is your daily max consumption on the last week ? type = CustomQuestionType.MAXLOAD timeStep = TimeStep.DAY interval = TimeStep.WEEK @@ -102,8 +104,8 @@ singleFluid = false Retrieve the **maxload** value of day/month/year (define by _timeStep_) from a week, month, year (define by _interval_) of _period_ -``` -example: Which is your daily max consumption on january 2020 ? +```js +// example: Which is your daily max consumption on january 2020 ? type = CustomQuestionType.MAXLOAD timeStep = TimeStep.DAY interval = TimeStep.MONTH @@ -117,8 +119,8 @@ singleFluid = false Retrieve the **average** of day/month/year (define by _timeStep_) from the last week, month, year (define by _interval_). -``` -example: Which is your daily average consumption on last week ? +```js +// example: Which is your daily average consumption on last week ? type = CustomQuestionType.AVERAGE timeStep = TimeStep.DAY interval = TimeStep.WEEK @@ -130,8 +132,8 @@ singleFluid = false Retrieve the **average** of day/month/year (define by _timeStep_) from a week, month, year (define by _interval_) of _period_ -``` -example: Which is your daily average consumption on january 2020 ? +```js +// example: Which is your daily average consumption on january 2020 ? type = CustomQuestionType.AVERAGE timeStep = TimeStep.DAY interval = TimeStep.MONTH @@ -143,8 +145,8 @@ singleFluid = false Retrieve the **average** of the _weekday_ from a week, month, year (define by _interval_). -``` -example: Which is your daily average consumption on wednesdays of last month? +```js +// example: Which is your daily average consumption on wednesdays of last month? type = CustomQuestionType.AVERAGE timeStep = TimeStep.DAY interval = TimeStep.MONTH @@ -191,7 +193,7 @@ When the user finish the exploration, he gets a success message and five more st Action is a feature which in the user has to apply an ecogesture for a given duration in order to reduce his consumption. An action refers to the model **UserAction** in the app, and is an extension of an ecogesture to which we add an _startDate_ and a _userActionState_, allowing user to manage the action state depending on user's progress. -```jsx +```ts UserAction { ecogesture: Ecogesture | null state: UserActionState diff --git a/docs/ecolyo/functionalities/consumption.md b/docs/ecolyo/functionalities/consumption.md index 4c307f27341083abdf104479cf146695afc15d41..14a7ddc4d8f404e393db3b894e1f6c343385ef4a 100644 --- a/docs/ecolyo/functionalities/consumption.md +++ b/docs/ecolyo/functionalities/consumption.md @@ -30,7 +30,7 @@ For EGL, the interval is **5 days** ## ConsumptionView -### Description +**Description:** This view is the main view of the application. It displays an aggregation view of all connected fluids. It is the entrypoint to several children components that each handles a particular feature : @@ -43,7 +43,7 @@ It is the entrypoint to several children components that each handles a particul The submenu (FluidButtons), allows the user to switch between the different fluids and the multifluid view. -### Rules +**Rules:** 1. If no fluids are connected, this view will display the multifluid view with the _KonnectorViewerList_ component which shows buttons that allow user to connect its first fluids. These buttons redirects to the chosen fluid section with the connection form. 2. If at least one fluid is connected, the multi fluid view and the connected fluids views are shown (electricity, water, gas). @@ -54,11 +54,11 @@ The submenu (FluidButtons), allows the user to switch between the different flui ## DateNavigator -### Description +**Description:** The component allows the user to navigate through the selected timestep (week by week, month by month, etc.) -### Rules +**Rules:** 1. If no fluid is connected, the navigation is locked 2. By default, the date is set to the lastDataDate. @@ -66,11 +66,11 @@ The component allows the user to navigate through the selected timestep (week by ## FluidButtons -### Description +**Description:** The component allows the user to navigate through the different fluid views (multifluid, electricity, water, gas) -### Rules +**Rules:** 1. If a Konnector is on error or its data is outdated, we show a red cross on the fluid icon 2. If the fluid is not connected we show a "turn on" icon @@ -78,7 +78,7 @@ The component allows the user to navigate through the different fluid views (mul ## FluidChart -### Description +**Description:** This component is the one that shows the user its consumption, according to the selected fluid, timestep and date. It is split in 3 distinct parts: @@ -87,7 +87,7 @@ It is split in 3 distinct parts: - The FluidSlides - The TimeStep Navigator -### Rules +**Rules:** | Component | Rules | | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -97,12 +97,12 @@ It is split in 3 distinct parts: ## DataLoad Consumption Visualizer -### Description +**Description:** This view displays the load of a specified fluid (electricity, water, gas) or the total consumption on the multifluid screen. The display will be done in function of the data state. -### Rules to define data state +**Rules to define data state:** The data state is define in the "ConsumptionFormatter" service following theses rules : @@ -202,7 +202,7 @@ The chart scale will adapt to the max load displayed between the _actualData_ an This component shows the konnector state and allows the user to connect, delete, or update a konnector -### Rules +**Rules:** - If the fluid is connected, this component will shows the konnector state at the end of the consumption page - If the fluid is not connected, it will show the connection form diff --git a/docs/ecolyo/functionalities/dacc.md b/docs/ecolyo/functionalities/dacc.md index 929169c45a759e6e2d96b996370fbc0d150adf7c..80e79b1ac63c929c962063839c6991ede509751d 100644 --- a/docs/ecolyo/functionalities/dacc.md +++ b/docs/ecolyo/functionalities/dacc.md @@ -23,7 +23,6 @@ This section explains how the application is tracking usage events. Here are the - All events are stored during the use of the application in the doctype **com.grandlyon.ecolyo.usageevents** - A service is responsible of the aggregation of these events to create ANONYMIZED indicators. These indicators are then sent to a remote docType. - | Title | Tech name | target | context | startDate | result | trigger | Cozy Dacc Name | | --- | --- | --- | --- | --- | --- | --- | --- | | Changement d'action dans un challenge | ActionChangeEvent | Id de l'action | Id du challenge en cours | --- | --- | Chaque appui sur le bouton `selectEcogesture` dans le `ActionCard` | navigation-action-daily | @@ -48,8 +47,6 @@ This section explains how the application is tracking usage events. Here are the | Consultation du nouveau bilan mensuel | ReportFromEvent | --- | 'analysis' | --- | 1 | Lorsque l'utilisateur consulte sa page analyse quand la notification est activée | summary-subscription-monthly | | Tentatitve de connexion à un connecteur (initialisation)| KonnectorAttemptEvent | Slug du connecteur | --- | --- | 'success or error' | Lorsque l'utilisateur clique sur le bouton de connexion. Lorsque la connexion est réussie, et que l'utilisateur clique sur OK dans la modale le *result* est passé à 'success' | konnector-attempts-monthly | - - 1. Nom de la page, différents cas existant | Page | target | Trigger | @@ -61,11 +58,13 @@ This section explains how the application is tracking usage events. Here are the ## Indicators -!!! warning "note" +!!! warning "note" All indicators are only sent if a user validate first version of CGU, the one containing dacc validation + ### Monthly Indicators All monthly indicators call can be found after this comment on the code + ```js // Monthly events ``` @@ -79,7 +78,6 @@ All monthly indicators call can be found after this comment on the code | profile-count-monthly | Tous les mois si le profil a été complété au moins une fois | Le nombre de fois ou le profile a été complété | | konnector-attempts-monthly | Tous les mois, le nombre de tentative de connexion pour connecter un connecteur la première fois. Une fois la connexion réussie, l'indicateur remonte true dans le groupe "success". L'indicateur ne remonte ensuite plus pour cet utilisateur car il aura déjà réussi à se connecter une première fois. | Le nombre total de tentatives | - ### Daily Indicators The daily process get all events of previous day and process them in the following indicators @@ -104,7 +102,7 @@ The daily process get all events of previous day and process them in the followi All indicator are post to a remote doctype, which will allow the application to read a defined external API. This doctype is created by Cozy itself. The structure to send is the following : -``` +```ts { createdBy: string measureName: string @@ -122,7 +120,7 @@ with: - *startDate*: used to defined the start date of the indicator - *value*: contains a value relevant to the defined indicator (example: number of page viewed on a day). - *groups*: contains all attributes defining a indicator. Please refer to [indicators definition](https://stats.cozycloud.cc/question#eyJkYXRhc2V0X3F1ZXJ5Ijp7ImRhdGFiYXNlIjo0LCJxdWVyeSI6eyJzb3VyY2UtdGFibGUiOjh9LCJ0eXBlIjoicXVlcnkifSwiZGlzcGxheSI6InRhYmxlIiwidmlzdWFsaXphdGlvbl9zZXR0aW5ncyI6e319) -- *mesureName*: contains one of the following value +- *mesureName*: contains one of the following value | ENUM | value | | --- | --- | @@ -142,7 +140,7 @@ with: | PROFILE_COUNT_MONTHLY | profile-count-monthly | | KONNECTOR_ATTEMPTS_MONTHLY | konnector-attempts-monthly | -### Environments +### Environments There is two remote doctypes pointing to two different mode. `dacc-dev` is used on alpha. @@ -162,11 +160,13 @@ There is two remote doctypes pointing to two different mode. `dacc-dev` is used First you need to modify the service in order to be able to see data in local : - Run a local server that will listen and log events. + ```sh node srcipts/server.js ``` - Edit dacc URL (line 67) to send requests to your local server at `http://localhost:8081` + ```js await client .getStackClient() @@ -180,7 +180,9 @@ node srcipts/server.js } ) ``` + - For **monthly indicators**, remove date protection (ligne 1100) + ```js if ( profile @@ -199,14 +201,16 @@ You will be able to see previous events and freshly generated events in the db ` :warning: because the cron run every day at 2am, it will take events from the day before. So if you want to test specific usage, you will have to edit the `eventDate` of events you want to send. - - Then you are finally ready to test ! Just run the following : -*If aggregatorUsageEvents changed* +*If aggregatorUsageEvents changed:* + ```sh yarn build-dev:browser && yarn run cozy-konnector-dev -m ./manifest.webapp ./build/services/aggregatorUsageEvents/ecolyo.js ``` + *To save time, when running multiple times and if aggregatorUsageEvents didn't change, you don't have to build.* + ```sh yarn run cozy-konnector-dev -m ./manifest.webapp ./build/services/aggregatorUsageEvents/ecolyo.js ``` @@ -215,25 +219,27 @@ yarn run cozy-konnector-dev -m ./manifest.webapp ./build/services/aggregatorUsag ```json { - data: '{"createdBy":"ecolyo","measureName":"connection-count-monthly","startDate":"2021-12-09","value":3}' + "data": {"createdBy":"ecolyo","measureName":"connection-count-monthly","startDate":"2021-12-09","value":3} } { - data: '{"createdBy":"ecolyo","measureName":"connection-count-monthly","startDate":"2021-12-09","value":3}' + "data": {"createdBy":"ecolyo","measureName":"connection-count-monthly","startDate":"2021-12-09","value":3} } ``` -## How to add new indicator ? +## How to add new indicator ? You have to reach cozy and discuss with them about new indicators. They will implement it for `dacc-dev` and `dacc` and you will be able to test it on alpha env. Remember you will need **at least 5 data** of each type to see it in metabase. -## Visualisation +## Visualisation All the data aggregated in the dacc can be visualized with a *Metabase* website hosted by [cozy](https://stats.cozycloud.cc/). ## Errors + More here in [DJU](https://doc.self-data.alpha.grandlyon.com/ecolyo/functionalities/profile_type/). If there is an authentication error, the api will returns an error in html format to cozy, so you'll get from cozy an error 502 as following, because cozy expects a json response : + ```json { "status": "502", diff --git a/docs/ecolyo/functionalities/ecogesture.md b/docs/ecolyo/functionalities/ecogesture.md index 3fb87d274d4bb41964feabfdda1cafd8e60f464e..afda91c1cf77417e06a0ebc982a8020d7c76823c 100644 --- a/docs/ecolyo/functionalities/ecogesture.md +++ b/docs/ecolyo/functionalities/ecogesture.md @@ -10,7 +10,7 @@ Also, an ecogesture can be used for an action challenge. ### Model -``` +```ts Ecogesture { id: string shortName: string @@ -35,9 +35,11 @@ Ecogesture { viewedInSelection: boolean } ``` + ## Ecogestures screen -This screen is divided in 3 tabs : +This screen is divided in 3 tabs : + - *ALL*: display the full list of ecogestures. User can filter ecogesture by usage. - *DOING*: display the list of doing ecogestures. User can filter ecogesture by usage. - *OBJECTIVES*: display the list of objectives ecogestures. User can filter ecogesture by usage. @@ -55,12 +57,13 @@ An ecogesture can have a status according the user's choice, it can be *doing* a ## Profile Ecogesture The first time the user consults the ecogesture page, he will be prompted to start selecting his custom ecogestures. + - If he refuses, I will still be able to access this functionality by clicking on the "Select" button on the tabs 'Doing' and 'Objectives' while they are still empty. - If he starts select ecogestures on his own by the tab 'All' and fill both 'objective' and 'doing' sections, he won't be able to access the form and selection as described in the next parts. ### Model -``` +```ts ProfileEcogesture { heating: IndividualOrCollective warmingFluid: WarmingType | null @@ -70,19 +73,21 @@ ProfileEcogesture { ``` ### Ecogesture Form + The form is compose in 2 parts : + - The first is made of question concerning his heating fluid and type (individual or collective), and his hotWater type. - The second part asks the user to pick the equipment he has. -*If the user has completed his profileType, he won't see the first part as it is automatically completed with the information he filled in his profileType* +*If the user has completed his profileType, he won't see the first part as it is automatically completed with the information he filled in his profileType:* - The first part filters his custom list by Usages ECS and HEATING - The second part filters his custom list by Equipments - ## Ecogesture Selection Once user has completed his profile ecogesture through the form, he has the possibility to enter the ecogesture selection (tinder-like) + - A list of custom ecogesture is made according to his profile - User will cross this list 10 by 10, and has to choose if it is 'doing' 'objective' or 'not interested diff --git a/docs/ecolyo/functionalities/initialization.md b/docs/ecolyo/functionalities/initialization.md index 9f53cec85dede6d70200994b434dc3373bceb4f8..77ce61ab39b43ca8e03fa426178f2c80ea950a7f 100644 --- a/docs/ecolyo/functionalities/initialization.md +++ b/docs/ecolyo/functionalities/initialization.md @@ -1,3 +1,5 @@ +# Inisitaliaztion + This section explains how to handle data storage. We handle data storage according to the following process : @@ -46,12 +48,9 @@ Functions used to init or update the hash : | initQuizEntity(hash: string) | | initExplorationEntity(hash: string) | - !!! info "Exception for ecogestures" When we update the ecogesture list in **ecogestureData.json**, we also get the previous existing list to transfer the ecogesture status (doing and/or objective) to the updated list. - - ### dataEntity vs userData In the project, you'll see two versions for the same data. The dataEntity (quizEntity, challengeEntity, ...) is the data stored in the db folder and in the CouchDB. These data are only edited in the CouchDB when we update a challenge/quiz/duel or add a new one. @@ -93,7 +92,7 @@ We create a userData and store it in the CouchDB under the doctype userData name To illustrate this, let's show an example of the conversion of duelEntity to UserDuel : -```jsx +```ts DuelEntity { id: string title: string @@ -104,12 +103,12 @@ DuelEntity { Becomes : -```jsx +```ts UserDuel { id: string title: string description: string - duration: Duration + duration: Duration threshold: number state: UserDuelState startDate: DateTime | null @@ -127,7 +126,7 @@ UserDuelEntity { id: string title: string description: string - duration: Duration + duration: Duration threshold: number state: UserDuelState startDate: string | null @@ -146,7 +145,7 @@ The initialization process displays progression steps in the splash screen so th Available loading steps are the followings : -```` +```ts MIGRATION = 0, CONSENT = 1, PROFILE = 2, @@ -154,12 +153,11 @@ Available loading steps are the followings : CHALLENGES = 4, PRICES = 5, CONSOS = 6, - ``` Possible errors are the followings : -``` +```ts MIGRATION_ERROR = 'migration_error', CONSENT_ERROR = 'consent_error', PROFILE_ERROR = 'profile_error', diff --git a/docs/ecolyo/functionalities/matomo.md b/docs/ecolyo/functionalities/matomo.md index 1319d2996e68b9e04208e9413ed1a15c1b1efec6..a10ef62b11f2b60688cbe8c2b6ef0a1abd6529d6 100644 --- a/docs/ecolyo/functionalities/matomo.md +++ b/docs/ecolyo/functionalities/matomo.md @@ -15,7 +15,7 @@ Matomo is hosted on [statweb.com](https://statweb.grandlyon.com/) where two proj _For our development, every alpha instance points to the REC project. That way, we work in an environment that is close to our production one._ -## Local testing +## Local testing ### Matomo server @@ -39,7 +39,8 @@ On step 5, create a super user with the credentials you want, for example On step6, enter dummy values and select a time zone. Once you finish the setup and access the server, you should see a warning telling you that matomo has not been configured with the correct port. To fix this problem follow these instructions. -``` + +```sh docker ps # copy container id of matomo @@ -54,16 +55,19 @@ vi config/config.ini.php ``` and under "[General]" add the port **9800** to the following line : -``` + +```sh trusted_hosts[] = "localhost:9800" ``` After reloading, you should be able to login. We need to make one last change for our app to send data to our matomo server. ### Ecolyo app -In the file + +In the file src/targets/browser/**index.tsx** at line 66 comment the dev condition that is preventing the tracker from being initialized. -```jsx + +```js if ( window.Piwik // && !isDev diff --git a/docs/ecolyo/functionalities/onboarding.md b/docs/ecolyo/functionalities/onboarding.md index 50460320e5a21a00398142f65c1cce29077cad9d..23a6cdc8572797c7f104a074a868b2a39bd6c007 100644 --- a/docs/ecolyo/functionalities/onboarding.md +++ b/docs/ecolyo/functionalities/onboarding.md @@ -1,16 +1,18 @@ +# Onboarding + This section explains the way we handle onboarding the application. ## Description When the user connects for the first time to Ecolyo, onboarding screens will be displayed. -!!! note "First connection" +!!! note "First connection" The first connection is define by the **isFirstConnection** boolean contains in the **profile** doctype. ### GCU screen First of all, we display the GCU screen, which allows user to read the General Condition of Use and the Legal Notice. The user should consent to all the terms to go further in the application. -!!! note "About terms" - More details are available on the (term section)[/ecolyo/functionalities/terms.md]. +!!! note "About terms" + More details are available on the [term section](/ecolyo/functionalities/terms.md). ### Welcome modal diff --git a/docs/ecolyo/functionalities/prices_calculation.md b/docs/ecolyo/functionalities/prices_calculation.md index f4348ec0b9d2683590c5f19374e0c006f5f7aba9..f414bf330c70b205f8602bd3aadd8a2543957f17 100644 --- a/docs/ecolyo/functionalities/prices_calculation.md +++ b/docs/ecolyo/functionalities/prices_calculation.md @@ -5,7 +5,8 @@ This section explains the price calculation process. ## Description Since version `1.6.0` of the app, we have a database storing fluid prices evolution since 2012 for the following fluids : -* Electricity + +* Electricity * Gas Before this version, the app was applying a hard coded price for each fluid without taking care of the time period. Now, there is a service running every night that process fresh data in order to apply the current price to this data, but also apply the most relevant price for a fluid doctype. @@ -83,15 +84,16 @@ stop This service is running every night at 02:00 AM. !!! warning "note" - You might observe some price miscalculation if data from konnector is collect after the service runtime. Because of the hard code price, which is the current price, the user should not see any difference. + You might observe some price miscalculation if data from konnector is collect after the service runtime. Because of the hard code price, which is the current price, the user should not see any difference. -### Init +### Init A migration job has been setup to init the database with json data store inside the app. This job should be run once and will init electricity and gas prices. ### New price In case of price update the following procedure must be done : + * Create a migration for adding new prices * Update hard coded price inside app in order to maintain fallback calculation * Verify full service calculation with new data @@ -102,6 +104,7 @@ In case of price update the following procedure must be done : ### Prices Data + We store in database a collection of prices with the following info : * StartDate * EndDate @@ -110,7 +113,6 @@ We store in database a collection of prices with the following info : The EndDate is set to null if it's the current fluid price. - ## App Price display The app can handle the new price calculation and also keep the old calculation system. @@ -123,7 +125,7 @@ If there is a price on the doctype we want to process, it will be use for displa The app take the hard code price for a given fluid and apply it to a load. This allow the app to handle prices in any case. -### How to test service ? +### How to test service ? In a shell run a build and test service with le following command line : @@ -134,6 +136,7 @@ yarn build-dev:browser; yarn run cozy-konnector-dev -m .\manifest.webapp .\build ### Future Changes We might consider a more dynamic process for fallback price calculation in the future: + * Get last price for a given price in database * Use it to calculate value instead of the hard coded one * Use it in all info pop-in for user information diff --git a/docs/ecolyo/functionalities/profile_type.md b/docs/ecolyo/functionalities/profile_type.md index c04e749fadee20050b3bf236ea2b663a4d940c59..995a23660b653798401dd751cb5dcc9e24bb68b5 100644 --- a/docs/ecolyo/functionalities/profile_type.md +++ b/docs/ecolyo/functionalities/profile_type.md @@ -1,10 +1,12 @@ +# Profile type + This section explains the profileType creation process in order to make different comparisons between the actual user's consumption and its profile type. ## Profile type data The profileType data are stored in the profile doctype and includes the following information : -```jsx +```ts { housingType: HousingType constructionYear: ConstructionYear @@ -35,22 +37,22 @@ Here is the flow of questions:  - ## Profile types handling over time + A user can have many profileTypes, Ecolyo takes into account that one can move from his home, have more occupants, start renovating works and so on. That's why a profileType is only active for a given time period, this is how its time logic works. -#### No filled profileType +### No filled profileType A default profileType is loaded in redux to operate basic operations. When the user looks at its analysis or options, ecolyo suggest user to fill a more accurate profileType. -#### First profileType +### First profileType The profileType will follow the form logic above (see ProfileType form section). *updateDate* field will be the current month and year. Since this profileType will be the only one in database, *getProfileType()* method will always return it, therefore it will be used for all past time period on analysis. -#### Following profileTypes +### Following profileTypes Each new profileType form will show a calendar picking section at the end of the form. By default, current month and year will be selected. @@ -58,6 +60,7 @@ By default, current month and year will be selected. If current year is not yet completed (december not reached), month dropdown menu will only propose past and present months for this year. When finishing, before the new profileType is saved. Checks if other profileTypes exist on the period between selected month/year and present day. + - If profileTypes are found, they are deleted (newest profileType always prevails on older ones, so that user had forgotten to fill some information before, this new profiletype will be more accurate). Then save profileType on given month/year. - If no other profileTypes are found, save profileType on given month/year. @@ -97,7 +100,7 @@ Here you can see the different methods provided by the profileType service. Thes Here is an example of a MonthlyForecast, which is the only function directly called by the analysis component : -```jsx +```ts { fluidForecast: [ { @@ -148,14 +151,15 @@ Also, we consider that if the heating or the hotwater are collective, we don't c ## DJU -The method **fetchDJU(month:number)** tries to fetch the daily dju from the datagrandlyon API trough a remote doctype named _org.ecolyo.dju_. +The method **fetchDJU(month:number)** tries to fetch the daily dju from the datagrandlyon API trough a remote doctype named *org.ecolyo.dju*. The data returned by this API are gathered by the lyon-bron-station The API returns dju by day for a given month, so we add them to return a monthly dju. If remote doctype fails or return a null value, we returns instead the default dju stored in _heating.json_ Useful tips while working with this API : - Do not pass a Content-Type while requesting, it will returns error - While requesting from a cozy instance, if you get errors, you will get errors from the cozy stack and not directly from the API, which leads to weird cases : - - If there is an authentication error, the api will returns an error in _html_ format to cozy, so you'll get from cozy an error 502 as following, because cozy expects a json response : + - If there is an authentication error, the api will returns an error in *html* format to cozy, so you'll get from cozy an error 502 as following, because cozy expects a json response : + ```json { "status": "502", @@ -164,4 +168,5 @@ Useful tips while working with this API : "source": {} } ``` - - In case of bad request (wrong parameters for example), the API will return an error in _xml_ format so you'll get exactly the same error as above in your cozy instance. + + - In case of bad request (wrong parameters for example), the API will return an error in *xml* format so you'll get exactly the same error as above in your cozy instance. diff --git a/docs/ecolyo/functionalities/terms.md b/docs/ecolyo/functionalities/terms.md index 9ee734ef551f56300994c8e5cdf4aa2ec67749df..b005b9efdda66872e245c9f8be703240bffa7028 100644 --- a/docs/ecolyo/functionalities/terms.md +++ b/docs/ecolyo/functionalities/terms.md @@ -1,3 +1,5 @@ +# Terms + This section explains the way we handle terms in the application. ## Description @@ -13,7 +15,6 @@ The only public routes are : - _/cgu_ : shows the CGU public page, accessible by the terms page - _/legal_ : shows the Legal Notice public page, accessible by the terms page - ### Terms management We check the terms acceptation in the **splash screen** while the application is initializing, if there is no consent (first connection), or the consent is outdated (update of terms), the user will be redirected to the terms acceptation page. @@ -21,7 +22,8 @@ We check the terms acceptation in the **splash screen** while the application is For the full terms acceptation process, the user has to check the two checkboxes (one for Data share consent, and one for CGU and Legal Notice) to unlock the terms acceptation button. Once he has accepted it, a new term doctype is created with the value _accepted_ to true. So he can access now the entire application. We store in user's profile a boolean _showConsentModal_ that allows the app to know about the consent status. -If there is a consent update, two cases are possible : +If there is a consent update, two cases are possible : + - It's a major update, ex: from 1.X.X to 2.X.X, the user has to go through the entire term validation process as explained above - It's a minor update, ex: from 1.1.X to 1.3.X or from 1.2.1 to 1.2.3, the user is just prompted with a modal with some text about the update, and a link to the legal notice, but there is no blocking acceptation input for the user. @@ -35,7 +37,7 @@ Once the verification done in the **splash screen**, the last term state is stor The model is the following : -``` +```ts termsStatus: { accepted: boolean, versionType: 'major' | 'minor' | 'init', diff --git a/docs/ecolyo/functionalities/usage_events_tracking.md b/docs/ecolyo/functionalities/usage_events_tracking.md index 92d0dddcf4092fb6a478940559447e92110511c9..a3e54a69da42ba3f33f9cc45dfa102e22e3a77ce 100644 --- a/docs/ecolyo/functionalities/usage_events_tracking.md +++ b/docs/ecolyo/functionalities/usage_events_tracking.md @@ -59,7 +59,7 @@ More technical information are available [here](/ecolyo/services/aggregator_usag All indicator are post to a remote doctype, which will allow the application to read a defined external API. This doctype is created by Cozy itself. Here are the actual structure of this remote doctype: -``` +```ts { source: string name: string diff --git a/docs/ecolyo/getting_started/launch_local_application.md b/docs/ecolyo/getting_started/launch_local_application.md index 088b7ae3ddab536edc90e4d7610d67b7b6dcfc44..e833743e7c1622d4e1960f1ae8a2f0c0f207b890 100644 --- a/docs/ecolyo/getting_started/launch_local_application.md +++ b/docs/ecolyo/getting_started/launch_local_application.md @@ -1,58 +1,54 @@ +# Launch the application on local + This section will allow you to launch a proper local environment of the Ecolyo application ## Initialisation of the project -### Clone the project repository - -Use following command in your favorite terminal to clone the project: +Clone the project repository using the following command -``` +```sh git clone https://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo.git ``` ## Installation of the project -### Installation of node modules +### Start the app -To install required node module, open a terminal on the root folder of the project and type the following command: +Install required node modules, open a terminal on the root folder of the project and type the following command: -``` +```sh yarn install ``` -### Start Ecolyo application +Start ecolyo application just launch the command: -To start ecolyo application just launch the command: - -``` +```sh yarn start ``` If the application starts successfully you should obtain the following message: -> App successfully compiled! -> Dev assets:http://localhost:8888 +> App successfully compiled! +> Dev assets: 'http://localhost:8888' Once the application is started, run the easy-cozy stack with docker. -#### On windows and linux +### Start cozy stack Launch the stack with the following command: -``` +```sh docker-compose up ``` -If you have an access denied issue, try to docker login - -``` -docker login registry.forge.grandlyon.com -``` - +!!! note "If you have an access denied issue, try to docker login" + ```sh + docker login registry.forge.grandlyon.com + ``` -A Powershell window will open. Wait until the success message: +Wait until the success message: -> Everything is setup. Go to http://ecolyo.cozy.tools:8080/ +> Everything is setup. Go to http://ecolyo.cozy.tools:8080/ > To exit, press ^C Once successful you can launch your local cozy with following url: [Cozy local url](http://cozy.tools:8080/) @@ -62,13 +58,14 @@ Local database can also be consulted at the following url: [Cozy local DB](http: ## 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'. +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 -``` + +```json { "_id": "eglgrandlyon", "grant_mode": "secret", @@ -79,8 +76,10 @@ EGL Example } } ``` + SGE Enedis example -``` + +```json { "_id": "enedis-sge-grandlyon", "grant_mode": "secret", @@ -93,6 +92,7 @@ SGE Enedis example } } ``` + !!! info "" You'll need to use konnector slug as is to make it work properly @@ -104,11 +104,11 @@ Once it is done, you will be able to use these 2 Konnectors with real accounts. ## Import mock data -!!! info "Requirement" +!!! info "Requirement" Your dev stack should be running to import the mock data First install ACH using yarn : -``` +```sh yarn global add cozy-ach ``` @@ -117,7 +117,7 @@ Next create the "config.js" file base on the "config.template.js" !!! info "" You can change the period of data generated by changing the following lines: - ``` + ```js const startingdate = DateTime.local() .plus({ days: -120 }) .startOf('day') @@ -128,25 +128,24 @@ Next create the "config.js" file base on the "config.template.js" Just replace -120 by the value needed -Next launch the script **createDayDataFiles.js** available into the **scripts** folder +Next launch the script `createDayDataFiles.js` available into the `scripts` folder -``` -cd scripts -node createDayDataFiles.js +```sh +node scripts/createDayDataFiles.js ``` -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: +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.bat ``` !!! info "" - 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```. + 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`. -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. +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** @@ -162,22 +161,21 @@ To simulate the connection you can use the script **createConnection.js** availa First update the authorization and cookie information from the "config.js" file (if not created just create it from the "config.template.js" file): -``` +```js 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: +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:  Next launch the script : -``` -cd scripts -node createConnections.js +```sh +node scripts/createConnections.js ``` Your data is now loaded and you can refresh the application to see your konnector connected. diff --git a/docs/ecolyo/getting_started/launch_local_konnector.md b/docs/ecolyo/getting_started/launch_local_konnector.md index f234c1293e8862d1298f13944676e21a838fd24c..2df4e6db50a5a7b233ca595dfb86b76e6c339f85 100644 --- a/docs/ecolyo/getting_started/launch_local_konnector.md +++ b/docs/ecolyo/getting_started/launch_local_konnector.md @@ -1,3 +1,5 @@ +# Launch a konnector on local + ## Cozy resources Please see also the [official cozy documentation](https://docs.cozy.io/en/cozy-konnector-libs/). @@ -22,4 +24,3 @@ This file needs to hold all the information transmitted by the cozy stack when t Type them all in the *fields* object. All data recovered by the standalone konnector will be stored in the *data* folder. - diff --git a/docs/ecolyo/index.md b/docs/ecolyo/index.md index b798284da5c034a45aed50aa797146c9de544fd0..afeac2401bba46a61fa2d10fc7c196951b582f30 100644 --- a/docs/ecolyo/index.md +++ b/docs/ecolyo/index.md @@ -1,13 +1,22 @@ +# Ecolyo + {: .center} Ecolyo is a multi-fluid application solution towards users of the grand lyon metropolis to monitor and optimize their energy consumption. +This is a [Cozy](https://docs.cozy.io/en/) application that allows users to connect their energy accounts such as **EGL**, **ENEDIS** and **GRDF**, using cozy [konnectors](https://docs.cozy.io/en/cozy-stack/konnectors/). + !!! danger "Reminder" If you're a new developer tasked to work on this project, please get acquainted with the team [processes](https://forge.grandlyon.com/web-et-numerique/wiki_web_num) and read the advised [dev environment](https://forge.grandlyon.com/web-et-numerique/wiki_web_num) documentation and the self-data [prerequisites](../index.md#installing-prerequisites). - ##  Repositories -- [ecolyo](https://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo) -- [ecolyo-agent server](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server) -- [ecolyo-agent client](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client) \ No newline at end of file +- [Ecolyo](https://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo) +- [Ecolyo.com](https://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo_landing_page) +- Ecolyo Agent + - [Ecolyo-agent server](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server) + - [Ecolyo-agent client](https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client) + +## Konnectors + +Ecolyo heavily rely on konnectors to work, check our [konnector documentation](../konnectors/index.md). diff --git a/docs/ecolyo/project_architecture/doctypes.md b/docs/ecolyo/project_architecture/doctypes.md index 82e365d263abeb934b0b68683abfb566763a0ccc..7acbb1819c246dc36071a667a2cddea85596e2e7 100644 --- a/docs/ecolyo/project_architecture/doctypes.md +++ b/docs/ecolyo/project_architecture/doctypes.md @@ -1,16 +1,17 @@ +# Doctypes + ## Timeseries doctypes -### Description +**Description :** Each fluid has its own doctype wildcard and one doctype per time step. Each available time step for a fluid depends of the available data from the energy provider. Here are the different time step: -- **half an hour** - use com.grandlyon.\*.minute doctype -- **week** - use com.grandlyon.\*.day doctype -- **day** - use com.grandlyon.\*.day doctype -- **month** - use com.grandlyon.\*.month doctype -- **year** - use com.grandlyon.\*.year doctype +- **half an hour** - use `com.grandlyon.\*.minute` doctype +- **day** - use `com.grandlyon.\*.day` doctype +- **month** - use `com.grandlyon.\*.month` doctype +- **year** - use `com.grandlyon.\*.year` doctype -### Doctype +**Doctype :** Here are the available doctypes: @@ -20,7 +21,7 @@ Here are the available doctypes: | gas fluid / grdf | **`com.grandlyon.grdf.*`** | **`com.grandlyon.grdf.day`**<br>**`com.grandlyon.grdf.month`**<br>**`com.grandlyon.grdf.year`** | | water fluid / eau du grand lyon | **`com.grandlyon.egl.*`** | **`com.grandlyon.egl.day`**<br>**`com.grandlyon.egl.month`**<br>**`com.grandlyon.egl.year`** | -### Structure +**Structure :** | Field | Type | Description | | ------ | ------ | ---------------------------------------------------------------- | @@ -31,9 +32,9 @@ Here are the available doctypes: | month | number | month of the date<br>_set to 1 for year series_ | | year | number | year of the date | -### Example +Example: -``` +```json { "load": 770.18, "minute": 0, @@ -46,15 +47,15 @@ Here are the available doctypes: ## User profile -### Description +**Description :** This doctype is used to store all information about the user. -### Doctype +**Doctype:** **`com.grandlyon.ecolyo.profile`** -### Structure +**Structure:** | Field | Type | Description | | ------------------------ | ------------------- | --------------------------------------------------------------------------------------------------------------------------------- | @@ -74,9 +75,9 @@ This doctype is used to store all information about the user. | isProfileTypeCompleted | boolean | Check if a user has completed his consumption profile | | showConsentModal | boolean | Boolean used to show the terms acceptation page, and to protect the app private routes if last terms are not accepted or outdated | -### Example +**Example:** -``` +```json { "id": "0e016e853592e18155e87b85ce00a33a", "challengeHash": "4cbcafe514788757c377534f1a407e022c29e38c", @@ -117,15 +118,15 @@ This doctype is used to store all information about the user. ## Ecogesture -### Description +**Description :** This doctype is used to store ecogestures. -### Doctype +**Doctype:** **`com.grandlyon.ecolyo.ecogesture`** -### Structure +**Structure:** | Field | Type | Description | | --------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -148,9 +149,9 @@ This doctype is used to store ecogestures. | actionName | string or null | action description of the ecogesture | | actionDuration | number | duration required to do an action challenge | -### Example +**Example:** -``` +```json { "shortName": "Déesse des eaux", "longName": "Je coupe l'eau de la douche pendant que je me savonne.", @@ -179,15 +180,15 @@ This doctype is used to store ecogestures. ## Challenge -### Description +**Description :** This doctype is used to store all challenges. -### Doctype +**Doctype:** **`com.grandlyon.ecolyo.challenge`** -### Structure +**Structure:** | Field | Type | Description | | ------------- | ------ | ------------------------------------------------- | @@ -197,9 +198,9 @@ This doctype is used to store all challenges. | target | number | The number of stars required to unlock the duel | | relationships | any | relation to quiz and duel | -### Example +**Example:** -``` +```json { "_id": "CHALLENGE0001", "title": "Nicolas Hublot", @@ -221,15 +222,15 @@ This doctype is used to store all challenges. ## User challenge -### Description +**Description :** This doctype is used to store all additional information about a challenge started or ended by the user. -### Doctype +**Doctype:** **`com.grandlyon.ecolyo.userchallenge`** -### Structure +**Structure:** | Field | Type | Description | | ----------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -246,9 +247,9 @@ This doctype is used to store all additional information about a challenge start | startDate | string null | starting date of the the challenge | | endingDate | string null | ending date of the challenge | -### Example +**Example:** -``` +```json { "_id": "eae3a79a05d677a739bdd2b46b009936", "description": "foobar", @@ -438,15 +439,15 @@ This doctype is used to store all additional information about a challenge start ## Quiz -### Description +**Description :** This doctype is used to store all quiz. -### Doctype +**Doctype:** **`com.grandlyon.ecolyo.quiz`** -### Structure +**Structure:** | Field | Type | Description | | -------------- | -------------------- | ------------------------------------------- | @@ -454,9 +455,9 @@ This doctype is used to store all quiz. | questions | QuestionEntity[] | Array of questions entities | | customQuestion | CustomQuestionEntity | Custom question based on user's consumption | -### Example +**Example:** -``` +```json { "_id": "QUIZ001", "questions": [ @@ -541,15 +542,15 @@ This doctype is used to store all quiz. ## Exploration -### Description +**Description :** This doctype is used to store all explorations. -### Doctype +**Doctype:** **`com.grandlyon.ecolyo.exploration`** -### Structure +**Structure:** | Field | Type | Description | | --------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -563,9 +564,9 @@ This doctype is used to store all explorations. | fluid_condition | FluidType[] | Array of fluid type on which an exploration can have an impact<br><br>_FluidType enum:_<br>- _ELECTRICITY = 0_<br>- _WATER = 1_<br>- _GAS = 2_<br>- _MULTIFLUID = 3_ | | message_success | string | message when exploration is done | -### Example +**Example:** -``` +```json { "_id": "EXPLORATION001", "description": "Consultez l'écogeste Chat échaudé", @@ -581,15 +582,15 @@ This doctype is used to store all explorations. ## Duel -### Description +**Description :** This doctype is used to store all duels. -### Doctype +**Doctype:** **`com.grandlyon.ecolyo.duel`** -### Structure +**Structure:** | Field | Type | Description | | ----------- | -------- | -------------------------------------- | @@ -598,9 +599,9 @@ This doctype is used to store all duels. | description | string | description of the duel | | duration | Duration | Luxon Duration of the duel | -### Example +**Example:** -``` +```json { "_id": "DUEL001", "title": "Nicolas Hublot", @@ -611,15 +612,15 @@ This doctype is used to store all duels. ## Usage event -### Description +**Description :** This doctype is used to store all usage events. -### Doctype +**Doctype:** **`com.grandlyon.ecolyo.usageevent`** -### Structure +**Structure:** | Field | Type | Description | | ------- | -------------- | ------------------------------------------------------------------------------------------ | @@ -631,15 +632,15 @@ This doctype is used to store all usage events. ## Terms -### Description +**Description :** This doctype is used to store the different version of the terms of the application. -### Doctype +**Doctype:** **`io.cozy.terms`** -### Structure +**Structure:** | Field | Type | Description | | ---------- | -------- | ----------------------------------------------------------------- | @@ -650,15 +651,15 @@ This doctype is used to store the different version of the terms of the applicat ## MaxPower -### Description +**Description :** This doctype is used to store the enedis maxpower values retrieved by the konnector on a daily basis. The value is in kVA. -### Doctype +**Doctype:** **`com.grandlyon.enedis.maxpower`** -### Structure +**Structure:** | Field | Type | Description | | ------ | ------ | ---------------------------------------------------------------- | @@ -669,18 +670,17 @@ This doctype is used to store the enedis maxpower values retrieved by the konnec | month | number | month of the date | | year | number | year of the date | - ## Enedis Monthly Analysis Data -### Description +**Description :** This doctype is used to store the enedis monthly analysis, it includes the month average half-hour consumption for weekdays and weekends, the minimum half-hour load, and the max power consumption of the month. -### Doctype +**Doctype:** **`com.grandlyon.enedis.monthly.analysis.data`** -### Structure +**Structure:** | Field | Type | Description | | ------- | -------------- | ------------------------------------------------------------------------------------------ | diff --git a/docs/ecolyo/project_architecture/environments.md b/docs/ecolyo/project_architecture/environments.md index efe69acd96b4ee6a50d6afb772d2be462138ea69..1558fe2f7f81500283e738d4a26272075d9d9d3a 100644 --- a/docs/ecolyo/project_architecture/environments.md +++ b/docs/ecolyo/project_architecture/environments.md @@ -1,8 +1,9 @@ # Environments We have 2 environments available for this project: -- One environment of dev hosted on scaleway and managed by the dev team -- One environment of production hosted on Cozy and managed by Cozy + +- A dev environment hosted on scaleway and managed by the dev team +- A prod environment hosted on Cozy and managed by Cozy ## Dev environment aka alpha @@ -16,11 +17,12 @@ Once done, you should be able to connect to the server using your private key. ### Cozy stack -It is based on the easy-cozy project available on Gitlab: https://forge.grandlyon.com/pocs/cozy/easy-cozy +It is based on the easy-cozy project available on [Gitlab](https://forge.grandlyon.com/pocs/cozy/easy-cozy) On the server, the .env file has been initialize with the good secrets (see the .env.template) and also initialize to create instance with Ecolyo and the 3 needed konnectors by default. -This project will build and run 3 images: +This project will build and run 3 images: + - the cozy stack - the couch db - keycloak @@ -38,7 +40,8 @@ The proxy is written in Go language. The "main.go" file contains all the source Default variables are the one used for the dev environment but we will overwrite them for the production. To Launch the proxy, just pull the project and use the docker-compose file with following commands: -``` + +```sh git pull https://forge.grandlyon.com/pocs/cozy/cozy-oauth-proxy cd cozy-oauth-proxy docker-compose up -d @@ -64,6 +67,7 @@ A dedicated proxy is deployed on Cozy side to allow konnector to make the Oauth The proxy deployed is based on the project available on the Gitlab but variables are overwritten using flags by the Cozy team in order to fit to the environment. For each modification in production, it needs: + - to be done on the Gitlab project - to be tested in dev environment @@ -74,6 +78,7 @@ After that we should ask Cozy to pull the modification from the Gitlab in order The production environment is based on the build branch which should reflect the build of sources present on master branch. Each deployment is done manually for each app/konnector by: + - building the application (yarn build) - deploy the build on the build branch (yarn deploy) - publishing content of build branch into Cozy repository (yarn cozyPublish) diff --git a/docs/ecolyo/project_architecture/libraries.md b/docs/ecolyo/project_architecture/libraries.md index 8d2de86daf75a62495d2cad58eb666b4a7c32cf4..c8add43efca5edde160553866fd0c5b983ab6089 100644 --- a/docs/ecolyo/project_architecture/libraries.md +++ b/docs/ecolyo/project_architecture/libraries.md @@ -70,7 +70,7 @@ It allows to create react component that implements Google's material design It allows to manipulate documents based on data. It combines visualization components and a data-driven approach to DOM manipulation. -##React-swipeable-views +## React-swipeable-views It is a React component to make swipeable views diff --git a/docs/ecolyo/project_architecture/remote_doctypes.md b/docs/ecolyo/project_architecture/remote_doctypes.md index ad0cddfb66b4794e51af22cb1c2bf9d1f2241dca..bec5cd9d5cc8ce21a10c25f4d89aa021ba2d4ee1 100644 --- a/docs/ecolyo/project_architecture/remote_doctypes.md +++ b/docs/ecolyo/project_architecture/remote_doctypes.md @@ -1,6 +1,6 @@ # Creation of the remote doctype -The remote doctype should be created in the cozy repository : [https://github.com/cozy/cozy-doctypes](https://github.com/cozy/cozy-doctypes) +The remote doctype should be created in the cozy repository : [cozy-doctypes](https://github.com/cozy/cozy-doctypes) ## Remote doctype org.ecolyo.usage @@ -31,7 +31,7 @@ Content-Type: application/json {{data}} ``` -- add the _—doctypes_ command in the "docker/cozy-app-dev-with-app.sh" file and also the _-remote-allow-custom-port_ flag +- add the _—doctypes_ command in the `docker/cozy-app-dev-with-app.sh` file and also the _-remote-allow-custom-port_ flag ```bash ${COZY_STACK_PATH} serve --allow-root \ @@ -47,7 +47,7 @@ ${COZY_STACK_PATH} serve --allow-root \ --fs-url "file://localhost${vfsdir}" & ``` -- add the following content in "docker/disableCSP.yaml": +- add the following content in `docker/disableCSP.yaml`: ```yaml remote_assets: @@ -56,13 +56,13 @@ remote_assets: - Go to the docker folder in the project root -``` +```sh cd docker ``` -- build the docker image and tag it to [registry.forge.grandlyon.com/web-et-numerique/llle_project/ecolyo/cozy-env](http://registry.forge.grandlyon.com/web-et-numerique/llle_project/ecolyo/cozy-env): +- build the docker image and tag it to [ecolyo / Container Registry / cozy-env](https://forge.grandlyon.com/web-et-numerique/llle_project/ecolyo/container_registry): -``` +```sh docker build . -t registry.forge.grandlyon.com/web-et-numerique/llle_project/ecolyo/cozy-env ``` @@ -78,15 +78,15 @@ docker build . -t registry.forge.grandlyon.com/web-et-numerique/llle_project/eco docker-compose up ``` -- Change the content request param in io.cozy.doctypes/org.ecolyo.usage using the db tool ([http://localhost:5984/\_utils](http://localhost:5984/_utils)): +- Change the content request param in `io.cozy.doctypes/org.ecolyo.usage` using the [couch db](http://localhost:5984/_utils): ```bash "request": "POST https://API_URL\nContent-Type: application/json\n\n{{data}}", ``` -# Use of remote doctype in the application +## Use of remote doctype in the application -Add permission in manifest.webapp +Add permission in `manifest.webapp` ```json "ecolyo-usage": { @@ -99,7 +99,7 @@ Don't forget to add the description Call the remote docType: -```jsx +```js const result = await client .getStackClient() .fetchJSON('POST', '/remote/org.ecolyo.usage', { @@ -122,7 +122,7 @@ Content-Type: application/json When you call the remote doctype, you can directly pass the parameters to the doctype : -```jsx +```js const result = await client .getStackClient() .fetchJSON("GET", "/remote/org.ecolyo.usage/queryParam=yourParameter"); @@ -132,13 +132,13 @@ If you wanna know more about remote doctypes and how to store and use secret tok ## Add secrets to a remote -As above, you can pass a _{{secret_token}}_ to your remote doctype. In local, you can directly pass it as a request param in _io.cozy.doctypes/org.ecolyo.usage_. -Otherwise, you will have to add it in the shell script _easy-cozy/db-init.sh_ on the server. You can add the following line to the file in order to add the secret in the database : +As above, you can pass a _{{secret_token}}_ to your remote doctype. In local, you can directly pass it as a request param in `io.cozy.doctypes/org.ecolyo.usage`. +Otherwise, you will have to add it in the shell script `easy-cozy/db-init.sh` on the server. You can add the following line to the file in order to add the secret in the database : -``` +```sh docker-compose exec db curl -X PUT -d "{\"_id\":\"org.ecolyo.dju\",\"token\":\"${API_DATAGRANDLYON_TOKEN}\"}" http://127.0.0.1:5984/secrets%2Fio-cozy-remote-secrets/org.ecolyo.dju ``` Make sure you have the right remote doctype name as \_id. -Then, in the .env file, just add your token variable. +Then, in the `.env` file, just add your token variable. diff --git a/docs/ecolyo/services/aggregator_usage_events.md b/docs/ecolyo/services/aggregator_usage_events.md index 86cbf8ad2b7803f4abf9a859af0536db0147b498..63f0026dddc24b86359ce02038a77b38ea8c7a0d 100644 --- a/docs/ecolyo/services/aggregator_usage_events.md +++ b/docs/ecolyo/services/aggregator_usage_events.md @@ -1,27 +1,29 @@ # Definition of the service + The service will run each day at [TO BE DEFINED], as defined in the manifest: -``` +```json "aggregatorUsageEvents": { - "type": "node", - "file": "services/aggregatorUsageEvents/ecolyo.js", - "trigger": "[TO BE DEFINED]" - } + "type": "node", + "file": "services/aggregatorUsageEvents/ecolyo.js", + "trigger": "[TO BE DEFINED]" +} ``` -# Main responsibilities of the service + +## Main responsibilities of the service The service is responsible of : -1. Collecting all new events from the **com.grandlyon.ecolyo.usageevents** +1. Collecting all new events from the ``com.grandlyon.ecolyo.usageevents`` 2. Aggregated them to indicators 3. Send indicators to the remote doctype -# To do +## To do As the remote doctype is not yet available for the service here are the remaining task to do: - In the manifest.webapp: - - Declare the remote doctype (see here)[/ecolyo/project_architecture/remote_doctypes.md] + - Declare the remote doctype [see here](/ecolyo/project_architecture/remote_doctypes.md) - Define the cron to run every day: to check with cozy to ensure that all instances will not trigger the service at the same time - Create the translation for "fr" and "en" - In the service: diff --git a/docs/ecolyo/services/consumption_alert.md b/docs/ecolyo/services/consumption_alert.md index a6b12377c5c73bb0cdb842477e36085ab05f0adf..c41e66cff23b8497018f910bee2e1188d2a0e03c 100644 --- a/docs/ecolyo/services/consumption_alert.md +++ b/docs/ecolyo/services/consumption_alert.md @@ -1,29 +1,34 @@ -# Definition of the service +# Consumption alert + +## Definition of the service + The service will run everyday at 10.00 am, as defined in the manifest: -``` +```json "consumptionAlert": { "type": "node", "file": "services/consumptionAlert/ecolyo.js", "trigger": "@cron 0 3 * * *" - } +} ``` -# Main responsibilities of the service + +## Main responsibilities of the service The service is responsible of sending a mail to user to warn him about an overload in his fluid consumption (based on a limit the user fixed in the option panel). For now it only monitors water consumption. Main steps are the following: - - Check the "sendConsumptionAlert" and "waterDailyConsumptionLimit" attributes in the com.grandlyon.ecolyo.profile doctype. If "sendConsumptionAlert" is set to true and "waterDailyConsumptionLimit" is not set to 0, service will continue, else it will stop. - - Fetches metadata to customize the mail (Public name, instance url, consumption of the last day fetched by the egl konnector). - - Check that the last consumption is greater than the limit set by the user. If false the service will stop. - - Build the mail. - - Send the mail. -# Sending mail +- Check the "sendConsumptionAlert" and "waterDailyConsumptionLimit" attributes in the `com.grandlyon.ecolyo.profile` doctype. If "sendConsumptionAlert" is set to true and "waterDailyConsumptionLimit" is not set to 0, service will continue, else it will stop. +- Fetches metadata to customize the mail (Public name, instance url, consumption of the last day fetched by the egl konnector). +- Check that the last consumption is greater than the limit set by the user. If false the service will stop. +- Build the mail. +- Send the mail. + +## Sending mail -Doc of cozy for sendmail worker: https://docs.cozy.io/en/cozy-stack/workers/#sendmail-worker +[Sendmail worker docs](https://docs.cozy.io/en/cozy-stack/workers/#sendmail-worker) !!! Send mail in local In local you can use the mail hog tools to see the mail sent by the stack using http://cozy.tools:8025/ \ No newline at end of file diff --git a/docs/ecolyo/services/enedis_halfhour_monthly_analysis.md b/docs/ecolyo/services/enedis_halfhour_monthly_analysis.md index 51c532e0e04ab1f9f5a25658d64c168de7b91092..deeb0466acafce0a902360621ac7581746999759 100644 --- a/docs/ecolyo/services/enedis_halfhour_monthly_analysis.md +++ b/docs/ecolyo/services/enedis_halfhour_monthly_analysis.md @@ -1,28 +1,30 @@ # Definition of the service + The service will run everyday 3rd of month at 8.00 am, as defined in the manifest: +```json +"enedisHalfHourMonthlyAnalysis": { + "type": "node", + "file": "services/enedisHalfHourMonthlyAnalysis/ecolyo.js", + "trigger": "@cron 0 0 8 3 * *" +} ``` - "enedisHalfHourMonthlyAnalysis": { - "type": "node", - "file": "services/enedisHalfHourMonthlyAnalysis/ecolyo.js", - "trigger": "@cron 0 0 8 3 * *" - } -``` -# Main responsibilities of the service + +## Main responsibilities of the service The service is responsible of calculating the average consumption load for half hour timestep on a given month. It is exclusively for Electricity fluid. The data result is stored in the doctype *com.grandlyon.enedis.monthly.analysis.data* Main steps are the following : -- Check *com.grandlyon.enedis.minute* doctype. If the doctype contains entries, it means the half-hour consumption tracking has been activated, and there is data to use. +- Check `com.grandlyon.enedis.minute` doctype. If the doctype contains entries, it means the half-hour consumption tracking has been activated, and there is data to use. -- If there is half-hour data, creates the average consumption load for the last month (for the analysis) and store it in the doctype *com.grandlyon.enedis.monthly.analysis.data* +- If there is half-hour data, creates the average consumption load for the last month (for the analysis) and store it in the doctype `com.grandlyon.enedis.monthly.analysis.data` - Checks **if there is other entries** in this doctype, if so, it means the service has already run before, so we create and store enedis monthly analysis for every month between the first entry in the enedis.minute doctype and the first entry in the enedis.monthly.analysis doctype. This way we will have an analysis available until the first month the half-hour consumption tracking has been activated - **If there is no other entries** in this doctype, it means it is the first the service runs, so we create and store enedis analysis from the last month analysis and until the minimum date between 1 year ago and the the date of first enedis.minute doctype entry. -# Calculating the average half-hour consumption +## Calculating the average half-hour consumption In order to calculate the average half-hour consumption on a given month, we use the function *getEnedisMonthAnalysisData* which takes the cozy client , a month and a year in parameters. @@ -47,13 +49,14 @@ weekEndValuesArray : [ 23h30-00h : [day1Value, day2Value, day3value ..... lastWeekEndDayValue] ] ``` + - Once the array is filled with all available values, we just have to calculate the average for each half-hour step - The **minimum value** is calculated by the *getMonthMinLoad* function, it takes the complete week and weekend values arrays as parameters and return the minimum value, excluding -1 (empty values), and 0 (null values). This value is multiplied by 48 (the number of half hour entries in a day) and with the number of days in the month. -- The **maxpower** value is fetched from the doctype *com.grandlyon.enedis.maxpower*, the value is stored on a daily basis, so take the maximum value for the given month. -- The result is stored in *com.grandlyon.enedis.monthly.analysis.data* according to the following model : +- The **maxpower** value is fetched from the doctype `com.grandlyon.enedis.maxpower`, the value is stored on a daily basis, so take the maximum value for the given month. +- The result is stored in `com.grandlyon.enedis.monthly.analysis.data` according to the following model : -``` +```ts EnedisMonthlyAnalysisData { weekDaysHalfHourAverageValues: number[] weekEndDaysHalfHourAverageValues: number[] @@ -67,6 +70,5 @@ EnedisMonthlyAnalysisData { ## Important rules - The empty half-hour values represented by a "-1" are not pushed in the valuesArray so we can keep an accurate average -- We have no choice but to get the half-hour values day per day because cozy limits the request result number to 1000 entries, and it is not enough to get a maximum of 48*31= 1488 entries per month, plus it doesn't allows us to properly calculate and average and handle the empty values. +- We have no choice but to get the half-hour values day per day because cozy limits the request result number to 1000 entries, and it is not enough to get a maximum of 48*31= 1488 entries per month, plus it doesn't allows us to properly calculate and average and handle the empty values. - This service is quite long to run so we decided to run it 2 hours before the newsletter sending, this way user can acces his last enedis analysis once he received the newsletter. - diff --git a/docs/ecolyo/services/index.md b/docs/ecolyo/services/index.md index 453f104ff3d212f92df539f7486db1a0cada8350..d35d47eacc4d3de767d5c7ef208c85a566a8ec68 100644 --- a/docs/ecolyo/services/index.md +++ b/docs/ecolyo/services/index.md @@ -1,9 +1,13 @@ +# Description + In order to build an automated task within our cozy-stack, we can create *services* which are javascript files called from a trigger job. For instance on Ecolyo, to schedule a mail that alert the user that a new **monthly report** is available in the application, we add a trigger that is launched every month with a *cron* attribute. On that trigger we link a .js script then we instantiate this script with cozy-client. -# Configuration -## Manifest +## Configuration + +### Manifest + The service should be described in the manifest.webapp file. it should defined the type, the file and the trigger. See more information in the official doc of Cozy [here](https://docs.cozy.io/en/howTos/dev/services/) Here is an example of service declaration in the ecolyo manifest: @@ -15,5 +19,6 @@ File location is determined after the build, see [here](https://forge.grandlyon. !!! note "Cron" See the cron definition at [cozy-stack](https://docs.cozy.io/en/cozy-stack/jobs/#cron-syntax). -# Ecolyo services -Service code are located under **src\targets\services**. \ No newline at end of file +## Ecolyo services + +Service code are located under ``src\targets\services``. diff --git a/docs/ecolyo/services/monthly_report_notification.md b/docs/ecolyo/services/monthly_report_notification.md index 8ffebc98b5671bc2bf5504bd1b1f0683457103bf..1acfd5cc5be0df0bd039db35b39ea8c8d7931f15 100644 --- a/docs/ecolyo/services/monthly_report_notification.md +++ b/docs/ecolyo/services/monthly_report_notification.md @@ -1,26 +1,29 @@ # Definition of the service + The service will run the 3rd of each month at 10.00 am, as defined in the manifest: -``` +```json "monthlyReportNotification": { - "type": "node", - "file": "services/monthlyReportNotification/ecolyo.js", - "trigger": "@cron 0 0 10 3 * *" - } + "type": "node", + "file": "services/monthlyReportNotification/ecolyo.js", + "trigger": "@cron 0 0 10 3 * *" +} ``` -# Main responsibilities of the service + +## Main responsibilities of the service The service is responsible of sending a mail to user to warn him about the availability of a new information in the Analyse. Main steps are the following: - - Check the "sendReportNotification" attribute in the com.grandlyon.ecolyo.profile doctype. If true, service will continue, else it will stop. - - Fetches metadata to customize the mail (Public name, instance url). - - Build the mail. - - Send the mail. -# Sending mail +- Check the "sendReportNotification" attribute in the com.grandlyon.ecolyo.profile doctype. If true, service will continue, else it will stop. +- Fetches metadata to customize the mail (Public name, instance url). +- Build the mail. +- Send the mail. + +## Sending mail -Doc of cozy for sendmail worker: https://docs.cozy.io/en/cozy-stack/workers/#sendmail-worker +[Sendmail worker docs](https://docs.cozy.io/en/cozy-stack/workers/#sendmail-worker) !!! Send mail in local In local you can use the mail hog tools to see the mail sent by the stack using http://cozy.tools:8025/ \ No newline at end of file diff --git a/docs/external_doc.md b/docs/external_doc.md deleted file mode 100644 index e86b4bd03e67b6e38c51b9e31a89f430bd199ed8..0000000000000000000000000000000000000000 --- a/docs/external_doc.md +++ /dev/null @@ -1,13 +0,0 @@ -### Grandlyon resources - -Link | Details ----------------------------------- | -------- -[WIKI](https://forge.grandlyon.com/web-et-numerique/wiki_web_num) | This wiki covers all the processes and guidelines towards developers. - -### Cozy resources - - -Link | Details ----------------------------------- | -------- -[COZY](https://docs.cozy.io/en/) | Full technical documentation for all cozy libraries. -[MATTERMOST](https://mattermost.cozycloud.cc/) | Chat app for exchange between G.Lyon & Cozy. diff --git a/docs/index.md b/docs/index.md index 83fc5c56b0c2eb416f83e82f76ea5efdfed6bd31..9799b32ac4710d5dd9d4ee424dfddb3faa485262 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,152 +1,28 @@ -# +# Self Data Docs + {: .center} This documentation covers the technical aspects of projects developed by the Grandlyon in cooperation with [Cozy Cloud](https://cozy.io/fr/). -## Installing prerequisites - -In order to work with a self-data environment, there are a couple of prerequisites. Don't forget to take a look at our general development guidelines [wiki](https://forge.grandlyon.com/web-et-numerique/wiki_web_num) first. - -Name | Required | Details ----------------------------------- | -------- | ------- -[Node](https://nodejs.org/en/download/) | Yes | Node 16 must be installed as it is the version that runs on the official cozystack. -[Yarn](https://classic.yarnpkg.com/en/docs/install) | Yes | Yarn is our projects package manager. -[Docker](https://www.docker.com/get-started) | Yes | See [cozystack]() for more information. -[Docker-compose](https://docs.docker.com/compose/install/) | Yes -[WSL](index.md#wsl) | No | Required for windows users. - -## Usage - -### Node NVM - -You might need to manage several NodeJS versions on the same computer when working on different projects. To manage it properly, you can use the `nvm` package on windows or `n` package on linux. - -```console -$ yarn global add nvm -``` - -=== "Install a version" - ```console - $ nvm install X.X.X - ``` - -=== "See installed node versions" - ```console - $ nvm list - ``` - -=== "Switch to a specific version" - ```console - $ nvm use X.X.X - ``` - -=== "Check your current version" - ```console - $ node -v - ``` - - -### WSL - -First open Powershell as administrator and launch the following command: - -```powershell -dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart -``` - -This command will install WSL on your computer. After this, you'll need to ==**reboot**==. - -#### Upgrade to WSL 2 - -If you're on WSL 1 and want to upgrade to WSL 2, here is the process: - -1. Open an elevated powershell and paste the following command: - ```powershell - dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart - ``` +In order to work with a self-data environment, there are a couple of prerequisites. -2. Then, enable the Virtual Machine Platform optional feature. - ```powershell - dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart - ``` +## Resources -3. Now restart your computer to apply these features. Once it's done, open an elevated powershell again and set the default wsl version to 2 - ```console - $ wsl --set-default-version 2 - ``` +### Grandlyon resources -!!! warning "You might see this message after running the command above" - WSL 2 requires an update to its kernel component. - For information please visit [wsl2kernel](https://aka.ms/wsl2kernel). +Don't forget to take a look at our wiki describing general development guidelines [wiki](https://forge.grandlyon.com/web-et-numerique/wiki_web_num). It covers all the processes and guidelines towards developers. -If you install the MSI from [wsl2kernel](https://aka.ms/wsl2kernel). Once you have the kernel installed, please run `wsl --set-default-version 2` again and it should complete successfully without showing the message. - -#### Install your Linux distribution - -After reboot, open the microsoft store and install the distribution of your choice, for instance: ==Ubuntu 20.04 lts==. Once it's done, open it and after a few minutes you'll be prompted for the creation of a user account. - -To make sure it's correctly installed and working, you can open Powershell and paste the following command : - -```powershell -wsl.exe --list --running -``` - -Now you should see the name of your distribution in the list. - -#### Setup your distribution - -1. Start updating the packages list by typing: - ```console - $ sudo apt update - ``` - -2. Install nodejs using the apt package manager - ```console - $ sudo apt install - ``` - -3. To verify the Installation execute the following command: - ```console - $ nodejs --version - ``` - -4. To be able to download npm package, you need to install the npm, the Node.js package manager. To do so type: - ```console - $ sudo apt install npm - ``` - -5. To verify the npm Install check using the command: - ```console - $ npm --version - ``` - -6. To Download and Setup Yarn - ```console - $ sudo apt install yarn - ``` - -7. To check the installed version of Yarn: - ```console - $ yarn --version - ``` - -Now you'll probably be in version 0.23+git, if so you'll have to upgrade to 1.22 to make everything work properly. -In order to achieve this, you'll have to launch several commands: - -``` -sudo apt-get remove cmdtest -sudo apt autoremove -sudo apt-get update -sudo apt install curl -y -curl -o- -L https://yarnpkg.com/install.sh | bash -source ~/.bashrc -``` - -Now you should be at least in version ==^1.22== and ready to go on. +### Cozy resources +Link | Details +---------------------------------- | -------- +[Cozy docs](https://docs.cozy.io/en/) | Full technical documentation for all cozy libraries. +[Mattermost](https://mattermost.cozycloud.cc/) | Chat app for exchange between G.Lyon & Cozy. ## Contributing to the documentation +### Clone the project + To install and run the documentation on your laptop, follow the steps in the [README](https://forge.grandlyon.com/web-et-numerique/llle_project/self-data-technical-doc). Then: - Create a branch for your change @@ -154,5 +30,9 @@ To install and run the documentation on your laptop, follow the steps in the [RE - Write some [markdown](https://guides.github.com/features/mastering-markdown/) - Submit a merge request +### Click the edit button + +Click the edit button at the very top, commit to a new branch and open a merge request. + {: .inline-center-left} - \ No newline at end of file + diff --git a/docs/konnectors/egl.md b/docs/konnectors/egl.md index 53ead7542a3b2d0d7a1c15a2163f22e975d0335c..d69c40e8d659585e029103fa97add6be5e4a5372 100644 --- a/docs/konnectors/egl.md +++ b/docs/konnectors/egl.md @@ -1,10 +1,10 @@ -## EGL Konnector +# EGL Konnector + +[EGL repository](https://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector). This konnector fetches consumption measures from EGL API. The EGL API allows us to get a user's consumption data gathered by it's connected water meter "Téléo". -You can clone the project [here](https://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector). - You should also check Cozy's official documentations for konnectors : [https://docs.cozy.io/en/tutorials/konnector/getting-started/](https://docs.cozy.io/en/tutorials/konnector/getting-started/) @@ -22,21 +22,21 @@ Authentication Route : **/connect.asp** ```json "headers": { - { - "AuthKey": <your-auth-key>, - "Content-Type": "application/x-www-form-urlencoded" - } + { + "AuthKey": "<your-auth-key>", + "Content-Type": "application/x-www-form-urlencoded" + } } ``` ```json "body": { - "mode": "formdata" - { - "login": <your-login>, - "pass": <your-password> - } + "mode": "formdata" + { + "login": "<your-login>", + "pass": "<your-password>" + } } ``` @@ -47,8 +47,8 @@ Once you've sent this request the API should answer with a code 100 if everythin "codeRetour": 100, "libelleRetour": "Connecté", "resultatRetour": { - "num_abt": toto, - "list_num_abt": [toto, tata] + "num_abt": "toto", + "list_num_abt": ["toto", "tata"], "token": "xxxxxxxxxxx" } } @@ -66,13 +66,13 @@ Data Route : **/getAllAgregatsByAbonnement.aspx** "body": { - "mode": "formdata" - { - "token": "897555754A703055397897456568776E32704C3953514F5R", - "num_abt": 1895683, - "date_debut": MM/DD/YYYY, - "date_fin": MM/DD/YYYY - } + "mode": "formdata" + { + "token": "897555754A703055397897456568776E32704C3953514F5R", + "num_abt": 1895683, + "date_debut": "MM/DD/YYYY", + "date_fin": "MM/DD/YYYY" + } } ``` @@ -100,6 +100,7 @@ The answer will provide you an array of data day by day with the value got by th ``` Daily data is calculated by subtracting current valeurIndex day with previous day. + ### TypeAgregats - "R" means the real value diff --git a/docs/konnectors/enedis-sge.md b/docs/konnectors/enedis-sge.md index 2ecec7ba5608acd968833fa7220b3ddccf0bed21..d1f7cea314908f9cc59e9159fd65eecf72e06f90 100644 --- a/docs/konnectors/enedis-sge.md +++ b/docs/konnectors/enedis-sge.md @@ -1,19 +1,17 @@ -This konnector fetches consumption measures from Enedis SGE SOAP API. +# Enedis SGE Konnector + +This konnector fetches consumption measures from Enedis SGE SOAP API. You should also check Cozy's official documentations for konnectors : [https://docs.cozy.io/en/tutorials/konnector/getting-started/](https://docs.cozy.io/en/tutorials/konnector/getting-started/) -# Enedis SGE Konnector - -!!! warning "This konnector is in a POC state" - ## Enedis context The API used by this konnector are the one used by all energy providers (edf, total...), this one is supposed to have a high availability. Contrary to enedis oauth konnector, this is a regular auth konnector. ## Technical overview -### Lib used +### Lib used - xml2js: Lib allowing easy parsing to json - easy-soap-request: Lib making soap request @@ -22,7 +20,7 @@ The API used by this konnector are the one used by all energy providers (edf, to For now enedis API are proxied by WSO2 api manager. You can find documentation and devportal [here](https://apis.grandlyon.fr/devportal). -### Scaffolding +### Scaffolding - core/types: contains jsdoc types - core/: requests wrapper with error handling logic @@ -30,6 +28,7 @@ For now enedis API are proxied by WSO2 api manager. You can find documentation a - requests/: contain all methods for : Parsing sge requests, Send/get backoffice data, interactions with cozy stack - index.js: main file where default konnector methods are launch (start, ...) - onDeleteAccount.js: hold consent suppression when a user delete an account. Automatically launched on delete. + ### ts-check In order to have better comfort while coding, we have enable ts-checking with vs-code. The verification is based on js-doc, please take time to maintain the js-doc. @@ -59,8 +58,8 @@ In order to local test you have to put the following configuration in `konnector "apiToken": "<SGE_TOKEN>" } } - ``` + Replace every `<***>` with your test values and corresponding secrets. !!! warning "user consent" @@ -78,6 +77,7 @@ yarn onDeleteAccount #Run onDeleteAccount script with real cozy For standalone cmd you can find konnector results in `/data/importedData.json` ### Konnector Methods + | Method | Description | | ------ | ------ | | start | Main method of konnector. Handle global flow and init method with provided params | @@ -95,18 +95,18 @@ For standalone cmd you can find konnector results in `/data/importedData.json` ### Overview -Functional and technical flow chart: +Functional and technical flow chart: [Lien du schema](https://whimsical.com/sge-tech-DxbYM8DdajRjTr6WZat1bV) ### Authentication -Information required: +Information required: - Name - Surname - PointID (PDL) -- Full address +- Full address - Postal Code - City @@ -130,7 +130,7 @@ Data Route : **enedis_SGE_ConsultationDonneesTechniquesContractuelles/1.0** </soapenv:Body> ``` -#### Get daily data and Get Half-hour data +#### Get daily data and Get Half-hour data Method : **POST** @@ -160,6 +160,7 @@ Data Route : **enedis_SGE_ConsultationMesuresDetaillees/1.0** </soapenv:Body> </soapenv:Envelope> ``` + #### Get Max Power data Method : **POST** @@ -190,11 +191,13 @@ Data Route : **enedis_SGE_ConsultationMesuresDetaillees/1.0** </soapenv:Body> </soapenv:Envelope> ``` + #### Get contract information Method : **POST** Data Route : **enedis_SGE_enedis_SGE_ConsultationDonneesTechniquesContractuelles/1.0** + ```xml <?xml version='1.0' encoding='utf-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" @@ -211,7 +214,7 @@ Data Route : **enedis_SGE_enedis_SGE_ConsultationDonneesTechniquesContractuelles </soapenv:Envelope> ``` -#### Get user PDL <a name="recherche_services_mesures"></a> +#### Get user PDL Method : **POST** @@ -264,7 +267,7 @@ Data Route : **enedis_SGE_RechercheServicesMesures/1.0** </soapenv:Envelope> ``` -#### Start user contract <a name="user_contract_start"></a> +#### Start user contract Method : **POST** @@ -309,6 +312,7 @@ Data Route : **enedis_SGE_CommandeCollectePublicationMesures/1.0** ``` #### Stop User contract + ```xml <?xml version='1.0' encoding='utf-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" @@ -362,7 +366,7 @@ Data Route : **enedis_SGE_ConsultationDonneesTechniquesContractuelles/1.0** #### Contract deletion and creation on same day -If you stop a contract on a day, (for exemple 8/08/22), you cannot start a new contract for this date with [start contract route](#user_contract_start). You have to wait for the next day. This might cause some production issues +If you stop a contract on a day, (for exemple 8/08/22), you cannot start a new contract for this date with [start contract route](./enedis-sge.md#user_contract_start). You have to wait for the next day. This might cause some production issues #### User data collect opposition @@ -383,4 +387,4 @@ Users can remove consent from enedis account on data collecting. This will retur </serviceSouscritMesures> ``` -We cannot override that, the only solution is to tell the user to activate data collect on [enedis](https://mon-compte-particulier.enedis.fr/donnees/). \ No newline at end of file +We cannot override that, the only solution is to tell the user to activate data collect on [enedis](https://mon-compte-particulier.enedis.fr/donnees/). diff --git a/docs/konnectors/enedis.md b/docs/konnectors/enedis.md index b965762d60d8516b851e1b5368e7e128aa240999..cbafa9709f915274d3e83db3e5937ff33ae28cbf 100644 --- a/docs/konnectors/enedis.md +++ b/docs/konnectors/enedis.md @@ -1,4 +1,5 @@ -## Enedis Konnector +# Enedis Konnector + !!! warning "DEPRECATED" This section of documentation is not relevant anymore, enedis data connect has been replaced with enedis sge @@ -9,7 +10,6 @@ You should also check Cozy's official documentations for konnectors : [https://docs.cozy.io/en/tutorials/konnector/getting-started/](https://docs.cozy.io/en/tutorials/konnector/getting-started/) [https://docs.cozy.io/en/tutorials/konnector/oauth/](https://docs.cozy.io/en/tutorials/konnector/oauth/) - The Oauth protocol does not take place in the konnector code, therefore it is also important to take a look at the [proxy](/proxy/description/) documentation to fully understand all the interactions that will be told below. All the actions performed by the stack are targeted from pre-registered parameters, here is the list of all parameters needed by the stack to perform the Oauth protocol and allow the konnector to fetch data. @@ -19,8 +19,8 @@ On its first launch, following the Oauth Client Connect authentication. - The account has now an access_token and an id_token from the oauth call !!! info "" -id token is only given when requesting the token endpoint in \_authorization_code grant_type. -This token holds several meta data, including the usage_point_id (id of user's meter) that will be needed further to fetch user's data. + id token is only given when requesting the token endpoint in \_authorization_code grant_type. + This token holds several meta data, including the usage_point_id (id of user's meter) that will be needed further to fetch user's data. - Konnector starts, if no usage_point_id are found in database or fields then proceed as a first launch. Store the usage_point_id in oauth_callback_result in db (see [addData](https://docs.cozy.io/en/cozy-konnector-libs/api/#adddata_1)). - Konnector finds usage*point_id when starting but token is expired. Proceed to refresh token and restart konnector with usage_point_id in fields params (see \_Troubleshooting when asking for refresh token* section at the end of the page). @@ -46,7 +46,7 @@ Route : **/v4/metering_data/daily_consumption_max_power** ```json "params": { - "usage_point_id": <your-usage-point-id>, + "usage_point_id": "<your-usage-point-id>", "start": "YYYY-MM-DD", "end": "YYYY-MM-DD", } @@ -55,7 +55,7 @@ Route : **/v4/metering_data/daily_consumption_max_power** ```json "headers": { - "Accept": "application/json", + "Accept": "application/json", "Authorization": "Bearer xxxxxxxxxxx" } ``` @@ -89,20 +89,25 @@ When a token expires, the konnector will encounter an error when fetching user d Since refresh token requests restart the Konnector, it was decided to add the `usage_point_id` into the start fields when asking for a refresh token (see line 97). !!! info "restart to refresh token" -Line 85: `` await cozyClient.fetchJSON( 'POST', `/accounts/enedisgrandlyon/${accountId}/refresh` ) `` + ```js + // Line 85 + await cozyClient.fetchJSON( 'POST', `/accounts/enedisgrandlyon/${accountId}/refresh`) - Line 97: ```fields.usage_point_id = usage_point_id``` + // Line 97 + fields.usage_point_id = usage_point_id - Line 98: ```return start(fields, cozyParameters, false)``` + // Line 98 + return start(fields, cozyParameters, false) + ``` In fact the usage_point_id still remains in the account collection, but on restart, the konnector loses `this._account` context leading to an error when searching for usage_point_id in account. ## Half-hour data issue When requesting the load curve api while the half-hour data is not activated, we may have an error response 404 with a message "no data found", which makes the whole data fetching process crash. So instead of making it crash we just log this particular error and avoid the konnector to crash. -So we added a condition in line 227, in the _checkConsentForLoadCurve_ function : +So we added a condition in line 227, in the *checkConsentForLoadCurve* function : -``` +```js if ( (err.statusCode === 404 || err.code === 404) && err.message.search('no_data_found') > 0 diff --git a/docs/konnectors/grdf.md b/docs/konnectors/grdf.md index 8ab1579dc1325a5bcc7528ddbf7a35938f4fd99b..518c98acb290b92f0d98f51d1f516969e8e508a4 100644 --- a/docs/konnectors/grdf.md +++ b/docs/konnectors/grdf.md @@ -1,3 +1,5 @@ +# Grdf Adict Konnector + This konnector fetches consumption measures from Grdf Adict API. This is an Oauth Konnector, meaning the authentication performed to access all data is made following an Oauth2 protocol. You can clone the project [here](https://forge.grandlyon.com/web-et-numerique/llle_project/grdf-adict-konnector). @@ -5,8 +7,6 @@ You should also check Cozy's official documentations for konnectors : [https://docs.cozy.io/en/tutorials/konnector/getting-started/](https://docs.cozy.io/en/tutorials/konnector/getting-started/) [https://docs.cozy.io/en/tutorials/konnector/oauth/](https://docs.cozy.io/en/tutorials/konnector/oauth/) -## Grdf Adict Konnector - The Oauth protocol does not take place in the konnector code, therefore it is also important to take a look at the [proxy](/proxy/description/) documentation to fully understand all the interactions that will be told below. All the actions performed by the stack are targeted from pre-registered parameters, here is the list of all parameters needed by the stack to perform the Oauth protocol and allow the konnector to fetch data. @@ -19,8 +19,8 @@ On its first launch, following the Oauth Client Connect authentication. - The account has now an access_token and an id_token from the oauth call !!! info "" -id*token is only given when requesting the token endpoint in \_authorization_code* grant_type. -This token holds several meta data, including the pce_id (id of user's meter) that will be needed further to fetch user's data. + id _token is only given when requesting the token endpoint in \_authorization_code- grant_type. + This token holds several meta data, including the pce_id (id of user's meter) that will be needed further to fetch user's data. - Konnector starts, fails to find a pce_id in database on first launch therefore decodes the id_token to store the pce_id in db (see [addData](https://docs.cozy.io/en/cozy-konnector-libs/api/#adddata_1)). - Konnector restarts, this time knowing a pce_id, it fails to fetch data because the access_token from oauth call has a reduced scope (only scoping for meta data requests). @@ -29,7 +29,7 @@ This token holds several meta data, including the pce_id (id of user's meter) th - Further jobs will not need to change scope again and will only ask for refresh tokens. -### Konnector Flow summarized +## Konnector Flow summarized ```plantuml Start -> Restart: No Pce_id @@ -65,7 +65,7 @@ Build the konnector with `yarn build`. `sudo docker cp /home/easy-cozy/fun/grdf-konnector/build/ $container_id:/tmp/grdf-oauth` -`sudo docker-compose exec cozy ./cozy konnectors install grdf-oauth --domain "$alphaDomain" file:///tmp/grdf-oauth $container_id ` +`sudo docker-compose exec cozy ./cozy konnectors install grdf-oauth --domain "$alphaDomain" file:///tmp/grdf-oauth $container_id` ### Install on production diff --git a/docs/konnectors/index.md b/docs/konnectors/index.md index 2f0157b6b5feebcdb2c481d0335831ba3bee836f..73894c2c7403ce24e8f037b3fb1e4e9494ecd0c8 100644 --- a/docs/konnectors/index.md +++ b/docs/konnectors/index.md @@ -1,7 +1,8 @@ -Konnectors are scripts that import data from a web service and put those data into cozy. Each konnector is an independent application managed by the cozy home application. +# Introduction +Konnectors are scripts that import data from a web service and put those data into cozy. Each konnector is an independent application managed by the cozy home application. -Ecolyo uses data from 3 web services : +Ecolyo uses data from 3 web services : - Enedis - Grdf @@ -19,4 +20,4 @@ Some variation have to be considered : - [enedis dataconnect (deprecated)](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-konnector) - [enedis sge](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector) - [grdf](https://forge.grandlyon.com/web-et-numerique/llle_project/grdf-konnector) -- [egl](https://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector) \ No newline at end of file +- [egl](https://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector) diff --git a/docs/pilote/Pilote - TS - Back/application/deploy.md b/docs/pilote/Pilote - TS - Back/application/deploy.md deleted file mode 100644 index 9b1701fe4f02cb62b84cf01624fd5ff94472d525..0000000000000000000000000000000000000000 --- a/docs/pilote/Pilote - TS - Back/application/deploy.md +++ /dev/null @@ -1,7 +0,0 @@ -### Deployment - -For each environment, the CI-CD is implemented. - -Once, you commit on 'dev' branch or 'rec' branch, the pipeline linked is running. - -On master branch, only build is set on the pipeline. \ No newline at end of file diff --git a/docs/pilote/Pilote - TS - Back/project_architecture/architecture.md b/docs/pilote/Pilote - TS - Back/project_architecture/architecture.md deleted file mode 100644 index 9817c7f27171d002b5567ae6a128af2dae5a063f..0000000000000000000000000000000000000000 --- a/docs/pilote/Pilote - TS - Back/project_architecture/architecture.md +++ /dev/null @@ -1,18 +0,0 @@ -# Techno used - -- NestJS -- Jest for the tests -- Docker -- PostgreSQL - - -# Docker-compose - -Two docker-compose are available into the project: -- the general one -- the local one - - -For the general one, all service are details. The env variable used are available on Synapps server. - -The local one is used with the docker-compose_dev.yml \ No newline at end of file diff --git a/docs/pilote/Pilote - TS - Front/.gitkeep b/docs/pilote/Pilote - TS - Front/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/docs/pilote/Pilote - Usager/application/deploy.md b/docs/pilote/Pilote - Usager/application/deploy.md deleted file mode 100644 index 33be66e3eab35bfd144da7ce5cc132cd6b7c4107..0000000000000000000000000000000000000000 --- a/docs/pilote/Pilote - Usager/application/deploy.md +++ /dev/null @@ -1,112 +0,0 @@ -:construction: Section under Construction :construction: - -This section will show you how to deploy your project on different environments. - -## Setup - -First of all you'll need to install [MobaXterm](https://mobaxterm.mobatek.net/download.html) in order to connect to the server. -Then, if you're on Linux you can skip the following section, otherwise if you are on Windows you'll have to install Windows Subsystem for Linux (WSL) since the deployment of the app is not working with windows commands. - -### Install WSL - -First open Powershell as administrator and launch the following command : - -```powershell -dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart -``` - -This command will install WSL on your computer. After this, you'll need to **reboot**. - -### Install your Linux distribution - -After reboot, open the microsoft store and install the distribution of your choice (for example : Ubuntu 20.04 lts). Once it's done, open it and after a few minutes you'll be prompted for the creation of a user account. - -To make sure it's correctly installed and working, you can open Powershell and paste the following command : - -```powershell -wsl.exe --list --running -``` -Now you should see the name of your distribution in the list. - -### Setup your distribution - -Start Up Updating the packages list by typing : -``` -sudo apt update -``` - -Install the nodejs using the apt package manager - -``` -sudo apt install -``` - -To verify the Installation execute the following command : -``` -nodejs --version -``` - -To be able to download npm package, you need to install the npm, the Node.js package manager. To do so type : -``` -sudo apt install npm -``` - -To verify the npm Install check using the command : -``` -npm --version -``` -To Download and Setup Yarn -``` -sudo apt install yarn -``` - -To check the Installed version of Yarn : - -``` -yarn --version -``` - -Now you'll probably be in version 0.23+git, if so you'll have to upgrade to 1.22 to make everything work properly. -In order to achieve this, you'll have to launch several commands : - -``` -sudo apt-get remove cmdtest -sudo apt autoremove -sudo apt-get update -sudo apt install curl -y -curl -o- -L https://yarnpkg.com/install.sh | bash -source ~/.bashrc -``` -Now you should be at least in version ^1.22 and ready to go on. - - -## Configuration of MobaXterm - -First open a new session and connect to the distant host **192.168.62.31**. Don't forget to add the path to the private key in the advanced SSH settings. - -## Deploy Pilote - -### Deploy on Alpha - -#### Windows - -First open your Ubuntu terminal, and clone the project in the repository of your choice. Once you've selected the branch of you want to deploy, write the following command : -``` -yarn build -``` -After this, you can launch the deployment. -In order to deploy on pilote-dev-build (development environment) use the command : - -``` -yarn deploy-dev -``` - -If you want to deploy on the pilote-build environment, use : - -``` -yarn deploy -``` - -#### Linux - -From your current branch, run ```yarn build``` then ```sudo yarn deploy_dev``` to instantly deploy your working branch on the latest tagged Pilote container registry. diff --git a/docs/pilote/Pilote - Usager/application/doctypes.md b/docs/pilote/Pilote - Usager/application/doctypes.md deleted file mode 100644 index cb6ee38c542bdaa298ad4ba42d1610c2c61a0fe7..0000000000000000000000000000000000000000 --- a/docs/pilote/Pilote - Usager/application/doctypes.md +++ /dev/null @@ -1,108 +0,0 @@ -# Doctypes - -Doctypes represent different types of data. Their primary use is for permissions: an app or konnector will request permissions for one or several doctypes and will not be able to access other doctypes. See [Doctypes documentation](https://docs.cozy.io/en/cozy-doctypes/docs/) for more information. - -The following is a full description of the doctypes we use and their fields. Cozy doctypes won't be fully described. Instead, for every used one, we'll include a link to its official documentation. - - - -## Used Cozy doctypes - -- [`io.cozy.accounts`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.accounts): Konnector accounts -- [`io.cozy.apps`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.apps/): Installed apps -- [`io.cozy.contacts`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.contacts): Contacts -- [`io.cozy.contacts.groups`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.contacts.groups): Contacts groups -- [`io.cozy.files`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.files): Files -- [`io.cozy.permissions`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.permissions): Permissions of the instance -- [`io.cozy.konnectors`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.konnectors/): Konnectors -- [`io.cozy.triggers`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.triggers): Job triggers - -## Used Cozy remote doctypes -This kind of doctype are set from the team. We have push two remote doctypes (each duplicate for rec and prod environment) - -> Prod -- [`org.mps.store`]: Required to store information on back-end TS -- [`org.mps.share`]: Required to search on back-end TS - -> Recette - -- [`org.mps.store.rec`]: Required to store information on rec back-end TS -- [`org.mps.share.rec`]: Required to search on rec back-end TS - -If you need to target rec remote doctype, you need to change the request : client.getStackClient().fetchJSON('POST','...') -and change them into the manifest also. - - -## Custom doctypes - -- `com.grandlyon.mps.profile` - - ##### Attributes - - - `tutorial`: {`object`} contains `contacts`, `documents`, `actions`, and `notes`. They represent the state of tutorials. For example, `contacts: true` means the contacts tutorial hasn't been seen yet and will be visible to the user the next time he visits the contacts component. - - `notification`: {`boolean`} If equals true, the user has a notification - - `fullname`: {`string`} User's full name - - `introduction`: {`boolean`} If equals `true`, it means the user has already used the app and seen the introduction. - - `lastConnectionDate` : {`string`} When was the user last connected (ISO string). - - `hasPhone`: {`boolean`} Equals true if the current user has already a phone number - - `userID`: {`string`} Current user id - - `publicProfile`: {`object`} contains `fullname`, `endDate` (ISO string), and `isActive` - - - -- `com.grandlyon.mps.appointments` - - ##### Attributes - - - `id`: {`string`} the appointment id - - `appointmentDate`: {`string`} the appointment date (ISO string) - - `note`: {`Note`} A unique note for each appointment - - `objectives`: {`Array<Objective>`} The list of appointment's objectives - - - -- `com.grandlyon.mps.objectives` - - ##### Attributes - - - `id`: {`string`} the objective id - - `title`: {`string`} the objective title - - `type`: {`string`} The id of the Objective type - - `subtype`: {`string`} The id of the Objective subType - - `tasks`: {`Array<Task>`} Array of Tasks ids - - `archived`: {`boolean`} If equals true, it mean the objective has been completed - - - -- `com.grandlyon.mps.tasks` - - ##### Attributes - - - `id`: {`string`} The task id - - `name`: {`string`} The task name - - `description`: {`string`} The task description - - `state`: {`TaskState`} It could be one of the following: `'USER_TO_VALID', 'USER_VALID', 'PUBLIC_VALID', 'PUBLIC_INVALID'` - - `qualifications`: {`Array<string>`} - - `items`: {`Array<TaskItem>`} - - - -- `com.grandlyon.mps.task.items` - - ##### Attributes - - - `id`: {`string`} Item id - - `file`: {`DocumentEntity`} The items' file - - `state`: {`TaskItemState`} It could be one of the following: `'USER_ITEM_PENDING', 'PUBLIC_ITEM_VALID', 'PUBLIC_ITEM_INVALID'` - - - -- `com.grandlyon.mps.notes` - - ##### Attributes - - - `id`: {`string`} Note's id - - `content`: {`string`} The content of the note. - - `createdAt`: {`string`} Date of creation (ISO string) - - diff --git a/docs/pilote/Pilote - Usager/application/gitflow.md b/docs/pilote/Pilote - Usager/application/gitflow.md deleted file mode 100644 index bbe88921dcbffeeaa80251b9c7f8fc6b1ac571d5..0000000000000000000000000000000000000000 --- a/docs/pilote/Pilote - Usager/application/gitflow.md +++ /dev/null @@ -1,67 +0,0 @@ -## Initialize - -- Create a new project in Gitlab and take note of its URL - -### Protecting Master Branch - -On the Gitlab page of your project go to *Settings/Repository* in the *Protected Branches* section. -Select the **Master** branch and set **allow to merge** to ***Master*** and **allow to push** to **No one** -This will prevent anyone to push on the master branch, the only way to add code to the branch will be merge requests. - -### Setting Development Branch - -- Retrieve the project on your computer, open a command line and execute. - -``` -git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager.git -``` - -- Create the development branch - -``` -git checkout -b dev -``` - -- Init your project and then type any time you want to commit changes: - -``` -git add . -git commit -m "Commit changes" -git push origin dev -``` - -## Start Developing - -For any other development you should create a branch from the development branch. - -First make sure to be on the ***dev*** branch, type: - -``` -git branch -``` - -> to see your current branch - -### Conventional Commits - -A `feature` branch name should follow this structure: - -- *feat/<title_of_the_user_story\>* - -You can create the branch by typing: - -``` -git checkout -b feat/<title_of_the_user_story> -``` - -Each fix branch should be named as the following *fix-\<title_of_the_fix\>*. - -**Breaking Change** -Appends a `!` before the title of the commit to notify that a breaking change has happened. Give a solid description of the changes as well. - -**add tag** - -``` -git tag -a 1.0.0 -m "complementary message" -``` - diff --git a/docs/pilote/Pilote-TS-Back/application/deploy.md b/docs/pilote/Pilote-TS-Back/application/deploy.md new file mode 100644 index 0000000000000000000000000000000000000000..a428850cf7fa751cd6423eb01ad87320ce604567 --- /dev/null +++ b/docs/pilote/Pilote-TS-Back/application/deploy.md @@ -0,0 +1,7 @@ +# Deploy + +For each environment, the CI-CD is implemented. + +Once, you commit on 'dev' branch or 'rec' branch, the pipeline linked is running. + +On master branch, only build is set on the pipeline. diff --git a/docs/pilote/Pilote - TS - Back/functionalities/routes.md b/docs/pilote/Pilote-TS-Back/functionalities/routes.md similarity index 81% rename from docs/pilote/Pilote - TS - Back/functionalities/routes.md rename to docs/pilote/Pilote-TS-Back/functionalities/routes.md index b338be641207e070637fc1f8498069c046e555a0..9b568b15f8f98da237f1d75efcb7d5fc4209f49b 100644 --- a/docs/pilote/Pilote - TS - Back/functionalities/routes.md +++ b/docs/pilote/Pilote-TS-Back/functionalities/routes.md @@ -1,47 +1,51 @@ +# Routes + This section explains the different API route. Descriptions are not currently up-to-date. A swagger documentation can be consulted at [http://localhost:3000/api/doc/](http://localhost:3000/api/doc/) -# Auth +## Auth - `api/auth/signin`: It is used for local and dev authentication. It is linked to two different password into the database. - - `api/auth/token` : It is used for generate one token. Only for internal process. This route is not call from another apps. - - `api/auth/token/check`: It is used for check one token. It is called from cozy-stack service of the usager. - - `api/auth/token`: It is used for generate one token. Only for internal process. This route is not call from another apps. - - `api/auth/login`: It is used for Sign&Go authentication. Linked to AuthStrategy. - - `login/callback`: Get the authentication from Sign&Go process. - -# Beneficiary +## Beneficiary - `/api/beneficiaire`: Get all usager known from Postgre database. - - `/api/beneficiaire/create'`: This route is used in order to store Usager domain and his trigger process from Cozy. This route is protected by a COZY_SECRET env variable token. This token is generated by us. If you change it, you need to inform Cozy team because this token is store in their side also. - - `/api/beneficiaire/remove'`: This route is used in order to remove Usager domain and his trigger process. Only available by POST. This route is not accessible from any part of TS FRONT application. Protected rout by the same token of create route. ## Add one beneficiary by Postman + - Create a POST request - Entry the URL: http://localhost:3020/api/beneficiaire/create or https://pilote-agent-rec.grandlyon.com/api/beneficiaire/create - Push in Authorization/ Bearer Token => the token use by "process.env.COZY_SECRET" -- In Body, as JSON format example : -- `` -{"cozy_name":"pilote-rec.cozy.self-data.alpha.grandlyon.com","trigger":"https://pilote-rec.cozy.self-data.alpha.grandlyon.com/jobs/webhooks/d010bf3fa2aed6f3c6584ea93a54affc"} -`` -- Local : `` -{"cozy_name":"pilote.cozy.tools:8080","trigger":"http://pilote.cozy.tools:8080/jobs/webhooks/"} -`` +- In Body, as JSON format example : + +```json +{ + "cozy_name":"pilote-rec.cozy.self-data.alpha.grandlyon.com", + "trigger":"https://pilote-rec.cozy.self-data.alpha.grandlyon.com/jobs/webhooks/d010bf3fa2aed6f3c6584ea93a54affc" +} +``` -# Cozy +- Local : + +```json +{ + "cozy_name":"pilote.cozy.tools:8080", + "trigger":"http://pilote.cozy.tools:8080/jobs/webhooks/" +} +``` + +## Cozy - `api/redirect/cozy`: Allow to send information to the cozy-stack in order to run smsProcess on cozy-stack side. -# Users +## Users Authentication only used for local or dev environment because Sign&Go is only available for rec and prod env. - diff --git a/docs/pilote/Pilote - TS - Back/getting_started/launch_local_application.md b/docs/pilote/Pilote-TS-Back/getting_started/launch_local_application.md similarity index 76% rename from docs/pilote/Pilote - TS - Back/getting_started/launch_local_application.md rename to docs/pilote/Pilote-TS-Back/getting_started/launch_local_application.md index ccd891cd6fa8d1f245267b87685e2036dd527d24..6df2992efcd062e25b9e5dfbd9eee89e17330302 100644 --- a/docs/pilote/Pilote - TS - Back/getting_started/launch_local_application.md +++ b/docs/pilote/Pilote-TS-Back/getting_started/launch_local_application.md @@ -1,10 +1,10 @@ -## Initialisation of the project +# Launch the application on local -### Clone the project repository +## Initialisation of the project -Use following command in your favorite terminal to clone the project: +Clone the project using the following command: -``` +```sh git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial-back.git ``` @@ -12,38 +12,37 @@ git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travaille ### Start Pilote application -Copy the ```template.env``` into ```.env``` +Copy the `template.env` into `.env` To start Pilote application just launch the following command in a terminal : -``` +```sh yarn docker-compose -f docker-compose.dev.yml up -d ``` If the application starts successfully you should obtain two containers running: +```sh +docker ps +# mps-travailleursocial-back_mps_1 +# mps-travailleursocial-back_postgres_1 ``` - mps-travailleursocial-back_mps_1 - mps-travailleursocial-back_postgres_1 -``` - -You can access by: http://localhost:3020/api -It will be redirect to the Swagger UI. It allow to test the different API defined. +You can access by: <http://localhost:3020/api> +It will be redirect to the Swagger UI. It allow to test the different API defined. -### Run Jest test +### Run Jest test To start test defined just run the command in a Powershell or Windows Powershell tool: -``` +```sh yarn test:watch ``` Don't forget to uncomment ending row into beneficiary.service.ts file before to run the above command. - ### Useful docker command - build : `docker build -t mps .` @@ -54,15 +53,15 @@ Don't forget to uncomment ending row into beneficiary.service.ts file before to - delete image/containers: `docker system prune -a -f` -- enter container: `docker exec -it <id_container> bash` +- enter container: `docker exec -it <id_container> bash` - remove container: `docker container rm -f <id_container>` -## Synapps environment +## Synapps environment - check mps container : `docker ps --filter "name=mps"` or use this alias created : `dpm` - docker stop <id_container> - run a service from the docker-compose file: `docker-compose up -d <name_of_service>` | -example: `docker-compose up -d mps-prod` , `docker-compose up -d app` , .... \ No newline at end of file +example: `docker-compose up -d mps-prod` , `docker-compose up -d app` , .... diff --git a/docs/pilote/Pilote-TS-Back/project_architecture/architecture.md b/docs/pilote/Pilote-TS-Back/project_architecture/architecture.md new file mode 100644 index 0000000000000000000000000000000000000000..04339c29a885c3fc183dc0d1c0adbb9d11129962 --- /dev/null +++ b/docs/pilote/Pilote-TS-Back/project_architecture/architecture.md @@ -0,0 +1,19 @@ +# Architecture + +## Techno used + +- NestJS +- Jest for the tests +- Docker +- PostgreSQL + +## Docker-compose + +Two docker-compose are available into the project: + +- the general one +- the local one + +For the general one, all service are details. The env variable used are available on Synapps server. + +The local one is used with the docker-compose_dev.yml diff --git a/docs/pilote/Pilote - TS - Back/project_architecture/share_sms.png b/docs/pilote/Pilote-TS-Back/project_architecture/share_sms.png similarity index 100% rename from docs/pilote/Pilote - TS - Back/project_architecture/share_sms.png rename to docs/pilote/Pilote-TS-Back/project_architecture/share_sms.png diff --git a/docs/pilote/Pilote - TS - Front/application/deploy.md b/docs/pilote/Pilote-TS-Front/application/deploy.md similarity index 54% rename from docs/pilote/Pilote - TS - Front/application/deploy.md rename to docs/pilote/Pilote-TS-Front/application/deploy.md index c54a693706c9895183f3ca504c1953b11deb7171..a2d79e3fb54053902cd881ed3a5ceb2a4da2c3c8 100644 --- a/docs/pilote/Pilote - TS - Front/application/deploy.md +++ b/docs/pilote/Pilote-TS-Front/application/deploy.md @@ -1,5 +1,5 @@ # Deployment -For each environment, the CI-CD is implemented. +For each environment, the CI-CD is implemented. -Once, you commit on 'dev' branch or 'rec' branch, the pipeline liked is running. \ No newline at end of file +Once, you commit on 'dev' branch or 'rec' branch, the pipeline liked is running. diff --git a/docs/pilote/Pilote - TS - Front/functionalities/functions.md b/docs/pilote/Pilote-TS-Front/functionalities/functions.md similarity index 72% rename from docs/pilote/Pilote - TS - Front/functionalities/functions.md rename to docs/pilote/Pilote-TS-Front/functionalities/functions.md index c3dc47fb6525881d4618c7a7c06af9fd1873a559..7813bdb6399ea4637151b7611028462080aa9e22 100644 --- a/docs/pilote/Pilote - TS - Front/functionalities/functions.md +++ b/docs/pilote/Pilote-TS-Front/functionalities/functions.md @@ -1,13 +1,15 @@ +# Routes + This section explains the different functionalities: -# Beneficiaries +## Beneficiaries Once you are authenticated, you'll redirect into /liste-beneficiaire route. You are getting all usager known. -# Sharing +## Sharing -For each beneficiary, you can ask the sharing. It means that you will be redirect into the public page of the cozy usager. In the same time, one process is running in order to send the sms. This sms contain one sharecode in order to provide some right on the cozy usager. +For each beneficiary, you can ask the sharing. It means that you will be redirect into the public page of the cozy usager. In the same time, one process is running in order to send the sms. This sms contain one sharecode in order to provide some right on the cozy usager. -In order to help you to understand this process, you can check : Pilote - TS - Back/project_architecture/share_sms.png \ No newline at end of file + diff --git a/docs/pilote/Pilote - TS - Front/getting_started/launch_local_application.md b/docs/pilote/Pilote-TS-Front/getting_started/launch_local_application.md similarity index 77% rename from docs/pilote/Pilote - TS - Front/getting_started/launch_local_application.md rename to docs/pilote/Pilote-TS-Front/getting_started/launch_local_application.md index 69beb3ef62832a3cc4270b079aabe84848301925..2c73b448ed02a859266029369f9b0c5c688a2539 100644 --- a/docs/pilote/Pilote - TS - Front/getting_started/launch_local_application.md +++ b/docs/pilote/Pilote-TS-Front/getting_started/launch_local_application.md @@ -1,10 +1,10 @@ -## Initialisation of the project +# Launch the application on local -### Clone the project repository +## Initialisation of the project -Use following command in your favorite terminal to clone the project: +Clone the project using the following command : -``` +```sh git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial.git ``` @@ -14,19 +14,18 @@ git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travaille Before to start Pilote application, you need to run this command in order to install dependencies: -``` +```sh yarn ``` -Copy the ```template.env``` into ```.env``` +Copy the `template.env` into `.env` To start Pilote application, make sure the server is running and launch the command in a terminal : -``` +```sh yarn start ``` If the application starts successfully you should access to: > [http://localhost:4200/](http://localhost:4200/) - diff --git a/docs/pilote/Pilote-Usager/application/deploy.md b/docs/pilote/Pilote-Usager/application/deploy.md new file mode 100644 index 0000000000000000000000000000000000000000..cbd3e094990ca370b93afdb07a017e7e93874c39 --- /dev/null +++ b/docs/pilote/Pilote-Usager/application/deploy.md @@ -0,0 +1,31 @@ +# Deploy + +:construction: Section under Construction :construction: + +This section will show you how to deploy your project on different environments. + +## Setup + +First of all you'll need to install [MobaXterm](https://mobaxterm.mobatek.net/download.html) in order to connect to the server. +Then, if you're on Linux you can skip the following section, otherwise if you are on Windows you'll have to install Windows Subsystem for Linux (WSL) since the deployment of the app is not working with windows commands. + +## Deploy Pilote + +### Deploy on Alpha + +First open your terminal, write the following commands : + +```sh +yarn build +``` + +After this, you can launch the deployment. +In order to deploy on pilote-dev-build (development environment) use the command : + +```sh +yarn deploy-dev +# OR for branch build +yarn deploy +``` + +Then go on server and use scripts to update your instance diff --git a/docs/pilote/Pilote-Usager/application/doctypes.md b/docs/pilote/Pilote-Usager/application/doctypes.md new file mode 100644 index 0000000000000000000000000000000000000000..51857d1127e9cf6127f0e3b6c75e7ad8e60da8d4 --- /dev/null +++ b/docs/pilote/Pilote-Usager/application/doctypes.md @@ -0,0 +1,77 @@ +# Doctypes + +Doctypes represent different types of data. Their primary use is for permissions: an app or konnector will request permissions for one or several doctypes and will not be able to access other doctypes. See [Doctypes documentation](https://docs.cozy.io/en/cozy-doctypes/docs/) for more information. + +The following is a full description of the doctypes we use and their fields. Cozy doctypes won't be fully described. Instead, for every used one, we'll include a link to its official documentation. + +## Used Cozy doctypes + +- [`io.cozy.accounts`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.accounts): Konnector accounts +- [`io.cozy.apps`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.apps/): Installed apps +- [`io.cozy.contacts`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.contacts): Contacts +- [`io.cozy.contacts.groups`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.contacts.groups): Contacts groups +- [`io.cozy.files`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.files): Files +- [`io.cozy.permissions`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.permissions): Permissions of the instance +- [`io.cozy.konnectors`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.konnectors/): Konnectors +- [`io.cozy.triggers`](https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.triggers): Job triggers + +## Used Cozy remote doctypes + +This kind of doctype are set from the team. We have push two remote doctypes (each duplicate for rec and prod environment) + +> Prod + +- [`org.mps.store`]: Required to store information on back-end TS +- [`org.mps.share`]: Required to search on back-end TS + +> Recette + +- [`org.mps.store.rec`]: Required to store information on rec back-end TS +- [`org.mps.share.rec`]: Required to search on rec back-end TS + +If you need to target rec remote doctype, you need to change the request : client.getStackClient().fetchJSON('POST','...') +and change them into the manifest also. + +## Custom doctypes + +- `com.grandlyon.mps.profile` + - `tutorial`: {`object`} contains `contacts`, `documents`, `actions`, and `notes`. They represent the state of tutorials. For example, `contacts: true` means the contacts tutorial hasn't been seen yet and will be visible to the user the next time he visits the contacts component. + - `notification`: {`boolean`} If equals true, the user has a notification + - `fullname`: {`string`} User's full name + - `introduction`: {`boolean`} If equals `true`, it means the user has already used the app and seen the introduction. + - `lastConnectionDate` : {`string`} When was the user last connected (ISO string). + - `hasPhone`: {`boolean`} Equals true if the current user has already a phone number + - `userID`: {`string`} Current user id + - `publicProfile`: {`object`} contains `fullname`, `endDate` (ISO string), and `isActive` + +- `com.grandlyon.mps.appointments` + - `id`: {`string`} the appointment id + - `appointmentDate`: {`string`} the appointment date (ISO string) + - `note`: {`Note`} A unique note for each appointment + - `objectives`: {`Array<Objective>`} The list of appointment's objectives + +- `com.grandlyon.mps.objectives` + - `id`: {`string`} the objective id + - `title`: {`string`} the objective title + - `type`: {`string`} The id of the Objective type + - `subtype`: {`string`} The id of the Objective subType + - `tasks`: {`Array<Task>`} Array of Tasks ids + - `archived`: {`boolean`} If equals true, it mean the objective has been completed + +- `com.grandlyon.mps.tasks` + - `id`: {`string`} The task id + - `name`: {`string`} The task name + - `description`: {`string`} The task description + - `state`: {`TaskState`} It could be one of the following: `'USER_TO_VALID', 'USER_VALID', 'PUBLIC_VALID', 'PUBLIC_INVALID'` + - `qualifications`: {`Array<string>`} + - `items`: {`Array<TaskItem>`} + +- `com.grandlyon.mps.task.items` + - `id`: {`string`} Item id + - `file`: {`DocumentEntity`} The items' file + - `state`: {`TaskItemState`} It could be one of the following: `'USER_ITEM_PENDING', 'PUBLIC_ITEM_VALID', 'PUBLIC_ITEM_INVALID'` + +- `com.grandlyon.mps.notes` + - `id`: {`string`} Note's id + - `content`: {`string`} The content of the note. + - `createdAt`: {`string`} Date of creation (ISO string) diff --git a/docs/pilote/Pilote - Usager/application/store.md b/docs/pilote/Pilote-Usager/application/redux.md similarity index 87% rename from docs/pilote/Pilote - Usager/application/store.md rename to docs/pilote/Pilote-Usager/application/redux.md index 11753239a9175234a9e9f55f69f3ef3530cb0865..965057cd66ca382051ccf45101bb8120d9d40cb8 100644 --- a/docs/pilote/Pilote - Usager/application/store.md +++ b/docs/pilote/Pilote-Usager/application/redux.md @@ -1,22 +1,21 @@ # Redux -We are using **Redux** for our application state management. it maintains the state of the entire application in a single immutable state tree (object), which can't be changed directly. When something changes, a new object is created (using actions and reducers). For more information about Redux, visit The [official documentation][https://redux.js.org/]. +We are using **Redux** for our application state management. it maintains the state of the entire application in a single immutable state tree (object), which can't be changed directly. When something changes, a new object is created (using actions and reducers). For more information about Redux, visit The [official documentation](https://redux.js.org/). ## Store The following are the existing store entities used by our application: - `Profile`: Preserves the state of tutorials, user profile, public profile, introduction, and notifications (see initial state below). - -- `Global`: Preserves the global state, which includes `isPublic` `toast` and `error` +- `Global`: Preserves the global state, which includes `isPublic` `toast` and `error` - `Appointment`: Preserves the state of tutorials and notifications. -- `UploadDocument`: Manages the state of uploaded documents. +- `UploadDocument`: Manages the state of uploaded documents. -#### Initial states +### Initial states -##### Profile +#### Profile -```javascript +```js { tutorial: { // Tells if a tutorial has already been seen contacts: true, @@ -40,9 +39,9 @@ The following are the existing store entities used by our application: } ``` -##### Global +#### Global -```javascript +```js { isPublic: false, toast: null, // Manages global messages toasts @@ -50,9 +49,9 @@ The following are the existing store entities used by our application: } ``` -##### Appointment +#### Appointment -```javascript +```js { id: '', appointmentDate: '', // ISO string @@ -65,9 +64,9 @@ The following are the existing store entities used by our application: } ``` -##### UploadDocument +#### UploadDocument -```javascript +```js { file: null, qualification: null, @@ -76,11 +75,11 @@ The following are the existing store entities used by our application: For each reducer file, a test file is associated testing the reducer. -All the actions are tested in a separate file with the same actions file name. +All the actions are tested in a separate file with the same actions file name. ## Used packages - **react-redux**: Official React bindings for [Redux](https://github.com/reduxjs/redux). - **react-redux**: [Thunk middleware](https://github.com/reduxjs/redux-thunk) for Redux. - **redux-devtools-extension**: For application's state changes debugging. -- **@types/react-redux**: This package contains type definitions for react-redux. \ No newline at end of file +- **@types/react-redux**: This package contains type definitions for react-redux. diff --git a/docs/pilote/Pilote - Usager/application/scaffolding.md b/docs/pilote/Pilote-Usager/application/scaffolding.md similarity index 99% rename from docs/pilote/Pilote - Usager/application/scaffolding.md rename to docs/pilote/Pilote-Usager/application/scaffolding.md index 464221051a9895fb7d191d1dfcf314ad1e194a8a..2d646784fc7771699398b88eb7d689386e1ad75d 100644 --- a/docs/pilote/Pilote - Usager/application/scaffolding.md +++ b/docs/pilote/Pilote-Usager/application/scaffolding.md @@ -33,4 +33,3 @@ In this section, you will find information about the project file structure and | tsconfig.json | Typescript config file | | konnector-dev-config.json | To locally test konnectors | | service-dev-config.json | To locally test services | - diff --git a/docs/pilote/Pilote - Usager/application/services.md b/docs/pilote/Pilote-Usager/application/services.md similarity index 91% rename from docs/pilote/Pilote - Usager/application/services.md rename to docs/pilote/Pilote-Usager/application/services.md index 79bec2d819c3cd3a0203a4f6440e2961267d9fb6..d9a7a41a722c1c40fd653c582add94cffe5d8f58 100644 --- a/docs/pilote/Pilote - Usager/application/services.md +++ b/docs/pilote/Pilote-Usager/application/services.md @@ -1,16 +1,12 @@ -## Profile Service +# Services -### Functions +## Profile Service - `getProfile`: Tries fetching the profile if it exists. If not, it creates a new one and returns it. - `updateProfile`: Updates the profile. - `parseProfile`: Returns the Profile passed as a parameter without the following properties: `_id, id, _type, _rev, cozyMetadata`. - - -## Notes Service - -### Functions +## Notes Service - `parseNote`: Returns the Note passed as a parameter without the following properties: `_id, _type, _rev, cozyMetadata`. - `getNoteByIDs`: Returns a list of Notes from a list of ids. @@ -19,11 +15,7 @@ - `getCurrentNoteOrCreate`: Returns the Note linked to the current Appointment. If id does not exist, it creates and returns a new one. - `getAllNotes`: Returns a list of all Notes. - - -## Appointments Service - -### Functions +## Appointments Service - `parseAppointment`: Returns an Appointment from an appointmentEntity. - `getLastAppointment`: Returns the last Appointment, which a user can see first in /actions. @@ -32,12 +24,8 @@ - `createAppointment`: Creates a new Appointment. - `updateAppointment`: Updates an Appointment. - - ## Documents Service -### Functions - - `getAllDocuments`: Returns the list of all documents. - `getDocumentsByQualification`: Returns a document by a qualification. - `getDocumentsByQualifications`: Uses `getDocumentsByQualification` to return a list of documents from a list of qualifications. @@ -54,12 +42,8 @@ - `replaceFile`: Replaces a file. - `keepFile`: Changes a file's name and saves it. - - ## Contacts Service -### Functions - - `getCurrentUser`: Returns the contact with an existing `me` field, which represents the current user. - `getAllContacts`: Returns a list of all contacts. - `findContactById`: Returns a contact by its id. @@ -67,26 +51,16 @@ - `updateContact`: Updates an existing contact. - `deleteContactById`: Deletes a contact by its id. - - ## Groups Service -## Function - - `createMetroGroup`: Creates a new group and returns it. - `getMetroGroup`: Returns the group if it exists or creates it if it doesn't. - - -## Initialization Service +## Initialization Service - `Initialization`: {`Object`} Initializes the profile, actions, and the appDirectory. - - -## Konnectors Service - -### Functions +## Konnectors Service - `getAllKonnectors`: Returns a list of all the Konnectors. - `getAllKonnectorSlugs`: Returns a list of all the Konnectors' slugs. @@ -95,11 +69,7 @@ - `getKonnectorByName`: Returns a Konnector from its name. - `getKonnectorsFromDocuments`: Returns a list of Konnectors from a passed documentEntity list. - - -## Objectives Service - -### Functions +## Objectives Service - `parseObjective`: Returns the Objective passed as a parameter without the following properties: `_type, _rev, _id, cozyMetadata, relationships`. - `getObjectiveByIDs`: Returns a list of Objectives from a list of ids. @@ -107,11 +77,7 @@ - `createObjective`: Creates a new Objective. - `updateObjective`: Updates an existing Objective. - - -## Tasks Service - -### Functions +## Tasks Service - `parseTaskJSONToTask`: Returns a Task from a TaskJSON. - `parseTask`: Returns the Task passed as a parameter without the following properties: `_type, _rev, _id, cozyMetadata, relationships`. @@ -119,21 +85,13 @@ - `createTask`: Creates a new Task. - `updateTask`: Updates a Task from its id. - - -## TaskItems Service - -### Functions +## TaskItems Service - `parseTaskItem`: Returns the TaskItem passed as a parameter without the following properties: `_type, _rev, _id, cozyMetadata, relationships`. - `getTaskItemByIDs`: Returns a list of TaskItems from a list of ids. - `createTaskItem`: Creates a new TaskItem. - `updateTaskItem`: Updates a TaskItem from its id. +## Triggers Service - -## Triggers Service - -### Functions - -- `getAllTriggers`: Returns All the triggers filtered by type if passed as parameter. \ No newline at end of file +- `getAllTriggers`: Returns All the triggers filtered by type if passed as parameter. diff --git a/docs/pilote/Pilote - Usager/functionalities/appointments.md b/docs/pilote/Pilote-Usager/functionalities/appointments.md similarity index 100% rename from docs/pilote/Pilote - Usager/functionalities/appointments.md rename to docs/pilote/Pilote-Usager/functionalities/appointments.md diff --git a/docs/pilote/Pilote - Usager/functionalities/contact.md b/docs/pilote/Pilote-Usager/functionalities/contact.md similarity index 92% rename from docs/pilote/Pilote - Usager/functionalities/contact.md rename to docs/pilote/Pilote-Usager/functionalities/contact.md index 48df10d0bd0130acc9acbaba9b0181db5ae788f9..b54767debb80f92db0f8bc36786fa4e12ca10c35 100644 --- a/docs/pilote/Pilote - Usager/functionalities/contact.md +++ b/docs/pilote/Pilote-Usager/functionalities/contact.md @@ -1,6 +1,6 @@ -## Description +# Contact Pilote allow usager to add contact : + - You will always see your profile at the first contact. You can not delete it. Just edit it. - Then, with the add concat button, you can add others contact - diff --git a/docs/pilote/Pilote - Usager/functionalities/cozy-registry.md b/docs/pilote/Pilote-Usager/functionalities/cozy-registry.md similarity index 96% rename from docs/pilote/Pilote - Usager/functionalities/cozy-registry.md rename to docs/pilote/Pilote-Usager/functionalities/cozy-registry.md index a766411137dc4547e35020b84758395435a48418..d038a22ec2577d8026917771337867f079d4325f 100644 --- a/docs/pilote/Pilote - Usager/functionalities/cozy-registry.md +++ b/docs/pilote/Pilote-Usager/functionalities/cozy-registry.md @@ -1,9 +1,9 @@ -## Description +# Cozy registry Pilote Usager is linked to a registry to allow a TS to find and connect to a user Pilote app. A service is run every day to send instance information to the registry. -### Service Flow summarized +## Service Flow summarized ```plantuml "Pilote Usager" -> "Cozy Registry": POST firstName, lastName, cozyURL, smsTriggerId @@ -16,8 +16,10 @@ A service is run every day to send instance information to the registry. ``` ## Launch the service locally + - Switch to Node 16 (using nvm or n) - install local remote doctypes (details [here](https://doc.self-data.alpha.grandlyon.com/ecolyo/project_architecture/remote_doctypes/#local-remote-doctype)), add a folder named org.mps.registry.dev, inside it add a file named request with the following content : + ``` POST https://cozy-registry.poc.self-data.alpha.grandlyon.com/api/pilote Authorization: Bearer {{secret_token}} @@ -25,13 +27,16 @@ Content-Type: application/json {{data}} ``` + - in the database, if it doesn't exist, create a table named secrets/io-cozy-remote-secrets and add a document with the following content : + ```json { "_id": "org.mps.registry.dev", "token": "pilotecozytoken" } ``` + - launch `docker-compose up` in a first terminal - launch `yarn build` in a second terminal - launch `yarn run cozy-konnector-dev -m ./manifest.webapp ./build/services/cozyRegistry/pilote.js` to execute the service diff --git a/docs/pilote/Pilote - Usager/functionalities/document.md b/docs/pilote/Pilote-Usager/functionalities/document.md similarity index 100% rename from docs/pilote/Pilote - Usager/functionalities/document.md rename to docs/pilote/Pilote-Usager/functionalities/document.md diff --git a/docs/pilote/Pilote - Usager/functionalities/setting.md b/docs/pilote/Pilote-Usager/functionalities/setting.md similarity index 58% rename from docs/pilote/Pilote - Usager/functionalities/setting.md rename to docs/pilote/Pilote-Usager/functionalities/setting.md index 2e733efc862de8d651335ac2be29cc9693db68fb..320d08b4aec9808f08bd7de76c5881f2fbcf7e31 100644 --- a/docs/pilote/Pilote - Usager/functionalities/setting.md +++ b/docs/pilote/Pilote-Usager/functionalities/setting.md @@ -1,8 +1,8 @@ -## Description +# Settings -Pilote has setting page. You can found : -- Notifications: Under construction +Pilote has setting page. You can found : + +- Notifications: Under construction - Tutorial: allow to view again one of the tutorial available - FAQ: Different explication of the global application - Legal Notice - diff --git a/docs/pilote/Pilote - Usager/getting_started/launch_local_application.md b/docs/pilote/Pilote-Usager/getting_started/launch_local_application.md similarity index 90% rename from docs/pilote/Pilote - Usager/getting_started/launch_local_application.md rename to docs/pilote/Pilote-Usager/getting_started/launch_local_application.md index 846bcc8d7e311d20855511efc9a73adabf87291d..34e4598d9bdd3b06162eb3b8dfb7d748e12ccfa2 100644 --- a/docs/pilote/Pilote - Usager/getting_started/launch_local_application.md +++ b/docs/pilote/Pilote-Usager/getting_started/launch_local_application.md @@ -1,10 +1,12 @@ +# Launch local application + ## Initialisation of the project ### Clone the project repository Use the following command in your favorite terminal to clone the project: -``` +```sh git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager ``` @@ -14,13 +16,13 @@ git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager Before starting Pilote Usager application, you need to install dependencies: -``` +```sh yarn ``` To start Pilote Usager application, you first need start the application and start a cozy stack: -``` +```sh yarn start docker-compose up @@ -29,7 +31,7 @@ docker-compose up As the pilote application has been recently upgraded to NodeJS 16 version, you might need to install additional packages in order to be able to run the app. Make sure your have the following installed : - Python3 -- Microsoft Visual Studio tools 2017 +- Microsoft Visual Studio tools 2017 - node-gyp And wait for the success message. @@ -41,4 +43,4 @@ Once successful you can launch your local cozy with following url [Cozy local ur To start a social worker instance, go to [**options page**](http://pilote.cozy.tools:8080/#/settings) and click '**Get sharecode**'. -Open the console and you'll see a link redirecting to a TS instance. \ No newline at end of file +Open the console and you'll see a link redirecting to a TS instance. diff --git a/docs/pilote/Pilote - Usager/getting_started/launch_local_doctypes.md b/docs/pilote/Pilote-Usager/getting_started/launch_local_doctypes.md similarity index 88% rename from docs/pilote/Pilote - Usager/getting_started/launch_local_doctypes.md rename to docs/pilote/Pilote-Usager/getting_started/launch_local_doctypes.md index b7266428dc28d76e8ad3da3b670ed512f1a2cb92..461e11aeb179d159a51880fe12fa86d22375172f 100644 --- a/docs/pilote/Pilote - Usager/getting_started/launch_local_doctypes.md +++ b/docs/pilote/Pilote-Usager/getting_started/launch_local_doctypes.md @@ -1,4 +1,5 @@ -## Use cozy-doctype in local +# Use cozy-doctype in local + In order to be able to use our own cozy-doctype, especially remote doctype here, we need to use them in local. 1/ clone [cozy-doctypes](https://github.com/cozy/cozy-doctypes) repository into your system. @@ -6,11 +7,12 @@ Then, push it into your root project. 2/ After that, add your own remote doctype into cozy-doctype folder: - - create a new folder ex: org.mps.share - - push into this folder request file: request + - create a new folder ex: org.mps.share + - push into this folder request file: request You must declare this doctype into your manifest.webapp file like that : -``` + +```json "share": { "description": "Required for searching on back-endTS", "type": "org.mps.share", @@ -18,21 +20,25 @@ You must declare this doctype into your manifest.webapp file like that : }, ``` - 3/ In cozy-app-dev-with-app.sh, you need to add another option when you serve the cozy-stack: -``` + +```sh cozy-stack serve --allow-root (...) --doctypes /path/to/the/doctype ``` + => in this project : -``` + +```sh cozy-stack serve (...) --doctypes /data/cozy-doctypes ``` + !!! warning "warning" You need to build and push the newest image on the forge registry when the step 3 is done. You must have all files, into your docker folder, in LF mode of "End of Line Sequence" ! For this project: -``` + +```sh cd docker docker build . docker tag <image_ID_created> registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes @@ -42,17 +48,21 @@ docker push registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager 4/ The path "/data/cozy-doctypes" is linked to the volume of the cozy-app-dev image. In order to mount this volume, you need to add it when you run the 'docker run' command : + ``` -v $PWD/cozy-doctypes:/data/cozy-doctypes ``` => for this project : -``` + +```sh docker run --rm -it -p 8080:8080 -p 5984:5984 -p 8025:8025 -v $PWD/build:/data/cozy-app/mps -v $PWD/data:/usr/local/couchdb/data -v $PWD/docker/disableCSP.yaml:/etc/cozy/cozy.yaml -v $PWD/cozy-doctypes:/data/cozy-doctypes registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes ``` -# How to test your remote doctype ? -## GET +## How to test your remote doctype ? + +### GET + 1/ In the request file created. Specify the method and the route to your target URL : GET https://pilote-agent-dev.grandlyon.com/api/cozy @@ -61,19 +71,20 @@ docker run --rm -it -p 8080:8080 -p 5984:5984 -p 8025:8025 -v $PWD/build:/data/c GET https://pilote-agent-dev.grandlyon.com/api/auth/token/check?token={{token}} - 2/ Then, you can test it by : -``` + +```js await client.getStackClient().fetchJSON('GET','/remote/org.mps.share') ``` or with value in query : +```js +await client.getStackClient().fetchJSON('GET','/remote/org.mps.share?token=eyJhb...') ``` -await client.getStackClient().fetchJSON('GET','/remote/org.mps.share?token=eyJhb...' ) -``` -## POST +### POST + 1/ In the request file created. Specify the method and the route to your target URL : POST https://pilote-agent-dev.grandlyon.com/api/auth/token/check @@ -81,9 +92,9 @@ await client.getStackClient().fetchJSON('GET','/remote/org.mps.share?token=eyJhb {{data}} - 2/ Then, you can test it by : -``` + +```js const parameters = { data: JSON.stringify({ token: "eyJhb..." diff --git a/docs/pilote/Pilote - Usager/getting_started/launch_local_services.md b/docs/pilote/Pilote-Usager/getting_started/launch_local_services.md similarity index 81% rename from docs/pilote/Pilote - Usager/getting_started/launch_local_services.md rename to docs/pilote/Pilote-Usager/getting_started/launch_local_services.md index 064f8f67604852693802a9237f78fc52c3c83d40..2857509c5383d7f87783ce16269b3621b789b463 100644 --- a/docs/pilote/Pilote - Usager/getting_started/launch_local_services.md +++ b/docs/pilote/Pilote-Usager/getting_started/launch_local_services.md @@ -1,17 +1,20 @@ -### Use services in local +# Use services in local + ## Configure the cozy-stack on local -In order to be able to use your service, follow these steps: + +In order to be able to use your service, follow these steps: 1/ clone [cozy-doctypes](https://github.com/cozy/cozy-doctypes) repository into your system. Then, push it into your root project. 2/ After that, add your own remote doctype into cozy-doctype folder: - - create a new folder ex: org.mps.share - - push into this folder request file: request + - create a new folder ex: org.mps.share + - push into this folder request file: request You must declare this doctype into your manifest.webapp file like that : -``` + +```json "share": { "description": "Required for searching on back-endTS", "type": "org.mps.share", @@ -20,20 +23,22 @@ You must declare this doctype into your manifest.webapp file like that : ``` 3/ In cozy-app-dev-with-app.sh, you need to add another option when you serve the cozy-stack: -``` + +```sh cozy-stack serve --allow-root (...) --doctypes /path/to/the/doctype ``` => in this project : -``` + +```sh cozy-stack serve (...) --doctypes /data/cozy-doctypes ``` 4/ You need to add another option when you install apps in the cozy-stack (go to: docker\cozy-app-dev-with-app.sh) -In do_install_app(): +In do_install_app(): -``` +```sh #add symbolic link to mps for sms service ln -s /data/cozy-app/mps /data/cozy-storage/cozy.tools\:8080/.cozy_apps/mps if [ -d "data/cozy-app/mps/0.1.1" ]; then @@ -48,14 +53,17 @@ In do_install_app(): echo "service added" ``` -5/ Then, add konnector-node-run.sh in docker folder. This file is a script to store the service logs. It should contain: - #!/bin/bash +5/ Then, add konnector-node-run.sh in docker folder. This file is a script to store the service logs. It should contain: - rundir="${1}" - cd $rundir - node index.js | tee /data/cozy-app/mps/services.log +```sh +#!/bin/bash -Then, add this following row into the Dockerfile: +rundir="${1}" +cd $rundir +node index.js | tee /data/cozy-app/mps/services.log +``` + +Then, add this following row into the Dockerfile: COPY konnector-node-run.sh /etc/cozy/konnector-node-run.sh @@ -64,13 +72,13 @@ COPY konnector-node-run.sh /etc/cozy/konnector-node-run.sh konnectors: cmd: /etc/cozy/konnector-node-run.sh # run connectors with node - !!! warning "warning" You need to build and push the newest image on the forge registry when the step 6 is done. You must have all files, into your docker folder, in LF mode of "End of Line Sequence" ! Finally, you should rebuild the docker image of the cozy-stack: -``` + +```sh cd docker docker build . docker tag <image_ID_created> registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes @@ -80,32 +88,35 @@ docker push registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager 7/ The path "/data/cozy-doctypes" is link to the volume of the cozy-app-dev image. In order to mount this volume, you need to add it when you run the 'docker run' command : - ``` + + ```sh -v $PWD/cozy-doctypes:/data/cozy-doctypes ``` => for this project : -``` + +```sh docker run --rm -it -p 8080:8080 -p 5984:5984 -p 8025:8025 -v $PWD/build:/data/cozy-app/mps -v $PWD/data:/usr/local/couchdb/data -v $PWD/docker/disableCSP.yaml:/etc/cozy/cozy.yaml -v $PWD/cozy-doctypes:/data/cozy-doctypes registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes ``` ## How to test your service ? -In the manifest.webapp, you need to declare the service: -``` +In the manifest.webapp, you need to declare the service: + +```json "services": { "smsProcess": { "type": "node", "file": "services/smsProcess/pilote.js" } -}, +} ``` -Then, in src\targets\services, you can add your service. +Then, in src\targets\services, you can add your service. -For this project, we have created a button in Home.component.tsx in order to generate trigger url to run the service: +For this project, we have created a button in Home.component.tsx in order to generate trigger url to run the service: -``` +```js const getTrigger = async () => { const attrs = { type: '@webhook', worker: 'service', @@ -120,7 +131,7 @@ const getTrigger = async () => { } ``` -It generates an trigger URL that we can call with our backend application : +It generates an trigger URL that we can call with our backend application : > URL_COZY/job/webhook/{{trigger_id}} diff --git a/docs/pilote/index.md b/docs/pilote/index.md index 1d239a6dc9f979aafa2537141643c5c8eb638db0..5aef3b39e606edc44ad02d7063062bbaca69a245 100644 --- a/docs/pilote/index.md +++ b/docs/pilote/index.md @@ -1,24 +1,24 @@ -{: .center} +# Pilote -Pilote aims to help people in various administrative processes, allowing them to share their personal information with a social worker to build the best possible claim for every needs. +{: .center} +Pilote aims to help people in various administrative processes, allowing them to share their personal information with a social worker to build the best possible claim for every needs. !!! danger "Reminder" If you're a new developer tasked to work on this project, please get acquainted with the team [processes](https://forge.grandlyon.com/web-et-numerique/wiki_web_num) and read the advised [dev environment](https://forge.grandlyon.com/web-et-numerique/wiki_web_num) documentation and the self-data [prerequisites](../index.md#installing-prerequisites). - ##  Repositories [MPS group](https://forge.grandlyon.com/solidarite/monparcourssocial) contains the following repositories: -* [pilote usager](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager) -* travailleur social - * [backend](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial-back) - * [frontend](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial) +- [pilote usager](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager) +- travailleur social + - [backend](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial-back) + - [frontend](https://forge.grandlyon.com/solidarite/monparcourssocial/mps-travailleursocial) ## Requirements -Node **16** +Node **16** ## Acces to the application deployed diff --git a/docs/proxy/description.md b/docs/proxy/description.md index 42f90278df1205ffc86449c1b23eaf8d95175583..38aa21f580aad38bb60f2500709a4b93e9ea35cb 100644 --- a/docs/proxy/description.md +++ b/docs/proxy/description.md @@ -1,9 +1,10 @@ +# Description + This section of documentation refers to the Oauth protocols working hand in hand with our custom proxy and the cozy-stack. To fully understand its whereabouts, you should also look at the [enedis konnector](/konnectors/enedis/) and [grdf konnector](/konnectors/grdf/) documentation.  [proxy](https://forge.grandlyon.com/pocs/cozy/cozy-oauth-proxy) - ## Oauth Dance To access customer data, one must first obtain customer authorization. This authorization is materialized by an access token and it must be obtained by the APIs exposed by each energy providers. @@ -11,9 +12,10 @@ To access customer data, one must first obtain customer authorization. This auth These APIs implement Oauth 2.0 protocol, it requires authentication from the customer along with its given consent. See both **[Enedis](./use_cases/enedis.md)** and **[Grdf](./use_cases/grdfadict.md)** use cases before going further. + ### Cozy Oauth Protocol -!!! info "cozy oauth flow documentation" +!!! info "cozy oauth flow documentation" [https://docs.cozy.io/en/cozy-stack/konnectors-workflow/#reminder-oauth-flow](https://docs.cozy.io/en/cozy-stack/konnectors-workflow/#reminder-oauth-flow) #### CouchDB @@ -87,7 +89,7 @@ Example: xyz.cozygrandlyon.cloud/account/redirect -> redirect to xyz toto.cozygrandlyon.cloud/account/redirect -> redirect to toto -- If the provider (Enedis for instance) is not accepting wildcards, then we put a proxy as a middleware to provide a generic endpoint to cater for all Oauth2 redirection. +- If the provider (Enedis for instance) is not accepting wildcards, then we put a proxy as a middleware to provide a generic endpoint to cater for all Oauth2 redirection. #### Result @@ -112,7 +114,6 @@ With that in mind, the proxy is now the one calling the auth and token provider Stack <-- Proxy: token ``` - ## Proxy Code Explained !!! info "reminder" @@ -122,7 +123,7 @@ The proxy is coded in golang. It is composed of six endpoints as seen above. The first endpoint to be called is **/auth**. -#### auth +### auth Originally called from a cozy-stack trying to setup its konnector. The proxy gets these information from the query: @@ -138,18 +139,18 @@ The state will be merged with the instance name, then decomposed again when reac With all these information, the proxy can contact the provider **/auth** endpoint to start the oauth dance. -##### Enedis +#### Enedis !!! warning "note" See that a new composed state is sent to enedis, it is made of the former state conceived by the cozy-stack + the original instance name. This will be useful when enedis is leading the oauth dance to the next step and we will need the name of the cozy to answer. Once the call is sent, enedis will point to the **/redirect** endpoint. -##### Grdf +#### Grdf > To be redacted -#### redirect +### redirect Retrieve the *code*, *usage_point_id*, and *state* answered by Enedis. @@ -163,9 +164,9 @@ Finally redirect all these parameters in a query to the cozy-stack (the cozy-sta !!! warning "state / instance" The state must be recovered without the instance name, otherwise the cozy-stack won't recognized it and the handshake will fail. -#### token +### token Gathering from query or parameters all params. -Sends a post request to the provider /token endpoint. +Sends a post request to the provider /token endpoint. The stack will store the response params in a *accounts* CouchDB database. diff --git a/docs/proxy/monitoring.md b/docs/proxy/monitoring.md index 294ce8cceb4daa7692baa6d6b20be70c4401b694..6ef63dab83411198839001f76d1f59b1393b9473 100644 --- a/docs/proxy/monitoring.md +++ b/docs/proxy/monitoring.md @@ -1,10 +1,12 @@ +# Monitoring + All logs printed by the Proxy are read and translated into statistics on a grafana dashboard. !!! info "Grafana" [scaleway monitoring](https://grafana.self-data.alpha.grandlyon.com/) [production address](https://oauth-logs.cozycloud.cc/d/xSRhz8fMk/cozy-oauth-proxy?orgId=1&refresh=5s) - + This monitoring system allow the team to parse more easily the cozy-stack logs when something goes wrong. For instance, test konnector or check from the proxy if an issue was coming from Enedis or Grdf. Learn more about how it works [here](https://forge.grandlyon.com/web-et-numerique/llle_project/logs-monitoring). @@ -18,4 +20,4 @@ To easily plug loki on a specific instance: - Click on configuration and data sources - Add data sources - Find Loki and type the loki url http://loki:3100 -- In the query builder select the container "easy-cozy" then add |= "domain=[specific-instance]" \ No newline at end of file +- In the query builder select the container "easy-cozy" then add |= "domain=[specific-instance]" diff --git a/docs/proxy/use_cases/enedis.md b/docs/proxy/use_cases/enedis.md index b835c1a0f397d81a1cc4ede351bcdd1113bfa13c..8fb5ecbea5b7916f07f631a89c28484fe049b559 100644 --- a/docs/proxy/use_cases/enedis.md +++ b/docs/proxy/use_cases/enedis.md @@ -1,18 +1,20 @@ -### Enedis Data Connect +# Enedis Data Connect + !!! warning "DEPRECATED" This section of documentation is not relevant anymore, enedis data connect has been replaced with enedis sge !!! info "enedis documentation" Create an account on [https://datahub-enedis.fr/](https://datahub-enedis.fr/) to explore all the services exposed by Enedis. - + [Authorize API](https://datahub-enedis.fr/data-connect/documentation/authorize-v1/) swagger. [Api healthcheck](https://datahub-enedis.fr/data-connect/ressources/etat-des-services/). Regarding Enedis, two endpoints are exposed: -#### Authorize -##### /dataconnect/v1/oauth2/authorize +## Authorize + +### /dataconnect/v1/oauth2/authorize <table> <colgroup> @@ -36,7 +38,7 @@ Regarding Enedis, two endpoints are exposed: </tr> <tr> <td>state</td> - <td>Security parameter allowing to maintain the state between the request and the redirection. ** Maximum length of 100 characters ! **</td> + <td>Security parameter allowing to maintain the state between the request and the redirection. **Maximum length of 100 characters !**</td> </tr> <tr> <td>duration</td> @@ -48,8 +50,8 @@ Regarding Enedis, two endpoints are exposed: !!! important "Important" The response targets the redirect-uri registered with Enedis (the redirect-uri is our proxy and the response will be explained in details further below when explaining the proxy endpoints mechanics). -#### Token -##### /v1/oauth2/token +## Token +### /v1/oauth2/token <table> <colgroup> @@ -96,11 +98,11 @@ Regarding Enedis, two endpoints are exposed: On success, response will contain **access_token** or **refresh_token**, **usage_point_id** among other things. All information will be stored by the cozy-stack in a cozy-accounts database. -#### Consent Handling +## Consent Handling Consent is replaced every time a new oauth dance is launched (for 6 months, hard coded in **/authorize** request). User can revoke its consent from the Enedis website, no external endpoints are available for this purpose. If a consent has been revoked or expired. A 403 error will be thrown saying: *No consent can be found for this customer and this usage point*. -Ecolyo can warn the user that the service is unable to continue and ask to give new consent. \ No newline at end of file +Ecolyo can warn the user that the service is unable to continue and ask to give new consent. diff --git a/docs/proxy/use_cases/grdfadict.md b/docs/proxy/use_cases/grdfadict.md index a0e35353d8445ef59cc51057703f6b56f4578ac0..ed761b474347452b0e5eff5f9c386181fab7b656 100644 --- a/docs/proxy/use_cases/grdfadict.md +++ b/docs/proxy/use_cases/grdfadict.md @@ -1,4 +1,4 @@ -### Grdf Adict +# Grdf Adict !!! info "grdf documentation" Visit [https://sites.grdf.fr/web/portail-api-grdf-adict/documentation-grdf-adict](https://sites.grdf.fr/web/portail-api-grdf-adict/documentation-grdf-adict) to explore all the services exposed by Grdf. @@ -9,25 +9,26 @@ Regarding Grdf Adict Oauth connection, two endpoints are exposed: !!! warning "Oauth connection still in Beta" Grdf Adict Oauth service is called Client Connect and is still in early beta. It is currently lacking a *state* parameter in the Oauth dance. -#### Authorize -##### /oauth2/realms/externeGrdf/authorize +## Authorize -#### Token -##### /oauth2/realms/externeGrdf/access_token +### /oauth2/realms/externeGrdf/authorize +## Token -The */access_token* endpoint can be called with two different *grant_type* parameter. +### /oauth2/realms/externeGrdf/access_token - - *authorization_code* gives an access token and will also retrieve the consents list given by the user in session. - - *client_credentials* gives only the access token allowing us to request the data service. +The *access_token* endpoint can be called with two different *grant_type* parameter. - The grdf Konnector would only need to call the *client_credentials* to get a refresh token. +- *authorization_code* gives an access token and will also retrieve the consents list given by the user in session. +- *client_credentials* gives only the access token allowing us to request the data service. -#### Consent Handling +The grdf Konnector would only need to call the *client_credentials* to get a refresh token. + +## Consent Handling Consent is represented by an access right. This access holds characteristics specific to the consent of the end customer. -##### Optional: Revoke consent from external applications -It is possible to cancel a consent that was given from the user to our service (for test or development purpose for instance). +### Optional: Revoke consent from external applications +It is possible to cancel a consent that was given from the user to our service (for test or development purpose for instance). **api.grdf.fr/adict/v1/droit_acces/{id_accreditation}** diff --git a/docs/setup_your_environment.md b/docs/setup_your_environment.md index 6a2387be1f2bb65af286b92802758c31092b6a28..e39f458aff2bf4a64afc1bc3c4339a86b58c78b6 100644 --- a/docs/setup_your_environment.md +++ b/docs/setup_your_environment.md @@ -1,93 +1,180 @@ -This section will allow you to install a proper local environment step by step for Pilote application using VSCode IDE. +# Setup your environment + +This section will allow you to install a proper local environment step by step. ## VSCode ### Install VSCode -Installation for VSCode can be found here: [Installation of VSCode](https://code.visualstudio.com/). +Installation for VSCode can be found [here](https://code.visualstudio.com/). ### Extensions -Installation of Extension is explained here: [Installation of Extensions](https://code.visualstudio.com/docs/editor/extension-gallery). - -Here are the list of important extensions to install: +Some of our projects might contain a `/.vscode/extensions.json` to recommand specific extesions. But here is a list of general important extensions to install: -- Prettier - Code formatter -- ES7 React/Redux/GraphQL/React-Native snippets -- GitLens - Git supercharged -- Markdown Preview +- [Clipboard Manager](https://marketplace.visualstudio.com/items?itemName=EdgardMessias.clipboard-manager) +- [ES7+ React/Redux/React-Native snippets](https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets) +- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) +- [GitLens - Git supercharged](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens) +- [Jest Runner](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) +- [Jest](https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest) +- [Markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) +- [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) +- [SonarLint](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode) +- [TabOut](https://marketplace.visualstudio.com/items?itemName=albert.TabOut) +- [Todo Tree](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree) Optional extensions: - CSS Peek - Auto Rename Tag - indent-rainbow -- TabOut - Liveshare (pair programming extension) ### User settings -Open the project with VSCode and add the following code into .vscode/settings.json: +Open the project with VSCode and add the following code into `.vscode/settings.json`: -``` +```json { - "workbench.colorCustomizations": { - /* Put anything you like here */ - }, + "breadcrumbs.enabled": true, "editor.snippetSuggestions": "top", "editor.tabSize": 2, "editor.formatOnSave": true, + "editor.formatOnPaste": true, + "editor.formatOnSave": true, "diffEditor.ignoreTrimWhitespace": false, + "javascript.updateImportsOnFileMove.enabled": "always", "window.zoomLevel": 0, "gitlens.advanced.messages": { - "suppressShowKeyBindingsNotice": true + "suppressShowKeyBindingsNotice": true }, - "breadcrumbs.enabled": true, + "workbench.colorCustomizations": { + /* Put anything you like here */ + }, "workbench.settings.editor": "json", - "editor.tabSize": 2, - "editor.formatOnSave": true, - "editor.formatOnPaste": true } ``` -If this file is not empty, you can simply add the following lines to it: +## Install your Linux distribution +If you're using windows, we highly recommand to install WSL. Checkout the official documation for installation or our [installation wiki](wsl.md). + +### Setup your distribution + +1. Start updating the packages list by typing: + + ```sh + sudo apt update + ``` + +2. Install nodejs using the apt package manager + + ```sh + sudo apt install + ``` + +## Installing prerequisites + +Name | Required | Details +---------------------------------- | -------- | ------- +[Docker-compose](https://docs.docker.com/compose/install/) | Yes +[Docker](https://www.docker.com/get-started) | Yes | See [cozystack](https://docs.cozy.io/en/cozy-stack/) for more information. +Git | Yes | +[Node](https://nodejs.org/en/download/) | Yes | Node 14 and 16 must be installed as it is the version that runs on the official cozystack. +[WSL](index.md#wsl) | No | Required for windows users. +[Yarn](https://classic.yarnpkg.com/en/docs/install) | Yes | Yarn is our projects package manager. + +### Git + +We are using Gitlab, you will need to [install Git](https://git-scm.com/) to checkout projects. Make sure to configure your informations : + +```sh +git config --global user.name "First_name LAST_NAME" +git config --global user.email "email@example.com" ``` - "gitlens.advanced.messages": { - "suppressShowKeyBindingsNotice": true - }, - "breadcrumbs.enabled": true, - "workbench.settings.editor": "json", - "editor.formatOnSave": true, - "diffEditor.ignoreTrimWhitespace": false, - "window.zoomLevel": 0, -``` -## Git +!!! info "Git version" + Check you installed version. You'll probably have to upgrade to 1.22 to make everything work properly. + In order to achieve this, you'll have to launch several commands: + + ```sh + sudo apt-get remove cmdtest + sudo apt autoremove + sudo apt-get update + sudo apt install curl -y + curl -o- -L https://yarnpkg.com/install.sh | bash + source ~/.bashrc + ``` -The project is using Gitlab, you will need to install Git to checkout the project. -Installation for Git can be found here: [Installation of Git](https://git-scm.com/). + Now you should be at least in version ==^1.22== and ready to go on. -## Node -Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. +### Node -!!! warning "Version 14 & 16" +Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. [Install here](https://nodejs.org/en/download/) -For our projects you will need to have a version manager for node such as [**n**](https://www.npmjs.com/package/n) on linux and [**nvm**](https://github.com/coreybutler/nvm-windows) on windows. Install both 14 and 16 versions. +!!! warning "We need versions 14 & 16 for our projects so we will have to install a node version manager (more on that later)." -## Yarn +### Npm + +Npm should come installed with node. Check your version installed with : + +```sh +npm --version +``` + +### Yarn Yarn is used as package manager for this project. Feel free to use the one you prefer but we advice to install yarn as all the documentation is described with this package manager. Installation for yarn can be found here: [Installation of Yarn](https://classic.yarnpkg.com/fr/docs/install/). -## Docker +To Download and Setup Yarn : + +```sh +sudo apt install yarn +# OR +npm i -g yarn + +# Then check the installed version +yarn -v +``` + +#### NVM + +For our projects you will need to have a version manager for node such as [**n**](https://www.npmjs.com/package/n), [**nvm**](https://github.com/nvm-sh/nvm) and [**nvm-windows**](https://github.com/coreybutler/nvm-windows) on windows. Install both **14** and **16** versions. + +```sh +yarn global add nvm +``` + +=== "Install a version" + ```sh + nvm install X.X.X + ``` + +=== "See installed node versions" + ```sh + nvm list + ``` + +=== "Switch to a specific version" + ```sh + nvm use X.X.X + ``` + +You can then check the current version of node used +```sh +node -v +``` + +### Docker Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code. -### Install Docker +#### Install Docker Installation of Docker can be found here: [Installation of Docker](https://www.docker.com/get-started). -### Install Docker-Compose +#### Install Docker-Compose Installation of Docker-Compose (according to your OS) is explained here: [Installation of Docker-Compose](https://docs.docker.com/compose/install/). diff --git a/docs/wsl.md b/docs/wsl.md new file mode 100644 index 0000000000000000000000000000000000000000..9b9f2bfdc67636ec69b7e3f9d0a244d10101ecf5 --- /dev/null +++ b/docs/wsl.md @@ -0,0 +1,52 @@ + + + +# WSL + +First open Powershell as administrator and launch the following command: + +```powershell +dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart +``` + +This command will install WSL on your computer. After this, you'll need to ==**reboot**==. + +## Upgrade to WSL 2 + +If you're on WSL 1 and want to upgrade to WSL 2, here is the process: + +1. Open an elevated powershell and paste the following command: + + ```powershell + dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart + ``` + +2. Then, enable the Virtual Machine Platform optional feature. + + ```powershell + dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart + ``` + +3. Now restart your computer to apply these features. Once it's done, open an elevated powershell again and set the default wsl version to 2 + + ```sh + wsl --set-default-version 2 + ``` + +!!! warning "You might see this message after running the command above" + WSL 2 requires an update to its kernel component. + For information please visit [wsl2kernel](https://aka.ms/wsl2kernel). + +If you install the MSI from [wsl2kernel](https://aka.ms/wsl2kernel). Once you have the kernel installed, please run `wsl --set-default-version 2` again and it should complete successfully without showing the message. + +## Start WSL + +After reboot, open the microsoft store and install the distribution of your choice, for instance: ==Ubuntu 20.04 lts==. Once it's done, open it and after a few minutes you'll be prompted for the creation of a user account. + +To make sure it's correctly installed and working, you can open Powershell and paste the following command : + +```powershell +wsl.exe --list --running +``` + +Now you should see the name of your distribution in the list. And follow [set_up_your_environment](setup_your_environment.md#install-your-linux-distribution) diff --git a/mkdocs.yml b/mkdocs.yml index a0062880c8b91645e27ebddad51f586a786c127f..18a87472bf57a2f70ee5b81533555388f39e7a86 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -46,8 +46,8 @@ plugins: nav: - Home: - Getting started: index.md - - Additional Ressources: external_doc.md - Setup your environment: setup_your_environment.md + - WSL: wsl.md - Easy Cozy: - Introduction: easycozy/index.md - Configuration: easycozy/config.md @@ -71,7 +71,6 @@ nav: - Remote Doctypes: ecolyo/project_architecture/remote_doctypes.md - Application: - Deploy: ecolyo/application/deploy.md - - Description: ecolyo/application/description.md - Gitflow: ecolyo/application/gitflow.md - Mail: ecolyo/application/mail.md - Redux: ecolyo/application/redux.md @@ -100,7 +99,6 @@ nav: - Ecolyo-Agent: - Introduction: ecolyo/ecolyo-agent/introduction.md - Getting started: - - Setup your environment: ecolyo/ecolyo-agent/getting_started/setup_your_environment.md - Launch the application on local: ecolyo/ecolyo-agent/getting_started/launch_local_application.md - Libraries: ecolyo/ecolyo-agent/getting_started/libraries.md - Functionalities: @@ -113,39 +111,38 @@ nav: - Backup: ecolyo/ecolyo-agent/development/backup.md - Pilote: - Introduction: pilote/index.md - - Pilote - TS - Back: + - Pilote-Usager: - Application: - - Deploy: pilote/Pilote - TS - Back/application/deploy.md + - Deploy: pilote/Pilote-Usager/application/deploy.md + - Doctypes: pilote/Pilote-Usager/application/doctypes.md + - Scaffolding: pilote/Pilote-Usager/application/scaffolding.md + - Services: pilote/Pilote-Usager/application/services.md + - Redux: pilote/Pilote-Usager/application/redux.md - Functionalities: - - Routes: pilote/Pilote - TS - Back/functionalities/routes.md + - Appointments: pilote/Pilote-Usager/functionalities/appointments.md + - Contact: pilote/Pilote-Usager/functionalities/contact.md + - Document: pilote/Pilote-Usager/functionalities/document.md + - Settings: pilote/Pilote-Usager/functionalities/setting.md + - Cozy Registry: pilote/Pilote-Usager/functionalities/cozy-registry.md - Getting Started: - - Launch the application on local: pilote/Pilote - TS - Back/getting_started/launch_local_application.md - - Project Architecture: pilote/Pilote - TS - Back/project_architecture/architecture.md - - Pilote - TS - Front: + - Launch local application: pilote/Pilote-Usager/getting_started/launch_local_application.md + - Launch local doctypes: pilote/Pilote-Usager/getting_started/launch_local_doctypes.md + - Launch local services: pilote/Pilote-Usager/getting_started/launch_local_services.md + - Pilote-TS - Back: - Application: - - Deploy: pilote/Pilote - TS - Front/application/deploy.md + - Deploy: pilote/Pilote-TS-Back/application/deploy.md - Functionalities: - - Routes: pilote/Pilote - TS - Front/functionalities/functions.md + - Routes: pilote/Pilote-TS-Back/functionalities/routes.md - Getting Started: - - Launch the application on local: pilote/Pilote - TS - Front/getting_started/launch_local_application.md - - Pilote - Usager: + - Launch the application on local: pilote/Pilote-TS-Back/getting_started/launch_local_application.md + - Project Architecture: pilote/Pilote-TS-Back/project_architecture/architecture.md + - Pilote-TS-Front: - Application: - - Deploy: pilote/Pilote - Usager/application/deploy.md - - Doctypes: pilote/Pilote - Usager/application/doctypes.md - - Gitflow: pilote/Pilote - Usager/application/gitflow.md - - Scaffolding: pilote/Pilote - Usager/application/scaffolding.md - - Services: pilote/Pilote - Usager/application/services.md - - Store: pilote/Pilote - Usager/application/store.md + - Deploy: pilote/Pilote-TS-Front/application/deploy.md - Functionalities: - - Appointments: pilote/Pilote - Usager/functionalities/appointments.md - - Contact: pilote/Pilote - Usager/functionalities/contact.md - - Document: pilote/Pilote - Usager/functionalities/document.md - - Settings: pilote/Pilote - Usager/functionalities/setting.md - - Cozy Registry: pilote/Pilote - Usager/functionalities/cozy-registry.md + - Routes: pilote/Pilote-TS-Front/functionalities/functions.md - Getting Started: - - Launch local application: pilote/Pilote - Usager/getting_started/launch_local_application.md - - Launch local doctypes: pilote/Pilote - Usager/getting_started/launch_local_doctypes.md - - Launch local services: pilote/Pilote - Usager/getting_started/launch_local_services.md + - Launch the application on local: pilote/Pilote-TS-Front/getting_started/launch_local_application.md - Konnectors: - Introduction: konnectors/index.md - Enedis [DEPRECATED]: konnectors/enedis.md