2023-07-23 16:23:56 +02:00
|
|
|
<script setup lang="ts">
|
2023-09-04 16:43:51 +02:00
|
|
|
import type { User } from '@/composables/states'
|
|
|
|
|
2023-07-25 22:51:03 +02:00
|
|
|
const { t } = useI18n()
|
|
|
|
const isLoggedIn = useIsLoggedIn()
|
2023-09-04 16:43:51 +02:00
|
|
|
const settings = await useSettings()
|
|
|
|
const user = await useUser<User | null>()
|
2023-08-06 16:27:24 +02:00
|
|
|
const skipLink: Ref<HTMLLinkElement | null> = ref(null)
|
2023-07-26 04:30:24 +02:00
|
|
|
|
2023-07-25 22:51:03 +02:00
|
|
|
const footerLinks = [
|
|
|
|
{ text: t('footerlink_edit'), to: '/edit' },
|
|
|
|
{
|
|
|
|
text: t('footerlink_documentation'),
|
2023-08-23 11:44:18 +02:00
|
|
|
to: '//yunohost.org/user_guide',
|
2023-07-25 22:51:03 +02:00
|
|
|
newWindow: true,
|
|
|
|
},
|
|
|
|
{ text: t('footerlink_support'), to: '//yunohost.org/help', newWindow: true },
|
|
|
|
{
|
|
|
|
text: t('footerlink_administration'),
|
|
|
|
to: '/yunohost/admin/',
|
|
|
|
newWindow: true,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
async function logout() {
|
|
|
|
const { error } = await useApi('/logout')
|
|
|
|
|
|
|
|
if (!error.value) {
|
2023-09-04 16:43:51 +02:00
|
|
|
// Delete user infos
|
|
|
|
user.value = null
|
2023-07-25 22:51:03 +02:00
|
|
|
isLoggedIn.value = false
|
2023-09-04 16:43:51 +02:00
|
|
|
await navigateTo(settings.value.public ? '/' : '/login')
|
2023-07-25 22:51:03 +02:00
|
|
|
} else {
|
|
|
|
// FIXME : display an error or something
|
|
|
|
}
|
|
|
|
}
|
2023-07-23 16:23:56 +02:00
|
|
|
</script>
|
|
|
|
|
2023-07-12 04:52:58 +02:00
|
|
|
<template>
|
2023-07-26 01:25:42 +02:00
|
|
|
<div class="container mx-auto p-10 min-h-screen flex flex-col">
|
2023-11-14 18:33:23 +01:00
|
|
|
<header class="py-2">
|
2023-08-06 16:27:24 +02:00
|
|
|
<div class="h-10 -mt-10">
|
|
|
|
<a
|
|
|
|
id="skip-link"
|
|
|
|
ref="skipLink"
|
|
|
|
class="link sr-only focus:not-sr-only"
|
|
|
|
href="#main-target"
|
|
|
|
>{{ $t('skip_to_main_content') }}</a
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
|
2023-07-25 22:51:03 +02:00
|
|
|
<slot name="header">
|
|
|
|
<div class="flex flex-row flex-wrap items-center min-w-full">
|
2023-07-26 01:25:42 +02:00
|
|
|
<NuxtLink to="/">
|
|
|
|
<span class="sr-only">{{ t('back_to_apps') }}</span>
|
2023-11-20 14:19:23 +01:00
|
|
|
<YIcon name="account-circle" size="5em" class="me-3" />
|
2023-07-26 01:25:42 +02:00
|
|
|
</NuxtLink>
|
2023-07-25 22:51:03 +02:00
|
|
|
|
|
|
|
<div>
|
|
|
|
<h2 class="text-2xl font-extrabold leading-none tracking-tight">
|
2023-09-04 16:43:51 +02:00
|
|
|
{{ user?.username || t('visitor') }}
|
2023-07-25 22:51:03 +02:00
|
|
|
</h2>
|
2023-09-04 16:43:51 +02:00
|
|
|
<h3 v-if="user">{{ user.fullname }}</h3>
|
|
|
|
<h4 v-if="user" class="opacity-50">{{ user.mail }}</h4>
|
2023-07-25 22:51:03 +02:00
|
|
|
</div>
|
|
|
|
|
2023-11-18 17:07:39 +01:00
|
|
|
<div class="ms-auto">
|
|
|
|
<YButton
|
|
|
|
v-if="isLoggedIn"
|
|
|
|
icon="logout"
|
|
|
|
:text="t('logout')"
|
|
|
|
@click.prevent="logout"
|
|
|
|
/>
|
|
|
|
<YButton v-else icon="login" :text="t('login')" to="/login" />
|
2023-07-26 04:30:24 +02:00
|
|
|
</div>
|
2023-07-25 22:51:03 +02:00
|
|
|
</div>
|
|
|
|
</slot>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<main>
|
2023-07-19 18:42:05 +02:00
|
|
|
<slot />
|
2023-07-25 22:51:03 +02:00
|
|
|
</main>
|
2023-07-19 18:42:05 +02:00
|
|
|
|
2023-07-25 22:51:03 +02:00
|
|
|
<footer class="mt-auto">
|
2023-07-19 18:42:05 +02:00
|
|
|
<slot name="footer">
|
2023-07-25 22:51:03 +02:00
|
|
|
<div class="sm:flex flex-row flex-wrap items-end justify-center">
|
|
|
|
<nav
|
2023-11-20 14:19:23 +01:00
|
|
|
class="border-t border-gray-500 space-x-5 flex-wrap sm:me-5 text-center sm:text-left"
|
2023-07-25 22:51:03 +02:00
|
|
|
>
|
|
|
|
<NuxtLink
|
|
|
|
v-for="link in footerLinks"
|
|
|
|
:key="link.to"
|
|
|
|
:to="link.to"
|
|
|
|
:target="link.newWindow ? '_blank' : undefined"
|
|
|
|
class="link link-hover text-base-content inline-block"
|
|
|
|
>
|
|
|
|
{{ link.text }}
|
|
|
|
</NuxtLink>
|
2023-07-19 18:42:05 +02:00
|
|
|
</nav>
|
2023-07-25 22:51:03 +02:00
|
|
|
|
2023-11-20 14:19:23 +01:00
|
|
|
<CustomLogo class="mt-8 sm:mt-0 mx-auto sm:ms-auto sm:me-0" />
|
2023-07-12 04:52:58 +02:00
|
|
|
</div>
|
2023-07-19 18:42:05 +02:00
|
|
|
</slot>
|
|
|
|
</footer>
|
|
|
|
</div>
|
2023-07-12 04:52:58 +02:00
|
|
|
</template>
|