From 92db8d3a73ad021dd87ae6115171dd89609b30e7 Mon Sep 17 00:00:00 2001 From: zixi0825 Date: Sat, 18 Nov 2023 14:05:05 +0800 Subject: [PATCH] [Feature][MetaData] Add metadata fetch execute page --- .../connector/plugin/JdbcConnector.java | 19 +- .../controller/CatalogMetaDataController.java | 46 +++++ .../catalog/CatalogMetaDataFetchTaskVO.java | 58 ++++++ .../CatalogMetaDataFetchTaskScheduler.java | 3 - .../CatalogMetaDataFetchExecutorImpl.java | 3 +- .../CatalogMetaDataFetchTaskMapper.java | 6 + .../CatalogMetaDataFetchTaskService.java | 4 + ...gMetaDataFetchTaskScheduleServiceImpl.java | 8 +- .../CatalogMetaDataFetchTaskServiceImpl.java | 13 +- .../mapper/CatalogMetaDataFetchTaskMapper.xml | 37 ++++ datavines-ui/src/locale/en_US.ts | 8 +- datavines-ui/src/locale/zh_CN.ts | 8 +- datavines-ui/src/type/metadata.ts | 23 +++ datavines-ui/src/view/Main/Home/List/Card.tsx | 86 +-------- .../view/Main/Home/List/MetaDataFetcher.tsx | 173 ++++++++++++++++++ .../Jobs/components/Schedule/index.tsx | 2 +- 16 files changed, 391 insertions(+), 106 deletions(-) create mode 100644 datavines-server/src/main/java/io/datavines/server/api/controller/CatalogMetaDataController.java create mode 100644 datavines-server/src/main/java/io/datavines/server/api/dto/vo/catalog/CatalogMetaDataFetchTaskVO.java create mode 100644 datavines-server/src/main/resources/mapper/CatalogMetaDataFetchTaskMapper.xml create mode 100644 datavines-ui/src/type/metadata.ts create mode 100644 datavines-ui/src/view/Main/Home/List/MetaDataFetcher.tsx diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-jdbc/src/main/java/io/datavines/connector/plugin/JdbcConnector.java b/datavines-connector/datavines-connector-plugins/datavines-connector-jdbc/src/main/java/io/datavines/connector/plugin/JdbcConnector.java index d41e3be6e..b4fc2ae86 100644 --- a/datavines-connector/datavines-connector-plugins/datavines-connector-jdbc/src/main/java/io/datavines/connector/plugin/JdbcConnector.java +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-jdbc/src/main/java/io/datavines/connector/plugin/JdbcConnector.java @@ -75,12 +75,13 @@ public ConnectorResponse getDatabases(GetDatabasesRequestParam param) throws SQL private JdbcExecutorClient getJdbcExecutorClient(String dataSourceParam) { JdbcConnectionInfo jdbcConnectionInfo = JSONUtils.parseObject(dataSourceParam, JdbcConnectionInfo.class); - - return jdbcExecutorClientManager.getExecutorClient(JdbcDataSourceInfoManager.getDatasourceInfo(dataSourceParam, getDatasourceInfo(jdbcConnectionInfo))); + return jdbcExecutorClientManager.getExecutorClient( + JdbcDataSourceInfoManager.getDatasourceInfo(dataSourceParam, getDatasourceInfo(jdbcConnectionInfo))); } private JdbcExecutorClient getJdbcExecutorClient(String dataSourceParam, JdbcConnectionInfo jdbcConnectionInfo) { - return jdbcExecutorClientManager.getExecutorClient(JdbcDataSourceInfoManager.getDatasourceInfo(dataSourceParam, getDatasourceInfo(jdbcConnectionInfo))); + return jdbcExecutorClientManager.getExecutorClient( + JdbcDataSourceInfoManager.getDatasourceInfo(dataSourceParam, getDatasourceInfo(jdbcConnectionInfo))); } @Override @@ -124,7 +125,7 @@ public ConnectorResponse getTables(GetTablesRequestParam param) throws SQLExcept } } catch (Exception e) { - logger.error("get table list error: {0}", e); + logger.error("get table list error: ", e); } finally { JdbcDataSourceUtils.releaseConnection(connection); } @@ -155,8 +156,7 @@ public ConnectorResponse getColumns(GetColumnsRequestParam param) throws SQLExce tableColumnInfo = new TableColumnInfo(tableName, primaryKeys, columns); } } catch (SQLException e) { - logger.error(e.toString(), e); - throw new SQLException(e.getMessage() + ", " + dataSourceParam); + logger.error("get column list error , param is {} : ", param, e); } finally { JdbcDataSourceUtils.releaseConnection(connection); } @@ -183,7 +183,7 @@ public ConnectorResponse testConnect(TestConnectionRequestParam param) { return ConnectorResponse.builder().status(ConnectorResponse.Status.SUCCESS).result(result).build(); } catch (SQLException e) { - logger.error(e.toString(), e); + logger.error("test connect error, param is {} :", JSONUtils.toJsonString(param), e); } return ConnectorResponse.builder().status(ConnectorResponse.Status.SUCCESS).result(false).build(); @@ -199,11 +199,12 @@ private List getPrimaryKeys(String catalog, String schema, String tableN if (rs == null) { return primaryKeys; } + while (rs.next()) { primaryKeys.add(rs.getString("COLUMN_NAME")); } } catch (Exception e) { - logger.error(e.toString(), e); + logger.error("get primary key error, param is {} :", schema + "." + tableName, e); } finally { JdbcDataSourceUtils.closeResult(rs); } @@ -225,7 +226,7 @@ public List getColumns(String catalog, String schema, String tableNa columnList.add(new ColumnInfo(name, rawType, comment,false)); } } catch (Exception e) { - logger.error(e.toString(), e); + logger.error("get column error, param is {} :", schema + "." + tableName, e); } finally { JdbcDataSourceUtils.closeResult(rs); } diff --git a/datavines-server/src/main/java/io/datavines/server/api/controller/CatalogMetaDataController.java b/datavines-server/src/main/java/io/datavines/server/api/controller/CatalogMetaDataController.java new file mode 100644 index 000000000..416974238 --- /dev/null +++ b/datavines-server/src/main/java/io/datavines/server/api/controller/CatalogMetaDataController.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.server.api.controller; + +import io.datavines.core.aop.RefreshToken; +import io.datavines.core.constant.DataVinesConstants; +import io.datavines.server.repository.service.CatalogMetaDataFetchTaskService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +@Api(value = "catalog", tags = "catalog", produces = MediaType.APPLICATION_JSON_VALUE) +@RestController +@RequestMapping(value = DataVinesConstants.BASE_API_PATH + "/catalog/metadata/task", produces = MediaType.APPLICATION_JSON_VALUE) +@RefreshToken +@Validated +public class CatalogMetaDataController { + + @Autowired + private CatalogMetaDataFetchTaskService catalogMetaDataFetchTaskService; + + @ApiOperation(value = "get job page") + @GetMapping(value = "/page") + public Object page(@RequestParam("datasourceId") Long datasourceId, + @RequestParam("pageNumber") Integer pageNumber, + @RequestParam("pageSize") Integer pageSize) { + return catalogMetaDataFetchTaskService.getFetchTaskPage(datasourceId, pageNumber, pageSize); + } +} \ No newline at end of file diff --git a/datavines-server/src/main/java/io/datavines/server/api/dto/vo/catalog/CatalogMetaDataFetchTaskVO.java b/datavines-server/src/main/java/io/datavines/server/api/dto/vo/catalog/CatalogMetaDataFetchTaskVO.java new file mode 100644 index 000000000..abc786e80 --- /dev/null +++ b/datavines-server/src/main/java/io/datavines/server/api/dto/vo/catalog/CatalogMetaDataFetchTaskVO.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.server.api.dto.vo.catalog; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.datavines.common.enums.ExecutionStatus; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +@Data +public class CatalogMetaDataFetchTaskVO implements Serializable { + + private static final long serialVersionUID = -1L; + + private Long id; + + private String type; + + private String databaseName; + + private String tableName; + + private String executeHost; + + private ExecutionStatus status; + + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime submitTime; + + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime scheduleTime; + + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime startTime; + + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime endTime; + + public String getStatus() { + return status.getDescription(); + } +} diff --git a/datavines-server/src/main/java/io/datavines/server/catalog/metadata/CatalogMetaDataFetchTaskScheduler.java b/datavines-server/src/main/java/io/datavines/server/catalog/metadata/CatalogMetaDataFetchTaskScheduler.java index 2e6eea376..87881ef1c 100644 --- a/datavines-server/src/main/java/io/datavines/server/catalog/metadata/CatalogMetaDataFetchTaskScheduler.java +++ b/datavines-server/src/main/java/io/datavines/server/catalog/metadata/CatalogMetaDataFetchTaskScheduler.java @@ -30,9 +30,6 @@ @Slf4j public class CatalogMetaDataFetchTaskScheduler extends Thread { - private final String CATALOG_METADATA_TASK_LOCK_KEY = - CommonPropertyUtils.getString(CommonPropertyUtils.CATALOG_METADATA_TASK_LOCK_KEY, CommonPropertyUtils.CATALOG_METADATA_TASK_LOCK_KEY_DEFAULT); - private static final int[] RETRY_BACKOFF = {1, 2, 3, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}; private final JobExternalService jobExternalService; diff --git a/datavines-server/src/main/java/io/datavines/server/catalog/metadata/task/CatalogMetaDataFetchExecutorImpl.java b/datavines-server/src/main/java/io/datavines/server/catalog/metadata/task/CatalogMetaDataFetchExecutorImpl.java index b7021e7c5..790c5d4ef 100644 --- a/datavines-server/src/main/java/io/datavines/server/catalog/metadata/task/CatalogMetaDataFetchExecutorImpl.java +++ b/datavines-server/src/main/java/io/datavines/server/catalog/metadata/task/CatalogMetaDataFetchExecutorImpl.java @@ -112,8 +112,7 @@ private void executeFetchDataSource() throws SQLException { GetDatabasesRequestParam param = new GetDatabasesRequestParam(); param.setType(dataSource.getType()); param.setDataSourceParam(dataSource.getParam()); - ConnectorResponse connectorResponse = - connectorFactory.getConnector().getDatabases(param); + ConnectorResponse connectorResponse = connectorFactory.getConnector().getDatabases(param); if (connectorResponse == null || connectorResponse.getResult() == null) { return; diff --git a/datavines-server/src/main/java/io/datavines/server/repository/mapper/CatalogMetaDataFetchTaskMapper.java b/datavines-server/src/main/java/io/datavines/server/repository/mapper/CatalogMetaDataFetchTaskMapper.java index 19cae5ce9..64020c27c 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/mapper/CatalogMetaDataFetchTaskMapper.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/mapper/CatalogMetaDataFetchTaskMapper.java @@ -18,10 +18,16 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.datavines.server.api.dto.vo.catalog.CatalogMetaDataFetchTaskVO; import io.datavines.server.repository.entity.catalog.CatalogMetaDataFetchTask; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper public interface CatalogMetaDataFetchTaskMapper extends BaseMapper { + IPage getJobExecutionPage(Page page, + @Param("datasourceId") Long datasourceId); } diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogMetaDataFetchTaskService.java b/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogMetaDataFetchTaskService.java index 0484f4455..a865b6813 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogMetaDataFetchTaskService.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/CatalogMetaDataFetchTaskService.java @@ -16,8 +16,10 @@ */ package io.datavines.server.repository.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import io.datavines.server.api.dto.bo.catalog.CatalogRefresh; +import io.datavines.server.api.dto.vo.catalog.CatalogMetaDataFetchTaskVO; import io.datavines.server.repository.entity.catalog.CatalogMetaDataFetchTask; import java.time.LocalDateTime; @@ -42,4 +44,6 @@ public interface CatalogMetaDataFetchTaskService extends IService getFetchTaskPage(Long datasourceId,Integer pageNumber, Integer pageSize); } diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogMetaDataFetchTaskScheduleServiceImpl.java b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogMetaDataFetchTaskScheduleServiceImpl.java index 02f22a968..7e7df659c 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogMetaDataFetchTaskScheduleServiceImpl.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogMetaDataFetchTaskScheduleServiceImpl.java @@ -157,8 +157,8 @@ private CatalogMetaDataFetchTaskSchedule update(CatalogMetaDataFetchTaskSchedule public boolean deleteById(long id) { CatalogMetaDataFetchTaskSchedule catalogMetaDataFetchTaskSchedule = getById(id); if (catalogMetaDataFetchTaskSchedule != null) { - Boolean deleteJob = quartzExecutor.deleteJob(getScheduleJobInfo(catalogMetaDataFetchTaskSchedule)); - if (!deleteJob ) { + boolean deleteJob = quartzExecutor.deleteJob(getScheduleJobInfo(catalogMetaDataFetchTaskSchedule)); + if (!deleteJob) { return false; } return removeById(id); @@ -175,7 +175,7 @@ public boolean deleteByDataSourceId(long dataSourceId) { return false; } - Boolean deleteJob = quartzExecutor.deleteJob(getScheduleJobInfo(catalogMetaDataFetchTaskSchedule)); + boolean deleteJob = quartzExecutor.deleteJob(getScheduleJobInfo(catalogMetaDataFetchTaskSchedule)); if (!deleteJob ) { return false; } @@ -228,7 +228,7 @@ private void updateCatalogTaskScheduleParam(CatalogMetaDataFetchTaskSchedule cat throw new DataVinesServerException(Status.SCHEDULE_PARAMETER_IS_NULL_ERROR); } - Boolean isValid = quartzExecutor.isValid(param.getCrontab()); + boolean isValid = quartzExecutor.isValid(param.getCrontab()); if (!isValid) { throw new DataVinesServerException(Status.SCHEDULE_CRON_IS_INVALID_ERROR, param.getCrontab()); } diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogMetaDataFetchTaskServiceImpl.java b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogMetaDataFetchTaskServiceImpl.java index 230f399b4..004e1630a 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogMetaDataFetchTaskServiceImpl.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/CatalogMetaDataFetchTaskServiceImpl.java @@ -17,6 +17,8 @@ package io.datavines.server.repository.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import io.datavines.common.enums.ExecutionStatus; import io.datavines.common.utils.CommonPropertyUtils; @@ -26,6 +28,7 @@ import io.datavines.core.enums.Status; import io.datavines.core.exception.DataVinesServerException; import io.datavines.server.api.dto.bo.catalog.CatalogRefresh; +import io.datavines.server.api.dto.vo.catalog.CatalogMetaDataFetchTaskVO; import io.datavines.server.enums.FetchType; import io.datavines.server.registry.RegistryHolder; import io.datavines.server.repository.entity.catalog.CatalogMetaDataFetchCommand; @@ -68,8 +71,7 @@ public long refreshCatalog(CatalogRefresh catalogRefresh) { queryWrapper.lambda().eq(CatalogMetaDataFetchTask::getStatus,0) .eq(CatalogMetaDataFetchTask::getDataSourceId, catalogRefresh.getDatasourceId()) .eq(CatalogMetaDataFetchTask::getParameter, JSONUtils.toJsonString(catalogRefresh)); - List oldTaskList = - baseMapper.selectList(queryWrapper); + List oldTaskList = baseMapper.selectList(queryWrapper); if (CollectionUtils.isNotEmpty(oldTaskList)) { registryHolder.release("1028"); @@ -164,6 +166,7 @@ public String getTaskExecuteHost(Long catalogTaskId) { } @Override + @Transactional(rollbackFor = Exception.class) public boolean deleteByDataSourceId(long dataSourceId) { remove(new QueryWrapper().eq("datasource_id", dataSourceId)); catalogMetaDataFetchTaskScheduleService.deleteByDataSourceId(dataSourceId); @@ -215,4 +218,10 @@ public LocalDateTime getRefreshTime(long dataSourceId, String databaseName, Stri return refreshTime; } + + @Override + public IPage getFetchTaskPage(Long datasourceId,Integer pageNumber, Integer pageSize) { + Page page = new Page<>(pageNumber, pageSize); + return baseMapper.getJobExecutionPage(page, datasourceId); + } } diff --git a/datavines-server/src/main/resources/mapper/CatalogMetaDataFetchTaskMapper.xml b/datavines-server/src/main/resources/mapper/CatalogMetaDataFetchTaskMapper.xml new file mode 100644 index 000000000..330de758c --- /dev/null +++ b/datavines-server/src/main/resources/mapper/CatalogMetaDataFetchTaskMapper.xml @@ -0,0 +1,37 @@ + + + + + + + select * from dv_catalog_metadata_fetch_task + + + datasource_id = #{datasourceId} + + + + + + \ No newline at end of file diff --git a/datavines-ui/src/locale/en_US.ts b/datavines-ui/src/locale/en_US.ts index dd2aa42c8..9bf5526c3 100755 --- a/datavines-ui/src/locale/en_US.ts +++ b/datavines-ui/src/locale/en_US.ts @@ -81,8 +81,9 @@ export default { home_search_placeholder: 'Search to DataSource', home_create_datasource: 'Create DataSource', - home_metadata_fetch: 'Metadata Fetcher', - home_metadata_fetch_schedule: 'Metadata Fetcher Schedule', + home_metadata_fetch: 'Metadata Manager', + home_metadata_fetch_now: 'Fetch', + home_metadata_fetch_schedule: 'Metadata Schedule Manager', // jobs jobs_list: 'Jobs', @@ -102,6 +103,9 @@ export default { jobs_task_table_name: 'Table', jobs_task_column_name: 'Column', jobs_task_metric_type: 'Metric Type', + jobs_task_execute_host: 'Execute Host', + jobs_task_schedule_time: 'Schedule Time', + jobs_task_submit_time: 'Submit Time', jobs_task_start_time: 'Start Time', jobs_task_end_time: 'End Time', jobs_task_stop_btn: 'Stop', diff --git a/datavines-ui/src/locale/zh_CN.ts b/datavines-ui/src/locale/zh_CN.ts index e82313d4e..33a8305ff 100755 --- a/datavines-ui/src/locale/zh_CN.ts +++ b/datavines-ui/src/locale/zh_CN.ts @@ -81,8 +81,9 @@ export default { home_search_placeholder: '搜索数据源', home_create_datasource: '创建数据源', - home_metadata_fetch: '元数据抓取', - home_metadata_fetch_schedule: '元数据抓取调度', + home_metadata_fetch: '元数据管理', + home_metadata_fetch_now: '立即抓取', + home_metadata_fetch_schedule: '元数据调度管理', // jobs jobs_list: '规则作业列表', @@ -102,6 +103,9 @@ export default { jobs_task_table_name: '表名', jobs_task_column_name: '列名', jobs_task_metric_type: '规则类型', + jobs_task_execute_host: '执行服务器地址', + jobs_task_schedule_time: '调度时间', + jobs_task_submit_time: '提交时间', jobs_task_start_time: '开始时间', jobs_task_end_time: '结束时间', jobs_task_stop_btn: '停止', diff --git a/datavines-ui/src/type/metadata.ts b/datavines-ui/src/type/metadata.ts new file mode 100644 index 000000000..023e3b1e5 --- /dev/null +++ b/datavines-ui/src/type/metadata.ts @@ -0,0 +1,23 @@ +export type TMetaDataFetchTaskTableItem = { + id: string | number, + + type: string, + + databaseName: string, + + tableName: string, + status: 'submitted' | 'running' | 'failure' | 'success' | 'kill', + + scheduleTime: string, + + submitTime: string, + + startTime: string, + + endTime: string +} + +export type TMetaDataFetchTaskTableData = { + list: TMetaDataFetchTaskTableItem[], + total: number +}; \ No newline at end of file diff --git a/datavines-ui/src/view/Main/Home/List/Card.tsx b/datavines-ui/src/view/Main/Home/List/Card.tsx index c638d28c4..3b1f91e23 100644 --- a/datavines-ui/src/view/Main/Home/List/Card.tsx +++ b/datavines-ui/src/view/Main/Home/List/Card.tsx @@ -1,13 +1,13 @@ import React, { useState } from 'react'; import { - Pagination, Dropdown, Menu, Popconfirm, Row, Col, Tag, Modal, + Pagination, Dropdown, Menu, Popconfirm, Row, Col, Tag, Modal, Table } from 'antd'; import { EditOutlined, DeleteOutlined, EllipsisOutlined, FundOutlined, } from '@ant-design/icons'; import { useIntl } from 'react-intl'; import { IDataSourceListItem, IDataSourceList } from '@/type/dataSource'; -import Schedule from '@/view/Main/HomeDetail/Jobs/components/Schedule'; +import MetaDataFetcher from "view/Main/Home/List/MetaDataFetcher"; type IndexProps = { tableData: IDataSourceList, @@ -95,7 +95,6 @@ const Index: React.FC = ({ }, { label: ( - { setisScheduleOpen(true); setUuid(item.id); @@ -104,7 +103,6 @@ const Index: React.FC = ({ {intl.formatMessage({ id: 'home_metadata_fetch' })} - ), key: 'push', }, @@ -129,78 +127,8 @@ const Index: React.FC = ({ {intl.formatMessage({ id: 'datasource_updateTime' })} : {item.updateTime} - - - {/* { - goDetail(item); - }} - > - {item.name} - - )} - extra={( -
(e.stopPropagation())}> - (onEdit(item))}>{intl.formatMessage({ id: 'common_edit' })}, - key: 'edit', - icon: , - }, - { - label: ( - { onDelete(item); }} - okText={intl.formatMessage({ id: 'common_Ok' })} - cancelText={intl.formatMessage({ id: 'common_Cancel' })} - > - {intl.formatMessage({ id: 'common_delete' })} - - ), - icon: , - key: 'delete', - }, - ]} - /> - )} - placement="bottomLeft" - > - - {intl.formatMessage({ id: 'common_more' })} - - - -
- )} - style={{ marginBottom: '15px' }} - > -

