1
0
Fork 0
mirror of synced 2024-10-02 10:08:09 +13:00

Move ui to frontend-core

This commit is contained in:
Adria Navarro 2024-01-08 11:11:46 +01:00
parent b115ead329
commit a427b322be
3 changed files with 71 additions and 55 deletions

View file

@ -1,65 +1,19 @@
<script>
import { Updating } from "@budibase/frontend-core"
import { redirect, params } from "@roxi/routify"
import { API } from "api"
const timeoutMs = 180000 // 3 minutes
const loadTime = Date.now()
let timedOut = false
async function checkMigrationsFinished() {
setTimeout(async () => {
const response = await API.getMigrationStatus()
if (!response.migrated) {
if (loadTime + timeoutMs > Date.now()) {
return checkMigrationsFinished()
}
return migrationTimeout()
}
// For some reason routify params is not stripping the ? properly, so we need to check both with and without ?
const returnUrl = $params.returnUrl || $params["?returnUrl"]
$redirect(returnUrl)
}, 1000)
async function isMigrationDone() {
const response = await API.getMigrationStatus()
return response.migrated
}
checkMigrationsFinished()
function migrationTimeout() {
timedOut = true
async function onMigrationDone() {
// For some reason routify params is not stripping the ? properly, so we need to check both with and without ?
const returnUrl = $params.returnUrl || $params["?returnUrl"]
$redirect(returnUrl)
}
$: text = !timedOut ? "System update" : "Something went wrong!"
$: subtext = !timedOut
? "Please wait and we will be back in a second!"
: "An error occurred, please try again later"
</script>
<div class="loading" class:timeout={timedOut}>
<span class="header">{text}</span>
<span class="subtext">{subtext}</span>
</div>
<style>
.loading {
display: flex;
justify-content: center;
flex-direction: column;
gap: var(--spacing-l);
height: 100vh;
text-align: center;
font-size: 18px;
}
.header {
font-weight: 700;
}
.timeout .header {
color: rgb(196, 46, 46);
}
.subtext {
font-size: 16px;
color: var(--grey-7);
}
</style>
<Updating timeoutMs={180000} {isMigrationDone} {onMigrationDone} />

View file

@ -0,0 +1,61 @@
<script>
export let isMigrationDone
export let onMigrationDone
export let timeoutMs = 180000 // 3 minutes
const loadTime = Date.now()
let timedOut = false
async function checkMigrationsFinished() {
setTimeout(async () => {
const isMigrated = await isMigrationDone()
if (!isMigrated) {
if (loadTime + timeoutMs > Date.now()) {
return checkMigrationsFinished()
}
return migrationTimeout()
}
onMigrationDone()
}, 1000)
}
checkMigrationsFinished()
function migrationTimeout() {
timedOut = true
}
$: text = !timedOut ? "System update" : "Something went wrong!"
$: subtext = !timedOut
? "Please wait and we will be back in a second!"
: "An error occurred, please try again later"
</script>
<div class="loading" class:timeout={timedOut}>
<span class="header">{text}</span>
<span class="subtext">{subtext}</span>
</div>
<style>
.loading {
display: flex;
justify-content: center;
flex-direction: column;
gap: var(--spacing-l);
height: 100vh;
text-align: center;
font-size: 18px;
}
.header {
font-weight: 700;
}
.timeout .header {
color: rgb(196, 46, 46);
}
.subtext {
font-size: 16px;
color: var(--grey-7);
}
</style>

View file

@ -3,4 +3,5 @@ export { default as TestimonialPage } from "./TestimonialPage.svelte"
export { default as Testimonial } from "./Testimonial.svelte"
export { default as UserAvatar } from "./UserAvatar.svelte"
export { default as UserAvatars } from "./UserAvatars.svelte"
export { default as Updating } from "./Updating.svelte"
export { Grid } from "./grid"