Added track listing

This commit is contained in:
Pünkösd Marcell 2020-11-26 06:42:04 +01:00
parent 31f8cffec1
commit 6a63392b09
6 changed files with 82 additions and 6 deletions

View File

@ -37,8 +37,12 @@ export default {
this.$api.getMyInfo().then(({name}) => {
this.$store.dispatch('storeUserData', name).then(() => {
this.$router.push({name: "Collections"}).catch(() => {});
this.$store.dispatch('setAppReady');
if (this.$route.path === '/login') {
// TODO: ez igy nagyon gagyi solution
this.$router.push({name: "Collections"}).catch(() => {
});
}
this.$store.dispatch('setAppReady');
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -18,7 +18,7 @@ export default {
},
methods: {
performClick() {
this.$emit('clicked');
this.$emit('click');
}
}
}

View File

@ -74,6 +74,11 @@ const router = new VueRouter({
router.beforeEach((to, from, next) => {
if (!store.state.appReady) {
next();
return;
}
const authorized = store.getters.isLoggedIn;
const visitAllowed = to.matched.some(record => record.meta.allowVisit(authorized))

View File

@ -1,10 +1,77 @@
<template>
<div></div>
<b-container>
<b-row>
<b-col>
<h1>Collection: {{ collectionName }}</h1>
</b-col>
</b-row>
<big-chungus-loader text="Fetching track list..." v-if="processing"/>
<b-row v-else>
<b-col class="my-4">
<b-table :items="tracklist" :fields="fields" hover borderless>
<template #cell(cover_url)="data">
<b-img-lazy :src="data.cover_url" height="45px" blank-src="@/assets/music_placeholder.png"
v-if="!!data.cover_url"/>
<b-img src="@/assets/music_placeholder.png" height="45px" v-else/>
</template>
<template #cell(id)="data">
<div class="text-right">
<b-button :asd="data">Open</b-button>&nbsp;
<b-button variant="success" :disabled="!data.spotify_id">Play</b-button>
</div>
</template>
</b-table>
</b-col>
</b-row>
</b-container>
</template>
<script>
import BigChungusLoader from "@/components/BigChungusLoader";
export default {
name: "Collection"
name: "Collection",
components: {
BigChungusLoader
},
data() {
return {
processing: true,
collectionName: "",
totalTracks: 0,
fields: [
{
key: "cover_url",
label: "Cover"
},
"artist",
"album",
"title",
{
key: "id",
label: ""
}
],
tracklist: []
}
},
mounted() {
this.$api.getList(this.$route.params.id).then((data) => {
if (data) {
this.tracklist = data.itemlist;
this.collectionName = data.name;
this.totalTracks = data.element_count;
this.processing = false;
} else {
this.$showToast("Invalid response from server");
}
}).catch(({text}) => {
this.$showToast(text);
});
}
}
</script>

View File

@ -27,7 +27,7 @@ export default {
},
methods: {
openCollection(id) {
console.log(id);
this.$router.push({name: "Collection", params: {id}})
}
},
mounted() {