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 @@ ...@@ -265,17 +265,19 @@
title="Edit playlist" title="Edit playlist"
></span> ></span>
<span <span
v-if="data.item.options.play"
class="timeslotEditLink" class="timeslotEditLink"
@click="notYetImplemented()" @click="notYetImplemented()"
><img ><img
src="../assets/16x16/media-playback-start.png" src="../assets/16x16/media-playback-start.png"
alt="Play audio file / playlist" alt="Open player"
title="Play audio file / playlist" title="Open player"
></span> ></span>
<span </template>
class="timeslotEditLink"
@click="notYetImplemented()" <template v-slot:cell(playlist)="data">
>...</span> <span v-if="data.value">{{ data.value }}</span>
<span v-else><small><i>(none set)</i></small></span>
</template> </template>
</b-table> </b-table>
<b-pagination <b-pagination
...@@ -752,6 +754,7 @@ export default { ...@@ -752,6 +754,7 @@ export default {
fundingcategory: false, fundingcategory: false,
type: false, type: false,
owners: false, owners: false,
playlists: false,
}, },
// the current object is used to hold all the necessary data to describe // the current object is used to hold all the necessary data to describe
...@@ -764,6 +767,7 @@ export default { ...@@ -764,6 +767,7 @@ export default {
musicfocus: [], musicfocus: [],
fundingcategory: [], fundingcategory: [],
type: [], type: [],
playlists: [],
timeslots: [], timeslots: [],
timeslotmeta: { // meta info when pagination is used timeslotmeta: { // meta info when pagination is used
count: 0, count: 0,
...@@ -784,7 +788,8 @@ export default { ...@@ -784,7 +788,8 @@ export default {
{ key: 'title', label: 'Title of emission' }, { key: 'title', label: 'Title of emission' },
{ key: 'starts', label: 'Emission start' }, { key: 'starts', label: 'Emission start' },
{ key: 'duration', label: 'Duration' }, { key: 'duration', label: 'Duration' },
{ key: 'options', label: 'Edit' } { key: 'options', label: 'Edit' },
{ key: 'playlist', label: 'Playlist' },
] ]
} }
}, },
...@@ -820,21 +825,34 @@ export default { ...@@ -820,21 +825,34 @@ export default {
// As we do not have a single object which holds all info we need to display // 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 // in the table with our timeslots, we use this computed array to do that
notesTableArray: function () { notesTableArray: function () {
var arr = [] let rows = []
for (var i in this.current.timeslots) { 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 } 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, title: note,
starts: this.prettyDateTime(this.current.timeslots[i].start), starts: this.prettyDateTime(this.current.timeslots[i].start),
duration: this.prettyDuration(this.current.timeslots[i].start, this.current.timeslots[i].end), duration: this.prettyDuration(this.current.timeslots[i].start, this.current.timeslots[i].end),
options: { options: {
id: this.current.timeslots[i].id, 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 { ...@@ -914,8 +932,8 @@ export default {
if (this.$parent.user.steeringUser.is_superuser) { if (this.$parent.user.steeringUser.is_superuser) {
this.getOwners() this.getOwners()
} }
// now fetch the timeslots (including notes) for a given show from PV backend
this.getTimeslots(this.dateStart, this.dateEnd, this.numSlots) 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. // (Re)Load all shows from server and switch to a show with a specific ID.
...@@ -958,6 +976,25 @@ export default { ...@@ -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 // Fetch timeslots for the current show and use filter variables if provided
getTimeslots: function (start, end, limit, offset) { getTimeslots: function (start, end, limit, offset) {
var dateRegex = new RegExp('^\\d{4}-\\d{2}-\\d{2}$') 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