Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/cookie welcome dialog #145

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
:options="tourConfig"
name="introduction"
@click.native="nextStep"
:callbacks="tourCallbacks"
/>

<v-mapbox
Expand Down Expand Up @@ -139,6 +140,7 @@
import { tourConfig, generateTourSteps, tourStepCount } from '@/plugins/vue-tour'
import FeedbackDialog from './components/FeedbackDialog/FeedbackDialog.vue'
import AcknowledgmentsDialog from '~/components/AcknowledgmentsDialog/AcknowledgmentsDialog.vue'
import { getCookie, setCookie } from './lib/cookies'

const removeRegion = locale => locale.replace(/-.+/, '')
const localeIsAvailable = locale => availableLocales.includes(locale)
Expand Down Expand Up @@ -168,6 +170,7 @@

data: () => ({
tourConfig,
tourCallbacks: {},
generateTourSteps,
tourStepCount,
accessToken: process.env.VUE_APP_MAPBOX_TOKEN,
Expand Down Expand Up @@ -237,7 +240,11 @@
await this.getAppData({ route, locale: this.currentLocale } )
this.localeIsLoading = false
})
this.showTour()
this.tourCallbacks = { onSkip: this.skipTourCallback, }
const skipTourCookie = getCookie("skipTour")
if (!skipTourCookie) {
this.showTour()
}
},

methods: {
Expand Down Expand Up @@ -315,7 +322,7 @@
this.layersDialogOpen = true
}
} catch (e) {
console.log(e)

Check warning on line 325 in src/App.vue

View workflow job for this annotation

GitHub Actions / deploy-application (nl2120, 1f6372f6-c532-4e0e-bba7-dee08678d518)

Unexpected console statement

Check warning on line 325 in src/App.vue

View workflow job for this annotation

GitHub Actions / deploy-application (openearth-data-viewer, 1785f3f6-b4cf-42de-bea6-b57d48a5c664)

Unexpected console statement

Check warning on line 325 in src/App.vue

View workflow job for this annotation

GitHub Actions / deploy-application (openearth-rws-viewer, 119b8ff3-5b22-4995-b43b-b31f21ba77c3)

Unexpected console statement
} finally {
this.searchIsLoading = false
}
Expand All @@ -332,6 +339,9 @@
showTour () {
this.$tours.introduction.start()
},
skipTourCallback() {
setCookie("skipTour", true, 30)
},
nextStep () {
if (tourStepCount == 2 ) {
const firstFolder = this.displayLayers[0]
Expand Down
22 changes: 22 additions & 0 deletions src/lib/cookies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export function setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
let expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

export function getCookie(cname) {
let name = cname + "=";
let ca = document.cookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}

Loading