From 592c80f86ed10b0d8927c719be7b22fbddf59edf Mon Sep 17 00:00:00 2001
From: Bastien DUMONT <bdumont@grandlyon.com>
Date: Tue, 29 Mar 2022 14:24:54 +0000
Subject: [PATCH] - new page for installing pilote local application -
 formatted doctypes & service page

---
 .../launch_local_application.md               |  42 +++
 .../getting_started/launch_local_doctypes.md  | 170 ++++++------
 .../getting_started/launch_local_services.md  | 243 +++++++++---------
 mkdocs.yml                                    |   1 +
 4 files changed, 265 insertions(+), 191 deletions(-)
 create mode 100644 docs/pilote/Pilote - Usager/getting_started/launch_local_application.md

diff --git a/docs/pilote/Pilote - Usager/getting_started/launch_local_application.md b/docs/pilote/Pilote - Usager/getting_started/launch_local_application.md
new file mode 100644
index 0000000..49087ad
--- /dev/null
+++ b/docs/pilote/Pilote - Usager/getting_started/launch_local_application.md	
@@ -0,0 +1,42 @@
+## 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
diff --git a/docs/pilote/Pilote - Usager/getting_started/launch_local_doctypes.md b/docs/pilote/Pilote - Usager/getting_started/launch_local_doctypes.md
index b565d95..6c87019 100644
--- a/docs/pilote/Pilote - Usager/getting_started/launch_local_doctypes.md	
+++ b/docs/pilote/Pilote - Usager/getting_started/launch_local_doctypes.md	
@@ -1,75 +1,95 @@
-## 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 ))
+```
diff --git a/docs/pilote/Pilote - Usager/getting_started/launch_local_services.md b/docs/pilote/Pilote - Usager/getting_started/launch_local_services.md
index 1ad538d..092c4ab 100644
--- a/docs/pilote/Pilote - Usager/getting_started/launch_local_services.md	
+++ b/docs/pilote/Pilote - Usager/getting_started/launch_local_services.md	
@@ -1,116 +1,127 @@
-### 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.
diff --git a/mkdocs.yml b/mkdocs.yml
index d9cd59c..673c5f7 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -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:
-- 
GitLab