Merge branch 'master' of github.com:KevinMidboe/vinlottis

This commit is contained in:
2020-03-17 15:26:51 +01:00
3 changed files with 26 additions and 22 deletions

View File

@@ -45,7 +45,8 @@ router.route("/log/wines").post(mustBeAuthenticated, async (req, res) => {
let subscription = subs[i]; //get subscription from your databse here. let subscription = subs[i]; //get subscription from your databse here.
const message = JSON.stringify({ const message = JSON.stringify({
message: "Dagens vin er lagt til, se den på lottis.vin/dagens!", message: "Dagens vin er lagt til, se den på lottis.vin/dagens!",
title: "Ny vin!" title: "Ny vin!",
link: "/#/dagens"
}); });
sub.sendNotification(subscription, message); sub.sendNotification(subscription, message);
} }

View File

@@ -3,18 +3,7 @@
<div class="container"> <div class="container">
<h1 class="title">Dagens viner</h1> <h1 class="title">Dagens viner</h1>
<div class="wines-container"> <div class="wines-container">
<a :href="wine.vivinoLink" v-for="wine in wines" :key="wine"> <Wine :wine="wine" v-for="wine in wines" :key="wine" :fullscreen="true" :inlineSlot="true" />
<div class="inner-wine-container">
<div class="left">
<img :src="wine.image" class="wine-image" />
</div>
<div class="right">
<h3>{{ wine.name }}</h3>
<span v-if="wine.rating">{{ wine.rating }} rating</span>
<span class="wine-link">Les mer</span>
</div>
</div>
</a>
</div> </div>
</div> </div>
</div> </div>
@@ -23,10 +12,12 @@
<script> <script>
import { page, event } from "vue-analytics"; import { page, event } from "vue-analytics";
import Banner from "@/ui/Banner"; import Banner from "@/ui/Banner";
import Wine from "@/ui/Wine";
export default { export default {
components: { components: {
Banner Banner,
Wine
}, },
data() { data() {
return { return {
@@ -55,7 +46,7 @@ h1 {
.wines-container { .wines-container {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-evenly; justify-content: space-between;
margin: 0 2rem; margin: 0 2rem;
@media (min-width: 1500px) { @media (min-width: 1500px) {

View File

@@ -3,14 +3,13 @@
<div class="top-banner"> <div class="top-banner">
<img src="/public/assets/images/knowit.svg" alt="knowit logo" /> <img src="/public/assets/images/knowit.svg" alt="knowit logo" />
<div class="clock"> <div class="clock">
<h2 cv-if="distance > 0"> <h2 v-if="!fiveMinutesLeft && !tenMinutesOver">
<span v-if="days > 0">{{ pad(days) }}:</span> <span v-if="days > 0">{{ pad(days) }}:</span>
<span>{{ pad(hours) }}</span <span>{{ pad(hours) }}</span>:
>: <span>{{ pad(minutes) }}</span <span>{{ pad(minutes) }}</span>:
>:
<span>{{ pad(seconds) }}</span> <span>{{ pad(seconds) }}</span>
</h2> </h2>
<h2 v-if="distance <= 0">Lotteriet har begynt!</h2> <h2 v-if="twoMinutesLeft || tenMinutesOver">Lotteriet er i gang!</h2>
</div> </div>
</div> </div>
</router-link> </router-link>
@@ -35,6 +34,20 @@ export default {
mounted() { mounted() {
this.initialize(), this.countdown(); this.initialize(), this.countdown();
}, },
computed: {
fiveMinutesLeft: function() {
if (this.days == 0 && this.hours == 0 && this.minutes <= 2) {
return true;
}
return false;
},
tenMinutesOver: function() {
if (this.days == 6 && this.hours >= 23 && this.minutes >= 50) {
return true;
}
return false;
}
},
methods: { methods: {
pad: function(num) { pad: function(num) {
if (num < 10) { if (num < 10) {
@@ -90,8 +103,7 @@ export default {
this.days = 0; this.days = 0;
} }
if (this.distance < 0) { if (this.distance < 0) {
clearTimeout(this.interval); this.initialize();
return;
} }
this.interval = setTimeout(this.countdown, 500); this.interval = setTimeout(this.countdown, 500);
} }