1
0
Fork 0
mirror of synced 2024-09-21 03:43:21 +12:00
budibase/packages/builder/src/components/integration/index.svelte

67 lines
1.6 KiB
Svelte
Raw Normal View History

2020-12-19 07:19:43 +13:00
<script>
2021-01-15 09:51:03 +13:00
import Editor from "./QueryEditor.svelte"
2021-01-14 03:11:53 +13:00
import FieldsBuilder from "./QueryFieldsBuilder.svelte"
import { Label, Input } from "@budibase/bbui"
2021-01-07 01:28:51 +13:00
2020-12-19 07:19:43 +13:00
const QueryTypes = {
SQL: "sql",
2021-01-12 10:01:21 +13:00
JSON: "json",
FIELDS: "fields",
2020-12-19 07:19:43 +13:00
}
export let query
2021-02-19 07:55:08 +13:00
export let datasource
2021-01-14 03:11:53 +13:00
export let schema
2021-01-15 03:22:24 +13:00
export let editable = true
export let height = 500
2021-01-12 06:18:22 +13:00
2021-02-20 03:31:07 +13:00
$: urlDisplay =
schema.urlDisplay &&
`${datasource.config.url}${query.fields.path}${query.fields.queryString}`
2021-02-19 07:55:08 +13:00
2021-01-12 06:18:22 +13:00
function updateQuery({ detail }) {
2021-01-14 05:39:47 +13:00
query.fields[schema.type] = detail.value
2021-01-12 06:18:22 +13:00
}
2020-12-19 07:19:43 +13:00
</script>
2021-01-14 05:39:47 +13:00
{#if schema}
2021-01-19 04:37:32 +13:00
{#key query._id}
{#if schema.type === QueryTypes.SQL}
<Editor
editorHeight={height}
2021-01-19 04:37:32 +13:00
label="Query"
mode="sql"
on:change={updateQuery}
readOnly={!editable}
2021-02-02 00:51:53 +13:00
value={query.fields.sql}
parameters={query.parameters} />
2021-01-19 04:37:32 +13:00
{:else if schema.type === QueryTypes.JSON}
<Editor
editorHeight={height}
2021-01-19 04:37:32 +13:00
label="Query"
mode="json"
on:change={updateQuery}
readOnly={!editable}
2021-02-02 00:51:53 +13:00
value={query.fields.json}
parameters={query.parameters} />
2021-01-19 04:37:32 +13:00
{:else if schema.type === QueryTypes.FIELDS}
<FieldsBuilder bind:fields={query.fields} {schema} {editable} />
2021-02-19 07:55:08 +13:00
{#if schema.urlDisplay}
<div class="url-row">
<Label small>URL</Label>
<Input thin outline disabled value={urlDisplay} />
</div>
{/if}
2021-01-19 04:37:32 +13:00
{/if}
{/key}
2021-01-12 23:28:41 +13:00
{/if}
2021-02-19 07:55:08 +13:00
<style>
2021-02-20 03:31:07 +13:00
.url-row {
display: grid;
grid-template-columns: 20% 1fr;
grid-gap: var(--spacing-l);
align-items: center;
}
2021-02-19 07:55:08 +13:00
</style>