2018-08-11 01:47:10 -04:00
|
|
|
<template>
|
2023-06-23 16:23:32 -04:00
|
|
|
<div class="fd-page">
|
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">
|
2023-06-30 15:41:40 -04:00
|
|
|
<mdicon class="icon" name="pencil" size="16" />
|
2022-05-20 07:44:22 -04:00
|
|
|
<span v-text="$t('page.podcasts.mark-all-played')" />
|
2022-02-19 00:39:14 -05:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template #content>
|
2022-05-29 12:49:00 -04:00
|
|
|
<list-tracks
|
2023-03-23 18:19:55 -04:00
|
|
|
:tracks="new_episodes"
|
2022-05-29 12:49:00 -04:00
|
|
|
: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')" />
|
2022-05-29 12:49:00 -04:00
|
|
|
<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">
|
2023-06-30 15:41:40 -04:00
|
|
|
<mdicon class="icon" name="refresh" size="16" />
|
2022-05-20 07:44:22 -04:00
|
|
|
<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">
|
2023-06-30 15:41:40 -04:00
|
|
|
<mdicon class="icon" name="rss" size="16" />
|
2022-05-20 07:44:22 -04:00
|
|
|
<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-29 12:49:00 -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>
|
2023-07-18 09:48:56 -04:00
|
|
|
import * as types from '@/store/mutation_types'
|
2022-02-19 00:18:01 -05:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
2023-07-18 09:48:56 -04:00
|
|
|
import { GroupByList } from '@/lib/GroupByList'
|
2022-02-19 00:18:01 -05:00
|
|
|
import ListAlbums from '@/components/ListAlbums.vue'
|
2023-07-18 09:48:56 -04:00
|
|
|
import ListTracks from '@/components/ListTracks.vue'
|
2022-02-19 00:18:01 -05:00
|
|
|
import ModalDialogAddRss from '@/components/ModalDialogAddRss.vue'
|
2018-08-11 01:47:10 -04:00
|
|
|
import webapi from '@/webapi'
|
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
const dataObject = {
|
2023-06-07 15:25:54 -04:00
|
|
|
load(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
|
|
|
},
|
|
|
|
|
2023-06-07 15:25:54 -04:00
|
|
|
set(vm, response) {
|
2022-02-19 01:47:54 -05:00
|
|
|
vm.albums = new GroupByList(response[0].data)
|
2023-03-23 18:19:55 -04:00
|
|
|
vm.new_episodes = new GroupByList(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: {
|
2023-06-07 15:25:54 -04:00
|
|
|
mark_all_played() {
|
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
|
|
|
},
|
|
|
|
|
2023-06-07 15:25:54 -04:00
|
|
|
open_add_podcast_dialog(item) {
|
2020-02-21 15:21:08 -05:00
|
|
|
this.show_url_modal = true
|
|
|
|
},
|
|
|
|
|
2023-06-07 15:25:54 -04:00
|
|
|
reload_new_episodes() {
|
2019-01-29 11:50:47 -05:00
|
|
|
webapi.library_podcasts_new_episodes().then(({ data }) => {
|
2023-03-23 18:19:55 -04:00
|
|
|
this.new_episodes = new GroupByList(data.tracks)
|
2019-01-29 11:50:47 -05:00
|
|
|
})
|
2020-02-21 15:21:08 -05:00
|
|
|
},
|
|
|
|
|
2023-06-07 15:25:54 -04:00
|
|
|
reload_podcasts() {
|
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
|
|
|
},
|
|
|
|
|
2023-06-07 15:25:54 -04:00
|
|
|
update_rss() {
|
2022-01-09 12:29:24 -05:00
|
|
|
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>
|