Skip to content

Commit

Permalink
implement basic import page
Browse files Browse the repository at this point in the history
  • Loading branch information
oscrx committed Dec 29, 2018
1 parent 51f5ec4 commit 747bf5f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ if (config.app.defaultAccount.autoCreate) {
createDefault()
}

const api = require('./api/index')
app.use('/', api)
const api = require('./api')
app.use('/api', api)

app.listen(config.app.port, function () {
console.log(`Beer backend running on port ${config.app.port}!`)
Expand Down
5 changes: 5 additions & 0 deletions src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
Aanbiedingen
</a>
</li>
<ul>
<li>
<a href="#/import">Import</a>
</li>
</ul>
<h2>Essential Links</h2>
<ul>
<li>
Expand Down
40 changes: 40 additions & 0 deletions src/components/Import.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<div>
<a class="button is-warning" @click="Import()">Import</a>
<ul v-if="status">
{{status.data}}
</ul>
<ul v-if="errors && errors.length">
<li v-for="error of errors">
{{error.message}}
</li>
</ul>
</div>
</template>

<script>
import Api from '@/services/Api'
export default {
data() {
return {
errors: [],
status
}
},
// Pushes posts to the server when called.
methods: {
Import() {
Api().post(`api/v1/import`, {
})
.then(response => {
this.status = response
})
.catch(e => {
this.errors.push(e)
})
}
}
}
</script>
6 changes: 6 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Router from 'vue-router'
import Hello from '@/components/HelloWorld'
import Aanbiedingen from '@/components/Aanbiedingen'
import Login from '@/components/Login'
import Import from '@/components/Import'

Vue.use(Router)

Expand All @@ -22,6 +23,11 @@ export default new Router({
path: '/login',
name: 'login',
component: Login
},
{
path: '/import',
name: 'import',
component: Import
}
]
})

0 comments on commit 747bf5f

Please sign in to comment.