Skip to content
Snippets Groups Projects
Commit cf6753b1 authored by Yoan VALLET's avatar Yoan VALLET
Browse files

add remote-doctype section and add todo for the service

parent 94d8f021
No related branches found
No related tags found
No related merge requests found
Pipeline #14150 passed
# Creation of the remote doctype
The remote doctype should be created in the cozy repo : [https://github.com/cozy/cozy-doctypes](https://github.com/cozy/cozy-doctypes)
## Remote doctype org.ecolyo.usage
To create the remote the first create a folder named 'org.ecolyo.usage' and then add a file name request in the folder.
Here is the structure of the file:
```bash
POST https://API_URL
Content-Type: application/json
{{data}}
```
## Local remote doctype
As the doctype if not yet avaible on cozy repo, we first need to test it on local. For that we can use the *—doctypes* command in the cozy-stack serve and use it to point to a local repo.
Here are the step:
- clone the repo and add it in the ecolyo repo
- create the remote doctype. Here we create a new folder named 'org.ecolyo.usage' and add the following request file (replace API_URL by the url of the API):
```bash
POST https://API_URL
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
```bash
${COZY_STACK_PATH} serve --allow-root \
--appdir "${appdir}" \
--host "::" \
--port "${COZY_STACK_PORT}" \
--admin-port "${COZY_STACK_ADMIN_PORT}" \
--couchdb-url "${COUCHDB_URL}" \
--doctypes /data/cozy-doctypes \
--mail-port 1025 \
--mail-disable-tls \
--remote-allow-custom-port \
--fs-url "file://localhost${vfsdir}" &
```
- add the following content in "docker/disableCSP.yaml":
```yaml
remote_assets:
ecolyo-usage: http://cozy.tools:8080/remote/org.ecolyo.usage/
```
- build the docker image: docker build .
- tag the image 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)
- add the following command to winstack script in the package.json:
```yaml
-v $PWD/cozy-doctypes:/data/cozy-doctypes
```
- start the server with the new image:
```bash
yarn winstack
```
- Change the content request param in io.cozy.doctypes/org.ecolyo.usage using the db tool ([http://localhost:5984/_utils](http://localhost:5984/_utils)):
```bash
"request": "POST https://API_URL\nContent-Type: application/json\n\n{{data}}",
```
# Use of remote doctype in the application
Add permission in manifest.webapp
```json
"ecolyo-usage": {
"type": "org.ecolyo.usage",
"verbs": ["GET", "POST"]
}
```
Don't forget to add the description
Call the remote docType:
```jsx
const result = await client
.getStackClient()
.fetchJSON('POST', '/remote/org.ecolyo.usage', {
JSON.stringify(indicator),
})
```
\ No newline at end of file
......@@ -16,3 +16,14 @@ The service is responsible of :
2. Aggregated them to indicators
3. Send indicators to the remote doctype
# 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]
- 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:
- Update the remote doctype name in the sendIndicator method
- Add a check on the environment to ensure that the service will not post information on the remote doctype when its comes for alpha instance
\ No newline at end of file
......@@ -40,6 +40,7 @@ nav:
- Libraries: ecolyo/project_architecture/libraries.md
- Environments: ecolyo/project_architecture/environments.md
- DocTypes: ecolyo/project_architecture/doctypes.md
- Remote DocTypes: ecolyo/project_architecture/remote_doctypes.md
- Application:
- Description: ecolyo/application/description.md
- Redux: ecolyo/application/redux.md
......
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