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

add URI import; delete debug code and typos

parent 63586820
......@@ -202,9 +202,6 @@ export default {
editFile: function (id) {
var file = this.getFileById(id)
this.temp.id = file.id
//this.temp.artist = file.metadata.artist === undefined ? '' : file.metadata.artist
//this.temp.album = file.metadata.album === undefined ? '' : file.metadata.album
//this.temp.title = file.metadata.title === undefined ? '' : file.metadata.title
this.temp.artist = file.metadata.artist
this.temp.album = file.metadata.album
this.temp.title = file.metadata.title
......@@ -213,13 +210,17 @@ export default {
},
saveFile: function (){
var file = this.getFileById(this.temp.id)
// we only want to send a PATCH request if some metadata actually changed
if (this.temp.artist !== file.metadata.artist || this.temp.album !== file.metadata.album || this.temp.title !== file.metadata.title ) {
var metadata= {}
if (this.temp.artist) metadata.artist = this.temp.artist
if (this.temp.album) metadata.album = this.temp.album
if (this.temp.title) metadata.title = this.temp.title
console.log(metadata)
// if a metadata property was in use before and now shall be emptied
// we cannot just omit the property, but have to explicitly send null
var metadata = {
title: this.temp.artist ? this.temp.artist : null,
album: this.temp.album ? this.temp.album : null,
title: this.temp.title ? this.temp.title : null
}
var uri = process.env.VUE_APP_API_TANK + 'shows/' + this.shows[this.currentShow].slug + '/files/' + file.id
// TODO: add mechanism to indicate the running patch request in the files table
axios.patch(uri, metadata, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
......@@ -234,6 +235,7 @@ export default {
},
deleteFile: function (id) {
var uri = process.env.VUE_APP_API_TANK + 'shows/' + this.shows[this.currentShow].slug + '/files/' + id
// TODO: add mechanism to indicate the running delete request in the files table
axios.delete(uri, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token },
......@@ -248,9 +250,19 @@ export default {
addFile: function () {
var uri = process.env.VUE_APP_API_TANK + 'shows/' + this.shows[this.currentShow].slug + '/files'
if (this.addNewFileURI) {
//this.uploadSourceURI
this.notYetImplemented()
// TODO: add mechanism to indicate the running post request in the files table
axios.post(uri, { 'source-uri': this.uploadSourceURI }, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(
this.fetchShows(this.shows[this.currentShow].slug)
).catch(error => {
console.log('Error:')
console.log(error)
alert('Error: could not add the new remote import. See console log for details.')
})
} else if (this.uploadSourceFile) {
// TODO: add mechanism to indicate the running post request in the files table
axios.post(uri, { 'source-uri': encodeURI('upload://' + this.uploadSourceFile.name) }, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
......@@ -263,7 +275,7 @@ export default {
alert('Error: could not add the new file upload. See console log for details.')
})
} else {
alert('Something is wrong. You have choose to upload a file, but the corresponding file object does not exist.')
alert('Something is wrong. You have choosen to upload a file, but the corresponding file object does not exist.')
}
},
startUpload: function (id) {
......
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