2018-08-11 01:47:10 -04:00
|
|
|
<template>
|
|
|
|
<div>
|
2019-01-27 00:36:19 -05:00
|
|
|
<content-with-heading v-if="new_episodes.items.length > 0">
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #heading-left>
|
2022-05-20 07:44:22 -04:00
|
|
|
<p class="title is-4" v-text="$t('page.podcasts.new-episodes')" />
|
2019-01-27 00:36:19 -05:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #heading-right>
|
|
|
|
<div class="buttons is-centered">
|
|
|
|
<a class="button is-small" @click="mark_all_played">
|
2022-05-20 07:44:22 -04:00
|
|
|
<mdicon class="icon" name="pencil" size="16" />
|
|
|
|
<span v-text="$t('page.podcasts.mark-all-played')" />
|
2022-02-19 00:39:14 -05:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template #content>
|
2022-05-20 07:44:22 -04:00
|
|
|
<list-tracks :tracks="new_episodes.items" :show_progress="true" @play-count-changed="reload_new_episodes" />
|
2019-01-27 00:36:19 -05:00
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
2018-08-11 01:47:10 -04:00
|
|
|
<content-with-heading>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #heading-left>
|
2022-05-20 07:44:22 -04:00
|
|
|
<p class="title is-4" v-text="$t('page.podcasts.title')" />
|
|
|
|
<p class="heading" v-text="$t('page.podcasts.count', { count: albums.total })" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #heading-right>
|
2020-02-21 15:21:08 -05:00
|
|
|
<div class="buttons is-centered">
|
2022-01-09 12:29:24 -05:00
|
|
|
<a v-if="rss.tracks > 0" class="button is-small" @click="update_rss">
|
2022-05-20 07:44:22 -04:00
|
|
|
<mdicon class="icon" name="refresh" size="16" />
|
|
|
|
<span v-text="$t('page.podcasts.update')" />
|
2022-01-09 12:29:24 -05:00
|
|
|
</a>
|
2020-04-12 03:37:32 -04:00
|
|
|
<a class="button is-small" @click="open_add_podcast_dialog">
|
2022-05-20 07:44:22 -04:00
|
|
|
<mdicon class="icon" name="rss" size="16" />
|
|
|
|
<span v-text="$t('page.podcasts.add')" />
|
2020-02-21 15:21:08 -05:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-02-19 00:39:14 -05:00
|
|
|
<template #content>
|
2022-05-20 07:44:22 -04:00
|
|
|
<list-albums :albums="albums" @play-count-changed="reload_new_episodes()" @podcast-deleted="reload_podcasts()" />
|
|
|
|
<modal-dialog-add-rss :show="show_url_modal" @close="show_url_modal = false" @podcast-added="reload_podcasts()" />
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-19 00:18:01 -05:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
2022-02-19 01:47:54 -05:00
|
|
|
import ListTracks from '@/components/ListTracks.vue'
|
2022-02-19 00:18:01 -05:00
|
|
|
import ListAlbums from '@/components/ListAlbums.vue'
|
|
|
|
import ModalDialogAddRss from '@/components/ModalDialogAddRss.vue'
|
2022-01-09 12:29:24 -05:00
|
|
|
import * as types from '@/store/mutation_types'
|
2018-08-11 01:47:10 -04:00
|
|
|
import webapi from '@/webapi'
|
2022-02-19 01:47:54 -05:00
|
|
|
import { GroupByList } from '@/lib/GroupByList'
|
2018-08-11 01:47:10 -04:00
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
const dataObject = {
|
2018-08-11 01:47:10 -04:00
|
|
|
load: function (to) {
|
2019-01-27 00:36:19 -05:00
|
|
|
return Promise.all([
|
2020-06-30 04:24:11 -04:00
|
|
|
webapi.library_albums('podcast'),
|
2019-01-27 00:36:19 -05:00
|
|
|
webapi.library_podcasts_new_episodes()
|
|
|
|
])
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
set: function (vm, response) {
|
2022-02-19 01:47:54 -05:00
|
|
|
vm.albums = new GroupByList(response[0].data)
|
2019-01-27 00:36:19 -05:00
|
|
|
vm.new_episodes = response[1].data.tracks
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PagePodcasts',
|
2022-02-19 00:18:01 -05:00
|
|
|
components: {
|
|
|
|
ContentWithHeading,
|
2022-02-19 01:47:54 -05:00
|
|
|
ListTracks,
|
2022-02-19 00:18:01 -05:00
|
|
|
ListAlbums,
|
2022-02-19 01:47:54 -05:00
|
|
|
ModalDialogAddRss
|
2022-02-19 00:18:01 -05:00
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
beforeRouteEnter(to, from, next) {
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
next((vm) => dataObject.set(vm, response))
|
|
|
|
})
|
|
|
|
},
|
2022-02-19 01:47:54 -05:00
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
beforeRouteUpdate(to, from, next) {
|
|
|
|
const vm = this
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
dataObject.set(vm, response)
|
|
|
|
next()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
2018-08-11 01:47:10 -04:00
|
|
|
return {
|
2022-02-19 01:47:54 -05:00
|
|
|
albums: [],
|
2019-01-27 00:36:19 -05:00
|
|
|
new_episodes: { items: [] },
|
2018-12-15 03:56:09 -05:00
|
|
|
|
2022-02-19 01:47:54 -05:00
|
|
|
show_url_modal: false
|
2018-12-15 03:56:09 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-01-09 12:29:24 -05:00
|
|
|
computed: {
|
2022-02-19 00:39:14 -05:00
|
|
|
rss() {
|
2022-01-09 12:29:24 -05:00
|
|
|
return this.$store.state.rss_count
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-12-15 03:56:09 -05:00
|
|
|
methods: {
|
2020-02-21 15:21:08 -05:00
|
|
|
mark_all_played: function () {
|
2022-02-19 00:39:14 -05:00
|
|
|
this.new_episodes.items.forEach((ep) => {
|
2020-04-11 13:43:53 -04:00
|
|
|
webapi.library_track_update(ep.id, { play_count: 'increment' })
|
2020-02-21 15:21:08 -05:00
|
|
|
})
|
2022-02-19 00:39:14 -05:00
|
|
|
this.new_episodes.items = {}
|
2020-02-21 15:21:08 -05:00
|
|
|
},
|
|
|
|
|
2020-04-12 03:37:32 -04:00
|
|
|
open_add_podcast_dialog: function (item) {
|
2020-02-21 15:21:08 -05:00
|
|
|
this.show_url_modal = true
|
|
|
|
},
|
|
|
|
|
2019-01-29 11:50:47 -05:00
|
|
|
reload_new_episodes: function () {
|
|
|
|
webapi.library_podcasts_new_episodes().then(({ data }) => {
|
|
|
|
this.new_episodes = data.tracks
|
|
|
|
})
|
2020-02-21 15:21:08 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
reload_podcasts: function () {
|
2020-06-30 04:24:11 -04:00
|
|
|
webapi.library_albums('podcast').then(({ data }) => {
|
2022-02-19 01:47:54 -05:00
|
|
|
this.albums = new GroupByList(data)
|
2020-02-21 15:21:08 -05:00
|
|
|
this.reload_new_episodes()
|
|
|
|
})
|
2022-01-09 12:29:24 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
update_rss: function () {
|
|
|
|
this.$store.commit(types.UPDATE_DIALOG_SCAN_KIND, 'rss')
|
|
|
|
this.$store.commit(types.SHOW_UPDATE_DIALOG, true)
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 00:39:14 -05:00
|
|
|
<style></style>
|