From 09f0436f986639f8e4e79f24376730679ae57431 Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Thu, 27 Aug 2020 13:25:44 +0200
Subject: [PATCH 01/32] add search functionality
---
api/vinmonopolet.js | 0
api/wineinfo.js | 46 ++++++++++++++++++++++++++++++++++
src/api.js | 16 ++++++++++++
src/components/RequestWine.vue | 44 ++++++++++++++++++++++++++++++++
src/routes/vinlottisRouter.js | 6 +++++
5 files changed, 112 insertions(+)
create mode 100644 api/vinmonopolet.js
create mode 100644 src/components/RequestWine.vue
diff --git a/api/vinmonopolet.js b/api/vinmonopolet.js
new file mode 100644
index 0000000..e69de29
diff --git a/api/wineinfo.js b/api/wineinfo.js
index 237de19..8c444dd 100644
--- a/api/wineinfo.js
+++ b/api/wineinfo.js
@@ -9,6 +9,52 @@ router.use((req, res, next) => {
next();
});
+const convertToOurWineObject = wine => {
+ console.log("traff her", wine)
+ return {
+ name: wine.basic.productShortName,
+ image: `https://bilder.vinmonopolet.no/cache/300x300-0/${wine.basic.productId}-1.jpg`,
+ rating: undefined,
+ price: wine.prices[0].salesPrice,
+ country: wine.origins.origin.country,
+ vivinoLink: undefined
+ }
+}
+
+router.route("/wineinfo/search").get(async (req, res) => {
+ console.log("h")
+ console.log(req)
+ const {query} = req.query
+ let url = new URL(`https://apis.vinmonopolet.no/products/v0/details-normal?productShortNameContains=test&maxResults=5`)
+ url.searchParams.set('productShortNameContains', query)
+
+ const vinmonopoletResponse = await fetch(url, {
+ headers: {
+ "Ocp-Apim-Subscription-Key": ""
+ }
+ })
+ .then(resp => resp.json())
+
+ const winesConverted = vinmonopoletResponse.map(convertToOurWineObject)
+ console.log(winesConverted)
+
+ if (vinmonopoletResponse.errors != null) {
+ return vinmonopoletResponse.errors.map(error => {
+ if (error.type == "UnknownProductError") {
+ return res.status(404).json({
+ message: error.message
+ })
+ } else {
+ return next()
+ }
+ })
+ }
+
+ res.send(winesConverted);
+});
+
+
+
router.route("/wineinfo/:ean").get(async (req, res) => {
const vinmonopoletResponse = await fetch("https://app.vinmonopolet.no/vmpws/v2/vmp/products/barCodeSearch/" + req.params.ean)
.then(resp => resp.json())
diff --git a/src/api.js b/src/api.js
index eb6d3c2..395de2d 100644
--- a/src/api.js
+++ b/src/api.js
@@ -160,6 +160,21 @@ const barcodeToVinmonopolet = id => {
});
};
+const searchForWine = searchString => {
+ const url = new URL("/api/wineinfo/search?query=" + searchString, BASE_URL);
+
+ return fetch(url.href).then(async resp => {
+ if (!resp.ok) {
+ if (resp.status == 404) {
+ throw await resp.json();
+ }
+ } else {
+ return resp.json();
+ }
+ });
+};
+
+
const handleErrors = async resp => {
if ([400, 409].includes(resp.status)) {
throw await resp.json();
@@ -269,6 +284,7 @@ export {
logWines,
wineSchema,
barcodeToVinmonopolet,
+ searchForWine,
login,
register,
addAttendee,
diff --git a/src/components/RequestWine.vue b/src/components/RequestWine.vue
new file mode 100644
index 0000000..b1af2f3
--- /dev/null
+++ b/src/components/RequestWine.vue
@@ -0,0 +1,44 @@
+
+
+
+ Anbefal en vin!
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/routes/vinlottisRouter.js b/src/routes/vinlottisRouter.js
index 32ae017..9a2e9cf 100644
--- a/src/routes/vinlottisRouter.js
+++ b/src/routes/vinlottisRouter.js
@@ -12,6 +12,8 @@ import WinnerPage from "@/components/WinnerPage";
import LotteryPage from "@/components/LotteryPage";
import HistoryPage from "@/components/HistoryPage";
+import RequestWine from "@/components/RequestWine";
+
const routes = [
{
path: "*",
@@ -52,6 +54,10 @@ const routes = [
{
path: "/history",
component: HistoryPage
+ },
+ {
+ path: "/request",
+ component: RequestWine
}
];
From 15b84a9b18c3c90e20341e12a81771f8256ddaba Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Thu, 27 Aug 2020 15:15:43 +0200
Subject: [PATCH 02/32] add token and some styling
---
.gitignore | 1 +
api/wineinfo.js | 25 ++++++------
src/components/RequestWine.vue | 72 ++++++++++++++++++++++++++++++----
3 files changed, 77 insertions(+), 21 deletions(-)
diff --git a/.gitignore b/.gitignore
index 86fe51d..2a2c678 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@ public/index.html
public/sw/
config/env/lottery.config.js
config/env/push.config.js
+config/env/vinmonopolet.config.js
# Logs
logs
diff --git a/api/wineinfo.js b/api/wineinfo.js
index 8c444dd..1b4c7ff 100644
--- a/api/wineinfo.js
+++ b/api/wineinfo.js
@@ -2,6 +2,7 @@ const express = require("express");
const path = require("path");
const router = express.Router();
const fetch = require('node-fetch')
+const config = require(path.join(__dirname + "/../config/env/vinmonopolet.config"));
const mustBeAuthenticated = require(path.join(__dirname + "/../middleware/mustBeAuthenticated"))
@@ -10,33 +11,31 @@ router.use((req, res, next) => {
});
const convertToOurWineObject = wine => {
- console.log("traff her", wine)
- return {
- name: wine.basic.productShortName,
- image: `https://bilder.vinmonopolet.no/cache/300x300-0/${wine.basic.productId}-1.jpg`,
- rating: undefined,
- price: wine.prices[0].salesPrice,
- country: wine.origins.origin.country,
- vivinoLink: undefined
+ if(wine.basic.ageLimit === "18"){
+ return {
+ name: wine.basic.productShortName,
+ image: `https://bilder.vinmonopolet.no/cache/300x300-0/${wine.basic.productId}-1.jpg`,
+ rating: undefined,
+ price: wine.prices[0].salesPrice,
+ country: wine.origins.origin.country,
+ vivinoLink: undefined
+ }
}
}
router.route("/wineinfo/search").get(async (req, res) => {
- console.log("h")
- console.log(req)
const {query} = req.query
let url = new URL(`https://apis.vinmonopolet.no/products/v0/details-normal?productShortNameContains=test&maxResults=5`)
url.searchParams.set('productShortNameContains', query)
const vinmonopoletResponse = await fetch(url, {
headers: {
- "Ocp-Apim-Subscription-Key": ""
+ "Ocp-Apim-Subscription-Key": `${config.gatewayToken}`
}
})
.then(resp => resp.json())
- const winesConverted = vinmonopoletResponse.map(convertToOurWineObject)
- console.log(winesConverted)
+ const winesConverted = vinmonopoletResponse.map(convertToOurWineObject).filter(Boolean)
if (vinmonopoletResponse.errors != null) {
return vinmonopoletResponse.errors.map(error => {
diff --git a/src/components/RequestWine.vue b/src/components/RequestWine.vue
index b1af2f3..d02c6f0 100644
--- a/src/components/RequestWine.vue
+++ b/src/components/RequestWine.vue
@@ -1,16 +1,30 @@
- Anbefal en vin!
+ Foreslå en vin!
@@ -39,6 +53,48 @@ export default {
}
-
\ No newline at end of file
From f785a111d852244a0d199baf1e0fd7950a941d76 Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Thu, 27 Aug 2020 16:50:04 +0200
Subject: [PATCH 03/32] cleanup
---
api/wineinfo.js | 4 +-
src/components/RequestWine.vue | 93 +++++++++++++++++++++++++---------
src/styles/global.scss | 6 ++-
3 files changed, 75 insertions(+), 28 deletions(-)
diff --git a/api/wineinfo.js b/api/wineinfo.js
index 1b4c7ff..37afbf2 100644
--- a/api/wineinfo.js
+++ b/api/wineinfo.js
@@ -15,10 +15,10 @@ const convertToOurWineObject = wine => {
return {
name: wine.basic.productShortName,
image: `https://bilder.vinmonopolet.no/cache/300x300-0/${wine.basic.productId}-1.jpg`,
- rating: undefined,
+ rating: wine.basic.alcoholContent,
price: wine.prices[0].salesPrice,
country: wine.origins.origin.country,
- vivinoLink: undefined
+ vivinoLink: "https://www.vinmonopolet.no/p/" + wine.basic.productId
}
}
}
diff --git a/src/components/RequestWine.vue b/src/components/RequestWine.vue
index d02c6f0..75a189a 100644
--- a/src/components/RequestWine.vue
+++ b/src/components/RequestWine.vue
@@ -4,8 +4,10 @@
Foreslå en vin!
+
+ Fant ingen viner med det navnet!
+
@@ -40,14 +52,15 @@ export default {
data() {
return {
searchString: undefined,
- res: undefined,
wines: undefined,
}
},
methods: {
fetchWineFromVin(){
- searchForWine(this.searchString)
- .then(res => this.wines = res)
+ if(this.searchString){
+ searchForWine(this.searchString)
+ .then(res => this.wines = res)
+ }
},
},
}
@@ -61,6 +74,7 @@ export default {
main{
margin: auto;
width: 80%;
+ text-align: center;
}
input[type="text"] {
@@ -69,32 +83,61 @@ input[type="text"] {
border-radius: 4px;
padding: 0.5rem 1rem;
border: 1px solid black;
- max-width: 200px;
+ max-width: 80%;
+}
+
+.search-section{
+ display: flex;
+ justify-content: space-around;
+ flex-flow: row;
}
.search-results-container{
display: flex;
- border: 1px solid black;
+ padding: 3px;
+ border-radius: 1px;
+ box-shadow: 0px 0px 0px 1px rgba(0,0,0,0.3);
+ margin: 1rem 0;
+ justify-content: space-around;
+ flex-flow: row wrap;
+ align-items: stretch;
+
+
+ .wine-image {
+ height: 100px;
+ }
+
+ .wine-placeholder {
+ height: 100px;
+ width: 70px;
+ }
+
+ .wine-info{
+ display: flex;
+ flex-direction: column;
+ .__details{
+ display: flex;
+ flex-direction: column;
+ }
+ }
+ .wine-link {
+ color: #333333;
+ font-family: Arial;
+ text-decoration: none;
+ font-weight: bold;
+ border-bottom: 1px solid #ff5fff;
+ width: fit-content;
+ }
.buttons{
- margin-left: auto;
+ display: flex;
+ align-items: center;
order: 2;
+ justify-content: space-between;
+ width: 40%;
+ margin-right: 1rem;
}
}
-.wine-image {
- height: 100px;
-}
-
-.wine-placeholder {
- height: 100px;
- width: 70px;
-}
-
-.wine-info{
- display: flex;
- flex-direction: column;
-}
-
\ No newline at end of file
diff --git a/src/styles/global.scss b/src/styles/global.scss
index 57e3251..cc89a83 100644
--- a/src/styles/global.scss
+++ b/src/styles/global.scss
@@ -133,13 +133,17 @@ textarea {
0 16px 32px rgba(0, 0, 0, 0.07), 0 32px 64px rgba(0, 0, 0, 0.07);
}
- &:hover {
+ &:hover:not(:disabled) {
transform: scale(1.02) translateZ(0);
&::after {
opacity: 1;
}
}
+ &:disabled{
+ opacity: 0.25;
+ cursor: not-allowed;
+ }
}
.no-margin {
From 7b7895728bdc835a3dd6c65d24f3343f986aea34 Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Fri, 28 Aug 2020 17:01:53 +0200
Subject: [PATCH 04/32] loko
---
api/request.js | 60 ++++++++++++++++++++++++++++++++++
api/wineinfo.js | 14 ++++----
server.js | 2 ++
src/components/RequestWine.vue | 22 +++++++++++--
4 files changed, 90 insertions(+), 8 deletions(-)
create mode 100644 api/request.js
diff --git a/api/request.js b/api/request.js
new file mode 100644
index 0000000..d2aca2b
--- /dev/null
+++ b/api/request.js
@@ -0,0 +1,60 @@
+const express = require("express");
+const path = require("path");
+const router = express.Router();
+const fetch = require('node-fetch');
+const { send } = require("process");
+const RequestedWine = require(path.join(
+ __dirname + "/../schemas/RequestedWine"
+));
+const Wine = require(path.join(
+ __dirname + "/../schemas/Wine"
+));
+
+router.use((req, res, next) => {
+ next();
+});
+
+
+router.route("/request").get(async (req, res) => {
+ const rWines = await RequestedWine.find({}).populate("wine")
+ return res.send(rWines)
+})
+
+router.route("/request").post(async (req, res) => {
+ const {wine} = req.body
+ console.log(wine)
+
+ let thisWineIsLOKO = await Wine.findOne({id: wine.id})
+
+ if(thisWineIsLOKO == undefined){
+ thisWineIsLOKO = new Wine({
+ name: wine.name,
+ vivinoLink: wine.vivinoLink,
+ rating: null,
+ occurences: null,
+ image: wine.image,
+ id: wine.id
+ });
+ await thisWineIsLOKO.save()
+ }
+ console.log(thisWineIsLOKO)
+
+ let requestedWine = await RequestedWine.findOne({ "wineId": wine.id})
+
+ if(requestedWine == undefined){
+ // console.log(localWine)
+ requestedWine = new RequestedWine({
+ count: 1,
+ wineId: wine.id,
+ wine: thisWineIsLOKO
+ })
+ } else {
+ requestedWine.count += 1;
+ }
+ await requestedWine.save()
+
+ res.send(requestedWine);
+
+});
+
+module.exports = router;
diff --git a/api/wineinfo.js b/api/wineinfo.js
index 37afbf2..053a68c 100644
--- a/api/wineinfo.js
+++ b/api/wineinfo.js
@@ -14,11 +14,13 @@ const convertToOurWineObject = wine => {
if(wine.basic.ageLimit === "18"){
return {
name: wine.basic.productShortName,
- image: `https://bilder.vinmonopolet.no/cache/300x300-0/${wine.basic.productId}-1.jpg`,
+ vivinoLink: "https://www.vinmonopolet.no/p/" + wine.basic.productId,
rating: wine.basic.alcoholContent,
- price: wine.prices[0].salesPrice,
- country: wine.origins.origin.country,
- vivinoLink: "https://www.vinmonopolet.no/p/" + wine.basic.productId
+ occurences: 0,
+ id: wine.basic.productId,
+ image: `https://bilder.vinmonopolet.no/cache/300x300-0/${wine.basic.productId}-1.jpg`,
+ price: wine.prices[0].salesPrice.toString(),
+ country: wine.origins.origin.country
}
}
}
@@ -34,8 +36,8 @@ router.route("/wineinfo/search").get(async (req, res) => {
}
})
.then(resp => resp.json())
+ .catch(err => console.error(err))
- const winesConverted = vinmonopoletResponse.map(convertToOurWineObject).filter(Boolean)
if (vinmonopoletResponse.errors != null) {
return vinmonopoletResponse.errors.map(error => {
@@ -48,7 +50,7 @@ router.route("/wineinfo/search").get(async (req, res) => {
}
})
}
-
+ const winesConverted = vinmonopoletResponse.map(convertToOurWineObject).filter(Boolean)
res.send(winesConverted);
});
diff --git a/server.js b/server.js
index e0fef6f..8cd45e2 100644
--- a/server.js
+++ b/server.js
@@ -11,6 +11,7 @@ const retrieveApi = require(path.join(__dirname + "/api/retrieve"));
const subscriptionApi = require(path.join(__dirname + "/api/subscriptions"));
const loginApi = require(path.join(__dirname + "/api/login"));
const wineinfoApi = require(path.join(__dirname + "/api/wineinfo"));
+const requestApi = require(path.join(__dirname + "/api/request"));
const virtualApi = require(path.join(__dirname + "/api/virtualLottery"));
const virtualRegistrationApi = require(path.join(
__dirname + "/api/virtualRegistration"
@@ -94,6 +95,7 @@ app.use("/", loginApi);
app.use("/api/", updateApi);
app.use("/api/", retrieveApi);
app.use("/api/", wineinfoApi);
+app.use("/api/", requestApi);
app.use("/api/", chatHistory);
app.use("/api/lottery", lottery);
app.use("/api/virtual/", virtualApi(io));
diff --git a/src/components/RequestWine.vue b/src/components/RequestWine.vue
index 75a189a..edc217c 100644
--- a/src/components/RequestWine.vue
+++ b/src/components/RequestWine.vue
@@ -26,7 +26,7 @@
+
+
From 1c9524485021f1924ac80aab77a0b8a012333457 Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Mon, 31 Aug 2020 16:45:19 +0200
Subject: [PATCH 11/32] interface on requested wines with sub-par css
---
src/components/AllRequestedWines.vue | 24 +++++++---
src/ui/Modal.vue | 1 +
src/ui/RequestedWineCard.vue | 72 ++++++++++++++++++++++++++++
3 files changed, 90 insertions(+), 7 deletions(-)
create mode 100644 src/ui/RequestedWineCard.vue
diff --git a/src/components/AllRequestedWines.vue b/src/components/AllRequestedWines.vue
index 8b84f61..cabfb87 100644
--- a/src/components/AllRequestedWines.vue
+++ b/src/components/AllRequestedWines.vue
@@ -1,30 +1,40 @@
- Alle viner
+ Alle viner foreslåtte viner
-
-
\ No newline at end of file
diff --git a/src/ui/Modal.vue b/src/ui/Modal.vue
index 6d44ca6..0d0e8f8 100644
--- a/src/ui/Modal.vue
+++ b/src/ui/Modal.vue
@@ -97,4 +97,5 @@ export default {
position: relative;
padding: 20px 10px;
}
+
\ No newline at end of file
diff --git a/src/ui/RequestedWineCard.vue b/src/ui/RequestedWineCard.vue
new file mode 100644
index 0000000..76b30fd
--- /dev/null
+++ b/src/ui/RequestedWineCard.vue
@@ -0,0 +1,72 @@
+
+
+
![]()
+
![Wine image]()
+
+ {{ wine.name }}
+ (no name)
+ Antall ganger denne har blitt foreslått: {{requestedElement.count}}
+
+
+
+
+
+
+
+
\ No newline at end of file
From a5ae46f5c39b5497b66302f0fcb4c3f0cc50ab8e Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Tue, 1 Sep 2020 10:17:17 +0200
Subject: [PATCH 12/32] working delete requested wine if admin
---
api/request.js | 7 +++++++
src/api.js | 16 ++++++++++++++++
src/components/AllRequestedWines.vue | 15 ++++++++++-----
src/ui/RequestedWineCard.vue | 16 +++++++++++++++-
4 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/api/request.js b/api/request.js
index 53511c9..d318beb 100644
--- a/api/request.js
+++ b/api/request.js
@@ -9,11 +9,18 @@ const RequestedWine = require(path.join(
const Wine = require(path.join(
__dirname + "/../schemas/Wine"
));
+const mustBeAuthenticated = require(path.join(
+ __dirname + "/../middleware/mustBeAuthenticated"
+));
router.use((req, res, next) => {
next();
});
+router.route("/request/").delete(mustBeAuthenticated, async (req, res) => {
+ await RequestedWine.deleteOne({wineId: req.body.id})
+ res.json(true);
+})
router.route("/request").get(async (req, res) => {
const rWines = await RequestedWine.find({}).populate("wine")
diff --git a/src/api.js b/src/api.js
index b549d22..1d5bb7f 100644
--- a/src/api.js
+++ b/src/api.js
@@ -100,6 +100,21 @@ const winners = () => {
return fetch(url.href).then(resp => resp.json());
};
+const deleteRequestedWine = wineToBeDeleted => {
+ console.log("when do i get here", wineToBeDeleted)
+ const url = new URL("api/request", BASE_URL);
+
+ const options = {
+ headers: {
+ "Content-Type": "application/json"
+ },
+ method: "DELETE",
+ body: JSON.stringify(wineToBeDeleted)
+ };
+
+ return fetch(url.href, options).then(resp => resp.json())
+}
+
const deleteWinners = () => {
const url = new URL("/api/virtual/winners", BASE_URL);
@@ -302,6 +317,7 @@ export {
winnersSecure,
deleteWinners,
deleteAttendees,
+ deleteRequestedWine,
getChatHistory,
finishedDraw,
getAmIWinner,
diff --git a/src/components/AllRequestedWines.vue b/src/components/AllRequestedWines.vue
index cabfb87..01033af 100644
--- a/src/components/AllRequestedWines.vue
+++ b/src/components/AllRequestedWines.vue
@@ -1,10 +1,10 @@
- Alle viner foreslåtte viner
+ Alle foreslåtte viner
@@ -22,9 +22,14 @@ export default {
canRequest: true
}
},
- async mounted() {
- const wines = await allRequestedWines();
- this.wines = wines
+ methods: {
+ async refreshData(){
+ const wines = await allRequestedWines()
+ this.wines = wines
+ }
+ },
+ mounted() {
+ this.refreshData()
}
}
diff --git a/src/ui/RequestedWineCard.vue b/src/ui/RequestedWineCard.vue
index 76b30fd..3c85be0 100644
--- a/src/ui/RequestedWineCard.vue
+++ b/src/ui/RequestedWineCard.vue
@@ -19,11 +19,16 @@
class="wine-link"
>Les mer på polet
+
From c38f5c88195c51572973e00172997afb74fcf1a8 Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Tue, 1 Sep 2020 10:44:54 +0200
Subject: [PATCH 13/32] some cleaning and empty wine list check
---
src/api.js | 2 +-
src/components/AllRequestedWines.vue | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/api.js b/src/api.js
index 1d5bb7f..f08e3ed 100644
--- a/src/api.js
+++ b/src/api.js
@@ -101,7 +101,7 @@ const winners = () => {
};
const deleteRequestedWine = wineToBeDeleted => {
- console.log("when do i get here", wineToBeDeleted)
+
const url = new URL("api/request", BASE_URL);
const options = {
diff --git a/src/components/AllRequestedWines.vue b/src/components/AllRequestedWines.vue
index 01033af..ffd8d6c 100644
--- a/src/components/AllRequestedWines.vue
+++ b/src/components/AllRequestedWines.vue
@@ -4,6 +4,7 @@
Alle foreslåtte viner
+ Ingen har foreslått noe enda!
@@ -35,6 +36,9 @@ export default {
From e481b6a812c9fa7491ae91f6d8201730ca8a12af Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Wed, 2 Sep 2020 12:52:45 +0200
Subject: [PATCH 18/32] reworked header to be one component scaling on css
properties
---
src/Vinlottis.vue | 35 +++++++---
src/styles/banner.scss | 147 ++++++++++++++++++++++++++++++++++++++++
src/ui/Banner.vue | 121 ++++++++++++++++++---------------
src/ui/MobileBanner.vue | 108 -----------------------------
4 files changed, 238 insertions(+), 173 deletions(-)
create mode 100644 src/styles/banner.scss
delete mode 100644 src/ui/MobileBanner.vue
diff --git a/src/Vinlottis.vue b/src/Vinlottis.vue
index af8aea7..4a5c4c1 100644
--- a/src/Vinlottis.vue
+++ b/src/Vinlottis.vue
@@ -1,7 +1,6 @@
-
-
+
@@ -84,8 +99,10 @@ body {
diff --git a/src/styles/banner.scss b/src/styles/banner.scss
new file mode 100644
index 0000000..5823376
--- /dev/null
+++ b/src/styles/banner.scss
@@ -0,0 +1,147 @@
+@import "./media-queries.scss";
+
+
+// https://codepen.io/erikterwan/pen/EVzeRP
+@include mobile{
+ #menuToggle
+ {
+ display: block;
+ position: relative;
+ margin: 7px;
+
+ z-index: 1;
+
+ -webkit-user-select: none;
+ user-select: none;
+ }
+
+ #menuToggle a
+ {
+ text-decoration: none;
+ color: #333333;
+
+ transition: color 0.3s ease;
+ }
+
+
+ #menuToggle input
+ {
+ display: block;
+ width: 40px;
+ height: 32px;
+ position: absolute;
+ top: -7px;
+ left: -5px;
+
+ cursor: pointer;
+
+ opacity: 0; /* hide this */
+ z-index: 2; /* and place it over the hamburger */
+
+ -webkit-touch-callout: none;
+ }
+
+ /*
+ * Just a quick hamburger
+ */
+ #menuToggle span
+ {
+ display: block;
+ width: 33px;
+ height: 4px;
+ margin-bottom: 5px;
+ position: relative;
+
+ background: #333333;
+ border-radius: 3px;
+
+ z-index: 1;
+
+ transform-origin: 4px 0px;
+
+ transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
+ background 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
+ opacity 0.55s ease;
+ }
+
+ #menuToggle span:first-child
+ {
+ transform-origin: 0% 0%;
+ }
+
+ #menuToggle span:nth-last-child(2)
+ {
+ transform-origin: 0% 100%;
+ }
+
+ /*
+ * Transform all the slices of hamburger
+ * into a crossmark.
+ */
+ #menuToggle input:checked ~ span
+ {
+ opacity: 1;
+ transform: rotate(45deg) translate(-2px, -1px);
+ background: #232323;
+ }
+
+ /*
+ * But let's hide the middle one.
+ */
+ #menuToggle input:checked ~ span:nth-last-child(3)
+ {
+ opacity: 0;
+ transform: rotate(0deg) scale(0.2, 0.2);
+ }
+
+ /*
+ * Ohyeah and the last one should go the other direction
+ */
+ #menuToggle input:checked ~ span:nth-last-child(2)
+ {
+ transform: rotate(-45deg) translate(0, -1px);
+ }
+
+ /*
+ * Make this absolute positioned
+ * at the top left of the screen
+ */
+ #menu
+ {
+ position: absolute;
+ width: 100vw;
+ margin: -100px 0 0 -50px;
+ padding-bottom: 10px;
+ padding-top: 125px;
+
+ background-color: $primary;
+ list-style-type: none;
+ -webkit-font-smoothing: antialiased;
+ /* to stop flickering of text in safari */
+
+ transform-origin: 0% 0%;
+ transform: translate(-100%, 0);
+
+ transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0);
+ }
+
+ #menu li
+ {
+ padding: 10px 0;
+ font-size: 22px;
+ }
+
+ /*
+ * And let's slide it in from the left
+ */
+ #menuToggle input:checked ~ ul
+ {
+ transform: none;
+ }
+}
+
+@include desktop{
+ #menuToggle{
+ display: none;
+ }
+}
diff --git a/src/ui/Banner.vue b/src/ui/Banner.vue
index f771be3..62daa6a 100644
--- a/src/ui/Banner.vue
+++ b/src/ui/Banner.vue
@@ -1,23 +1,36 @@
-
-
-

-
-
- {{route.name}}
+
+
+
-
-
- {{ pad(days) }}:
- {{ pad(hours) }}:
- {{ pad(minutes) }}:
- {{ pad(seconds) }}
-
- Lotteriet er i gang!
-
+
-
+
+
+
+
+
+
+ {{route.name}}
+
+
+
+
+ {{ pad(days) }}:
+ {{ pad(hours) }}:
+ {{ pad(minutes) }}:
+ {{ pad(seconds) }}
+
+ Lotteriet er i gang!
+
+
-
-
-
From 58b424a8734c4aaf639c66e0fe88333d19f1e4bb Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Wed, 2 Sep 2020 13:04:34 +0200
Subject: [PATCH 19/32] bigger clock margin on desktop
---
src/ui/Banner.vue | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/ui/Banner.vue b/src/ui/Banner.vue
index 62daa6a..870ad2d 100644
--- a/src/ui/Banner.vue
+++ b/src/ui/Banner.vue
@@ -188,7 +188,11 @@ export default {
color: #333333;
display: flex;
font-family: Arial;
- font-size: 0.8em;
+ margin-right: 2rem;
+ @include mobile {
+ font-size: 0.8em;
+ margin-right: 1rem;
+ }
h2 {
display: flex;
}
From fe5f9d212427af88930a884b1aa0f8508af9418e Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Wed, 2 Sep 2020 13:22:17 +0200
Subject: [PATCH 20/32] remove unused code
---
src/Vinlottis.vue | 5 -----
src/ui/Banner.vue | 16 ----------------
2 files changed, 21 deletions(-)
diff --git a/src/Vinlottis.vue b/src/Vinlottis.vue
index 4a5c4c1..c87655f 100644
--- a/src/Vinlottis.vue
+++ b/src/Vinlottis.vue
@@ -49,9 +49,6 @@ export default {
]
};
},
- beforeMount(){
- this.handleView()
- },
mounted() {
console.log("SNEAKY PETE!");
this.$on("service-worker-updated", () => {
@@ -99,10 +96,8 @@ body {
diff --git a/src/ui/Banner.vue b/src/ui/Banner.vue
index 870ad2d..4f66d63 100644
--- a/src/ui/Banner.vue
+++ b/src/ui/Banner.vue
@@ -43,9 +43,6 @@ export default {
minutes: 0,
seconds: 0,
distance: 0,
- enabled: false,
- code: "38384040373937396665",
- codeDone: "",
interval: null,
};
},
@@ -79,19 +76,6 @@ export default {
}
return num;
},
- listenerFunction: function(event) {
- this.codeDone += event.keyCode;
- if (this.code.substring(0, this.codeDone.length) == this.codeDone) {
- if (this.code == this.codeDone && !this.enabled) {
- this.enabled = true;
- this.initialize();
- this.countdown();
- this.codeDone = "";
- }
- } else {
- this.codeDone = "";
- }
- },
initialize: function() {
let d = new Date();
let dayOfLottery = __DATE__;
From ed6ac2ac01908e3444960c46725f5b39e7912909 Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Fri, 4 Sep 2020 15:42:03 +0200
Subject: [PATCH 21/32] move api call, remove delete requested wine button,
rename emit
---
api/request.js | 6 ++++++
api/retrieve.js | 6 ------
api/wineinfo.js | 2 +-
src/api.js | 2 +-
src/components/RequestWine.vue | 2 +-
src/ui/Modal.vue | 2 +-
src/ui/RequestedWineCard.vue | 4 ++--
7 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/api/request.js b/api/request.js
index d318beb..d377f2c 100644
--- a/api/request.js
+++ b/api/request.js
@@ -27,6 +27,12 @@ router.route("/request").get(async (req, res) => {
return res.send(rWines)
})
+router.route("/request/all").get(async (req, res) => {
+ const allWines = await RequestedWine.find({}).populate("wine");
+
+ res.json(allWines);
+});
+
router.route("/request").post(async (req, res) => {
const {wine} = req.body
diff --git a/api/retrieve.js b/api/retrieve.js
index 9cbd64a..ef9d7c9 100644
--- a/api/retrieve.js
+++ b/api/retrieve.js
@@ -104,12 +104,6 @@ router.route("/highscore/statistics").get(async (req, res) => {
res.json(highscore);
});
-router.route("/wines/all-requested-wines").get(async (req, res) => {
- const allWines = await RequestedWine.find({}).populate("wine");
-
- res.json(allWines);
-});
-
router.route("/wines/statistics").get(async (req, res) => {
const wines = await Wine.find();
diff --git a/api/wineinfo.js b/api/wineinfo.js
index a5d0497..b7bd7d7 100644
--- a/api/wineinfo.js
+++ b/api/wineinfo.js
@@ -18,7 +18,7 @@ const convertToOurWineObject = wine => {
rating: wine.basic.alcoholContent,
occurences: 0,
id: wine.basic.productId,
- image: `https://bilder.vinmonopolet.no/cache/300x300-0/${wine.basic.productId}-1.jpg`,
+ image: `https://bilder.vinmonopolet.no/cache/500x500-0/${wine.basic.productId}-1.jpg`,
price: wine.prices[0].salesPrice.toString(),
country: wine.origins.origin.country
}
diff --git a/src/api.js b/src/api.js
index f08e3ed..52fbbb3 100644
--- a/src/api.js
+++ b/src/api.js
@@ -25,7 +25,7 @@ const overallWineStatistics = () => {
};
const allRequestedWines = () => {
- const url = new URL("/api/wines/all-requested-wines", BASE_URL);
+ const url = new URL("/api/request/all", BASE_URL);
return fetch(url.href).then(resp => resp.json());
};
diff --git a/src/components/RequestWine.vue b/src/components/RequestWine.vue
index d1861b0..f8b8e54 100644
--- a/src/components/RequestWine.vue
+++ b/src/components/RequestWine.vue
@@ -7,7 +7,7 @@
v-if="showModal"
modalText="Ønsket ditt har blitt lagt til"
:buttons="modalButtons"
- @modalBtnClicked="emitFromModalButton"
+ @click="emitFromModalButton"
>
diff --git a/src/ui/Modal.vue b/src/ui/Modal.vue
index 0d0e8f8..4fd002f 100644
--- a/src/ui/Modal.vue
+++ b/src/ui/Modal.vue
@@ -38,7 +38,7 @@ export default {
},
methods:{
modalButtonClicked(action){
- this.$emit('modalBtnClicked', action)
+ this.$emit('click', action)
}
}
}
diff --git a/src/ui/RequestedWineCard.vue b/src/ui/RequestedWineCard.vue
index 3c85be0..232431b 100644
--- a/src/ui/RequestedWineCard.vue
+++ b/src/ui/RequestedWineCard.vue
@@ -19,9 +19,9 @@
class="wine-link"
>Les mer på polet
-
From 6d26da181715184672466fc95921344ffe13c7e2 Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Mon, 7 Sep 2020 13:15:10 +0200
Subject: [PATCH 22/32] resolve first batch of comments
---
.gitignore | 1 -
api/retrieve.js | 1 -
src/components/AllRequestedWines.vue | 11 ++++++-----
src/ui/RequestedWineCard.vue | 8 ++++----
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/.gitignore b/.gitignore
index 2a2c678..86fe51d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,6 @@ public/index.html
public/sw/
config/env/lottery.config.js
config/env/push.config.js
-config/env/vinmonopolet.config.js
# Logs
logs
diff --git a/api/retrieve.js b/api/retrieve.js
index ef9d7c9..8d36da6 100644
--- a/api/retrieve.js
+++ b/api/retrieve.js
@@ -9,7 +9,6 @@ mongoose.connect("mongodb://localhost:27017/vinlottis", {
const Purchase = require(path.join(__dirname + "/../schemas/Purchase"));
const Wine = require(path.join(__dirname + "/../schemas/Wine"));
const Highscore = require(path.join(__dirname + "/../schemas/Highscore"));
-const RequestedWine = require(path.join(__dirname + "/../schemas/RequestedWine"));
const PreLotteryWine = require(path.join(
__dirname + "/../schemas/PreLotteryWine"
));
diff --git a/src/components/AllRequestedWines.vue b/src/components/AllRequestedWines.vue
index 9022fc4..33e2dbd 100644
--- a/src/components/AllRequestedWines.vue
+++ b/src/components/AllRequestedWines.vue
@@ -4,8 +4,8 @@
Alle foreslåtte viner
- Ingen har foreslått noe enda!
-
+ Ingen har foreslått noe enda!
+
@@ -24,10 +24,11 @@ export default {
}
},
methods: {
+ filterOutDeletedWine(wine){
+ this.wines = this.wines.filter(item => item.wine._id !== wine._id)
+ },
async refreshData(){
- this.wines = []
- const wines = await allRequestedWines()
- this.wines = wines
+ this.wines = await allRequestedWines() || []
}
},
mounted() {
diff --git a/src/ui/RequestedWineCard.vue b/src/ui/RequestedWineCard.vue
index 232431b..d29f52e 100644
--- a/src/ui/RequestedWineCard.vue
+++ b/src/ui/RequestedWineCard.vue
@@ -19,9 +19,9 @@
class="wine-link"
>Les mer på polet
-
+
@@ -63,9 +63,9 @@ export default {
if (window.confirm("Er du sikker på at du vil slette vinen?")) {
let response = await deleteRequestedWine(wine);
if (response) {
- this.$emit('deletedOne');
+ this.$emit('wineDeleted', wine);
} else {
- alert("Klarte ikke hente ut vinnere");
+ alert("Klarte ikke slette vinen");
}
}
},
From ea278a489250ee00a1a321375f4624f24c319a66 Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Mon, 7 Sep 2020 14:50:40 +0200
Subject: [PATCH 23/32] remove console log
---
api/request.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/api/request.js b/api/request.js
index 23bceb7..f7ac11c 100644
--- a/api/request.js
+++ b/api/request.js
@@ -31,8 +31,6 @@ const getAllRequestedWines = async (req, res) => {
const requestNewWine = async (req, res) => {
const {wine} = req.body
-
- console.log(req.body)
let thisWineIsLOKO = await Wine.findOne({id: wine.id})
From e060ff3aaa283659baa78954de225b274aee3629 Mon Sep 17 00:00:00 2001
From: Adrian Thompson
Date: Mon, 7 Sep 2020 14:57:52 +0200
Subject: [PATCH 24/32] cleanup api use
---
src/components/RequestWine.vue | 16 ++--------------
src/ui/RequestedWineCard.vue | 15 ++-------------
2 files changed, 4 insertions(+), 27 deletions(-)
diff --git a/src/components/RequestWine.vue b/src/components/RequestWine.vue
index aaffdf3..58fbd32 100644
--- a/src/components/RequestWine.vue
+++ b/src/components/RequestWine.vue
@@ -48,7 +48,7 @@