fix radio table

This commit is contained in:
Thomas Amland 2021-01-24 12:24:16 +01:00
parent c49eb98efb
commit 383334cfe5
2 changed files with 19 additions and 4 deletions

View File

@ -1,9 +1,12 @@
<template> <template>
<div v-if="items"> <div v-if="items">
<h1>Radio</h1> <h1>Radio</h1>
<table class="table table-hover table-borderless"> <table class="table table-hover table-borderless table-numbered">
<thead> <thead>
<tr> <tr>
<th>
#
</th>
<th class="text-left"> <th class="text-left">
Title Title
</th> </th>
@ -13,9 +16,17 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="(item, index) in items" :key="index" <tr v-for="(item, index) in items"
:class="{'active': item.id === playingTrackId}"> :key="index"
<td @click="play(index)"> :class="{'active': item.id === playingTrackId}"
@click="play(index)">
<td>
<button>
<Icon class="icon" :icon="isPlaying && item.id === playingTrackId ? 'pause-fill' :'play-fill'" />
<span class="number">{{ index + 1 }}</span>
</button>
</td>
<td>
{{ item.title }} {{ item.title }}
<div> <div>
<small class="text-muted"> <small class="text-muted">
@ -49,6 +60,7 @@
computed: { computed: {
...mapGetters({ ...mapGetters({
playingTrackId: 'player/trackId', playingTrackId: 'player/trackId',
isPlaying: 'player/isPlaying',
}), }),
}, },
async created() { async created() {

View File

@ -188,6 +188,9 @@ export const playerModule: Module<State, any> = {
trackId(state, getters): number { trackId(state, getters): number {
return getters.track ? getters.track.id : -1 return getters.track ? getters.track.id : -1
}, },
isPlaying(state): boolean {
return state.isPlaying
},
progress(state) { progress(state) {
if (state.currentTime > -1 && state.duration > 0) { if (state.currentTime > -1 && state.duration > 0) {
return (state.currentTime / state.duration) * 100 return (state.currentTime / state.duration) * 100