diff --git a/api/virtualLottery.js b/api/virtualLottery.js index cad4924..706016b 100644 --- a/api/virtualLottery.js +++ b/api/virtualLottery.js @@ -166,8 +166,16 @@ const drawWinner = async (req, res) => { Math.floor(Math.random() * attendeeListDemocratic.length) ]; + let winners = await VirtualWinner.find({ timestamp_sent: undefined }).sort({ + timestamp_drawn: 1 + }); + var io = req.app.get('socketio'); - io.emit("winner", { color: colorToChooseFrom, name: winner.name }); + io.emit("winner", { + color: colorToChooseFrom, + name: winner.name, + winner_count: winners.length + 1 + }); let newWinnerElement = new VirtualWinner({ name: winner.name, diff --git a/frontend/components/VinlottisPage.vue b/frontend/components/VinlottisPage.vue index df44ad0..bbc0719 100644 --- a/frontend/components/VinlottisPage.vue +++ b/frontend/components/VinlottisPage.vue @@ -17,12 +17,12 @@ /> - +

Trykk her for å delta

- + Se vipps detaljer og QR-kode diff --git a/frontend/components/VirtualLotteryPage.vue b/frontend/components/VirtualLotteryPage.vue index e6d1065..cf7d67e 100644 --- a/frontend/components/VirtualLotteryPage.vue +++ b/frontend/components/VirtualLotteryPage.vue @@ -1,48 +1,60 @@ @@ -50,22 +62,24 @@ import { attendees, winners, prelottery } from "@/api"; import Chat from "@/ui/Chat"; import Vipps from "@/ui/Vipps"; +import VippsPill from "@/ui/VippsPill"; import Attendees from "@/ui/Attendees"; +import Wine from "@/ui/Wine"; import Winners from "@/ui/Winners"; import WinnerDraw from "@/ui/WinnerDraw"; import io from "socket.io-client"; export default { - components: { Chat, Attendees, Winners, WinnerDraw, Vipps }, + components: { Chat, Attendees, Winners, WinnerDraw, Vipps, VippsPill, Wine }, data() { return { attendees: [], winners: [], + wines: [], currentWinnerDrawn: false, - currentWinner: {}, + currentWinner: null, socket: null, attendeesFetched: false, - winnersFetched: false, wasDisconnected: false, ticketsBought: {} }; @@ -73,6 +87,7 @@ export default { mounted() { this.track(); this.getAttendees(); + this.getTodaysWines(); this.getWinners(); this.socket = io(window.location.origin); this.socket.on("color_winner", msg => {}); @@ -83,14 +98,18 @@ export default { this.socket.on("winner", async msg => { this.currentWinnerDrawn = true; - this.currentWinner = { name: msg.name, color: msg.color }; + this.currentWinner = { + name: msg.name, + color: msg.color, + winnerCount: msg.winner_count + }; setTimeout(() => { this.getWinners(); this.getAttendees(); this.currentWinner = null; this.currentWinnerDrawn = false; - }, 12000); + }, 19250); }); this.socket.on("refresh_data", async msg => { this.getAttendees(); @@ -104,20 +123,20 @@ export default { this.socket.disconnect(); this.socket = null; }, - computed: { - todayExists: () => { - return prelottery() - .then(wines => wines.length > 0) - .catch(() => false); - } - }, methods: { getWinners: async function() { let response = await winners(); if (response) { this.winners = response; } - this.winnersFetched = true; + }, + getTodaysWines() { + prelottery() + .then(wines => { + this.wines = wines; + this.todayExists = wines.length > 0; + }) + .catch(_ => this.todayExists = false) }, getAttendees: async function() { let response = await attendees(); @@ -139,6 +158,20 @@ export default { } this.attendeesFetched = true; }, + scrollToContent() { + console.log(window.scrollY) + const intersectingHeaderHeight = this.$refs.header.getBoundingClientRect().bottom - 50; + const { scrollY } = window; + let scrollHeight = intersectingHeaderHeight; + if (scrollY > 0) { + scrollHeight = intersectingHeaderHeight + scrollY; + } + + window.scrollTo({ + top: scrollHeight, + behavior: "smooth" + }); + }, track() { window.ga('send', 'pageview', '/lottery/game'); } @@ -146,241 +179,197 @@ export default { }; - - - - - diff --git a/frontend/router.js b/frontend/router.js index e625e41..beaa308 100644 --- a/frontend/router.js +++ b/frontend/router.js @@ -1,9 +1,9 @@ const VinlottisPage = () => import( /* webpackChunkName: "landing-page" */ "@/components/VinlottisPage"); -const LotteryPage = () => import( +const VirtualLotteryPage = () => import( /* webpackChunkName: "landing-page" */ - "@/components/LotteryPage"); + "@/components/VirtualLotteryPage"); const GeneratePage = () => import( /* webpackChunkName: "landing-page" */ "@/components/GeneratePage"); @@ -54,7 +54,7 @@ const routes = [ { path: "/lottery", name: "Lotteri", - component: LotteryPage + component: VirtualLotteryPage }, { path: "/dagens", @@ -82,8 +82,8 @@ const routes = [ component: AdminPage }, { - path: "/lottery/:tab", - component: LotteryPage + path: "/generate/", + component: GeneratePage }, { path: "/winner/:id", diff --git a/frontend/styles/global.scss b/frontend/styles/global.scss index c6b8f4f..5f64ca6 100644 --- a/frontend/styles/global.scss +++ b/frontend/styles/global.scss @@ -112,10 +112,9 @@ textarea { .vin-button { font-family: Arial; - $color: #b7debd; position: relative; display: inline-block; - background: $color; + background: $primary; color: #333; padding: 10px 30px; margin: 0; @@ -188,7 +187,7 @@ textarea { .vin-link { font-weight: bold; border-bottom: 1px solid $link-color; - font-size: 1rem; + font-size: inherit; cursor: pointer; text-decoration: none; diff --git a/frontend/styles/media-queries.scss b/frontend/styles/media-queries.scss index 8108453..1cf3261 100644 --- a/frontend/styles/media-queries.scss +++ b/frontend/styles/media-queries.scss @@ -25,4 +25,16 @@ $desktop-max: 2004px; @media (min-width: #{$desktop-max + 1px}){ @content; } +} + +.desktop-only { + @include mobile { + display: none; + } +} + +.mobile-only { + @include tablet { + display: none; + } } \ No newline at end of file diff --git a/frontend/ui/Attendees.vue b/frontend/ui/Attendees.vue index 92f4a64..adcb75d 100644 --- a/frontend/ui/Attendees.vue +++ b/frontend/ui/Attendees.vue @@ -1,6 +1,5 @@