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

- new page for installing pilote local application

- formatted doctypes & service page 
parent 294ff22d
No related branches found
No related tags found
1 merge request!10fix/pilote
## 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
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.
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
You must declare this doctype into your manifest.webapp file like that :
"share": {
"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 :
- cozy-stack serve (...) --doctypes /data/cozy-doctypes
!! 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" !
For this project:
- cd docker
- 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
4/ 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 :
-v $PWD/cozy-doctypes:/data/cozy-doctypes
=> 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
# How to test your remote doctype ?
## GET
1/ In the request file created. Specify the methode and the route to your target URL :
GET https://pilote-agent-dev.grandlyon.com/api/cozy
or with value in query :
GET https://pilote-agent-dev.grandlyon.com/api/auth/token/check?token={{token}}
2/ Then, you can test it by :
- await client.getStackClient().fetchJSON('GET','/remote/org.mps.share')
or with value in query :
- await client.getStackClient().fetchJSON('GET','/remote/org.mps.share?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImNvenlBcGlDaGVjayIsInVzZXJJZCI6IjEiLCJpYXQiOjE2MDU2OTI0NjYsImV4cCI6MTYwNTY5MjUyNn0.HbQh5H-TcVIASUpbjZAD0MY9slRAJOVw-VMKSBu_sQ0' )
## 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 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.
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
You must declare this doctype into your manifest.webapp file like that :
```
"share": {
"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 :
```
cozy-stack serve (...) --doctypes /data/cozy-doctypes
```
!!! warning "warning"
You need to build and push the newlest 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:
```
cd docker
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
```
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 :
```
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
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
or with value in query :
GET https://pilote-agent-dev.grandlyon.com/api/auth/token/check?token={{token}}
2/ Then, you can test it by :
```
await client.getStackClient().fetchJSON('GET','/remote/org.mps.share')
```
or with value in query :
```
await client.getStackClient().fetchJSON('GET','/remote/org.mps.share?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImNvenlBcGlDaGVjayIsInVzZXJJZCI6IjEiLCJpYXQiOjE2MDU2OTI0NjYsImV4cCI6MTYwNTY5MjUyNn0.HbQh5H-TcVIASUpbjZAD0MY9slRAJOVw-VMKSBu_sQ0' )
```
## 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
## Configure the cozy-stack on local
In order to be able to use your sercice, follow these steps:
1/ clone cozy-doctype 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
You must declare this doctype into your manifest.webapp file like that :
"share": {
"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 :
- 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():
```
#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
echo "data/cozy-app/mps/0.1.1 already here!";
else
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!";
fi
# mkdir /data/cozy-app/mps/0.1.1
# cp -a /data/cozy-app/mps/services/ /data/cozy-app/mps/0.1.1/
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
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
6/ Into the disableCSP.yml, you need to add one more configuration:
konnectors:
cmd: /etc/cozy/konnector-node-run.sh # run connectors with node
!! 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" !
Finaly, you should rebuild the docker image of the cozy-stack:
- cd docker
- 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
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 :
-v $PWD/cozy-doctypes:/data/cozy-doctypes
=> 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
## How to test your service ?
In the manifest.webapp, you need to declare the service:
"services": {
"smsProcess": {
"type": "node",
"file": "services/smsProcess/pilote.js"
}
},
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:
const getTrigger = async () => {
const attrs = { type: '@webhook',
worker: 'service',
message: {
name: 'smsProcess',
slug: 'pilotedemo',
},
}
const trigger = await client.getStackClient() .collection('io.cozy.triggers') .create(attrs)
console.log('trigger', trigger)
}
It generate 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.
### Use services in local
## Configure the cozy-stack on local
In order to be able to use your sercice, 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
You must declare this doctype into your manifest.webapp file like that :
```
"share": {
"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 :
```
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():
```
#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
echo "data/cozy-app/mps/0.1.1 already here!";
else
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!";
fi
# mkdir /data/cozy-app/mps/0.1.1
# cp -a /data/cozy-app/mps/services/ /data/cozy-app/mps/0.1.1/
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
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
6/ Into the disableCSP.yml, you need to add one more configuration:
konnectors:
cmd: /etc/cozy/konnector-node-run.sh # run connectors with node
!!! 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" !
Finaly, you should rebuild the docker image of the cozy-stack:
```
cd docker
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
```
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 :
```
-v $PWD/cozy-doctypes:/data/cozy-doctypes
```
=> 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
```
## How to test your service ?
In the manifest.webapp, you need to declare the service:
```
"services": {
"smsProcess": {
"type": "node",
"file": "services/smsProcess/pilote.js"
}
},
```
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:
```
const getTrigger = async () => {
const attrs = { type: '@webhook',
worker: 'service',
message: {
name: 'smsProcess',
slug: 'pilotedemo',
},
}
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:
- Document: pilote/Pilote - Usager/functionalities/document.md
- Settings: pilote/Pilote - Usager/functionalities/setting.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
- Konnectors:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment