2018-01-09 16:52:26 +00:00
|
|
|
<template>
|
2019-01-21 14:08:22 +00:00
|
|
|
<div id="mobilizon">
|
2019-04-03 15:29:03 +00:00
|
|
|
<NavBar />
|
2019-10-01 18:10:53 +00:00
|
|
|
<main>
|
2019-10-08 18:01:00 +00:00
|
|
|
<transition name="fade">
|
|
|
|
<router-view />
|
|
|
|
</transition>
|
2019-01-21 14:08:22 +00:00
|
|
|
</main>
|
2019-04-03 15:29:03 +00:00
|
|
|
<mobilizon-footer />
|
2019-01-21 14:08:22 +00:00
|
|
|
</div>
|
2018-01-09 16:52:26 +00:00
|
|
|
</template>
|
|
|
|
|
2018-12-21 14:41:34 +00:00
|
|
|
<script lang="ts">
|
2019-08-13 06:43:37 +00:00
|
|
|
import NavBar from '@/components/NavBar.vue';
|
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
2019-09-11 07:59:01 +00:00
|
|
|
import {
|
|
|
|
AUTH_ACCESS_TOKEN,
|
|
|
|
AUTH_USER_EMAIL,
|
|
|
|
AUTH_USER_ID,
|
|
|
|
AUTH_USER_ROLE,
|
|
|
|
} from '@/constants';
|
2019-08-13 06:43:37 +00:00
|
|
|
import { CURRENT_USER_CLIENT, UPDATE_CURRENT_USER_CLIENT } from '@/graphql/user';
|
|
|
|
import Footer from '@/components/Footer.vue';
|
|
|
|
import Logo from '@/components/Logo.vue';
|
2019-10-04 16:28:25 +00:00
|
|
|
import { initializeCurrentActor } from '@/utils/auth';
|
2019-08-13 06:43:37 +00:00
|
|
|
@Component({
|
2019-01-18 13:47:10 +00:00
|
|
|
apollo: {
|
|
|
|
currentUser: {
|
2019-03-22 09:57:14 +00:00
|
|
|
query: CURRENT_USER_CLIENT,
|
|
|
|
},
|
2019-01-18 13:47:10 +00:00
|
|
|
},
|
2018-12-21 16:10:39 +00:00
|
|
|
components: {
|
2019-04-03 15:29:03 +00:00
|
|
|
Logo,
|
2019-03-22 09:57:14 +00:00
|
|
|
NavBar,
|
2019-04-03 15:29:03 +00:00
|
|
|
'mobilizon-footer': Footer,
|
2019-03-22 09:57:14 +00:00
|
|
|
},
|
2018-12-21 16:10:39 +00:00
|
|
|
})
|
|
|
|
export default class App extends Vue {
|
2019-09-11 07:59:01 +00:00
|
|
|
async created() {
|
2019-09-18 15:32:37 +00:00
|
|
|
if (await this.initializeCurrentUser()) {
|
|
|
|
await initializeCurrentActor(this.$apollo.provider.defaultClient);
|
|
|
|
}
|
2018-12-21 14:41:34 +00:00
|
|
|
}
|
|
|
|
|
2019-09-18 15:32:37 +00:00
|
|
|
private async initializeCurrentUser() {
|
2019-01-18 13:47:10 +00:00
|
|
|
const userId = localStorage.getItem(AUTH_USER_ID);
|
|
|
|
const userEmail = localStorage.getItem(AUTH_USER_EMAIL);
|
2019-08-12 14:04:16 +00:00
|
|
|
const accessToken = localStorage.getItem(AUTH_ACCESS_TOKEN);
|
2019-09-09 07:31:08 +00:00
|
|
|
const role = localStorage.getItem(AUTH_USER_ROLE);
|
2019-01-18 13:47:10 +00:00
|
|
|
|
2019-09-09 07:31:08 +00:00
|
|
|
if (userId && userEmail && accessToken && role) {
|
2019-09-18 15:32:37 +00:00
|
|
|
return await this.$apollo.mutate({
|
2019-01-18 13:47:10 +00:00
|
|
|
mutation: UPDATE_CURRENT_USER_CLIENT,
|
|
|
|
variables: {
|
|
|
|
id: userId,
|
|
|
|
email: userEmail,
|
2019-04-01 09:49:54 +00:00
|
|
|
isLoggedIn: true,
|
2019-09-09 07:31:08 +00:00
|
|
|
role,
|
2019-01-18 13:47:10 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2019-09-18 15:32:37 +00:00
|
|
|
return false;
|
2019-09-11 07:59:01 +00:00
|
|
|
}
|
2018-12-21 16:10:39 +00:00
|
|
|
}
|
2018-01-09 16:52:26 +00:00
|
|
|
</script>
|
|
|
|
|
2019-04-03 15:29:03 +00:00
|
|
|
<style lang="scss">
|
2019-08-13 06:43:37 +00:00
|
|
|
@import "variables";
|
2019-04-03 15:29:03 +00:00
|
|
|
|
2019-08-13 06:43:37 +00:00
|
|
|
/* Bulma imports */
|
2019-09-26 14:38:58 +00:00
|
|
|
@import "~bulma/bulma";
|
2019-05-17 14:28:15 +00:00
|
|
|
|
2019-08-13 06:43:37 +00:00
|
|
|
/* Buefy imports */
|
2019-09-26 14:38:58 +00:00
|
|
|
@import "~buefy/src/scss/buefy";
|
2019-04-03 15:29:03 +00:00
|
|
|
|
2019-10-08 18:01:00 +00:00
|
|
|
.fade-enter-active, .fade-leave-active {
|
|
|
|
transition: opacity .75s;
|
2019-01-21 14:08:22 +00:00
|
|
|
}
|
2019-10-08 18:01:00 +00:00
|
|
|
.fade-enter, .fade-leave-to {
|
2019-01-21 14:08:22 +00:00
|
|
|
opacity: 0;
|
|
|
|
}
|
2019-04-03 15:29:03 +00:00
|
|
|
|
|
|
|
body {
|
2019-10-05 17:07:50 +00:00
|
|
|
// background: #f7f8fa;
|
|
|
|
background: #ebebeb;
|
2019-04-03 15:29:03 +00:00
|
|
|
}
|
2018-01-09 16:52:26 +00:00
|
|
|
</style>
|