- {intl.formatMessage({ id: 'datasource_modal_source_type' })} - : - {' '} - {item.type} -

-

- {intl.formatMessage({ id: 'datasource_updateTime' })} - : - {' '} - {item.updateTime} -

-
*/} ); @@ -228,7 +156,7 @@ const Index: React.FC = ({ /> { @@ -237,15 +165,11 @@ const Index: React.FC = ({ open={isScheduleOpen} maskClosable={false} > - { setisScheduleOpen(false); }} - width="100%" - style={{ height: 'auto' }} - jobId={uuid} - isShowPush - api="catalog/metadata" /> diff --git a/datavines-ui/src/view/Main/Home/List/MetaDataFetcher.tsx b/datavines-ui/src/view/Main/Home/List/MetaDataFetcher.tsx new file mode 100644 index 000000000..eb9e407e4 --- /dev/null +++ b/datavines-ui/src/view/Main/Home/List/MetaDataFetcher.tsx @@ -0,0 +1,173 @@ +import React, {useEffect, useState} from 'react'; +import { + Table +} from 'antd'; +import { useIntl } from 'react-intl'; +import Schedule from '@/view/Main/HomeDetail/Jobs/components/Schedule'; +import {Tabs} from "antd/lib"; +import TabPane = Tabs.TabPane; +import {TJobsInstanceTableData, TJobsInstanceTableItem} from "@/type/JobsInstance"; +import {$http} from "@/http"; +import {IF, useMount} from "@Editor/common"; +import {ColumnsType} from "antd/lib/table"; +import {defaultRender} from "utils/helper"; + +type IndexProps = { + datasourceId: number | string, + onSavaEnd: any, +} + +const Index: React.FC = ({datasourceId, onSavaEnd}) => { + const intl = useIntl(); + const [loading, setLoading] = useState(false); + const [tableData, setTableData] = useState({ list: [], total: 0 }); + const [pageParams, setPageParams] = useState({ + pageNumber: 1, + pageSize: 10, + }); + + const getData = async (values?: any, $pageParams?: any) => { + try { + setLoading(true); + const res = (await $http.get('/catalog/metadata/task/page', { + datasourceId: datasourceId, + ...($pageParams || pageParams), + })) || []; + setTableData({ + list: res?.records || [], + total: res.total || 0, + }); + } catch (error) { + console.log("get execution page : {}", error) + } finally { + setLoading(false); + } + }; + useMount(() => { + getData(); + }); + + useEffect(() =>{ + getData(); + }) + + const onChange = ({ current, pageSize }: any) => { + setPageParams({ + pageNumber: current, + pageSize, + }); + getData(null, { + pageNumber: current, + pageSize, + }); + }; + + const columns: ColumnsType = [ + { + title: intl.formatMessage({ id: 'jobs_task_type' }), + dataIndex: 'type', + key: 'type', + width: 100, + render: (text) => defaultRender(text, 300), + }, + { + title: intl.formatMessage({ id: 'jobs_task_schema_name' }), + dataIndex: 'databaseName', + key: 'databaseName', + width: 100, + render: (text) => defaultRender(text, 300), + }, + { + title: intl.formatMessage({ id: 'jobs_task_table_name' }), + dataIndex: 'tableName', + key: 'tableName', + width: 200, + render: (text) => defaultRender(text, 300), + }, + { + title: intl.formatMessage({ id: 'jobs_task_status' }), + dataIndex: 'status', + key: 'status', + width: 100, + render: (text: string) =>
{text}
, + }, + { + title: intl.formatMessage({ id: 'jobs_task_execute_host' }), + dataIndex: 'executeHost', + key: 'executeHost', + width: 140, + render: (text: string) =>
{text}
, + }, + { + title: intl.formatMessage({ id: 'jobs_task_schedule_time' }), + dataIndex: 'scheduleTime', + key: 'scheduleTime', + width: 200, + render: (text: string) =>
{text || '--'}
, + }, + { + title: intl.formatMessage({ id: 'jobs_task_submit_time' }), + dataIndex: 'submitTime', + key: 'submitTime', + width: 200, + render: (text: string) =>
{text || '--'}
, + }, + { + title: intl.formatMessage({ id: 'jobs_task_start_time' }), + dataIndex: 'startTime', + key: 'startTime', + width: 200, + render: (text: string) =>
{text || '--'}
, + }, + { + title: intl.formatMessage({ id: 'jobs_task_end_time' }), + dataIndex: 'endTime', + key: 'endTime', + width: 200, + render: (text: string) =>
{text || '--'}
, + } + ]; + + return ( + <> + + + + { + onSavaEnd(); + }} + width="100%" + style={{ height: 'auto' }} + jobId={datasourceId} + isShowPush + api="catalog/metadata" + /> + + + + + size="middle" + loading={loading} + rowKey="id" + columns={columns} + dataSource={tableData.list || []} + onChange={onChange} + pagination={{ + size: 'small', + total: tableData.total, + showSizeChanger: true, + current: pageParams.pageNumber, + pageSize: pageParams.pageSize, + }} + /> + + + + ) +}; + +export default Index; \ No newline at end of file diff --git a/datavines-ui/src/view/Main/HomeDetail/Jobs/components/Schedule/index.tsx b/datavines-ui/src/view/Main/HomeDetail/Jobs/components/Schedule/index.tsx index e03711b23..356ac7a91 100644 --- a/datavines-ui/src/view/Main/HomeDetail/Jobs/components/Schedule/index.tsx +++ b/datavines-ui/src/view/Main/HomeDetail/Jobs/components/Schedule/index.tsx @@ -493,7 +493,7 @@ const ScheduleContainer = ({ onSave('push')}>{intl.formatMessage({ id: 'home_metadata_fetch' })} : undefined, + isShowPush ? : undefined, , ]} >