mirror of https://github.com/Budibase/budibase.git
13 changed files with 194 additions and 33 deletions
@ -1,11 +0,0 @@ |
|||
import { writable } from "svelte/store" |
|||
|
|||
const INITIAL_ADMIN_STATE = { |
|||
oauth: [], |
|||
} |
|||
|
|||
export const getAdminStore = () => { |
|||
const store = writable({ ...INITIAL_ADMIN_STATE }) |
|||
store.actions = {} |
|||
return store |
|||
} |
|||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,111 @@ |
|||
<script> |
|||
import { |
|||
Layout, |
|||
Heading, |
|||
Body, |
|||
Button, |
|||
Divider, |
|||
Label, |
|||
Input, |
|||
Toggle, |
|||
Dropzone, |
|||
notifications, |
|||
} from "@budibase/bbui" |
|||
import { organisation } from "stores/portal" |
|||
import analytics from "analytics" |
|||
let analyticsDisabled = analytics.disabled() |
|||
|
|||
function toggleAnalytics() { |
|||
if (analyticsDisabled) { |
|||
analytics.optIn() |
|||
} else { |
|||
analytics.optOut() |
|||
} |
|||
} |
|||
|
|||
let loading = false |
|||
|
|||
$: company = $organisation?.company |
|||
$: logoUrl = $organisation.logoUrl |
|||
|
|||
async function saveConfig() { |
|||
loading = true |
|||
await toggleAnalytics() |
|||
const res = await organisation.save({ ...$organisation, company }) |
|||
if (res.status === 200) { |
|||
notifications.success("General settings saved.") |
|||
} else { |
|||
notifications.danger("Error when saving settings.") |
|||
} |
|||
loading = false |
|||
} |
|||
</script> |
|||
|
|||
<div class="container"> |
|||
<Layout noPadding> |
|||
<div class="intro"> |
|||
<Heading size="M">General</Heading> |
|||
<Body |
|||
>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Hic vero, aut |
|||
culpa provident sunt ratione! Voluptas doloremque, dicta nisi velit |
|||
perspiciatis, ratione vel blanditiis totam, nam voluptate repellat |
|||
aperiam fuga!</Body |
|||
> |
|||
</div> |
|||
<Divider size="S" /> |
|||
<div class="information"> |
|||
<Heading size="S">Information</Heading> |
|||
<Body>Here you can update your logo and organization name.</Body> |
|||
<div class="fields"> |
|||
<div class="field"> |
|||
<Label>Organization name</Label> |
|||
<Input thin bind:value={company} /> |
|||
</div> |
|||
<!-- <div class="field"> |
|||
<Label>Logo</Label> |
|||
<div class="file"> |
|||
<Dropzone /> |
|||
</div> |
|||
</div> --> |
|||
</div> |
|||
</div> |
|||
<Divider size="S" /> |
|||
<div class="analytics"> |
|||
<Heading size="S">Analytics</Heading> |
|||
<Body |
|||
>If you would like to send analytics that help us make Budibase better, |
|||
please let us know below.</Body |
|||
> |
|||
<div class="fields"> |
|||
<div class="field"> |
|||
<Label>Send Analytics to Budibase</Label> |
|||
<Toggle text="" value={!analyticsDisabled} /> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="save"> |
|||
<Button disabled={loading} on:click={saveConfig} cta>Save</Button> |
|||
</div> |
|||
</Layout> |
|||
</div> |
|||
|
|||
<style> |
|||
.fields { |
|||
display: grid; |
|||
grid-gap: var(--spacing-m); |
|||
margin-top: var(--spacing-xl); |
|||
} |
|||
.field { |
|||
display: grid; |
|||
grid-template-columns: 30% 1fr; |
|||
} |
|||
.file { |
|||
max-width: 30ch; |
|||
} |
|||
.intro { |
|||
display: grid; |
|||
} |
|||
.save { |
|||
margin-left: auto; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,4 @@ |
|||
<script> |
|||
import { goto } from "@roxi/routify" |
|||
$goto("./general") |
|||
</script> |
|||
@ -0,0 +1,7 @@ |
|||
import { writable } from "svelte/store" |
|||
|
|||
const INITIAL_ADMIN_STATE = { |
|||
oauth: [], |
|||
} |
|||
|
|||
export const admin = writable({ ...INITIAL_ADMIN_STATE }) |
|||
@ -0,0 +1,2 @@ |
|||
export { organisation } from "./organisation" |
|||
export { admin } from "./admin" |
|||
@ -0,0 +1,37 @@ |
|||
import { writable } from "svelte/store" |
|||
import api from "builderStore/api" |
|||
|
|||
export function createOrganisationStore() { |
|||
const { subscribe, set } = writable({}) |
|||
|
|||
async function init() { |
|||
try { |
|||
const response = await api.get(`/api/admin/configs/settings`) |
|||
const json = await response.json() |
|||
set(json) |
|||
} catch (error) { |
|||
set({ |
|||
platformUrl: "", |
|||
logoUrl: "", |
|||
docsUrl: "", |
|||
company: "", |
|||
}) |
|||
} |
|||
} |
|||
|
|||
return { |
|||
subscribe, |
|||
save: async config => { |
|||
try { |
|||
await api.post("/api/admin/configs", { type: "settings", config }) |
|||
await init() |
|||
return { status: 200 } |
|||
} catch (error) { |
|||
return { error } |
|||
} |
|||
}, |
|||
init, |
|||
} |
|||
} |
|||
|
|||
export const organisation = createOrganisationStore() |
|||
Loading…
Reference in new issue