Use new schema endpoint
This commit is contained in:
parent
df40420470
commit
3a58aa624f
|
@ -35,11 +35,11 @@
|
||||||
try {
|
try {
|
||||||
const isSelected =
|
const isSelected =
|
||||||
decodeURIComponent($params.viewName) === $views.selectedViewName
|
decodeURIComponent($params.viewName) === $views.selectedViewName
|
||||||
const id = view.tableId
|
const { tableId } = view
|
||||||
await views.delete(view)
|
await views.delete(view)
|
||||||
notifications.success("View deleted")
|
notifications.success("View deleted")
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
$goto(`./table/${id}`)
|
$goto(`./table/${tableId}`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error deleting view")
|
notifications.error("Error deleting view")
|
||||||
|
|
|
@ -109,7 +109,14 @@
|
||||||
type: "View",
|
type: "View",
|
||||||
name: view.name,
|
name: view.name,
|
||||||
icon: "Remove",
|
icon: "Remove",
|
||||||
action: () => $goto(`./data/view/${view.name}`),
|
action: () => {
|
||||||
|
debugger
|
||||||
|
if (view.version === 2) {
|
||||||
|
$goto(`./data/view/v2/${view.id}`)
|
||||||
|
} else {
|
||||||
|
$goto(`./data/view/${view.name}`)
|
||||||
|
}
|
||||||
|
},
|
||||||
})) ?? []),
|
})) ?? []),
|
||||||
...($queries?.list?.map(query => ({
|
...($queries?.list?.map(query => ({
|
||||||
type: "Query",
|
type: "Query",
|
||||||
|
|
|
@ -26,4 +26,11 @@ export const buildViewV2Endpoints = API => ({
|
||||||
delete: async viewId => {
|
delete: async viewId => {
|
||||||
return await API.delete({ url: `/api/v2/views/${viewId}` })
|
return await API.delete({ url: `/api/v2/views/${viewId}` })
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Returns schema of a view
|
||||||
|
* @param viewId the id of the view
|
||||||
|
*/
|
||||||
|
getSchema: async viewId => {
|
||||||
|
return await API.get({ url: `/api/v2/views/${viewId}/schema` })
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import { get } from "svelte/store"
|
|
||||||
import { views as viewsStore } from "stores/backend"
|
|
||||||
import DataFetch from "./DataFetch.js"
|
import DataFetch from "./DataFetch.js"
|
||||||
|
|
||||||
export default class ViewV2Fetch extends DataFetch {
|
export default class ViewV2Fetch extends DataFetch {
|
||||||
|
@ -9,10 +7,8 @@ export default class ViewV2Fetch extends DataFetch {
|
||||||
|
|
||||||
async getDefinition(datasource) {
|
async getDefinition(datasource) {
|
||||||
try {
|
try {
|
||||||
const views = get(viewsStore).list
|
const { schema } = await this.API.viewV2.getSchema(datasource.tableId)
|
||||||
const { tableId } = views.find(v => v.id === datasource.tableId)
|
return { schema }
|
||||||
const result = await this.API.fetchTableDefinition(tableId)
|
|
||||||
return result
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.store.update(state => ({
|
this.store.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
|
|
Loading…
Reference in New Issue