diff --git a/src/common/network/table/helper.ts b/src/common/network/table/helper.ts index 43fd9d355..a22a12e69 100644 --- a/src/common/network/table/helper.ts +++ b/src/common/network/table/helper.ts @@ -240,7 +240,14 @@ export function convertTableToServerTable( return serverTable; } -export function convertServerTableToTable(data: IServerTable): Partial { +export function convertServerTableToTable( + data: IServerTable, + logicalDbTableParams?: { + isLogicalTable: boolean; + tableId: number; + databaseId: number; + }, +): Partial { if (!data) { return null; } @@ -261,6 +268,9 @@ export function convertServerTableToTable(data: IServerTable): Partial { return item.allColumns ? ColumnStoreType.ROW : ColumnStoreType.COLUMN; }) || [], + isLogicalTable: logicalDbTableParams?.isLogicalTable, + tableId: logicalDbTableParams?.tableId, + databaseId: logicalDbTableParams?.databaseId, }; // column table.columns = data.columns.map((column) => { diff --git a/src/common/network/table/index.ts b/src/common/network/table/index.ts index 7cc3a0eca..16c77a22b 100644 --- a/src/common/network/table/index.ts +++ b/src/common/network/table/index.ts @@ -79,7 +79,17 @@ export async function getLogicTableInfo( tableId: number, ): Promise> { const res = await getLogicalTableDetail(databaseId, tableId); - return { ...res, ...convertServerTableToTable({ ...res?.basePhysicalTable, name: res?.name }) }; + return { + ...res, + ...convertServerTableToTable( + { ...res?.basePhysicalTable, name: res?.name }, + { + isLogicalTable: true, + tableId, + databaseId, + }, + ), + }; } export async function queryTableOrViewData( diff --git a/src/component/Task/LogicDatabaseAsyncTask/CreateModal/index.tsx b/src/component/Task/LogicDatabaseAsyncTask/CreateModal/index.tsx index 34fd691dd..feb6317a5 100644 --- a/src/component/Task/LogicDatabaseAsyncTask/CreateModal/index.tsx +++ b/src/component/Task/LogicDatabaseAsyncTask/CreateModal/index.tsx @@ -372,12 +372,6 @@ const CreateModal: React.FC = (props) => { }) /*立即执行*/ } - - {formatMessage({ - id: 'odc.components.TaskManagePage.ManualExecution', - defaultMessage: '手动执行', - })} - { formatMessage({ diff --git a/src/component/Task/component/CommonDetailModal/TaskExecuteModal.tsx b/src/component/Task/component/CommonDetailModal/TaskExecuteModal.tsx index 74fcda639..1ae2d91de 100644 --- a/src/component/Task/component/CommonDetailModal/TaskExecuteModal.tsx +++ b/src/component/Task/component/CommonDetailModal/TaskExecuteModal.tsx @@ -60,8 +60,9 @@ const getColumns = () => { }, { title: '结果', - key: 'result', - dataIndex: 'result', + key: 'track', + dataIndex: 'track', + ellipsis: true, render: (value: string, row: any) => row.status === ISqlExecuteResultStatus.SUCCESS ? ( getResultText(row) @@ -105,25 +106,31 @@ const getColumns = () => { (stage) => stage.stageName === 'DB Server Execute SQL', ); const DBCostTime = formatTimeTemplate( - BigNumber(executeSQLStage?.totalDurationMicroseconds).div(1000000).toNumber(), + BigNumber(executeStage?.totalDurationMicroseconds).div(1000000).toNumber(), ); + const showDBTimeline = ![ + ISqlExecuteResultStatus.CANCELED, + ISqlExecuteResultStatus.CREATED, + ].includes(row?.status); return ( {DBCostTime} - } - > - - + {showDBTimeline ? ( + } + > + + + ) : null} ); }, diff --git a/src/component/Task/component/CommonDetailModal/TaskExecuteRecord.tsx b/src/component/Task/component/CommonDetailModal/TaskExecuteRecord.tsx index 156e94a59..4442fe073 100644 --- a/src/component/Task/component/CommonDetailModal/TaskExecuteRecord.tsx +++ b/src/component/Task/component/CommonDetailModal/TaskExecuteRecord.tsx @@ -398,12 +398,12 @@ const TaskExecuteRecord: React.FC = (props) => { }; const handleLogicalDatabaseTaskStop = async (detailId: number) => { - await skipPhysicalSqlExecute(flowList?.contents?.[0]?.id, detailId); + await stopPhysicalSqlExecute(flowList?.contents?.[0]?.id, detailId); onReload?.(); }; const handleLogicalDatabaseTaskSkip = async (detailId: number) => { - await stopPhysicalSqlExecute(flowList?.contents?.[0]?.id, detailId); + await skipPhysicalSqlExecute(flowList?.contents?.[0]?.id, detailId); onReload?.(); }; diff --git a/src/page/Datasource/Info/index.tsx b/src/page/Datasource/Info/index.tsx index 29724220f..ef873110b 100644 --- a/src/page/Datasource/Info/index.tsx +++ b/src/page/Datasource/Info/index.tsx @@ -322,7 +322,7 @@ const Info: React.FC = ({ id, datasource }) => { dataIndex: 'lastSyncTime', width: 200, render(v, record) { - const time = record?.lastSyncTime || record?.objectLastSyncTime; + const time = record?.objectLastSyncTime || record?.lastSyncTime; return getLocalFormatDateTime(time); }, }, diff --git a/src/page/Project/Database/components/LogicDatabase/ManageLogicDatabase.tsx b/src/page/Project/Database/components/LogicDatabase/ManageLogicDatabase.tsx index 18b6ec6b8..f0038f6dd 100644 --- a/src/page/Project/Database/components/LogicDatabase/ManageLogicDatabase.tsx +++ b/src/page/Project/Database/components/LogicDatabase/ManageLogicDatabase.tsx @@ -1,3 +1,4 @@ +import { render } from '@/app'; import { checkLogicalTable, deleteLogicalTable, @@ -28,8 +29,13 @@ import { Modal, Space, Tooltip, + Typography, } from 'antd'; import React, { useEffect, useRef, useState } from 'react'; +import { getDataSourceStyleByConnectType } from '@/common/datasource'; +import RiskLevelLabel from '@/component/RiskLevelLabel'; +import { getLocalFormatDateTime } from '@/util/utils'; +import type { FixedType } from 'rc-table/es/interface'; const getColumns = ({ logicalDatabaseId, reload }) => { return [ @@ -148,6 +154,72 @@ const subColumn = [ }, }, ]; + +const physicalDbColumns = [ + { + key: 'name', + title: '数据库名称', + dataIndex: 'name', + width: 100, + fixed: 'left' as FixedType, + render(value, record) { + return ( + <> + + + {value} + + + ); + }, + }, + { + title: '所属数据源', + dataIndex: ['dataSource', 'name'], + width: 160, + ellipsis: { + showTitle: false, + }, + render(value, record, index) { + const style = getDataSourceStyleByConnectType(record?.dialectType); + if (!value) { + return '-'; + } + return ( + <> + + {value} + + ); + }, + }, + { + title: '环境', + dataIndex: 'environmentId', + width: 80, + render(value, record, index) { + return ( + + ); + }, + }, + { + title: '上一次同步时间', + dataIndex: 'objectLastSyncTime', + width: 170, + render(v, record) { + const time = record?.objectLastSyncTime || record?.lastSyncTime; + return getLocalFormatDateTime(time); + }, + }, +]; const expandedRowRender = (record: ILogicalTable, logicalDatabaseId: number, callback: any) => { return (
@@ -181,6 +253,7 @@ const ManageLogicDatabase: React.FC<{ const [_logicalTableMap, setLogicalTableMap] = useState< Map> >(new Map()); + const [drawerOpen, setDrawerOpen] = useState(false); const handleExtractLogicalTables = async () => { const successful = await extractLogicalTables(database?.id); @@ -198,7 +271,11 @@ const ManageLogicDatabase: React.FC<{ logicalDatabaseId: currentDatabase?.id, reload: queryLogicalDatabaseById, }); - // const CallbackExpandedRowRender = useCallback((record) => expandedRowRender(record, logicalTableMap, _logicalTableMap), [_logicalTableMap]) + + const openPhysicalDbdrawer = () => { + setDrawerOpen(true); + }; + useEffect(() => { if (database && openManageLogicDatabase) { queryLogicalDatabaseById(); @@ -209,97 +286,115 @@ const ManageLogicDatabase: React.FC<{ }; }, [openManageLogicDatabase]); return ( - setOpenManageLogicDatabase(false)} - > - - -
- - {database?.name} -
-
-
- - - - - - - } - extra={} + <> + setOpenManageLogicDatabase(false)} > - ( - -
暂无数据
- {isOwner && ( -
- 系统可能正在将表名相似、结构一致的表提取逻辑表,请耐心等待;也可选择手动提取 -
- )} -
- } - /> - )} + + +
+ + {database?.name} +
+
+
+ + + + + + + } + extra={} > - - rowKey={'id'} - scroll={{ - x: 752, - }} - expandable={{ - expandedRowRender: (record) => - expandedRowRender(record, currentDatabase?.id, (values) => { - const newLogicalTables = currentDatabase?.logicalTables?.reduce((pre, cur) => { - if (record?.id === cur?.id) { - cur.topologies = values; - } - pre.push(cur); - return pre; - }, []); - currentDatabase.logicalTables = newLogicalTables; - setCurrentDatabase({ ...currentDatabase }); - }), - rowExpandable: (record) => record.physicalTableCount > 0, - }} - columns={columns} - dataSource={currentDatabase?.logicalTables ?? []} - pagination={null} - loadData={(page, filters) => { - const pageSize = page.pageSize; - const current = page.current; - // loadData(pageSize, current, filters['environmentId']?.[0]); - }} - /> - - - + ( + +
暂无数据
+ {isOwner && ( +
+ 系统可能正在将表名相似、结构一致的表提取逻辑表,请耐心等待;也可选择手动提取 +
+ )} + + } + /> + )} + > + + rowKey={'id'} + scroll={{ + x: 752, + }} + expandable={{ + expandedRowRender: (record) => + expandedRowRender(record, currentDatabase?.id, (values) => { + const newLogicalTables = currentDatabase?.logicalTables?.reduce((pre, cur) => { + if (record?.id === cur?.id) { + cur.topologies = values; + } + pre.push(cur); + return pre; + }, []); + currentDatabase.logicalTables = newLogicalTables; + setCurrentDatabase({ ...currentDatabase }); + }), + rowExpandable: (record) => record.physicalTableCount > 0, + }} + columns={columns} + dataSource={currentDatabase?.logicalTables ?? []} + pagination={null} + loadData={(page, filters) => { + const pageSize = page.pageSize; + const current = page.current; + // loadData(pageSize, current, filters['environmentId']?.[0]); + }} + /> +
+ + + setDrawerOpen(false)} + closable + destroyOnClose + > + {}} + /> + + ); }; export default ManageLogicDatabase; diff --git a/src/page/Project/Database/index.tsx b/src/page/Project/Database/index.tsx index 127480252..6bbdded12 100644 --- a/src/page/Project/Database/index.tsx +++ b/src/page/Project/Database/index.tsx @@ -430,9 +430,8 @@ const Database: React.FC = ({ id, modalStore }) => { dataIndex: 'objectLastSyncTime', width: 170, render(v, record) { - const time = record?.lastSyncTime || record?.objectLastSyncTime; + const time = record?.objectLastSyncTime || record?.lastSyncTime; return getLocalFormatDateTime(time); - /* 这里也缺时间 */ }, }, { diff --git a/src/page/Workspace/SideBar/ResourceTree/TreeNodeMenu/config/table.tsx b/src/page/Workspace/SideBar/ResourceTree/TreeNodeMenu/config/table.tsx index 30db3b8a7..01b72b0c1 100644 --- a/src/page/Workspace/SideBar/ResourceTree/TreeNodeMenu/config/table.tsx +++ b/src/page/Workspace/SideBar/ResourceTree/TreeNodeMenu/config/table.tsx @@ -69,6 +69,10 @@ export const tableMenusConfig: Partial {isNil(value) ? ( diff --git a/src/page/Workspace/components/SQLResultSet/ExecuteHistory.tsx b/src/page/Workspace/components/SQLResultSet/ExecuteHistory.tsx index c36232c60..65d468672 100644 --- a/src/page/Workspace/components/SQLResultSet/ExecuteHistory.tsx +++ b/src/page/Workspace/components/SQLResultSet/ExecuteHistory.tsx @@ -249,23 +249,29 @@ const ExecuteHistory: React.FC = function (props) { const DBCostTime = formatTimeTemplate( BigNumber(executeSQLStage?.totalDurationMicroseconds).div(1000000).toNumber(), ); + const showDBTimeline = ![ + ISqlExecuteResultStatus.CANCELED, + ISqlExecuteResultStatus.CREATED, + ].includes(row?.status); return ( {DBCostTime} - } - > - - + {showDBTimeline ? ( + } + > + + + ) : null} ); }, diff --git a/src/page/Workspace/components/TablePage/ShowTableBaseInfoForm/LogicTableBaseInfo.tsx b/src/page/Workspace/components/TablePage/ShowTableBaseInfoForm/LogicTableBaseInfo.tsx index 58aeb8738..5316cbf07 100644 --- a/src/page/Workspace/components/TablePage/ShowTableBaseInfoForm/LogicTableBaseInfo.tsx +++ b/src/page/Workspace/components/TablePage/ShowTableBaseInfoForm/LogicTableBaseInfo.tsx @@ -136,7 +136,7 @@ const LogicTableBaseInfo = ({ table }) => { }, { label: '逻辑表表达式', - content: table?.info?.expression, + content: table?.expression, span: 8, }, { diff --git a/src/store/sessionManager/database.ts b/src/store/sessionManager/database.ts index e09e56b78..1fe11840f 100644 --- a/src/store/sessionManager/database.ts +++ b/src/store/sessionManager/database.ts @@ -112,19 +112,9 @@ class DatabaseStore { @action public async getTableList() { const sid = generateDatabaseSidByDataBaseId(this.databaseId, this.sessionId); - let data; - switch (this.databaseIdType) { - case DBType.PHYSICAL: { - data = await request.get(`/api/v2/databaseSchema/tables`, { - params: { databaseId: this.databaseId, includePermittedAction: true }, - }); - break; - } - case DBType.LOGICAL: { - data = await logicalDatabaseDetail(this.databaseId); - break; - } - } + const data = await request.get(`/api/v2/databaseSchema/tables`, { + params: { databaseId: this.databaseId, includePermittedAction: true }, + }); runInAction(() => { this.tables = data?.data?.contents?.map((table: ITable) => ({