owntone-server/web-src/src/components/ModalDialogAlbum.vue

189 lines
5.8 KiB
Vue
Raw Normal View History

<template>
2024-03-05 14:21:35 +01:00
<transition name="fade">
<div v-if="show" class="modal is-active">
<div class="modal-background" @click="$emit('close')" />
<div class="modal-content">
<div class="card">
<div class="card-content">
<cover-artwork
2024-03-26 03:13:17 +01:00
:artwork_url="item.artwork_url"
:artist="item.artist"
:album="item.name"
2024-03-05 14:21:35 +01:00
class="fd-has-shadow fd-cover fd-cover-normal-image mb-5"
/>
<p class="title is-4">
2024-03-26 03:13:17 +01:00
<a class="has-text-link" @click="open" v-text="item.name" />
2024-03-05 14:21:35 +01:00
</p>
<div v-if="media_kind_resolved === 'podcast'" class="buttons">
<a
class="button is-small"
@click="mark_played"
v-text="$t('dialog.album.mark-as-played')"
/>
<a
2024-03-26 03:13:17 +01:00
v-if="item.data_kind === 'url'"
2024-03-05 14:21:35 +01:00
class="button is-small"
@click="$emit('remove-podcast')"
v-text="$t('dialog.album.remove-podcast')"
/>
</div>
<div class="content is-small">
2024-03-26 03:13:17 +01:00
<p v-if="item.artist">
2024-03-05 14:21:35 +01:00
<span class="heading" v-text="$t('dialog.album.artist')" />
<a
2024-03-05 14:21:35 +01:00
class="title is-6 has-text-link"
@click="open_artist"
2024-03-26 03:13:17 +01:00
v-text="item.artist"
/>
</p>
2024-03-26 03:13:17 +01:00
<p v-if="item.date_released">
2024-03-05 14:21:35 +01:00
<span
class="heading"
v-text="$t('dialog.album.release-date')"
/>
2024-03-05 14:21:35 +01:00
<span
class="title is-6"
2024-03-26 03:13:17 +01:00
v-text="$filters.date(item.date_released)"
2024-03-05 14:21:35 +01:00
/>
</p>
2024-03-26 03:13:17 +01:00
<p v-else-if="item.year">
2024-03-05 14:21:35 +01:00
<span class="heading" v-text="$t('dialog.album.year')" />
2024-03-26 03:13:17 +01:00
<span class="title is-6" v-text="item.year" />
2024-03-05 14:21:35 +01:00
</p>
<p>
<span class="heading" v-text="$t('dialog.album.tracks')" />
2024-03-26 03:13:17 +01:00
<span class="title is-6" v-text="item.track_count" />
2024-03-05 14:21:35 +01:00
</p>
<p>
<span class="heading" v-text="$t('dialog.album.duration')" />
<span
class="title is-6"
2024-03-26 03:13:17 +01:00
v-text="$filters.durationInHours(item.length_ms)"
2024-03-05 14:21:35 +01:00
/>
</p>
<p>
<span class="heading" v-text="$t('dialog.album.type')" />
<span
class="title is-6"
v-text="
2024-03-26 03:34:50 +01:00
`${$t(`media.kind.${item.media_kind}`)} - ${$t(`data.kind.${item.data_kind}`)}`
2024-03-05 14:21:35 +01:00
"
/>
2024-03-05 14:21:35 +01:00
</p>
<p>
<span class="heading" v-text="$t('dialog.album.added-on')" />
<span
class="title is-6"
2024-03-26 03:13:17 +01:00
v-text="$filters.datetime(item.time_added)"
2024-03-05 14:21:35 +01:00
/>
</p>
</div>
</div>
2024-03-05 14:21:35 +01:00
<footer class="card-footer">
<a class="card-footer-item has-text-dark" @click="queue_add">
<mdicon class="icon" name="playlist-plus" size="16" />
<span class="is-size-7" v-text="$t('dialog.album.add')" />
</a>
<a class="card-footer-item has-text-dark" @click="queue_add_next">
<mdicon class="icon" name="playlist-play" size="16" />
<span class="is-size-7" v-text="$t('dialog.album.add-next')" />
</a>
<a class="card-footer-item has-text-dark" @click="play">
<mdicon class="icon" name="play" size="16" />
<span class="is-size-7" v-text="$t('dialog.album.play')" />
</a>
</footer>
</div>
</div>
2024-03-05 14:21:35 +01:00
<button
class="modal-close is-large"
aria-label="close"
@click="$emit('close')"
/>
</div>
</transition>
</template>
<script>
2022-02-19 06:18:01 +01:00
import CoverArtwork from '@/components/CoverArtwork.vue'
import webapi from '@/webapi'
export default {
name: 'ModalDialogAlbum',
components: { CoverArtwork },
2024-02-27 17:18:58 +01:00
props: {
2024-03-26 03:13:17 +01:00
item: { required: true, type: Object },
2024-02-28 13:10:08 +01:00
media_kind: { default: '', type: String },
show: Boolean
2024-02-27 17:18:58 +01:00
},
2022-02-19 07:05:59 +01:00
emits: ['close', 'remove-podcast', 'play-count-changed'],
data() {
return {
artwork_visible: false
}
},
computed: {
media_kind_resolved() {
2024-03-26 03:13:17 +01:00
return this.media_kind || this.item.media_kind
}
},
methods: {
2024-03-26 01:17:07 +01:00
mark_played() {
webapi
2024-03-26 03:13:17 +01:00
.library_album_track_update(this.item.id, { play_count: 'played' })
2024-03-26 01:17:07 +01:00
.then(({ data }) => {
this.$emit('play-count-changed')
this.$emit('close')
})
},
2024-03-26 01:29:05 +01:00
open() {
this.$emit('close')
if (this.media_kind_resolved === 'podcast') {
2024-03-26 03:13:17 +01:00
this.$router.push({ name: 'podcast', params: { id: this.item.id } })
} else if (this.media_kind_resolved === 'audiobook') {
this.$router.push({
name: 'audiobooks-album',
2024-03-26 03:13:17 +01:00
params: { id: this.item.id }
})
} else {
this.$router.push({
name: 'music-album',
2024-03-26 03:13:17 +01:00
params: { id: this.item.id }
})
}
},
open_artist() {
this.$emit('close')
if (this.media_kind_resolved === 'audiobook') {
this.$router.push({
name: 'audiobooks-artist',
2024-03-26 03:13:17 +01:00
params: { id: this.item.artist_id }
})
} else {
this.$router.push({
name: 'music-artist',
2024-03-26 03:13:17 +01:00
params: { id: this.item.artist_id }
})
}
},
2024-03-26 01:17:07 +01:00
play() {
this.$emit('close')
2024-03-26 03:13:17 +01:00
webapi.player_play_uri(this.item.uri, false)
2024-03-26 01:17:07 +01:00
},
queue_add() {
this.$emit('close')
2024-03-26 03:13:17 +01:00
webapi.queue_add(this.item.uri)
2024-03-26 01:17:07 +01:00
},
queue_add_next() {
this.$emit('close')
2024-03-26 03:13:17 +01:00
webapi.queue_add_next(this.item.uri)
}
}
}
</script>
<style></style>