Unverified Commit 5c7529cc authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Refactor][web] refactor reg's datasource (#1975)

* refactor reg's datasource * added detail page * optimize layout * fix cannot close modal * added table info * fix i18n * modify layout * modify layout
parent d185cf82
......@@ -31,6 +31,7 @@ import org.dinky.model.QueryData;
import org.dinky.model.Schema;
import org.dinky.model.SqlGeneration;
import org.dinky.service.DataBaseService;
import org.dinky.utils.MessageResolverUtils;
import java.util.ArrayList;
import java.util.List;
......@@ -64,25 +65,42 @@ public class DataBaseController {
private final DataBaseService databaseService;
/** 新增或者更新 */
/**
* save or update database
*
* @param database {@link DataBase}
* @return {@link Result}< {@link Void}>
*/
@PutMapping
public Result<Void> saveOrUpdate(@RequestBody DataBase database) {
if (databaseService.saveOrUpdateDataBase(database)) {
DriverPool.remove(database.getName());
return Result.succeed("更新成功");
return Result.succeed(MessageResolverUtils.getMessage("save.success"));
} else {
return Result.failed("更新失败");
return Result.failed(MessageResolverUtils.getMessage("save.failed"));
}
}
/** 动态查询列表 */
/**
* get all database
*
* @param para {@link JsonNode}
* @return {@link ProTableResult}< {@link DataBase}>
*/
@PostMapping
public ProTableResult<DataBase> listDataBases(@RequestBody JsonNode para) {
return databaseService.selectForProTable(para);
}
/** 批量删除 */
/**
* batch delete database , this method is {@link @Deprecated} , please use {@link
* #deleteById(Integer id)}
*
* @param para {@link JsonNode}
* @return {@link Result}< {@link Void}>
*/
@DeleteMapping
@Deprecated
public Result<Void> deleteMul(@RequestBody JsonNode para) {
if (para.size() > 0) {
List<Integer> error = new ArrayList<>();
......@@ -102,21 +120,64 @@ public class DataBaseController {
}
}
/** 获取指定ID的信息 */
/**
* delete by id
*
* @param id {@link Integer}
* @return {@link Result}< {@link Void}>
*/
@DeleteMapping("/delete")
public Result<Void> deleteById(@RequestParam Integer id) {
if (databaseService.removeById(id)) {
return Result.succeed(MessageResolverUtils.getMessage("delete.success"));
}
return Result.failed(MessageResolverUtils.getMessage("delete.failed"));
}
/**
* enable or disable by id
*
* @param id {@link Integer}
* @return {@link Result}< {@link Void}>
*/
@PutMapping("/enable")
public Result<Void> enable(@RequestParam Integer id) {
if (databaseService.enable(id)) {
return Result.succeed(MessageResolverUtils.getMessage("modify.success"));
}
return Result.failed(MessageResolverUtils.getMessage("modify.failed"));
}
/**
* get one by id
*
* @param database {@link DataBase}
* @return {@link Result}< {@link DataBase}>
*/
@PostMapping("/getOneById")
@Deprecated
public Result<DataBase> getOneById(@RequestBody DataBase database) {
database = databaseService.getById(database.getId());
return Result.succeed(database, "获取成功");
return Result.succeed(database, MessageResolverUtils.getMessage("response.get.success"));
}
/** 获取可用的数据库列表 */
/**
* get all enabled database
*
* @return {@link Result}< {@link List}< {@link DataBase}>>
*/
@GetMapping("/listEnabledAll")
public Result<List<DataBase>> listEnabledAll() {
List<DataBase> dataBases = databaseService.listEnabledAll();
return Result.succeed(dataBases, "获取成功");
return Result.succeed(dataBases, MessageResolverUtils.getMessage("response.get.success"));
}
/** 连接测试 */
/**
* test connect database
*
* @param database {@link DataBase}
* @return {@link Result}< {@link Void}>
*/
@PostMapping("/testConnect")
public Result<Void> testConnect(@RequestBody DataBase database) {
String msg = databaseService.testConnect(database);
......@@ -128,8 +189,14 @@ public class DataBaseController {
}
}
/** 全部心跳监测 */
/**
* heart beat check all database, this method is {@link @Deprecated} , please use {@link
* #checkHeartBeatById(Integer id)}
*
* @return {@link Result}< {@link Void}>
*/
@PostMapping("/checkHeartBeats")
@Deprecated
public Result<Void> checkHeartBeats() {
List<DataBase> dataBases = databaseService.listEnabledAll();
for (DataBase dataBase : dataBases) {
......@@ -142,8 +209,15 @@ public class DataBaseController {
return Result.succeed("状态刷新完成");
}
/** 心跳检测指定ID */
/**
* heart beat check by id, this method is {@link @Deprecated} , please use {@link
* #checkHeartBeatByDataSourceId(Integer id)}
*
* @param id {@link Integer}
* @return {@link Result}< {@link Void}>
*/
@GetMapping("/checkHeartBeatById")
@Deprecated
public Result<Void> checkHeartBeatById(@RequestParam Integer id) {
DataBase dataBase = databaseService.getById(id);
Asserts.checkNotNull(dataBase, "该数据源不存在!");
......@@ -160,21 +234,61 @@ public class DataBaseController {
return Result.succeed("数据源连接正常");
}
/** 获取元数据的表 */
/**
* heart beat check by id
*
* @param id {@link Integer}
* @return {@link Result}< {@link Void}>
*/
@PutMapping("/checkHeartBeatByDataSourceId")
public Result<Void> checkHeartBeatByDataSourceId(@RequestParam Integer id) {
DataBase dataBase = databaseService.getById(id);
Asserts.checkNotNull(dataBase, "该数据源不存在!");
String error = "";
try {
databaseService.checkHeartBeat(dataBase);
} catch (Exception e) {
error = e.getMessage();
}
databaseService.updateById(dataBase);
if (Asserts.isNotNullString(error)) {
return Result.failed(error);
}
return Result.succeed("数据源连接正常");
}
/**
* get all database of schemas and tables
*
* @param id {@link Integer}
* @return {@link Result}< {@link List}< {@link Schema}>>
*/
@Cacheable(cacheNames = "metadata_schema", key = "#id")
@GetMapping("/getSchemasAndTables")
public Result<List<Schema>> getSchemasAndTables(@RequestParam Integer id) {
return Result.succeed(databaseService.getSchemasAndTables(id), "获取成功");
}
/** 清除元数据表的缓存 */
/**
* clear cache of schemas and tables
*
* @param id {@link Integer}
* @return {@link Result}< {@link String}>
*/
@CacheEvict(cacheNames = "metadata_schema", key = "#id")
@GetMapping("/unCacheSchemasAndTables")
public Result<String> unCacheSchemasAndTables(@RequestParam Integer id) {
return Result.succeed("clear cache", "success");
}
/** 获取元数据的指定表的列 */
/**
* get columns of table
*
* @param id {@link Integer}
* @param schemaName {@link String}
* @param tableName {@link String}
* @return {@link Result}< {@link List}< {@link Column}>>
*/
@GetMapping("/listColumns")
public Result<List<Column>> listColumns(
@RequestParam Integer id,
......@@ -183,7 +297,12 @@ public class DataBaseController {
return Result.succeed(databaseService.listColumns(id, schemaName, tableName), "获取成功");
}
/** 获取元数据的指定表的数据 */
/**
* query data of table
*
* @param queryData {@link QueryData}
* @return {@link Result}< {@link JdbcSelectResult}>
*/
@PostMapping("/queryData")
public Result<JdbcSelectResult> queryData(@RequestBody QueryData queryData) {
JdbcSelectResult jdbcSelectResult = databaseService.queryData(queryData);
......@@ -194,7 +313,12 @@ public class DataBaseController {
}
}
/** 执行sql */
/**
* exec sql
*
* @param queryData {@link QueryData}
* @return {@link Result}< {@link JdbcSelectResult}>
*/
@PostMapping("/execSql")
public Result<JdbcSelectResult> execSql(@RequestBody QueryData queryData) {
JdbcSelectResult jdbcSelectResult = databaseService.execSql(queryData);
......@@ -205,7 +329,14 @@ public class DataBaseController {
}
}
/** 获取 SqlGeneration */
/**
* get sql generation
*
* @param id {@link Integer}
* @param schemaName {@link String}
* @param tableName {@link String}
* @return {@link Result}< {@link SqlGeneration}>
*/
@GetMapping("/getSqlGeneration")
public Result<SqlGeneration> getSqlGeneration(
@RequestParam Integer id,
......@@ -214,7 +345,12 @@ public class DataBaseController {
return Result.succeed(databaseService.getSqlGeneration(id, schemaName, tableName), "获取成功");
}
/** copyDatabase */
/**
* copy database
*
* @param database {@link DataBase}
* @return {@link Result}< {@link Void}>
*/
@PostMapping("/copyDatabase")
public Result<Void> copyDatabase(@RequestBody DataBase database) {
if (databaseService.copyDatabase(database)) {
......
......@@ -36,16 +36,61 @@ import java.util.List;
*/
public interface DataBaseService extends ISuperService<DataBase> {
/**
* test connect database
*
* @param dataBase {@link DataBase}
* @return {@link String}
*/
String testConnect(DataBase dataBase);
boolean checkHeartBeat(DataBase dataBase);
boolean saveOrUpdateDataBase(DataBase dataBase);
/**
* check heart beat
*
* @param dataBase {@link DataBase}
* @return {@link Boolean}
*/
Boolean checkHeartBeat(DataBase dataBase);
/**
* save or update database
*
* @param dataBase {@link DataBase}
* @return {@link Boolean}
*/
Boolean saveOrUpdateDataBase(DataBase dataBase);
/**
* enable or disable database
*
* @param id {@link Integer}
* @return {@link Boolean}
*/
Boolean enable(Integer id);
/**
* list all enable database
*
* @return {@link List}< {@link DataBase}>
*/
List<DataBase> listEnabledAll();
/**
* get all database of schemas and tables
*
* @param id {@link Integer}
* @return {@link List}< {@link Schema}>
*/
List<Schema> getSchemasAndTables(Integer id);
/**
* get columns of table
*
* @param id {@link Integer}
* @param schemaName {@link String}
* @param tableName {@link String}
* @return {@link List}< {@link Column}>
*/
List<Column> listColumns(Integer id, String schemaName, String tableName);
String getFlinkTableSql(Integer id, String schemaName, String tableName);
......@@ -54,15 +99,41 @@ public interface DataBaseService extends ISuperService<DataBase> {
String getSqlCreate(Integer id, String schemaName, String tableName);
/**
* query data of table
*
* @param queryData {@link QueryData}
* @return {@link JdbcSelectResult}
*/
JdbcSelectResult queryData(QueryData queryData);
/**
* exec sql
*
* @param queryData {@link QueryData}
* @return {@link JdbcSelectResult}
*/
JdbcSelectResult execSql(QueryData queryData);
/**
* get sql generation
*
* @param id {@link Integer}
* @param schemaName {@link String}
* @param tableName {@link String}
* @return {@link SqlGeneration}
*/
SqlGeneration getSqlGeneration(Integer id, String schemaName, String tableName);
List<String> listEnabledFlinkWith();
String getEnabledFlinkWithSql();
boolean copyDatabase(DataBase database);
/**
* copy database
*
* @param database {@link DataBase}
* @return {@link Boolean}
*/
Boolean copyDatabase(DataBase database);
}
......@@ -59,7 +59,7 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa
}
@Override
public boolean checkHeartBeat(DataBase dataBase) {
public Boolean checkHeartBeat(DataBase dataBase) {
boolean isHealthy = false;
dataBase.setHeartbeatTime(LocalDateTime.now());
try {
......@@ -80,7 +80,7 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa
}
@Override
public boolean saveOrUpdateDataBase(DataBase dataBase) {
public Boolean saveOrUpdateDataBase(DataBase dataBase) {
if (Asserts.isNull(dataBase)) {
return false;
}
......@@ -109,6 +109,20 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa
}
}
/**
* @param id
* @return
*/
@Override
public Boolean enable(Integer id) {
DataBase dataBase = getById(id);
if (Asserts.isNull(dataBase)) {
return false;
}
dataBase.setEnabled(!dataBase.getEnabled());
return updateById(dataBase);
}
@Override
public List<DataBase> listEnabledAll() {
return this.list(new QueryWrapper<DataBase>().eq("enabled", 1));
......@@ -219,7 +233,7 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa
}
@Override
public boolean copyDatabase(DataBase database) {
public Boolean copyDatabase(DataBase database) {
String name = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 10);
database.setId(null);
database.setName(
......
......@@ -16,13 +16,13 @@
*/
// https://umijs.org/config/
import { defineConfig } from '@umijs/max';
import { join } from 'path';
import {defineConfig} from '@umijs/max';
import {join} from 'path';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
import routes from './routes';
const { REACT_APP_ENV = 'dev' } = process.env;
const {REACT_APP_ENV = 'dev'} = process.env;
export default defineConfig({
/**
......@@ -30,12 +30,12 @@ export default defineConfig({
* doc description: https://juejin.cn/post/7153525746751766559
* issue: https://www.github.com/ant-design/ant-design-pro/issues/10550
*/
/* keepalive: [/./],
tabsLayout: {
hasDropdown: true, // Whether there is a drop-down menu
hasCustomTabs: true, // Whether there are custom tabs
hasFixedHeader: true, // Whether there is a fixed header
},*/
/* keepalive: [/./],
tabsLayout: {
hasDropdown: true, // Whether there is a drop-down menu
hasCustomTabs: true, // Whether there are custom tabs
hasFixedHeader: true, // Whether there is a fixed header
},*/
/**
* @name 开启 hash 模式
......@@ -131,6 +131,7 @@ export default defineConfig({
antd: true,
// default true, when it is true, will use `navigator.language` overwrite default
baseNavigator: true,
useLocalStorage: true,
},
/**
* @name antd 插件
......@@ -156,7 +157,7 @@ export default defineConfig({
*/
headScripts: [
// 解决首次加载时白屏的问题
{ src: '/scripts/loading.js', async: true },
{src: '/scripts/loading.js', async: true},
],
//================ pro 插件配置 =================
presets: ['umi-presets-pro'],
......@@ -167,14 +168,14 @@ export default defineConfig({
*/
openAPI: [
{
requestLibPath: "import { request } from '@umijs/max'",
requestLibPath: 'import { request } from \'@umijs/max\'',
// 或者使用在线的版本
// schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json"
schemaPath: join(__dirname, 'oneapi.json'),
mock: false,
},
{
requestLibPath: "import { request } from '@umijs/max'",
requestLibPath: 'import { request } from \'@umijs/max\'',
schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json',
projectName: 'swagger',
},
......
......@@ -118,7 +118,12 @@ export default [
path: '/registration/database',
name: 'database',
icon: 'DatabaseOutlined',
// component: './RegistrationCenter/DataBase',
component: './RegCenter/DataSource',
routes: [
{
path: '/registration/database/detail/:id',
}
]
},
{
path: '/registration/alert',
......@@ -167,7 +172,7 @@ export default [
name: 'auth',
icon: 'SafetyCertificateOutlined',
path: '/auth',
access: "canAdmin",
access: 'canAdmin',
routes: [
{
path: '/auth',
......
......@@ -66,6 +66,7 @@
"react-monaco-editor": "^0.52.0",
"react-spring": "^9.7.1",
"screenfull": "^6.0.2",
"styled-components": "^6.0.0-rc.1",
"use-sse": "^2.0.1"
},
"devDependencies": {
......
......@@ -21,21 +21,21 @@ import {SWITCH_OPTIONS} from "@/services/constants";
import React from "react";
type EnableSwitchProps = {
record: any;
onChange: () => void;
disabled?: boolean;
record: any;
onChange: () => void;
disabled?: boolean;
}
export const EnableSwitchBtn: React.FC<EnableSwitchProps> = (props) => {
const {record, onChange, disabled = false} = props;
const {record, onChange, disabled = false} = props;
return <>
<Space className={"hidden-overflow"}>
<Switch
{...SWITCH_OPTIONS()}
checked={record.enabled}
disabled={disabled}
onChange={() => onChange()}/>
</Space>
</>
}
\ No newline at end of file
return <>
<Space className={"hidden-overflow"}>
<Switch
{...SWITCH_OPTIONS()}
checked={record.enabled}
disabled={disabled}
onChange={() => onChange()}/>
</Space>
</>;
};
This diff is collapsed.
/*
* 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.
*/
import styled from "styled-components";
export const DataSourceAction = styled.div`
display: flex !important;
justify-content: space-between;
margin-left: 2vw;
margin-right: 2vw;
`;
export const DataSourceDetailBackButton = styled.div`
display: flex !important;
justify-content: flex-end;
`;
......@@ -232,6 +232,16 @@ ol {
}
}
.schemaTree {
height: 75vh;
max-height: 75vh;
background-color: white;
}
.columnTable{
max-height: 60vh;
overflow: auto;
}
.code-content-empty {
height: 100%;
display: flex;
......
......@@ -50,6 +50,8 @@ export default {
'button.recycle': 'Recycle',
'button.refresh': 'Refresh',
'button.test': 'Test',
'button.clear': 'Clear',
'button.copy': 'Copy',
'button.refreshData': 'Refresh Data',
'button.collapseDir': 'Collapse Directory',
'button.asc': 'ASC',
......
......@@ -116,6 +116,66 @@ export default {
//-------------------------------- register center --------------------------------
// datasource
'rc.ds.management': 'DataSource Management',
'rc.ds.name': 'Name',
'rc.ds.groupName': 'Group Type',
'rc.ds.type': 'DataSource Type',
'rc.ds.url': 'Database URL',
'rc.ds.username': 'Username',
'rc.ds.password': 'Password',
'rc.ds.flinkConfig': 'Flink Connection Config',
'rc.ds.flinkTemplate': 'Flink Connection Template',
'rc.ds.create': 'Create DataSource',
'rc.ds.modify': 'Modify DataSource',
'rc.ds.delete': 'Delete DataSource',
'rc.ds.deleteConfirm': 'Are you sure to delete this DataSource? ',
'rc.ds.namePlaceholder': 'Please enter a name!',
'rc.ds.groupNamePlaceholder': 'Please select a group type!',
'rc.ds.typePlaceholder': 'Please select the DataSource type! Enter keywords to search',
'rc.ds.urlPlaceholder': 'Please enter a properly formatted url link!',
'rc.ds.usernamePlaceholder': 'Please enter username!',
'rc.ds.passwordPlaceholder': 'Please enter password!',
'rc.ds.flinkConfigPlaceholder': 'Please specify the default configuration of Flink With!',
'rc.ds.flinkConfigTooltip': 'Avoid disclosure of private information, and reuse the connection configuration as a global variable. In FlinkSQL, you can use `variable reference method` to load the connection configuration. Explanation: The reference name refers to the unique identifier, which is the `name` in this form. Note that you need to enable global variables (the original fragment mechanism)',
'rc.ds.flinkTemplatePlaceholder': 'Please specify the generation template of Flink With!',
'rc.ds.flinkTemplateTooltip': 'Flink connection template is an extended function for generating FlinkSQL DDL. Among them, the schemaName in `variable reference method` refers to dynamically obtaining the database, and the tableName in `variable reference method` refers to dynamically obtaining the table name',
'rc.ds.source': 'Source',
'rc.ds.warehouse': 'Data Warehouse',
'rc.ds.application': 'Application',
'rc.ds.backup': 'Backup',
'rc.ds.other': 'Other',
'rc.ds.enter': 'Click the icon picture in the list to enter the details page of the DataSource! Support viewing the database & table information of the DataSource, and timely query',
'rc.ds.enter.error': 'The DataSource status is abnormal and cannot be entered, only after the heartbeat is normal!',
// datasource of schema info page
// tags
'rc.ds.detail.tag.desc': 'Description',
'rc.ds.detail.tag.query': 'Query',
'rc.ds.detail.tag.gensql': 'Generate SQL',
'rc.ds.detail.tag.console': 'Console',
// tips
'rc.ds.detail.tips': 'Click on the table on the left to get the description information of the table',
// columns info
'rc.ds.no': 'No.',
'rc.ds.columnName': 'Field Name',
'rc.ds.columnType': 'Type',
'rc.ds.comment': 'Comment',
'rc.ds.primarykey': 'Primary Key',
'rc.ds.autoIncrement': 'Autoincrement',
'rc.ds.isNull': 'Not Null',
'rc.ds.null': 'Nullable',
'rc.ds.default': 'Default Value',
'rc.ds.length': 'Length',
'rc.ds.precision': 'Precision',
'rc.ds.decimalDigits': 'Decimal Range',
'rc.ds.character': 'Character Set',
'rc.ds.collationRule': 'Collation Rule',
'rc.ds.javaType': 'Java Type',
// alert instance
'rc.ai.management': 'Alert Instance Management',
'rc.ai.name': 'Name',
......@@ -141,7 +201,7 @@ export default {
'rc.ai.msgtypePleaseHolder': 'please choose message Send Type`',
'rc.ai.corpIdPleaseHolder': 'Please enter CorpId',
'rc.ai.wechatAtUsersPleaseHolder': 'Please enter the @user ID (enterprise and micro user name spelled out), separated by multiple commas!',
'rc.ai.sendTypePleaseHolder' : 'Please choose Send Type',
'rc.ai.sendTypePleaseHolder': 'Please choose Send Type',
'rc.ai.agentIdPleaseHolder': 'Please enter AgentId',
'rc.ai.receiversPleaseHolder': 'Please enter recipient email address! Separate multiple commas',
'rc.ai.receiverCcsPleaseHolder': 'Please enter the receiverCcs email address! Separate multiple commas!',
......@@ -288,38 +348,37 @@ export default {
// udf template
'rc.udf.management': 'UDF Template Management',
'rc.template.name' : 'Template Name',
'rc.template.namePlaceholder' : 'Please enter the template name! ',
'rc.template.codeType' : 'Code Type',
'rc.template.codeTypePlaceholder' : 'Please select code type! ',
'rc.template.functionType' : 'Function Type',
'rc.template.functionTypePlaceholder' : 'Please select function type! ',
'rc.template.templateCodeLabel' : 'Template Code( {language} )',
'rc.template.templateCode' : 'Template Code',
'rc.template.templateCodePlaceholder' : 'Please edit the template code! ',
'rc.template.delete' : 'Delete Template! ',
'rc.template.deleteConfirm' : 'Are you sure you want to delete this template?',
'rc.template.name': 'Template Name',
'rc.template.namePlaceholder': 'Please enter the template name! ',
'rc.template.codeType': 'Code Type',
'rc.template.codeTypePlaceholder': 'Please select code type! ',
'rc.template.functionType': 'Function Type',
'rc.template.functionTypePlaceholder': 'Please select function type! ',
'rc.template.templateCodeLabel': 'Template Code( {language} )',
'rc.template.templateCode': 'Template Code',
'rc.template.templateCodePlaceholder': 'Please edit the template code! ',
'rc.template.delete': 'Delete Template! ',
'rc.template.deleteConfirm': 'Are you sure you want to delete this template?',
'rc.template.create': 'Create UDF Template',
'rc.template.modify': 'Modify UDF Template',
//-------------------------------- setting center --------------------------------
// process
'sys.process.id':'Process ID',
'sys.process.id': 'Process ID',
'sys.process.name': 'Process Name',
'sys.process.taskId':'Job ID',
'sys.process.taskId': 'Job ID',
'sys.process.type': 'Type',
'sys.process.status': 'Status',
'sys.process.startTime': 'Start Time',
'sys.process.endTime': 'End Time',
'sys.process.duration': 'Duration',
'sys.process.operator': 'Operator',
'sys.process.viewInfoLog':'View Info Level Log',
'sys.process.viewErrorLog':'View Error Level Log',
'sys.process.subStep.status':'Step Status',
'sys.process.subStep.info':'Step Info',
'sys.process.subStep.error':'Step Error',
'sys.process.viewInfoLog': 'View Info Level Log',
'sys.process.viewErrorLog': 'View Error Level Log',
'sys.process.subStep.status': 'Step Status',
'sys.process.subStep.info': 'Step Info',
'sys.process.subStep.error': 'Step Error',
// system info of log
'sys.info.logList.tips': 'Click left log file to viewing',
......
......@@ -50,6 +50,8 @@ export default {
'button.recycle': '回收',
'button.refresh': '刷新',
'button.test': '测试',
'button.clear': '清除',
'button.copy': '复制',
'button.refreshData': '刷新数据',
'button.collapseDir': '折叠目录',
'button.asc': '升序',
......@@ -92,8 +94,8 @@ export default {
'tips.confirm.delete.table': '确定删除表【{tableName}】吗?',
'tips.create.session.success': '创建会话【{session}】成功!',
'status.enabled': '已启用',
'status.disabled': '已禁用',
'status.enabled': '启用',
'status.disabled': '禁用',
'global.time.second': '秒 ',
'global.time.minute': '分 ',
......
......@@ -111,6 +111,68 @@ export default {
//-------------------------------- register center --------------------------------
// =============== data source =======================
// datasource list page
'rc.ds.management': '数据源管理',
'rc.ds.name': '名称',
'rc.ds.groupName': '分组类型',
'rc.ds.type': '数据源类型',
'rc.ds.url': '数据库连接 URL',
'rc.ds.username': '用户名',
'rc.ds.password': '密码',
'rc.ds.flinkConfig': 'Flink 连接配置',
'rc.ds.flinkTemplate': 'Flink 连接模板',
'rc.ds.create': '创建数据源',
'rc.ds.modify': '修改数据源',
'rc.ds.delete': '删除数据源',
'rc.ds.deleteConfirm': '确定删除该数据源吗?',
'rc.ds.namePlaceholder': '请输入名称!',
'rc.ds.groupNamePlaceholder': '请选择分组类型!',
'rc.ds.typePlaceholder': '请选择数据源类型! 输入关键词搜索',
'rc.ds.urlPlaceholder': '请输入格式正确的 url 连接!',
'rc.ds.usernamePlaceholder': '请输入用户名!',
'rc.ds.passwordPlaceholder': '请输入密码!',
'rc.ds.flinkConfigPlaceholder': '请指定 Flink With 的默认配置!',
'rc.ds.flinkConfigTooltip': '避免私密信息泄露,同时作为全局变量复用连接配置,在FlinkSQL中可使用 `变量引用方式` 来加载连接配置。说明:引用名称指的是唯一标识,即该表单中的`名称`。注意需要开启全局变量(原片段机制)',
'rc.ds.flinkTemplatePlaceholder': '请指定 Flink With 的生成模板!',
'rc.ds.flinkTemplateTooltip': 'Flink 连接模板作用是为生成 FlinkSQL DDL 而扩展的功能。其中 `变量引用方式`中的 schemaName 是指动态获取数据库,`变量引用方式`中的 tableName 动态获取表名称',
'rc.ds.source': '来源',
'rc.ds.warehouse': '数仓',
'rc.ds.application': '应用',
'rc.ds.backup': '备份',
'rc.ds.other': '其他',
'rc.ds.enter': '点击列表中的 icon 图片进入该数据源的详情页! 支持查看该数据源的库&表信息,以及可以进行即时查询',
'rc.ds.enter.error': '该数据源状态异常无法进入,心跳正常后方可进入!',
// datasource of schema info page
// tags
'rc.ds.detail.tag.desc': '描述',
'rc.ds.detail.tag.query': '查询',
'rc.ds.detail.tag.gensql': '生成 SQL',
'rc.ds.detail.tag.console': '控制台',
// tips
'rc.ds.detail.tips': '点击左侧的表,获取表的描述信息',
// columns info
'rc.ds.no': '序号',
'rc.ds.columnName': '名称',
'rc.ds.columnType': '类型',
'rc.ds.comment': '注释',
'rc.ds.primarykey': '主键',
'rc.ds.autoIncrement': '自增',
'rc.ds.isNull': '非空',
'rc.ds.null': '可为空',
'rc.ds.default': '默认值',
'rc.ds.length': '长度',
'rc.ds.precision': '精度',
'rc.ds.decimalDigits': '小数范围',
'rc.ds.character': '字符集',
'rc.ds.collationRule': '排序规则',
'rc.ds.javaType': 'Java 类型',
// alert instance
'rc.ai.management': '告警实例管理',
'rc.ai.type': '类型',
......@@ -136,7 +198,7 @@ export default {
'rc.ai.msgtypePleaseHolder': '请选择消息发送类型',
'rc.ai.corpIdPleaseHolder': '请输入 企业Id',
'rc.ai.wechatAtUsersPleaseHolder': '请输入被@用户ID(企微用户名全拼),多个逗号隔开!',
'rc.ai.sendTypePleaseHolder' : '请选择发送方式!',
'rc.ai.sendTypePleaseHolder': '请选择发送方式!',
'rc.ai.agentIdPleaseHolder': '请输入 AgentId',
'rc.ai.receiversPleaseHolder': '请输入收件人邮箱!多个英文逗号隔开',
'rc.ai.receiverCcsPleaseHolder': '请输入抄送人邮箱!多个英文逗号隔开!',
......@@ -283,37 +345,37 @@ export default {
// udf template
'rc.udf.management': 'UDF 模板管理',
'rc.template.name' :'模板名',
'rc.template.namePlaceholder' :'请输入模板名!',
'rc.template.codeType' :'代码类型',
'rc.template.codeTypePlaceholder' :'请选择代码类型!',
'rc.template.functionType' :'函数类型',
'rc.template.functionTypePlaceholder' :'请选择函数类型!',
'rc.template.templateCodeLabel' :'模板代码({language})',
'rc.template.templateCode' :'模板代码',
'rc.template.templateCodePlaceholder' :'请编辑模板代码!',
'rc.template.delete' :'删除模板!',
'rc.template.deleteConfirm' :'确定删除该模板吗?',
'rc.template.name': '模板名',
'rc.template.namePlaceholder': '请输入模板名!',
'rc.template.codeType': '代码类型',
'rc.template.codeTypePlaceholder': '请选择代码类型!',
'rc.template.functionType': '函数类型',
'rc.template.functionTypePlaceholder': '请选择函数类型!',
'rc.template.templateCodeLabel': '模板代码({language})',
'rc.template.templateCode': '模板代码',
'rc.template.templateCodePlaceholder': '请编辑模板代码!',
'rc.template.delete': '删除模板!',
'rc.template.deleteConfirm': '确定删除该模板吗?',
'rc.template.create': '创建 UDF 模板',
'rc.template.modify': '修改 UDF 模板',
//-------------------------------- setting center --------------------------------
// process
'sys.process.id':'进程ID',
'sys.process.name':'进程名',
'sys.process.taskId':'任务ID',
'sys.process.type':'类型',
'sys.process.status':'状态',
'sys.process.startTime':'开始时间',
'sys.process.endTime':'结束时间',
'sys.process.duration':'耗时',
'sys.process.operator':'操作人',
'sys.process.viewInfoLog':'查看 Info 级别日志',
'sys.process.viewErrorLog':'查看 Error 级别日志',
'sys.process.subStep.status':'步骤状态',
'sys.process.subStep.info':'步骤 Info 日志',
'sys.process.subStep.error':'步骤 Error 日志',
'sys.process.id': '进程ID',
'sys.process.name': '进程名',
'sys.process.taskId': '任务ID',
'sys.process.type': '类型',
'sys.process.status': '状态',
'sys.process.startTime': '开始时间',
'sys.process.endTime': '结束时间',
'sys.process.duration': '耗时',
'sys.process.operator': '操作人',
'sys.process.viewInfoLog': '查看 Info 级别日志',
'sys.process.viewErrorLog': '查看 Error 级别日志',
'sys.process.subStep.status': '步骤状态',
'sys.process.subStep.info': '步骤 Info 日志',
'sys.process.subStep.error': '步骤 Error 日志',
// system info of log
'sys.info.logList.tips': '点击左侧日志文件查看',
......
......@@ -30,8 +30,7 @@ import {handleAddOrUpdate, handleRemoveById, updateEnabled} from "@/services/Bus
import {showAlertInstance} from "@/pages/RegCenter/Alert/AlertGroup/service";
import {connect} from "@umijs/max";
import {ProList} from "@ant-design/pro-components";
import {API_CONSTANTS, PROTABLE_OPTIONS_PUBLIC, SWITCH_OPTIONS} from "@/services/constants";
import {PRO_LIST_CARD_OPTIONS} from "@/pages/RegCenter/Alert/AlertInstance/constans";
import {API_CONSTANTS, PRO_LIST_CARD_OPTIONS, PROTABLE_OPTIONS_PUBLIC, SWITCH_OPTIONS} from "@/services/constants";
import {getAlertIcon} from "@/pages/RegCenter/Alert/AlertInstance/function";
import {DangerDeleteIcon} from "@/components/Icons/CustomIcons";
import DescriptionsItem from "antd/es/descriptions/Item";
......
......@@ -16,7 +16,7 @@
*/
import {Alert} from "@/types/RegCenter/data";
import {Alert} from '@/types/RegCenter/data';
/**
* AlertInstanceFormProps
......@@ -28,21 +28,3 @@ export type AlertInstanceFormProps = {
modalVisible: boolean;
values: Partial<Alert.AlertInstance>;
};
export const PRO_LIST_CARD_META = {
title: {},
subTitle: {},
type: {},
avatar: {},
content: {},
actions: {
cardActionProps: "actions"
},
};
export const PRO_LIST_CARD_OPTIONS = {
search: false,
metas: PRO_LIST_CARD_META,
grid: {gutter: 24, column: 6}
};
......@@ -26,12 +26,11 @@ import {Alert} from "@/types/RegCenter/data.d";
import {queryList} from "@/services/api";
import {handleRemoveById, updateEnabled} from "@/services/BusinessCrud";
import {ProList} from "@ant-design/pro-components";
import {API_CONSTANTS, PROTABLE_OPTIONS_PUBLIC, SWITCH_OPTIONS} from "@/services/constants";
import {API_CONSTANTS, PRO_LIST_CARD_OPTIONS, PROTABLE_OPTIONS_PUBLIC, SWITCH_OPTIONS} from "@/services/constants";
import {DangerDeleteIcon} from "@/components/Icons/CustomIcons";
import {getAlertIcon} from "@/pages/RegCenter/Alert/AlertInstance/function";
import DescriptionsItem from "antd/es/descriptions/Item";
import AlertTypeChoose from "./components/AlertTypeChoose";
import {PRO_LIST_CARD_OPTIONS} from "@/pages/RegCenter/Alert/AlertInstance/constans";
const AlertInstanceTableList: React.FC = () => {
......
/*
* 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.
*/
import {DataSources} from '@/types/RegCenter/data';
import React from 'react';
import {l} from '@/utils/intl';
import {CheckSquareOutlined, KeyOutlined } from '@ant-design/icons';
import { ProTable } from '@ant-design/pro-components';
import {ProColumns} from '@ant-design/pro-table/es/typing';
type ColumnInfoProps = {
columnInfo: Partial<DataSources.Column[]>;
}
const ColumnInfo: React.FC<ColumnInfoProps> = (props) => {
const {columnInfo} = props;
const columns :ProColumns<DataSources.Column>[] = [
{
title: l('rc.ds.no'),
dataIndex: 'position',
width: "4%",
},
{
title: l('rc.ds.columnName'),
dataIndex: 'name',
width: "10%",
ellipsis : true,
copyable: true,
},
{
title: l('rc.ds.columnType'),
dataIndex: 'type',
width: "6%",
},
{
title: l('rc.ds.primarykey'),
dataIndex: 'keyFlag',
width: "4%",
render: (_, record) => {
return record.keyFlag ? <KeyOutlined style={{color: '#FAA100'}}/> : undefined
},
}, {
title: l('rc.ds.autoIncrement'),
dataIndex: 'autoIncrement',
width: "4%",
render: (_, record) => {
return record.autoIncrement ? <CheckSquareOutlined style={{color: '#1296db'}}/> : undefined
},
}, {
title: l('rc.ds.isNull'),
dataIndex: 'nullable',
width: "4%",
render: (_, record) => {
return !record.nullable ? <CheckSquareOutlined style={{color: '#1296db'}}/> : undefined
},
}, {
title: l('rc.ds.default'),
dataIndex: 'defaultValue',
ellipsis: true,
width: "8%",
}, {
title: l('rc.ds.length'),
dataIndex: 'length',
width: "4%",
}, {
title: l('rc.ds.precision'),
dataIndex: 'precision',
width: "4%",
}, {
title: l('rc.ds.decimalDigits'),
dataIndex: 'scale',
ellipsis: true,
width: "6%",
}, {
title: l('rc.ds.character'),
dataIndex: 'characterSet',
width: "6%",
ellipsis: true,
}, {
title: l('rc.ds.collationRule'),
dataIndex: 'collation',
width: "10%",
ellipsis: true,
}, {
title: l('rc.ds.javaType'),
dataIndex: 'javaType',
ellipsis: true,
width: "8%",
},
{
title: l('rc.ds.comment'),
dataIndex: 'comment',
ellipsis: true,
},
];
return <>
<ProTable<DataSources.Column>
toolBarRender={false}
className={'columnTable'}
pagination={{
defaultPageSize:12,
hideOnSinglePage: true,
}}
search={false}
options={false}
size={"small"}
bordered
columns={columns}
dataSource={columnInfo as DataSources.Column[]}
/>
</>;
};
export default ColumnInfo;
/*
* 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.
*/
import React from 'react';
import {DataSources} from '@/types/RegCenter/data';
import {Descriptions} from 'antd';
type TableInfoProps = {
tableInfo: Partial<DataSources.Table>;
}
const TableInfo: React.FC<TableInfoProps> = (props) => {
const {tableInfo} = props;
return <>
<Descriptions size={'small'} bordered column={4}>
<Descriptions.Item label="Name">{tableInfo.name}</Descriptions.Item>
<Descriptions.Item label="Schema">{tableInfo.schema}</Descriptions.Item>
<Descriptions.Item label="Catalog">{tableInfo.catalog}</Descriptions.Item>
<Descriptions.Item label="Rows">{tableInfo.rows}</Descriptions.Item>
<Descriptions.Item label="Type">{tableInfo.type}</Descriptions.Item>
<Descriptions.Item label="Engine">{tableInfo.engine}</Descriptions.Item>
<Descriptions.Item label="Options">{tableInfo.options}</Descriptions.Item>
<Descriptions.Item label="CreateTime">{tableInfo.createTime}</Descriptions.Item>
<Descriptions.Item label="UpdateTime">{tableInfo.updateTime || '-'}</Descriptions.Item>
<Descriptions.Item label="Comment" span={3}>{tableInfo.comment || '-'}</Descriptions.Item>
</Descriptions>
</>;
};
export default TableInfo;
/*
* 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.
*/
import {DataSources} from '@/types/RegCenter/data';
import {Divider, Empty} from 'antd';
import React from 'react';
import TableInfo from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/TableInfo';
import ColumnInfo from './ColumnInfo/Index';
import {l} from '@/utils/intl';
type SchemaDescProps = {
tableInfo: Partial<DataSources.Table>;
tableColumns: Partial<DataSources.Column[]>;
}
const SchemaDesc: React.FC<SchemaDescProps> = (props) => {
const {tableInfo, tableColumns} = props;
return <>
{!(Object.keys(tableInfo).length === 0 && tableColumns.length === 0) ?
<>
<TableInfo tableInfo={tableInfo}/>
<ColumnInfo columnInfo={tableColumns}/>
</>
: <Empty className={'code-content-empty'} description={l('rc.ds.detail.tips')}/>
}
</>;
};
export default SchemaDesc;
/*
* 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.
*/
import {Space, Tabs} from 'antd';
import {l} from '@/utils/intl';
import {
BookOutlined,
} from '@ant-design/icons';
import React from 'react';
import {DataSources} from '@/types/RegCenter/data';
import SchemaDesc from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc';
type RightTagsRouterProps = {
tableInfo: Partial<DataSources.Table>;
tableColumns: Partial<DataSources.Column[]>;
}
const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => {
const {tableColumns, tableInfo} = props;
const [activeKey, setActiveKey] = React.useState('desc');
return <>
<Tabs
activeKey={activeKey}
onChange={(key) => setActiveKey(key)}
size="small"
animated
destroyInactiveTabPane
style={{height: '100%'}}
items={[
{
key: 'desc',
label: <Space><BookOutlined/>{l('rc.ds.detail.tag.desc')}</Space>,
children: <SchemaDesc tableInfo={tableInfo} tableColumns={tableColumns}/>
},
{
key: 'query',
label: <Space><BookOutlined/>{l('rc.ds.detail.tag.query')}</Space>,
children: <SchemaDesc tableInfo={tableInfo} tableColumns={tableColumns}/>
},
{
key: 'gensql',
label: <Space><BookOutlined/>{l('rc.ds.detail.tag.gensql')}</Space>,
children: <SchemaDesc tableInfo={tableInfo} tableColumns={tableColumns}/>
},
{
key: 'console',
label: <Space><BookOutlined/>{l('rc.ds.detail.tag.console')}</Space>,
children: <SchemaDesc tableInfo={tableInfo} tableColumns={tableColumns}/>
},
]}
/>
</>;
};
export default RightTagsRouter;
/*
* 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.
*/
import {Empty, Tree} from 'antd';
import React from 'react';
import {DatabaseTwoTone, TableOutlined, TabletTwoTone} from '@ant-design/icons';
import {folderSeparator} from '@/utils/function';
const {DirectoryTree} = Tree;
type SchemaTreeProps = {
treeData: Partial<any>[];
onNodeClick: (info: any) => void
}
const SchemaTree:React.FC<SchemaTreeProps> = (props) => {
const {treeData, onNodeClick} = props;
const buildSchemaTree = (data: any): any => data.map((item: any) => {
return {
isLeaf: false,
name: item.name,
parentId: item.name,
icon: <DatabaseTwoTone/>,
content: item.name,
path: item.name,
title: item.name,
fullInfo: item,
key: item.name,
children: item.tables.map((table: any) => {
return {
isLeaf: true,
name: table.name,
parentId: item.name,
icon: <TableOutlined/>,
content: table.name,
path: item.name + folderSeparator() + table.name,
title: table.name,
key: item.name + folderSeparator() + table.name,
fullInfo: table,
};
}),
};
});
return<>
{
(treeData.length > 0) ?
<DirectoryTree
onSelect={(_, info) => onNodeClick(info)}
treeData={buildSchemaTree(treeData)}
/> : <Empty className={"code-content-empty"}/>
}
</>
}
export default SchemaTree;
/*
* 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.
*/
import React, {useCallback, useEffect, useState} from 'react';
import {DataSources} from '@/types/RegCenter/data';
import {Loading} from '@/pages/Other/Loading';
import {Button, Col, Row, Space} from 'antd';
import {BackwardOutlined, ReloadOutlined} from '@ant-design/icons';
import {DataSourceDetailBackButton} from '@/components/StyledComponents';
import {l} from '@/utils/intl';
import SchemaTree from '@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree';
import RightTagsRouter from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter';
import {useNavigate} from '@umijs/max';
import {API_CONSTANTS, RESPONSE_CODE} from '@/services/constants';
import {getDataByIdReturnResult, queryDataByParams} from '@/services/BusinessCrud';
type DataSourceDetailProps = {
dataSource: Partial<DataSources.DataSource>;
backClick: () => void;
}
const DataSourceDetail: React.FC<DataSourceDetailProps> = (props) => {
const navigate = useNavigate();
const {dataSource, backClick} = props;
const [loading, setLoading] = useState<boolean>(false);
const [treeData, setTreeData] = useState<Partial<any>[]>([]);
const [tableColumns, setTableColumns] = useState<Partial<DataSources.Column[]>>([]);
const [tableInfo, setTableInfo] = useState<Partial<DataSources.Table>>({});
const handleBackClick = () => {
// go back
navigate('/registration/database', {state: {from: `/registration/database/detail/${dataSource.id}`}});
// back click callback
backClick();
};
const querySchemaTree = useCallback(async () => {
setTableColumns([]);
setTableInfo({});
setLoading(true);
await getDataByIdReturnResult(API_CONSTANTS.DATASOURCE_GET_SCHEMA_TABLES, dataSource.id).then((res) => {
if (res.code === RESPONSE_CODE.SUCCESS) {
setTreeData(res.datas);
}
});
setLoading(false);
}, []);
useEffect(() => {
querySchemaTree();
}, []);
const onSchemaTreeNodeClick = useCallback(async (info: any) => {
const {node: nodeInfo, node: {isLeaf, parentId, name, fullInfo}} = info;
if (isLeaf) {
console.log(nodeInfo, 'nodeInfo');
const data = await queryDataByParams(API_CONSTANTS.DATASOURCE_GET_COLUMNS_BY_TABLE, {
id: dataSource.id,
schemaName: parentId,
tableName: name
});
setTableColumns(data);
setTableInfo(fullInfo);
} else {
setTableColumns([]);
setTableInfo({});
}
}, []);
return <>
<DataSourceDetailBackButton>
<Space size={'large'}>
<Button size={'middle'} icon={<ReloadOutlined spin={loading}/>} type="primary"
onClick={() => querySchemaTree()}>{l('button.refresh')}</Button>
<Button size={'middle'} icon={<BackwardOutlined/>} type="primary"
onClick={handleBackClick}>{l('button.back')}</Button>
</Space>
</DataSourceDetailBackButton>
{
loading ?
<Loading loading={loading}/>
:
<>
<Row>
<Col span={4} className={'siderTree schemaTree'}>
{/* tree */}
<SchemaTree onNodeClick={(info: any) => onSchemaTreeNodeClick(info)} treeData={treeData}/>
</Col>
<Col span={20}>
{/* tags */}
<RightTagsRouter
tableInfo={tableInfo}
tableColumns={tableColumns}
/>
</Col>
</Row>
</>
}
</>;
};
export default DataSourceDetail;
/*
* 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.
*/
import {ActionType, ProList} from '@ant-design/pro-components';
import {DataSources} from '@/types/RegCenter/data.d';
import {API_CONSTANTS, PRO_LIST_CARD_OPTIONS, PROTABLE_OPTIONS_PUBLIC} from '@/services/constants';
import {l} from '@/utils/intl';
import React, {useEffect, useState} from 'react';
import {CreateBtn} from '@/components/CallBackButton/CreateBtn';
import DataSourceModal from '../DataSourceModal';
import {queryList} from '@/services/api';
import {Button, Descriptions, Modal, Space, Tag, Tooltip} from 'antd';
import {
handleAddOrUpdate,
handleOption,
handlePutDataByParams,
handleRemoveById,
updateEnabled
} from '@/services/BusinessCrud';
import DescriptionsItem from 'antd/es/descriptions/Item';
import {CheckCircleOutlined, CopyTwoTone, ExclamationCircleOutlined, HeartTwoTone} from '@ant-design/icons';
import {renderDBIcon} from '@/pages/RegCenter/DataSource/components/function';
import {EnableSwitchBtn} from '@/components/CallBackButton/EnableSwitchBtn';
import {EditBtn} from '@/components/CallBackButton/EditBtn';
import {NormalDeleteBtn} from '@/components/CallBackButton/NormalDeleteBtn';
import {DataSourceAction} from '@/components/StyledComponents';
import DataSourceDetail from '@/pages/RegCenter/DataSource/components/DataSourceDetail';
import {WarningMessage} from '@/utils/messages';
import {useNavigate} from '@@/exports';
const DataSourceTable = () => {
const navigate = useNavigate();
/**
* state
*/
const actionRef = React.useRef<ActionType>();
const [loading, setLoading] = React.useState<boolean>(false);
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [detailPage, setDetailPage] = useState<boolean>(false);
const [updateModalVisible, setUpdateModalVisible] = useState<boolean>(false);
const [dataSource, setDataSource] = useState<DataSources.DataSource[]>([]);
const [formValues, setFormValues] = useState<Partial<DataSources.DataSource>>({});
/**
* execute query list
* set list
*/
const querDataSourceList = async () => {
await queryList(API_CONSTANTS.DATASOURCE).then(res => {
setDataSource(res.data);
});
};
/**
* extra callback
* @param callback
*/
const executeAndCallbackRefresh = async (callback: () => void) => {
await setLoading(true);
await callback();
await querDataSourceList();
await setLoading(false);
};
/**
* handle add or update
* @param item
*/
const saveOrUpdateHandle = async (item: Partial<DataSources.DataSource>) => {
await executeAndCallbackRefresh(async () => {
await handleAddOrUpdate(API_CONSTANTS.DATASOURCE, item);
});
};
/**
* handle delete
* @param id
*/
const handleDeleteSubmit = async (id: number) => {
Modal.confirm({
title: l('rc.ds.delete'),
content: l('rc.ds.deleteConfirm'),
okText: l('button.confirm'),
cancelText: l('button.cancel'),
onOk: async () => {
await executeAndCallbackRefresh(async () => {
await handleRemoveById(API_CONSTANTS.DATASOURCE_DELETE, id);
});
}
});
};
/**
* handle enable
* @param item
*/
const handleEnable = async (item: DataSources.DataSource) => {
await executeAndCallbackRefresh(async () => {
await updateEnabled(API_CONSTANTS.DATASOURCE_ENABLE, {id: item.id});
});
};
/**
* handle test
* @param item
*/
const handleTest = async (item: Partial<DataSources.DataSource>) => {
await handleOption(API_CONSTANTS.DATASOURCE_TEST, l('button.test'), item);
};
/**
* handle check heart
* @param item
*/
const handleCheckHeartBeat = async (item: DataSources.DataSource) => {
await executeAndCallbackRefresh(async () => {
await handlePutDataByParams(API_CONSTANTS.DATASOURCE_CHECK_HEARTBEAT_BY_ID, l('button.heartbeat'), {id: item.id});
});
};
const onCopyDataBase = async (item: DataSources.DataSource) => {
await executeAndCallbackRefresh(async () => {
await handleOption(API_CONSTANTS.DATASOURCE_COPY, l('button.copy'), item);
});
};
/**
* query list
*/
useEffect(() => {
querDataSourceList();
}, []);
/**
* render sub title
* @param item
*/
const renderDataSourceSubTitle = (item: DataSources.DataSource) => {
return (
<Descriptions size={'small'} layout={'vertical'} column={1}>
<DescriptionsItem
className={'hidden-overflow'}
key={item.id}>
<Tooltip key={item.name} title={item.name}>{item.name}</Tooltip>
</DescriptionsItem>
</Descriptions>
);
};
/**
* edit click callback
* @param item
*/
const editClick = (item: DataSources.DataSource) => {
setFormValues(item);
setUpdateModalVisible(!modalVisible);
};
/**
* enter details page callback
* @param item
*/
const enterDetailPageClickHandler = async (item: DataSources.DataSource) => {
// if status is true, enter detail page, else show error message , do nothing
if (item.status) {
setFormValues(item);
navigate(`/registration/database/detail/${item.id}`, {state: {from: '/registration/database'}});
setDetailPage(!detailPage);
} else {
await WarningMessage(l('rc.ds.enter.error'));
return;
}
};
/**
* render alert instance action button
* @param item
*/
const renderDataSourceActionButton = (item: DataSources.DataSource) => {
return [
<EditBtn key={`${item.id}_edit`} onClick={() => editClick(item)}/>,
<NormalDeleteBtn key={`${item.id}_delete`} onClick={() => handleDeleteSubmit(item.id)}/>,
<Button
className={'options-button'}
key={`${item.id}_heart`}
onClick={() => handleCheckHeartBeat(item)}
title={l('button.heartbeat')}
icon={<HeartTwoTone twoToneColor={item.status ? '#1ac431' : '#e10d0d'}/>}
/>,
<Button
className={'options-button'}
key={`${item.id}_copy`}
onClick={() => onCopyDataBase(item)}
title={l('button.copy')}
icon={<CopyTwoTone/>}
/>
];
};
/**
* render alert instance action button
* @param item
*/
const renderDataSourceContent = (item: DataSources.DataSource) => {
return (
<Space className={'hidden-overflow'}>
<Tag color="cyan">{item.type}</Tag>
<EnableSwitchBtn record={item} onChange={() => handleEnable(item)}/>
<Tag
icon={item.status ? <CheckCircleOutlined/> : <ExclamationCircleOutlined/>}
color={item.status ? 'success' : 'warning'}
>
{item.status ? l('global.table.status.normal') : l('global.table.status.abnormal')}
</Tag>
</Space>
);
};
/**
* render data source
*/
const renderDataSource = dataSource.map((item) => ({
subTitle: renderDataSourceSubTitle(item),
actions: <DataSourceAction>{renderDataSourceActionButton(item)}</DataSourceAction>,
avatar: <Space onClick={() => enterDetailPageClickHandler(item)}>{renderDBIcon(item.type, 60)}</Space>,
content: renderDataSourceContent(item),
key: item.id,
}));
/**
* cancel all
*/
const cancelAll = () => {
setModalVisible(false);
setUpdateModalVisible(false);
setFormValues({});
};
/**
* render
*/
return <>
{
!detailPage ? <>
<ProList<DataSources.DataSource>
{...PROTABLE_OPTIONS_PUBLIC}
{...PRO_LIST_CARD_OPTIONS as any}
loading={loading}
tooltip={l('rc.ds.enter')}
actionRef={actionRef}
headerTitle={l('rc.ds.management')}
toolBarRender={() => [<CreateBtn key={'CreateBtn'} onClick={() => setModalVisible(true)}/>]}
dataSource={renderDataSource}
/>
{/* added */}
<DataSourceModal
values={{}}
visible={modalVisible}
onCancel={cancelAll}
onTest={(value) => handleTest(value)}
onSubmit={(value) => saveOrUpdateHandle(value)}
/>
{/* modify*/}
<DataSourceModal
values={formValues}
visible={updateModalVisible}
onCancel={cancelAll}
onTest={(value) => handleTest(value)}
onSubmit={(value) => saveOrUpdateHandle(value)}
/>
</> :
<DataSourceDetail backClick={() => setDetailPage(false)} dataSource={formValues}/>
}
</>;
};
export default DataSourceTable;
/*
* 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.
*/
import React from "react";
import {FormInstance} from "antd/es/form/hooks/useForm";
import {Values} from "async-validator";
import {ProForm, ProFormGroup, ProFormSelect, ProFormText} from "@ant-design/pro-components";
import {l} from "@/utils/intl";
import {DataSources} from "@/types/RegCenter/data.d";
import {AUTO_COMPLETE_TYPE, GROUP_TYPE} from "@/pages/RegCenter/DataSource/components/constants";
import {AutoComplete, Input} from "antd";
import CodeEdit from "@/components/CustomEditor/CodeEdit";
import {renderDataSourceType} from "@/pages/RegCenter/DataSource/components/function";
type DataSourceProFormProps = {
values: Partial<DataSources.DataSource>,
form: FormInstance<Values>,
flinkConfigChange: (value: string) => void
flinkTemplateChange: (value: string) => void
}
const CodeEditProps = {
height: "30vh",
width: "22vw",
lineNumbers: "off",
language: "sql",
};
const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
const {values, form, flinkTemplateChange, flinkConfigChange} = props;
const [excludeFormItem, setExcludeFormItem] = React.useState<boolean>(false);
const handleTypeChange = (type: string) => {
if (type === "Hive" || type === "Presto") {
setExcludeFormItem(true);
} else {
setExcludeFormItem(false);
}
};
const renderDataSourceForm = () => {
return <>
<ProForm.Group>
<ProFormText
name="name"
width={"md"}
label={l("rc.ds.name")}
rules={[{required: true, message: l("rc.ds.namePlaceholder")}]}
placeholder={l("rc.ds.namePlaceholder")}
/>
<ProFormSelect
name="groupName"
width={"sm"}
label={l("rc.ds.groupName")}
options={GROUP_TYPE}
placeholder={l("rc.ds.groupNamePlaceholder")}
/>
<ProFormSelect
name="type"
width={"sm"}
label={l("rc.ds.type")}
showSearch
options={renderDataSourceType()}
rules={[{required: true, message: l("rc.ds.typePlaceholder")}]}
placeholder={l("rc.ds.typePlaceholder")}
/>
<ProFormText
name="username"
width={"sm"}
label={l("rc.ds.username")}
rules={[{required: true, message: l("rc.ds.usernamePlaceholder")}]}
placeholder={l("rc.ds.usernamePlaceholder")}
/>
<ProFormText.Password
name="password"
width={"sm"}
label={l("rc.ds.password")}
rules={[{required: true, message: l("rc.ds.passwordPlaceholder")}]}
placeholder={l("rc.ds.passwordPlaceholder")}
/>
<ProFormText
name="note"
width={"md"}
label={l("global.table.note")}
placeholder={l("global.table.notePlaceholder")}
/>
</ProForm.Group>
<ProForm.Group>
<AutoComplete
options={AUTO_COMPLETE_TYPE}
onSelect={(value) => form.setFieldsValue({url: value})}
>
<ProForm.Item
name="url"
label={l("rc.ds.url")}
rules={[{required: true, message: l("rc.ds.urlPlaceholder")}]}
>
<Input.TextArea rows={3} cols={130} placeholder={l("rc.ds.urlPlaceholder")}/>
</ProForm.Item>
</AutoComplete>
</ProForm.Group>
{!excludeFormItem &&
<ProFormGroup>
<ProForm.Item
name="flinkConfig"
label={l("rc.ds.flinkConfig")}
tooltip={l("rc.ds.flinkConfigTooltip")}
>
<CodeEdit {...CodeEditProps} onChange={flinkConfigChange} code={values.flinkConfig || ""}/>
</ProForm.Item>
<ProForm.Item
name="flinkTemplate"
label={l("rc.ds.flinkTemplate")}
tooltip={l("rc.ds.flinkTemplateTooltip")}
>
<CodeEdit {...CodeEditProps} onChange={flinkTemplateChange} code={values.flinkTemplate || ""}/>
</ProForm.Item>
</ProFormGroup>
}
</>;
};
return <>
<ProForm
initialValues={values}
form={form}
onValuesChange={(changedValues) => handleTypeChange(changedValues.type)}
submitter={false}
>
{renderDataSourceForm()}
</ProForm>
</>;
};
export default DataSourceProForm;
/*
* 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.
*/
import {Button, Form} from "antd";
import {l} from "@/utils/intl";
import React, {useEffect} from "react";
import {MODAL_FORM_OPTIONS} from "@/services/constants";
import {DataSources} from "@/types/RegCenter/data";
import DataSourceProForm from "@/pages/RegCenter/DataSource/components/DataSourceModal/DataSourceProForm";
import {FormContextValue} from "@/components/Context/FormContext";
import {ModalForm} from "@ant-design/pro-components";
type DataSourceModalProps = {
visible: boolean;
onCancel: () => void;
onSubmit: (values: Partial<DataSources.DataSource>) => void;
onTest: (values: Partial<DataSources.DataSource>) => void;
values: Partial<DataSources.DataSource>;
}
const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
const {visible, values, onCancel, onSubmit, onTest} = props;
const [submitting, setSubmitting] = React.useState<boolean>(false);
const [flinkConfigValue, setFlinkConfigValue] = React.useState<string>(values.flinkConfig || "");
const [flinkTemplateValue, setFlinkTemplateValue] = React.useState<string>(values.flinkTemplate || "");
/**
* init form
*/
const [form] = Form.useForm();
/**
* init form context
*/
const formContext = React.useMemo<FormContextValue>(() => ({
resetForm: () => form.resetFields(), // 定义 resetForm 方法
}), [form]);
/**
* when modalVisible or values changed, set form values
*/
useEffect(() => {
form.setFieldsValue(values);
}, [visible, values, form]);
/**
* handle cancel
*/
const handleCancel = () => {
onCancel();
setSubmitting(false);
formContext.resetForm();
};
/**
* handle flink config value change
* @param value
*/
const handleFlinkConfigValueChange = (value: string) => {
setFlinkConfigValue(value);
form.setFieldsValue({flinkConfig: value});
};
/**
* handle flink template value change
* @param value
*/
const handleFlinkTemplateValueChange = (value: string) => {
setFlinkTemplateValue(value);
form.setFieldsValue({flinkTemplate: value});
};
/**
* test connect
*/
const handleTestConnect = async () => {
const fieldsValue = await form.validateFields();
onTest({...values, ...fieldsValue});
};
/**
* submit form
*/
const submitForm = async () => {
const fieldsValue = await form.validateFields();
setSubmitting(true);
await onSubmit({...values, ...fieldsValue});
handleCancel();
};
/**
* render footer
*/
const renderFooter = () => {
return [
<Button key={"cancel"} onClick={() => handleCancel()}>{l("button.cancel")}</Button>,
<Button key={"test"} loading={submitting} type="primary"
onClick={handleTestConnect}>{l("button.test")}</Button>,
<Button key={"finish"} loading={submitting} type="primary"
onClick={() => submitForm()}>{l("button.finish")}</Button>,
];
};
/**
* render
*/
return <>
<ModalForm<DataSources.DataSource>
{...MODAL_FORM_OPTIONS}
open={visible}
modalProps={{onCancel: handleCancel}}
title={values.id ? l("rc.ds.modify") : l("rc.ds.create")}
form={form}
submitter={{render: () => [...renderFooter()]}}
initialValues={{...values, flinkConfig: flinkConfigValue, flinkTemplate: flinkTemplateValue}}
>
<DataSourceProForm values={values} form={form} flinkConfigChange={handleFlinkConfigValueChange}
flinkTemplateChange={handleFlinkTemplateValueChange}/>
</ModalForm>
</>;
};
export default DataSourceModal;
/*
* 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.
*/
import {l} from '@/utils/intl';
/**
* data source type
*/
export const DATA_SOURCE_TYPE: any = [
{
type: 'MySQL',
}, {
type: 'Oracle',
}, {
type: 'PostgreSQL',
}, {
type: 'ClickHouse',
}, {
type: 'SQLServer',
}, {
type: 'Doris',
}, {
type: 'Phoenix',
}, {
type: 'Hive',
}, {
type: 'StarRocks',
}, {
type: 'Presto',
}
];
/**
* data source group type
*/
export const GROUP_TYPE = [
{
key: 'source',
value: 'source',
label: l('rc.ds.source'),
},
{
key: 'warehouse',
value: 'warehouse',
label: l('rc.ds.warehouse'),
},
{
key: 'application',
value: 'application',
label: l('rc.ds.application'),
},
{
key: 'backup',
value: 'backup',
label: l('rc.ds.backup'),
},
{
key: 'other',
value: 'other',
label: l('rc.ds.other'),
},
];
/**
* data source url , render autocomplete value
*/
export const AUTO_COMPLETE_TYPE = [
{
key: 'mysql',
value: 'jdbc:mysql://localhost:3306/dinky?useSSL=false&serverTimezone=UTC',
label: 'jdbc:mysql://localhost:3306/dinky?useSSL=false&serverTimezone=UTC',
},
{
key: 'oracle',
value: 'jdbc:oracle:thin:@localhost:1521:orcl',
label: 'jdbc:oracle:thin:@localhost:1521:orcl',
},
{
key: 'postgresql',
value: 'jdbc:postgresql://localhost:5432/dinky',
label: 'jdbc:postgresql://localhost:5432/dinky',
},
{
key: 'clickhouse',
value: 'jdbc:clickhouse://localhost:8123/dinky',
label: 'jdbc:clickhouse://localhost:8123/dinky',
},
{
key: 'sqlserver',
value: 'jdbc:sqlserver://localhost:1433;DatabaseName=dinky',
label: 'jdbc:sqlserver://localhost:1433;DatabaseName=dinky',
},
{
key: 'doris',
value: 'jdbc:mysql://localhost:9030/dinky?useSSL=false&serverTimezone=UTC',
label: 'jdbc:mysql://localhost:9030/dinky?useSSL=false&serverTimezone=UTC',
},
{
key: 'phoenix',
value: 'jdbc:phoenix:localhost:2181',
label: 'jdbc:phoenix:localhost:2181',
},
{
key: 'hive',
value: 'jdbc:hive2://localhost:10000/dinky',
label: 'jdbc:hive2://localhost:10000/dinky',
},
{
key: 'starrocks',
value: 'jdbc:mysql://localhost:9030/dinky?useSSL=false&serverTimezone=UTC',
label: 'jdbc:mysql://localhost:9030/dinky?useSSL=false&serverTimezone=UTC',
},
{
key: 'presto',
value: 'jdbc:presto://localhost:8080/dinky',
label: 'jdbc:presto://localhost:8080/dinky',
},
];
/*
* 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.
*/
import {DATA_SOURCE_TYPE} from "@/pages/RegCenter/DataSource/components/constants";
import {DefaultOptionType} from "antd/es/select";
import {
ClickHouseIcons, DefaultDBIcons,
DorisIcons, HiveIcons,
MysqlIcons,
OracleIcons, PhoenixIcons,
PostgresqlIcons, PrestoIcons,
SqlServerIcons, StarRocksIcons
} from "@/components/Icons/DBIcons";
/**
* render DB icon
* @param type
* @param size
*/
export const renderDBIcon = (type: string, size?: number) => {
switch (type.toLowerCase()) {
case "mysql":
return <MysqlIcons size={size}/>;
case "oracle":
return <OracleIcons size={size}/>;
case "postgresql":
return <PostgresqlIcons size={size}/>;
case "clickhouse":
return <ClickHouseIcons size={size}/>;
case "sqlserver":
return <SqlServerIcons size={size}/>;
case "doris":
return <DorisIcons size={size}/>;
case "phoenix":
return <PhoenixIcons size={size}/>;
case "hive":
return <HiveIcons size={size}/>;
case "starrocks":
return <StarRocksIcons size={size}/>;
case "presto":
return <PrestoIcons size={size}/>;
default:
return <DefaultDBIcons size={size}/>;
}
};
/**
* render DataSourceType
*/
export const renderDataSourceType = () => {
let dataSourceType: DefaultOptionType[] = [];
DATA_SOURCE_TYPE.forEach((item: { type: string }) => {
dataSourceType.push({
key: item.type,
value: item.type,
label: item.type,
});
});
return dataSourceType;
};
/*
* 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.
*/
import {PageContainer} from "@ant-design/pro-components";
import DataSourceTable from "@/pages/RegCenter/DataSource/components/DataSourceList";
/**
* render DataSource page
*/
export default () => {
return <>
<PageContainer title={false}>
<DataSourceTable/>
</PageContainer>
</>;
}
......@@ -19,16 +19,16 @@ import {
addOrUpdateData, putData, getDataByRequestBody, getInfoById,
postAll,
removeById, updateDataByParams, getData,
} from "@/services/api";
import {l} from "@/utils/intl";
import {API_CONSTANTS, METHOD_CONSTANTS, RESPONSE_CODE} from "@/services/constants";
import {request} from "@@/exports";
} from '@/services/api';
import {l} from '@/utils/intl';
import {API_CONSTANTS, METHOD_CONSTANTS, RESPONSE_CODE} from '@/services/constants';
import {request} from '@@/exports';
import {
LoadingMessageAsync, SuccessMessage, WarningMessage,
} from "@/utils/messages";
} from '@/utils/messages';
const APPLICATION_JSON = "application/json";
const APPLICATION_JSON = 'application/json';
// ================================ About Account ================================
/**
......@@ -90,8 +90,8 @@ export function chooseTenantSubmit(params: { tenantId: number }) {
* @param params
*/
export const handleAddOrUpdate = async (url: string, params: any) => {
const tipsTitle = params.id ? l("app.request.update") : l("app.request.add");
await LoadingMessageAsync(l("app.request.running") + tipsTitle);
const tipsTitle = params.id ? l('app.request.update') : l('app.request.add');
await LoadingMessageAsync(l('app.request.running') + tipsTitle);
try {
const {code, msg} = await addOrUpdateData(url, {...params});
if (code === RESPONSE_CODE.SUCCESS) {
......@@ -111,7 +111,7 @@ export const handleAddOrUpdate = async (url: string, params: any) => {
* @param id
*/
export const handleRemoveById = async (url: string, id: number) => {
await LoadingMessageAsync(l("app.request.delete"));
await LoadingMessageAsync(l('app.request.delete'));
try {
const {code, msg} = await removeById(url, {id});
if (code === RESPONSE_CODE.SUCCESS) {
......@@ -130,7 +130,7 @@ export const handleRemoveById = async (url: string, id: number) => {
* @param params
*/
export const updateEnabled = async (url: string, params: any) => {
await LoadingMessageAsync(l("app.request.update"));
await LoadingMessageAsync(l('app.request.update'));
try {
const {code, msg} = await updateDataByParams(url, {...params});
if (code === RESPONSE_CODE.SUCCESS) {
......@@ -145,7 +145,7 @@ export const updateEnabled = async (url: string, params: any) => {
};
export const handleOption = async (url: string, title: string, param: any) => {
await LoadingMessageAsync(l("app.request.running") + title);
await LoadingMessageAsync(l('app.request.running') + title);
try {
const {code, msg} = await postAll(url, param);
if (code === RESPONSE_CODE.SUCCESS) {
......@@ -174,8 +174,8 @@ export const handleData = async (url: string, id: any) => {
export const handlePutData = async (url: string, fields: any) => {
const tipsTitle = fields.id ? l("app.request.update") : l("app.request.add");
await LoadingMessageAsync(l("app.request.running") + tipsTitle);
const tipsTitle = fields.id ? l('app.request.update') : l('app.request.add');
await LoadingMessageAsync(l('app.request.running') + tipsTitle);
try {
const {code, msg} = await postAll(url, {...fields});
if (code === RESPONSE_CODE.SUCCESS) {
......@@ -210,7 +210,7 @@ export const queryDataByParams = async (url: string, params?: any) => {
export const handlePutDataByParams = async (url: string, title: string, params: any) => {
await LoadingMessageAsync(l("app.request.running") + title);
await LoadingMessageAsync(l('app.request.running') + title);
try {
const {code, msg} = await putData(url, {...params});
if (code === RESPONSE_CODE.SUCCESS) {
......@@ -224,3 +224,19 @@ export const handlePutDataByParams = async (url: string, title: string, params:
return false;
}
};
export const getDataByIdReturnResult = async (url: string, id: any) => {
try {
const result = await getInfoById(url, id);
if (result.code === RESPONSE_CODE.SUCCESS) {
SuccessMessage(result.msg);
return result;
} else {
WarningMessage(result.msg);
return false;
}
} catch (error) {
return false;
}
};
......@@ -78,6 +78,24 @@ export const API_CONSTANTS = {
// --- registries center ---
// datasource registries list
DATASOURCE: "/api/database",
// datasource registries delete
DATASOURCE_DELETE: "/api/database/delete",
// datasource registries enable or disable
DATASOURCE_ENABLE: "/api/database/enable",
// datasource registries test
DATASOURCE_TEST: "/api/database/testConnect",
// datasource checkHeartBeat By Id
DATASOURCE_CHECK_HEARTBEAT_BY_ID: "/api/database/checkHeartBeatByDataSourceId",
// copy datasource
DATASOURCE_COPY: "/api/database/copyDatabase",
// get schema by datasource id
DATASOURCE_GET_SCHEMA_TABLES: "/api/database/getSchemasAndTables",
DATASOURCE_GET_COLUMNS_BY_TABLE: "/api/database/listColumns",
// document list
DOCUMENT: "/api/document",
// delete document by id
......@@ -221,7 +239,7 @@ export const FORM_LAYOUT_PUBLIC = {
* the modal form layout of public
*/
export const MODAL_FORM_STYLE: any = {
width: "40%",
width: "50%",
style: {
maxHeight: "70vh",
overflowY: "auto",
......@@ -229,6 +247,28 @@ export const MODAL_FORM_STYLE: any = {
};
export const PRO_LIST_CARD_META = {
title: {},
subTitle: {},
type: {},
avatar: {},
content: {},
actions: {
cardActionProps: "actions"
},
};
export const PRO_LIST_CARD_OPTIONS = {
search: false,
metas: PRO_LIST_CARD_META,
pagination: {
defaultPageSize: 10,
},
grid: {gutter: 24, column: 5}
};
/**
* the protable layout of public
*/
......@@ -250,12 +290,20 @@ export const PROTABLE_OPTIONS_PUBLIC = {
* the modal layout of public
*/
export const NORMAL_MODAL_OPTIONS = {
width: "40%",
width: "50%",
bodyStyle: {padding: "20px 10px 10px"},
destroyOnClose: true,
maskClosable: false,
};
/**
* the modal layout of public
*/
export const MODAL_FORM_OPTIONS = {
width: "50%",
};
/**
* the modal layout of public
*/
......
......@@ -15,7 +15,7 @@
* limitations under the License.
*/
import {BaseBeanColumns} from "@/types/Public/data";
import {BaseBeanColumns} from '@/types/Public/data';
/**
* about alert
......@@ -44,11 +44,11 @@ export type AlertConfig = {
}
export const ALERT_TYPE = {
DINGTALK: "DingTalk",
WECHAT: "WeChat",
FEISHU: "FeiShu",
EMAIL: "Email",
GROUP: "Group",
DINGTALK: 'DingTalk',
WECHAT: 'WeChat',
FEISHU: 'FeiShu',
EMAIL: 'Email',
GROUP: 'Group',
};
export const ALERT_CONFIG_LIST: AlertConfig[] = [{
......@@ -98,12 +98,12 @@ declare namespace Cluster {
/**
* about database and metadata
*/
declare namespace DataBases {
declare namespace DataSources {
/**
* database info
*/
export type DataBase = BaseBeanColumns & {
export type DataSource = BaseBeanColumns & {
groupName: string,
type: string,
url: string,
......@@ -201,7 +201,6 @@ export type GitProject = BaseBeanColumns & {
}
export type GitProjectTreeNode = {
name: string;
path: string;
......
......@@ -45,3 +45,7 @@ alter table dinky_udf modify column `class_name` varchar(200);
alter table dinky_udf alter column `enable` set default 1;
alter table dinky_udf modify column `source_code` longtext;
-- change data source of type
update dinky_data_source set `type` = 'MySQL' where `type` = 'Mysql';
update dinky_data_source set `type` = 'PostgreSQL' where `type` = 'PostgreSql';
update dinky_data_source set `type` = 'SQLServer' where `type` = 'SqlServer';
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment