Commit 00a45967 authored by Andrea Ida Malkah Klaura's avatar Andrea Ida Malkah Klaura
Browse files

switched from vue-resource to axios

as vue-resource is retired from official recommendation status
we switch to axios, which is better maintained and supports a
similar API.

for more background see:
https://medium.com/the-vue-point/retiring-vue-resource-871a82880af4
parent 0412fbcd
...@@ -4,8 +4,6 @@ const prodEnv = require('./prod.env') ...@@ -4,8 +4,6 @@ const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, { module.exports = merge(prodEnv, {
NODE_ENV: '"development"', NODE_ENV: '"development"',
API_STEERING: '"http://127.0.0.1:3000/api/v1/"', API_STEERING: '"http://127.0.0.1:8000/api/v1/"',
API_STEERING_SHOWS: '"http://127.0.0.1:3000/api/v1/shows/"' API_STEERING_SHOWS: '"http://127.0.0.1:8000/api/v1/shows/"'
//API_STEERING: '"http://127.0.0.1:8000/api/v1/"',
//API_STEERING_SHOWS: '"http://127.0.0.1:8000/api/v1/shows/"'
}) })
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs" "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
}, },
"dependencies": { "dependencies": {
"axios": "^0.17.1",
"vue": "^2.5.2", "vue": "^2.5.2",
"vue-router": "^3.0.1" "vue-router": "^3.0.1"
}, },
......
...@@ -206,6 +206,7 @@ ...@@ -206,6 +206,7 @@
<script> <script>
import timeslotSort from '../mixins/timeslotSort' import timeslotSort from '../mixins/timeslotSort'
import axios from 'axios'
function leadingZero (num) { function leadingZero (num) {
if (num < 10) return '0' + num if (num < 10) return '0' + num
...@@ -250,28 +251,22 @@ export default { ...@@ -250,28 +251,22 @@ export default {
this.currentShow = index this.currentShow = index
this.currentShowID = this.shows[this.currentShow].id this.currentShowID = this.shows[this.currentShow].id
// now fetch the single timeslots for a given show from PV backend // now fetch the single timeslots for a given show from PV backend
this.$http.get(process.env.API_STEERING_SHOWS + this.currentShowID + '/timeslots').then(response => { axios.get(process.env.API_STEERING_SHOWS + this.currentShowID + '/timeslots').then(response => {
if (response.body.hasOwnProperty('error')) alert(response.body.error) this.timeslots = response.data
else { this.timeslotsLoaded = true
this.timeslots = response.body // now that we have the timeslots we can fetch notes for all those timeslots
this.timeslotsLoaded = true // TODO: curently we are fetching all notes for the show into a single array
// now that we have the timeslots we can fetch notes for all those timeslots // for bigger data sets it might be preferable to fetch only the notes for those
// TODO: curently we are fetching all notes for the show into a single array // timeslots that are also visible to the user
// for bigger data sets it might be preferable to fetch only the notes for those axios.get(process.env.API_STEERING_SHOWS + this.currentShowID + '/notes').then(response => {
// timeslots that are also visible to the user this.notes = response.body
this.$http.get(process.env.API_STEERING_SHOWS + this.currentShowID + '/notes').then(response => { this.notesLoaded = true
if (response.body.hasOwnProperty('error')) alert(response.body.error) }).catch(error => {
else { alert('There was an error fetching notes from the server' + error)
this.notes = response.body })
this.notesLoaded = true // done fetching notes
} }).catch(error => {
}, response => { alert('There was an error fetching timeslots from the server' + error)
alert('There was an error fetching notes from the server')
})
// done fetching notes
}
}, response => {
alert('There was an error fetching timeslots from the server')
}) })
// done fetching timeslots // done fetching timeslots
}, },
...@@ -312,19 +307,14 @@ export default { ...@@ -312,19 +307,14 @@ export default {
} }
}, },
created () { created () {
// fetch sendereihen from PV backend axios.get(process.env.API_STEERING_SHOWS).then(response => {
this.$http.get(process.env.API_STEERING_SHOWS).then(response => { this.shows = response.data
if (response.body.hasOwnProperty('error')) { this.currentShowID = this.shows[0].id
alert(response.body.error) this.currentShow = 0
} else { this.showsLoaded = true
this.shows = response.body this.switchShow(this.currentShow)
this.currentShowID = this.shows[0].id }).catch(error => {
this.currentShow = 0 alert('There was an error fetching shows from the server: ' + error)
this.showsLoaded = true
this.switchShow(this.currentShow)
}
}, response => {
alert('There was an error fetching shows from the server')
}) })
} }
} }
......
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from './App'
import router from './router' import router from './router'
import VueResource from 'vue-resource'
import BootstrapVue from 'bootstrap-vue' import BootstrapVue from 'bootstrap-vue'
Vue.use(VueResource)
Vue.use(BootstrapVue) Vue.use(BootstrapVue)
Vue.config.productionTip = false Vue.config.productionTip = false
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment