1
0
Fork 0
mirror of https://github.com/Findus23/RadioStats.git synced 2024-09-19 16:03:48 +02:00
RadioStats/web/src/DetailView.vue

168 lines
5.5 KiB
Vue
Raw Normal View History

2018-02-19 20:23:05 +01:00
<template>
2020-02-06 17:57:50 +01:00
<div class="detailView customRow" :style="{backgroundColor:'#'+song.song.background_color,color:'#'+song.song.text_color}">
2018-02-19 20:23:05 +01:00
<div>
<img v-if="song.song.image_large" :src="song.song.image_large">
<div v-else class="imgPlaceholder">
<div>?</div>
</div>
<audio v-if="song.song.preview_url" controls preload="none" :src="song.song.preview_url"></audio>
<a v-if="song.song.spotify_url" :href="song.song.spotify_url" class="spotifyLink" target="_blank"
2020-02-06 17:57:50 +01:00
rel="noopener" :style="{color: '#'+song.song.alternative_color}">
2018-02-19 20:23:05 +01:00
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 168 168">
<path d="m83.996 0.277c-46.249 0-83.743 37.493-83.743 83.742 0 46.251 37.494 83.741 83.743 83.741 46.254 0 83.744-37.49 83.744-83.741 0-46.246-37.49-83.738-83.745-83.738l0.001-0.004zm38.404 120.78c-1.5 2.46-4.72 3.24-7.18 1.73-19.662-12.01-44.414-14.73-73.564-8.07-2.809 0.64-5.609-1.12-6.249-3.93-0.643-2.81 1.11-5.61 3.926-6.25 31.9-7.291 59.263-4.15 81.337 9.34 2.46 1.51 3.24 4.72 1.73 7.18zm10.25-22.805c-1.89 3.075-5.91 4.045-8.98 2.155-22.51-13.839-56.823-17.846-83.448-9.764-3.453 1.043-7.1-0.903-8.148-4.35-1.04-3.453 0.907-7.093 4.354-8.143 30.413-9.228 68.222-4.758 94.072 11.127 3.07 1.89 4.04 5.91 2.15 8.976v-0.001zm0.88-23.744c-26.99-16.031-71.52-17.505-97.289-9.684-4.138 1.255-8.514-1.081-9.768-5.219-1.254-4.14 1.08-8.513 5.221-9.771 29.581-8.98 78.756-7.245 109.83 11.202 3.73 2.209 4.95 7.016 2.74 10.733-2.2 3.722-7.02 4.949-10.73 2.739z"></path>
</svg>
</a>
</div>
<div>
<ul>
<li v-for="play in plays">
{{play.format("dddd DD. MMMM: HH:mm:ss")}}
2018-02-19 20:23:05 +01:00
</li>
</ul>
</div>
<router-link class="closeButton" :to="{ name: 'List', params: { channel: $route.params.channel }}" replace
:style="{color: color.backgroundColor}">
2018-02-19 20:23:05 +01:00
&times;
</router-link>
</div>
</template>
<script>
import axios from "axios";
import moment from "moment";
import "moment/locale/de-at";
2021-05-12 20:51:38 +02:00
if (import.meta.env.NODE_ENV === "production") {
2018-02-19 20:23:05 +01:00
axios.defaults.headers.common['X-Requested-With'] = "XMLHttpRequest";
}
2021-05-12 20:51:38 +02:00
const baseURL = (import.meta.env.NODE_ENV === "production") ? "/api/" : "http://127.0.0.1:5000/api/";
2018-02-19 20:23:05 +01:00
export default {
name: "detailview",
data() {
return {
plays: [],
};
},
props: ['songs', 'color', 'momentDate', 'dateType'],
2018-02-19 20:23:05 +01:00
mounted() {
this.getPlays();
2018-02-20 14:12:32 +01:00
document.title = "Radiostats - " + this.song.song.title + " - " + this.song.song.artist;
2018-02-19 20:23:05 +01:00
},
methods: {
getPlays: function() {
2018-02-19 20:23:05 +01:00
let vm = this;
this.plays = [];
axios.get(baseURL + this.$route.params.channel + "/plays/" + this.$route.params.songId, {
params: {
date: vm.momentDate.format("YYYY-MM-DD"),
dateType: vm.dateType
}
})
.then(function(response) {
response.data.forEach(function(time) {
2018-02-19 20:23:05 +01:00
vm.plays.push(moment(time));
});
// document.title = "Radiostats - " + vm.channels[vm.channel].stationname;
})
.catch(function(error) {
2018-02-19 20:23:05 +01:00
vm.httpError = error;
});
},
},
computed: {
song() {
return this.songs[this.$route.params.songId];
},
},
components: {},
watch: {
song: function() {
2018-02-19 20:23:05 +01:00
this.getPlays();
2018-02-20 14:12:32 +01:00
document.title = "Radiostats - " + this.song.song.title + " - " + this.song.song.artist;
2018-02-19 20:23:05 +01:00
},
}
};
</script>
<style lang="scss">
2021-05-12 20:51:38 +02:00
@import "./variables";
2018-02-19 20:23:05 +01:00
.detailWrapper {
padding: 0;
}
.detailView {
position: relative;
background-color: #f5f5f5;
2018-02-19 20:23:05 +01:00
img, .imgPlaceholder {
width: 250px;
height: 250px;
background-color: #eee;
display: block;
2018-02-19 20:23:05 +01:00
div {
text-align: center;
vertical-align: middle;
line-height: 250px;
font-size: 90px;
font-weight: bold;
}
}
2018-02-19 20:23:05 +01:00
> div {
padding: 15px 15px !important;
}
2018-02-19 20:23:05 +01:00
audio {
width: 250px;
}
2018-02-19 20:23:05 +01:00
.spotifyLink {
display: inline-block;
width: 250px;
2018-02-24 22:15:00 +01:00
margin-top: 5px;
2018-02-19 20:23:05 +01:00
&:hover {
color: #1ED760 !important;
}
svg {
fill: currentColor;
display: block;
width: 50px;
height: 50px;
margin-left: 100px;
}
}
2018-02-19 20:23:05 +01:00
ul {
max-height: 250px;
overflow-y: auto;
2018-04-15 19:15:07 +02:00
-webkit-overflow-scrolling: touch;
2018-02-19 20:23:05 +01:00
list-style: none;
}
2018-02-19 20:23:05 +01:00
.closeButton {
position: absolute;
font-size: 40px;
line-height: 10px;
top: 10px;
right: 20px;
padding: 10px;
cursor: pointer;
transition: color 0.2s;
2018-02-19 20:23:05 +01:00
&:hover {
color: darkgrey !important;
2018-02-19 20:23:05 +01:00
}
}
}
</style>