2024-11-23 12:55:41 -05:00
|
|
|
<script lang="ts" setup>
|
2024-11-24 20:50:39 -05:00
|
|
|
import {ref} from "vue";
|
2024-11-26 19:43:08 -05:00
|
|
|
import {useRouter} from "vue-router";
|
2024-11-24 20:50:39 -05:00
|
|
|
|
|
|
|
|
import Avatar from 'primevue/avatar';
|
|
|
|
|
import Menu from "primevue/menu";
|
|
|
|
|
|
|
|
|
|
import { userActions } from "@/stores/userActionsStore";
|
|
|
|
|
import { useUserStore } from "@/stores/userStore";
|
2024-11-22 19:38:29 -05:00
|
|
|
import Navigation from "@/components/Navigation.vue";
|
2024-11-24 20:50:39 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
const userStore = useUserStore();
|
2024-11-26 19:43:08 -05:00
|
|
|
const router = useRouter();
|
2024-11-24 20:50:39 -05:00
|
|
|
|
|
|
|
|
const logout = () => {
|
|
|
|
|
userStore.logout();
|
|
|
|
|
};
|
2024-11-26 19:43:08 -05:00
|
|
|
const profile = () => {
|
|
|
|
|
router.push({name: "profile"});
|
|
|
|
|
};
|
2024-11-24 20:50:39 -05:00
|
|
|
|
|
|
|
|
// Attach handlers.
|
|
|
|
|
userActions.map((item) => {
|
2024-11-26 19:43:08 -05:00
|
|
|
switch (item.cmd) {
|
|
|
|
|
case "logout":
|
|
|
|
|
item.command = logout;
|
|
|
|
|
break;
|
|
|
|
|
case "profile":
|
|
|
|
|
item.command = profile;
|
|
|
|
|
break;
|
2024-11-24 20:50:39 -05:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
const items = ref(userActions);
|
|
|
|
|
const menu = ref();
|
|
|
|
|
|
|
|
|
|
const toggle = (event) => { menu.value.toggle(event); };
|
2024-11-22 19:38:29 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-11-23 12:55:41 -05:00
|
|
|
<aside>
|
|
|
|
|
<Navigation></Navigation>
|
2024-11-24 20:50:39 -05:00
|
|
|
<div class="mt-auto act-avatar">
|
|
|
|
|
<a class="nav-item" @click="toggle">
|
|
|
|
|
<div v-if="userStore.isAnonymous">
|
|
|
|
|
<Avatar icon="pi pi-user" size="large" shape="circle" />
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else>
|
|
|
|
|
<Avatar v-bind:label="userStore.initials" size="large" shape="circle" />
|
|
|
|
|
</div>
|
|
|
|
|
<span class="inline lg:hidden">{{ userStore.user.name }}</span>
|
2024-11-23 12:55:41 -05:00
|
|
|
</a>
|
2024-11-24 20:50:39 -05:00
|
|
|
<Menu ref="menu" id="overlay_menu" :model="items" :popup="true">
|
|
|
|
|
<template #item="{ item, props }">
|
|
|
|
|
<a
|
|
|
|
|
class="flex items-center"
|
|
|
|
|
v-bind:class="{ 'act-useraction': item.needsAuth }"
|
|
|
|
|
v-bind="props.action"
|
|
|
|
|
v-if="!item.needsAuth || !userStore.isAnonymous">
|
|
|
|
|
<span v-bind:class="item.icon" />
|
|
|
|
|
<span>{{ item.label }}</span>
|
|
|
|
|
</a>
|
|
|
|
|
</template>
|
|
|
|
|
</Menu>
|
2024-11-22 19:38:29 -05:00
|
|
|
</div>
|
|
|
|
|
</aside>
|
|
|
|
|
</template>
|
2024-11-23 12:55:41 -05:00
|
|
|
|
2024-11-22 19:38:29 -05:00
|
|
|
<style scoped>
|
|
|
|
|
@import "@/assets/nav-items.css";
|
2024-11-23 12:55:41 -05:00
|
|
|
aside {
|
|
|
|
|
background-color: #333;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
height: 100%;
|
2024-11-24 20:50:39 -05:00
|
|
|
.act-avatar {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
2024-11-23 12:55:41 -05:00
|
|
|
}
|
|
|
|
|
@media (screen(sm)) {
|
|
|
|
|
aside {
|
|
|
|
|
flex-direction: column;
|
2024-11-24 20:50:39 -05:00
|
|
|
.act-avatar {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
2024-11-23 12:55:41 -05:00
|
|
|
}
|
|
|
|
|
}
|
2024-11-22 19:38:29 -05:00
|
|
|
</style>
|