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/* ...@@ -35,11 +35,9 @@ target/*
*/target/* */target/*
*/*/target/* */*/target/*
*/*/*/target/* */*/*/target/*
dlink-web/node_modules/* dlink-web/*
dlink-web/node/*
dlink-web/dist/*
dlink-web/.mfsu-production
# Dinky Web gitignore
dinky-web/node_modules/* dinky-web/node_modules/*
dinky-web/node/* dinky-web/node/*
dinky-web/dist/* dinky-web/dist/*
......
...@@ -69,12 +69,6 @@ public class Knife4jConfig { ...@@ -69,12 +69,6 @@ public class Knife4jConfig {
@Bean(value = "defaultApi2") @Bean(value = "defaultApi2")
public Docket 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) return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo()) .apiInfo(apiInfo())
.groupName(dinkyVersion) .groupName(dinkyVersion)
......
...@@ -129,7 +129,7 @@ public class CatalogueController { ...@@ -129,7 +129,7 @@ public class CatalogueController {
* @param catalogueTaskDTO {@link CatalogueTaskDTO} * @param catalogueTaskDTO {@link CatalogueTaskDTO}
* @return {@link Result}< {@link Catalogue}>} * @return {@link Result}< {@link Catalogue}>}
*/ */
@PutMapping("/createTask") @PutMapping("/saveOrUpdateCatalogueAndTask")
@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")
public Result<Catalogue> createTask(@RequestBody CatalogueTaskDTO catalogueTaskDTO) { public Result<Catalogue> createTask(@RequestBody CatalogueTaskDTO catalogueTaskDTO) {
......
...@@ -73,7 +73,7 @@ public class TaskController { ...@@ -73,7 +73,7 @@ public class TaskController {
@PutMapping @PutMapping
@ApiOperation("Insert Or Update Task") @ApiOperation("Insert Or Update Task")
@Log(title = "Insert Or Update Task", businessType = BusinessType.INSERT_OR_UPDATE) @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)) { if (taskService.saveOrUpdateTask(task)) {
return Result.succeed(Status.SAVE_SUCCESS); return Result.succeed(Status.SAVE_SUCCESS);
} else { } else {
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
package org.dinky.data.dto; package org.dinky.data.dto;
import java.util.HashMap; import org.dinky.data.model.TaskExtConfig;
import java.util.Map;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -42,5 +41,6 @@ public class CatalogueTaskDTO { ...@@ -42,5 +41,6 @@ public class CatalogueTaskDTO {
private String name; private String name;
private String type; private String type;
private String dialect; private String dialect;
private Map<String, String> config = new HashMap<>(); private String note;
private TaskExtConfig configJson;
} }
...@@ -19,13 +19,11 @@ ...@@ -19,13 +19,11 @@
package org.dinky.data.dto; package org.dinky.data.dto;
import org.dinky.data.model.TaskExtConfig;
import org.dinky.job.JobConfig; import org.dinky.job.JobConfig;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -62,10 +60,12 @@ public class StudioExecuteDTO extends AbstractStatementDTO { ...@@ -62,10 +60,12 @@ public class StudioExecuteDTO extends AbstractStatementDTO {
private Integer parallelism; private Integer parallelism;
private Integer savePointStrategy; private Integer savePointStrategy;
private String savePointPath; private String savePointPath;
private Map<String, String> configJson = new HashMap<>(); private TaskExtConfig configJson;
private static final ObjectMapper mapper = new ObjectMapper();
public JobConfig getJobConfig() { public JobConfig getJobConfig() {
Map<String, String> parsedConfig = this.configJson.getCustomConfigMaps();
return new JobConfig( return new JobConfig(
type, type,
useResult, useResult,
...@@ -87,7 +87,7 @@ public class StudioExecuteDTO extends AbstractStatementDTO { ...@@ -87,7 +87,7 @@ public class StudioExecuteDTO extends AbstractStatementDTO {
savePointStrategy, savePointStrategy,
savePointPath, savePointPath,
getVariables(), getVariables(),
configJson); parsedConfig);
} }
public Integer getTaskId() { 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; ...@@ -21,10 +21,12 @@ package org.dinky.data.model;
import org.dinky.assertion.Asserts; import org.dinky.assertion.Asserts;
import org.dinky.config.Dialect; 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.job.JobConfig;
import org.dinky.mybatis.model.SuperEntity; import org.dinky.mybatis.model.SuperEntity;
import org.apache.ibatis.type.JdbcType;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -99,8 +101,8 @@ public class Task extends SuperEntity<Task> { ...@@ -99,8 +101,8 @@ public class Task extends SuperEntity<Task> {
@TableField(exist = false) @TableField(exist = false)
private List<Savepoints> savePoints; private List<Savepoints> savePoints;
@TableField(typeHandler = ListTypeHandler.class) @TableField(typeHandler = TaskExtConfigTypeHandler.class, jdbcType = JdbcType.VARCHAR)
private List<Map<String, String>> configJson; private TaskExtConfig configJson;
@TableField(exist = false) @TableField(exist = false)
private String path; private String path;
...@@ -122,9 +124,11 @@ public class Task extends SuperEntity<Task> { ...@@ -122,9 +124,11 @@ public class Task extends SuperEntity<Task> {
public JobConfig buildSubmitConfig() { public JobConfig buildSubmitConfig() {
boolean useRemote = clusterId != null && clusterId != 0; boolean useRemote = clusterId != null && clusterId != 0;
Map<String, String> map = configJson.stream()
.filter(Asserts::isNotNull) List<ConfigItem> extCustomConfig = this.configJson.getCustomConfig();
.collect(Collectors.toMap(item -> item.get("name"), item -> item.get("value"), (a, b) -> b));
Map<String, String> parsedConfig =
extCustomConfig.stream().collect(Collectors.toMap(ConfigItem::getKey, ConfigItem::getValue));
int jid = Asserts.isNull(jarId) ? 0 : jarId; int jid = Asserts.isNull(jarId) ? 0 : jarId;
boolean fg = Asserts.isNotNull(fragment) && fragment; boolean fg = Asserts.isNotNull(fragment) && fragment;
...@@ -147,10 +151,28 @@ public class Task extends SuperEntity<Task> { ...@@ -147,10 +151,28 @@ public class Task extends SuperEntity<Task> {
parallelism, parallelism,
savePointStrategy, savePointStrategy,
savePointPath, savePointPath,
map, parsedConfig,
isJarTask()); 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) { public JsonNode parseJsonNode(ObjectMapper mapper) {
ObjectNode jsonNode = mapper.createObjectNode(); ObjectNode jsonNode = mapper.createObjectNode();
jsonNode.put("name", this.getName()); 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; ...@@ -46,7 +46,6 @@ import java.io.File;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
...@@ -106,11 +105,11 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -106,11 +105,11 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
List<Catalogue> returnList = new ArrayList<>(); List<Catalogue> returnList = new ArrayList<>();
for (Iterator<Catalogue> iterator = catalogueList.iterator(); iterator.hasNext(); ) { for (Iterator<Catalogue> iterator = catalogueList.iterator(); iterator.hasNext(); ) {
Catalogue menu = iterator.next(); Catalogue catalogue = iterator.next();
// get all child menu of parent menu id , the -1 is root menu // get all child catalogue of parent catalogue id , the 0 is root catalogue
if (menu.getParentId() == 0) { if (catalogue.getParentId() == 0) {
recursionBuildCatalogueAndChildren(catalogueList, menu); recursionBuildCatalogueAndChildren(catalogueList, catalogue);
returnList.add(menu); returnList.add(catalogue);
} }
} }
if (returnList.isEmpty()) { if (returnList.isEmpty()) {
...@@ -131,14 +130,15 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -131,14 +130,15 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
for (Catalogue tChild : childList) { for (Catalogue tChild : childList) {
if (hasChild(list, tChild)) { if (hasChild(list, tChild)) {
// Determine whether there are child nodes // Determine whether there are child nodes
for (Catalogue n : childList) { for (Catalogue children : childList) {
if (n.getIsLeaf()) { recursionBuildCatalogueAndChildren(list, children);
Task task = taskService.getById(n.getTaskId());
if (task != null) {
n.setTask(task);
} }
} 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 ...@@ -147,11 +147,11 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
/** /**
* Determine whether there are child nodes * Determine whether there are child nodes
* @param list * @param list
* @param menu * @param catalogue
* @return * @return
*/ */
private boolean hasChild(List<Catalogue> list, Catalogue menu) { private boolean hasChild(List<Catalogue> list, Catalogue catalogue) {
return getChildList(list, menu).size() > 0; return getChildList(list, catalogue).size() > 0;
} }
/** /**
...@@ -191,7 +191,8 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -191,7 +191,8 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
} }
task.setName(catalogueTaskDTO.getName()); task.setName(catalogueTaskDTO.getName());
task.setDialect(catalogueTaskDTO.getType()); task.setDialect(catalogueTaskDTO.getType());
task.setConfigJson(Collections.singletonList(catalogueTaskDTO.getConfig())); task.setConfigJson(catalogueTaskDTO.getConfigJson());
task.setNote(catalogueTaskDTO.getNote());
taskService.saveOrUpdateTask(task); taskService.saveOrUpdateTask(task);
catalogue.setTenantId(catalogueTaskDTO.getTenantId()); catalogue.setTenantId(catalogueTaskDTO.getTenantId());
...@@ -413,12 +414,9 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -413,12 +414,9 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
} }
// 获取 catalogue 表中的作业 // 获取 catalogue 表中的作业
Catalogue catalogue = getById(catalogueId); Catalogue catalogue = getById(catalogueId);
// 如果是文件夹 , 且下边没有子文件夹 , 则删除
if (catalogue.getIsLeaf()) { // 判断书否为空 且 是否为叶子节点
return removeById(catalogueId) if (BeanUtil.isNotEmpty(catalogue) && catalogue.getIsLeaf()) {
? Result.succeed(Status.DELETE_SUCCESS)
: Result.failed(Status.DELETE_FAILED);
}
// doing: cascade delete jobInstance && jobHistory && history && statement // doing: cascade delete jobInstance && jobHistory && history && statement
// 获取 task 表中的作业 // 获取 task 表中的作业
Task task = taskService.getById(catalogue.getTaskId()); Task task = taskService.getById(catalogue.getTaskId());
...@@ -428,8 +426,8 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -428,8 +426,8 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
List<JobInstance> jobInstanceList = jobInstanceService.list( List<JobInstance> jobInstanceList = jobInstanceService.list(
new LambdaQueryWrapper<JobInstance>().eq(JobInstance::getTaskId, catalogue.getTaskId())); new LambdaQueryWrapper<JobInstance>().eq(JobInstance::getTaskId, catalogue.getTaskId()));
// 获取 history 表中的作业 // 获取 history 表中的作业
List<History> historyList = List<History> historyList = historyService.list(
historyService.list(new LambdaQueryWrapper<History>().eq(History::getTaskId, catalogue.getTaskId())); new LambdaQueryWrapper<History>().eq(History::getTaskId, catalogue.getTaskId()));
historyList.forEach(history -> { historyList.forEach(history -> {
// 查询 job history 表中的作业 通过 id 关联查询 // 查询 job history 表中的作业 通过 id 关联查询
JobHistory historyServiceById = jobHistoryService.getById(history.getId()); JobHistory historyServiceById = jobHistoryService.getById(history.getId());
...@@ -443,11 +441,17 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -443,11 +441,17 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
jobInstanceService.removeById(jobInstance.getId()); jobInstanceService.removeById(jobInstance.getId());
}); });
// 删除 task 表中的作业 // 删除 task 表中的作业
if (task != null) {
taskService.removeById(task.getId()); taskService.removeById(task.getId());
}
// 删除 statement 表中的作业 // 删除 statement 表中的作业
if (statement != null) {
statementService.removeById(statement.getId()); 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; ...@@ -62,6 +62,7 @@ import org.dinky.data.model.Savepoints;
import org.dinky.data.model.Statement; import org.dinky.data.model.Statement;
import org.dinky.data.model.SystemConfiguration; import org.dinky.data.model.SystemConfiguration;
import org.dinky.data.model.Task; import org.dinky.data.model.Task;
import org.dinky.data.model.TaskExtConfig;
import org.dinky.data.model.TaskVersion; import org.dinky.data.model.TaskVersion;
import org.dinky.data.model.UDFTemplate; import org.dinky.data.model.UDFTemplate;
import org.dinky.data.result.Result; import org.dinky.data.result.Result;
...@@ -153,8 +154,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode; ...@@ -153,8 +154,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil; 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.Tree;
import cn.hutool.core.lang.tree.TreeNode; import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil; import cn.hutool.core.lang.tree.TreeUtil;
...@@ -448,14 +447,20 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -448,14 +447,20 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Override @Override
public boolean saveOrUpdateTask(Task task) { public boolean saveOrUpdateTask(Task task) {
if (Dialect.isUDF(task.getDialect())) { if (Dialect.isUDF(task.getDialect())) {
if (CollUtil.isNotEmpty(task.getConfigJson())
TaskExtConfig taskConfigJson = task.getConfigJson();
if (BeanUtil.isNotEmpty(task.getConfigJson())
&& Asserts.isNullString(task.getStatement()) && Asserts.isNullString(task.getStatement())
&& Convert.toInt(task.getConfigJson().get(0).get("templateId"), 0) != 0) { && BeanUtil.isNotEmpty(taskConfigJson.getUdfConfig())) {
Map<String, String> config = task.getConfigJson().get(0);
UDFTemplate template = udfTemplateService.getById(config.get("templateId")); UDFTemplate template =
udfTemplateService.getById(taskConfigJson.getUdfConfig().getTemplateId());
if (template != null) { if (template != null) {
String code = UDFUtil.templateParse( String code = UDFUtil.templateParse(
task.getDialect(), template.getTemplateCode(), config.get("className")); task.getDialect(),
template.getTemplateCode(),
taskConfigJson.getUdfConfig().getClassName());
task.setStatement(code); task.setStatement(code);
} }
} }
......
...@@ -30,7 +30,7 @@ public class UDFUtils extends UDFUtil { ...@@ -30,7 +30,7 @@ public class UDFUtils extends UDFUtil {
public static UDF taskToUDF(Task task) { public static UDF taskToUDF(Task task) {
return UDF.builder() return UDF.builder()
.className(task.getSavePointPath()) .className(task.getConfigJson().getUdfConfig().getClassName())
.code(task.getStatement()) .code(task.getStatement())
.functionLanguage(FunctionLanguage.valueOf(task.getDialect().toUpperCase())) .functionLanguage(FunctionLanguage.valueOf(task.getDialect().toUpperCase()))
.build(); .build();
......
...@@ -152,21 +152,8 @@ sa-token: ...@@ -152,21 +152,8 @@ sa-token:
################################################################################################################# #################################################################################################################
knife4j: knife4j:
enable: true enable: true
# openapi:
# title: Dinky REST APIS dinky:
# 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:
version: @project.version@ version: @project.version@
sms: sms:
is-print: false is-print: false
......
{ {
"name": "Dinky", "name": "dinky-web",
"version": "6.0.0", "version": "1.0.0",
"private": true,
"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.", "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": { "scripts": {
"analyze": "cross-env ANALYZE=1 max build", "analyze": "cross-env ANALYZE=1 max build",
"build": "max build", "build": "max build",
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
*/ */
import { PopconfirmDeleteBtn } from '@/components/CallBackButton/PopconfirmDeleteBtn'; import { PopconfirmDeleteBtn } from '@/components/CallBackButton/PopconfirmDeleteBtn';
import { TaskVersionListItem } from '@/types/Studio/data';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { DeliveredProcedureOutlined } from '@ant-design/icons'; import { DeliveredProcedureOutlined } from '@ant-design/icons';
import { List, Skeleton, Space, Tag, Tooltip } from 'antd'; import { List, Skeleton, Space, Tag, Tooltip } from 'antd';
import { ListItemTypeProps } from 'antd/es/list/Item'; import { ListItemTypeProps } from 'antd/es/list/Item';
import {TaskVersionListItem} from "@/types/Studio/data";
export interface VersionListProps { export interface VersionListProps {
data: TaskVersionListItem[]; data: TaskVersionListItem[];
......
...@@ -1166,6 +1166,8 @@ export default { ...@@ -1166,6 +1166,8 @@ export default {
'catalog.name': 'Job Name', 'catalog.name': 'Job Name',
'catalog.name.placeholder': 'Please enter the 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': 'catalog.name.tip':
'This name can be used as the JobName of the FlinkSql task (pipeline.name configuration item)', 'This name can be used as the JobName of the FlinkSql task (pipeline.name configuration item)',
'catalog.type': 'Job Type', 'catalog.type': 'Job Type',
......
...@@ -1129,6 +1129,8 @@ export default { ...@@ -1129,6 +1129,8 @@ export default {
'catalog.name': '作业名称', 'catalog.name': '作业名称',
'catalog.name.placeholder': '请输入作业名称', 'catalog.name.placeholder': '请输入作业名称',
'catalog.note': '作业描述',
'catalog.note.placeholder': '请输入作业描述',
'catalog.name.tip': '此名称可作为 FlinkSql 任务的 JobName ([配置项: pipeline.name])', 'catalog.name.tip': '此名称可作为 FlinkSql 任务的 JobName ([配置项: pipeline.name])',
'catalog.type': '作业类型', 'catalog.type': '作业类型',
'catalog.type.placeholder': '请选择作业类型', 'catalog.type.placeholder': '请选择作业类型',
......
...@@ -24,7 +24,7 @@ import { queryDataByParams } from '@/services/BusinessCrud'; ...@@ -24,7 +24,7 @@ import { queryDataByParams } from '@/services/BusinessCrud';
import { API_CONSTANTS } from '@/services/endpoints'; import { API_CONSTANTS } from '@/services/endpoints';
import { Catalogue } from '@/types/Studio/data'; import { Catalogue } from '@/types/Studio/data';
import { l } from '@/utils/intl'; 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 { ProFormCascader } from '@ant-design/pro-form/lib';
import { Form } from 'antd'; import { Form } from 'antd';
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
...@@ -55,8 +55,9 @@ const JobModal: React.FC<JobModalProps> = (props) => { ...@@ -55,8 +55,9 @@ const JobModal: React.FC<JobModalProps> = (props) => {
* when modalVisible or values changed, set form values * when modalVisible or values changed, set form values
*/ */
useEffect(() => { useEffect(() => {
const newValues = { ...values, configJson: values.task?.configJson };
if (modalVisible) form.resetFields(); if (modalVisible) form.resetFields();
form.setFieldsValue(values); form.setFieldsValue(newValues);
}, [open, values, form]); }, [open, values, form]);
const queryUdfTemplate = async () => { const queryUdfTemplate = async () => {
...@@ -69,7 +70,6 @@ const JobModal: React.FC<JobModalProps> = (props) => { ...@@ -69,7 +70,6 @@ const JobModal: React.FC<JobModalProps> = (props) => {
}; };
useEffect(() => { useEffect(() => {
form.setFieldValue('configJson', {});
isUDF(jobType) && queryUdfTemplate(); isUDF(jobType) && queryUdfTemplate();
}, [jobType, form]); }, [jobType, form]);
...@@ -96,9 +96,8 @@ const JobModal: React.FC<JobModalProps> = (props) => { ...@@ -96,9 +96,8 @@ const JobModal: React.FC<JobModalProps> = (props) => {
const submitForm = async (formData: Catalogue) => { const submitForm = async (formData: Catalogue) => {
await form.validateFields(); await form.validateFields();
if (isUDF(formData.type) && formData.configJson) { if (isUDF(formData.type) && formData.configJson) {
// todo: 有个 bug 接口入参载荷正常, 但是接口获取的 configJson 提示无法 const { selectKeys } = formData.configJson.udfConfig;
const { templateId } = formData.configJson; formData.configJson.udfConfig.templateId = selectKeys[selectKeys.length - 1];
formData.configJson.templateId = (templateId as any[]).sort((a, b) => a - b).pop();
} }
onSubmit({ ...values, ...formData } as Catalogue); onSubmit({ ...values, ...formData } as Catalogue);
}; };
...@@ -122,10 +121,16 @@ const JobModal: React.FC<JobModalProps> = (props) => { ...@@ -122,10 +121,16 @@ const JobModal: React.FC<JobModalProps> = (props) => {
placeholder={l('catalog.name.placeholder')} placeholder={l('catalog.name.placeholder')}
rules={[{ required: true, message: 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) && ( {isUDF(jobType) && (
<> <>
<ProFormCascader <ProFormCascader
name={['configJson', 'templateId']} name={['configJson', 'udfConfig', 'selectKeys']}
label={l('catalog.udf.templateId')} label={l('catalog.udf.templateId')}
shouldUpdate={(prevValues, curValues) => prevValues.type !== curValues.type} shouldUpdate={(prevValues, curValues) => prevValues.type !== curValues.type}
placeholder={l('catalog.udf.templateId.placeholder')} placeholder={l('catalog.udf.templateId.placeholder')}
...@@ -142,7 +147,7 @@ const JobModal: React.FC<JobModalProps> = (props) => { ...@@ -142,7 +147,7 @@ const JobModal: React.FC<JobModalProps> = (props) => {
/> />
<ProFormText <ProFormText
name={['configJson', 'className']} name={['configJson', 'udfConfig', 'className']}
label={l('catalog.udf.className')} label={l('catalog.udf.className')}
placeholder={l('catalog.udf.className.placeholder')} placeholder={l('catalog.udf.className.placeholder')}
rules={[ rules={[
......
...@@ -194,9 +194,13 @@ const Project: React.FC = (props: connect) => { ...@@ -194,9 +194,13 @@ const Project: React.FC = (props: connect) => {
: modalAllVisible.value.parentId : modalAllVisible.value.parentId
}; };
if (rightActiveKey === 'createTask') { if (rightActiveKey === 'createTask' || rightActiveKey === 'edit') {
options.url = API_CONSTANTS.CREATE_TASK_URL; options.url = API_CONSTANTS.SAVE_OR_UPDATE_TASK_URL;
options.parentId = modalAllVisible.isCreateTask && modalAllVisible.value.id; options.parentId = modalAllVisible.isCreateTask
? modalAllVisible.value.id
: modalAllVisible.isEdit
? modalAllVisible.value.parentId
: options.parentId;
} else { } else {
options.url = API_CONSTANTS.SAVE_OR_UPDATE_CATALOGUE_URL; options.url = API_CONSTANTS.SAVE_OR_UPDATE_CATALOGUE_URL;
} }
...@@ -217,12 +221,12 @@ const Project: React.FC = (props: connect) => { ...@@ -217,12 +221,12 @@ const Project: React.FC = (props: connect) => {
isCreateTask: false, isCreateTask: false,
isCut: false isCut: false
})); }));
dispatch({ type: STUDIO_MODEL_ASYNC.queryProject });
if (modalAllVisible.isRename) { if (modalAllVisible.isRename) {
// todo: 如果是重命名/修改(修改了名字), 则需要 更新 tab 的 label // todo: 如果是重命名/修改(修改了名字), 则需要 更新 tab 的 label
} }
} }
); );
dispatch({ type: STUDIO_MODEL_ASYNC.queryProject });
}; };
/** /**
......
...@@ -47,6 +47,7 @@ import { ...@@ -47,6 +47,7 @@ import {
import { Badge, Space, Typography } from 'antd'; import { Badge, Space, Typography } from 'antd';
import { useForm } from 'antd/es/form/Form'; import { useForm } from 'antd/es/form/Form';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { useEffect } from 'react';
import { connect } from 'umi'; import { connect } from 'umi';
const { Text } = Typography; const { Text } = Typography;
...@@ -73,7 +74,10 @@ const JobConfig = (props: any) => { ...@@ -73,7 +74,10 @@ const JobConfig = (props: any) => {
} }
}; };
const [form] = useForm(); const [form] = useForm();
useEffect(() => {
form.setFieldsValue(current); form.setFieldsValue(current);
}, [current]);
const onValuesChange = (change: { [key in string]: string }, all: any) => { const onValuesChange = (change: { [key in string]: string }, all: any) => {
const pane = getCurrentTab(panes, activeKey); const pane = getCurrentTab(panes, activeKey);
...@@ -128,15 +132,15 @@ const JobConfig = (props: any) => { ...@@ -128,15 +132,15 @@ const JobConfig = (props: any) => {
<> <>
{currentSession.session ? ( {currentSession.session ? (
currentSession.sessionConfig?.clusterId ? ( currentSession.sessionConfig?.clusterId ? (
<> <Space>
<Badge status='success' /> <Badge status='success' />
<Text type='success'>{currentSession.sessionConfig.clusterName}</Text> <Text type='success'>{currentSession.sessionConfig.clusterName}</Text>
</> </Space>
) : ( ) : (
<> <Space>
<Badge status='error' /> <Badge status='error' />
<Text type='danger'>{l('pages.devops.jobinfo.localenv')}</Text> <Text type='danger'>{l('pages.devops.jobinfo.localenv')}</Text>
</> </Space>
) )
) : ( ) : (
<> <>
...@@ -180,6 +184,7 @@ const JobConfig = (props: any) => { ...@@ -180,6 +184,7 @@ const JobConfig = (props: any) => {
tooltip={l('pages.datastudio.label.jobConfig.flinksql.env.tip1')} tooltip={l('pages.datastudio.label.jobConfig.flinksql.env.tip1')}
options={buildEnvOptions(env)} options={buildEnvOptions(env)}
showSearch showSearch
initialValue={0}
/> />
<ProFormGroup> <ProFormGroup>
...@@ -229,6 +234,7 @@ const JobConfig = (props: any) => { ...@@ -229,6 +234,7 @@ const JobConfig = (props: any) => {
name='savePointStrategy' name='savePointStrategy'
tooltip={l('pages.datastudio.label.jobConfig.savePointStrategy.tip')} tooltip={l('pages.datastudio.label.jobConfig.savePointStrategy.tip')}
options={SAVE_POINT_TYPE} options={SAVE_POINT_TYPE}
initialValue={0}
/> />
{current.savePointStrategy === 3 && ( {current.savePointStrategy === 3 && (
...@@ -248,11 +254,10 @@ const JobConfig = (props: any) => { ...@@ -248,11 +254,10 @@ const JobConfig = (props: any) => {
options={buildAlertGroupOptions(group)} options={buildAlertGroupOptions(group)}
/> />
{/*todo 这里需要优化,有有异常抛出*/}
<ProFormList <ProFormList
label={l('pages.datastudio.label.jobConfig.other')} label={l('pages.datastudio.label.jobConfig.other')}
tooltip={l('pages.datastudio.label.jobConfig.other.tip')} tooltip={l('pages.datastudio.label.jobConfig.other.tip')}
name={'configJson'} name={['configJson', 'customConfig']}
copyIconProps={false} copyIconProps={false}
creatorButtonProps={{ creatorButtonProps={{
style: { width: '100%' }, style: { width: '100%' },
...@@ -265,6 +270,13 @@ const JobConfig = (props: any) => { ...@@ -265,6 +270,13 @@ const JobConfig = (props: any) => {
name='key' name='key'
placeholder={l('pages.datastudio.label.jobConfig.addConfig.params')} 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 <ProFormText
name='value' name='value'
placeholder={l('pages.datastudio.label.jobConfig.addConfig.value')} placeholder={l('pages.datastudio.label.jobConfig.addConfig.value')}
......
...@@ -17,80 +17,51 @@ ...@@ -17,80 +17,51 @@
* *
*/ */
import { import { getCurrentData } from '@/pages/DataStudio/function';
getCurrentData, import { StateType, TaskDataType } from '@/pages/DataStudio/model';
getCurrentTab,
isDataStudioTabsItemType
} from '@/pages/DataStudio/function';
import { StateType, STUDIO_MODEL } from '@/pages/DataStudio/model';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { Col, Descriptions, Form, Row } from 'antd'; import { Descriptions } from 'antd';
import { useForm } from 'antd/es/form/Form';
import TextArea from 'antd/es/input/TextArea';
import Paragraph from 'antd/es/typography/Paragraph'; import Paragraph from 'antd/es/typography/Paragraph';
import { useEffect, useState } from 'react';
import { connect } from 'umi'; import { connect } from 'umi';
const JobInfo = (props: any) => { const JobInfo = (props: any) => {
const { const {
dispatch,
tabs: { panes, activeKey } tabs: { panes, activeKey }
} = props; } = props;
const current = getCurrentData(panes, activeKey);
const [form] = useForm(); const [currentInfo, setCurrentInfo] = useState<Partial<TaskDataType>>(
form.setFieldsValue(current); getCurrentData(panes, activeKey) ?? {}
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];
});
dispatch({ useEffect(() => {
type: STUDIO_MODEL.saveTabs, setCurrentInfo({ ...currentInfo, ...getCurrentData(panes, activeKey) });
payload: { ...props.tabs } }, [activeKey, panes]);
});
};
return ( return (
<div style={{ paddingInline: 8 }}> <div style={{ paddingInline: 8 }}>
<Descriptions bordered size='small' column={1}> <Descriptions bordered size='small' column={1}>
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.id')}> <Descriptions.Item label={l('pages.datastudio.label.jobInfo.id')}>
<Paragraph copyable>{current?.id}</Paragraph> <Paragraph copyable>{currentInfo?.id}</Paragraph>
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.name')}> <Descriptions.Item label={l('pages.datastudio.label.jobInfo.name')}>
{current?.name} {currentInfo?.name}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.dialect')}> <Descriptions.Item label={l('pages.datastudio.label.jobInfo.dialect')}>
{current?.dialect} {currentInfo?.dialect}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={l('pages.datastudio.label.jobInfo.versionId')}> <Descriptions.Item label={l('pages.datastudio.label.jobInfo.versionId')}>
{current?.versionId} {currentInfo?.versionId}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={l('global.table.createTime')}> <Descriptions.Item label={l('global.table.createTime')}>
{current?.createTime} {currentInfo?.createTime}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={l('global.table.updateTime')}> <Descriptions.Item label={l('global.table.updateTime')}>
{current?.updateTime} {currentInfo?.updateTime}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label={l('global.table.note')}>{currentInfo?.note}</Descriptions.Item>
</Descriptions> </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> </div>
); );
}; };
......
...@@ -19,8 +19,8 @@ import { showAlertInstance } from '@/pages/RegCenter/Alert/AlertGroup/service'; ...@@ -19,8 +19,8 @@ import { showAlertInstance } from '@/pages/RegCenter/Alert/AlertGroup/service';
import { Alert } from '@/types/RegCenter/data.d'; import { Alert } from '@/types/RegCenter/data.d';
import { Reducer } from 'umi'; import { Reducer } from 'umi';
import { createModelTypes } from '@/utils/modelUtils';
import { Effect } from '@@/plugin-dva/types'; import { Effect } from '@@/plugin-dva/types';
import {createModelTypes} from "@/utils/modelUtils";
export type AlertStateType = { export type AlertStateType = {
instance: Alert.AlertInstance[]; instance: Alert.AlertInstance[];
......
...@@ -27,6 +27,7 @@ import { DataAction } from '@/components/StyledComponents'; ...@@ -27,6 +27,7 @@ import { DataAction } from '@/components/StyledComponents';
import { imgStyle } from '@/pages/Home/constants'; import { imgStyle } from '@/pages/Home/constants';
import ConfigurationModal from '@/pages/RegCenter/Cluster/Configuration/components/ConfigurationModal'; import ConfigurationModal from '@/pages/RegCenter/Cluster/Configuration/components/ConfigurationModal';
import { CLUSTER_CONFIG_TYPE } from '@/pages/RegCenter/Cluster/Configuration/components/contants'; import { CLUSTER_CONFIG_TYPE } from '@/pages/RegCenter/Cluster/Configuration/components/contants';
import { queryList } from '@/services/api';
import { import {
handleAddOrUpdate, handleAddOrUpdate,
handleOption, handleOption,
...@@ -42,10 +43,9 @@ import { ClusterConfigState } from '@/types/RegCenter/state.d'; ...@@ -42,10 +43,9 @@ import { ClusterConfigState } from '@/types/RegCenter/state.d';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { CheckCircleOutlined, ExclamationCircleOutlined, HeartTwoTone } from '@ant-design/icons'; import { CheckCircleOutlined, ExclamationCircleOutlined, HeartTwoTone } from '@ant-design/icons';
import { ActionType, ProList } from '@ant-design/pro-components'; import { ActionType, ProList } from '@ant-design/pro-components';
import { useRequest } from '@umijs/max';
import { Button, Descriptions, Modal, Space, Tag, Tooltip } from 'antd'; import { Button, Descriptions, Modal, Space, Tag, Tooltip } from 'antd';
import DescriptionsItem from 'antd/es/descriptions/Item'; import DescriptionsItem from 'antd/es/descriptions/Item';
import { useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
export default () => { export default () => {
/** /**
...@@ -56,11 +56,21 @@ export default () => { ...@@ -56,11 +56,21 @@ export default () => {
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const { data, run } = useRequest({ // const { data, run } = useRequest({
url: API_CONSTANTS.CLUSTER_CONFIGURATION, // url: API_CONSTANTS.CLUSTER_CONFIGURATION,
method: 'POST', // method: 'POST',
data: {} // data: {}
}); // });
const queryClusterConfigList = async () => {
queryList(API_CONSTANTS.CLUSTER_CONFIGURATION).then((res) =>
setClusterConfigState((prevState) => ({ ...prevState, configList: res.data }))
);
};
useEffect(() => {
queryClusterConfigList();
}, []);
/** /**
* execute and callback function * execute and callback function
...@@ -70,7 +80,7 @@ export default () => { ...@@ -70,7 +80,7 @@ export default () => {
const executeAndCallbackRefresh = async (callback: () => void) => { const executeAndCallbackRefresh = async (callback: () => void) => {
setClusterConfigState((prevState) => ({ ...prevState, loading: true })); setClusterConfigState((prevState) => ({ ...prevState, loading: true }));
await callback(); await callback();
await run(); await queryClusterConfigList();
setClusterConfigState((prevState) => ({ ...prevState, loading: false })); setClusterConfigState((prevState) => ({ ...prevState, loading: false }));
actionRef.current?.reload?.(); actionRef.current?.reload?.();
}; };
...@@ -225,13 +235,16 @@ export default () => { ...@@ -225,13 +235,16 @@ export default () => {
/** /**
* render data list * render data list
*/ */
const renderData = data?.map((item: Cluster.Config) => ({ const renderData = (list: Cluster.Config[]) =>
list.map((item: Cluster.Config) => {
return {
subTitle: renderDataSubTitle(item), subTitle: renderDataSubTitle(item),
actions: <DataAction>{renderDataActionButton(item)}</DataAction>, actions: <DataAction>{renderDataActionButton(item)}</DataAction>,
avatar: <ClusterConfigIcon style={imgStyle} />, avatar: <ClusterConfigIcon style={imgStyle} />,
content: renderDataContent(item), content: renderDataContent(item),
key: item.id key: item.id
})); };
});
/** /**
* tool bar render * tool bar render
...@@ -255,7 +268,7 @@ export default () => { ...@@ -255,7 +268,7 @@ export default () => {
actionRef={actionRef} actionRef={actionRef}
headerTitle={l('rc.cc.management')} headerTitle={l('rc.cc.management')}
toolBarRender={toolBarRender} toolBarRender={toolBarRender}
dataSource={renderData} dataSource={renderData(clusterConfigState.configList)}
/> />
{/*added*/} {/*added*/}
......
...@@ -24,7 +24,11 @@ import { DefaultOptionType } from 'rc-select/es/Select'; ...@@ -24,7 +24,11 @@ import { DefaultOptionType } from 'rc-select/es/Select';
* Cluster config type * Cluster config type
*/ */
export const CLUSTER_CONFIG_TYPE: DefaultOptionType[] = [ 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, value: ClusterType.KUBERNETES_NATIVE,
label: 'Kubernetes Native', label: 'Kubernetes Native',
......
...@@ -248,7 +248,7 @@ export enum API_CONSTANTS { ...@@ -248,7 +248,7 @@ export enum API_CONSTANTS {
// catalog // catalog
DELETE_CATALOGUE_BY_ID_URL = '/api/catalogue/deleteCatalogueById', 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', SAVE_OR_UPDATE_CATALOGUE_URL = '/api/catalogue/saveOrUpdateCatalogue',
COPY_TASK_URL = '/api/catalogue/copyTask', COPY_TASK_URL = '/api/catalogue/copyTask',
MOVE_CATALOGUE_URL = '/api/catalogue/moveCatalogue' MOVE_CATALOGUE_URL = '/api/catalogue/moveCatalogue'
......
...@@ -37,8 +37,8 @@ import { ...@@ -37,8 +37,8 @@ import {
export const InitAlertGroupState: AlertGroupState = { export const InitAlertGroupState: AlertGroupState = {
alertGroupList: [], alertGroupList: [],
loading: false, loading: false,
addedAlertGroupOpen: false, addedOpen: false,
editAlertGroupOpen: false, editOpen: false,
value: {} value: {}
}; };
...@@ -49,8 +49,8 @@ export const InitAlertGroupState: AlertGroupState = { ...@@ -49,8 +49,8 @@ export const InitAlertGroupState: AlertGroupState = {
export const InitAlertInstanceState: AlertInstanceState = { export const InitAlertInstanceState: AlertInstanceState = {
alertInstanceList: [], alertInstanceList: [],
loading: false, loading: false,
addedAlertInstanceOpen: false, addedOpen: false,
editAlertInstanceOpen: false, editOpen: false,
value: {} value: {}
}; };
...@@ -60,9 +60,10 @@ export const InitAlertInstanceState: AlertInstanceState = { ...@@ -60,9 +60,10 @@ export const InitAlertInstanceState: AlertInstanceState = {
*/ */
export const InitClusterConfigState: ClusterConfigState = { export const InitClusterConfigState: ClusterConfigState = {
loading: false, loading: false,
addedClusterConfigOpen: false, addedOpen: false,
editClusterConfigOpen: false, editOpen: false,
value: {} value: {},
configList: []
}; };
/** /**
...@@ -71,8 +72,8 @@ export const InitClusterConfigState: ClusterConfigState = { ...@@ -71,8 +72,8 @@ export const InitClusterConfigState: ClusterConfigState = {
*/ */
export const InitClusterInstanceState: ClusterInstanceState = { export const InitClusterInstanceState: ClusterInstanceState = {
loading: false, loading: false,
addedClusterInstanceOpen: false, addedOpen: false,
editClusterInstanceOpen: false, editOpen: false,
value: {} value: {}
}; };
...@@ -82,8 +83,8 @@ export const InitClusterInstanceState: ClusterInstanceState = { ...@@ -82,8 +83,8 @@ export const InitClusterInstanceState: ClusterInstanceState = {
*/ */
export const InitDocumentState: DocumentState = { export const InitDocumentState: DocumentState = {
loading: false, loading: false,
addedDocumentOpen: false, addedOpen: false,
editDocumentOpen: false, editOpen: false,
value: {}, value: {},
drawerOpen: false drawerOpen: false
}; };
......
...@@ -50,6 +50,7 @@ export interface AlertInstanceState extends BaseState { ...@@ -50,6 +50,7 @@ export interface AlertInstanceState extends BaseState {
*/ */
export interface ClusterConfigState extends BaseState { export interface ClusterConfigState extends BaseState {
value: Partial<Cluster.Config>; value: Partial<Cluster.Config>;
configList: Cluster.Config[];
} }
/** /**
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
* *
*/ */
import { List } from 'antd';
export type Catalogue = { export type Catalogue = {
id: number; id: number;
name: string; name: string;
...@@ -28,10 +30,26 @@ export type Catalogue = { ...@@ -28,10 +30,26 @@ export type Catalogue = {
createTime: Date; createTime: Date;
updateTime: Date; updateTime: Date;
children: Catalogue[]; children: Catalogue[];
configJson: Object<string, object>; configJson: TaskExtConfig;
task: Task; 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 = { export type Task = {
id: number; id: number;
name: string; name: string;
...@@ -58,7 +76,7 @@ export type Task = { ...@@ -58,7 +76,7 @@ export type Task = {
statement: string; statement: string;
clusterName: string; clusterName: string;
savePoints: SavePoint[]; savePoints: SavePoint[];
configJson: Object<string, object>; configJson: TaskExtConfig;
path: string; path: string;
jarName: string; jarName: string;
clusterConfigurationName: string; clusterConfigurationName: string;
......
...@@ -46,4 +46,3 @@ export const ErrorModelWithCode = ( ...@@ -46,4 +46,3 @@ export const ErrorModelWithCode = (
/> />
); );
}; };
interface BaseModelType { interface BaseModelType {
['reducers']: {}; ['reducers']: {};
['effects']: {}; ['effects']: {};
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Dinky :</name> <name>Dinky : Real-time Computing Platform</name>
<modules> <modules>
<module>dinky-flink</module> <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