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-11-30 15:59:41 +01:00
|
|
|
const queryMsg = useQueryMsg()
|
2023-09-04 16:43:51 +02:00
|
|
|
const settings = await useSettings()
|
|
|
|
const user = await useUser<User | 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'),
|
2023-11-30 16:55:54 +01:00
|
|
|
to: `//${settings.value.domain}/yunohost/admin/`,
|
2023-07-25 22:51:03 +02:00
|
|
|
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>
|
2024-02-21 00:25:06 +01:00
|
|
|
<div class="container mx-auto p-6 md:p-10 min-h-screen flex flex-col">
|
2023-11-30 15:59:41 +01:00
|
|
|
<BaseAlert
|
|
|
|
v-if="queryMsg"
|
|
|
|
variant="warning"
|
|
|
|
icon="alert-outline"
|
|
|
|
:message="t('ssowat.' + queryMsg)"
|
|
|
|
class="mb-4"
|
|
|
|
assertive
|
|
|
|
/>
|
|
|
|
|
2023-11-14 18:33:23 +01:00
|
|
|
<header class="py-2">
|
2023-11-22 15:48:25 +01:00
|
|
|
<div id="focus-reset" class="h-10 -mt-10 focus-target" tabindex="-1">
|
|
|
|
<a class="link sr-only focus:not-sr-only" href="#main-target">
|
|
|
|
{{ $t('skip_link.main_content') }}
|
|
|
|
</a>
|
2023-08-06 16:27:24 +02:00
|
|
|
<a
|
2023-11-22 15:48:25 +01:00
|
|
|
v-if="isLoggedIn"
|
2023-08-06 16:27:24 +02:00
|
|
|
class="link sr-only focus:not-sr-only"
|
2023-11-22 15:48:25 +01:00
|
|
|
href="#main-footer"
|
2023-08-06 16:27:24 +02:00
|
|
|
>
|
2023-11-22 15:48:25 +01:00
|
|
|
{{ $t('skip_link.footer') }}
|
|
|
|
</a>
|
2023-08-06 16:27:24 +02:00
|
|
|
</div>
|
|
|
|
|
2023-07-25 22:51:03 +02:00
|
|
|
<slot name="header">
|
2023-11-21 13:57:35 +01:00
|
|
|
<div class="flex flex-row items-center">
|
|
|
|
<NuxtLink to="/" class="me-5">
|
2023-07-26 01:25:42 +02:00
|
|
|
<span class="sr-only">{{ t('back_to_apps') }}</span>
|
2023-11-21 13:57:35 +01:00
|
|
|
<CustomLogo class="logo" />
|
2023-07-26 01:25:42 +02:00
|
|
|
</NuxtLink>
|
2023-07-25 22:51:03 +02:00
|
|
|
|
2023-11-21 13:57:35 +01:00
|
|
|
<div
|
2024-01-19 13:36:45 +01:00
|
|
|
class="flex flex-grow flex-wrap min-[500px]:w-full max-[500px]:flex-col max-[500px]:ms-auto"
|
2023-11-21 13:57:35 +01:00
|
|
|
>
|
2024-01-19 13:36:45 +01:00
|
|
|
<div v-if="user" class="flex-grow">
|
2024-02-09 15:28:40 +01:00
|
|
|
<!-- eslint-disable-next-line vuejs-accessibility/click-events-have-key-events vuejs-accessibility/no-static-element-interactions -->
|
|
|
|
<div
|
|
|
|
class="profile cursor-pointer flex flex-col"
|
|
|
|
@click="navigateTo('/edit')"
|
|
|
|
>
|
2024-01-19 13:36:45 +01:00
|
|
|
<span>
|
|
|
|
<span
|
|
|
|
class="text-2xl font-extrabold tracking-tight leading-none"
|
|
|
|
>
|
|
|
|
{{ user.username }}
|
|
|
|
</span>
|
|
|
|
<YIcon name="pencil" size="1.25em" class="ms-2" />
|
2023-11-23 17:07:54 +01:00
|
|
|
</span>
|
2024-01-19 13:36:45 +01:00
|
|
|
<span class="leading-none">{{ user.fullname }}</span>
|
|
|
|
<span class="opacity-50">{{ user.mail }}</span>
|
|
|
|
<NuxtLink to="/edit" class="link sr-only focus:not-sr-only">
|
|
|
|
{{ t('footerlink_edit') }}
|
|
|
|
</NuxtLink>
|
2023-11-23 17:07:54 +01:00
|
|
|
</div>
|
2023-11-21 13:57:35 +01:00
|
|
|
</div>
|
2024-02-09 15:28:40 +01:00
|
|
|
<p
|
|
|
|
v-else-if="settings.portal_title"
|
|
|
|
class="text-3xl font-bold flex-grow min-[800px]:text-center mb-3"
|
|
|
|
>
|
2024-01-19 13:36:45 +01:00
|
|
|
{{ settings.portal_title }}
|
|
|
|
</p>
|
2023-07-25 22:51:03 +02:00
|
|
|
|
2024-01-19 13:36:45 +01:00
|
|
|
<div class="max-[500px]:mt-2">
|
2023-11-21 13:57:35 +01:00
|
|
|
<YButton
|
|
|
|
v-if="isLoggedIn"
|
|
|
|
icon="logout"
|
|
|
|
:text="t('logout')"
|
|
|
|
@click.prevent="logout"
|
|
|
|
/>
|
|
|
|
<YButton v-else icon="login" :text="t('login')" to="/login" />
|
|
|
|
</div>
|
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-11-22 16:30:02 +01:00
|
|
|
<footer
|
|
|
|
v-if="isLoggedIn"
|
|
|
|
id="main-footer"
|
2024-01-19 13:36:45 +01:00
|
|
|
class="mt-auto focus-target border-t border-gray-500"
|
2023-11-22 16:30:02 +01:00
|
|
|
tabindex="-1"
|
|
|
|
>
|
2023-07-19 18:42:05 +02:00
|
|
|
<slot name="footer">
|
2023-11-21 13:57:35 +01:00
|
|
|
<nav
|
2024-01-19 13:36:45 +01:00
|
|
|
class="flex pt-2 flex-col flex-wrap text-center sm:space-x-5 sm:flex-row sm:inline-flex"
|
2023-11-21 13:57:35 +01: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"
|
2023-07-25 22:51:03 +02:00
|
|
|
>
|
2023-11-21 13:57:35 +01:00
|
|
|
{{ link.text }}
|
|
|
|
</NuxtLink>
|
|
|
|
</nav>
|
2023-07-19 18:42:05 +02:00
|
|
|
</slot>
|
|
|
|
</footer>
|
|
|
|
</div>
|
2023-07-12 04:52:58 +02:00
|
|
|
</template>
|
2023-11-21 13:57:35 +01:00
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
header .logo {
|
|
|
|
width: 100px;
|
|
|
|
}
|
2023-11-22 15:48:25 +01:00
|
|
|
|
2023-11-23 17:07:54 +01:00
|
|
|
header .profile:not(:hover) .nuxt-icon {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2023-11-22 15:48:25 +01:00
|
|
|
.focus-target:not(:focus-visible) {
|
|
|
|
outline: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
#focus-reset {
|
|
|
|
outline: none;
|
|
|
|
}
|
2023-11-21 13:57:35 +01:00
|
|
|
</style>
|