2024-05-12 10:37:57 +02:00
|
|
|
<template>
|
|
|
|
|
<div v-if="loading" class="fixed inset-0 bg-black z-[500] flex items-center justify-center">
|
|
|
|
|
<!-- Progress bar stuck to top -->
|
2024-06-16 03:42:48 +02:00
|
|
|
<div class="fixed top-0 left-0 right-0 h-1.5 bg-primary-500" :style="{ width: `${progress}%` }"></div>
|
2024-05-12 10:37:57 +02:00
|
|
|
<div class="flex flex-col items-center justify-center gap-8">
|
2024-06-15 23:18:58 +02:00
|
|
|
<img src="/logo.webp" class="size-20 animate-pulse" role="presentation" />
|
2024-05-12 10:37:57 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
const loading = ref(true);
|
2024-06-20 03:40:13 +02:00
|
|
|
const params = useUrlSearchParams();
|
2024-05-12 10:37:57 +02:00
|
|
|
|
2024-05-12 11:23:38 +02:00
|
|
|
const estimatedProgress = (duration: number, elapsed: number) =>
|
|
|
|
|
(2 / Math.PI) * 100 * Math.atan(((elapsed / duration) * 100) / 50);
|
2024-05-12 10:37:57 +02:00
|
|
|
|
|
|
|
|
const progress = ref(0);
|
|
|
|
|
const timeAtStart = performance.now();
|
|
|
|
|
const app = useNuxtApp();
|
|
|
|
|
|
|
|
|
|
const duration = 3000;
|
|
|
|
|
|
|
|
|
|
useIntervalFn(() => {
|
|
|
|
|
const elapsed = performance.now() - timeAtStart;
|
|
|
|
|
progress.value = estimatedProgress(duration, elapsed);
|
|
|
|
|
}, 1000 / 60);
|
|
|
|
|
|
|
|
|
|
app.hook("page:finish", async () => {
|
2024-06-16 05:14:13 +02:00
|
|
|
// Wait until page has loaded for at least 300ms
|
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 300));
|
2024-05-12 10:37:57 +02:00
|
|
|
loading.value = false;
|
2024-05-17 08:25:59 +02:00
|
|
|
|
2024-06-20 03:40:13 +02:00
|
|
|
if (params.oidc_account_linking_error) {
|
2024-05-17 08:25:59 +02:00
|
|
|
useEvent("notification:new", {
|
|
|
|
|
type: "error",
|
2024-06-20 03:40:13 +02:00
|
|
|
title: params.oidc_account_linking_error,
|
|
|
|
|
description: params.oidc_account_linking_error_message ?? undefined,
|
|
|
|
|
duration: 999999,
|
|
|
|
|
onStatusChange: (details) => {
|
|
|
|
|
if (details.status === "dismissing") {
|
|
|
|
|
// Remove data from URL
|
|
|
|
|
window.history.replaceState(
|
|
|
|
|
{},
|
|
|
|
|
document.title,
|
|
|
|
|
window.location.pathname,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-05-17 08:25:59 +02:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-20 03:40:13 +02:00
|
|
|
if (params.oidc_account_linked) {
|
2024-05-17 08:25:59 +02:00
|
|
|
useEvent("notification:new", {
|
2024-05-17 08:47:49 +02:00
|
|
|
type: "success",
|
2024-05-17 08:25:59 +02:00
|
|
|
title: "Account linked",
|
2024-06-20 03:40:13 +02:00
|
|
|
description:
|
2024-05-17 08:25:59 +02:00
|
|
|
"Your account has been successfully linked to your OpenID Connect provider.",
|
2024-06-20 03:40:13 +02:00
|
|
|
duration: 999999,
|
|
|
|
|
onStatusChange: (details) => {
|
|
|
|
|
if (details.status === "dismissing") {
|
|
|
|
|
// Remove data from URL
|
|
|
|
|
window.history.replaceState(
|
|
|
|
|
{},
|
|
|
|
|
document.title,
|
|
|
|
|
window.location.pathname,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-05-17 08:25:59 +02:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-05-12 10:37:57 +02:00
|
|
|
});
|
|
|
|
|
</script>
|