-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTopHeader.vue
More file actions
66 lines (63 loc) · 1.72 KB
/
TopHeader.vue
File metadata and controls
66 lines (63 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
<div>
<b-navbar toggleable="sm" type="dark" variant="primary" class="shadow py-2">
<b-navbar-brand class="nav-brand" to="/">My Open Tab</b-navbar-brand>
<b-navbar-toggle target="nav-collapse"></b-navbar-toggle>
<b-collapse id="nav-collapse" is-nav>
<b-navbar-nav class="ml-auto">
<b-nav-item v-if="isAuth()" to="/dashboard"
><i class="fab fa-dyalog mt-1"></i
></b-nav-item>
<b-nav-item v-if="!isAuth()" to="/register">Register</b-nav-item>
<b-nav-item v-if="!isAuth()" to="/login">Login</b-nav-item>
<b-nav-item-dropdown
class="mt-1"
v-if="isAuth()"
v-bind:text="getLoggedInUser()"
right
>
<b-dropdown-item to="/profile">Profile</b-dropdown-item>
<b-dropdown-item v-if="isAdmin()" to="/users"
>Users</b-dropdown-item
>
<b-dropdown-item @click="logout">Logout</b-dropdown-item>
</b-nav-item-dropdown>
</b-navbar-nav>
</b-collapse>
</b-navbar>
</div>
</template>
<script>
export default {
name: "TopHeader",
methods: {
isAuth() {
return this.$store.getters["isAuthenticated"];
},
isAdmin() {
return this.$store.getters["isAdmin"];
},
getLoggedInUser() {
let user = null;
try {
user = JSON.parse(this.$store.state.auth.userInfo);
} catch (error) {
user = this.$store.state.auth.userInfo;
}
return user.firstName + " " + user.lastName;
},
logout() {
return this.$store.dispatch("logout");
},
},
};
</script>
<style>
.nav-brand {
font-size: 1.3rem;
}
.fa-th,
.fa-dyalog {
font-size: 1.4rem;
}
</style>