Commit f0fc01d0 authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

FEAT: implement storing of new/updated playlists

parent 1c246b6e
......@@ -891,11 +891,44 @@ export default {
this.$bvModal.show('modal-edit-playlist')
},
// Adds a new or updates an existing playlist by sending a POST/PUT
// request to the AURA tank API
storePlaylist: function () {
this.notYetImplemented()
var data = { entries: this.playlistEditor.entries }
console.log('Attempting to send playlist data:')
console.log(JSON.stringify(data))
var uri = process.env.VUE_APP_API_TANK + 'shows/' + this.shows[this.currentShow].slug + '/playlists'
// TODO: add some spinner or other visualisation while the playlist is added/updated
if (this.playlistEditor.mode === 'add') {
axios.post(uri, data, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
this.playlists.push(response.data)
}).catch(error => {
console.log('Error: ' + error.response.status + ' ' + error.response.statusText)
console.log(error.response)
alert('Error: could not add new playlist. See console log for details.')
})
// when updating an existing playlist we use a PUT request and add the id
// of the playlist to the uri
} else if (this.playlistEditor.mode === 'edit') {
uri += '/' + this.playlistEditor.id
axios.put(uri, data, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
// TODO: seems to be not implemented in the tank yet
// update this as soon as tank has it implemented
//this.playlists.push(response.data)
console.log(response.data)
}).catch(error => {
console.log('Error: ' + error.response.status + ' ' + error.response.statusText)
console.log(error.response)
alert('Error: could not update playlist. See console log for details.')
})
}
},
// To start modifying the meta information for a file we have to set our
......
Markdown is supported
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