configure api

This commit is contained in:
vincent 2020-03-30 21:27:06 +02:00
parent 20cd5269aa
commit f6dc1508dd
5 changed files with 69 additions and 24 deletions

View File

@ -4,6 +4,4 @@ const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, { module.exports = merge(prodEnv, {
NODE_ENV: '"development"', NODE_ENV: '"development"',
ROOT_API:'"http://localhost:5000"',
}) })

View File

@ -9,7 +9,7 @@ module.exports = {
// Paths // Paths
assetsSubDirectory: 'static', assetsSubDirectory: 'static',
assetsPublicPath: '/', assetsPublicPath: '',
// Various Dev Server settings // Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST host: 'localhost', // can be overwritten by process.env.HOST
@ -44,7 +44,7 @@ module.exports = {
build: { build: {
// Template for index.html // Template for index.html
index: path.resolve(__dirname, '../../backend/dist/index.html'), index: path.resolve(__dirname, '../dist/index.html'),
// Paths // Paths
assetsRoot: path.resolve(__dirname, '../dist'), assetsRoot: path.resolve(__dirname, '../dist'),

View File

@ -1,5 +1,5 @@
'use strict' 'use strict'
module.exports = { module.exports = {
NODE_ENV: '"production"', NODE_ENV: '"production"',
ROOT_API:'"/"' ROOT_API:'"https://outlook.office.com/webhook/d607186d-098c-4d35-b188-440315e30b33@1d593042-a69d-49e0-8d1c-0daf8ac1717b/IncomingWebhook/b84597cf0ff2443a997d3bea0aad92bb/84d01e58-379e-4aff-862f-d308fc799011"'
} }

View File

@ -1,17 +1,25 @@
import axios from 'axios'; import axios from 'axios';
const API_PATH = `${process.env.ROOT_API}/api/v1`; const API_PATH = `${process.env.ROOT_API}`;
export function fetchchaine(num) {
return axios.get(`${API_PATH}/chaine/${num}`); export async function PostMood(MoodData) {
} const response = await fetch(API_PATH, {
export function fetchemission(num) { method: 'POST', // *GET, POST, PUT, DELETE, etc.
return axios.get(`${API_PATH}/chaine/${num}/emission`); mode: 'no-cors', // no-cors, *cors, same-origin
} cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
export function putparsechaine(jwt) { headers: {
return axios.put(`${API_PATH}/chaine/`, '', { headers: { Authorization: `Bearer: ${jwt}` } }); 'Content-Type': 'application/json'
} // 'Content-Type': 'application/x-www-form-urlencoded',
export function authenticate(userData) { },
return axios.post(`${API_PATH}/login/`, userData); redirect: 'follow', // manual, *follow, error
referrerPolicy: 'no-referrer', // no-referrer, *client
body: JSON.stringify(MoodData) // body data type must match "Content-Type" header
});
return await response
// return axios.post(`${API_PATH}`, JSON.stringify(MoodData));
} }
// export function register(userData) { // export function register(userData) {
// return axios.post(`${API_URL}/register/`, userData); // return axios.post(`${API_URL}/register/`, userData);

View File

@ -11,16 +11,16 @@
<div class="field is-grouped-centered"> <div class="field is-grouped-centered">
<div class="control"> <div class="control">
<label class="label">Humeur</label> <label class="label">Humeur</label>
<b-slider rounded title="humeur" v-model="humeur" id="humeur" :step="1" :min="0" :max="5" ></b-slider> <b-slider rounded title="humeur" v-model="humeur" id="humeur" :step="1" :min="0" :max="3" ></b-slider>
</div> </div>
<div class="control"> <div class="control">
<label class="label">stress</label> <label class="label">stress</label>
<b-slider rounded title="stress" v-model="stress" id="stress" :step="1" :min="0" :max="5"></b-slider> <b-slider rounded title="stress" v-model="stress" id="stress" :step="1" :min="0" :max="3"></b-slider>
</div> </div>
<div class="control"> <div class="control">
<label class="label">fatigue</label> <label class="label">fatigue</label>
<b-slider rounded title="fatigue" v-model="fatigue" id="fatigue" :step="1" :min="0" :max="5" ></b-slider> <b-slider rounded title="fatigue" v-model="fatigue" id="fatigue" :step="1" :min="0" :max="3" ></b-slider>
</div> </div>
@ -29,7 +29,7 @@
</div> </div>
<div class="field is-grouped is-grouped-centered"> <div class="field is-grouped is-grouped-centered">
<div class="control"> <div class="control">
<button class="button is-success" v-on:click="">valider</button> <button class="button is-success" v-on:click="validate()">valider</button>
</div> </div>
<div class="control"> <div class="control">
<button class="button is-success" v-on:click="showModalname=true">modifier votre Nom</button> <button class="button is-success" v-on:click="showModalname=true">modifier votre Nom</button>
@ -46,11 +46,13 @@
</template> </template>
<script> <script>
import { putparsechaine } from '../api'; import { PostMood } from '../api';
import modalname from './modalname' import modalname from './modalname'
import modal from './modal' import modal from './modal'
import { EventBus } from '../utils'; import { EventBus } from '../utils';
const HashSmile=["https://image.noelshack.com/fichiers/2020/14/1/1585595805-battery0.png","https://image.noelshack.com/fichiers/2020/14/1/1585595805-battery1.png","https://image.noelshack.com/fichiers/2020/14/1/1585595805-battery2.png","https://image.noelshack.com/fichiers/2020/14/1/1585595805-battery3.png"]
export default { export default {
name: 'Teammood', name: 'Teammood',
components: { components: {
@ -68,11 +70,48 @@ export default {
}; };
}, },
methods: { methods: {
validate() {
let cardJson={
"title": this.$store.getters.name+ "'s mood",
"sections": [
{
"activityTitle": "stress",
"activityImage": HashSmile[this.stress],
},
{
"activityTitle": "humeur",
"activityImage": HashSmile[this.humeur],
},
{
"activityTitle": "fatigue",
"activityImage": HashSmile[this.fatigue],
},
],
"text": " "
}
console.log(cardJson)
return PostMood(cardJson)
.then((res) => {
console.log(res.status)
if (res.status == '0') {
this.modalmessage="votre humeur du jour a bien été prise en compte";
this.showModal=true;
} else {
this.modalmessage="une erreur est survenu lors de l'envoie du formulaire merci de réessayer";
this.showModal=true;
}
})
.catch((error) => {
console.log('Network erreur');
console.log(error);
});
}
}, },
mounted() { mounted() {
console.log(this)
if(!this.$store.getters.name){ if(!this.$store.getters.name){
this.showModalname=true; this.showModalname=true;