forked from tsai/budibase
18 changed files with 92 additions and 73 deletions
@ -0,0 +1,10 @@ |
|||||
|
import API from "./api" |
||||
|
|
||||
|
/** |
||||
|
* Fetches screen definition for an app. |
||||
|
*/ |
||||
|
export const fetchAppDefinition = async appId => { |
||||
|
return await API.get({ |
||||
|
url: `/api/applications/${appId}/definition`, |
||||
|
}) |
||||
|
} |
||||
@ -1,10 +1,10 @@ |
|||||
import api from "./api" |
import API from "./api" |
||||
|
|
||||
/** |
/** |
||||
* Fetches available routes for the client app. |
* Fetches available routes for the client app. |
||||
*/ |
*/ |
||||
export const fetchRoutes = async () => { |
export const fetchRoutes = async () => { |
||||
return await api.get({ |
return await API.get({ |
||||
url: `/api/routing/client`, |
url: `/api/routing/client`, |
||||
}) |
}) |
||||
} |
} |
||||
|
|||||
@ -1,14 +1,22 @@ |
|||||
<script> |
<script> |
||||
import { setContext } from "svelte" |
import { setContext, onMount } from "svelte" |
||||
import Component from "./Component.svelte" |
import Component from "./Component.svelte" |
||||
import SDK from "../sdk" |
import SDK from "../sdk" |
||||
|
import { routeStore, screenStore } from "../store" |
||||
|
|
||||
// Provide SDK for components |
// Provide SDK for components |
||||
setContext("app", SDK) |
setContext("app", SDK) |
||||
|
|
||||
const frontendDefinition = window["##BUDIBASE_FRONTEND_DEFINITION##"] |
let loaded = false |
||||
$: pageDefinition = frontendDefinition?.page?.props |
|
||||
$: console.log(frontendDefinition) |
// Load app config |
||||
|
onMount(async () => { |
||||
|
await routeStore.actions.fetchRoutes() |
||||
|
await screenStore.actions.fetchScreens() |
||||
|
loaded = true |
||||
|
}) |
||||
</script> |
</script> |
||||
|
|
||||
<Component definition={pageDefinition} /> |
{#if loaded} |
||||
|
<Component definition={$screenStore.page.props} /> |
||||
|
{/if} |
||||
|
|||||
Loading…
Reference in new issue