user creation
This commit is contained in:
parent
30e33b7ee0
commit
a91b89b7c2
|
@ -11,20 +11,11 @@
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
background: var(--primary100);
|
background: var(--secondary80);
|
||||||
color: var(--white);
|
color: var(--white);
|
||||||
font-family: "Courier New", Courier, monospace;
|
font-family: "Courier New", Courier, monospace;
|
||||||
width: 95%;
|
width: 95%;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
|
||||||
margin-left: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import api from "../../builderStore/api"
|
import api from "../../builderStore/api"
|
||||||
import { getNewRecord, getNewInstance } from "../../common/core"
|
import { getNewRecord, getNewInstance } from "../../common/core"
|
||||||
|
|
||||||
|
export async function createUser(user, { appname, instanceId }) {
|
||||||
|
const CREATE_USER_URL = `/_builder/instance/${appname}/${instanceId}/api/createUser`
|
||||||
|
const response = await api.post(CREATE_USER_URL, user)
|
||||||
|
return await response.json()
|
||||||
|
}
|
||||||
|
|
||||||
export async function createDatabase(appname, instanceName) {
|
export async function createDatabase(appname, instanceName) {
|
||||||
const CREATE_DATABASE_URL = `/_builder/instance/_master/0/api/record/`
|
const CREATE_DATABASE_URL = `/_builder/instance/_master/0/api/record/`
|
||||||
const database = getNewInstance(appname, instanceName)
|
const database = getNewInstance(appname, instanceName)
|
||||||
|
|
|
@ -1,30 +1,51 @@
|
||||||
<script>
|
<script>
|
||||||
import Modal from "../../../common/Modal.svelte"
|
import Modal from "../../../common/Modal.svelte"
|
||||||
import { store } from "../../../builderStore"
|
import { store, backendUiStore } from "../../../builderStore"
|
||||||
import ActionButton from "../../../common/ActionButton.svelte"
|
import ActionButton from "../../../common/ActionButton.svelte"
|
||||||
// import * as api from "../api"
|
import * as api from "../api"
|
||||||
|
|
||||||
export let onClosed
|
export let onClosed
|
||||||
|
|
||||||
let userName
|
let username
|
||||||
|
let password
|
||||||
|
let accessLevels = []
|
||||||
|
|
||||||
|
$: valid = username && password && accessLevels.length
|
||||||
|
$: currentAppInfo = {
|
||||||
|
appname: $store.appname,
|
||||||
|
instanceId: $backendUiStore.selectedDatabase.id,
|
||||||
|
}
|
||||||
|
|
||||||
async function createUser() {
|
async function createUser() {
|
||||||
// const response = await api.createUser($store.appname, userName)
|
const response = await api.createUser(
|
||||||
// store.createUserForInstance(response)
|
{
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
accessLevels,
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
currentAppInfo
|
||||||
|
)
|
||||||
onClosed()
|
onClosed()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<form class="uk-form-stacked">
|
||||||
User Name
|
<label class="uk-form-label" for="form-stacked-text">Username</label>
|
||||||
<input class="uk-input" type="text" bind:value={userName} />
|
<input class="uk-input" type="text" bind:value={username} />
|
||||||
|
<label class="uk-form-label" for="form-stacked-text">Password</label>
|
||||||
|
<input class="uk-input" type="password" bind:value={password} />
|
||||||
|
<label class="uk-form-label" for="form-stacked-text">Access Levels</label>
|
||||||
|
<select multiple bind:value={accessLevels}>
|
||||||
|
{#each $store.accessLevels.levels as level}
|
||||||
|
<option value={level.name}>{level.name}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
<footer>
|
<footer>
|
||||||
<ActionButton alert on:click={onClosed}>Cancel</ActionButton>
|
<ActionButton alert on:click={onClosed}>Cancel</ActionButton>
|
||||||
<ActionButton disabled={!userName} on:click={createUser}>
|
<ActionButton disabled={!valid} on:click={createUser}>Save</ActionButton>
|
||||||
Save
|
|
||||||
</ActionButton>
|
|
||||||
</footer>
|
</footer>
|
||||||
</section>
|
</form>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
footer {
|
footer {
|
||||||
|
|
|
@ -30,7 +30,10 @@
|
||||||
<div class="components-list-container">
|
<div class="components-list-container">
|
||||||
<div class="nav-group-header">
|
<div class="nav-group-header">
|
||||||
<div class="hierarchy-title">Users</div>
|
<div class="hierarchy-title">Users</div>
|
||||||
<i class="ri-add-line" />
|
<i
|
||||||
|
class="ri-add-line hoverable"
|
||||||
|
on:click={() => backendUiStore.actions.modals.show('USER')}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue