Create config

This commit is contained in:
adrinr 2023-03-21 15:54:50 +00:00
parent 4a4ba487a0
commit 53020e2d2d
1 changed files with 41 additions and 0 deletions

View File

@ -31,6 +31,7 @@
const ConfigTypes = { const ConfigTypes = {
Google: "google", Google: "google",
OIDC: "oidc", OIDC: "oidc",
SCIM: "scim",
} }
const HasSpacesRegex = /[\\"\s]/ const HasSpacesRegex = /[\\"\s]/
@ -160,6 +161,8 @@
providers.oidc?.config?.configs[0].clientSecret providers.oidc?.config?.configs[0].clientSecret
) )
$: scimEnabled = true
const onFileSelected = e => { const onFileSelected = e => {
let fileName = e.target.files[0].name let fileName = e.target.files[0].name
image = e.target.files[0] image = e.target.files[0]
@ -253,6 +256,19 @@
originalGoogleDoc = cloneDeep(providers.google) originalGoogleDoc = cloneDeep(providers.google)
} }
async function saveSCIM() {
try {
const res = await saveConfig({
type: "scim",
enabled: scimEnabled,
})
notifications.success(`Settings saved`)
} catch (e) {
notifications.error(e.message)
return
}
}
let defaultScopes = ["profile", "email", "offline_access"] let defaultScopes = ["profile", "email", "offline_access"]
const refreshScopes = idx => { const refreshScopes = idx => {
@ -343,6 +359,14 @@
originalOidcDoc = cloneDeep(oidcDoc) originalOidcDoc = cloneDeep(oidcDoc)
providers.oidc = oidcDoc providers.oidc = oidcDoc
} }
try {
const scimConfig = await API.getConfig(ConfigTypes.SCIM)
scimEnabled = scimConfig?.enabled
} catch (error) {
console.error(error)
notifications.error("Error fetching SCIM config")
}
}) })
</script> </script>
@ -606,11 +630,28 @@
</Tags> </Tags>
</div> </div>
</Layout> </Layout>
<div> <div>
<Button disabled={oidcSaveButtonDisabled} cta on:click={() => saveOIDC()}> <Button disabled={oidcSaveButtonDisabled} cta on:click={() => saveOIDC()}>
Save Save
</Button> </Button>
</div> </div>
<Divider />
<Layout gap="XS" noPadding>
<div class="provider-title">
<Heading size="S">SCIM</Heading>
</div>
<Body size="S">Sync users with your identity provider.</Body>
<div class="form-row">
<Label size="L">Activated</Label>
<Toggle text="" bind:value={scimEnabled} />
</div>
</Layout>
<div>
<Button cta on:click={saveSCIM}>Save</Button>
</div>
{/if} {/if}
</Layout> </Layout>