107 lines
2.7 KiB
Vue
Raw Normal View History

<template>
2024-03-26 03:13:17 +01:00
<template v-for="item in items" :key="item.itemId">
<div v-if="!item.isItem" class="mt-6 mb-5 py-2">
<span
2024-03-26 03:34:50 +01:00
:id="`index_${item.index}`"
class="tag is-info is-light is-small has-text-weight-bold"
2024-03-26 03:13:17 +01:00
v-text="item.index"
/>
</div>
<div
v-else
class="media is-align-items-center"
:class="{ 'with-progress': show_progress }"
2024-03-26 03:13:17 +01:00
@click="play(item.item)"
>
<figure v-if="show_icon" class="media-left is-clickable">
<mdicon class="icon" name="file-outline" size="16" />
</figure>
<div class="media-content is-clickable is-clipped">
<h1
class="title is-6"
:class="{
'has-text-grey':
2024-03-26 03:13:17 +01:00
item.item.media_kind === 'podcast' && item.item.play_count > 0
}"
2024-03-26 03:13:17 +01:00
v-text="item.item.title"
/>
2023-12-09 10:49:15 +01:00
<h2
class="subtitle is-7 has-text-grey has-text-weight-bold"
2024-03-26 03:13:17 +01:00
v-text="item.item.artist"
2023-12-09 10:49:15 +01:00
/>
2024-03-26 03:13:17 +01:00
<h2 class="subtitle is-7 has-text-grey" v-text="item.item.album" />
<progress
2024-03-26 03:13:17 +01:00
v-if="show_progress && item.item.seek_ms > 0"
class="progress is-info"
2024-03-26 03:13:17 +01:00
:max="item.item.length_ms"
:value="item.item.seek_ms"
/>
</div>
<div class="media-right">
2024-03-26 03:13:17 +01:00
<a @click.prevent.stop="open_dialog(item.item)">
<mdicon class="icon has-text-dark" name="dots-vertical" size="16" />
</a>
</div>
</div>
</template>
<teleport to="#app">
<modal-dialog-track
2024-03-26 03:13:17 +01:00
:item="selected_item"
:show="show_details_modal"
@close="show_details_modal = false"
@play-count-changed="$emit('play-count-changed')"
/>
</teleport>
</template>
<script>
2022-02-19 06:18:01 +01:00
import ModalDialogTrack from '@/components/ModalDialogTrack.vue'
import webapi from '@/webapi'
export default {
name: 'ListTracks',
components: { ModalDialogTrack },
2024-02-27 17:18:58 +01:00
props: {
2024-02-28 13:10:08 +01:00
expression: { default: '', type: String },
items: { required: true, type: Object },
2024-02-28 13:10:08 +01:00
show_icon: Boolean,
2024-02-27 17:18:58 +01:00
show_progress: Boolean,
2024-02-28 13:10:08 +01:00
uris: { default: '', type: String }
2024-02-27 17:18:58 +01:00
},
emits: ['play-count-changed'],
data() {
return {
2024-03-26 03:13:17 +01:00
selected_item: {},
show_details_modal: false
}
},
methods: {
2024-03-26 03:13:17 +01:00
open_dialog(item) {
this.selected_item = item
2024-03-23 01:53:25 +01:00
this.show_details_modal = true
},
2024-03-26 03:13:17 +01:00
play(item) {
if (this.uris) {
2024-03-26 03:13:17 +01:00
webapi.player_play_uri(this.uris, false, this.items.items.indexOf(item))
} else if (this.expression) {
2023-07-26 16:04:12 +02:00
webapi.player_play_expression(
this.expression,
false,
2024-03-26 03:13:17 +01:00
this.items.items.indexOf(item)
2023-07-26 16:04:12 +02:00
)
} else {
2024-03-26 03:13:17 +01:00
webapi.player_play_uri(item.uri, false)
}
}
}
}
</script>
<style scoped>
.progress {
height: 0.25rem;
}
</style>