2023-07-19 18:42:05 +02:00
|
|
|
<script setup lang="ts">
|
|
|
|
const isLoggedIn = useIsLoggedIn()
|
|
|
|
|
2023-07-20 17:36:08 +02:00
|
|
|
const { data } = await useApi<{
|
|
|
|
username: string
|
|
|
|
fullname: string
|
|
|
|
mail: string
|
|
|
|
'mail-aliases': string[]
|
|
|
|
'mail-forward': string[]
|
|
|
|
groups: string[]
|
|
|
|
apps: Record<string, { label: string; url: string }>
|
|
|
|
}>('/me')
|
2023-07-19 18:42:05 +02:00
|
|
|
|
2023-07-20 17:36:08 +02:00
|
|
|
const me = computed(() => {
|
|
|
|
const appTileColors = [
|
|
|
|
'red',
|
|
|
|
'orange',
|
|
|
|
'yellow',
|
|
|
|
'lime',
|
|
|
|
'green',
|
|
|
|
'teal',
|
|
|
|
'indigo',
|
|
|
|
'sky',
|
|
|
|
'purple',
|
|
|
|
'rose',
|
|
|
|
]
|
|
|
|
if (!data.value) return
|
|
|
|
return {
|
|
|
|
...data.value,
|
|
|
|
apps: Object.entries(data.value.apps).map(([id, app]) => {
|
|
|
|
return {
|
|
|
|
...app,
|
|
|
|
id,
|
|
|
|
color: appTileColors[parseInt(app.label, 36) % appTileColors.length],
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
})
|
2023-07-19 18:42:05 +02:00
|
|
|
|
|
|
|
async function logout() {
|
2023-07-20 17:36:08 +02:00
|
|
|
const { error } = await useApi('/logout')
|
2023-07-19 18:42:05 +02:00
|
|
|
|
2023-07-20 17:36:08 +02:00
|
|
|
if (!error.value) {
|
2023-07-19 18:42:05 +02:00
|
|
|
// FIXME : meh, turns out the cookie is still valid after successfully calling the route for some reason ... !?
|
2023-07-20 17:36:08 +02:00
|
|
|
isLoggedIn.value = false
|
2023-07-19 18:42:05 +02:00
|
|
|
await navigateTo('/login')
|
2023-07-20 17:36:08 +02:00
|
|
|
} else {
|
|
|
|
// FIXME : display an error or something
|
2023-07-19 18:42:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2023-07-12 04:52:58 +02:00
|
|
|
|
2023-07-19 18:42:05 +02:00
|
|
|
<template>
|
2023-07-20 17:36:08 +02:00
|
|
|
<div v-if="me">
|
2023-07-19 18:42:05 +02:00
|
|
|
<div class="flex flex-row items-center min-w-full">
|
|
|
|
<span class="flex-none pr-5">
|
|
|
|
<Icon name="mdi:account-circle" size="5em" class="text-gray-500" />
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<div class="grow">
|
|
|
|
<h2 class="text-2xl font-extrabold leading-none tracking-tight">
|
|
|
|
{{ me.username }}
|
|
|
|
</h2>
|
|
|
|
<h3>{{ me.fullname }}</h3>
|
|
|
|
<h4 class="opacity-50">{{ me.mail }}</h4>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex-none">
|
|
|
|
<button class="btn bg-gray-800" @click.prevent="logout">
|
|
|
|
<Icon name="mdi:logout" class="text-gray-500" />
|
|
|
|
Logout
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-07-12 04:52:58 +02:00
|
|
|
|
2023-07-19 18:42:05 +02:00
|
|
|
<div id="apps" class="p-10">
|
2023-07-20 17:36:08 +02:00
|
|
|
<div v-if="!me.apps.length">
|
2023-07-19 18:42:05 +02:00
|
|
|
<em class="text-gray-400"
|
|
|
|
>There is no app to list here, either because no web app yet is
|
|
|
|
installed on the server, or because you don't have access to any.
|
|
|
|
Please check with the admins of the server for more infos!</em
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
|
2023-07-20 17:36:08 +02:00
|
|
|
<ul v-else class="flex space-x-4">
|
2023-07-19 18:42:05 +02:00
|
|
|
<!-- NB : because of the usage of dynamic colors, gotta force tailwind to expose those, cf 'safelisting' -->
|
|
|
|
<li
|
|
|
|
v-for="app in me.apps"
|
|
|
|
:key="app.id"
|
|
|
|
:class="
|
|
|
|
'text-center leading-none p-5 card h-32 w-32 bg-' +
|
|
|
|
app.color +
|
|
|
|
'-500'
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<a>
|
|
|
|
<div class="text-6xl font-extrabold">
|
|
|
|
{{ app.label.substring(0, 2) }}
|
2023-07-12 04:52:58 +02:00
|
|
|
</div>
|
2023-07-19 18:42:05 +02:00
|
|
|
<span class="leading-tight">{{ app.label }}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2023-07-12 04:52:58 +02:00
|
|
|
</div>
|
2023-07-19 18:42:05 +02:00
|
|
|
</div>
|
2023-07-12 04:52:58 +02:00
|
|
|
</template>
|