From 23a2772468304e7b070fd3be6e5eaf72a72b7925 Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Wed, 10 Jan 2024 09:32:41 -0700 Subject: [PATCH] Move disclaimer to app (#68) The pre app disclaimer makes more sense initialized by the app and not the home page. This PR moves the popup to the app and adds basic store functionality to give global access to the state of the apps agreement. Signed-off-by: Justin Georgi Reviewed-on: https://gitea.azgeorgis.net/Georgi_Lab/ALVINN_f7/pulls/68 --- src/components/app.vue | 80 +++++++++++++++++++++++++++++++++++++++--- src/js/store.js | 43 ++++++----------------- src/pages/home.vue | 78 +++++++--------------------------------- 3 files changed, 99 insertions(+), 102 deletions(-) diff --git a/src/components/app.vue b/src/components/app.vue index 695725e..accb8d5 100644 --- a/src/components/app.vue +++ b/src/components/app.vue @@ -17,7 +17,29 @@ - + + + + IMPORTANT + + +

+ ALVINN is for educational purposes only. It may not be used for medical diagnosis, intervention, or treatment. +

+
+ + Don't show again + + +
+
+
+
@@ -38,6 +60,57 @@ import store from '../js/store'; export default { + data () { + return { + rememberAgreement: false, + siteAgreement: false, + showDisclaimer: true + } + }, + created () { + var loadSiteSettings = localStorage.getItem('siteSettings') + if (loadSiteSettings) { + var loadedSettings = JSON.parse(loadSiteSettings) + this.siteAgreement = loadedSettings.siteAgreement + this.rememberAgreement = loadedSettings.rememberAgreement + } + if (this.siteAgreement && this.rememberAgreement) { + this.showDisclaimer = false + store().agree() + } + }, + methods: { + setAgreement () { + this.siteAgreement = true + store().agree() + let newSettings = { + siteAgreement: this.siteAgreement, + rememberAgreement: this.rememberAgreement + } + let saveSiteSettings = new Promise( + (saved,failed) => { + try { + localStorage.setItem('siteSettings',JSON.stringify(newSettings)) + saved() + } catch { + failed() + } + } + ) + saveSiteSettings.then( + () => { + this.showDisclaimer = false + }, + () => { + var toast = f7.toast.create({ + text: 'ERROR: No settings saved', + closeTimeout: 2000 + }) + toast.open() + } + ) + } + }, setup() { const device = getDevice(); // Framework7 Parameters @@ -48,6 +121,7 @@ } catch { var darkTheme = 'auto' } + //provide('isAgreed',siteAgreement) const f7params = { name: 'ALVINN', // App name theme: 'auto', // Automatic theme detection @@ -56,8 +130,6 @@ primary: '#002f65', }, - // App store - store: store, // App routes routes: routes, @@ -98,7 +170,7 @@ }); return { - f7params + f7params, } } } diff --git a/src/js/store.js b/src/js/store.js index 1d8b1fa..a9e2e29 100644 --- a/src/js/store.js +++ b/src/js/store.js @@ -1,35 +1,14 @@ +import { reactive, computed } from 'vue'; -import { createStore } from 'framework7/lite'; +const state = reactive({ + disclaimerAgreement: false + }) -const store = createStore({ - state: { - products: [ - { - id: '1', - title: 'Apple iPhone 8', - description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi tempora similique reiciendis, error nesciunt vero, blanditiis pariatur dolor, minima sed sapiente rerum, dolorem corrupti hic modi praesentium unde saepe perspiciatis.' - }, - { - id: '2', - title: 'Apple iPhone 8 Plus', - description: 'Velit odit autem modi saepe ratione totam minus, aperiam, labore quia provident temporibus quasi est ut aliquid blanditiis beatae suscipit odio vel! Nostrum porro sunt sint eveniet maiores, dolorem itaque!' - }, - { - id: '3', - title: 'Apple iPhone X', - description: 'Expedita sequi perferendis quod illum pariatur aliquam, alias laboriosam! Vero blanditiis placeat, mollitia necessitatibus reprehenderit. Labore dolores amet quos, accusamus earum asperiores officiis assumenda optio architecto quia neque, quae eum.' - }, - ] - }, - getters: { - products({ state }) { - return state.products; - } - }, - actions: { - addProduct({ state }, product) { - state.products = [...state.products, product]; - }, - }, +const agree = () => { + state.disclaimerAgreement = true +} + +export default () => ({ + isAgreed: computed(() => state.disclaimerAgreement), + agree }) -export default store; diff --git a/src/pages/home.vue b/src/pages/home.vue index 0ab6624..fb37552 100644 --- a/src/pages/home.vue +++ b/src/pages/home.vue @@ -11,43 +11,26 @@

Anatomy Lab Visual Identification Neural Network

Veterinary Anatomy Edition

-

Select a region to begin

+

Select a region to begin.

- + + - + + - + + - + +
- - - IMPORTANT - - -

- ALVINN is for educational purposes only. It may not be used for medical diagnosis, intervention, or treatment. -

-
- - Don't show again - - -
-
-
@@ -109,51 +92,14 @@