Unverified Commit 13ef7bac authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Refactor] Refactor datastudio contextmenu (#2211)

* refactor datastudio contextmenu * Spotless Apply * fix copy bug * refactor cut job and paste job * Spotless Apply * refactor datastudio contextmenu * Spotless Apply * mkdify packagejson --------- Co-authored-by: 's avatarzhu-mingye <zhu-mingye@users.noreply.github.com>
parent b6a541b4
...@@ -31,11 +31,13 @@ import org.dinky.service.CatalogueService; ...@@ -31,11 +31,13 @@ import org.dinky.service.CatalogueService;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -102,22 +104,29 @@ public class CatalogueController { ...@@ -102,22 +104,29 @@ public class CatalogueController {
@Log(title = "Insert Or Update Catalogue", businessType = BusinessType.INSERT_OR_UPDATE) @Log(title = "Insert Or Update Catalogue", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("Insert Or Update Catalogue") @ApiOperation("Insert Or Update Catalogue")
public Result<Void> saveOrUpdateCatalogue(@RequestBody Catalogue catalogue) { public Result<Void> saveOrUpdateCatalogue(@RequestBody Catalogue catalogue) {
if (catalogueService.saveOrUpdate(catalogue)) { if (catalogueService.saveOrUpdateOrRename(catalogue)) {
return Result.succeed(Status.SAVE_SUCCESS); return Result.succeed(Status.SAVE_SUCCESS);
} else { } else {
return Result.failed(Status.SAVE_FAILED); return Result.failed(Status.SAVE_FAILED);
} }
} }
/** 获取所有目录 */ /**
* query catalogue tree data
* @return {@link Result}< {@link List}< {@link Catalogue}>>}
*/
@PostMapping("/getCatalogueTreeData") @PostMapping("/getCatalogueTreeData")
@ApiOperation("Get Catalogue Tree Data") @ApiOperation("Get Catalogue Tree Data")
public Result<List<Catalogue>> getCatalogueTreeData() { public Result<List<Catalogue>> getCatalogueTree() {
List<Catalogue> catalogues = catalogueService.getAllData(); List<Catalogue> catalogues = catalogueService.getCatalogueTree();
return Result.succeed(catalogues); return Result.succeed(catalogues);
} }
/** 创建节点和作业 */ /**
* create catalogue and task
* @param catalogueTaskDTO {@link CatalogueTaskDTO}
* @return {@link Result}< {@link Catalogue}>}
*/
@PutMapping("/createTask") @PutMapping("/createTask")
@Log(title = "Create Catalogue And Task", businessType = BusinessType.INSERT_OR_UPDATE) @Log(title = "Create Catalogue And Task", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("Create Catalogue And Task") @ApiOperation("Create Catalogue And Task")
...@@ -130,30 +139,30 @@ public class CatalogueController { ...@@ -130,30 +139,30 @@ public class CatalogueController {
} }
} }
/** 重命名节点和作业 */ /**
@PutMapping("/toRename") * move catalogue
@Log(title = "Rename Catalogue And Task", businessType = BusinessType.UPDATE) * @param originCatalogueId origin catalogue id
@ApiOperation("Rename Catalogue And Task") * @param targetParentId target parent id
public Result<Void> toRename(@RequestBody Catalogue catalogue) { * @return {@link Result}< {@link Boolean}>}
if (catalogueService.toRename(catalogue)) { */
return Result.succeed(Status.RENAME_SUCCESS);
} else {
return Result.failed(Status.RENAME_FAILED);
}
}
/** 重命名节点和作业 */
@PutMapping("/moveCatalogue") @PutMapping("/moveCatalogue")
@Log(title = "Move Catalogue", businessType = BusinessType.UPDATE) @Log(title = "Move Catalogue", businessType = BusinessType.UPDATE)
@ApiOperation("Move Catalogue") @ApiOperation("Move Catalogue")
public Result<Boolean> moveCatalogue(@RequestBody Catalogue catalogue) { public Result<Boolean> moveCatalogue(
if (catalogueService.moveCatalogue(catalogue.getId(), catalogue.getParentId())) { @RequestParam("originCatalogueId") Integer originCatalogueId,
@RequestParam("targetParentId") Integer targetParentId) {
if (catalogueService.moveCatalogue(originCatalogueId, targetParentId)) {
return Result.succeed(true, Status.MOVE_SUCCESS); return Result.succeed(true, Status.MOVE_SUCCESS);
} else { } else {
return Result.failed(false, Status.MOVE_FAILED); return Result.failed(false, Status.MOVE_FAILED);
} }
} }
/**
* copy task
* @param catalogue {@link Catalogue}
* @return {@link Result}< {@link Catalogue}>}
*/
@PostMapping("/copyTask") @PostMapping("/copyTask")
@Log(title = "Copy Task", businessType = BusinessType.INSERT_OR_UPDATE) @Log(title = "Copy Task", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("Copy Task") @ApiOperation("Copy Task")
...@@ -164,4 +173,16 @@ public class CatalogueController { ...@@ -164,4 +173,16 @@ public class CatalogueController {
return Result.failed(Status.COPY_FAILED); return Result.failed(Status.COPY_FAILED);
} }
} }
/**
* delete catalogue by id
* @param id catalogue id
* @return {@link Result}< {@link Void}>}
*/
@DeleteMapping("deleteCatalogueById")
@Log(title = "Delete Catalogue By Id", businessType = BusinessType.DELETE)
@ApiOperation("Delete Catalogue By Id")
public Result<Void> deleteCatalogueById(@RequestParam Integer id) {
return catalogueService.deleteCatalogueById(id);
}
} }
...@@ -35,6 +35,7 @@ import java.util.Set; ...@@ -35,6 +35,7 @@ import java.util.Set;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -65,7 +66,7 @@ public class UDFController { ...@@ -65,7 +66,7 @@ public class UDFController {
* *
* @return * @return
*/ */
@PostMapping("/tree") @GetMapping("/tree")
@ApiOperation("Build UDF Tree") @ApiOperation("Build UDF Tree")
public Result<List<Object>> listUdfTemplates() { public Result<List<Object>> listUdfTemplates() {
List<UDFTemplate> list = udfTemplateService.list(); List<UDFTemplate> list = udfTemplateService.list();
......
...@@ -21,6 +21,10 @@ package org.dinky.data.model; ...@@ -21,6 +21,10 @@ package org.dinky.data.model;
import org.dinky.mybatis.model.SuperEntity; import org.dinky.mybatis.model.SuperEntity;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
...@@ -48,6 +52,12 @@ public class Catalogue extends SuperEntity { ...@@ -48,6 +52,12 @@ public class Catalogue extends SuperEntity {
private Boolean isLeaf; private Boolean isLeaf;
@TableField(exist = false)
private List<Catalogue> children = new ArrayList<>();
@TableField(exist = false)
private Task task;
public Catalogue() {} public Catalogue() {}
public Catalogue(String name, Integer taskId, String type, Integer parentId, Boolean isLeaf) { public Catalogue(String name, Integer taskId, String type, Integer parentId, Boolean isLeaf) {
......
...@@ -21,6 +21,7 @@ package org.dinky.service; ...@@ -21,6 +21,7 @@ package org.dinky.service;
import org.dinky.data.dto.CatalogueTaskDTO; import org.dinky.data.dto.CatalogueTaskDTO;
import org.dinky.data.model.Catalogue; import org.dinky.data.model.Catalogue;
import org.dinky.data.result.Result;
import org.dinky.mybatis.service.ISuperService; import org.dinky.mybatis.service.ISuperService;
import java.util.List; import java.util.List;
...@@ -32,7 +33,7 @@ import java.util.List; ...@@ -32,7 +33,7 @@ import java.util.List;
*/ */
public interface CatalogueService extends ISuperService<Catalogue> { public interface CatalogueService extends ISuperService<Catalogue> {
List<Catalogue> getAllData(); List<Catalogue> getCatalogueTree();
Catalogue findByParentIdAndName(Integer parentId, String name); Catalogue findByParentIdAndName(Integer parentId, String name);
...@@ -42,9 +43,7 @@ public interface CatalogueService extends ISuperService<Catalogue> { ...@@ -42,9 +43,7 @@ public interface CatalogueService extends ISuperService<Catalogue> {
boolean toRename(Catalogue catalogue); boolean toRename(Catalogue catalogue);
List<String> removeCatalogueAndTaskById(Integer id); boolean moveCatalogue(Integer originCatalogueId, Integer targetParentId);
boolean moveCatalogue(Integer id, Integer parentId);
boolean copyTask(Catalogue catalogue); boolean copyTask(Catalogue catalogue);
...@@ -53,4 +52,8 @@ public interface CatalogueService extends ISuperService<Catalogue> { ...@@ -53,4 +52,8 @@ public interface CatalogueService extends ISuperService<Catalogue> {
void traverseFile(String sourcePath, Catalogue catalog); void traverseFile(String sourcePath, Catalogue catalog);
Catalogue getCatalogue(Integer parentId, String name); Catalogue getCatalogue(Integer parentId, String name);
Result<Void> deleteCatalogueById(Integer catalogueId);
Boolean saveOrUpdateOrRename(Catalogue catalogue);
} }
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<select id="queryAllSizeByName" resultType="java.lang.Integer"> <select id="queryAllSizeByName" resultType="java.lang.Integer">
SELECT count(*) SELECT count(*)
from dinky_task from dinky_task
where `name` REGEXP '${name}_[0-9]$' where `name` REGEXP concat(#{name}, '_[0-9]$')
</select> </select>
<select id="getTaskByNameAndTenantId" resultType="org.dinky.data.model.Task"> <select id="getTaskByNameAndTenantId" resultType="org.dinky.data.model.Task">
......
...@@ -223,6 +223,12 @@ public enum Status { ...@@ -223,6 +223,12 @@ public enum Status {
+ " or do not use LDAP to log in", + " or do not use LDAP to log in",
"当前用户登录模式不是LDAP,请联系管理员修改,或不使用LDAP登录"), "当前用户登录模式不是LDAP,请联系管理员修改,或不使用LDAP登录"),
/**
* datastudio about
*/
// 该目录下存在子目录/作业,无法删除
FOLDER_NOT_EMPTY(19001, "Folder Not Empty, Can Not Delete", "该目录下存在子目录/作业,无法删除"),
/** global exception */ /** global exception */
GLOBAL_PARAMS_CHECK_ERROR(90001, "Field: {0}, {1}", "字段: {0}, {1}"), GLOBAL_PARAMS_CHECK_ERROR(90001, "Field: {0}, {1}", "字段: {0}, {1}"),
GLOBAL_PARAMS_CHECK_ERROR_VALUE(90002, "Field: {0}, Illegal Value: {1}", "字段: {0}, 不合法的值: {1}"), GLOBAL_PARAMS_CHECK_ERROR_VALUE(90002, "Field: {0}, Illegal Value: {1}", "字段: {0}, 不合法的值: {1}"),
......
...@@ -8,10 +8,7 @@ ...@@ -8,10 +8,7 @@
"build": "max build", "build": "max build",
"deploy": "npm run build && npm run gh-pages", "deploy": "npm run build && npm run gh-pages",
"dev": "npm run start:dev", "dev": "npm run start:dev",
"gh-pages": "gh-pages -d dist",
"i18n-remove": "pro i18n-remove --locale=zh-CN --write",
"postinstall": "max setup", "postinstall": "max setup",
"jest": "jest",
"lint": "npm run lint:js && npm run lint:prettier && npm run tsc", "lint": "npm run lint:js && npm run lint:prettier && npm run tsc",
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ", "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ",
...@@ -21,16 +18,11 @@ ...@@ -21,16 +18,11 @@
"openapi": "max openapi", "openapi": "max openapi",
"prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\"", "prettier": "prettier -c --write \"**/**.{js,jsx,tsx,ts,less,md,json}\"",
"preview": "npm run build && max preview --port 8000", "preview": "npm run build && max preview --port 8000",
"record": "cross-env NODE_ENV=development REACT_APP_ENV=test max record --scene=login",
"serve": "umi-serve", "serve": "umi-serve",
"start": "cross-env UMI_ENV=dev max dev", "start": "cross-env UMI_ENV=dev max dev",
"start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev max dev", "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev max dev",
"start:no-mock": "cross-env MOCK=none UMI_ENV=dev max dev", "start:no-mock": "cross-env MOCK=none UMI_ENV=dev max dev",
"start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev max dev", "start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev max dev",
"start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev max dev",
"test": "jest",
"test:coverage": "npm run jest -- --coverage",
"test:update": "npm run jest -- -u",
"tsc": "tsc --noEmit" "tsc": "tsc --noEmit"
}, },
"lint-staged": { "lint-staged": {
...@@ -82,7 +74,6 @@ ...@@ -82,7 +74,6 @@
"@types/classnames": "^2.3.1", "@types/classnames": "^2.3.1",
"@types/express": "^4.17.17", "@types/express": "^4.17.17",
"@types/history": "^5.0.0", "@types/history": "^5.0.0",
"@types/jest": "^29.2.1",
"@types/lodash": "^4.14.186", "@types/lodash": "^4.14.186",
"@types/react": "^18.0.28", "@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11", "@types/react-dom": "^18.0.11",
...@@ -94,8 +85,6 @@ ...@@ -94,8 +85,6 @@
"express": "^4.18.2", "express": "^4.18.2",
"gh-pages": "^5.0.0", "gh-pages": "^5.0.0",
"husky": "^8", "husky": "^8",
"jest": "^29.4.3",
"jest-environment-jsdom": "^29.4.3",
"lint-staged": "^13", "lint-staged": "^13",
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"prettier": "^2", "prettier": "^2",
......
...@@ -77,7 +77,7 @@ export default { ...@@ -77,7 +77,7 @@ export default {
'right.menu.open': 'Open', 'right.menu.open': 'Open',
'right.menu.submit': 'Sync Submit', 'right.menu.submit': 'Sync Submit',
'right.menu.addSub': 'Add Sub Item', 'right.menu.addSub': 'Add Sub Item',
'right.menu.addRoot': 'Add Root Menu', 'right.menu.createSubFolder': 'Create Sub Folder',
'right.menu.exportJson': 'Export JSON', 'right.menu.exportJson': 'Export JSON',
'right.menu.importJson': 'Import JSON', 'right.menu.importJson': 'Import JSON',
'right.menu.rename': 'Rename', 'right.menu.rename': 'Rename',
...@@ -88,6 +88,7 @@ export default { ...@@ -88,6 +88,7 @@ export default {
'right.menu.paste': 'Paste', 'right.menu.paste': 'Paste',
'right.menu.delete': 'Delete', 'right.menu.delete': 'Delete',
'right.menu.createCatalogue': 'Create Directory', 'right.menu.createCatalogue': 'Create Directory',
'right.menu.createRoot': 'Create Root Directory',
'right.menu.uploadZipToCreate': 'Upload Zip To Create', 'right.menu.uploadZipToCreate': 'Upload Zip To Create',
'right.menu.createTask': 'Create Task', 'right.menu.createTask': 'Create Task',
'right.menu.closeAll': 'Close All', 'right.menu.closeAll': 'Close All',
......
...@@ -1063,4 +1063,18 @@ export default { ...@@ -1063,4 +1063,18 @@ export default {
'datastudio.project.create.rootFolder': 'Create Root Folder', 'datastudio.project.create.rootFolder': 'Create Root Folder',
'datastudio.project.create.folder.name': 'Folder Name', 'datastudio.project.create.folder.name': 'Folder Name',
'datastudio.project.create.folder.name.placeholder': 'Please enter the folder name', 'datastudio.project.create.folder.name.placeholder': 'Please enter the folder name',
'datastudio.project.create.folder.tip': 'No job, please click the new directory in the upper left corner',
'datastudio.project.delete.job': 'Delete [{type}] Job [{name}]',
'datastudio.project.delete.job.confirm': 'This operation will delete the execution history of the task and all information of the task. \nPlease operate with caution! This operation is irreversible!!! \n\t\t\t\tConfirm to delete?',
'catalog.name': 'Job Name',
'catalog.name.placeholder': 'Please enter the job name',
'catalog.name.tip': 'This name can be used as the JobName of the FlinkSql task (pipeline.name configuration item)',
'catalog.type': 'Job Type',
'catalog.type.placeholder': 'Please select the job type',
'catalog.type.tip': 'The job type determines the execution method of the job, please choose carefully, once selected, it cannot be modified',
'catalog.udf.templateId': 'UDF Template',
'catalog.udf.templateId.placeholder': 'Please select UDF template',
'catalog.udf.className': 'Class/Method Name',
'catalog.udf.className.placeholder': 'Please enter the class or method name',
}; };
...@@ -79,6 +79,7 @@ export default { ...@@ -79,6 +79,7 @@ export default {
'right.menu.open': '打开', 'right.menu.open': '打开',
'right.menu.submit': '异步提交', 'right.menu.submit': '异步提交',
'right.menu.addSub': '添加子项', 'right.menu.addSub': '添加子项',
'right.menu.createSubFolder': '添加子目录',
'right.menu.exportJson': '导出 JSON', 'right.menu.exportJson': '导出 JSON',
'right.menu.importJson': '导入 JSON', 'right.menu.importJson': '导入 JSON',
'right.menu.rename': '重命名', 'right.menu.rename': '重命名',
...@@ -89,7 +90,7 @@ export default { ...@@ -89,7 +90,7 @@ export default {
'right.menu.paste': '粘贴', 'right.menu.paste': '粘贴',
'right.menu.delete': '删除', 'right.menu.delete': '删除',
'right.menu.createCatalogue': '创建目录', 'right.menu.createCatalogue': '创建目录',
'right.menu.createRootCatalogue': '创建根目录', 'right.menu.createRoot': '创建根目录',
'right.menu.uploadZipToCreate': '上传zip包创建工程', 'right.menu.uploadZipToCreate': '上传zip包创建工程',
'right.menu.createTask': '创建作业', 'right.menu.createTask': '创建作业',
'right.menu.closeAll': '关闭所有', 'right.menu.closeAll': '关闭所有',
......
...@@ -1076,6 +1076,21 @@ export default { ...@@ -1076,6 +1076,21 @@ export default {
'datastudio.project.create.rootFolder': '创建根目录', 'datastudio.project.create.rootFolder': '创建根目录',
'datastudio.project.create.folder.name': '目录名称', 'datastudio.project.create.folder.name': '目录名称',
'datastudio.project.create.folder.name.placeholder': '请输入目录名称', 'datastudio.project.create.folder.name.placeholder': '请输入目录名称',
'datastudio.project.create.folder.tip': '暂无作业,请点击左上角新建目录',
'datastudio.project.delete.job': '删除 [{type}] 作业 [{name}]',
'datastudio.project.delete.job.confirm': '此操作会将该任务的执行历史, 以及任务的所有信息全部删除.\n\t\t\t\t请谨慎操作! 该操作不可逆!!!\n\t\t\t\t\t确认删除吗?',
'catalog.name': '作业名称',
'catalog.name.placeholder': '请输入作业名称',
'catalog.name.tip': '此名称可作为 FlinkSql 任务的 JobName ([配置项: pipeline.name])',
'catalog.type': '作业类型',
'catalog.type.placeholder': '请选择作业类型',
'catalog.type.tip': '作业类型决定了作业的执行方式, 请谨慎选择, 一旦选择后不可修改',
'catalog.udf.templateId': 'UDF 模板',
'catalog.udf.templateId.placeholder': '请选择 UDF 模板',
'catalog.udf.className': '类或方法名',
'catalog.udf.className.placeholder': '请输入类或方法名',
}; };
{
"name": "Dinky",
"short_name": "Dinky",
"display": "standalone",
"start_url": "./?utm_source=homescreen",
"theme_color": "#002140",
"background_color": "#001529",
"icons": [
{
"src": "dinky.svg",
"sizes": "192x192"
},
{
"src": "dinky.svg",
"sizes": "128x128"
},
{
"src": "dinky.svg",
"sizes": "512x512"
}
]
}
...@@ -221,7 +221,7 @@ const MenuList: React.FC = () => { ...@@ -221,7 +221,7 @@ const MenuList: React.FC = () => {
type={'primary'} type={'primary'}
onClick={() => handleCreateRoot()} onClick={() => handleCreateRoot()}
> >
{l('right.menu.addRoot')} {l('right.menu.createRoot')}
</Button> </Button>
<Button <Button
size={'middle'} size={'middle'}
...@@ -241,7 +241,7 @@ const MenuList: React.FC = () => { ...@@ -241,7 +241,7 @@ const MenuList: React.FC = () => {
{(formValues.id && updateModalVisible) ? {(formValues.id && updateModalVisible) ?
l('menu.edit') : (!formValues.id && modalVisible && !isRootMenu) ? l('menu.edit') : (!formValues.id && modalVisible && !isRootMenu) ?
l('right.menu.addSub') : (!formValues.id && modalVisible && isRootMenu) ? l('right.menu.addSub') : (!formValues.id && modalVisible && isRootMenu) ?
l('right.menu.addRoot') : ''} l('right.menu.createRoot') : ''}
</> </>
} }
......
...@@ -21,11 +21,10 @@ import React from "react"; ...@@ -21,11 +21,10 @@ import React from "react";
import {ProForm, ProFormText} from "@ant-design/pro-components"; import {ProForm, ProFormText} from "@ant-design/pro-components";
import {l} from "@/utils/intl"; import {l} from "@/utils/intl";
const JobForm = () => { const FolderForm = () => {
return <> return <>
<ProFormText <ProFormText
name="name" name="name"
width={'md'}
label={l('datastudio.project.create.folder.name')} label={l('datastudio.project.create.folder.name')}
placeholder={l('datastudio.project.create.folder.name.placeholder')} placeholder={l('datastudio.project.create.folder.name.placeholder')}
rules={[ {required: true, message: l('datastudio.project.create.folder.name.placeholder')} ]} rules={[ {required: true, message: l('datastudio.project.create.folder.name.placeholder')} ]}
...@@ -34,4 +33,4 @@ const JobForm = () => { ...@@ -34,4 +33,4 @@ const JobForm = () => {
}; };
export default JobForm; export default FolderForm;
\ No newline at end of file \ No newline at end of file
/*
*
* 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 { ModalForm } from "@ant-design/pro-components";
import {Form} from "antd";
import React, {useEffect} from "react";
import {Catalogue} from "@/types/Studio/data";
import {FormContextValue} from "@/components/Context/FormContext";
import FolderForm from "@/pages/DataStudio/LeftContainer/Project/FolderModal/FolderForm";
type JobModalProps = {
onCancel: () => void
onSubmit: (values: Catalogue) => void
modalVisible: boolean
title: React.ReactNode
values: Partial<Catalogue>
}
const FolderModal:React.FC<JobModalProps> = ( props ) => {
const {onCancel, onSubmit, modalVisible,title,values} = props;
const [form] = Form.useForm<Catalogue>();
/**
* init form context
*/
const formContext = React.useMemo<FormContextValue>(
() => ({
resetForm: () => form.resetFields(), // 定义 resetForm 方法
}),
[form],
);
/**
* when modalVisible or values changed, set form values
*/
useEffect(() => {
if (modalVisible) form.resetFields();
form.setFieldsValue(values);
}, [open, values, form]);
/**
* handle cancel
*/
const handleCancel = () => {
onCancel();
formContext.resetForm();
};
/**
* submit form
*/
const submitForm = async (formData: Catalogue ) => {
await form.validateFields();
const newValue = await form.getFieldsValue();
onSubmit({...values, name: newValue.name} as Catalogue);
};
return <>
<ModalForm<Catalogue>
title={title}
form={form}
width={'30%'}
initialValues={values}
open={modalVisible}
layout={'horizontal'}
autoFocusFirstInput
modalProps={{destroyOnClose: true, maskClosable: false, onCancel: handleCancel}}
onFinish={async (values) => submitForm(values)}
>
<FolderForm />
</ModalForm>
</>
};
export default FolderModal;
\ No newline at end of file
...@@ -17,41 +17,140 @@ ...@@ -17,41 +17,140 @@
* *
*/ */
import { ModalForm } from "@ant-design/pro-components"; import {ModalForm, ProFormSelect, ProFormText} from "@ant-design/pro-components";
import {l} from "@/utils/intl";
import {Form} from "antd"; import {Form} from "antd";
import React from "react";
import JobForm from "@/pages/DataStudio/LeftContainer/Project/JobModal/JobForm";
import {Catalogue} from "@/types/Studio/data"; import {Catalogue} from "@/types/Studio/data";
import {l} from "@/utils/intl"; import React, {useEffect, useState} from "react";
import {FormContextValue} from "@/components/Context/FormContext";
import {JOB_TYPE} from "@/pages/DataStudio/LeftContainer/Project/constants";
import {isUDF} from "@/pages/DataStudio/LeftContainer/Project/function";
import {ProFormCascader} from "@ant-design/pro-form/lib";
import {queryDataByParams} from "@/services/BusinessCrud";
import {API_CONSTANTS} from "@/services/constants";
type JobModalProps = { type JobModalProps = {
onCancel: () => void onCancel: () => void
onSubmit: (values: Catalogue) => void onSubmit: (values: Catalogue) => void
modalVisible: boolean modalVisible: boolean
title: React.ReactNode
values: Partial<Catalogue>
} }
const JobModal:React.FC<JobModalProps> = ( props ) => { const JobModal: React.FC<JobModalProps> = (props) => {
const {onCancel, onSubmit, modalVisible, title, values} = props;
const [jobType, setJobType] = React.useState<string>(values.type || '');
const {onCancel, onSubmit, modalVisible} = props;
const [form] = Form.useForm<Catalogue>(); const [form] = Form.useForm<Catalogue>();
/**
* init form context
*/
const formContext = React.useMemo<FormContextValue>(
() => ({
resetForm: () => form.resetFields(), // 定义 resetForm 方法
}),
[form],
);
/**
* when modalVisible or values changed, set form values
*/
useEffect(() => {
if (modalVisible) form.resetFields();
form.setFieldsValue(values);
}, [open, values, form]);
/**
* handle cancel
*/
const handleCancel = () => {
onCancel();
formContext.resetForm();
};
/**
* form values change
* @param changedValues
* @param allValues
*/
const onValuesChange = (changedValues: any, allValues: any) => {
if (allValues.type) setJobType(allValues.type);
}
/**
* submit form
*/
const submitForm = async (formData: Catalogue) => {
await form.validateFields();
if(!formData.configJson.templateId) return
formData.configJson.templateId = formData.configJson.templateId.reverse().pop();
onSubmit({...values, ...formData} as Catalogue);
};
const renderForm = () => {
return <>
<ProFormSelect
name={'type'}
label={l('catalog.type')}
tooltip={l('catalog.type.tip')}
options={JOB_TYPE}
disabled={!!values.id}
placeholder={l('catalog.type.placeholder')}
rules={[{required: true, message: l('catalog.type.placeholder')}]}
/>
<ProFormText
name="name"
label={l('catalog.name')}
tooltip={l('catalog.name.tip')}
placeholder={l('catalog.name.placeholder')}
rules={[{required: true, message: l('catalog.name.placeholder')}]}
/>
{
isUDF(jobType) &&
<>
<ProFormCascader
name={['configJson', 'templateId']}
label={l('catalog.udf.templateId')}
placeholder={l('catalog.udf.templateId.placeholder')}
request={async () => await queryDataByParams(API_CONSTANTS.UDF_TEMPLATE_TREE)}
rules={[{required: true, message: l('catalog.udf.templateId.placeholder')}]}
/>
<ProFormText
name={['configJson', 'className']}
label={l('catalog.udf.className')}
placeholder={l('catalog.udf.className.placeholder')}
rules={[{required: true, message: l('catalog.udf.className.placeholder')}]}
/>
</>
}
</>
};
return <> return <>
<ModalForm<Catalogue> <ModalForm<Catalogue>
title={l('datastudio.project.create.rootFolder')} title={title}
form={form} form={form}
width={'30%'} width={'30%'}
initialValues={{...values}}
open={modalVisible} open={modalVisible}
layout={'inline'} layout={'horizontal'}
style={{display: 'flex', flexDirection: 'column', alignItems: 'center',}} autoFocusFirstInput onValuesChange={onValuesChange}
autoFocusFirstInput modalProps={{destroyOnClose: true, maskClosable: false, onCancel: handleCancel}}
modalProps={{destroyOnClose: true, maskClosable: false, onCancel: onCancel}} onFinish={async (values) => submitForm(values)}
onFinish={async (values) => onSubmit(values)}
> >
<JobForm /> {renderForm()}
</ModalForm> </ModalForm>
</> </>
}; };
export default JobModal
export default JobModal; \ No newline at end of file
\ No newline at end of file
...@@ -19,12 +19,16 @@ ...@@ -19,12 +19,16 @@
import React, {useState} from "react"; import React, {useState} from "react";
import {Empty, Tree} from "antd"; import {Empty, Tree} from "antd";
import {convertToTreeData, generateList, getParentKey, loop, TreeDataNode} from "@/pages/DataStudio/LeftContainer/Project/function"; import {
buildProjectTree, generateList, getParentKey,
} from "@/pages/DataStudio/LeftContainer/Project/function";
import {connect} from "@@/exports"; import {connect} from "@@/exports";
import {StateType} from "@/pages/DataStudio/model"; import {StateType} from "@/pages/DataStudio/model";
import {Key} from "@ant-design/pro-components"; import {Key} from "@ant-design/pro-components";
import {BtnRoute} from "@/pages/DataStudio/route"; import {BtnRoute} from "@/pages/DataStudio/route";
import Search from "antd/es/input/Search"; import Search from "antd/es/input/Search";
import {l} from "@/utils/intl";
import {Catalogue} from "@/types/Studio/data";
const {DirectoryTree} = Tree; const {DirectoryTree} = Tree;
...@@ -34,16 +38,18 @@ const {DirectoryTree} = Tree; ...@@ -34,16 +38,18 @@ const {DirectoryTree} = Tree;
* props * props
*/ */
type TreeProps = { type TreeProps = {
treeData: TreeDataNode[]; treeData: Catalogue[];
onNodeClick: (info: any) => void onNodeClick: (info: any) => void
onRightClick: (info: any) => void
style?: React.CSSProperties style?: React.CSSProperties
selectedKeys: Key[]
} }
const JobTree: React.FC<TreeProps & connect> = (props) => { const JobTree: React.FC<TreeProps & connect> = (props) => {
const {treeData, onNodeClick, style, height} = props; const {treeData, onNodeClick, style, height,onRightClick,selectedKeys} = props;
const [searchValue,setSearchValueValue] = useState(""); const [searchValue,setSearchValueValue] = useState("");
const data = loop(convertToTreeData(JSON.parse(JSON.stringify(treeData)), 0), searchValue); const data = buildProjectTree(treeData, searchValue);
const [expandedKeys, setExpandedKeys] = useState<Key[]>(); const [expandedKeys, setExpandedKeys] = useState<Key[]>();
const [autoExpandParent, setAutoExpandParent] = useState(true); const [autoExpandParent, setAutoExpandParent] = useState(true);
...@@ -73,29 +79,32 @@ const JobTree: React.FC<TreeProps & connect> = (props) => { ...@@ -73,29 +79,32 @@ const JobTree: React.FC<TreeProps & connect> = (props) => {
setExpandedKeys(expandedKeys); setExpandedKeys(expandedKeys);
}; };
const expandAll = () => { const expandAll = () => {
const map = (data as TreeDataNode[]).filter(x=>!x.isLeaf).map(x => x.key); const map = (data).filter((x: { isLeaf: any; })=>!x.isLeaf).map((x: { key: any; }) => x.key);
setExpandedKeys(map); setExpandedKeys(map);
} }
const btn = BtnRoute['menu.datastudio.project']; const btn = BtnRoute['menu.datastudio.project'];
btn[0].onClick = expandAll
btn[1].onClick = () => setExpandedKeys([]); btn[1].onClick = expandAll
btn[2].onClick = () => setExpandedKeys([]);
return <> return <>
<Search style={{margin:"8px 0px"}} placeholder="Search" onChange={onChangeSearch} allowClear={true}/> <Search style={{margin:"8px 0px"}} placeholder={l('global.search.text')} onChange={onChangeSearch} allowClear={true}/>
{ {
(treeData.length > 0) ? (treeData.length > 0) ?
<DirectoryTree <DirectoryTree
style={{...style, height: height-40-16,overflowY:'auto'}} style={{...style, height: height-40-16,overflowY:'auto'}}
// className={'treeList'} className={'treeList'}
onSelect={(_, info) => onNodeClick(info)} onSelect={(_, info) => onNodeClick(info)}
onRightClick={onRightClick}
expandedKeys={expandedKeys} expandedKeys={expandedKeys}
selectedKeys={selectedKeys}
onExpand={onExpand} onExpand={onExpand}
treeData={data} treeData={data}
autoExpandParent={autoExpandParent} autoExpandParent={autoExpandParent}
/> : <Empty className={'code-content-empty'} description={"暂无作业,请点击左上角新建目录"}/> /> : <Empty className={'code-content-empty'} description={l('datastudio.project.create.folder.tip')}/>
} }
</>; </>;
}; };
......
...@@ -21,13 +21,12 @@ import React, {useState} from "react"; ...@@ -21,13 +21,12 @@ import React, {useState} from "react";
import {Space} from "antd"; import {Space} from "antd";
import Title from "@/components/Front/Title"; import Title from "@/components/Front/Title";
import {l} from "@/utils/intl"; import {l} from "@/utils/intl";
import JobModal from "@/pages/DataStudio/LeftContainer/Project/JobModal";
import {connect} from "@umijs/max"; import {connect} from "@umijs/max";
import {StateType} from "@/pages/DataStudio/model"; import {StateType} from "@/pages/DataStudio/model";
import {Catalogue} from "@/types/Studio/data"; import {Catalogue} from "@/types/Studio/data";
import {handleAddOrUpdate} from "@/services/BusinessCrud"; import {handleAddOrUpdate} from "@/services/BusinessCrud";
import {PlusOutlined} from "@ant-design/icons"; import {BtnRoute} from "@/pages/DataStudio/route";
import {CircleBtn} from "@/components/CallBackButton/CircleBtn"; import FolderModal from "@/pages/DataStudio/LeftContainer/Project/FolderModal";
const ProjectTitle: React.FC<StateType & connect> = (props) => { const ProjectTitle: React.FC<StateType & connect> = (props) => {
...@@ -62,7 +61,10 @@ const ProjectTitle: React.FC<StateType & connect> = (props) => { ...@@ -62,7 +61,10 @@ const ProjectTitle: React.FC<StateType & connect> = (props) => {
handleCancelCreate(); handleCancelCreate();
dispatch({type: 'Studio/queryProject'}); dispatch({type: 'Studio/queryProject'});
}); });
} };
const btn = BtnRoute['menu.datastudio.project'];
btn[0].onClick = () => handleCreateClick();
/** /**
...@@ -73,9 +75,12 @@ const ProjectTitle: React.FC<StateType & connect> = (props) => { ...@@ -73,9 +75,12 @@ const ProjectTitle: React.FC<StateType & connect> = (props) => {
if (selectKey && selectKey === "menu.datastudio.project") { if (selectKey && selectKey === "menu.datastudio.project") {
return <Space> return <Space>
<Title>{l(selectKey)}</Title> <Title>{l(selectKey)}</Title>
<CircleBtn title={l("datastudio.project.create.rootFolder")} icon={<PlusOutlined/>} <FolderModal
onClick={() => handleCreateClick()}/> title={l('right.menu.createRoot')}
<JobModal modalVisible={createModalVisible} onCancel={handleCancelCreate} onSubmit={handleSubmit}/> modalVisible={createModalVisible}
onCancel={handleCancelCreate}
onSubmit={handleSubmit} values={{}}
/>
</Space> </Space>
} else { } else {
return <Title>{l(selectKey)}</Title> return <Title>{l(selectKey)}</Title>
......
/*
*
* 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 {
CompassTwoTone,
CopyrightTwoTone,
CopyTwoTone,
CustomerServiceTwoTone,
DeleteTwoTone,
EditTwoTone, ExportOutlined,
PlusCircleTwoTone, UpCircleTwoTone, UploadOutlined
} from "@ant-design/icons";
import {l} from "@/utils/intl";
import {BackIcon} from "@/components/Icons/CustomIcons";
import React from "react";
import {MenuItemType} from "antd/es/menu/hooks/useItems";
import {DefaultOptionType} from "antd/es/select";
import {DIALECT} from "@/services/constants";
/**
* 目录级别:
* 新建子目录
* 新建作业
* 删除(删除时检测是否有下级)
* 重命名
* 粘贴
* 取消
* @type {({icon: JSX.Element, label: string, key: string} | {icon: JSX.Element, label: string, key: string} | {icon: JSX.Element, label: string, key: string} | {icon: JSX.Element, label: string, key: string})[]}
*/
export const FOLDER_RIGHT_MENU =(disabled = false) : MenuItemType[] =>[
{
key: 'addSubFolder',
icon: <PlusCircleTwoTone/>,
label: l('right.menu.createSubFolder'),
},
{
key: 'createTask',
icon: <PlusCircleTwoTone/>,
label: l('right.menu.createTask'),
},
{
key: 'delete',
icon: <DeleteTwoTone twoToneColor={'red'}/>,
label: l('button.delete'),
},
{
key: 'renameFolder',
icon: <EditTwoTone />,
label: l('right.menu.rename'),
},
{
key: 'paste',
icon: <CompassTwoTone />,
label: l('right.menu.paste'),
disabled: !disabled
},
];
/**
* 作业级别:
* 非目录(即任务)
* 导出 json
* 修改
* 复制
* 剪切
* 删除
* @type {({icon: JSX.Element, label: string, key: string} | {icon: JSX.Element, label: string, key: string} | {icon: JSX.Element, label: string, key: string} | {icon: JSX.Element, label: string, key: string})[]}
*/
export const JOB_RIGHT_MENU =(disabled = false) : MenuItemType[] => [
{
key: 'edit',
icon: <EditTwoTone />,
label: l('button.edit'),
},
{
key: 'exportJson',
icon: <UpCircleTwoTone />,
label: l('right.menu.exportJson'),
},
{
key: 'copy',
icon: <CopyTwoTone />,
label: l('right.menu.copy'),
},
{
key: 'cut',
icon: <CopyrightTwoTone />,
label: l('right.menu.cut'),
disabled: disabled
},
{
key: 'delete',
icon: <DeleteTwoTone twoToneColor={'red'}/>,
label: l('button.delete'),
},
];
/**
* 作业 方言类型
* @type {({options: ({label: string, value: string} | {label: string, value: string} | {label: string, value: string} | {label: string, value: string})[], label: string} | {options: ({label: string, value: string} | {label: string, value: string} | {label: string, value: string} | {label: string, value: string} | {label: string, value: string} | {label: string, value: string} | {label: string, value: string} | {label: string, value: string} | {label: string, value: string} | {label: string, value: string} | {label: string, value: string})[], label: string} | {options: ({label: string, value: string} | {label: string, value: string} | {label: string, value: string})[], label: string})[]}
*/
export const JOB_TYPE: DefaultOptionType[] = [
{
label: 'Flink Job Type',
options: [
{
value: 'FlinkSql',
label: 'FlinkSql',
},
{
value: 'FlinkJar',
label: 'FlinkJar',
},
{
value: 'FlinkSqlEnv',
label: 'FlinkSqlEnv',
},
{
value: 'KubernetesApplication',
label: 'KubernetesApplication',
}
]
},
{
label: 'Jdbc Query Type',
options: [
{
value: 'Sql',
label: 'Sql',
},
{
value: 'Mysql',
label: 'Mysql',
},
{
value: 'Oracle',
label: 'Oracle',
},
{
value: 'SqlServer',
label: 'SqlServer',
},
{
value: 'PostgreSql',
label: 'PostgreSql',
},
{
value: 'ClickHouse',
label: 'ClickHouse',
},
{
value: 'Doris',
label: 'Doris',
},
{
value: 'Hive',
label: 'Hive',
},
{
value: 'Phoenix',
label: 'Phoenix',
},
{
value: 'StarRocks',
label: 'StarRocks',
},
{
value: 'Presto',
label: 'Presto',
},
]
},
{
label: 'Other Type',
options: [
{
value: 'Java',
label: 'Java',
},
{
value: 'Scala',
label: 'Scala',
},
{
value: 'Python',
label: 'Python',
}
]
},
]
\ No newline at end of file
import { DataNode } from "antd/es/tree"; import {searchTreeNode} from "@/utils/function";
import {getIcon} from "@/utils/function";
import style from "./index.less";
import {getTabIcon} from "@/pages/DataStudio/MiddleContainer/function"; import {getTabIcon} from "@/pages/DataStudio/MiddleContainer/function";
import {SysMenu} from "@/types/RegCenter/data";
import {Catalogue} from "@/types/Studio/data";
import path from "path";
import {DIALECT} from "@/services/constants";
export interface TreeDataNode extends DataNode {
name:string;
type?:string;
id:number;
taskId:number;
parentId:number;
path:string[];
schema:string;
table:string;
}
export const generateList = (data: any, list: any[]) => { export const generateList = (data: any, list: any[]) => {
for (const element of data) { for (const element of data) {
...@@ -39,71 +31,48 @@ export const getParentKey = (key: number | string, tree: any): any => { ...@@ -39,71 +31,48 @@ export const getParentKey = (key: number | string, tree: any): any => {
} }
return parentKey; return parentKey;
}; };
export function convertToTreeData(data:TreeDataNode[], pid:number,path?:string[]) {
!path&&(path=[]);
const result:TreeDataNode[] = [];
let temp:TreeDataNode[] = [];
for (let i = 0; i < data?.length; i++) {
if (data[i].parentId === pid) {
let obj = data[i];
obj.title = obj.name;
obj.key = obj.id;
obj.path = path.slice();
obj.path.push(obj.name);
temp = convertToTreeData(data, data[i].id,obj.path);
if (temp.length > 0) {
obj.children = temp
}
result.push(obj)
}
}
return result
}
export const loop:any= (data: TreeDataNode[],searchValue:string) =>
data?.map((item: any) => {
const index = item.title.indexOf(searchValue);
const beforeStr = item.name.substring(0, index);
const afterStr = item.name.substring(index + searchValue.length);
item.icon = getTabIcon(item.type,20);
const title = /**
index > -1 ? ( * build menu tree
<span> * @param {SysMenu[]} data
{beforeStr} * @param {string} searchValue
<span className={style['site-tree-search-value']}>{searchValue}</span> * @param path
{afterStr} * @returns {any}
</span> */
) : (
<div> export const buildProjectTree = (data: Catalogue[], searchValue: string = '', path?: string[]): any => data.filter((ca: Catalogue) => (ca.name.toLowerCase().indexOf(searchValue.toLowerCase()) > -1)).map((item: Catalogue) => {
<span>{item.name}</span>
</div> // 使用 name 拼接 path todo: 有 bug ,需要修复
); if (path) {
if (item.children) { path.push(...path,item.name)
return {
isLeaf: item.isLeaf,
name: item.name,
id: item.id,
taskId: item.taskId,
type: item.type,
parentId: item.parentId,
path: item.path,
icon: item.isLeaf ? item.icon : '',
title,
key: item.key,
children: loop(item.children,searchValue)
};
} }
return { return {
isLeaf: item.isLeaf, // isLeaf: (item.type && item.children.length === 0) ,
isLeaf: item.isLeaf ,
name: item.name, name: item.name,
parentId: item.parentId,
label: searchTreeNode(item.name, searchValue),
icon: (item.type && item.children.length === 0) && getTabIcon(item.type,20),
value: item.id,
path: path || [],
type: item.type,
title: <>{searchTreeNode(item.name, searchValue)}</>,
fullInfo: item,
key: item.id,
id: item.id, id: item.id,
taskId: item.taskId, taskId: item.taskId,
type: item.type, children: buildProjectTree(item.children, searchValue , path),
parentId: item.parentId, }
path: item.path, });
icon: item.isLeaf ? item.icon : '',
title: title,
key: item.key, export const isUDF = (jobType: string) => {
}; return (jobType === 'Scala' || jobType === 'Python' || jobType === 'Java')
}); }
export const buildUDFTree = (data: []) => {
}
\ No newline at end of file
/*
*
* 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.
*
*/
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
} from "@/components/Icons/CodeLanguageIcon"; } from "@/components/Icons/CodeLanguageIcon";
import {ClickHouseIcons, DorisIcons, HiveIcons, MysqlIcons, OracleIcons, PhoenixIcons, import {ClickHouseIcons, DorisIcons, HiveIcons, MysqlIcons, OracleIcons, PhoenixIcons,
PostgresqlIcons, PrestoIcons, SqlServerIcons, StarRocksIcons} from "@/components/Icons/DBIcons"; PostgresqlIcons, PrestoIcons, SqlServerIcons, StarRocksIcons} from "@/components/Icons/DBIcons";
import {FolderOutlined} from "@ant-design/icons";
export const getTabIcon = (type: string, size?: number) => { export const getTabIcon = (type: string, size?: number) => {
if (!type){ if (!type){
......
...@@ -26,26 +26,20 @@ import {l} from "@/utils/intl"; ...@@ -26,26 +26,20 @@ import {l} from "@/utils/intl";
import {Drawer} from "antd"; import {Drawer} from "antd";
import {ProDescriptionsItemProps} from "@ant-design/pro-descriptions"; import {ProDescriptionsItemProps} from "@ant-design/pro-descriptions";
import {postAll} from "@/services/api"; import {postAll} from "@/services/api";
import {SavePoint} from "@/types/Studio/data";
const url = '/api/savepoints'; const url = '/api/savepoints';
export type SavePointTableListItem = {
id: number,
taskId: number,
name: string,
type: string,
path: string,
createTime: Date,
};
const SavePoints = (props: any) => { const SavePoints = (props: any) => {
const { tabs: {panes, activeKey}} = props; const { tabs: {panes, activeKey}} = props;
const current = getCurrentData(panes, activeKey); const current = getCurrentData(panes, activeKey);
const [row, setRow] = useState<SavePointTableListItem>(); const [row, setRow] = useState<SavePoint>();
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
actionRef.current?.reloadAndRest?.(); actionRef.current?.reloadAndRest?.();
const columns: ProDescriptionsItemProps<SavePointTableListItem>[] = [ const columns: ProDescriptionsItemProps<SavePoint>[] = [
{ {
title: l('pages.task.savePointPath'), title: l('pages.task.savePointPath'),
...@@ -67,7 +61,7 @@ const SavePoints = (props: any) => { ...@@ -67,7 +61,7 @@ const SavePoints = (props: any) => {
return ( return (
<> <>
<ProTable<SavePointTableListItem> <ProTable<SavePoint>
actionRef={actionRef} actionRef={actionRef}
rowKey="id" rowKey="id"
request={(params, sorter, filter) => postAll(url, {taskId: current.key, ...params, sorter, filter})} request={(params, sorter, filter) => postAll(url, {taskId: current.key, ...params, sorter, filter})}
...@@ -83,7 +77,7 @@ const SavePoints = (props: any) => { ...@@ -83,7 +77,7 @@ const SavePoints = (props: any) => {
closable={false} closable={false}
> >
{row?.name && ( {row?.name && (
<ProDescriptions<SavePointTableListItem> <ProDescriptions<SavePoint>
column={2} column={2}
title={row?.name} title={row?.name}
request={async () => ({ request={async () => ({
......
...@@ -252,6 +252,7 @@ export type ModelType = { ...@@ -252,6 +252,7 @@ export type ModelType = {
saveProject: Reducer<StateType>; saveProject: Reducer<StateType>;
updateTabsActiveKey: Reducer<StateType>; updateTabsActiveKey: Reducer<StateType>;
closeTab: Reducer<StateType>; closeTab: Reducer<StateType>;
removeTag: Reducer<StateType>;
addTab: Reducer<StateType>; addTab: Reducer<StateType>;
saveTabs: Reducer<StateType>; saveTabs: Reducer<StateType>;
closeAllTabs: Reducer<StateType>; closeAllTabs: Reducer<StateType>;
...@@ -537,6 +538,37 @@ const Model: ModelType = { ...@@ -537,6 +538,37 @@ const Model: ModelType = {
} }
}; };
}, },
/**
* 移除标签
* @param {StateType} state
* @param {any} payload
* @returns {{centerContentHeight: number, tabs: {panes: TabsItemType[], activeBreadcrumbTitle: string, activeKey: string}, project: {data: any[], expandKeys: [], selectKey: []}, leftContainer: Container, env: EnvType[], footContainer: {codeType: string, jobRunningMsg: JobRunningMsgType, codeEncoding: string, memDetails: string, lineSeparator: string, space: number, codePosition: [number, number]}, clusterConfiguration: Cluster.Config[], toolContentHeight: number, database: {dbData: DataSources.DataSource[], selectDatabaseId: number | null, expandKeys: [], selectKey: []}, sessionCluster: Cluster.Instance[], isFullScreen: boolean, rightContainer: Container, bottomContainerContent: BottomContainerContent, bottomContainer: Container}}
*/
removeTag(state, {payload}) {
const needRemoveKey = payload
const {tabs: {panes, activeKey}} = state;
const index = panes.findIndex((item,index)=> {
const params = item.params as DataStudioParams;
return params.taskId === needRemoveKey
})
// 关闭 传过来的key
if (index !== -1) {
panes.splice(index, 1);
}
const newActiveKey = activeKey === needRemoveKey ? panes[panes.length - 1].key : activeKey;
return {
...state,
tabs: {
...state.tabs,
panes: panes,
activeKey: newActiveKey,
}
}
},
/** /**
* 关闭tab * 关闭tab
* @param {StateType} state * @param {StateType} state
......
...@@ -30,7 +30,7 @@ import { ...@@ -30,7 +30,7 @@ import {
HistoryOutlined, HistoryOutlined,
InfoCircleOutlined, InfoCircleOutlined,
MonitorOutlined, MonitorOutlined,
PlayCircleOutlined, PlayCircleOutlined, PlusCircleOutlined, PlusCircleTwoTone,
ReloadOutlined, ReloadOutlined,
RightSquareOutlined, RightSquareOutlined,
SettingOutlined, ShrinkOutlined, SettingOutlined, ShrinkOutlined,
...@@ -213,6 +213,12 @@ export const BtnRoute: { [c:string]:CircleButtonProps[] } = { ...@@ -213,6 +213,12 @@ export const BtnRoute: { [c:string]:CircleButtonProps[] } = {
} }
], ],
'menu.datastudio.project':[ 'menu.datastudio.project':[
{
icon: <PlusCircleOutlined />,
title: l('right.menu.createRoot'),
key: 'right.menu.createRoot',
onClick: ()=>{}
},
{ {
icon: <ArrowsAltOutlined />, icon: <ArrowsAltOutlined />,
title: l('button.expand-all'), title: l('button.expand-all'),
......
...@@ -113,13 +113,15 @@ export const handleAddOrUpdate = async (url: string, params: any, afterCallBack? ...@@ -113,13 +113,15 @@ export const handleAddOrUpdate = async (url: string, params: any, afterCallBack?
* delete by id * delete by id
* @param url * @param url
* @param id * @param id
* @param afterCallBack
*/ */
export const handleRemoveById = async (url: string, id: number) => { export const handleRemoveById = async (url: string, id: number, afterCallBack?: ()=>void) => {
await LoadingMessageAsync(l('app.request.delete')); await LoadingMessageAsync(l('app.request.delete'));
try { try {
const {code, msg} = await removeById(url, {id}); const {code, msg} = await removeById(url, {id});
if (code === RESPONSE_CODE.SUCCESS) { if (code === RESPONSE_CODE.SUCCESS) {
await SuccessMessage(msg); await SuccessMessage(msg);
afterCallBack && afterCallBack();
} else { } else {
await WarningMessage(msg); await WarningMessage(msg);
} }
...@@ -170,12 +172,13 @@ export const updateEnabled = async (url: string, params: any) => { ...@@ -170,12 +172,13 @@ export const updateEnabled = async (url: string, params: any) => {
export const handleOption = async (url: string, title: string, param: any) => { export const handleOption = async (url: string, title: string, param: any, afterCallBack?: ()=>void) => {
await LoadingMessageAsync(l('app.request.running') + title); await LoadingMessageAsync(l('app.request.running') + title);
try { try {
const result = await postAll(url, param); const result = await postAll(url, param);
if (result.code === RESPONSE_CODE.SUCCESS) { if (result.code === RESPONSE_CODE.SUCCESS) {
SuccessMessage(result.msg); SuccessMessage(result.msg);
afterCallBack && afterCallBack();
return result; return result;
} else { } else {
WarningMessage(result.msg); WarningMessage(result.msg);
...@@ -266,12 +269,13 @@ export const queryDataByParams = async (url: string, params?: any) => { ...@@ -266,12 +269,13 @@ export const queryDataByParams = async (url: string, params?: any) => {
}; };
export const handlePutDataByParams = async (url: string, title: string, params: any) => { export const handlePutDataByParams = async (url: string, title: string, params: any,afterCallBack?: ()=> void) => {
await LoadingMessageAsync(l('app.request.running') + title); await LoadingMessageAsync(l('app.request.running') + title);
try { try {
const {code, msg} = await putData(url, {...params}); const {code, msg} = await putData(url, {...params});
if (code === RESPONSE_CODE.SUCCESS) { if (code === RESPONSE_CODE.SUCCESS) {
await SuccessMessage(msg); await SuccessMessage(msg);
afterCallBack && afterCallBack();
return true; return true;
} else { } else {
await WarningMessage(msg); await WarningMessage(msg);
......
...@@ -179,6 +179,7 @@ export const API_CONSTANTS = { ...@@ -179,6 +179,7 @@ export const API_CONSTANTS = {
UDF_TEMPLATE_DELETE: "/api/udf/template/delete", UDF_TEMPLATE_DELETE: "/api/udf/template/delete",
// UDF template enable or disable // UDF template enable or disable
UDF_TEMPLATE_ENABLE: "/api/udf/template/enable", UDF_TEMPLATE_ENABLE: "/api/udf/template/enable",
UDF_TEMPLATE_TREE: '/api/udf/template/tree',
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* *
*/ */
export type Catalogue = { export type Catalogue = {
id: number; id: number;
name: string; name: string;
...@@ -27,4 +28,55 @@ export type Catalogue = { ...@@ -27,4 +28,55 @@ export type Catalogue = {
isLeaf: boolean; isLeaf: boolean;
createTime: Date; createTime: Date;
updateTime: Date; updateTime: Date;
} children: Catalogue[];
\ No newline at end of file configJson: Object<string, object>;
task: Task;
};
export type Task = {
id: number;
name: string;
dialect: string;
tenantId: number;
type: string;
checkPoint: number;
savePointStrategy: number;
savePointPath: string;
parallelism: number;
fragment: boolean;
statementSet: boolean;
batchModel: boolean;
clusterId: number;
clusterConfigurationId: number;
databaseId: number;
jarId: number;
envId: number;
alertGroupId: number;
note: string;
step: number;
jobInstanceId: number;
versionId: number;
statement: string;
clusterName: string;
savePoints: SavePoint[];
configJson: Object<string, object>;
path: string;
jarName: string;
clusterConfigurationName: string;
databaseName: string;
envName: string;
alertGroupName: string;
createTime: Date;
updateTime: Date;
};
export type SavePoint = {
id: number,
taskId: number,
name: string,
type: string,
path: string,
createTime: Date,
};
\ No newline at end of file
/*
* 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.
*/
const localStorageMock = {
getItem: jest.fn(),
setItem: jest.fn(),
removeItem: jest.fn(),
clear: jest.fn(),
};
global.localStorage = localStorageMock;
Object.defineProperty(URL, 'createObjectURL', {
writable: true,
value: jest.fn(),
});
class Worker {
constructor(stringUrl) {
this.url = stringUrl;
this.onmessage = () => {};
}
postMessage(msg) {
this.onmessage(msg);
}
}
window.Worker = Worker;
/* eslint-disable global-require */
if (typeof window !== 'undefined') {
// ref: https://github.com/ant-design/ant-design/issues/18774
if (!window.matchMedia) {
Object.defineProperty(global.window, 'matchMedia', {
writable: true,
configurable: true,
value: jest.fn(() => ({
matches: false,
addListener: jest.fn(),
removeListener: jest.fn(),
})),
});
}
if (!window.matchMedia) {
Object.defineProperty(global.window, 'matchMedia', {
writable: true,
configurable: true,
value: jest.fn((query) => ({
matches: query.includes('max-width'),
addListener: jest.fn(),
removeListener: jest.fn(),
})),
});
}
}
const errorLog = console.error;
Object.defineProperty(global.window.console, 'error', {
writable: true,
configurable: true,
value: (...rest) => {
const logStr = rest.join('');
if (logStr.includes('Warning: An update to %s inside a test was not wrapped in act(...)')) {
return;
}
errorLog(...rest);
},
});
This diff is collapsed.
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.
*/
This diff is collapsed.
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