implemented user menu, fixed bugs

This commit is contained in:
Timo Volkmann 2019-05-16 20:45:34 +02:00
parent 2cacf050be
commit 63649b2647
3 changed files with 61 additions and 18 deletions

View File

@ -73,7 +73,9 @@ module.exports = function (ctx) {
'QSlideTransition', 'QSlideTransition',
'QToggle', 'QToggle',
'QLinearProgress', 'QLinearProgress',
'QBtnGroup' 'QBtnGroup',
'QTooltip',
'QMenu'
], ],
directives: [ directives: [

View File

@ -2,13 +2,44 @@
<q-layout view="hhh Lpr lFf" @click.native="counter()"> <q-layout view="hhh Lpr lFf" @click.native="counter()">
<q-header id="qheader" class="bg-white text-grey-14" elevated> <q-header id="qheader" class="bg-white text-grey-14" elevated>
<q-toolbar class="q-pa-md"> <q-toolbar class="q-pa-md">
<q-img src="statics/buga_logo.svg" style="max-width: 40px;" class="q-mr-sm"/> <router-link to="/">
<q-img src="statics/buga_logo.svg" style="width: 40px;" class="q-mr-sm"/>
</router-link>
<q-toolbar-title> <q-toolbar-title>
BuGa Geocaching Geocaching
</q-toolbar-title> </q-toolbar-title>
<!-- <router-link v-if="getUser" to="/Profile" class="text-grey-14">-->
<a href="#" v-if="getUser" class="row q-mx-sm items-center q-gutter-x-sm text-grey-14">
<p class="q-ma-none gt-xs">{{ getUser.email }}</p>
<q-avatar size="33px" font-size="33px" color="white" icon="account_circle">
</q-avatar>
<q-menu
transition-show="jump-down"
transition-hide="jump-up"
anchor="bottom right" self="top right"
:offset="[0, 10]">
<q-item clickable v-close-popup to="/Profile" class="text-grey-14">
<q-item-section>
Profil
</q-item-section>
<q-item-section avatar>
<q-icon name="perm_identity"/>
</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="logout" class="text-grey-14">
<q-item-section>
Logout
</q-item-section>
<q-item-section avatar>
<q-icon name="logout"/>
</q-item-section>
</q-item>
</q-menu>
</a>
<!-- </router-link>-->
<q-btn <q-btn
class="q-pa-sm"
flat flat
dense dense
ripple ripple
@ -57,7 +88,7 @@
<q-item-section> <q-item-section>
<q-item-label>QR-Code Scanner</q-item-label> <q-item-label>QR-Code Scanner</q-item-label>
</q-item-section> </q-item-section>
</q-item> </q-item>
<q-item <q-item
clickable clickable
class="text-primary" class="text-primary"
@ -164,16 +195,16 @@
</q-item> </q-item>
<!-- <q-item--> <!-- <q-item-->
<!-- disable--> <!-- disable-->
<!-- class="text-grey-5"--> <!-- class="text-grey-5"-->
<!-- >--> <!-- >-->
<!-- <q-item-section avatar>--> <!-- <q-item-section avatar>-->
<!-- </q-item-section>--> <!-- </q-item-section>-->
<!-- <q-item-section>--> <!-- <q-item-section>-->
<!-- <q-item-label>dev: {{ clickCounter }} clicks</q-item-label>--> <!-- <q-item-label>dev: {{ clickCounter }} clicks</q-item-label>-->
<!-- </q-item-section>--> <!-- </q-item-section>-->
<!-- </q-item>--> <!-- </q-item>-->
</q-list> </q-list>
@ -203,7 +234,6 @@
</template> </template>
<script> <script>
import {openURL} from "quasar";
export default { export default {
name: "MyLayout", name: "MyLayout",
@ -247,6 +277,12 @@
// console.log("get dialogColorBtn: "+this.$store.state.dialog.dialog.colorButton) // console.log("get dialogColorBtn: "+this.$store.state.dialog.dialog.colorButton)
return this.$store.state.dialog.dialog.colorButton; return this.$store.state.dialog.dialog.colorButton;
}, },
},
getUser: {
get() {
// console.log("get dialogColorBtn: "+this.$store.state.dialog.dialog.colorButton)
return this.$store.getters['auth/GET_USER'];
},
} }
}, },
created() { created() {
@ -261,15 +297,16 @@
console.log("dialogClose(): ") console.log("dialogClose(): ")
this.$store.commit('dialog/RESET_MESSAGE_DIALOG'); this.$store.commit('dialog/RESET_MESSAGE_DIALOG');
}, },
evalAuthentication: function () { evalAuthentication() {
this.$store.commit('auth/SET_AUTHENTICATED'); this.$store.commit('auth/SET_AUTHENTICATED');
this.$store.commit('auth/SET_USER'); this.$store.commit('auth/SET_USER');
}, },
logout: function () { logout() {
console.log("logout()"); console.log("logout()");
console.log(JSON.parse(localStorage.getItem('userToken'))); console.log(JSON.parse(localStorage.getItem('userToken')));
localStorage.removeItem('userToken'); localStorage.removeItem('userToken');
this.evalAuthentication(); this.evalAuthentication();
this.$router.push({path: `/login`})
}, },
} }

View File

@ -11,6 +11,10 @@ export function GET_ADMINSTATE(state) {
return false; return false;
} }
} }
export function GET_USER(state) {
console.log("GET_USER");
return state.userAuthenticated;
}
// /** // /**
// * @return {boolean} // * @return {boolean}