2018-01-09 16:52:26 +00:00
|
|
|
<template>
|
2019-01-21 14:08:22 +00:00
|
|
|
<div id="mobilizon">
|
|
|
|
<NavBar></NavBar>
|
|
|
|
<main class="container">
|
|
|
|
<router-view></router-view>
|
|
|
|
</main>
|
|
|
|
<footer class="footer">
|
|
|
|
<div class="content has-text-centered">
|
|
|
|
<span
|
|
|
|
v-translate="{
|
|
|
|
date: new Date().getFullYear(),
|
|
|
|
}"
|
|
|
|
>© The Mobilizon Contributors %{date} - Made with Elixir, Phoenix, VueJS & with some love and some weeks</span>
|
|
|
|
</div>
|
|
|
|
</footer>
|
|
|
|
</div>
|
2018-01-09 16:52:26 +00:00
|
|
|
</template>
|
|
|
|
|
2018-12-21 14:41:34 +00:00
|
|
|
<script lang="ts">
|
2018-12-21 16:10:39 +00:00
|
|
|
import NavBar from '@/components/NavBar.vue';
|
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
2019-01-18 13:47:10 +00:00
|
|
|
import { AUTH_TOKEN, AUTH_USER_ACTOR, AUTH_USER_EMAIL, AUTH_USER_ID } from '@/constants';
|
|
|
|
import { CURRENT_USER_CLIENT, UPDATE_CURRENT_USER_CLIENT } from '@/graphql/user';
|
2019-03-22 09:57:14 +00:00
|
|
|
import { ICurrentUser } from '@/types/current-user.model';
|
2018-01-09 16:52:26 +00:00
|
|
|
|
2018-12-21 16:10:39 +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-03-22 09:57:14 +00:00
|
|
|
NavBar,
|
|
|
|
},
|
2018-12-21 16:10:39 +00:00
|
|
|
})
|
|
|
|
export default class App extends Vue {
|
|
|
|
drawer = false;
|
|
|
|
fab = false;
|
|
|
|
items = [
|
|
|
|
{
|
2019-03-22 09:57:14 +00:00
|
|
|
icon: 'poll',
|
|
|
|
text: 'Events',
|
|
|
|
route: 'EventList',
|
|
|
|
role: null,
|
2018-12-21 16:10:39 +00:00
|
|
|
},
|
|
|
|
{
|
2019-03-22 09:57:14 +00:00
|
|
|
icon: 'group',
|
|
|
|
text: 'Groups',
|
|
|
|
route: 'GroupList',
|
|
|
|
role: null,
|
2018-12-21 16:10:39 +00:00
|
|
|
},
|
2019-03-22 09:57:14 +00:00
|
|
|
{ icon: 'settings', text: 'Settings', role: 'ROLE_USER' },
|
|
|
|
{ icon: 'chat_bubble', text: 'Send feedback', role: 'ROLE_USER' },
|
|
|
|
{ icon: 'help', text: 'Help', role: null },
|
|
|
|
{ icon: 'phonelink', text: 'App downloads', role: null },
|
2018-12-21 16:10:39 +00:00
|
|
|
];
|
|
|
|
error = {
|
|
|
|
timeout: 3000,
|
|
|
|
show: false,
|
2019-03-22 09:57:14 +00:00
|
|
|
text: '',
|
2018-12-21 16:10:39 +00:00
|
|
|
};
|
2019-01-18 13:47:10 +00:00
|
|
|
currentUser!: ICurrentUser;
|
2018-12-21 14:41:34 +00:00
|
|
|
|
2018-12-21 16:10:39 +00:00
|
|
|
actor = localStorage.getItem(AUTH_USER_ACTOR);
|
2018-12-21 14:41:34 +00:00
|
|
|
|
2019-01-18 13:47:10 +00:00
|
|
|
mounted () {
|
2019-03-22 09:57:14 +00:00
|
|
|
this.initializeCurrentUser();
|
2019-01-18 13:47:10 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 16:10:39 +00:00
|
|
|
get displayed_name () {
|
|
|
|
// FIXME: load actor
|
2019-03-22 09:57:14 +00:00
|
|
|
return 'no implemented';
|
2018-12-21 16:10:39 +00:00
|
|
|
// return this.actor.display_name === null ? this.actor.username : this.actor.display_name
|
|
|
|
}
|
2018-12-21 14:41:34 +00:00
|
|
|
|
2019-01-21 14:08:22 +00:00
|
|
|
showMenuItem(elem) {
|
2018-12-21 16:10:39 +00:00
|
|
|
// FIXME: load actor
|
|
|
|
return false;
|
|
|
|
// return elem !== null && this.user && this.user.roles !== undefined ? this.user.roles.includes(elem) : true
|
|
|
|
}
|
2018-12-21 14:41:34 +00:00
|
|
|
|
2019-01-21 14:08:22 +00:00
|
|
|
getUser (): ICurrentUser|false {
|
2019-01-18 13:47:10 +00:00
|
|
|
return this.currentUser.id ? this.currentUser : false;
|
2018-12-21 14:41:34 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 14:08:22 +00:00
|
|
|
toggleDrawer() {
|
2018-12-21 16:10:39 +00:00
|
|
|
this.drawer = !this.drawer;
|
|
|
|
}
|
2019-01-18 13:47:10 +00:00
|
|
|
|
|
|
|
private initializeCurrentUser() {
|
|
|
|
const userId = localStorage.getItem(AUTH_USER_ID);
|
|
|
|
const userEmail = localStorage.getItem(AUTH_USER_EMAIL);
|
|
|
|
const token = localStorage.getItem(AUTH_TOKEN);
|
|
|
|
|
|
|
|
if (userId && userEmail && token) {
|
|
|
|
return this.$apollo.mutate({
|
|
|
|
mutation: UPDATE_CURRENT_USER_CLIENT,
|
|
|
|
variables: {
|
|
|
|
id: userId,
|
|
|
|
email: userEmail,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2018-12-21 16:10:39 +00:00
|
|
|
}
|
2018-01-09 16:52:26 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2019-01-21 14:08:22 +00:00
|
|
|
.router-enter-active,
|
|
|
|
.router-leave-active {
|
|
|
|
transition-property: opacity;
|
|
|
|
transition-duration: 0.25s;
|
|
|
|
}
|
2018-07-04 12:29:17 +00:00
|
|
|
|
2019-01-21 14:08:22 +00:00
|
|
|
.router-enter-active {
|
|
|
|
transition-delay: 0.25s;
|
|
|
|
}
|
2018-07-04 12:29:17 +00:00
|
|
|
|
2019-01-21 14:08:22 +00:00
|
|
|
.router-enter,
|
|
|
|
.router-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
2018-01-09 16:52:26 +00:00
|
|
|
</style>
|