Move updating page to the client

This commit is contained in:
Adria Navarro 2023-12-19 12:05:27 +01:00
parent 0b46b6883d
commit 75b8190c01
4 changed files with 20 additions and 4 deletions

View File

@ -1,3 +1,6 @@
<script>
</script>
<div class="loading">Updating the system...</div>
<style>

View File

@ -1,4 +1,5 @@
import ClientApp from "./components/ClientApp.svelte"
import UpdatingApp from "./components/UpdatingApp.svelte"
import {
builderStore,
appStore,
@ -52,6 +53,13 @@ const loadBudibase = async () => {
window["##BUDIBASE_APP_EMBEDDED##"] === "true"
)
if (window.MIGRATING_APP) {
new UpdatingApp({
target: window.document.body,
})
return
}
// Fetch environment info
if (!get(environmentStore)?.loaded) {
await environmentStore.actions.fetchEnvironment()

View File

@ -156,10 +156,6 @@ export const serveApp = async function (ctx: Ctx) {
appHbsPath = join(__dirname, "templates", "app.hbs")
}
const App = !needMigrations
? require("./templates/BudibaseApp.svelte").default
: require("./templates/Updating.svelte").default
let db
try {
db = context.getAppDB({ skip_setup: true })
@ -168,6 +164,7 @@ export const serveApp = async function (ctx: Ctx) {
if (!env.isJest()) {
const plugins = objectStore.enrichPluginURLs(appInfo.usedPlugins)
const App = require("./templates/BudibaseApp.svelte").default
const { head, html, css } = App.render({
metaImage:
branding?.metaImageUrl ||
@ -188,6 +185,7 @@ export const serveApp = async function (ctx: Ctx) {
config?.logoUrl !== ""
? objectStore.getGlobalFileUrl("settings", "logoUrl")
: "",
appMigrating: needMigrations,
})
const appHbs = loadHandlebarsFile(appHbsPath)
ctx.body = await processString(appHbs, {
@ -203,6 +201,7 @@ export const serveApp = async function (ctx: Ctx) {
}
} catch (error) {
if (!env.isJest()) {
const App = require("./templates/BudibaseApp.svelte").default
const { head, html, css } = App.render({
title: branding?.metaTitle,
metaTitle: branding?.metaTitle,

View File

@ -8,6 +8,7 @@
export let clientLibPath
export let usedPlugins
export let appMigrating
</script>
<svelte:head>
@ -110,6 +111,11 @@
<script type="application/javascript">
window.INIT_TIME = Date.now()
</script>
{#if appMigrating}
<script type="application/javascript">
window.MIGRATING_APP = true
</script>
{/if}
<script type="application/javascript" src={clientLibPath}>
</script>
<!-- Custom components need inserted after the core client library -->