2020-03-31 11:50:13 +02:00
|
|
|
<script>
|
2020-05-26 10:38:43 +02:00
|
|
|
import { getContext } from "svelte"
|
2020-05-07 11:53:34 +02:00
|
|
|
import { store } from "builderStore"
|
2020-08-03 15:59:50 +02:00
|
|
|
import api from "builderStore/api"
|
2020-04-02 15:16:46 +02:00
|
|
|
import AppList from "components/start/AppList.svelte"
|
2020-03-31 11:50:13 +02:00
|
|
|
import { onMount } from "svelte"
|
2020-05-25 17:57:17 +02:00
|
|
|
import ActionButton from "components/common/ActionButton.svelte"
|
2020-06-03 18:05:36 +02:00
|
|
|
import { get } from "builderStore/api"
|
2020-04-02 15:16:46 +02:00
|
|
|
import Spinner from "components/common/Spinner.svelte"
|
2020-05-26 16:25:37 +02:00
|
|
|
import CreateAppModal from "components/start/CreateAppModal.svelte"
|
2020-07-02 12:02:31 +02:00
|
|
|
import { Button } from "@budibase/bbui"
|
2020-03-31 11:50:13 +02:00
|
|
|
|
|
|
|
let promise = getApps()
|
|
|
|
|
|
|
|
async function getApps() {
|
2020-06-03 18:05:36 +02:00
|
|
|
const res = await get("/api/applications")
|
2020-03-31 11:50:13 +02:00
|
|
|
const json = await res.json()
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
return json
|
|
|
|
} else {
|
|
|
|
throw new Error(json)
|
|
|
|
}
|
|
|
|
}
|
2020-05-25 17:57:17 +02:00
|
|
|
|
2020-08-03 15:59:50 +02:00
|
|
|
let hasKey
|
|
|
|
|
|
|
|
async function fetchKeys() {
|
|
|
|
const response = await api.get(`/api/keys/`)
|
|
|
|
const res = await response.json()
|
|
|
|
return res.budibase
|
|
|
|
}
|
|
|
|
|
|
|
|
async function checkIfKeysAndApps() {
|
|
|
|
const key = await fetchKeys()
|
|
|
|
const apps = await getApps()
|
|
|
|
if (key) {
|
|
|
|
hasKey = true
|
|
|
|
} else {
|
|
|
|
showCreateAppModal()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-26 10:38:43 +02:00
|
|
|
// Handle create app modal
|
|
|
|
const { open } = getContext("simple-modal")
|
2020-05-26 16:25:37 +02:00
|
|
|
|
2020-05-26 10:38:43 +02:00
|
|
|
const showCreateAppModal = () => {
|
|
|
|
open(
|
2020-05-26 16:25:37 +02:00
|
|
|
CreateAppModal,
|
2020-05-26 10:38:43 +02:00
|
|
|
{
|
2020-08-03 15:59:50 +02:00
|
|
|
hasKey,
|
2020-05-26 10:38:43 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
closeButton: false,
|
|
|
|
closeOnEsc: false,
|
|
|
|
closeOnOuterClick: false,
|
2020-05-26 16:25:37 +02:00
|
|
|
styleContent: { padding: 0 },
|
2020-05-27 12:54:53 +02:00
|
|
|
closeOnOuterClick: true,
|
2020-05-26 10:38:43 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2020-08-03 15:59:50 +02:00
|
|
|
|
|
|
|
checkIfKeysAndApps()
|
2020-05-26 10:38:43 +02:00
|
|
|
</script>
|
2020-05-25 17:57:17 +02:00
|
|
|
|
2020-07-02 12:02:31 +02:00
|
|
|
<div class="header">
|
|
|
|
<div class="welcome">Welcome to the Budibase Beta</div>
|
2020-08-11 18:02:54 +02:00
|
|
|
<Button primary purple on:click={showCreateAppModal}>
|
2020-08-11 17:57:15 +02:00
|
|
|
Create New Web App
|
|
|
|
</Button>
|
2020-07-02 12:02:31 +02:00
|
|
|
</div>
|
2020-06-04 12:56:01 +02:00
|
|
|
|
2020-05-26 10:38:43 +02:00
|
|
|
<div class="banner">
|
2020-07-02 12:02:31 +02:00
|
|
|
<img src="/_builder/assets/orange-landscape.png" alt="rocket" />
|
2020-06-04 20:30:44 +02:00
|
|
|
<div class="banner-content">
|
|
|
|
Every accomplishment starts with a decision to try.
|
|
|
|
</div>
|
2020-05-25 17:57:17 +02:00
|
|
|
</div>
|
2020-06-04 12:56:01 +02:00
|
|
|
|
2020-05-26 10:38:43 +02:00
|
|
|
{#await promise}
|
|
|
|
<div class="spinner-container">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
{:then result}
|
|
|
|
<AppList apps={result} />
|
|
|
|
{:catch err}
|
|
|
|
<h1 style="color:red">{err}</h1>
|
|
|
|
{/await}
|
2020-03-31 11:50:13 +02:00
|
|
|
|
|
|
|
<style>
|
2020-07-02 12:02:31 +02:00
|
|
|
.header {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
margin: 40px 80px 0px 80px;
|
|
|
|
}
|
|
|
|
|
2020-05-25 17:57:17 +02:00
|
|
|
.welcome {
|
2020-08-11 17:57:15 +02:00
|
|
|
font-size: var(--font-size-3xl);
|
2020-05-25 17:57:17 +02:00
|
|
|
color: var(--ink);
|
2020-08-11 17:57:15 +02:00
|
|
|
font-weight: 600;
|
2020-05-25 17:57:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.banner {
|
2020-06-04 12:56:01 +02:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
position: relative;
|
|
|
|
text-align: center;
|
|
|
|
color: white;
|
2020-05-25 17:57:17 +02:00
|
|
|
margin: 20px 80px 40px 80px;
|
2020-08-11 17:57:15 +02:00
|
|
|
border-radius: 16px;
|
2020-05-25 17:57:17 +02:00
|
|
|
}
|
2020-05-25 21:26:48 +02:00
|
|
|
|
2020-06-04 12:56:01 +02:00
|
|
|
.banner img {
|
|
|
|
height: 250px;
|
|
|
|
width: 100%;
|
|
|
|
border-radius: 5px;
|
2020-06-04 20:30:44 +02:00
|
|
|
}
|
2020-05-25 21:26:48 +02:00
|
|
|
|
2020-06-04 12:56:01 +02:00
|
|
|
.banner-content {
|
|
|
|
position: absolute;
|
2020-05-25 21:26:48 +02:00
|
|
|
font-size: 24px;
|
2020-05-25 17:57:17 +02:00
|
|
|
color: var(--white);
|
|
|
|
font-weight: 500;
|
2020-03-31 11:50:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.spinner-container {
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
</style>
|