This commit is contained in:
Martin McKeaveney 2021-01-13 18:29:51 +00:00
parent 01ff661f17
commit 267e85c2bf
6 changed files with 29 additions and 41 deletions

View File

@ -11,22 +11,22 @@
let loading = false
let error = false
async function fetchData() {
try {
loading = true
const response = await api.fetchDataForQuery(
$params.selectedDatasource,
query._id
)
data = response.rows || []
error = false
} catch (err) {
error = `${query}: Query error. (${err.message}). This could be a problem with your datasource configuration.`
notifier.danger(error)
} finally {
loading = false
}
}
// async function fetchData() {
// try {
// loading = true
// const response = await api.fetchDataForQuery(
// $params.selectedDatasource,
// query._id
// )
// data = response.rows || []
// error = false
// } catch (err) {
// error = `${query}: Query error. (${err.message}). This could be a problem with your datasource configuration.`
// notifier.danger(error)
// } finally {
// loading = false
// }
// }
// Fetch rows for specified query
// $: query && fetchData()

View File

@ -30,15 +30,3 @@ export async function fetchDataForView(view) {
}
return json
}
export async function fetchDataForQuery(datasourceId, queryId) {
const FETCH_QUERY_URL = `/api/queries/${queryId}`
const response = await api.get(FETCH_QUERY_URL)
const json = await response.json()
if (response.status !== 200) {
throw new Error(json.message)
}
return json
}

View File

@ -9,8 +9,7 @@
$: datasource = $backendUiStore.datasources.find(
ds => ds._id === parameters.datasourceId
)
// TODO: binding needs a significant refactor and needs to
// be centralised
// TODO: binding needs to be centralised
$: bindableProperties = fetchBindableProperties({
componentInstanceId: $store.selectedComponentId,
components: $store.components,
@ -51,7 +50,6 @@
<Spacer medium />
<!-- TODO: Need to render defaults, but allow interpolation of frontend values -->
{#if query}
<ParameterBuilder
bind:customParams={parameters.queryParams}

View File

@ -17,7 +17,7 @@ const SCHEMA = {
query: {
create: {
"Airtable Record": {
type: "fields",
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
table: {

View File

@ -1,24 +1,25 @@
const PouchDB = require("pouchdb")
const { FIELD_TYPES, QUERY_TYPES } = require("./Integration")
const SCHEMA = {
datasource: {
url: {
type: "string",
type: FIELD_TYPES.STRING,
required: true,
default: "localhost",
},
database: {
type: "string",
type: FIELD_TYPES.STRING,
required: true,
},
view: {
type: "string",
type: FIELD_TYPES.STRING,
required: true,
},
},
query: {
json: {
type: "json",
type: QUERY_TYPES.JSON,
required: true,
},
},

View File

@ -1,30 +1,31 @@
const { MongoClient } = require("mongodb")
const { FIELD_TYPES, QUERY_TYPES } = require("./Integration")
const SCHEMA = {
datasource: {
connectionString: {
type: "string",
type: FIELD_TYPES.STRING,
required: true,
default: "localhost",
},
db: {
type: "string",
type: FIELD_TYPES.STRING,
required: true,
},
collection: {
type: "string",
type: FIELD_TYPES.STRING,
required: true,
},
},
query: {
create: {
JSON: {
type: "json",
type: QUERY_TYPES.JSON,
},
},
read: {
JSON: {
type: "json",
type: QUERY_TYPES.JSON,
},
},
},