Socket-things

This commit is contained in:
Kasper Rynning-Tønnesen
2020-03-16 09:39:46 +01:00
parent 3055ea6ecc
commit 18b6e3a941
5 changed files with 26 additions and 5 deletions

View File

@@ -133,6 +133,7 @@
</template> </template>
<script> <script>
import io from "socket.io-client";
import { import {
addAttendee, addAttendee,
getVirtualWinner, getVirtualWinner,
@@ -160,12 +161,29 @@ export default {
secondsLeft: 20, secondsLeft: 20,
drawTime: 20, drawTime: 20,
currentWinners: 1, currentWinners: 1,
numberOfWinners: 4 numberOfWinners: 4,
socket: null
}; };
}, },
mounted() { mounted() {
this.getAttendees(); this.getAttendees();
this.getWinners(); this.getWinners();
this.socket = io(`${window.location.hostname}:${window.location.port}`);
this.socket.on("winner", async msg => {
this.getWinners();
this.getAttendees();
});
this.socket.on("refresh_data", async msg => {
this.getAttendees();
this.getWinners();
});
this.socket.on("new_attendee", async msg => {
this.getAttendees();
});
}, },
methods: { methods: {
sendAttendee: async function() { sendAttendee: async function() {

View File

@@ -4,12 +4,10 @@ import TodaysPage from "@/components/TodaysPage";
import AllWinesPage from "@/components/AllWinesPage"; import AllWinesPage from "@/components/AllWinesPage";
import LoginPage from "@/components/LoginPage"; import LoginPage from "@/components/LoginPage";
import RegisterPage from "@/components/RegisterPage";
import CreatePage from "@/components/CreatePage"; import CreatePage from "@/components/CreatePage";
import AdminPage from "@/components/AdminPage"; import AdminPage from "@/components/AdminPage";
import VirtualLotteryRegistrationPage from "@/components/VirtualLotteryRegistrationPage";
import VirtualLotteryPage from "@/components/VirtualLotteryPage"; import VirtualLotteryPage from "@/components/VirtualLotteryPage";
const routes = [ const routes = [

View File

@@ -43,6 +43,8 @@ export default {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
font-weight: bold; font-weight: bold;
font-size: 0.75rem;
text-align: center;
} }
.attendees { .attendees {

View File

@@ -18,7 +18,7 @@
@keyup.enter="sendMessage" @keyup.enter="sendMessage"
type="text" type="text"
v-model="message" v-model="message"
maxlength="30" placeholder="Melding.."
/> />
<button @click="sendMessage">Send</button <button @click="sendMessage">Send</button
><button @click="removeUsername">Logg ut</button> ><button @click="removeUsername">Logg ut</button>
@@ -29,7 +29,8 @@
type="text" type="text"
@keyup.enter="setUsername" @keyup.enter="setUsername"
v-model="temporaryUsername" v-model="temporaryUsername"
title maxlength="30"
placeholder="Ditt navn.."
/> />
<button @click="setUsername">Lagre brukernavn</button> <button @click="setUsername">Lagre brukernavn</button>
</div> </div>

View File

@@ -174,5 +174,7 @@ h2 {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
font-size: 0.75rem;
text-align: center;
} }
</style> </style>