2018-01-09 17:52:26 +01:00
|
|
|
<template>
|
2019-01-21 15:08:22 +01:00
|
|
|
<nav class="navbar is-fixed-top" role="navigation" aria-label="main navigation">
|
|
|
|
<div class="navbar-brand">
|
|
|
|
<router-link class="navbar-item" :to="{ name: 'Home' }">Mobilizon</router-link>
|
2019-01-18 14:47:10 +01:00
|
|
|
|
2019-01-21 15:08:22 +01:00
|
|
|
<a
|
|
|
|
role="button"
|
|
|
|
class="navbar-burger burger"
|
|
|
|
aria-label="menu"
|
|
|
|
aria-expanded="false"
|
|
|
|
data-target="navbarBasicExample"
|
|
|
|
>
|
|
|
|
<span aria-hidden="true"></span>
|
|
|
|
<span aria-hidden="true"></span>
|
|
|
|
<span aria-hidden="true"></span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="navbar-end">
|
|
|
|
<div class="navbar-item">
|
|
|
|
<div class="buttons">
|
|
|
|
<router-link class="button is-primary" v-if="!currentUser.id" :to="{ name: 'Register' }">
|
|
|
|
<strong>
|
|
|
|
<translate>Sign up</translate>
|
|
|
|
</strong>
|
|
|
|
</router-link>
|
|
|
|
<router-link class="button is-light" v-if="!currentUser.id" :to="{ name: 'Login' }">
|
|
|
|
<translate>Log in</translate>
|
|
|
|
</router-link>
|
|
|
|
<router-link
|
|
|
|
class="button is-light"
|
2019-01-24 15:57:45 +01:00
|
|
|
v-if="currentUser.id && loggedPerson"
|
2019-01-21 15:08:22 +01:00
|
|
|
:to="{ name: 'Profile', params: { name: loggedPerson.preferredUsername} }"
|
|
|
|
>
|
|
|
|
<figure class="image is-24x24">
|
|
|
|
<img :src="loggedPerson.avatarUrl">
|
|
|
|
</figure>
|
|
|
|
<span>{{ loggedPerson.preferredUsername }}</span>
|
|
|
|
</router-link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
2018-01-09 17:52:26 +01:00
|
|
|
</template>
|
|
|
|
|
2018-12-21 15:41:34 +01:00
|
|
|
<script lang="ts">
|
2019-01-24 15:57:45 +01:00
|
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
|
|
import { AUTH_USER_ACTOR } from "@/constants";
|
|
|
|
import { SEARCH } from "@/graphql/search";
|
|
|
|
import { CURRENT_USER_CLIENT } from "@/graphql/user";
|
|
|
|
import { onLogout } from "@/vue-apollo";
|
|
|
|
import { deleteUserData } from "@/utils/auth";
|
2019-01-21 15:08:22 +01:00
|
|
|
import { LOGGED_PERSON } from "@/graphql/actor";
|
|
|
|
import { IPerson } from "../types/actor.model";
|
2018-12-21 15:41:34 +01:00
|
|
|
|
2019-01-24 15:57:45 +01:00
|
|
|
@Component({
|
2018-12-21 17:10:39 +01:00
|
|
|
apollo: {
|
|
|
|
search: {
|
|
|
|
query: SEARCH,
|
|
|
|
variables() {
|
|
|
|
return {
|
2019-01-24 15:57:45 +01:00
|
|
|
searchText: this.searchText
|
2018-12-21 17:10:39 +01:00
|
|
|
};
|
2018-11-06 10:30:27 +01:00
|
|
|
},
|
2018-12-21 17:10:39 +01:00
|
|
|
skip() {
|
|
|
|
return !this.searchText;
|
2019-01-24 15:57:45 +01:00
|
|
|
}
|
2018-12-21 17:10:39 +01:00
|
|
|
},
|
2019-01-18 14:47:10 +01:00
|
|
|
currentUser: {
|
|
|
|
query: CURRENT_USER_CLIENT
|
2019-01-21 15:08:22 +01:00
|
|
|
},
|
|
|
|
loggedPerson: {
|
|
|
|
query: LOGGED_PERSON
|
2019-01-18 14:47:10 +01:00
|
|
|
}
|
2019-01-24 15:57:45 +01:00
|
|
|
}
|
2018-12-21 17:10:39 +01:00
|
|
|
})
|
|
|
|
export default class NavBar extends Vue {
|
|
|
|
notifications = [
|
2019-01-21 15:08:22 +01:00
|
|
|
{ header: "Coucou" },
|
|
|
|
{ title: "T'as une notification", subtitle: "Et elle est cool" }
|
2018-12-21 17:10:39 +01:00
|
|
|
];
|
|
|
|
model = null;
|
|
|
|
search: any[] = [];
|
|
|
|
searchText: string | null = null;
|
|
|
|
searchSelect = null;
|
2019-01-21 15:08:22 +01:00
|
|
|
loggedPerson!: IPerson;
|
2018-12-21 15:41:34 +01:00
|
|
|
|
2018-12-21 17:10:39 +01:00
|
|
|
get items() {
|
|
|
|
return this.search.map(searchEntry => {
|
|
|
|
switch (searchEntry.__typename) {
|
2019-01-21 15:08:22 +01:00
|
|
|
case "Actor":
|
|
|
|
searchEntry.label =
|
|
|
|
searchEntry.preferredUsername +
|
|
|
|
(searchEntry.domain === null ? "" : `@${searchEntry.domain}`);
|
2018-12-21 17:10:39 +01:00
|
|
|
break;
|
2019-01-21 15:08:22 +01:00
|
|
|
case "Event":
|
2018-12-21 17:10:39 +01:00
|
|
|
searchEntry.label = searchEntry.title;
|
2018-12-21 15:41:34 +01:00
|
|
|
break;
|
|
|
|
}
|
2018-12-21 17:10:39 +01:00
|
|
|
return searchEntry;
|
|
|
|
});
|
|
|
|
}
|
2018-12-21 15:41:34 +01:00
|
|
|
|
2019-01-21 15:08:22 +01:00
|
|
|
@Watch("model")
|
2018-12-21 17:10:39 +01:00
|
|
|
onModelChanged(val) {
|
|
|
|
switch (val.__typename) {
|
2019-01-21 15:08:22 +01:00
|
|
|
case "Event":
|
|
|
|
this.$router.push({ name: "Event", params: { uuid: val.uuid } });
|
2018-12-21 17:10:39 +01:00
|
|
|
break;
|
2019-01-21 15:08:22 +01:00
|
|
|
case "Actor":
|
|
|
|
this.$router.push({
|
|
|
|
name: "Profile",
|
|
|
|
params: { name: this.username_with_domain(val) }
|
|
|
|
});
|
2018-12-21 17:10:39 +01:00
|
|
|
break;
|
2018-12-21 15:41:34 +01:00
|
|
|
}
|
2018-12-21 17:10:39 +01:00
|
|
|
}
|
2018-12-21 15:41:34 +01:00
|
|
|
|
2018-12-21 17:10:39 +01:00
|
|
|
username_with_domain(actor) {
|
2019-01-21 15:08:22 +01:00
|
|
|
return (
|
|
|
|
actor.preferredUsername +
|
|
|
|
(actor.domain === null ? "" : `@${actor.domain}`)
|
|
|
|
);
|
2018-12-21 17:10:39 +01:00
|
|
|
}
|
2018-07-04 14:29:17 +02:00
|
|
|
|
2018-12-21 17:10:39 +01:00
|
|
|
enter() {
|
2019-01-21 15:08:22 +01:00
|
|
|
console.log("enter");
|
|
|
|
this.$apollo.queries["search"].refetch();
|
2018-12-21 15:41:34 +01:00
|
|
|
}
|
|
|
|
|
2019-01-18 14:47:10 +01:00
|
|
|
logout() {
|
2019-01-24 15:57:45 +01:00
|
|
|
alert("logout !");
|
2019-01-18 14:47:10 +01:00
|
|
|
|
|
|
|
deleteUserData();
|
|
|
|
|
|
|
|
return onLogout(this.$apollo);
|
|
|
|
}
|
2018-12-21 17:10:39 +01:00
|
|
|
}
|
2018-12-21 15:41:34 +01:00
|
|
|
</script>
|