From 32122ad5704c1743d84ba365c5a79e853ccf803e Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 30 Sep 2024 16:05:24 +0300 Subject: [PATCH 1/4] Add fetch columns, upgrade filters and select columns --- .../src/stores/project/tables/table.store.ts | 42 ++- .../Components/Group/ListSchemaComponent.vue | 246 ++++++++++-------- .../Group/ListSchemaToolbarElement.vue | 138 ++++++++++ .../src/views/Project/Tables/types/group.ts | 18 +- .../api/routers/project/tables/list.py | 63 +++-- 5 files changed, 356 insertions(+), 151 deletions(-) create mode 100644 client/src/views/Project/Tables/Components/Group/ListSchemaToolbarElement.vue diff --git a/client/src/stores/project/tables/table.store.ts b/client/src/stores/project/tables/table.store.ts index 3c065d6..8178574 100644 --- a/client/src/stores/project/tables/table.store.ts +++ b/client/src/stores/project/tables/table.store.ts @@ -17,7 +17,9 @@ export const useTableStore = defineStore({ if (alreadyProject) { return alreadyProject } - const result = (await ApiService.post<{table_schema: any} | undefined>('/api/project/tables/main/schema/download', + const result = (await ApiService.post<{ + table_schema: any + } | undefined>('/api/project/tables/main/schema/download', { project: project, } @@ -43,11 +45,11 @@ export const useTableStore = defineStore({ key: string, order: 'ask' | 'desc' }[] | undefined = undefined, - filter: { - key: string | undefined, - value: string | undefined, - like: boolean | undefined - } | undefined = undefined + filters: { + key: string, + value?: string | number | boolean | undefined, + operator: string + }[] | undefined = undefined ) { return await ApiService.post('/api/project/tables/list/load', { @@ -57,7 +59,7 @@ export const useTableStore = defineStore({ page: page - 1, count: count, order_by: orderBy, - filter: filter?.key ? filter : undefined + filter: filters } ) }, @@ -65,18 +67,32 @@ export const useTableStore = defineStore({ project: string, table: string, columns: string[], - filter: { - key: string | undefined, - value: string | undefined, - like: boolean | undefined - } | undefined = undefined + filters: { + key: string, + value?: string | number | boolean | undefined, + operator: string + }[] | undefined = undefined ) { return await ApiService.post<{ count: number }>('/api/project/tables/list/count', { project: project, table: table, columns: columns, - filter: filter?.key ? filter : undefined + filter: filters + } + ) + }, + async fetchColumns( + project: string, + table: string + ) { + return await ApiService.post<{ + column_name: string, + data_type: string + }[]>('/api/project/tables/list/fetch_columns', + { + project: project, + table: table, } ) }, diff --git a/client/src/views/Project/Tables/Components/Group/ListSchemaComponent.vue b/client/src/views/Project/Tables/Components/Group/ListSchemaComponent.vue index 4875add..8837d77 100644 --- a/client/src/views/Project/Tables/Components/Group/ListSchemaComponent.vue +++ b/client/src/views/Project/Tables/Components/Group/ListSchemaComponent.vue @@ -1,15 +1,15 @@