|
|
@ -50,6 +50,7 @@ |
|
|
let saveId |
|
|
let saveId |
|
|
let response, schema, isGet |
|
|
let response, schema, isGet |
|
|
let datasourceType, integrationInfo, queryConfig, responseSuccess |
|
|
let datasourceType, integrationInfo, queryConfig, responseSuccess |
|
|
|
|
|
let authConfigId |
|
|
|
|
|
|
|
|
$: datasource = $datasources.list.find(ds => ds._id === query?.datasourceId) |
|
|
$: datasource = $datasources.list.find(ds => ds._id === query?.datasourceId) |
|
|
$: datasourceType = datasource?.source |
|
|
$: datasourceType = datasource?.source |
|
|
@ -60,6 +61,7 @@ |
|
|
$: isGet = query?.queryVerb === "read" |
|
|
$: isGet = query?.queryVerb === "read" |
|
|
$: responseSuccess = |
|
|
$: responseSuccess = |
|
|
response?.info?.code >= 200 && response?.info?.code <= 206 |
|
|
response?.info?.code >= 200 && response?.info?.code <= 206 |
|
|
|
|
|
$: authConfigs = buildAuthConfigs(datasource) |
|
|
|
|
|
|
|
|
function getSelectedQuery() { |
|
|
function getSelectedQuery() { |
|
|
return cloneDeep( |
|
|
return cloneDeep( |
|
|
@ -91,6 +93,16 @@ |
|
|
return qs.length > 0 ? `${newUrl}?${qs}` : newUrl |
|
|
return qs.length > 0 ? `${newUrl}?${qs}` : newUrl |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const buildAuthConfigs = datasource => { |
|
|
|
|
|
if (datasource?.config?.authConfigs) { |
|
|
|
|
|
return datasource.config.authConfigs.map(c => ({ |
|
|
|
|
|
label: c.name, |
|
|
|
|
|
value: c._id, |
|
|
|
|
|
})) |
|
|
|
|
|
} |
|
|
|
|
|
return [] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function learnMoreBanner() { |
|
|
function learnMoreBanner() { |
|
|
window.open("https://docs.budibase.com/building-apps/data/transformers") |
|
|
window.open("https://docs.budibase.com/building-apps/data/transformers") |
|
|
} |
|
|
} |
|
|
@ -100,6 +112,7 @@ |
|
|
const queryString = buildQueryString(breakQs) |
|
|
const queryString = buildQueryString(breakQs) |
|
|
newQuery.fields.path = url.split("?")[0] |
|
|
newQuery.fields.path = url.split("?")[0] |
|
|
newQuery.fields.queryString = queryString |
|
|
newQuery.fields.queryString = queryString |
|
|
|
|
|
newQuery.fields.authConfigId = authConfigId |
|
|
newQuery.schema = fieldsToSchema(schema) |
|
|
newQuery.schema = fieldsToSchema(schema) |
|
|
newQuery.parameters = keyValueToQueryParameters(bindings) |
|
|
newQuery.parameters = keyValueToQueryParameters(bindings) |
|
|
return newQuery |
|
|
return newQuery |
|
|
@ -132,6 +145,22 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getAuthConfigId = () => { |
|
|
|
|
|
let id = query.fields.authConfigId |
|
|
|
|
|
if (id) { |
|
|
|
|
|
// find the matching config on the datasource |
|
|
|
|
|
const matchedConfig = datasource?.config?.authConfigs?.filter( |
|
|
|
|
|
c => c._id === authConfigId |
|
|
|
|
|
)[0] |
|
|
|
|
|
// clear the id if the config is not found (deleted) |
|
|
|
|
|
// i.e. just show 'None' in the dropdown |
|
|
|
|
|
if (!matchedConfig) { |
|
|
|
|
|
id = undefined |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return id |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
onMount(() => { |
|
|
onMount(() => { |
|
|
query = getSelectedQuery() |
|
|
query = getSelectedQuery() |
|
|
const qs = query?.fields.queryString |
|
|
const qs = query?.fields.queryString |
|
|
@ -139,6 +168,7 @@ |
|
|
url = buildUrl(query.fields.path, breakQs) |
|
|
url = buildUrl(query.fields.path, breakQs) |
|
|
schema = schemaToFields(query.schema) |
|
|
schema = schemaToFields(query.schema) |
|
|
bindings = queryParametersToKeyValue(query.parameters) |
|
|
bindings = queryParametersToKeyValue(query.parameters) |
|
|
|
|
|
authConfigId = getAuthConfigId() |
|
|
if (query && !query.transformer) { |
|
|
if (query && !query.transformer) { |
|
|
query.transformer = "return data" |
|
|
query.transformer = "return data" |
|
|
} |
|
|
} |
|
|
@ -238,6 +268,19 @@ |
|
|
/> |
|
|
/> |
|
|
</Layout> |
|
|
</Layout> |
|
|
</Tab> |
|
|
</Tab> |
|
|
|
|
|
<div class="auth-container"> |
|
|
|
|
|
<div /> |
|
|
|
|
|
<!-- spacer --> |
|
|
|
|
|
<div class="auth-select"> |
|
|
|
|
|
<Select |
|
|
|
|
|
label="Auth" |
|
|
|
|
|
labelPosition="left" |
|
|
|
|
|
placeholder="None" |
|
|
|
|
|
bind:value={authConfigId} |
|
|
|
|
|
options={authConfigs} |
|
|
|
|
|
/> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
</Tabs> |
|
|
</Tabs> |
|
|
</Layout> |
|
|
</Layout> |
|
|
</div> |
|
|
</div> |
|
|
@ -384,4 +427,12 @@ |
|
|
margin-top: var(--spacing-xl); |
|
|
margin-top: var(--spacing-xl); |
|
|
justify-content: center; |
|
|
justify-content: center; |
|
|
} |
|
|
} |
|
|
|
|
|
.auth-container { |
|
|
|
|
|
width: 100%; |
|
|
|
|
|
display: flex; |
|
|
|
|
|
justify-content: space-between; |
|
|
|
|
|
} |
|
|
|
|
|
.auth-select { |
|
|
|
|
|
width: 200px; |
|
|
|
|
|
} |
|
|
</style> |
|
|
</style> |
|
|
|