budibase/packages/frontend-core/src/components/Updating.svelte

81 lines
1.5 KiB
Svelte
Raw Normal View History

2024-01-08 11:11:46 +01:00
<script>
2024-01-08 13:33:41 +01:00
import { API } from "../api"
2024-01-08 12:09:24 +01:00
2024-01-08 11:11:46 +01:00
export let onMigrationDone
2024-01-08 12:51:29 +01:00
export let timeoutSeconds = 3 * 60 // 3 minutes
2024-01-08 11:11:46 +01:00
const loadTime = Date.now()
let timedOut = false
async function checkMigrationsFinished() {
setTimeout(async () => {
2024-01-08 12:09:24 +01:00
const response = await API.getMigrationStatus()
2024-01-08 12:51:29 +01:00
const timeoutMs = timeoutSeconds * 1000
2024-01-08 12:09:24 +01:00
if (!response.migrated) {
2024-01-08 11:11:46 +01:00
if (loadTime + timeoutMs > Date.now()) {
return checkMigrationsFinished()
}
return migrationTimeout()
}
onMigrationDone()
}, 1000)
}
checkMigrationsFinished()
function migrationTimeout() {
timedOut = true
}
</script>
<div class="loading" class:timeout={timedOut}>
2024-01-08 13:07:33 +01:00
<span class="header">
{#if !timedOut}
System update
{:else}
Something went wrong!
{/if}
</span>
<span class="subtext">
{#if !timedOut}
Please wait and we will be back in a second!
{:else}
An error occurred, please try again later.
<br />
2024-01-08 13:31:41 +01:00
Contact
<a href="https://budibase.com/support/" target="_blank">support</a> if the
issue persists.
2024-01-08 13:07:33 +01:00
{/if}</span
>
2024-01-08 11:11:46 +01:00
</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);
}
2024-01-08 13:31:41 +01:00
.subtext a {
color: var(--grey-7);
font-weight: 700;
}
2024-01-08 11:11:46 +01:00
</style>