From 6205dff463b6361af11c22e653cbb8c97ea7db25 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Wed, 8 Nov 2023 19:47:57 +0800 Subject: [PATCH 1/5] [Core] [Metadata] Fixed an error in selecting columns directly without selecting tables --- .github/ISSUE_TEMPLATE/release_notes.yml | 4 ++-- core/datacap-server/src/main/bin/debug.sh | 2 +- core/datacap-server/src/main/bin/startup.sh | 2 +- core/datacap-web/src/views/admin/source/SourceManager.vue | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/release_notes.yml b/.github/ISSUE_TEMPLATE/release_notes.yml index a4793a78..3151f4f5 100644 --- a/.github/ISSUE_TEMPLATE/release_notes.yml +++ b/.github/ISSUE_TEMPLATE/release_notes.yml @@ -1,5 +1,5 @@ -name: Release notes -title: Release notes for xxx +name: 🆕 Release new version +title: 🆕 [Release] Release notes for xxx description: New version released labels: - release diff --git a/core/datacap-server/src/main/bin/debug.sh b/core/datacap-server/src/main/bin/debug.sh index b7309627..e9e4258c 100644 --- a/core/datacap-server/src/main/bin/debug.sh +++ b/core/datacap-server/src/main/bin/debug.sh @@ -9,7 +9,7 @@ check_java_version() { local java_version=$("$JAVA_HOME"/bin/java -version 2>&1 | awk -F '"' '/version/ {print $2}') local major_version=$(echo "$java_version" | awk -F. '{print $1}') if [ "$major_version" != "1" ] && [ "$major_version" != "11" ]; then - printf "Error: Java version %s is not supported. Please use Java 1.8 or 11.\n" "$java_version" + printf "Error: Java version [ %s ] is not supported. Please use Java 1.8 or 11.\n" "$java_version" exit 1 fi } diff --git a/core/datacap-server/src/main/bin/startup.sh b/core/datacap-server/src/main/bin/startup.sh index c0ed9a19..cf3bd84f 100644 --- a/core/datacap-server/src/main/bin/startup.sh +++ b/core/datacap-server/src/main/bin/startup.sh @@ -9,7 +9,7 @@ check_java_version() { local java_version=$("$JAVA_HOME"/bin/java -version 2>&1 | awk -F '"' '/version/ {print $2}') local major_version=$(echo "$java_version" | awk -F. '{print $1}') if [ "$major_version" != "1" ] && [ "$major_version" != "11" ]; then - printf "Error: Java version %s is not supported. Please use Java 1.8 or 11.\n" "$java_version" + printf "Error: Java version [ %s ] is not supported. Please use Java 1.8 or 11.\n" "$java_version" exit 1 fi } diff --git a/core/datacap-web/src/views/admin/source/SourceManager.vue b/core/datacap-web/src/views/admin/source/SourceManager.vue index 3b1d571d..238e8a59 100644 --- a/core/datacap-web/src/views/admin/source/SourceManager.vue +++ b/core/datacap-web/src/views/admin/source/SourceManager.vue @@ -281,7 +281,9 @@ export default defineComponent({ } const currentNode = node[0]; if (currentNode.level === DataStructureEnum.COLUMN) { - this.applyValue.node.selected = true; + if (this.applyValue.node) { + this.applyValue.node.selected = true; + } currentNode.selected = false; return; } From 5fbfe9d81f50626e215c0f2275388bc8dbbb4a28 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Thu, 9 Nov 2023 12:34:14 +0800 Subject: [PATCH 2/5] [Core] [Metadata] Supports custom column display --- .../src/i18n/langs/en/source/manager.ts | 1 + .../src/i18n/langs/zhCn/source/manager.ts | 1 + .../admin/source/components/TableColumn.vue | 69 +++++++++++++++++++ .../admin/source/components/TableData.vue | 54 ++++++++++++--- .../source/components/TableDataFunction.ts | 3 +- 5 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 core/datacap-web/src/views/admin/source/components/TableColumn.vue diff --git a/core/datacap-web/src/i18n/langs/en/source/manager.ts b/core/datacap-web/src/i18n/langs/en/source/manager.ts index 2150d846..05efed6e 100644 --- a/core/datacap-web/src/i18n/langs/en/source/manager.ts +++ b/core/datacap-web/src/i18n/langs/en/source/manager.ts @@ -4,4 +4,5 @@ export default { updateSuccess: 'Update Success', deleteRows: 'Delete Rows', deleteSuccess: 'Delete Success', + visibleColumn: 'Visible Column', } diff --git a/core/datacap-web/src/i18n/langs/zhCn/source/manager.ts b/core/datacap-web/src/i18n/langs/zhCn/source/manager.ts index 15046aed..7e757d18 100644 --- a/core/datacap-web/src/i18n/langs/zhCn/source/manager.ts +++ b/core/datacap-web/src/i18n/langs/zhCn/source/manager.ts @@ -4,4 +4,5 @@ export default { updateSuccess: '更新成功', deleteRows: '删除行', deleteSuccess: '删除成功', + visibleColumn: '可见列', } diff --git a/core/datacap-web/src/views/admin/source/components/TableColumn.vue b/core/datacap-web/src/views/admin/source/components/TableColumn.vue new file mode 100644 index 00000000..633b3e6d --- /dev/null +++ b/core/datacap-web/src/views/admin/source/components/TableColumn.vue @@ -0,0 +1,69 @@ + + diff --git a/core/datacap-web/src/views/admin/source/components/TableData.vue b/core/datacap-web/src/views/admin/source/components/TableData.vue index 072c9a05..eeb4a8c9 100644 --- a/core/datacap-web/src/views/admin/source/components/TableData.vue +++ b/core/datacap-web/src/views/admin/source/components/TableData.vue @@ -96,13 +96,22 @@
- - - + + + + + + + +
+ @selectionChanged="handlerSelectionChanged" + @columnVisible="handlerColumnVisible"> @@ -141,6 +151,12 @@ :columns="dataSelectedChanged.columns" @close="handlerSelectedChangedPreview(false)"> + + + @@ -162,10 +178,11 @@ import {SqlColumn, TableFilter} from "@/model/TableFilter"; import TableCellEditPreview from "@/views/admin/source/components/TableCellEditPreview.vue"; import TableRowDeletePreview from "@/views/admin/source/components/TableRowDeletePreview.vue"; import {cloneDeep} from "lodash"; +import TableColumn from "@/views/admin/source/components/TableColumn.vue"; export default defineComponent({ name: "TableData", - components: {TableRowDeletePreview, TableCellEditPreview, MarkdownPreview, InputNumber, CircularLoading, AgGridVue}, + components: {TableColumn, TableRowDeletePreview, TableCellEditPreview, MarkdownPreview, InputNumber, CircularLoading, AgGridVue}, props: { id: { type: Number, @@ -206,6 +223,10 @@ export default defineComponent({ changed: false, pending: false, columns: [] + }, + visibleColumn: { + show: false, + columns: [] } } }, @@ -324,6 +345,21 @@ export default defineComponent({ { this.visibleContent.show = show; }, + handlerColumnVisible(event: { visible: any; column: { visible: any; colId: any; }; }) + { + if (!event.visible) { + this.configure.headers.map((column: { field: any; checked: boolean; }) => { + if (column.field === event.column.colId) { + column.checked = false; + } + }) + } + }, + handlerVisibleColumn(show: boolean) + { + this.visibleColumn.show = show; + this.visibleColumn.columns = this.configure.headers; + }, watchId() { watch( diff --git a/core/datacap-web/src/views/admin/source/components/TableDataFunction.ts b/core/datacap-web/src/views/admin/source/components/TableDataFunction.ts index 0edcd9a6..6735453d 100644 --- a/core/datacap-web/src/views/admin/source/components/TableDataFunction.ts +++ b/core/datacap-web/src/views/admin/source/components/TableDataFunction.ts @@ -20,7 +20,8 @@ const createColumnDefs = (headers: any[], types: any[]): any[] => { }, cellEditorPopup: true, cellEditor: 'agLargeTextCellEditor', - cellEditorParams: {maxLength: 9999999999999, rows: 10} + cellEditorParams: {maxLength: 9999999999999, rows: 10}, + checked: true }; columnDefs.push(columnDef); }) From 51767e1b474b0ec79102e689640c67ceaefae359 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Thu, 9 Nov 2023 16:28:47 +0800 Subject: [PATCH 3/5] [Core] [Metadata] Remove unused components --- .../admin/source/components/TablePreview.vue | 111 ------------------ .../admin/source/components/sort/SortBy.vue | 79 ------------- 2 files changed, 190 deletions(-) delete mode 100644 core/datacap-web/src/views/admin/source/components/TablePreview.vue delete mode 100644 core/datacap-web/src/views/admin/source/components/sort/SortBy.vue diff --git a/core/datacap-web/src/views/admin/source/components/TablePreview.vue b/core/datacap-web/src/views/admin/source/components/TablePreview.vue deleted file mode 100644 index f5edb837..00000000 --- a/core/datacap-web/src/views/admin/source/components/TablePreview.vue +++ /dev/null @@ -1,111 +0,0 @@ - - diff --git a/core/datacap-web/src/views/admin/source/components/sort/SortBy.vue b/core/datacap-web/src/views/admin/source/components/sort/SortBy.vue deleted file mode 100644 index 5b63d858..00000000 --- a/core/datacap-web/src/views/admin/source/components/sort/SortBy.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - From b90bca46ef4422d7e8261b1a42bb135c1080f0d9 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Thu, 9 Nov 2023 17:38:57 +0800 Subject: [PATCH 4/5] [Core] [Metadata] Supports resetting column positions --- .../service/impl/TableServiceImpl.java | 21 ++++++--- .../admin/source/components/TableData.vue | 46 ++++++++++++++----- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/core/datacap-service/src/main/java/io/edurt/datacap/service/service/impl/TableServiceImpl.java b/core/datacap-service/src/main/java/io/edurt/datacap/service/service/impl/TableServiceImpl.java index 030da39c..aaaba1c9 100644 --- a/core/datacap-service/src/main/java/io/edurt/datacap/service/service/impl/TableServiceImpl.java +++ b/core/datacap-service/src/main/java/io/edurt/datacap/service/service/impl/TableServiceImpl.java @@ -122,12 +122,21 @@ public class TableServiceImpl } } - table.getColumns() - .stream() - .sorted(Comparator.comparing(item -> Integer.parseInt(item.getPosition()))) - .forEach(column -> columns.add(SqlColumn.builder() - .column(String.format("`%s`", column.getName())) - .build())); + // If the columns of the query are not passed, they are obtained through metadata + if (configure.getColumns() == null || configure.getColumns().size() == 0) { + table.getColumns() + .stream() + .sorted(Comparator.comparing(item -> Integer.parseInt(item.getPosition()))) + .forEach(column -> columns.add(SqlColumn.builder() + .column(String.format("`%s`", column.getName())) + .build())); + } + else { + configure.getColumns() + .forEach(column -> columns.add(SqlColumn.builder() + .column(String.format("`%s`", column.getColumn())) + .build())); + } int offset = configure.getPagination().getPageSize() * (configure.getPagination().getCurrentPage() - 1); SqlBody body = SqlBody.builder() .type(SqlType.SELECT) diff --git a/core/datacap-web/src/views/admin/source/components/TableData.vue b/core/datacap-web/src/views/admin/source/components/TableData.vue index eeb4a8c9..0de9dd0e 100644 --- a/core/datacap-web/src/views/admin/source/components/TableData.vue +++ b/core/datacap-web/src/views/admin/source/components/TableData.vue @@ -126,7 +126,8 @@ @sortChanged="handlerSortChanged" @cellValueChanged="handlerCellValueChanged" @selectionChanged="handlerSelectionChanged" - @columnVisible="handlerColumnVisible"> + @columnVisible="handlerColumnVisible" + @columnMoved="handlerColumnMoved"> @@ -260,20 +261,11 @@ export default defineComponent({ this.gridApi = params.api; this.gridColumnApi = params.columnApi; }, - handlerSortChanged() + handlerRefererData(configure: TableFilter) { this.configure.columns = []; this.gridOptions.overlayNoRowsTemplate = ''; this.refererLoading = true; - const columnState = this.gridColumnApi.getColumnState(); - const orders = columnState.map((column: { colId: any; sort: any; }) => ({ - column: column.colId, - order: column.sort - })); - const configure: TableFilter = new TableFilter(); - configure.pagination = this.configure.pagination; - configure.orders = orders; - TableService.getData(this.id, configure) .then(response => { if (response.status && response.data) { @@ -290,6 +282,12 @@ export default defineComponent({ }) .finally(() => this.refererLoading = false) }, + handlerSortChanged() + { + const configure: TableFilter = new TableFilter(); + this.getSortConfigure(configure) + this.handlerRefererData(configure) + }, handlerCellValueChanged(event: { data: any; colDef: { field: string; }; oldValue: any; newValue: any; }) { const oldColumn = event.data; @@ -360,6 +358,32 @@ export default defineComponent({ this.visibleColumn.show = show; this.visibleColumn.columns = this.configure.headers; }, + handlerColumnMoved(event) + { + if (event.finished) { + const configure: TableFilter = new TableFilter() + this.getSortConfigure(configure) + this.getVisibleColumn(configure) + this.handlerRefererData(configure) + } + }, + getSortConfigure(configure: TableFilter) + { + const columnState = this.gridColumnApi.getColumnState(); + const orders = columnState.map((column: { colId: any; sort: any; }) => ({ + column: column.colId, + order: column.sort + })); + configure.pagination = this.configure.pagination; + configure.orders = orders; + }, + getVisibleColumn(configure: TableFilter) + { + const columns = this.gridColumnApi.getColumnState() + .filter(item => !item.hide) + .map((item: { colId: any; }) => ({column: item.colId})) + configure.columns = columns + }, watchId() { watch( From 20b61e2647d1bcf20b852cabffbf45a42cae75e5 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Fri, 10 Nov 2023 13:07:35 +0800 Subject: [PATCH 5/5] [Core] [Metadata] Support for selecting specified columns (close #471) --- .../admin/source/components/TableColumn.vue | 16 ++++++++-- .../admin/source/components/TableData.vue | 32 ++++++++++++++++--- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/core/datacap-web/src/views/admin/source/components/TableColumn.vue b/core/datacap-web/src/views/admin/source/components/TableColumn.vue index 633b3e6d..7ebd3819 100644 --- a/core/datacap-web/src/views/admin/source/components/TableColumn.vue +++ b/core/datacap-web/src/views/admin/source/components/TableColumn.vue @@ -13,6 +13,17 @@ + @@ -45,12 +56,13 @@ export default defineComponent({ { this.columns.filter((item: { checked: any; }) => item.checked) .forEach((item: { field: any; }) => { - this.applyColumns.push(item.field); + this.applyColumns.push(item.field) }) }, handlerCancel() { - this.visible = false; + this.$emit('onClose', this.applyColumns) + this.visible = false } }, computed: { diff --git a/core/datacap-web/src/views/admin/source/components/TableData.vue b/core/datacap-web/src/views/admin/source/components/TableData.vue index 0de9dd0e..b84dbe52 100644 --- a/core/datacap-web/src/views/admin/source/components/TableData.vue +++ b/core/datacap-web/src/views/admin/source/components/TableData.vue @@ -107,7 +107,7 @@ @@ -156,7 +156,8 @@ + @close="handlerVisibleColumn($event, false)" + @onClose="handlerVisibleColumn($event, false)"> @@ -205,6 +206,7 @@ export default defineComponent({ gridOptions: null, gridApi: null as GridApi, gridColumnApi: null as ColumnApi, + originalColumns: [], configure: { headers: [], columns: [], @@ -246,6 +248,7 @@ export default defineComponent({ .then(response => { if (response.status && response.data) { this.configure.headers = createColumnDefs(response.data.headers, response.data.types); + this.originalColumns = this.configure.headers this.configure.columns = response.data.columns; this.configure.pagination = response.data.pagination; this.visibleContent.content = '```sql\n' + response.data.content + '\n```'; @@ -269,6 +272,7 @@ export default defineComponent({ TableService.getData(this.id, configure) .then(response => { if (response.status && response.data) { + this.configure.headers = createColumnDefs(response.data.headers, response.data.types); this.configure.columns = response.data.columns; if (this.configure.columns.length <= 0) { this.gridOptions.overlayNoRowsTemplate = 'No Rows To Show'; @@ -353,12 +357,30 @@ export default defineComponent({ }) } }, - handlerVisibleColumn(show: boolean) + handlerVisibleColumn(event, show: boolean) { this.visibleColumn.show = show; - this.visibleColumn.columns = this.configure.headers; + if (event) { + const configure: TableFilter = new TableFilter() + this.getSortConfigure(configure) + this.getVisibleColumn(configure) + const columns = event.map((item: string) => ({column: item})) + configure.columns = columns + // Remove the reduced column is not selected + this.originalColumns.filter((item: { field: string; }) => !event.includes(item.field)) + .map((item: { checked: boolean; }) => { + item.checked = false + }) + // Add new Column is selected + this.originalColumns.filter((item: { field: string; }) => event.includes(item.field)) + .map((item: { checked: boolean; }) => { + item.checked = true + }) + this.handlerRefererData(configure) + } + this.visibleColumn.columns = this.originalColumns }, - handlerColumnMoved(event) + handlerColumnMoved(event: { finished: any; }) { if (event.finished) { const configure: TableFilter = new TableFilter()