diff --git a/src/App.vue b/src/App.vue index f5f146c6034693fe5755a4a245dcfc8973fba9c7..236a66d05a2d5e6cc99c9331ffcce2bd921987df 100644 --- a/src/App.vue +++ b/src/App.vue @@ -23,25 +23,18 @@ --> <template> <main id="app" role="main" class="container"> - <div v-if="$root.sharedState.uuid"> - <router-view/> - </div> - <div v-else> - <Welcome></Welcome> - </div> + <router-view></router-view> </main> </template> <script> -import Welcome from '@/components/Welcome' import CommonUtil from "@/components/CommonUtil"; - export default { name: 'App', components : { - Welcome - }, + +}, methods: { }, beforeMount(){ diff --git a/src/components/LoginSystem.vue b/src/components/LoginSystem.vue index ca72b13f101fc577d3501709d378610b4c3fa6c6..028cd8afc5162b3fa7b187b3b483bd727100cc33 100644 --- a/src/components/LoginSystem.vue +++ b/src/components/LoginSystem.vue @@ -27,7 +27,7 @@ <font-awesome-icon style="font-size: large; color: #3d8052; padding-left: 5px;" icon="fa-user" /> <span v-text="userLoggedInName"></span> <br /> - <a class="vips-btn" v-on:click="handleLogout()">{{ $t("logout.button.label")}}</a> + <a class="btn btn-primary" v-on:click="handleLogout()">{{ $t("logout.button.label")}}</a> </div> <div v-else> <form class="my-2 my-lg-0"> @@ -47,6 +47,7 @@ v-on:keyup.enter="handleLogin()"> {{ $t("login.button.label")}} </button> + <router-link to="/RegisterUserForm" class="btn btn-warning" onclick="$('.offcanvas-collapse').toggleClass('open')">{{ $t("registeruser.button.label") }}</router-link> <div v-show="errMsg" class="alert alert-warning alert-dismissible fade show"> {{errMsg}} <button type="button" class="close" data-dismiss="alert" aria-label="Close"> @@ -236,7 +237,7 @@ this.$emit(CommonUtil.CONST_EVENT_LOGIN_USER_DETAIL, ''); $('.offcanvas-collapse').removeClass('open'); - this.$router.push('/logout'); + this.$router.push('/Logout'); }, /** Remove stored data on logout */ removeStoredData() { diff --git a/src/components/Logout.vue b/src/components/Logout.vue deleted file mode 100644 index 6aa2fe2cc36d23affa0057259ba3bea1f1250d7c..0000000000000000000000000000000000000000 --- a/src/components/Logout.vue +++ /dev/null @@ -1,31 +0,0 @@ -<!-- - - Copyright (c) 2022 NIBIO <http://www.nibio.no/>. - - This file is part of VIPSObservationApp. - VIPSObservationApp is free software: you can redistribute it and/or modify - it under the terms of the NIBIO Open Source License as published by - NIBIO, either version 1 of the License, or (at your option) any - later version. - - VIPSObservationApp is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - NIBIO Open Source License for more details. - - You should have received a copy of the NIBIO Open Source License - along with VIPSObservationApp. If not, see <http://www.nibio.no/licenses/>. - - Author: Bhabesh Bhabani Mukhopadhyay - Author: Tor-Einar Skog <tor-einar.skog@nibio.no> - Dated : 19-Aug-2021 - ---> -<template> - <div> - <h1>{{$t("logout.header.text")}}</h1> - <div class="alert alert-warning" role="alert"> - {{$t("logout.success.text")}} - </div> - </div> -</template> \ No newline at end of file diff --git a/src/components/MapPOI.vue b/src/components/MapPOI.vue index 58e84b69e449d5522500489ad9702b6432192344..d566279c46db4142eca8e29a1d4c4eb2098b6707 100644 --- a/src/components/MapPOI.vue +++ b/src/components/MapPOI.vue @@ -545,6 +545,12 @@ appDiv.style.paddingRight = "15px"; appDiv.style.paddingLeft = "15px"; }, + beforeRouteEnter(to,from,next){ + next(vm=>{ + if(vm.$root.sharedState.uuid == ""){ next("/Welcome"); } + else { next(); } + }) + } } </script> diff --git a/src/components/Observation.vue b/src/components/Observation.vue index fe4a89896d89c0c8f9b78e70eeb04154daa9f471..057de53a26004ca21b29cc59dd7a683b3afd57cd 100644 --- a/src/components/Observation.vue +++ b/src/components/Observation.vue @@ -784,6 +784,12 @@ this.observationForStore.locationIsPrivate = this.observation.locationIsPrivate; this.observationForStore.polygonService = this.observation.polygonService; } + }, + beforeRouteEnter(to,from,next){ + next(vm=>{ + if(vm.$root.sharedState.uuid == ""){ next("/Welcome"); } + else { next(); } + }) } } diff --git a/src/components/ObservationList.vue b/src/components/ObservationList.vue index 4037958f0e86919363e7aa78daeec036736f35c1..979e1d83c573b63f41293384280cd6b4e87a3a26 100644 --- a/src/components/ObservationList.vue +++ b/src/components/ObservationList.vue @@ -136,6 +136,12 @@ // Making it globally available, so that e.g. the Sync component can update the list // calling e.g. this.$root.sharedState.observationListComponent.getObservationsFromStore(); this.$root.sharedState.observationListComponent = this; + }, + beforeRouteEnter(to,from,next){ + next(vm=>{ + if(vm.$root.sharedState.uuid == ""){ next("/Welcome"); } + else { next(); } + }) } } </script> diff --git a/src/components/PlacesList.vue b/src/components/PlacesList.vue index fbff8f75cefbd30bb419463e46bf9d05958c3266..6e7c3820bd95e9795556552131a50e9c140b8250 100644 --- a/src/components/PlacesList.vue +++ b/src/components/PlacesList.vue @@ -173,6 +173,12 @@ // calling e.g. this.$root.sharedState.placesListComponent.fooBar(); this.$root.sharedState.placesListComponent = this; + }, + beforeRouteEnter(to,from,next){ + next(vm=>{ + if(vm.$root.sharedState.uuid == ""){ next("/Welcome"); } + else { next(); } + }) } } </script> diff --git a/src/components/RegisterUserForm.vue b/src/components/RegisterUserForm.vue new file mode 100644 index 0000000000000000000000000000000000000000..1720e7f9b7b01ce7dba2f8203fb3f7a5e2dbbc5a --- /dev/null +++ b/src/components/RegisterUserForm.vue @@ -0,0 +1,36 @@ +<!-- + + Copyright (c) 2023 NIBIO <http://www.nibio.no/>. + + This file is part of VIPSObservationApp. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. + + Author: Tor-Einar Skog <tor-einar.skog@nibio.no> + Created : 2023-04-18 + +--> + +<template> + <div> + <h1>Register new user</h1> + </div> +</template> + +<script> + import CommonUtil from '@/components/CommonUtil'; + + export default { + name: 'RegisterUserForm' + } +</script> \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index ae35bdc2fa6842a9f3674f5ac51751a9723fca1a..a1149f60639efe616bbedfc62a7466dc9698c248 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -71,6 +71,6 @@ "about.header": "About", "about.version": "Version", "about.text": "<p>The app is developed by <a href='#' onclick=\"cordova.InAppBrowser.open('https://nibio.no/en', '_system')\">NIBIO</a>'s <a href='#' onclick=\"cordova.InAppBrowser.open('https://www.vips-landbruk.no/', '_system')\">VIPS</a> team.</p><p>VIPS project leader: <a href='#' onclick=\"cordova.InAppBrowser.open('https://www.nibio.no/ansatte/berit-nordskog', '_system')\">Berit Nordskog</a></p><p>© 2022 <a href='#' onclick=\"cordova.InAppBrowser.open('https://nibio.no/en', '_system')\">NIBIO</a></p>", - + "registeruser.button.label": "Register new user", "copy" : "Copy" } \ No newline at end of file diff --git a/src/locales/nb.json b/src/locales/nb.json index 9b0e3d0cb058056fd45c25ede6c0443c269bd254..c70f7a4b13bd147be03b6f996403957115cc7b79 100644 --- a/src/locales/nb.json +++ b/src/locales/nb.json @@ -71,6 +71,6 @@ "about.header": "Om appen", "about.version": "Versjon", "about.text": "<p>Appen er utviklet av <a href='#' onclick=\"cordova.InAppBrowser.open('https://nibio.no/', '_system')\">NIBIO</a>s <a href='#' onclick=\"cordova.InAppBrowser.open('https://www.vips-landbruk.no/', '_system')\">VIPS-team</a>.</p><p>Prosjektleder for VIPS: <a href='#' onclick=\"cordova.InAppBrowser.open('https://www.nibio.no/ansatte/berit-nordskog', '_system')\">Berit Nordskog</a></p><p>© 2022 <a href='#' onclick=\"cordova.InAppBrowser.open('https://nibio.no/', '_system')\">NIBIO</a></p>", - + "registeruser.button.label": "Registrer ny bruker", "copy" : "Kopi" } \ No newline at end of file diff --git a/src/main.js b/src/main.js index 566a3e3b73f524e6c040d9251931218ebc869f3b..a11d407eff3bb0d95723d3266d0056540ef498f6 100644 --- a/src/main.js +++ b/src/main.js @@ -72,12 +72,11 @@ const init = () => { }, i18n, - created() { - CommonUtil.setHeaderTitle(this.$i18n.t("index.header")); - CommonUtil.logInfo("Vue is ready"); - CommonUtil.logInfo("User's preferred language is " + this.$i18n.locale); - // Are we logged in already? + CommonUtil.setHeaderTitle(this.$i18n.t("index.header")); + CommonUtil.logInfo("Vue is ready"); + CommonUtil.logInfo("User's preferred language is " + this.$i18n.locale); + // Are we logged in already? } diff --git a/src/router/index.js b/src/router/index.js index 3fd29a726f3c3b9946087b0abdd502000a360920..98a9088e0737b6b501ba2a02dedd57d8638ecf3a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -9,11 +9,12 @@ import CropCategory from '@/components/CropCategory' import MapObservation from '@/components/MapObservation' import MapPOI from '@/components/MapPOI' import Quantification from '@/components/Quantification' -import Logout from '@/components/Logout' +import RegisterUserForm from '@/components/RegisterUserForm' + Vue.use(Router) -export default new Router({ +const router = new Router({ routes: [ { path: '/welcome', @@ -61,11 +62,42 @@ export default new Router({ name : 'Quantification', component : Quantification }, + { + path : '/RegisterUserForm', + name : 'RegisterUserForm', + component : RegisterUserForm + }, { path : '/logout', name : 'Logout', - component : Logout + component : Welcome }, ] }) + +export default router; + +/*router.beforeEach((to,from,next) => { + //console.info(this.sharedState); + + //console.info(router.app.$root.sharedState); + //console.info(router.app.$root.sharedState.uuid); + //console.info(from); + + //console.info("uuid=" + router.app.$root.sharedState.uuid); + + console.info("to.name=" + to.name); + console.info(router.app.sharedState) + //var isLoggedIn = router.app.$root.sharedState.uuid != undefined && router.app.$root.sharedState.uuid != ""; + + if(!isLoggedIn && ["RegisterUserForm","Welcome"].indexOf(to.name) < 0) + { + next({name:"Welcome"}); + } + else { + next(); + } +}); +*/ + diff --git a/static/css/vipsobsapp.css b/static/css/vipsobsapp.css index d64309eebd3e7346fb0f1d2169b71a0a8691b2fe..72b037808e9193365ff479eebcacc05adbe2861e 100644 --- a/static/css/vipsobsapp.css +++ b/static/css/vipsobsapp.css @@ -23,6 +23,11 @@ a.nav-link{ border-color: #3d8052; } +.btn-primary, .btn-primary:hover { + background-color: #3d8052; + border-color: #3d8052; +} + a.vips-btn { background-color: #3d8052; color: white;