mirror of https://github.com/Budibase/budibase.git
8 changed files with 156 additions and 25 deletions
@ -0,0 +1,35 @@ |
|||
import { writable } from "svelte/store" |
|||
import api from "../api" |
|||
|
|||
const INITIAL_BACKEND_UI_STATE = { |
|||
hostingInfo: {}, |
|||
appUrl: "", |
|||
} |
|||
|
|||
export const getHostingStore = () => { |
|||
const store = writable({...INITIAL_BACKEND_UI_STATE}) |
|||
store.actions = { |
|||
fetch: async () => { |
|||
const response = await api.get("/api/hosting/") |
|||
const info = await response.json() |
|||
store.update(state => { |
|||
state.hostingInfo = info |
|||
return state |
|||
}) |
|||
return info |
|||
}, |
|||
save: async hostingInfo => { |
|||
const response = await api.post("/api/hosting", hostingInfo) |
|||
const revision = (await response.json()).rev |
|||
store.update(state => { |
|||
state.hostingInfo = { |
|||
...hostingInfo, |
|||
_rev: revision, |
|||
} |
|||
return state |
|||
}) |
|||
} |
|||
} |
|||
|
|||
return store |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<script> |
|||
import { TextButton as Button, Modal } from "@budibase/bbui" |
|||
import BuilderSettingsModal from "./BuilderSettingsModal.svelte" |
|||
|
|||
let modal |
|||
</script> |
|||
|
|||
<div> |
|||
<Button text on:click={modal.show}> |
|||
<i class="ri-settings-3-fill"></i> |
|||
<p>Settings</p> |
|||
</Button> |
|||
</div> |
|||
<Modal bind:this={modal} width="30%"> |
|||
<BuilderSettingsModal /> |
|||
</Modal> |
|||
|
|||
<style> |
|||
div i { |
|||
font-size: 26px; |
|||
color: var(--grey-7); |
|||
margin-left: 12px; |
|||
} |
|||
|
|||
div p { |
|||
font-family: var(--font-sans); |
|||
font-size: var(--font-size-s); |
|||
color: var(--ink); |
|||
font-weight: 400; |
|||
margin: 0 0 0 12px; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,51 @@ |
|||
<script> |
|||
import { notifier } from "builderStore/store/notifications" |
|||
import { hostingStore } from "builderStore" |
|||
import { Input, ModalContent, Toggle } from "@budibase/bbui" |
|||
import analytics from "analytics" |
|||
import { onMount } from "svelte" |
|||
|
|||
let selfhosted = false |
|||
let hostingInfo |
|||
|
|||
async function save() { |
|||
if (!selfhosted) { |
|||
return |
|||
} |
|||
hostingInfo.type = selfhosted ? "self" : "cloud" |
|||
try { |
|||
await hostingStore.actions.save(hostingInfo) |
|||
notifier.success(`Settings saved.`) |
|||
} catch (err) { |
|||
notifier.danger(`Failed to update builder settings.`) |
|||
} |
|||
} |
|||
|
|||
onMount(async () => { |
|||
hostingInfo = await hostingStore.actions.fetch() |
|||
selfhosted = hostingInfo.type === "self" |
|||
|
|||
}) |
|||
</script> |
|||
|
|||
<ModalContent title="Builder settings" confirmText="Save" onConfirm={save} showConfirmButton={selfhosted}> |
|||
<h5>Hosting</h5> |
|||
<p>This section contains settings that relate to the deployment and hosting of apps made in this builder.</p> |
|||
<Toggle thin text="Self hosted" bind:checked={selfhosted} /> |
|||
{#if selfhosted} |
|||
<Input bind:value={hostingInfo.appServerUrl} label="Apps URL" /> |
|||
<Input bind:value={hostingInfo.objectStoreUrl} label="Object store URL" /> |
|||
<Toggle thin text="HTTPS" bind:checked={hostingInfo.useHttps} /> |
|||
{/if} |
|||
</ModalContent> |
|||
|
|||
<style> |
|||
h5 { |
|||
margin: 0; |
|||
font-size: 14px; |
|||
} |
|||
p { |
|||
margin: 0; |
|||
font-size: 12px; |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue