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

Add playlist column to timeslots table for #35

parent 40f3faec
......@@ -265,17 +265,19 @@
title="Edit playlist"
></span>
<span
v-if="data.item.options.play"
class="timeslotEditLink"
@click="notYetImplemented()"
><img
src="../assets/16x16/media-playback-start.png"
alt="Play audio file / playlist"
title="Play audio file / playlist"
alt="Open player"
title="Open player"
></span>
<span
class="timeslotEditLink"
@click="notYetImplemented()"
>...</span>
</template>
<template v-slot:cell(playlist)="data">
<span v-if="data.value">{{ data.value }}</span>
<span v-else><small><i>(none set)</i></small></span>
</template>
</b-table>
<b-pagination
......@@ -752,6 +754,7 @@ export default {
fundingcategory: false,
type: false,
owners: false,
playlists: false,
},
// the current object is used to hold all the necessary data to describe
......@@ -764,6 +767,7 @@ export default {
musicfocus: [],
fundingcategory: [],
type: [],
playlists: [],
timeslots: [],
timeslotmeta: { // meta info when pagination is used
count: 0,
......@@ -784,7 +788,8 @@ export default {
{ key: 'title', label: 'Title of emission' },
{ key: 'starts', label: 'Emission start' },
{ key: 'duration', label: 'Duration' },
{ key: 'options', label: 'Edit' }
{ key: 'options', label: 'Edit' },
{ key: 'playlist', label: 'Playlist' },
]
}
},
......@@ -820,21 +825,34 @@ export default {
// As we do not have a single object which holds all info we need to display
// in the table with our timeslots, we use this computed array to do that
notesTableArray: function () {
var arr = []
let rows = []
for (var i in this.current.timeslots) {
var note = this.getNoteByTimeslotID(this.current.timeslots[i].id)
let note = this.getNoteByTimeslotID(this.current.timeslots[i].id)
if (note !== null) { note = note.title }
arr.push({
let playlistTitle = ''
if (this.current.timeslots[i].playlist_id !== null) {
let playlist = this.current.playlists.find(list => list.id === this.current.timeslots[i].playlist_id)
if (playlist && playlist.description.length > 0) {
playlistTitle = playlist.description
} else {
playlistTitle = playlist.id
}
}
rows.push({
title: note,
starts: this.prettyDateTime(this.current.timeslots[i].start),
duration: this.prettyDuration(this.current.timeslots[i].start, this.current.timeslots[i].end),
options: {
id: this.current.timeslots[i].id,
schedule: this.current.timeslots[i].schedule
}
schedule: this.current.timeslots[i].schedule,
play: this.current.timeslots[i].playlist_id !== null
},
playlist: playlistTitle
})
}
return arr
return rows
}
},
......@@ -914,8 +932,8 @@ export default {
if (this.$parent.user.steeringUser.is_superuser) {
this.getOwners()
}
// now fetch the timeslots (including notes) for a given show from PV backend
this.getTimeslots(this.dateStart, this.dateEnd, this.numSlots)
this.loadPlaylists()
},
// (Re)Load all shows from server and switch to a show with a specific ID.
......@@ -958,6 +976,25 @@ export default {
})
},
loadPlaylists () {
this.loaded.playlists = false
let uri = process.env.VUE_APP_API_TANK + 'shows/' + this.shows[this.currentShow].slug + '/playlists'
axios.get(uri, {
withCredentials: true,
headers: { 'Authorization': 'Bearer ' + this.$parent.user.access_token }
}).then(response => {
// we don't have to check separately, if there are playlists, because tank
// always provides an empty array if there are no playlists (or even if there is no corresponding show)
this.current.playlists = response.data.results
this.loaded.playlists = true
}).catch(error => {
//this.$log.error(error.response.status + ' ' + error.response.statusText)
//this.$log.error(error.response)
this.$log.error(error)
alert('Error: could not fetch playlists from tank. See console for details.')
})
},
// Fetch timeslots for the current show and use filter variables if provided
getTimeslots: function (start, end, limit, offset) {
var dateRegex = new RegExp('^\\d{4}-\\d{2}-\\d{2}$')
......
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