working on rust side

This commit is contained in:
2019-02-13 16:01:24 +01:00
parent 8c89b9c059
commit 3ee9533faf
4 changed files with 108 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
<template>
<div class="box">
<button @click="fetchSolution"
<button @click="fetchCompletion"
class="button is-primary is-fullwidth"
v-bind:class="{'is-loading': is_loading }">
FetchSolution</button>
@@ -109,7 +109,23 @@ export default {
return res.json();}
)
.then((data) => this.template.updateJson(data))
.catch((err) => console.log(err));
.catch((err) => console.error(err));
},
fetchCompletion: function() {
this.is_loading = true;
// TODO: Keep only value's id
let body = JSON.stringify(this.template.items);
fetch("http://localhost:8000/api/solver/complete", {
method: 'POST',
body,
})
.then((res) => {
this.is_loading = false;
return res.json();}
)
.then((data) => this.template.updateJson(data))
.catch((err) => console.error(err));
},
unsetMeal: function(mealKey) {
let idx = this.template.findIndexByKey(mealKey);