Skip to content
Snippets Groups Projects
README.md 2.07 KiB
Newer Older
Timothee P's avatar
Timothee P committed
# geocontrib-frontend
Timothee P's avatar
Timothee P committed

## Project setup
```
npm install
```

Timothee P's avatar
Timothee P committed
### Préparation des variables d'environnement
Créer un fichier .env à la racine du projet puis ajouter les variables comme indiquer dans l'exemple ci-dessous (à adapter en fonction de l'environnement d'exploitation).


Timothee P's avatar
Timothee P committed
```
DOMAIN=http://localhost:8010/
Timothee P's avatar
Timothee P committed

NODE_ENV=development
VUE_APP_LOCALE=fr-FR
Timothee P's avatar
Timothee P committed

Timothee P's avatar
Timothee P committed
VUE_APP_APPLICATION_NAME=GéoContrib
Timothee P's avatar
Timothee P committed
VUE_APP_APPLICATION_ABSTRACT=Application de saisie d'informations géographiques contributive
Timothee P's avatar
Timothee P committed
VUE_APP_LOGO_PATH=@/assets/img/logo-neogeo-circle.png
Timothee P's avatar
Timothee P committed

VUE_APP_DJANGO_API_BASE=${DOMAIN}api/
VUE_APP_DJANGO_BASE=${DOMAIN}
Timothee P's avatar
Timothee P committed

```

Timothee P's avatar
Timothee P committed
### Compiles and hot-reloads for development
Timothee P's avatar
Timothee P committed

Pour éviter les problèmes de Cors en dév, (car backend sur serveur différent de frontend, différent en prod car même serveur), on utilise un proxy qui s'occupe de renseigner les CORS: https://github.com/garmeeh/local-cors-proxy#local-cors-proxy  

**À installer avant de lancer le serveur !**  
```
npm install -g local-cors-proxy
```

La commande serve lance les deux serveurs en parallèle dans le même terminal.
Timothee P's avatar
Timothee P committed
```
npm run serve
```

### Compiles and minifies for production
```
npm run build
```

### Lints and fixes files
```
npm run lint
```

### Customize configuration
Timothee P's avatar
Timothee P committed
See [Configuration Reference](https://cli.vuejs.org/config/).  
Timothee P's avatar
Timothee P committed

Timothee P's avatar
Timothee P committed
---
Timothee P's avatar
Timothee P committed
## Docker

Lancer un build
```
npm run build
```
Créér une image docker
```
docker-compose build
``` 
puis 
```
docker-compose push
```
Aller sur la VM geocontrib, (demander l'accès si besoin), aller dans ```/opt/geocontrib/[user]``` et ensuite :
```
docker-compose pull
```
et
```
docker-compose up -d
Timothee P's avatar
Timothee P committed
---
## Notes
### Changement par rapport au projet django
- Base.html => App.vue
- Découpage en composants
Timothee P's avatar
Timothee P committed
### Divers
- Afin de garder la même structure de pages que les templates originaux dans Django et aller vite, on utilise Vue-frag qui permet d'avoir plusieurs éléments html à la racine du template d'un compposant (comme les fragments dans React), sans avoir à ajouter une div wrapper qui pourait modifier le style (si on a une classe parente avec du flex par exemple).