Provide schema from data providers
This commit is contained in:
parent
1368074f68
commit
1ccbe140b8
|
@ -17,10 +17,13 @@
|
||||||
let loaded = false
|
let loaded = false
|
||||||
|
|
||||||
let allRows = []
|
let allRows = []
|
||||||
|
let schema = {}
|
||||||
|
|
||||||
$: fetchData(dataSource)
|
$: fetchData(dataSource)
|
||||||
$: filteredRows = filterRows(allRows, filter)
|
$: filteredRows = filterRows(allRows, filter)
|
||||||
$: sortedRows = sortRows(filteredRows, sortColumn, sortOrder)
|
$: sortedRows = sortRows(filteredRows, sortColumn, sortOrder)
|
||||||
$: rows = limitRows(sortedRows, limit)
|
$: rows = limitRows(sortedRows, limit)
|
||||||
|
$: getSchema(dataSource)
|
||||||
$: actions = [
|
$: actions = [
|
||||||
{
|
{
|
||||||
type: ActionTypes.RefreshDatasource,
|
type: ActionTypes.RefreshDatasource,
|
||||||
|
@ -30,6 +33,7 @@
|
||||||
]
|
]
|
||||||
$: dataContext = {
|
$: dataContext = {
|
||||||
rows,
|
rows,
|
||||||
|
schema,
|
||||||
rowsLength: rows.length,
|
rowsLength: rows.length,
|
||||||
loading,
|
loading,
|
||||||
loaded,
|
loaded,
|
||||||
|
@ -79,6 +83,17 @@
|
||||||
}
|
}
|
||||||
return rows.slice(0, numLimit)
|
return rows.slice(0, numLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getSchema = async dataSource => {
|
||||||
|
if (dataSource?.schema) {
|
||||||
|
schema = dataSource.schema
|
||||||
|
} else if (dataSource?.tableId) {
|
||||||
|
const definition = await API.fetchTableDefinition(dataSource.tableId)
|
||||||
|
schema = definition?.schema ?? {}
|
||||||
|
} else {
|
||||||
|
schema = {}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Provider {actions} data={dataContext}>
|
<Provider {actions} data={dataContext}>
|
||||||
|
|
Loading…
Reference in New Issue