Merge branch 'master' of github.com:KevinMidboe/vinlottis
This commit is contained in:
@@ -76,7 +76,7 @@
|
|||||||
<h3>Legg til lodd kjøpt</h3>
|
<h3>Legg til lodd kjøpt</h3>
|
||||||
<div class="colors">
|
<div class="colors">
|
||||||
<div
|
<div
|
||||||
v-for="color in lotteryColorBoxes"
|
v-for="color in lotteryColors"
|
||||||
:class="color.css + ' colors-box'"
|
:class="color.css + ' colors-box'"
|
||||||
:key="color"
|
:key="color"
|
||||||
>
|
>
|
||||||
@@ -171,10 +171,6 @@ export default {
|
|||||||
components: { TextToast, Wine, ScanToVinmonopolet },
|
components: { TextToast, Wine, ScanToVinmonopolet },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
red: null,
|
|
||||||
blue: null,
|
|
||||||
green: null,
|
|
||||||
yellow: null,
|
|
||||||
payed: undefined,
|
payed: undefined,
|
||||||
winners: [],
|
winners: [],
|
||||||
wines: [],
|
wines: [],
|
||||||
@@ -184,6 +180,12 @@ export default {
|
|||||||
showToast: false,
|
showToast: false,
|
||||||
showCamera: false,
|
showCamera: false,
|
||||||
editWine: false,
|
editWine: false,
|
||||||
|
lotteryColors: [
|
||||||
|
{ value: null, name: "Blå", css: "blue" },
|
||||||
|
{ value: null, name: "Rød", css: "red" },
|
||||||
|
{ value: null, name: "Grønn", css: "green" },
|
||||||
|
{ value: null, name: "Gul", css: "yellow" }
|
||||||
|
],
|
||||||
price: __PRICE__
|
price: __PRICE__
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -195,16 +197,6 @@ export default {
|
|||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.setWinnerdataToStorage();
|
this.setWinnerdataToStorage();
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
lotteryColorBoxes() {
|
|
||||||
return [
|
|
||||||
{ value: this.blue, name: "Blå", css: "blue" },
|
|
||||||
{ value: this.red, name: "Rød", css: "red" },
|
|
||||||
{ value: this.green, name: "Grønn", css: "green" },
|
|
||||||
{ value: this.yellow, name: "Gul", css: "yellow" }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
amIBeingEdited(wine) {
|
amIBeingEdited(wine) {
|
||||||
return this.editWine.id == wine.id && this.editWine.name == wine.name;
|
return this.editWine.id == wine.id && this.editWine.name == wine.name;
|
||||||
@@ -285,13 +277,17 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
sendInfo: async function(event) {
|
sendInfo: async function(event) {
|
||||||
|
const colors = {
|
||||||
|
red: this.lotteryColors.filter(c => c.css == "red")[0].value,
|
||||||
|
green: this.lotteryColors.filter(c => c.css == "green")[0].value,
|
||||||
|
blue: this.lotteryColors.filter(c => c.css == "blue")[0].value,
|
||||||
|
yellow: this.lotteryColors.filter(c => c.css == "yellow")[0].value
|
||||||
|
}
|
||||||
|
|
||||||
let sendObject = {
|
let sendObject = {
|
||||||
purchase: {
|
purchase: {
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
blue: this.blue,
|
...colors
|
||||||
red: this.red,
|
|
||||||
yellow: this.yellow,
|
|
||||||
green: this.green
|
|
||||||
},
|
},
|
||||||
winners: this.winners
|
winners: this.winners
|
||||||
};
|
};
|
||||||
@@ -314,10 +310,10 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendObject.purchase.bought =
|
sendObject.purchase.bought =
|
||||||
parseInt(this.blue) +
|
parseInt(colors.blue) +
|
||||||
parseInt(this.red) +
|
parseInt(colors.red) +
|
||||||
parseInt(this.green) +
|
parseInt(colors.green) +
|
||||||
parseInt(this.yellow);
|
parseInt(colors.yellow);
|
||||||
const stolen = sendObject.purchase.bought - parseInt(this.payed) / 10;
|
const stolen = sendObject.purchase.bought - parseInt(this.payed) / 10;
|
||||||
if (isNaN(stolen) || stolen == undefined) {
|
if (isNaN(stolen) || stolen == undefined) {
|
||||||
alert("Betalt må registreres");
|
alert("Betalt må registreres");
|
||||||
@@ -374,7 +370,7 @@ export default {
|
|||||||
let localColors = localStorage.getItem("colorValues");
|
let localColors = localStorage.getItem("colorValues");
|
||||||
if (localColors) {
|
if (localColors) {
|
||||||
localColors = localColors.split(",");
|
localColors = localColors.split(",");
|
||||||
this.lotteryColorBoxes.forEach((color, i) => {
|
this.lotteryColors.forEach((color, i) => {
|
||||||
const localColorValue = Number(localColors[i]);
|
const localColorValue = Number(localColors[i]);
|
||||||
color.value = localColorValue == 0 ? null : localColorValue;
|
color.value = localColorValue == 0 ? null : localColorValue;
|
||||||
});
|
});
|
||||||
@@ -385,14 +381,14 @@ export default {
|
|||||||
localStorage.setItem("winners", JSON.stringify(this.winners));
|
localStorage.setItem("winners", JSON.stringify(this.winners));
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"colorValues",
|
"colorValues",
|
||||||
this.lotteryColorBoxes.map(color => Number(color.value))
|
this.lotteryColors.map(color => Number(color.value))
|
||||||
);
|
);
|
||||||
window.removeEventListener("unload", this.setWinnerdataToStorage);
|
window.removeEventListener("unload", this.setWinnerdataToStorage);
|
||||||
},
|
},
|
||||||
resetWinnerDataInStorage() {
|
resetWinnerDataInStorage() {
|
||||||
this.winners = [];
|
this.winners = [];
|
||||||
this.fetchAndAddPrelotteryWines().then(resp => (this.winners = resp));
|
this.fetchAndAddPrelotteryWines().then(resp => (this.winners = resp));
|
||||||
this.lotteryColorBoxes.map(color => (color.value = null));
|
this.lotteryColors.map(color => (color.value = null));
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import Banner from "@/ui/Banner";
|
|||||||
import Wines from "@/ui/Wines";
|
import Wines from "@/ui/Wines";
|
||||||
import Vipps from "@/ui/Vipps";
|
import Vipps from "@/ui/Vipps";
|
||||||
import Countdown from "@/ui/Countdown";
|
import Countdown from "@/ui/Countdown";
|
||||||
|
import { prelottery } from "@/api";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -67,7 +68,6 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
hardStart: false,
|
hardStart: false,
|
||||||
todayExists: false,
|
|
||||||
pushAllowed: false
|
pushAllowed: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -81,21 +81,17 @@ export default {
|
|||||||
!this.pushAllowed ||
|
!this.pushAllowed ||
|
||||||
localStorage.getItem("push") == null
|
localStorage.getItem("push") == null
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
todayExists: () => {
|
||||||
|
return prelottery()
|
||||||
|
.then(wines => wines.length > 0)
|
||||||
|
.catch(() => false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$on("push-allowed", () => {
|
this.$on("push-allowed", () => {
|
||||||
this.pushAllowed = true;
|
this.pushAllowed = true;
|
||||||
});
|
});
|
||||||
fetch("/api/wines/prelottery")
|
|
||||||
.then(wines => wines.json())
|
|
||||||
.then(wines => {
|
|
||||||
if (wines.length > 0) {
|
|
||||||
this.todayExists = true;
|
|
||||||
} else {
|
|
||||||
this.todayExists = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (window.location.hostname == "localhost") {
|
if (window.location.hostname == "localhost") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,27 @@
|
|||||||
<h2>Send vipps med melding "Vinlotteri" for å bli registrert til virtuelt lotteri</h2>
|
<h2>Send vipps med melding "Vinlotteri" for å bli registrert til virtuelt lotteri</h2>
|
||||||
<p>Send gjerne melding om fargeønsker også</p>
|
<p>Send gjerne melding om fargeønsker også</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<router-link to="/dagens" class="generate-link" v-if="todayExists">
|
||||||
|
Lurer du på dagens fangst?
|
||||||
|
<span class="subtext generator-link">Se her</span>
|
||||||
|
</router-link>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2>Live oversikt av lodd kjøp i dag</h2>
|
||||||
|
<div class="colors">
|
||||||
|
<div
|
||||||
|
v-for="color in Object.keys(ticketsBought)"
|
||||||
|
:class="color + ' colors-box'"
|
||||||
|
:key="color"
|
||||||
|
>
|
||||||
|
<div class="colors-overlay">
|
||||||
|
<p>{{ ticketsBought[color] }} kjøpt</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<WinnerDraw
|
<WinnerDraw
|
||||||
:currentWinnerDrawn="currentWinnerDrawn"
|
:currentWinnerDrawn="currentWinnerDrawn"
|
||||||
:currentWinner="currentWinner"
|
:currentWinner="currentWinner"
|
||||||
@@ -39,7 +60,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { page, event } from "vue-analytics";
|
import { page, event } from "vue-analytics";
|
||||||
import { attendees, winners, getChatHistory } from "@/api";
|
import { attendees, winners, getChatHistory, prelottery } from "@/api";
|
||||||
import Chat from "@/ui/Chat";
|
import Chat from "@/ui/Chat";
|
||||||
import Vipps from "@/ui/Vipps";
|
import Vipps from "@/ui/Vipps";
|
||||||
import Attendees from "@/ui/Attendees";
|
import Attendees from "@/ui/Attendees";
|
||||||
@@ -62,7 +83,8 @@ export default {
|
|||||||
usernameAccepted: false,
|
usernameAccepted: false,
|
||||||
username: null,
|
username: null,
|
||||||
wasDisconnected: false,
|
wasDisconnected: false,
|
||||||
emitUsernameOnConnect: false
|
emitUsernameOnConnect: false,
|
||||||
|
ticketsBought: {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@@ -124,6 +146,13 @@ export default {
|
|||||||
this.socket.disconnect();
|
this.socket.disconnect();
|
||||||
this.socket = null;
|
this.socket = null;
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
todayExists: () => {
|
||||||
|
return prelottery()
|
||||||
|
.then(wines => wines.length > 0)
|
||||||
|
.catch(() => false)
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setUsername: function(username) {
|
setUsername: function(username) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
@@ -147,6 +176,14 @@ export default {
|
|||||||
let response = await attendees();
|
let response = await attendees();
|
||||||
if (response) {
|
if (response) {
|
||||||
this.attendees = response;
|
this.attendees = response;
|
||||||
|
const addValueOfListObjectByKey = (list, key) => list.map(object => object[key]).reduce((a, b) => a + b);
|
||||||
|
|
||||||
|
this.ticketsBought = {
|
||||||
|
red: addValueOfListObjectByKey(response, "red"),
|
||||||
|
blue: addValueOfListObjectByKey(response, "blue"),
|
||||||
|
green: addValueOfListObjectByKey(response, "green"),
|
||||||
|
yellow: addValueOfListObjectByKey(response, "yellow"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.attendeesFetched = true;
|
this.attendeesFetched = true;
|
||||||
},
|
},
|
||||||
@@ -157,6 +194,183 @@ export default {
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- TODO move link styling to global with more generic name -->
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import "../styles/global.scss";
|
||||||
|
@import "../styles/variables.scss";
|
||||||
|
@import "../styles/media-queries.scss";
|
||||||
|
.generate-link {
|
||||||
|
color: #333333;
|
||||||
|
text-decoration: none;
|
||||||
|
display: block;
|
||||||
|
width: 100vw;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
|
||||||
|
@include mobile {
|
||||||
|
width: 60vw;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.vipps-image {
|
||||||
|
width: 250px;
|
||||||
|
margin: auto;
|
||||||
|
display: block;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.generator-link {
|
||||||
|
font-weight: bold;
|
||||||
|
border-bottom: 1px solid #ff5fff;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import "../styles/global.scss";
|
||||||
|
@import "../styles/variables.scss";
|
||||||
|
@import "../styles/media-queries.scss";
|
||||||
|
.color-selector {
|
||||||
|
margin-bottom: 0.65rem;
|
||||||
|
margin-right: 1rem;
|
||||||
|
|
||||||
|
@include desktop {
|
||||||
|
min-width: 175px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@include mobile {
|
||||||
|
max-width: 25vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.active {
|
||||||
|
border: 2px solid unset;
|
||||||
|
|
||||||
|
&.green {
|
||||||
|
border-color: $green;
|
||||||
|
}
|
||||||
|
&.blue {
|
||||||
|
border-color: $dark-blue;
|
||||||
|
}
|
||||||
|
&.red {
|
||||||
|
border-color: $red;
|
||||||
|
}
|
||||||
|
&.yellow {
|
||||||
|
border-color: $dark-yellow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
border: 2px solid transparent;
|
||||||
|
display: inline-flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
flex-direction: row;
|
||||||
|
height: 2.5rem;
|
||||||
|
width: 2.5rem;
|
||||||
|
|
||||||
|
// disable-dbl-tap-zoom
|
||||||
|
touch-action: manipulation;
|
||||||
|
|
||||||
|
@include mobile {
|
||||||
|
margin: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.green {
|
||||||
|
background: #c8f9df;
|
||||||
|
}
|
||||||
|
&.blue {
|
||||||
|
background: #d4f2fe;
|
||||||
|
}
|
||||||
|
&.red {
|
||||||
|
background: #fbd7de;
|
||||||
|
}
|
||||||
|
&.yellow {
|
||||||
|
background: #fff6d6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.colors {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
max-width: 1400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
|
||||||
|
@include mobile {
|
||||||
|
margin: 1.8rem auto 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-div {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.colors-box {
|
||||||
|
width: 150px;
|
||||||
|
height: 150px;
|
||||||
|
margin: 20px;
|
||||||
|
-webkit-mask-image: url(/../../public/assets/images/lodd.svg);
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
mask-image: url(/../../public/assets/images/lodd.svg);
|
||||||
|
-webkit-mask-repeat: no-repeat;
|
||||||
|
mask-repeat: no-repeat;
|
||||||
|
|
||||||
|
@include mobile {
|
||||||
|
width: 120px;
|
||||||
|
height: 120px;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.colors-overlay {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0 0.25rem;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
p {
|
||||||
|
width: 70%;
|
||||||
|
border: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
height: unset;
|
||||||
|
max-height: unset;
|
||||||
|
|
||||||
|
@include mobile {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.green,
|
||||||
|
.green .colors-overlay > input {
|
||||||
|
background-color: $light-green;
|
||||||
|
color: $green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blue,
|
||||||
|
.blue .colors-overlay > input {
|
||||||
|
background-color: $light-blue;
|
||||||
|
color: $blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yellow,
|
||||||
|
.yellow .colors-overlay > input {
|
||||||
|
background-color: $light-yellow;
|
||||||
|
color: $yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
.red,
|
||||||
|
.red .colors-overlay > input {
|
||||||
|
background-color: $light-red;
|
||||||
|
color: $red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "../styles/global.scss";
|
@import "../styles/global.scss";
|
||||||
@import "../styles/variables.scss";
|
@import "../styles/variables.scss";
|
||||||
|
|||||||
@@ -74,13 +74,15 @@ body {
|
|||||||
margin-right: 2rem;
|
margin-right: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@include mobile &:not(.row) {
|
@include mobile {
|
||||||
flex-direction: column;
|
&:not(.row) {
|
||||||
align-items: center;
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
> *:not(:last-child) {
|
> *:not(:last-child) {
|
||||||
margin-right: unset;
|
margin-right: unset;
|
||||||
margin-bottom: .75rem;
|
margin-bottom: .75rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="attendees" v-if="attendees.length > 0">
|
<div class="attendees" v-if="attendees.length > 0">
|
||||||
<h2>Deltakere ({{ attendees.length }})</h2>
|
<h2>Deltakere ({{ attendees.length }})</h2>
|
||||||
<div class="attendees-container" ref="attendees">
|
<div class="attendees-container" ref="attendees">
|
||||||
<div class="attendee" v-for="(attendee, index) in attendees" :key="index">
|
<div class="attendee" v-for="(attendee, index) in flipList(attendees)" :key="index">
|
||||||
<span class="attendee-name">{{ attendee.name }}</span>
|
<span class="attendee-name">{{ attendee.name }}</span>
|
||||||
<div class="red-ballot ballot-element small">{{ attendee.red }}</div>
|
<div class="red-ballot ballot-element small">{{ attendee.red }}</div>
|
||||||
<div class="blue-ballot ballot-element small">{{ attendee.blue }}</div>
|
<div class="blue-ballot ballot-element small">{{ attendee.blue }}</div>
|
||||||
@@ -20,13 +20,18 @@ export default {
|
|||||||
type: Array
|
type: Array
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
flipList: (list) => list.slice().reverse()
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
attendees: {
|
attendees: {
|
||||||
deep: true,
|
deep: true,
|
||||||
handler() {
|
handler() {
|
||||||
setTimeout(() => {
|
if (this.$refs && this.$refs.history) {
|
||||||
this.$refs.attendees.scrollTop = this.$refs.attendees.scrollHeight;
|
setTimeout(() => {
|
||||||
}, 50);
|
this.$refs.attendees.scrollTop = this.$refs.attendees.scrollHeight;
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,9 +53,11 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
chatHistory: {
|
chatHistory: {
|
||||||
handler() {
|
handler() {
|
||||||
setTimeout(() => {
|
if (this.$refs && this.$refs.history) {
|
||||||
this.$refs.history.scrollTop = this.$refs.history.scrollHeight;
|
setTimeout(() => {
|
||||||
}, 10);
|
this.$refs.history.scrollTop = this.$refs.history.scrollHeight;
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user