Skip to content

Commit 43bda45

Browse files
committed
Init application
1 parent d4ed6bf commit 43bda45

File tree

61 files changed

+7086
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+7086
-41
lines changed

.github/workflows/tests.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Lancement des tests
2+
3+
on: [push, pull_request_target, workflow_dispatch]
4+
5+
jobs:
6+
tests:
7+
strategy:
8+
matrix:
9+
php-versions: ['7.4']
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: Installation des dépendances
15+
uses: php-actions/composer@v6
16+
with:
17+
command: install
18+
args: --no-interaction --no-progress --no-suggest
19+
php_version: ${{ matrix.php-versions }}
20+
- name: Lancement des tests
21+
run: php ./vendor/atoum/atoum/bin/atoum --no-code-coverage -d tests/units

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,13 @@
1818
.phpunit.result.cache
1919
/phpunit.xml
2020
###< symfony/phpunit-bridge ###
21+
22+
###> symfony/webpack-encore-bundle ###
23+
/node_modules/
24+
/public/build/
25+
npm-debug.log
26+
yarn-error.log
27+
###< symfony/webpack-encore-bundle ###
28+
29+
.vscode/
30+
.idea/

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM php:7.4-apache
2+
3+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
4+
RUN curl -sS https://get.symfony.com/cli/installer | bash \
5+
&& mv /root/.symfony5/bin/symfony /usr/local/bin/symfony
6+
7+
RUN apt-get update && apt-get install -y \
8+
git \
9+
unzip \
10+
libzip-dev && rm -rf /var/lib/apt/lists/* \
11+
&& docker-php-ext-install mysqli pdo pdo_mysql zip \
12+
&& echo "LISTEN 8080" >> /etc/apache2/ports.conf \
13+
&& curl -sL https://deb.nodesource.com/setup_18.x | bash - \
14+
&& apt-get update \
15+
&& apt-get install -y nodejs \
16+
&& npm install -g yarn
17+
18+
COPY . /var/www/html
19+
COPY ./docker/entrypoint.sh /usr/bin/entrypoint.sh
20+
COPY ./docker/apache2/hosts.conf /etc/apache2/sites-enabled/hosts.conf
21+
COPY ./docker/apache2/symfony.conf /etc/apache2/sites-available/000-default.conf
22+
23+
RUN chown -R www-data:www-data /var/www \
24+
&& echo "date.timezone = Europe/Paris" >> /usr/local/etc/php/php.ini \
25+
&& usermod -u 1000 www-data
26+
27+
RUN ["chmod", "+x", "/usr/bin/entrypoint.sh"]
28+
29+
HEALTHCHECK --interval=5s --timeout=3s CMD curl --fail http://localhost:80/ || exit 1
30+
31+
WORKDIR /var/www/html
32+
33+
RUN set -eux; \
34+
composer install; \
35+
composer dump-autoload; \
36+
chmod +x bin/console; sync
37+
38+
USER www-data
39+
40+
ENTRYPOINT ["/usr/bin/entrypoint.sh"]

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Projet d'intégration Kairios
2+
3+
## Présentation
4+
Vous trouverez dans ce dépôt le code source concernant une application Symfony et Vue qui viendra décrire une interface Web simpliste détaillant deux entités à savoir le `Dépot` et la `Reponse`.
5+
6+
## Installation
7+
Le projet est configuré pour fonctionner sous un environnement Docker. Il suffit donc de lancer les commandes suivantes pour lancer le projet :
8+
```bash
9+
docker-compose up -d
10+
docker-compose exec application yarn install
11+
docker-compose exec application yarn encore dev
12+
```
13+
14+
L'application sera donc accessible à l'adresse suivante : [http://localhost](http://localhost)
15+
16+
## Lancement des tests unitaires
17+
Pour lancer les tests unitaires, il suffit de lancer la commande suivante :
18+
```bash
19+
docker-compose exec application php vendor/atoum/atoum/bin/atoum -d tests/units
20+
```
21+
22+
## Se connecter en bash au container
23+
Pour se connecter en bash au container, il suffit de lancer la commande suivante :
24+
```bash
25+
docker-compose exec application bash
26+
```
27+
28+
## Lancer le mode watch pour le front
29+
Pour lancer le mode watch pour le front, il suffit de lancer la commande suivante :
30+
```bash
31+
docker-compose exec application npm run watch
32+
```
33+
34+
## Convention de commit
35+
Le projet exige une norme de commit afin de faciliter la lecture de ces derniers. Il vient respecter le format suivant :
36+
37+
`<type>(<scope>): <subject>`
38+
`<BLANK LINE>`
39+
`<body>`
40+
41+
Par exemple :
42+
```
43+
feat(README): Ajout d'une section sur les tests unitaires
44+
45+
Ajout d'une section sur les tests unitaires dans le README
46+
```
47+
48+
```
49+
fix(demande clinique): Correction d'un bug sur la création d'une demande clinique
50+
51+
Un bug était présent sur la création d'une demande clinique. Il concernait la prise en compte du paramètre optionnel comme étant requis.
52+
```

assets/App.vue

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template>
2+
<div class="h-screen flex items-center justify-center" v-if="loading">
3+
Chargement
4+
</div>
5+
<div class="container mx-auto mt-10 min-h-screen" v-else>
6+
<router-view></router-view>
7+
</div>
8+
</template>
9+
10+
<script>
11+
import { mapActions } from 'vuex';
12+
13+
export default {
14+
name: 'App',
15+
data: function () {
16+
return {
17+
loading: true,
18+
};
19+
},
20+
methods: {
21+
...mapActions({
22+
chargerDepots: 'demande_clinique/chargerDepots',
23+
}),
24+
},
25+
mounted: async function () {
26+
await this.chargerDepots();
27+
this.loading = false;
28+
},
29+
};
30+
</script>

assets/api/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import demande_clinique from './modules/demande_clinique';
2+
3+
export default {
4+
demande_clinique,
5+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import axios from 'axios';
2+
3+
export default {
4+
depots: {
5+
all: async () => (await axios.get('/v1/demande-clinique/depots')).data,
6+
ajouterReponse: async (id, titre, description, type) => (await axios.post(`/v1/demande-clinique/depots/${id}/reponses`, {titre, description, type})).data,
7+
},
8+
reponses: {
9+
creer: async (depot) => (await axios.post('/v1/demande-clinique/reponses', depot)).data,
10+
}
11+
};

assets/app.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Vue from 'vue';
2+
import App from './App.vue';
3+
import Router from './router';
4+
import Store from './store';
5+
6+
(new Vue({
7+
router: Router,
8+
store: Store,
9+
render: (h) => h(App),
10+
})).$mount('#app');
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export const PRIORITAIRE = 1;
2+
export const DANS_L_HEURE = 2;
3+
export const DANS_LA_JOURNEE = 3;
4+
export const DANS_LES_48_HEURES = 4;
5+
6+
export const getAll = () => {
7+
return [PRIORITAIRE, DANS_L_HEURE, DANS_LA_JOURNEE, DANS_LES_48_HEURES];
8+
};
9+
10+
export const getLabel = (type) => {
11+
switch (type) {
12+
case PRIORITAIRE:
13+
return 'Prioritaire';
14+
case DANS_L_HEURE:
15+
return 'Dans l\'heure';
16+
case DANS_LA_JOURNEE:
17+
return 'Dans la journée';
18+
case DANS_LES_48_HEURES:
19+
return 'Dans les 48 heures';
20+
default:
21+
return 'Aucun type';
22+
}
23+
};

assets/pages/depots/_id.vue

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<template>
2+
<div v-if="depot">
3+
<div class="mb-2">
4+
<h1 class="text-4xl font-bold">{{ depot.titre }}</h1>
5+
<p class="text-xl">{{ depot.description }}</p>
6+
</div>
7+
<div class="mt-4 px-4 py-2 bg-white rounded-xl">
8+
<h2 class="text-md font-semibold">Création d'une nouvelle réponse</h2>
9+
<form class="flex flex-col gap-2" @submit.prevent="creer">
10+
<input type="text" v-model="titre" placeholder="Titre" class="border border-gray-300 rounded-lg p-2">
11+
<textarea v-model="description" placeholder="Description" class="border border-gray-300 rounded-lg p-2"></textarea>
12+
<select v-model="type" class="border border-gray-300 rounded-lg p-2" placeholder="Priorité">
13+
<option selected disabled value="0">Type de réponse</option>
14+
<option v-for="type in getTypes()" :value="type" :key="type">{{ getTypeLabel(type) }}</option>
15+
</select>
16+
<button
17+
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
18+
:class="{
19+
'cursor-not-allowed': loading,
20+
}"
21+
:disabled="loading"
22+
>{{ loading ? 'En cours' : 'Creer' }}</button>
23+
</form>
24+
</div>
25+
</div>
26+
<div v-else>
27+
<p>Le dépot n'existe pas</p>
28+
</div>
29+
</template>
30+
31+
<script>
32+
import { mapActions, mapGetters } from 'vuex';
33+
import api from '@/api';
34+
import {getAll, getLabel} from '@/enum/demande_clinique/reponse/type';
35+
36+
export default {
37+
name: 'Depot',
38+
data: function () {
39+
return {
40+
titre: '',
41+
description: '',
42+
loading: false,
43+
type: 0,
44+
};
45+
},
46+
computed: {
47+
...mapGetters({
48+
depots: 'demande_clinique/depots',
49+
}),
50+
id: function () {
51+
return parseInt(this.$route.params.id);
52+
},
53+
depot: function () {
54+
return this.depots.find((depot) => depot.id === this.id);
55+
},
56+
},
57+
methods: {
58+
...mapActions({
59+
chargerDepots: 'demande_clinique/chargerDepots',
60+
}),
61+
getTypes: getAll,
62+
getTypeLabel: getLabel,
63+
creer: async function() {
64+
if (!(this.titre && this.description)) {
65+
window.alert('Veuillez remplir tous les champs');
66+
return;
67+
}
68+
69+
try {
70+
this.loading = true;
71+
await api.demande_clinique.depots.ajouterReponse(this.depot.id, this.titre, this.description, this.type);
72+
await this.chargerDepots();
73+
this.$router.push('/');
74+
} catch (e) {
75+
console.error(e);
76+
window.alert('Une erreur est survenue');
77+
this.loading = false;
78+
}
79+
}
80+
}
81+
}
82+
</script>

0 commit comments

Comments
 (0)