Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/llle_project/self-data-technical-doc
1 result
Show changes
Commits on Source (2)
Showing
with 135 additions and 283 deletions
# Introduction
![easycozy](../img/easycozy.png){: .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)
## Local stack
# Local stack
![gitlab](../img/gitlab-logo.svg) [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:
......
# :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
### :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
```
![easycozy](../img/easycozy.png){: .center}
# Introduction
![easycozy](../img/easycozy.png){: .center}
![gitlab](../img/gitlab-logo.svg) [easy-cozy](https://forge.grandlyon.com/pocs/cozy/easy-cozy)
### :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:
![oops_error](/img/known_errors/oops_error.png)
......@@ -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:
![oops_error_2](/img/known_errors/oops_error_2.png)
### 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
......
### :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 |
### :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
![Bearer&cozysessid](/img/bearer_cozysessid.png)
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.
......@@ -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)
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/)
# 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"
```
......
# 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-)
......@@ -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.
......@@ -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
```
......
# 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 |
| --------------- | ---------------------------------------------------------------------------------------------------------------------- |
......
# 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
```
# 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
```
......
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.
......@@ -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.
# Introduction
## Newsletter
The goal is to send newsletters following this design :
![Architecture principles](/img/ecolyo-agent/newsletter-template.png)
......@@ -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.