Skip to content
Snippets Groups Projects
Commit a3f81956 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Merge branch 'fix/pilote' into 'master'

fix/pilote

See merge request web-et-numerique/llle_project/self-data-technical-doc!10
parents 294ff22d 592c80f8
Branches
No related tags found
1 merge request!10fix/pilote
Pipeline #23505 passed
## Initialisation of the project
### Clone the project repository
Use the following command in your favorite terminal to clone the project:
```
git clone https://forge.grandlyon.com/solidarite/monparcourssocial/mps-usager
```
## Installation of the project
### Start Pilote Usager application
Before starting Pilote Usager application, you need to install dependencies:
```
yarn install
```
To start Pilote Usager application, you first need start the application and start a cozy stack:
```
yarn start
# on windows
yarn winstack
# on linux
yarn linstack
```
And wait for the success message.
> Everything is setup. Go to http://mps.cozy.tools:8080/
Once successful you can launch your local cozy with following url [Cozy local url](http://cozy.tools:8080/) and connect with the password '**cozy**'.
### Start Pilote TS application
To start a social worker instance, go to [**options page**](http://mps.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
## Use cozy-doctype in local ## Use cozy-doctype in local
In order to be able to use our own cozy-doctype, especialy remote doctype here, we need to use them in local. In order to be able to use our own cozy-doctype, especialy remote doctype here, we need to use them in local.
1/ clone cozy-doctype repository into your system. 1/ clone [cozy-doctypes](https://github.com/cozy/cozy-doctypes) repository into your system.
Then, push it into your root project. Then, push it into your root project.
2/ After that, add your own remote doctype into cozy-doctype folder: 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 :
"share": { You must declare this doctype into your manifest.webapp file like that :
"description": "Required for searching on back-endTS", ```
"type": "org.mps.share", "share": {
"verbs": ["GET", "POST"] "description": "Required for searching on back-endTS",
}, "type": "org.mps.share",
"verbs": ["GET", "POST"]
},
3/ In cozy-app-dev-with-app.sh, you need to add another option when you serve the cozy-stack: ```
- cozy-stack serve --allow-root (...) --doctypes /path/to/the/doctype
=> in this project : 3/ In cozy-app-dev-with-app.sh, you need to add another option when you serve the cozy-stack:
- cozy-stack serve (...) --doctypes /data/cozy-doctypes ```
cozy-stack serve --allow-root (...) --doctypes /path/to/the/doctype
!! Warning !! : You need to build and push the newlest image on the forge registry when the step 3 is done ```
!! Warning !! : You must have all files, into your docker folder, in LF mode of "End of Line Sequence" ! => in this project :
```
For this project: cozy-stack serve (...) --doctypes /data/cozy-doctypes
- cd docker ```
- docker build . !!! warning "warning"
- docker tag <image_ID_created> registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes You need to build and push the newlest image on the forge registry when the step 3 is done.
- docker push registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes:latest You must have all files, into your docker folder, in LF mode of "End of Line Sequence" !
4/ The path "/data/cozy-doctypes" is link to the volume of the cozy-app-dev image. For this project:
- 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 cd docker
docker build .
=> for this project : docker tag <image_ID_created> registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes
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 docker push registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes:latest
```
# How to test your remote doctype ? 4/ The path "/data/cozy-doctypes" is linked to the volume of the cozy-app-dev image.
## GET
1/ In the request file created. Specify the methode and the route to your target URL : In order to mount this volume, you need to add it when you run the 'docker run' command :
GET https://pilote-agent-dev.grandlyon.com/api/cozy ```
-v $PWD/cozy-doctypes:/data/cozy-doctypes
or with value in query : ```
GET https://pilote-agent-dev.grandlyon.com/api/auth/token/check?token={{token}} => for this project :
```
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
2/ Then, you can test it by : ```
- await client.getStackClient().fetchJSON('GET','/remote/org.mps.share')
# How to test your remote doctype ?
or with value in query : ## GET
1/ In the request file created. Specify the method and the route to your target URL :
- await client.getStackClient().fetchJSON('GET','/remote/org.mps.share?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImNvenlBcGlDaGVjayIsInVzZXJJZCI6IjEiLCJpYXQiOjE2MDU2OTI0NjYsImV4cCI6MTYwNTY5MjUyNn0.HbQh5H-TcVIASUpbjZAD0MY9slRAJOVw-VMKSBu_sQ0' )
GET https://pilote-agent-dev.grandlyon.com/api/cozy
## POST
1/ In the request file created. Specify the methode and the route to your target URL : or with value in query :
POST https://pilote-agent-dev.grandlyon.com/api/auth/token/check
Content-Type: application/json GET https://pilote-agent-dev.grandlyon.com/api/auth/token/check?token={{token}}
{{data}}
2/ Then, you can test it by :
```
2/ Then, you can test it by : await client.getStackClient().fetchJSON('GET','/remote/org.mps.share')
const parameters = { ```
data: JSON.stringify({
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImNvenlBcGlDaGVjayIsInVzZXJJZCI6IjEiLCJpYXQiOjE2MDU2MjYxNzAsImV4cCI6MTYwNTYyNjIzMH0.8m-rEAZkuqb4upAPKY7j8DhvFi8mVbmiCFDitgNYt6Y" or with value in query :
}
) ```
} await client.getStackClient().fetchJSON('GET','/remote/org.mps.share?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImNvenlBcGlDaGVjayIsInVzZXJJZCI6IjEiLCJpYXQiOjE2MDU2OTI0NjYsImV4cCI6MTYwNTY5MjUyNn0.HbQh5H-TcVIASUpbjZAD0MY9slRAJOVw-VMKSBu_sQ0' )
```
console.log('call remote ==> ', await client.getStackClient().fetchJSON('POST','/remote/org.mps.share', parameters ))
## POST
1/ In the request file created. Specify the methode and the route to your target URL :
POST https://pilote-agent-dev.grandlyon.com/api/auth/token/check
Content-Type: application/json
{{data}}
2/ Then, you can test it by :
```
const parameters = {
data: JSON.stringify({
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImNvenlBcGlDaGVjayIsInVzZXJJZCI6IjEiLCJpYXQiOjE2MDU2MjYxNzAsImV4cCI6MTYwNTYyNjIzMH0.8m-rEAZkuqb4upAPKY7j8DhvFi8mVbmiCFDitgNYt6Y"
}
)
}
console.log('call remote ==> ', await client.getStackClient().fetchJSON('POST','/remote/org.mps.share', parameters ))
```
### Use services in local ### Use services in local
## Configure the cozy-stack on local ## Configure the cozy-stack on local
In order to be able to use your sercice, follow these steps: In order to be able to use your sercice, follow these steps:
1/ clone cozy-doctype repository into your system. 1/ clone [cozy-doctypes](https://github.com/cozy/cozy-doctypes) repository into your system.
Then, push it into your root project. Then, push it into your root project.
2/ After that, add your own remote doctype into cozy-doctype folder: 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 :
"share": { You must declare this doctype into your manifest.webapp file like that :
"description": "Required for searching on back-endTS", ```
"type": "org.mps.share", "share": {
"verbs": ["GET", "POST"] "description": "Required for searching on back-endTS",
}, "type": "org.mps.share",
"verbs": ["GET", "POST"]
},
3/ In cozy-app-dev-with-app.sh, you need to add another option when you serve the cozy-stack: ```
- cozy-stack serve --allow-root (...) --doctypes /path/to/the/doctype
3/ In cozy-app-dev-with-app.sh, you need to add another option when you serve the cozy-stack:
=> in this project : ```
- cozy-stack serve (...) --doctypes /data/cozy-doctypes cozy-stack serve --allow-root (...) --doctypes /path/to/the/doctype
```
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 this project :
```
``` cozy-stack serve (...) --doctypes /data/cozy-doctypes
#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 4/ You need to add another option when you install apps in the cozy-stack (go to: docker\cozy-app-dev-with-app.sh)
echo "data/cozy-app/mps/0.1.1 already here!";
else In do_install_app():
mkdir /data/cozy-app/mps/0.1.1
cp -a /data/cozy-app/mps/services/ /data/cozy-app/mps/0.1.1/ ```
echo "data/cozy-app/mps/0.1.1 just create!"; #add symbolic link to mps for sms service
fi ln -s /data/cozy-app/mps /data/cozy-storage/cozy.tools\:8080/.cozy_apps/mps
# mkdir /data/cozy-app/mps/0.1.1 if [ -d "data/cozy-app/mps/0.1.1" ]; then
# cp -a /data/cozy-app/mps/services/ /data/cozy-app/mps/0.1.1/ echo "data/cozy-app/mps/0.1.1 already here!";
echo "service added" else
``` mkdir /data/cozy-app/mps/0.1.1
cp -a /data/cozy-app/mps/services/ /data/cozy-app/mps/0.1.1/
5/ Then, add konnector-node-run.sh in docker folder. This file is a script to store the service logs. It should contain: echo "data/cozy-app/mps/0.1.1 just create!";
#!/bin/bash fi
# mkdir /data/cozy-app/mps/0.1.1
rundir="${1}" # cp -a /data/cozy-app/mps/services/ /data/cozy-app/mps/0.1.1/
cd $rundir echo "service added"
node index.js | tee /data/cozy-app/mps/services.log ```
Then, add this following row into the Dockerfile: 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
COPY konnector-node-run.sh /etc/cozy/konnector-node-run.sh
rundir="${1}"
6/ Into the disableCSP.yml, you need to add one more configuration: cd $rundir
node index.js | tee /data/cozy-app/mps/services.log
konnectors:
cmd: /etc/cozy/konnector-node-run.sh # run connectors with node Then, add this following row into the Dockerfile:
COPY konnector-node-run.sh /etc/cozy/konnector-node-run.sh
!! Warning !! : You need to build and push the newlest image on the forge registry when the step 6 is done
!! Warning !! : You must have all files, into your docker folder, in LF mode of "End of Line Sequence" ! 6/ Into the disableCSP.yml, you need to add one more configuration:
Finaly, you should rebuild the docker image of the cozy-stack: konnectors:
- cd docker cmd: /etc/cozy/konnector-node-run.sh # run connectors with node
- docker build .
- docker tag <image_ID_created> registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes
- docker push registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes:latest !!! warning "warning"
You need to build and push the newlest 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" !
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 : Finaly, you should rebuild the docker image of the cozy-stack:
-v $PWD/cozy-doctypes:/data/cozy-doctypes ```
cd docker
=> for this project : docker build .
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 docker tag <image_ID_created> registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes
docker push registry.forge.grandlyon.com/solidarite/monparcourssocial/mps-usager/cozy-env-doctypes:latest
```
## How to test your service ?
7/ The path "/data/cozy-doctypes" is link to the volume of the cozy-app-dev image.
In the manifest.webapp, you need to declare the service:
In order to mount this volume, you need to add it when you run the 'docker run' command :
"services": { ```
"smsProcess": { -v $PWD/cozy-doctypes:/data/cozy-doctypes
"type": "node", ```
"file": "services/smsProcess/pilote.js"
} => for this project :
}, ```
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
Then, in src\targets\services, you can add your service. ```
## How to test your service ?
For this project, we have created a button in Home.component.tsx in order to generate trigger url to run the service: In the manifest.webapp, you need to declare the service:
```
const getTrigger = async () => { "services": {
const attrs = { type: '@webhook', "smsProcess": {
worker: 'service', "type": "node",
message: { "file": "services/smsProcess/pilote.js"
name: 'smsProcess', }
slug: 'pilotedemo', },
}, ```
}
Then, in src\targets\services, you can add your service.
const trigger = await client.getStackClient() .collection('io.cozy.triggers') .create(attrs)
console.log('trigger', trigger) For this project, we have created a button in Home.component.tsx in order to generate trigger url to run the service:
}
```
It generate an trigger URL that we can call with our backend application : const getTrigger = async () => {
const attrs = { type: '@webhook',
> URL_COZY/job/webhook/{{trigger_id}} worker: 'service',
message: {
name: 'smsProcess',
slug: 'pilotedemo',
URL_COZY represent the cozy-stack url of your environment and not your application URL. },
}
const trigger = await client.getStackClient() .collection('io.cozy.triggers') .create(attrs)
console.log('trigger', trigger)
}
```
It generates an trigger URL that we can call with our backend application :
> URL_COZY/job/webhook/{{trigger_id}}
URL_COZY represent the cozy-stack url of your environment and not your application URL.
...@@ -116,6 +116,7 @@ nav: ...@@ -116,6 +116,7 @@ nav:
- Document: pilote/Pilote - Usager/functionalities/document.md - Document: pilote/Pilote - Usager/functionalities/document.md
- Settings: pilote/Pilote - Usager/functionalities/setting.md - Settings: pilote/Pilote - Usager/functionalities/setting.md
- Getting Started: - 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 doctypes: pilote/Pilote - Usager/getting_started/launch_local_doctypes.md
- Launch local services: pilote/Pilote - Usager/getting_started/launch_local_services.md - Launch local services: pilote/Pilote - Usager/getting_started/launch_local_services.md
- Konnectors: - Konnectors:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment