Unverified Commit 889307be authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Refactor] refactor configjson (#2261)

* Spotless Apply * refactor-configjson * refactor-configjson * Spotless Apply * refactor-configjson * refactor-configjson * Spotless Apply * refactor-configjson * added desc * modify package.json * modify .gitignore * refactor-configjson * modify some code * modify some code * modify package.json * modify some code * modify some code --------- Co-authored-by: 's avatarzhu-mingye <zhu-mingye@users.noreply.github.com>
parent 5d04ae42
......@@ -35,11 +35,9 @@ target/*
*/target/*
*/*/target/*
*/*/*/target/*
dlink-web/node_modules/*
dlink-web/node/*
dlink-web/dist/*
dlink-web/.mfsu-production
dlink-web/*
# Dinky Web gitignore
dinky-web/node_modules/*
dinky-web/node/*
dinky-web/dist/*
......
......@@ -69,12 +69,6 @@ public class Knife4jConfig {
@Bean(value = "defaultApi2")
public Docket defaultApi2() {
// OpenApiExtendSetting openApiExtendSetting = new OpenApiExtendSetting();
// openApiExtendSetting.setEnableFooter(false);
// openApiExtendSetting.setEnableFooterCustom(true);
// openApiExtendSetting.setFooterCustomContent("Apache License 2.0 | Copyright © 2023 Dinky, Inc.
// DataLinkDC. [鲁ICP备20001630号-2](https://beian.miit.gov.cn)");
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName(dinkyVersion)
......
......@@ -129,7 +129,7 @@ public class CatalogueController {
* @param catalogueTaskDTO {@link CatalogueTaskDTO}
* @return {@link Result}< {@link Catalogue}>}
*/
@PutMapping("/createTask")
@PutMapping("/saveOrUpdateCatalogueAndTask")
@Log(title = "Create Catalogue And Task", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("Create Catalogue And Task")
public Result<Catalogue> createTask(@RequestBody CatalogueTaskDTO catalogueTaskDTO) {
......
......@@ -73,7 +73,7 @@ public class TaskController {
@PutMapping
@ApiOperation("Insert Or Update Task")
@Log(title = "Insert Or Update Task", businessType = BusinessType.INSERT_OR_UPDATE)
public Result<Void> saveOrUpdateTask(@RequestBody Task task) throws Exception {
public Result<Void> saveOrUpdateTask(@RequestBody Task task) {
if (taskService.saveOrUpdateTask(task)) {
return Result.succeed(Status.SAVE_SUCCESS);
} else {
......
......@@ -19,8 +19,7 @@
package org.dinky.data.dto;
import java.util.HashMap;
import java.util.Map;
import org.dinky.data.model.TaskExtConfig;
import lombok.Getter;
import lombok.Setter;
......@@ -42,5 +41,6 @@ public class CatalogueTaskDTO {
private String name;
private String type;
private String dialect;
private Map<String, String> config = new HashMap<>();
private String note;
private TaskExtConfig configJson;
}
......@@ -19,13 +19,11 @@
package org.dinky.data.dto;
import org.dinky.data.model.TaskExtConfig;
import org.dinky.job.JobConfig;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
......@@ -62,10 +60,12 @@ public class StudioExecuteDTO extends AbstractStatementDTO {
private Integer parallelism;
private Integer savePointStrategy;
private String savePointPath;
private Map<String, String> configJson = new HashMap<>();
private static final ObjectMapper mapper = new ObjectMapper();
private TaskExtConfig configJson;
public JobConfig getJobConfig() {
Map<String, String> parsedConfig = this.configJson.getCustomConfigMaps();
return new JobConfig(
type,
useResult,
......@@ -87,7 +87,7 @@ public class StudioExecuteDTO extends AbstractStatementDTO {
savePointStrategy,
savePointPath,
getVariables(),
configJson);
parsedConfig);
}
public Integer getTaskId() {
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.model;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ConfigItem implements Serializable {
private static final long serialVersionUID = 1L;
private String key;
private String value;
}
......@@ -21,10 +21,12 @@ package org.dinky.data.model;
import org.dinky.assertion.Asserts;
import org.dinky.config.Dialect;
import org.dinky.data.typehandler.ListTypeHandler;
import org.dinky.data.typehandler.TaskExtConfigTypeHandler;
import org.dinky.job.JobConfig;
import org.dinky.mybatis.model.SuperEntity;
import org.apache.ibatis.type.JdbcType;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -99,8 +101,8 @@ public class Task extends SuperEntity<Task> {
@TableField(exist = false)
private List<Savepoints> savePoints;
@TableField(typeHandler = ListTypeHandler.class)
private List<Map<String, String>> configJson;
@TableField(typeHandler = TaskExtConfigTypeHandler.class, jdbcType = JdbcType.VARCHAR)
private TaskExtConfig configJson;
@TableField(exist = false)
private String path;
......@@ -122,9 +124,11 @@ public class Task extends SuperEntity<Task> {
public JobConfig buildSubmitConfig() {
boolean useRemote = clusterId != null && clusterId != 0;
Map<String, String> map = configJson.stream()
.filter(Asserts::isNotNull)
.collect(Collectors.toMap(item -> item.get("name"), item -> item.get("value"), (a, b) -> b));
List<ConfigItem> extCustomConfig = this.configJson.getCustomConfig();
Map<String, String> parsedConfig =
extCustomConfig.stream().collect(Collectors.toMap(ConfigItem::getKey, ConfigItem::getValue));
int jid = Asserts.isNull(jarId) ? 0 : jarId;
boolean fg = Asserts.isNotNull(fragment) && fragment;
......@@ -147,10 +151,28 @@ public class Task extends SuperEntity<Task> {
parallelism,
savePointStrategy,
savePointPath,
map,
parsedConfig,
isJarTask());
}
/**
* 根据key获取自定义配置的值
* @param key
* @return String
*/
public String findCustomConfigKeyOfValue(String key) {
return this.configJson.containsKey(key) ? this.configJson.getCustomConfigValue(key) : null;
}
/**
* 判断是否有自定义配置
* @param key
* @return
*/
public boolean hasCustomConfigKey(String key) {
return this.configJson.containsKey(key);
}
public JsonNode parseJsonNode(ObjectMapper mapper) {
ObjectNode jsonNode = mapper.createObjectNode();
jsonNode.put("name", this.getName());
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.model;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaskExtConfig implements Serializable {
private static final long serialVersionUID = 1L;
private TaskUdfConfig udfConfig;
private List<ConfigItem> customConfig;
// 获取自定义配置的某个key的值
public String getCustomConfigValue(String key) {
return customConfig.stream()
.filter(item -> item.getKey().equals(key))
.findFirst()
.orElseGet(() -> new ConfigItem(key, ""))
.getValue();
}
// 获取自定义配置的所有key
public List<String> getCustomConfigKeys() {
return customConfig.stream().map(ConfigItem::getKey).collect(Collectors.toList());
}
// 获取自定义配置的所有key-value
public Map<String, String> getCustomConfigMaps() {
return customConfig.stream().collect(Collectors.toMap(ConfigItem::getKey, ConfigItem::getValue));
}
// 是否包含某个key
public boolean containsKey(String key) {
return customConfig.stream().anyMatch(item -> item.getKey().equals(key));
}
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.model;
import java.io.Serializable;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaskUdfConfig implements Serializable {
private static final long serialVersionUID = 1L;
private Integer templateId;
private List<Object> selectKeys;
private String className;
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.typehandler;
import org.dinky.data.model.TaskExtConfig;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import cn.hutool.json.JSONUtil;
@MappedTypes({TaskExtConfig.class})
@MappedJdbcTypes({JdbcType.VARCHAR})
public class TaskExtConfigTypeHandler extends AbstractJsonTypeHandler<TaskExtConfig> {
private static final Logger log = LoggerFactory.getLogger(FastjsonTypeHandler.class);
protected TaskExtConfig parse(String json) {
return JSONUtil.toBean(json, TaskExtConfig.class);
}
@Override
protected String toJson(TaskExtConfig obj) {
return JSONUtil.toJsonStr(obj);
}
}
......@@ -46,7 +46,6 @@ import java.io.File;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
......@@ -106,11 +105,11 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
List<Catalogue> returnList = new ArrayList<>();
for (Iterator<Catalogue> iterator = catalogueList.iterator(); iterator.hasNext(); ) {
Catalogue menu = iterator.next();
// get all child menu of parent menu id , the -1 is root menu
if (menu.getParentId() == 0) {
recursionBuildCatalogueAndChildren(catalogueList, menu);
returnList.add(menu);
Catalogue catalogue = iterator.next();
// get all child catalogue of parent catalogue id , the 0 is root catalogue
if (catalogue.getParentId() == 0) {
recursionBuildCatalogueAndChildren(catalogueList, catalogue);
returnList.add(catalogue);
}
}
if (returnList.isEmpty()) {
......@@ -131,14 +130,15 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
for (Catalogue tChild : childList) {
if (hasChild(list, tChild)) {
// Determine whether there are child nodes
for (Catalogue n : childList) {
if (n.getIsLeaf()) {
Task task = taskService.getById(n.getTaskId());
if (task != null) {
n.setTask(task);
}
for (Catalogue children : childList) {
recursionBuildCatalogueAndChildren(list, children);
}
} else {
if (tChild.getIsLeaf() || null != tChild.getTaskId()) {
Task task = taskService.getById(tChild.getTaskId());
if (task != null) {
tChild.setTask(task);
}
recursionBuildCatalogueAndChildren(list, n);
}
}
}
......@@ -147,11 +147,11 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
/**
* Determine whether there are child nodes
* @param list
* @param menu
* @param catalogue
* @return
*/
private boolean hasChild(List<Catalogue> list, Catalogue menu) {
return getChildList(list, menu).size() > 0;
private boolean hasChild(List<Catalogue> list, Catalogue catalogue) {
return getChildList(list, catalogue).size() > 0;
}
/**
......@@ -191,7 +191,8 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
}
task.setName(catalogueTaskDTO.getName());
task.setDialect(catalogueTaskDTO.getType());
task.setConfigJson(Collections.singletonList(catalogueTaskDTO.getConfig()));
task.setConfigJson(catalogueTaskDTO.getConfigJson());
task.setNote(catalogueTaskDTO.getNote());
taskService.saveOrUpdateTask(task);
catalogue.setTenantId(catalogueTaskDTO.getTenantId());
......@@ -413,41 +414,44 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
}
// 获取 catalogue 表中的作业
Catalogue catalogue = getById(catalogueId);
// 如果是文件夹 , 且下边没有子文件夹 , 则删除
if (catalogue.getIsLeaf()) {
return removeById(catalogueId)
? Result.succeed(Status.DELETE_SUCCESS)
: Result.failed(Status.DELETE_FAILED);
// 判断书否为空 且 是否为叶子节点
if (BeanUtil.isNotEmpty(catalogue) && catalogue.getIsLeaf()) {
// doing: cascade delete jobInstance && jobHistory && history && statement
// 获取 task 表中的作业
Task task = taskService.getById(catalogue.getTaskId());
// 获取 statement 表中的作业
Statement statement = statementService.getById(catalogue.getTaskId());
// 获取 job instance 表中的作业
List<JobInstance> jobInstanceList = jobInstanceService.list(
new LambdaQueryWrapper<JobInstance>().eq(JobInstance::getTaskId, catalogue.getTaskId()));
// 获取 history 表中的作业
List<History> historyList = historyService.list(
new LambdaQueryWrapper<History>().eq(History::getTaskId, catalogue.getTaskId()));
historyList.forEach(history -> {
// 查询 job history 表中的作业 通过 id 关联查询
JobHistory historyServiceById = jobHistoryService.getById(history.getId());
// 删除 job history 表中的作业
jobHistoryService.removeById(historyServiceById.getId());
// 删除 history 表中的作业
historyService.removeById(history.getId());
});
jobInstanceList.forEach(jobInstance -> {
// 删除 job instance 表中的作业
jobInstanceService.removeById(jobInstance.getId());
});
// 删除 task 表中的作业
if (task != null) {
taskService.removeById(task.getId());
}
// 删除 statement 表中的作业
if (statement != null) {
statementService.removeById(statement.getId());
}
}
// doing: cascade delete jobInstance && jobHistory && history && statement
// 获取 task 表中的作业
Task task = taskService.getById(catalogue.getTaskId());
// 获取 statement 表中的作业
Statement statement = statementService.getById(catalogue.getTaskId());
// 获取 job instance 表中的作业
List<JobInstance> jobInstanceList = jobInstanceService.list(
new LambdaQueryWrapper<JobInstance>().eq(JobInstance::getTaskId, catalogue.getTaskId()));
// 获取 history 表中的作业
List<History> historyList =
historyService.list(new LambdaQueryWrapper<History>().eq(History::getTaskId, catalogue.getTaskId()));
historyList.forEach(history -> {
// 查询 job history 表中的作业 通过 id 关联查询
JobHistory historyServiceById = jobHistoryService.getById(history.getId());
// 删除 job history 表中的作业
jobHistoryService.removeById(historyServiceById.getId());
// 删除 history 表中的作业
historyService.removeById(history.getId());
});
jobInstanceList.forEach(jobInstance -> {
// 删除 job instance 表中的作业
jobInstanceService.removeById(jobInstance.getId());
});
// 删除 task 表中的作业
taskService.removeById(task.getId());
// 删除 statement 表中的作业
statementService.removeById(statement.getId());
removeById(catalogueId);
return Result.succeed(Status.DELETE_SUCCESS);
// 如果是文件夹 , 且下边没有子文件夹 , 则删除
return Result.succeed(removeById(catalogueId) ? Status.DELETE_SUCCESS : Status.DELETE_FAILED);
}
/**
......
......@@ -62,6 +62,7 @@ import org.dinky.data.model.Savepoints;
import org.dinky.data.model.Statement;
import org.dinky.data.model.SystemConfiguration;
import org.dinky.data.model.Task;
import org.dinky.data.model.TaskExtConfig;
import org.dinky.data.model.TaskVersion;
import org.dinky.data.model.UDFTemplate;
import org.dinky.data.result.Result;
......@@ -153,8 +154,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil;
......@@ -448,14 +447,20 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Override
public boolean saveOrUpdateTask(Task task) {
if (Dialect.isUDF(task.getDialect())) {
if (CollUtil.isNotEmpty(task.getConfigJson())
TaskExtConfig taskConfigJson = task.getConfigJson();
if (BeanUtil.isNotEmpty(task.getConfigJson())
&& Asserts.isNullString(task.getStatement())
&& Convert.toInt(task.getConfigJson().get(0).get("templateId"), 0) != 0) {
Map<String, String> config = task.getConfigJson().get(0);
UDFTemplate template = udfTemplateService.getById(config.get("templateId"));
&& BeanUtil.isNotEmpty(taskConfigJson.getUdfConfig())) {
UDFTemplate template =
udfTemplateService.getById(taskConfigJson.getUdfConfig().getTemplateId());
if (template != null) {
String code = UDFUtil.templateParse(
task.getDialect(), template.getTemplateCode(), config.get("className"));
task.getDialect(),
template.getTemplateCode(),
taskConfigJson.getUdfConfig().getClassName());
task.setStatement(code);
}
}
......
......@@ -30,7 +30,7 @@ public class UDFUtils extends UDFUtil {
public static UDF taskToUDF(Task task) {
return UDF.builder()
.className(task.getSavePointPath())
.className(task.getConfigJson().getUdfConfig().getClassName())
.code(task.getStatement())
.functionLanguage(FunctionLanguage.valueOf(task.getDialect().toUpperCase()))
.build();
......
......@@ -152,21 +152,8 @@ sa-token:
#################################################################################################################
knife4j:
enable: true
# openapi:
# title: Dinky REST APIS
# description: Dinky REST APIS
# concat: Dinky
# url: http://www.dlink.top/
# version: v4.0
# license: Apache 2.0
# license-url: https://www.apache.org/licenses/LICENSE-2.0
# group:
# Api:
# group-name: Dinky Api
# api-rule: package
# api-rule-resources:
# - org.dinky.controller
Dinky:
dinky:
version: @project.version@
sms:
is-print: false
......
{
"name": "Dinky",
"version": "6.0.0",
"private": true,
"name": "dinky-web",
"version": "1.0.0",
"description": "Dinky is an out of the box one-stop real-time computing platform dedicated to the construction and practice of Unified Batch & Streaming and Unified Data Lake & Data Warehouse. Based on Apache Flink, Dinky provides the ability to connect many big data frameworks including OLAP and Data Lake.",
"license": "Apache License 2.0",
"scripts": {
"analyze": "cross-env ANALYZE=1 max build",
"build": "max build",
......
......@@ -17,11 +17,11 @@
*/
import { PopconfirmDeleteBtn } from '@/components/CallBackButton/PopconfirmDeleteBtn';
import { TaskVersionListItem } from '@/types/Studio/data';
import { l } from '@/utils/intl';
import { DeliveredProcedureOutlined } from '@ant-design/icons';
import { List, Skeleton, Space, Tag, Tooltip } from 'antd';
import { ListItemTypeProps } from 'antd/es/list/Item';
import {TaskVersionListItem} from "@/types/Studio/data";
export interface VersionListProps {
data: TaskVersionListItem[];
......
......@@ -1166,6 +1166,8 @@ export default {
'catalog.name': 'Job Name',
'catalog.name.placeholder': 'Please enter the job name',
'catalog.note': 'Job Description',
'catalog.note.placeholder': 'Please enter the job description',
'catalog.name.tip':
'This name can be used as the JobName of the FlinkSql task (pipeline.name configuration item)',
'catalog.type': 'Job Type',
......
......@@ -1129,6 +1129,8 @@ export default {
'catalog.name': '作业名称',
'catalog.name.placeholder': '请输入作业名称',
'catalog.note': '作业描述',
'catalog.note.placeholder': '请输入作业描述',
'catalog.name.tip': '此名称可作为 FlinkSql 任务的 JobName ([配置项: pipeline.name])',
'catalog.type': '作业类型',
'catalog.type.placeholder': '请选择作业类型',
......
......@@ -24,7 +24,7 @@ import { queryDataByParams } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints';
import { Catalogue } from '@/types/Studio/data';
import { l } from '@/utils/intl';
import { ModalForm, ProFormSelect, ProFormText } from '@ant-design/pro-components';
import { ModalForm, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
import { ProFormCascader } from '@ant-design/pro-form/lib';
import { Form } from 'antd';
import React, { useEffect } from 'react';
......@@ -55,8 +55,9 @@ const JobModal: React.FC<JobModalProps> = (props) => {
* when modalVisible or values changed, set form values
*/
useEffect(() => {
const newValues = { ...values, configJson: values.task?.configJson };
if (modalVisible) form.resetFields();
form.setFieldsValue(values);
form.setFieldsValue(newValues);
}, [open, values, form]);
const queryUdfTemplate = async () => {
......@@ -69,7 +70,6 @@ const JobModal: React.FC<JobModalProps> = (props) => {
};
useEffect(() => {
form.setFieldValue('configJson', {});
isUDF(jobType) && queryUdfTemplate();
}, [jobType, form]);
......@@ -96,9 +96,8 @@ const JobModal: React.FC<JobModalProps> = (props) => {
const submitForm = async (formData: Catalogue) => {
await form.validateFields();
if (isUDF(formData.type) && formData.configJson) {
// todo: 有个 bug 接口入参载荷正常, 但是接口获取的 configJson 提示无法
const { templateId } = formData.configJson;
formData.configJson.templateId = (templateId as any[]).sort((a, b) => a - b).pop();
const { selectKeys } = formData.configJson.udfConfig;
formData.configJson.udfConfig.templateId = selectKeys[selectKeys.length - 1];
}
onSubmit({ ...values, ...formData } as Catalogue);
};
......@@ -122,10 +121,16 @@ const JobModal: React.FC<JobModalProps> = (props) => {
placeholder={l('catalog.name.placeholder')}
rules={[{ required: true, message: l('catalog.name.placeholder') }]}
/>
<ProFormTextArea
name='note'
label={l('catalog.note')}
placeholder={l('catalog.note.placeholder')}
rules={[{ required: true, message: l('catalog.note.placeholder') }]}
/>
{isUDF(jobType) && (
<>
<ProFormCascader
name={['configJson', 'templateId']}
name={['configJson', 'udfConfig', 'selectKeys']}
label={l('catalog.udf.templateId')}
shouldUpdate={(prevValues, curValues) => prevValues.type !== curValues.type}
placeholder={l('catalog.udf.templateId.placeholder')}
......@@ -142,7 +147,7 @@ const JobModal: React.FC<JobModalProps> = (props) => {
/>
<ProFormText
name={['configJson', 'className']}
name={['configJson', 'udfConfig', 'className']}
label={l('catalog.udf.className')}
placeholder={l('catalog.udf.className.placeholder')}
rules={[
......
......@@ -194,9 +194,13 @@ const Project: React.FC = (props: connect) => {
: modalAllVisible.value.parentId
};
if (rightActiveKey === 'createTask') {
options.url = API_CONSTANTS.CREATE_TASK_URL;
options.parentId = modalAllVisible.isCreateTask && modalAllVisible.value.id;
if (rightActiveKey === 'createTask' || rightActiveKey === 'edit') {
options.url = API_CONSTANTS.SAVE_OR_UPDATE_TASK_URL;
options.parentId = modalAllVisible.isCreateTask
? modalAllVisible.value.id
: modalAllVisible.isEdit
? modalAllVisible.value.parentId
: options.parentId;
} else {
options.url = API_CONSTANTS.SAVE_OR_UPDATE_CATALOGUE_URL;
}
......@@ -217,12 +221,12 @@ const Project: React.FC = (props: connect) => {
isCreateTask: false,
isCut: false
}));
dispatch({ type: STUDIO_MODEL_ASYNC.queryProject });
if (modalAllVisible.isRename) {
// todo: 如果是重命名/修改(修改了名字), 则需要 更新 tab 的 label
}
}
);
dispatch({ type: STUDIO_MODEL_ASYNC.queryProject });
};
/**
......
......@@ -47,6 +47,7 @@ import {
import { Badge, Space, Typography } from 'antd';
import { useForm } from 'antd/es/form/Form';
import { debounce } from 'lodash';
import { useEffect } from 'react';
import { connect } from 'umi';
const { Text } = Typography;
......@@ -73,7 +74,10 @@ const JobConfig = (props: any) => {
}
};
const [form] = useForm();
form.setFieldsValue(current);
useEffect(() => {
form.setFieldsValue(current);
}, [current]);
const onValuesChange = (change: { [key in string]: string }, all: any) => {
const pane = getCurrentTab(panes, activeKey);
......@@ -128,15 +132,15 @@ const JobConfig = (props: any) => {
<>
{currentSession.session ? (
currentSession.sessionConfig?.clusterId ? (
<>
<Space>
<Badge status='success' />
<Text type='success'>{currentSession.sessionConfig.clusterName}</Text>
</>
</Space>
) : (
<>
<Space>
<Badge status='error' />
<Text type='danger'>{l('pages.devops.jobinfo.localenv')}</Text>
</>
</Space>
)
) : (
<>
......@@ -180,6 +184,7 @@ const JobConfig = (props: any) => {
tooltip={l('pages.datastudio.label.jobConfig.flinksql.env.tip1')}
options={buildEnvOptions(env)}
showSearch
initialValue={0}
/>
<ProFormGroup>
......@@ -229,6 +234,7 @@ const JobConfig = (props: any) => {
name='savePointStrategy'
tooltip={l('pages.datastudio.label.jobConfig.savePointStrategy.tip')}
options={SAVE_POINT_TYPE}
initialValue={0}
/>
{current.savePointStrategy === 3 && (
......@@ -248,11 +254,10 @@ const JobConfig = (props: any) => {
options={buildAlertGroupOptions(group)}
/>
{/*todo 这里需要优化,有有异常抛出*/}
<ProFormList
label={l('pages.datastudio.label.jobConfig.other')}
tooltip={l('pages.datastudio.label.jobConfig.other.tip')}
name={'configJson'}
name={['configJson', 'customConfig']}
copyIconProps={false}
creatorButtonProps={{
style: { width: '100%' },
......@@ -265,6 +270,13 @@ const JobConfig = (props: any) => {
name='key'
placeholder={l('pages.datastudio.label.jobConfig.addConfig.params')}
/>
{/*todo: 通过接口拿到预设配置渲染下拉框 */}
{/*<ProFormSelect*/}
{/* name='key'*/}
{/* mode={'single'} allowClear={false}*/}
{/* placeholder={l('pages.datastudio.label.jobConfig.addConfig.params')}*/}
{/* options={[{ label: 'String', value: 'String' }, { label: 'Int', value: 'Int' }]}*/}
{/*/>*/}
<ProFormText
name='value'
placeholder={l('pages.datastudio.label.jobConfig.addConfig.value')}
......
......@@ -17,80 +17,51 @@
*
*/
import {
getCurrentData,
getCurrentTab,
isDataStudioTabsItemType
} from '@/pages/DataStudio/function';
import { StateType, STUDIO_MODEL } from '@/pages/DataStudio/model';
import { getCurrentData } from '@/pages/DataStudio/function';
import { StateType, TaskDataType } from '@/pages/DataStudio/model';
import { l } from '@/utils/intl';
import { Col, Descriptions, Form, Row } from 'antd';
import { useForm } from 'antd/es/form/Form';
import TextArea from 'antd/es/input/TextArea';
import { Descriptions } from 'antd';
import Paragraph from 'antd/es/typography/Paragraph';
import { useEffect, useState } from 'react';
import { connect } from 'umi';
const JobInfo = (props: any) => {
const {
dispatch,
tabs: { panes, activeKey }
} = props;
const current = getCurrentData(panes, activeKey);
const [form] = useForm();
form.setFieldsValue(current);
const onValuesChange = (change: any, all: any) => {
const pane = getCurrentTab(panes, activeKey);
if (!isDataStudioTabsItemType(pane)) {
return;
}
Object.keys(change).forEach((key) => {
pane.params.taskData[key] = all[key];
});
const [currentInfo, setCurrentInfo] = useState<Partial<TaskDataType>>(
getCurrentData(panes, activeKey) ?? {}
);
dispatch({
type: STUDIO_MODEL.saveTabs,
payload: { ...props.tabs }
});
};
useEffect(() => {
setCurrentInfo({ ...currentInfo, ...getCurrentData(panes, activeKey) });
}, [activeKey, panes]);
return (
<div style={{ paddingInline: 8 }}>
<Descriptions bordered size='small' column={1}>
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.id')}>
<Paragraph copyable>{current?.id}</Paragraph>
<Paragraph copyable>{currentInfo?.id}</Paragraph>
</Descriptions.Item>
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.name')}>
{current?.name}
{currentInfo?.name}
</Descriptions.Item>
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.dialect')}>
{current?.dialect}
{currentInfo?.dialect}
</Descriptions.Item>
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.versionId')}>
{current?.versionId}
{currentInfo?.versionId}
</Descriptions.Item>
<Descriptions.Item label={l('global.table.createTime')}>
{current?.createTime}
{currentInfo?.createTime}
</Descriptions.Item>
<Descriptions.Item label={l('global.table.updateTime')}>
{current?.updateTime}
{currentInfo?.updateTime}
</Descriptions.Item>
<Descriptions.Item label={l('global.table.note')}>{currentInfo?.note}</Descriptions.Item>
</Descriptions>
<Form
layout='vertical'
form={form}
// className={styles.form_setting}
onValuesChange={onValuesChange}
>
<Row>
<Col span={24}>
<Form.Item label={l('global.table.note')} name='note'>
<TextArea rows={4} maxLength={255} />
</Form.Item>
</Col>
</Row>
</Form>
</div>
);
};
......
......@@ -19,8 +19,8 @@ import { showAlertInstance } from '@/pages/RegCenter/Alert/AlertGroup/service';
import { Alert } from '@/types/RegCenter/data.d';
import { Reducer } from 'umi';
import { createModelTypes } from '@/utils/modelUtils';
import { Effect } from '@@/plugin-dva/types';
import {createModelTypes} from "@/utils/modelUtils";
export type AlertStateType = {
instance: Alert.AlertInstance[];
......
......@@ -27,6 +27,7 @@ import { DataAction } from '@/components/StyledComponents';
import { imgStyle } from '@/pages/Home/constants';
import ConfigurationModal from '@/pages/RegCenter/Cluster/Configuration/components/ConfigurationModal';
import { CLUSTER_CONFIG_TYPE } from '@/pages/RegCenter/Cluster/Configuration/components/contants';
import { queryList } from '@/services/api';
import {
handleAddOrUpdate,
handleOption,
......@@ -42,10 +43,9 @@ import { ClusterConfigState } from '@/types/RegCenter/state.d';
import { l } from '@/utils/intl';
import { CheckCircleOutlined, ExclamationCircleOutlined, HeartTwoTone } from '@ant-design/icons';
import { ActionType, ProList } from '@ant-design/pro-components';
import { useRequest } from '@umijs/max';
import { Button, Descriptions, Modal, Space, Tag, Tooltip } from 'antd';
import DescriptionsItem from 'antd/es/descriptions/Item';
import { useRef, useState } from 'react';
import { useEffect, useRef, useState } from 'react';
export default () => {
/**
......@@ -56,11 +56,21 @@ export default () => {
const actionRef = useRef<ActionType>();
const { data, run } = useRequest({
url: API_CONSTANTS.CLUSTER_CONFIGURATION,
method: 'POST',
data: {}
});
// const { data, run } = useRequest({
// url: API_CONSTANTS.CLUSTER_CONFIGURATION,
// method: 'POST',
// data: {}
// });
const queryClusterConfigList = async () => {
queryList(API_CONSTANTS.CLUSTER_CONFIGURATION).then((res) =>
setClusterConfigState((prevState) => ({ ...prevState, configList: res.data }))
);
};
useEffect(() => {
queryClusterConfigList();
}, []);
/**
* execute and callback function
......@@ -70,7 +80,7 @@ export default () => {
const executeAndCallbackRefresh = async (callback: () => void) => {
setClusterConfigState((prevState) => ({ ...prevState, loading: true }));
await callback();
await run();
await queryClusterConfigList();
setClusterConfigState((prevState) => ({ ...prevState, loading: false }));
actionRef.current?.reload?.();
};
......@@ -225,13 +235,16 @@ export default () => {
/**
* render data list
*/
const renderData = data?.map((item: Cluster.Config) => ({
subTitle: renderDataSubTitle(item),
actions: <DataAction>{renderDataActionButton(item)}</DataAction>,
avatar: <ClusterConfigIcon style={imgStyle} />,
content: renderDataContent(item),
key: item.id
}));
const renderData = (list: Cluster.Config[]) =>
list.map((item: Cluster.Config) => {
return {
subTitle: renderDataSubTitle(item),
actions: <DataAction>{renderDataActionButton(item)}</DataAction>,
avatar: <ClusterConfigIcon style={imgStyle} />,
content: renderDataContent(item),
key: item.id
};
});
/**
* tool bar render
......@@ -255,7 +268,7 @@ export default () => {
actionRef={actionRef}
headerTitle={l('rc.cc.management')}
toolBarRender={toolBarRender}
dataSource={renderData}
dataSource={renderData(clusterConfigState.configList)}
/>
{/*added*/}
......
......@@ -24,7 +24,11 @@ import { DefaultOptionType } from 'rc-select/es/Select';
* Cluster config type
*/
export const CLUSTER_CONFIG_TYPE: DefaultOptionType[] = [
{ value: ClusterType.YARN, label: 'Flink On Yarn', key: ClusterType.YARN },
{
value: ClusterType.YARN,
label: 'Flink On Yarn',
key: ClusterType.YARN
},
{
value: ClusterType.KUBERNETES_NATIVE,
label: 'Kubernetes Native',
......
......@@ -248,7 +248,7 @@ export enum API_CONSTANTS {
// catalog
DELETE_CATALOGUE_BY_ID_URL = '/api/catalogue/deleteCatalogueById',
CREATE_TASK_URL = '/api/catalogue/createTask',
SAVE_OR_UPDATE_TASK_URL = '/api/catalogue/saveOrUpdateCatalogueAndTask',
SAVE_OR_UPDATE_CATALOGUE_URL = '/api/catalogue/saveOrUpdateCatalogue',
COPY_TASK_URL = '/api/catalogue/copyTask',
MOVE_CATALOGUE_URL = '/api/catalogue/moveCatalogue'
......
......@@ -37,8 +37,8 @@ import {
export const InitAlertGroupState: AlertGroupState = {
alertGroupList: [],
loading: false,
addedAlertGroupOpen: false,
editAlertGroupOpen: false,
addedOpen: false,
editOpen: false,
value: {}
};
......@@ -49,8 +49,8 @@ export const InitAlertGroupState: AlertGroupState = {
export const InitAlertInstanceState: AlertInstanceState = {
alertInstanceList: [],
loading: false,
addedAlertInstanceOpen: false,
editAlertInstanceOpen: false,
addedOpen: false,
editOpen: false,
value: {}
};
......@@ -60,9 +60,10 @@ export const InitAlertInstanceState: AlertInstanceState = {
*/
export const InitClusterConfigState: ClusterConfigState = {
loading: false,
addedClusterConfigOpen: false,
editClusterConfigOpen: false,
value: {}
addedOpen: false,
editOpen: false,
value: {},
configList: []
};
/**
......@@ -71,8 +72,8 @@ export const InitClusterConfigState: ClusterConfigState = {
*/
export const InitClusterInstanceState: ClusterInstanceState = {
loading: false,
addedClusterInstanceOpen: false,
editClusterInstanceOpen: false,
addedOpen: false,
editOpen: false,
value: {}
};
......@@ -82,8 +83,8 @@ export const InitClusterInstanceState: ClusterInstanceState = {
*/
export const InitDocumentState: DocumentState = {
loading: false,
addedDocumentOpen: false,
editDocumentOpen: false,
addedOpen: false,
editOpen: false,
value: {},
drawerOpen: false
};
......
......@@ -50,6 +50,7 @@ export interface AlertInstanceState extends BaseState {
*/
export interface ClusterConfigState extends BaseState {
value: Partial<Cluster.Config>;
configList: Cluster.Config[];
}
/**
......
......@@ -17,6 +17,8 @@
*
*/
import { List } from 'antd';
export type Catalogue = {
id: number;
name: string;
......@@ -28,10 +30,26 @@ export type Catalogue = {
createTime: Date;
updateTime: Date;
children: Catalogue[];
configJson: Object<string, object>;
configJson: TaskExtConfig;
task: Task;
};
export type TaskUdfConfig = {
templateId: number;
selectKeys: List<string | number>;
className: string;
};
export type ConfigItem = {
key: string;
value: string;
};
export type TaskExtConfig = {
udfConfig: TaskUdfConfig;
customConfig: List<Map<string, object>>;
};
export type Task = {
id: number;
name: string;
......@@ -58,7 +76,7 @@ export type Task = {
statement: string;
clusterName: string;
savePoints: SavePoint[];
configJson: Object<string, object>;
configJson: TaskExtConfig;
path: string;
jarName: string;
clusterConfigurationName: string;
......
......@@ -46,4 +46,3 @@ export const ErrorModelWithCode = (
/>
);
};
interface BaseModelType {
['reducers']: {};
['effects']: {};
['namespace']: string;
['reducers']: {};
['effects']: {};
['namespace']: string;
}
type MemberType<T extends BaseModelType, U> = U extends 'effects' ? T['effects'] : T['reducers'];
function getModelTypes<T extends BaseModelType>(
target: T,
type: 'effects' | 'reducers'
target: T,
type: 'effects' | 'reducers'
): { [K in keyof MemberType<T, typeof type>]: string } {
const reducers = Object.keys(target[type]).map((obj: string) => [
obj,
`${target.namespace}/${obj}`
]);
// @ts-ignore
return Object.fromEntries(new Map<keyof (typeof target)[type], string>(reducers));
const reducers = Object.keys(target[type]).map((obj: string) => [
obj,
`${target.namespace}/${obj}`
]);
// @ts-ignore
return Object.fromEntries(new Map<keyof (typeof target)[type], string>(reducers));
}
export const createModelTypes = <T extends BaseModelType>(
target: T
target: T
): [{ [K in keyof T['reducers']]: string }, { [K in keyof T['effects']]: string }] => {
return [getModelTypes(target, 'reducers'), getModelTypes(target, 'effects')];
return [getModelTypes(target, 'reducers'), getModelTypes(target, 'effects')];
};
......@@ -26,7 +26,7 @@
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Dinky :</name>
<name>Dinky : Real-time Computing Platform</name>
<modules>
<module>dinky-flink</module>
......
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