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";
|
|
|
|
|
|
2024-12-02 19:35:53 -05:00
|
|
|
import { type UserAction, userActions } from "@/stores/userActionsStore";
|
2024-12-01 20:54:21 -05:00
|
|
|
import { useSessionStore } from "@/stores/sessionStore";
|
2024-11-22 19:38:29 -05:00
|
|
|
import Navigation from "@/components/Navigation.vue";
|
2024-11-24 20:50:39 -05:00
|
|
|
|
|
|
|
|
|
2024-12-01 20:54:21 -05:00
|
|
|
const sessionStore = useSessionStore();
|
2024-11-26 19:43:08 -05:00
|
|
|
const router = useRouter();
|
2024-11-24 20:50:39 -05:00
|
|
|
|
|
|
|
|
const logout = () => {
|
2024-12-01 20:54:21 -05:00
|
|
|
sessionStore.logout();
|
2024-11-24 20:50:39 -05:00
|
|
|
};
|
2024-11-26 19:43:08 -05:00
|
|
|
const profile = () => {
|
|
|
|
|
router.push({name: "profile"});
|
|
|
|
|
};
|
2024-11-24 20:50:39 -05:00
|
|
|
|
|
|
|
|
// Attach handlers.
|
2024-12-02 19:35:53 -05:00
|
|
|
userActions.map((item: UserAction) => {
|
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();
|
|
|
|
|
|
2024-12-02 19:35:53 -05:00
|
|
|
const toggle = (event: 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">
|
2025-10-22 09:19:37 -04:00
|
|
|
<!-- TODO -->
|
2024-11-24 20:50:39 -05:00
|
|
|
<a class="nav-item" @click="toggle">
|
2024-12-01 20:54:21 -05:00
|
|
|
<div v-if="sessionStore.isAnonymous">
|
2024-11-24 20:50:39 -05:00
|
|
|
<Avatar icon="pi pi-user" size="large" shape="circle" />
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else>
|
2024-12-01 20:54:21 -05:00
|
|
|
<Avatar v-bind:label="sessionStore.initials" size="large" shape="circle" />
|
2024-11-24 20:50:39 -05:00
|
|
|
</div>
|
2024-12-04 09:01:43 -05:00
|
|
|
<span>{{ sessionStore.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"
|
2024-12-01 20:54:21 -05:00
|
|
|
v-if="!item.needsAuth || !sessionStore.isAnonymous">
|
2024-11-24 20:50:39 -05:00
|
|
|
<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>
|
2025-10-22 09:19:37 -04:00
|
|
|
@reference "tailwindcss";
|
|
|
|
|
@reference "tailwindcss-primeui";
|
|
|
|
|
|
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
|
|
|
}
|
2025-10-22 09:19:37 -04:00
|
|
|
/* Duplicated in Navigation.vue. */
|
|
|
|
|
.nav-item {
|
|
|
|
|
align-items: center;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
|
|
@apply hover:bg-surface-800 rounded-border text-surface-300 hover:text-white;
|
|
|
|
|
span {
|
|
|
|
|
@apply text-base;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@media (min-width: 640px) {
|
2024-11-23 12:55:41 -05:00
|
|
|
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>
|