From c62b65b012e41eb6565c87f08891bae049d7b44c Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Tue, 15 Oct 2019 17:27:16 +0530 Subject: [PATCH] :sparkles: Added Cookie Consent toast --- layouts/default.vue | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/layouts/default.vue b/layouts/default.vue index 91367a2a1..a377ce350 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -183,6 +183,50 @@ // etc. (async () => { this.showInstallPrompt = await intializePwa(); + let cookiesAllowed = localStorage.getItem('cookiesAllowed') === 'yes'; + if(!cookiesAllowed) { + this.$toast.show('We use cookies for analytics and to improve our site', { + icon: 'info', + duration: 0, + action: [ + { + text: 'Deny', + onClick: (e, toastObject) => { + toastObject.goAway(0); + this.$toast.error("HTTP service won't work without your consent", { + icon: 'error', + duration: 0, + action: [ + { + text: 'Leave', + onClick: (e, toastObject) => { + this.$router.push({ + path: '/websocket' + }); + toastObject.goAway(0); + } + }, + { + text: 'Opt-in', + onClick: (e, toastObject) => { + localStorage.setItem('cookiesAllowed', 'yes'); + toastObject.goAway(0); + } + } + ] + }); + } + }, + { + text: 'Accept', + onClick: (e, toastObject) => { + localStorage.setItem('cookiesAllowed', 'yes'); + toastObject.goAway(0); + } + } + ] + }); + } })(); } }