Skip to content
Snippets Groups Projects
Commit 7fba814d authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Refactor/change to cope with user reg form

parent 4c76e4e8
Branches
No related tags found
No related merge requests found
...@@ -23,25 +23,18 @@ ...@@ -23,25 +23,18 @@
--> -->
<template> <template>
<main id="app" role="main" class="container"> <main id="app" role="main" class="container">
<div v-if="$root.sharedState.uuid"> <router-view></router-view>
<router-view/>
</div>
<div v-else>
<Welcome></Welcome>
</div>
</main> </main>
</template> </template>
<script> <script>
import Welcome from '@/components/Welcome'
import CommonUtil from "@/components/CommonUtil"; import CommonUtil from "@/components/CommonUtil";
export default { export default {
name: 'App', name: 'App',
components : { components : {
Welcome
}, },
methods: { methods: {
}, },
beforeMount(){ beforeMount(){
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<font-awesome-icon style="font-size: large; color: #3d8052; padding-left: 5px;" icon="fa-user" /> <span <font-awesome-icon style="font-size: large; color: #3d8052; padding-left: 5px;" icon="fa-user" /> <span
v-text="userLoggedInName"></span> v-text="userLoggedInName"></span>
<br /> <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>
<div v-else> <div v-else>
<form class="my-2 my-lg-0"> <form class="my-2 my-lg-0">
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
v-on:keyup.enter="handleLogin()"> v-on:keyup.enter="handleLogin()">
{{ $t("login.button.label")}} {{ $t("login.button.label")}}
</button> </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"> <div v-show="errMsg" class="alert alert-warning alert-dismissible fade show">
{{errMsg}} {{errMsg}}
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> <button type="button" class="close" data-dismiss="alert" aria-label="Close">
...@@ -236,7 +237,7 @@ ...@@ -236,7 +237,7 @@
this.$emit(CommonUtil.CONST_EVENT_LOGIN_USER_DETAIL, ''); this.$emit(CommonUtil.CONST_EVENT_LOGIN_USER_DETAIL, '');
$('.offcanvas-collapse').removeClass('open'); $('.offcanvas-collapse').removeClass('open');
this.$router.push('/logout'); this.$router.push('/Logout');
}, },
/** Remove stored data on logout */ /** Remove stored data on logout */
removeStoredData() { removeStoredData() {
......
<!--
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
...@@ -545,6 +545,12 @@ ...@@ -545,6 +545,12 @@
appDiv.style.paddingRight = "15px"; appDiv.style.paddingRight = "15px";
appDiv.style.paddingLeft = "15px"; appDiv.style.paddingLeft = "15px";
}, },
beforeRouteEnter(to,from,next){
next(vm=>{
if(vm.$root.sharedState.uuid == ""){ next("/Welcome"); }
else { next(); }
})
}
} }
</script> </script>
......
...@@ -784,6 +784,12 @@ ...@@ -784,6 +784,12 @@
this.observationForStore.locationIsPrivate = this.observation.locationIsPrivate; this.observationForStore.locationIsPrivate = this.observation.locationIsPrivate;
this.observationForStore.polygonService = this.observation.polygonService; this.observationForStore.polygonService = this.observation.polygonService;
} }
},
beforeRouteEnter(to,from,next){
next(vm=>{
if(vm.$root.sharedState.uuid == ""){ next("/Welcome"); }
else { next(); }
})
} }
} }
......
...@@ -136,6 +136,12 @@ ...@@ -136,6 +136,12 @@
// Making it globally available, so that e.g. the Sync component can update the list // Making it globally available, so that e.g. the Sync component can update the list
// calling e.g. this.$root.sharedState.observationListComponent.getObservationsFromStore(); // calling e.g. this.$root.sharedState.observationListComponent.getObservationsFromStore();
this.$root.sharedState.observationListComponent = this; this.$root.sharedState.observationListComponent = this;
},
beforeRouteEnter(to,from,next){
next(vm=>{
if(vm.$root.sharedState.uuid == ""){ next("/Welcome"); }
else { next(); }
})
} }
} }
</script> </script>
......
...@@ -173,6 +173,12 @@ ...@@ -173,6 +173,12 @@
// calling e.g. this.$root.sharedState.placesListComponent.fooBar(); // calling e.g. this.$root.sharedState.placesListComponent.fooBar();
this.$root.sharedState.placesListComponent = this; this.$root.sharedState.placesListComponent = this;
},
beforeRouteEnter(to,from,next){
next(vm=>{
if(vm.$root.sharedState.uuid == ""){ next("/Welcome"); }
else { next(); }
})
} }
} }
</script> </script>
......
<!--
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
...@@ -71,6 +71,6 @@ ...@@ -71,6 +71,6 @@
"about.header": "About", "about.header": "About",
"about.version": "Version", "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>&copy; 2022 <a href='#' onclick=\"cordova.InAppBrowser.open('https://nibio.no/en', '_system')\">NIBIO</a></p>", "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>&copy; 2022 <a href='#' onclick=\"cordova.InAppBrowser.open('https://nibio.no/en', '_system')\">NIBIO</a></p>",
"registeruser.button.label": "Register new user",
"copy" : "Copy" "copy" : "Copy"
} }
\ No newline at end of file
...@@ -71,6 +71,6 @@ ...@@ -71,6 +71,6 @@
"about.header": "Om appen", "about.header": "Om appen",
"about.version": "Versjon", "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>&copy; 2022 <a href='#' onclick=\"cordova.InAppBrowser.open('https://nibio.no/', '_system')\">NIBIO</a></p>", "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>&copy; 2022 <a href='#' onclick=\"cordova.InAppBrowser.open('https://nibio.no/', '_system')\">NIBIO</a></p>",
"registeruser.button.label": "Registrer ny bruker",
"copy" : "Kopi" "copy" : "Kopi"
} }
\ No newline at end of file
...@@ -72,12 +72,11 @@ const init = () => { ...@@ -72,12 +72,11 @@ const init = () => {
}, },
i18n, i18n,
created() { created() {
CommonUtil.setHeaderTitle(this.$i18n.t("index.header")); CommonUtil.setHeaderTitle(this.$i18n.t("index.header"));
CommonUtil.logInfo("Vue is ready"); CommonUtil.logInfo("Vue is ready");
CommonUtil.logInfo("User's preferred language is " + this.$i18n.locale); CommonUtil.logInfo("User's preferred language is " + this.$i18n.locale);
// Are we logged in already? // Are we logged in already?
} }
......
...@@ -9,11 +9,12 @@ import CropCategory from '@/components/CropCategory' ...@@ -9,11 +9,12 @@ import CropCategory from '@/components/CropCategory'
import MapObservation from '@/components/MapObservation' import MapObservation from '@/components/MapObservation'
import MapPOI from '@/components/MapPOI' import MapPOI from '@/components/MapPOI'
import Quantification from '@/components/Quantification' import Quantification from '@/components/Quantification'
import Logout from '@/components/Logout' import RegisterUserForm from '@/components/RegisterUserForm'
Vue.use(Router) Vue.use(Router)
export default new Router({ const router = new Router({
routes: [ routes: [
{ {
path: '/welcome', path: '/welcome',
...@@ -61,11 +62,42 @@ export default new Router({ ...@@ -61,11 +62,42 @@ export default new Router({
name : 'Quantification', name : 'Quantification',
component : Quantification component : Quantification
}, },
{
path : '/RegisterUserForm',
name : 'RegisterUserForm',
component : RegisterUserForm
},
{ {
path : '/logout', path : '/logout',
name : '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();
}
});
*/
...@@ -23,6 +23,11 @@ a.nav-link{ ...@@ -23,6 +23,11 @@ a.nav-link{
border-color: #3d8052; border-color: #3d8052;
} }
.btn-primary, .btn-primary:hover {
background-color: #3d8052;
border-color: #3d8052;
}
a.vips-btn { a.vips-btn {
background-color: #3d8052; background-color: #3d8052;
color: white; color: white;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment