Implementing feature #1700 and making it possible to remove logo.

This commit is contained in:
mike12345567 2021-06-21 18:01:25 +01:00
parent ed5dd08c66
commit 61d810edfe
8 changed files with 56 additions and 12 deletions

View File

@ -9,6 +9,7 @@
} from "@budibase/bbui"
import { organisation, auth } from "stores/portal"
import Logo from "assets/bb-emblem.svg"
import { onMount } from "svelte"
let email = ""
@ -20,6 +21,10 @@
notifications.error("Unable to send reset password link")
}
}
onMount(async () => {
await organisation.init()
})
</script>
<div class="login">

View File

@ -10,13 +10,16 @@
notifications,
} from "@budibase/bbui"
import { goto, params } from "@roxi/routify"
import { auth } from "stores/portal"
import { auth, organisation } from "stores/portal"
import GoogleButton from "./_components/GoogleButton.svelte"
import Logo from "assets/bb-emblem.svg"
import { onMount } from "svelte"
let username = ""
let password = ""
$: company = $organisation.company || "Budibase"
async function login() {
try {
await auth.login({
@ -43,6 +46,10 @@
function handleKeydown(evt) {
if (evt.key === "Enter") login()
}
onMount(async () => {
await organisation.init()
})
</script>
<svelte:window on:keydown={handleKeydown} />
@ -50,8 +57,8 @@
<div class="main">
<Layout>
<Layout noPadding justifyItems="center">
<img alt="logo" src={Logo} />
<Heading>Sign in to Budibase</Heading>
<img alt="logo" src={$organisation.logoUrl || Logo} />
<Heading>Sign in to {company}</Heading>
</Layout>
<GoogleButton />
<Divider noGrid />
@ -66,7 +73,7 @@
/>
</Layout>
<Layout gap="XS" noPadding>
<Button cta on:click={login}>Sign in to Budibase</Button>
<Button cta on:click={login}>Sign in to {company}</Button>
<ActionButton quiet on:click={() => $goto("./forgot")}>
Forgot password?
</ActionButton>

View File

@ -2,8 +2,9 @@
import { Body, Button, Heading, Layout, notifications } from "@budibase/bbui"
import { goto, params } from "@roxi/routify"
import PasswordRepeatInput from "components/common/users/PasswordRepeatInput.svelte"
import { auth } from "stores/portal"
import { auth, organisation } from "stores/portal"
import Logo from "assets/bb-emblem.svg"
import { onMount } from "svelte"
const resetCode = $params["?code"]
let password, error
@ -28,13 +29,17 @@
notifications.error("Unable to reset password")
}
}
onMount(async () => {
await organisation.init()
})
</script>
<div class="login">
<div class="main">
<Layout>
<Layout noPadding justifyItems="center">
<img src={Logo} alt="Organisation logo" />
<img src={$organisation.logoUrl || Logo} alt="Organisation logo" />
</Layout>
<Layout gap="XS" noPadding>
<Heading textAlign="center">Reset your password</Heading>

View File

@ -57,11 +57,17 @@
await organisation.init()
}
// Update settings
const res = await organisation.save({
const config = {
company: $values.company ?? "",
platformUrl: $values.platformUrl ?? "",
})
}
// remove logo if required
if (!$values.logo) {
config.logoUrl = ""
}
// Update settings
const res = await organisation.save(config)
if (res.status === 200) {
notifications.success("Settings saved successfully")
} else {
@ -98,7 +104,11 @@
<Dropzone
value={[$values.logo]}
on:change={e => {
$values.logo = e.detail?.[0]
if (!e.detail || e.detail.length === 0) {
$values.logo = null
} else {
$values.logo = e.detail[0]
}
}}
/>
</div>

View File

@ -13,7 +13,7 @@ export function createOrganisationStore() {
const { subscribe, set } = store
async function init() {
const res = await api.get(`/api/admin/configs/settings`)
const res = await api.get(`/api/admin/configs/public`)
const json = await res.json()
if (json.status === 400) {

View File

@ -98,6 +98,18 @@ exports.find = async function (ctx) {
}
}
exports.publicSettings = async function (ctx) {
const db = new CouchDB(GLOBAL_DB)
try {
// Find the config with the most granular scope based on context
ctx.body = await getScopedFullConfig(db, {
type: Configs.SETTINGS,
})
} catch (err) {
ctx.throw(err.status, err)
}
}
exports.upload = async function (ctx) {
if (ctx.request.files == null || ctx.request.files.file.length > 1) {
ctx.throw(400, "One file must be uploaded.")

View File

@ -37,6 +37,10 @@ const PUBLIC_ENDPOINTS = [
route: "/api/apps",
method: "GET",
},
{
route: "/api/admin/configs/public",
method: "GET",
}
]
const router = new Router()

View File

@ -26,7 +26,7 @@ function settingValidation() {
// prettier-ignore
return Joi.object({
platformUrl: Joi.string().optional(),
logoUrl: Joi.string().optional(),
logoUrl: Joi.string().optional().allow("", null),
docsUrl: Joi.string().optional(),
company: Joi.string().required(),
}).unknown(true)
@ -91,6 +91,7 @@ router
buildConfigGetValidation(),
controller.fetch
)
.get("/api/admin/configs/public", controller.publicSettings)
.get("/api/admin/configs/:type", buildConfigGetValidation(), controller.find)
.post(
"/api/admin/configs/upload/:type/:name",