Use new schema endpoint
This commit is contained in:
parent
df40420470
commit
3a58aa624f
|
@ -35,11 +35,11 @@
|
|||
try {
|
||||
const isSelected =
|
||||
decodeURIComponent($params.viewName) === $views.selectedViewName
|
||||
const id = view.tableId
|
||||
const { tableId } = view
|
||||
await views.delete(view)
|
||||
notifications.success("View deleted")
|
||||
if (isSelected) {
|
||||
$goto(`./table/${id}`)
|
||||
$goto(`./table/${tableId}`)
|
||||
}
|
||||
} catch (error) {
|
||||
notifications.error("Error deleting view")
|
||||
|
|
|
@ -109,7 +109,14 @@
|
|||
type: "View",
|
||||
name: view.name,
|
||||
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 => ({
|
||||
type: "Query",
|
||||
|
|
|
@ -26,4 +26,11 @@ export const buildViewV2Endpoints = API => ({
|
|||
delete: async 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"
|
||||
|
||||
export default class ViewV2Fetch extends DataFetch {
|
||||
|
@ -9,10 +7,8 @@ export default class ViewV2Fetch extends DataFetch {
|
|||
|
||||
async getDefinition(datasource) {
|
||||
try {
|
||||
const views = get(viewsStore).list
|
||||
const { tableId } = views.find(v => v.id === datasource.tableId)
|
||||
const result = await this.API.fetchTableDefinition(tableId)
|
||||
return result
|
||||
const { schema } = await this.API.viewV2.getSchema(datasource.tableId)
|
||||
return { schema }
|
||||
} catch (error) {
|
||||
this.store.update(state => ({
|
||||
...state,
|
||||
|
|
Loading…
Reference in New Issue