summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichiel Schuurmans <michielschuurmans@gmail.com>2020-10-28 16:39:57 +0100
committerMichiel Schuurmans <michielschuurmans@gmail.com>2020-10-28 16:39:57 +0100
commitdfec6adf2ca5a860fe8ff2a7cefd2d5a69ac26b5 (patch)
treedb9794eb0044b860eb7586f69c27fa25d4f94c96
parent85621b93ecc74efe330dad1478b3414016baaad6 (diff)
Web: pass oxygen to api
Signed-off-by: Michiel Schuurmans <michielschuurmans@gmail.com>
-rw-r--r--api/app/Http/Controllers/BlenderController.php2
-rw-r--r--web/src/App.vue5
-rw-r--r--web/src/router/index.js21
-rw-r--r--web/src/views/Blender.vue7
4 files changed, 7 insertions, 28 deletions
diff --git a/api/app/Http/Controllers/BlenderController.php b/api/app/Http/Controllers/BlenderController.php
index 8c7924c..5ed7954 100644
--- a/api/app/Http/Controllers/BlenderController.php
+++ b/api/app/Http/Controllers/BlenderController.php
@@ -34,7 +34,7 @@ class BlenderController extends Controller
public function start($id, Request $request)
{
$this->validate($request, [
- 'oxygen' => 'required'
+ 'oxygen' => 'required|integer'
]);
$action = new BlenderAction($request->all());
diff --git a/web/src/App.vue b/web/src/App.vue
index 4ad4374..25f531f 100644
--- a/web/src/App.vue
+++ b/web/src/App.vue
@@ -1,10 +1,7 @@
<template>
<div id="app">
<div id="nav">
- <router-link to="/">Home</router-link> |
- <router-link to="/about">About</router-link> |
- <router-link v-if="$auth.isAuthenticated" to="/profile">Profile</router-link> |
- <router-link v-if="$auth.isAuthenticated" to="/blender">Blender</router-link>
+ <router-link v-if="$auth.isAuthenticated" to="/">Blender</router-link>
</div>
<router-view/>
</div>
diff --git a/web/src/router/index.js b/web/src/router/index.js
index ab4075f..c9a3b6b 100644
--- a/web/src/router/index.js
+++ b/web/src/router/index.js
@@ -1,8 +1,6 @@
import Vue from 'vue'
import { authGuard } from "../auth/authGuard";
import VueRouter from 'vue-router'
-import Home from '../views/Home.vue'
-import Profile from '../views/Profile.vue'
import Blender from '../views/Blender.vue'
Vue.use(VueRouter)
@@ -11,25 +9,6 @@ const routes = [
{
path: '/',
name: 'Home',
- component: Home
- },
- {
- path: '/about',
- name: 'About',
- // route level code-splitting
- // this generates a separate chunk (about.[hash].js) for this route
- // which is lazy-loaded when the route is visited.
- component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
- },
- {
- path: "/profile",
- name: "profile",
- component: Profile,
- beforeEnter: authGuard
- },
- {
- path: "/blender",
- name: "blender",
component: Blender,
beforeEnter: authGuard
}
diff --git a/web/src/views/Blender.vue b/web/src/views/Blender.vue
index 43299b7..95377e0 100644
--- a/web/src/views/Blender.vue
+++ b/web/src/views/Blender.vue
@@ -1,5 +1,7 @@
<template>
<div>
+ <input v-model="oxygen" type=text /><br /><br />
+
<button @click="start">Start</button> -
<button @click="stop">Stop</button>
<p>{{ apiMessage }}</p>
@@ -13,14 +15,15 @@ export default {
name: "blender",
data() {
return {
- apiMessage: ""
+ apiMessage: "",
+ oxygen: 21
};
},
methods: {
async start() {
const token = await this.$auth.getTokenSilently();
- const { data } = await axios.post("http://localhost:8000/api/v1/blenders/2/start",{ oxygen: 21 }, {
+ const { data } = await axios.post("http://localhost:8000/api/v1/blenders/2/start",{ oxygen: this.oxygen }, {
headers: {
Authorization: `Bearer ${token}`
}