Unverified Commit b8e6a44c authored by Zzm0809's avatar Zzm0809 Committed by GitHub

refactor push ds (#2662)

* refactor push ds * Spotless Apply --------- Co-authored-by: 's avatarZzm0809 <Zzm0809@users.noreply.github.com>
parent 106d1b53
...@@ -225,18 +225,18 @@ public class SystemInit implements ApplicationRunner { ...@@ -225,18 +225,18 @@ public class SystemInit implements ApplicationRunner {
* init DolphinScheduler * init DolphinScheduler
*/ */
private void initDolphinScheduler() { private void initDolphinScheduler() {
systemConfiguration List<Configuration<?>> configurationList =
.getAllConfiguration() systemConfiguration.getAllConfiguration().get("dolphinscheduler");
.get("dolphinscheduler") configurationList.forEach(c -> c.addParameterCheck(this::aboutDolphinSchedulerInitOperation));
.forEach(c -> c.addParameterCheck(v -> { // init call for once
if (Boolean.TRUE.equals( aboutDolphinSchedulerInitOperation("init");
systemConfiguration.getDolphinschedulerEnable().getValue())) { }
private void aboutDolphinSchedulerInitOperation(Object v) {
if (Boolean.TRUE.equals(systemConfiguration.getDolphinschedulerEnable().getValue())) {
if (StrUtil.isEmpty(Convert.toStr(v))) { if (StrUtil.isEmpty(Convert.toStr(v))) {
sysConfigService.updateSysConfigByKv( sysConfigService.updateSysConfigByKv(
systemConfiguration systemConfiguration.getDolphinschedulerEnable().getKey(), "false");
.getDolphinschedulerEnable()
.getKey(),
"false");
throw new DinkyException("Before starting DolphinScheduler" throw new DinkyException("Before starting DolphinScheduler"
+ " docking, please fill in the" + " docking, please fill in the"
+ " relevant configuration"); + " relevant configuration");
...@@ -251,7 +251,6 @@ public class SystemInit implements ApplicationRunner { ...@@ -251,7 +251,6 @@ public class SystemInit implements ApplicationRunner {
throw new DinkyException(e); throw new DinkyException(e);
} }
} }
}));
} }
/** /**
......
/*
*
* 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.service;
import org.dinky.scheduler.model.DinkyTaskRequest;
import org.dinky.scheduler.model.TaskDefinition;
import org.dinky.scheduler.model.TaskMainInfo;
import java.util.List;
public interface SchedulerService {
/**
* Pushes the specified DinkyTaskRequest to the task queue.
*
* @param dinkyTaskRequest the DinkyTaskRequest to be added to the task queue
* @return true if the task was successfully added, false otherwise
*/
boolean pushAddTask(DinkyTaskRequest dinkyTaskRequest);
/**
* A description of the entire Java function.
*
* @param projectCode description of parameter
* @param processCode description of parameter
* @param taskCode description of parameter
* @param dinkyTaskRequest description of parameter
* @return description of return value
*/
boolean pushUpdateTask(long projectCode, long processCode, long taskCode, DinkyTaskRequest dinkyTaskRequest);
/**
* Retrieves a list of TaskMainInfo objects based on the provided dinkyTaskId.
*
* @param dinkyTaskId the ID of the task
* @return a list of TaskMainInfo objects
*/
List<TaskMainInfo> getTaskMainInfos(long dinkyTaskId);
/**
* Retrieves the task definition information for a given dinky task ID.
*
* @param dinkyTaskId the ID of the dinky task
* @return the task definition information
*/
TaskDefinition getTaskDefinitionInfo(long dinkyTaskId);
}
...@@ -22,6 +22,7 @@ package org.dinky.data.exception; ...@@ -22,6 +22,7 @@ package org.dinky.data.exception;
import org.dinky.data.enums.Status; import org.dinky.data.enums.Status;
import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -58,6 +59,12 @@ public class BusException extends RuntimeException { ...@@ -58,6 +59,12 @@ public class BusException extends RuntimeException {
setMsg(status.getMessage()); setMsg(status.getMessage());
} }
public BusException(Status status, Object... errorArgs) {
super(status.getMessage());
setCode(String.valueOf(status.getCode()));
setMsg(StrUtil.format(status.getMessage(), errorArgs));
}
public BusException(String message, Object... args) { public BusException(String message, Object... args) {
super(); super();
setCode(message); setCode(message);
......
...@@ -109,7 +109,7 @@ success=Successfully ...@@ -109,7 +109,7 @@ success=Successfully
tenant.not.exist=Tenant Not Exist tenant.not.exist=Tenant Not Exist
user.already.exists=User Already Exists user.already.exists=User Already Exists
git.building=Git Building git.building=Git Building
ds.work.flow.definition.task.name.exist=Add Failed, Workflow Definition [{}] Already Exists Task Definition [{}] Please Refresh ds.work.flow.definition.task.name.exist=Workflow Definition [{}] Already Exists Task Definition [{}] , Will Update Operation
role.already.exists=Role Already Exists role.already.exists=Role Already Exists
internal.server.error.args=Internal Server Error: {0} internal.server.error.args=Internal Server Error: {0}
kick.out=token has been kicked offline kick.out=token has been kicked offline
......
...@@ -109,7 +109,7 @@ success=获取成功 ...@@ -109,7 +109,7 @@ success=获取成功
tenant.not.exist=租户不存在 tenant.not.exist=租户不存在
user.already.exists=用户名已存在 user.already.exists=用户名已存在
git.building=此任务正在构建 git.building=此任务正在构建
ds.work.flow.definition.task.name.exist=添加失败,工作流定义 [{}] 已存在任务定义 [{}] 请刷新 ds.work.flow.definition.task.name.exist=工作流定义 [{}] 已存在任务定义 [{}] , 将执行更新操作
role.already.exists=角色已存在 role.already.exists=角色已存在
internal.server.error.args=服务端异常: {0} internal.server.error.args=服务端异常: {0}
kick.out=token 已被踢下线 kick.out=token 已被踢下线
......
...@@ -41,10 +41,12 @@ import org.slf4j.Logger; ...@@ -41,10 +41,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.TypeReference; import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
/** 任务定义 */ /** 任务定义 */
@Component @Component
...@@ -60,8 +62,8 @@ public class TaskClient { ...@@ -60,8 +62,8 @@ public class TaskClient {
* @param taskName 任务定义名称 * @param taskName 任务定义名称
* @return {@link TaskMainInfo} * @return {@link TaskMainInfo}
*/ */
public TaskMainInfo getTaskMainInfo(Long projectCode, String processName, String taskName) { public TaskMainInfo getTaskMainInfo(Long projectCode, String processName, String taskName, String taskType) {
List<TaskMainInfo> lists = getTaskMainInfos(projectCode, processName, taskName); List<TaskMainInfo> lists = getTaskMainInfos(projectCode, processName, taskName, taskType);
for (TaskMainInfo list : lists) { for (TaskMainInfo list : lists) {
if (list.getTaskName().equalsIgnoreCase(taskName)) { if (list.getTaskName().equalsIgnoreCase(taskName)) {
return list; return list;
...@@ -78,7 +80,7 @@ public class TaskClient { ...@@ -78,7 +80,7 @@ public class TaskClient {
* @param taskName 任务定义名称 * @param taskName 任务定义名称
* @return {@link List<TaskMainInfo>} * @return {@link List<TaskMainInfo>}
*/ */
public List<TaskMainInfo> getTaskMainInfos(Long projectCode, String processName, String taskName) { public List<TaskMainInfo> getTaskMainInfos(Long projectCode, String processName, String taskName, String taskType) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("projectCode", projectCode); map.put("projectCode", projectCode);
String format = StrUtil.format( String format = StrUtil.format(
...@@ -89,7 +91,7 @@ public class TaskClient { ...@@ -89,7 +91,7 @@ public class TaskClient {
Map<String, Object> pageParams = ParamUtil.getPageParams(); Map<String, Object> pageParams = ParamUtil.getPageParams();
pageParams.put("searchTaskName", taskName); pageParams.put("searchTaskName", taskName);
pageParams.put("searchWorkflowName", processName); pageParams.put("searchWorkflowName", processName);
pageParams.put("taskType", "DINKY"); pageParams.put("taskType", taskType);
String content = HttpRequest.get(format) String content = HttpRequest.get(format)
.header( .header(
...@@ -109,9 +111,7 @@ public class TaskClient { ...@@ -109,9 +111,7 @@ public class TaskClient {
} }
for (JSONObject jsonObject : data.getTotalList()) { for (JSONObject jsonObject : data.getTotalList()) {
if (processName.equalsIgnoreCase(jsonObject.getStr("processDefinitionName"))) { lists.add(JSONUtil.toBean(jsonObject, TaskMainInfo.class));
lists.add(MyJSONUtil.toBean(jsonObject, TaskMainInfo.class));
}
} }
return lists; return lists;
} }
...@@ -153,7 +153,7 @@ public class TaskClient { ...@@ -153,7 +153,7 @@ public class TaskClient {
* @return {@link TaskDefinitionLog} * @return {@link TaskDefinitionLog}
*/ */
public TaskDefinitionLog createTaskDefinition( public TaskDefinitionLog createTaskDefinition(
Long projectCode, Long processCode, String upstreamCodes, String taskDefinitionJsonObj) { Long projectCode, Long processCode, List<String> upstreamCodes, String taskDefinitionJsonObj) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("projectCode", projectCode); map.put("projectCode", projectCode);
String format = StrUtil.format( String format = StrUtil.format(
...@@ -163,8 +163,8 @@ public class TaskClient { ...@@ -163,8 +163,8 @@ public class TaskClient {
Map<String, Object> pageParams = new HashMap<>(); Map<String, Object> pageParams = new HashMap<>();
pageParams.put("processDefinitionCode", processCode); pageParams.put("processDefinitionCode", processCode);
if (StringUtils.isNotBlank(upstreamCodes)) { if (CollUtil.isNotEmpty(upstreamCodes)) {
pageParams.put("upstreamCodes", upstreamCodes); pageParams.put("upstreamCodes", StringUtils.join(upstreamCodes, ","));
} }
pageParams.put("taskDefinitionJsonObj", taskDefinitionJsonObj); pageParams.put("taskDefinitionJsonObj", taskDefinitionJsonObj);
...@@ -192,7 +192,7 @@ public class TaskClient { ...@@ -192,7 +192,7 @@ public class TaskClient {
* @return {@link Long} * @return {@link Long}
*/ */
public Long updateTaskDefinition( public Long updateTaskDefinition(
long projectCode, long taskCode, String upstreamCodes, String taskDefinitionJsonObj) { long projectCode, long taskCode, List<String> upstreamCodes, String taskDefinitionJsonObj) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("projectCode", projectCode); map.put("projectCode", projectCode);
map.put("code", taskCode); map.put("code", taskCode);
...@@ -202,7 +202,9 @@ public class TaskClient { ...@@ -202,7 +202,9 @@ public class TaskClient {
map); map);
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("upstreamCodes", upstreamCodes); if (CollUtil.isNotEmpty(upstreamCodes)) {
params.put("upstreamCodes", StringUtils.join(upstreamCodes, ","));
}
params.put("taskDefinitionJsonObj", taskDefinitionJsonObj); params.put("taskDefinitionJsonObj", taskDefinitionJsonObj);
String content = HttpRequest.put(format) String content = HttpRequest.put(format)
......
/*
*
* 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.scheduler.model;
import org.dinky.data.model.SystemConfiguration;
import java.util.Arrays;
import java.util.List;
import javax.validation.constraints.NotNull;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class DinkyTaskRequest extends TaskRequest {
@ApiModelProperty(value = "自定义参数")
private List<Property> localParams;
@ApiModelProperty(value = "dinky地址")
@NotNull
private String address = SystemConfiguration.getInstances().getDinkyAddr().getValue();
@ApiModelProperty(value = "上游任务编号")
List<String> upstreamCodes = Arrays.asList();
@ApiModelProperty(value = "dinky任务id", required = true)
@NotNull
private String taskId;
}
...@@ -19,11 +19,7 @@ ...@@ -19,11 +19,7 @@
package org.dinky.scheduler.model; package org.dinky.scheduler.model;
import org.dinky.scheduler.enums.Flag;
import org.dinky.scheduler.enums.Priority;
import org.dinky.scheduler.enums.TaskExecuteType; import org.dinky.scheduler.enums.TaskExecuteType;
import org.dinky.scheduler.enums.TaskTimeoutStrategy;
import org.dinky.scheduler.enums.TimeoutFlag;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
...@@ -55,14 +51,14 @@ public class TaskRequest { ...@@ -55,14 +51,14 @@ public class TaskRequest {
private Integer failRetryTimes; private Integer failRetryTimes;
@ApiModelProperty(value = "运行标志 yes 正常/no 禁止执行") @ApiModelProperty(value = "运行标志 yes 正常/no 禁止执行")
private Flag flag; private String flag;
@ApiModelProperty(value = "任务参数 默认DINKY参数") @ApiModelProperty(value = "任务参数 默认DINKY参数")
private String taskParams; private String taskParams;
@NotNull @NotNull
@ApiModelProperty(value = "优先级") @ApiModelProperty(value = "优先级")
private Priority taskPriority; private String taskPriority;
@ApiModelProperty(value = "任务类型 默认DINKY") @ApiModelProperty(value = "任务类型 默认DINKY")
private String taskType = "DINKY"; private String taskType = "DINKY";
...@@ -71,10 +67,10 @@ public class TaskRequest { ...@@ -71,10 +67,10 @@ public class TaskRequest {
private Integer timeout; private Integer timeout;
@ApiModelProperty(value = "超时告警") @ApiModelProperty(value = "超时告警")
private TimeoutFlag timeoutFlag; private String timeoutFlag;
@ApiModelProperty(value = "超时通知策略") @ApiModelProperty(value = "超时通知策略")
private TaskTimeoutStrategy timeoutNotifyStrategy; private String timeoutNotifyStrategy;
@ApiModelProperty(value = "worker分组 默认default") @ApiModelProperty(value = "worker分组 默认default")
private String workerGroup = "default"; private String workerGroup = "default";
......
...@@ -36,6 +36,34 @@ export const DangerDeleteIcon = (props: any) => { ...@@ -36,6 +36,34 @@ export const DangerDeleteIcon = (props: any) => {
); );
}; };
export const PushpinIcon = (props: any) => {
return (
<>
<Icon
{...props}
style={{ ...IconStyle }}
component={() => (
<svg
className='icon'
viewBox='0 0 1293 1024'
version='1.1'
xmlns='http://www.w3.org/2000/svg'
>
<path
d='M304.061663 1024l-10.075639-558.583565 673.072886-298.727501 37.527055 84.565975-616.984683 273.834748 4.307805 239.256659 131.89401-166.298629 199.358866 217.963381L1116.921383 123.047108 189.774722 276.899361l105.06419 107.911966-66.293943 64.5448L0 214.595197 1293.252283 0l-552.497706 972.320793-211.935344-231.710773-224.75757 283.38998z'
fill='#1262B3'
></path>
<path
d='M304.061663 1024l-10.075639-558.583565 673.072886-298.727501 37.527055 84.565975-616.984683 273.834748 4.307805 239.256659 98.154354-123.769894 72.480992 57.490407-258.48277 325.933171z'
fill='#FF584D'
></path>
</svg>
)}
/>
</>
);
};
/** /**
* This is a custom icon that is used to indicate a show log action. * This is a custom icon that is used to indicate a show log action.
* @constructor * @constructor
......
...@@ -87,6 +87,33 @@ export default { ...@@ -87,6 +87,33 @@ export default {
'datastudio.middle.qg.gitprojects': 'Git Projects', 'datastudio.middle.qg.gitprojects': 'Git Projects',
'datastudio.middle.qg.resource': 'Resource', 'datastudio.middle.qg.resource': 'Resource',
'datastudio.middle.qg.udf': 'UDF', 'datastudio.middle.qg.udf': 'UDF',
'datastudio.header.pushdolphin.title': 'Push task [ {name} ] to DolphinScheduler',
'datastudio.header.pushdolphin.taskId': 'Dinky task encoding',
'datastudio.header.pushdolphin.taskName': 'Task name: {name}',
'datastudio.header.pushdolphin.taskNameExt':
'Task type: {type} Process definition: {processDefinitionName}',
'datastudio.header.pushdolphin.upstreamCodes': 'pre-task',
'datastudio.header.pushdolphin.upstreamCodesTip':
'After selecting the pre-task, the task will not be executed until the pre-task is successfully executed. Please choose wisely to avoid task circular dependencies. This platform does not do dependency checking',
'datastudio.header.pushdolphin.taskPriority': 'Task Priority',
'datastudio.header.pushdolphin.failRetryTimes': 'Number of retries',
'datastudio.header.pushdolphin.failRetryInterval': 'Failure retry interval (minutes)',
'datastudio.header.pushdolphin.failRetryIntervalPlaceholder':
'Please enter the failure retry interval (minutes)',
'datastudio.header.pushdolphin.delayTime': 'Delayed execution time (minutes)',
'datastudio.header.pushdolphin.delayTimePlaceholder':
'Please enter the delay execution time (minutes)',
'datastudio.header.pushdolphin.timeoutFlag': 'Timeout alarm',
'datastudio.header.pushdolphin.timeoutFlag.warn': 'Timeout warning',
'datastudio.header.pushdolphin.timeoutFlag.failed': 'Timeout failed',
'datastudio.header.pushdolphin.timeoutFlagTip': 'Please select a timeout warning',
'datastudio.header.pushdolphin.flag': 'Run flag',
'datastudio.header.pushdolphin.flagTip': 'Please select the run flag',
'datastudio.header.pushdolphin.timeoutNotifyStrategy': 'Timeout notification strategy',
'datastudio.header.pushdolphin.timeoutNotifyStrategyTip':
'Please select a timeout notification strategy',
'datastudio.header.pushdolphin.timeout': 'Timeout (minutes)',
'datastudio.header.pushdolphin.timeoutPlaceholder': 'Please enter the timeout time (minutes)',
'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': 'datastudio.project.create.folder.tip':
......
...@@ -82,6 +82,30 @@ export default { ...@@ -82,6 +82,30 @@ export default {
'datastudio.middle.qg.gitprojects': 'Git 项目', 'datastudio.middle.qg.gitprojects': 'Git 项目',
'datastudio.middle.qg.resource': '资源', 'datastudio.middle.qg.resource': '资源',
'datastudio.middle.qg.udf': 'UDF', 'datastudio.middle.qg.udf': 'UDF',
'datastudio.header.pushdolphin.title': '将任务 [ {name} ]推送至 DolphinScheduler',
'datastudio.header.pushdolphin.taskId': 'Dinky任务编码',
'datastudio.header.pushdolphin.taskName': 'Task名称: {name}',
'datastudio.header.pushdolphin.taskNameExt':
'Task类型: {type} 所属进程定义: {processDefinitionName}',
'datastudio.header.pushdolphin.upstreamCodes': '前置任务',
'datastudio.header.pushdolphin.upstreamCodesTip':
'选择前置任务后,任务将会在前置任务执行成功后才会执行,请合理选择,避免任务循环依赖,本平台不做依赖检查',
'datastudio.header.pushdolphin.taskPriority': '任务优先级',
'datastudio.header.pushdolphin.failRetryTimes': '重试次数',
'datastudio.header.pushdolphin.failRetryInterval': '失败重试间隔(分钟)',
'datastudio.header.pushdolphin.failRetryIntervalPlaceholder': '请输入失败重试间隔(分钟)',
'datastudio.header.pushdolphin.delayTime': '延时执行时间(分钟)',
'datastudio.header.pushdolphin.delayTimePlaceholder': '请输入延时执行时间(分钟)',
'datastudio.header.pushdolphin.timeoutFlag': '超时告警',
'datastudio.header.pushdolphin.timeoutFlag.warn': '超时告警',
'datastudio.header.pushdolphin.timeoutFlag.failed': '超时失败',
'datastudio.header.pushdolphin.timeoutFlagTip': '请选择超时警告',
'datastudio.header.pushdolphin.flag': '运行标志',
'datastudio.header.pushdolphin.flagTip': '请选择运行标志',
'datastudio.header.pushdolphin.timeoutNotifyStrategy': '超时通知策略',
'datastudio.header.pushdolphin.timeoutNotifyStrategyTip': '请选择超时通知策略',
'datastudio.header.pushdolphin.timeout': '超时时间(分钟)',
'datastudio.header.pushdolphin.timeoutPlaceholder': '请输入超时时间(分钟)',
'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.create.folder.tip': '暂无作业,请点击左上角新建目录',
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { l } from '@/utils/intl';
import { Badge, Space } from 'antd';
import { CheckboxOptionType } from 'antd/es/checkbox/Group';
import { DefaultOptionType } from 'antd/es/select';
/**
* priority list for select | 优先级列表
*/
export const PriorityList: DefaultOptionType[] = [
{
label: (
<Space>
<Badge color={'red'} />
Highest
</Space>
),
value: 'HIGHEST',
key: 'HIGHEST'
},
{
label: (
<Space>
<Badge color={'orange'} />
High
</Space>
),
value: 'HIGH',
key: 'HIGH'
},
{
label: (
<Space>
<Badge color={'blue'} />
Medium
</Space>
),
value: 'MEDIUM',
key: 'MEDIUM'
},
{
label: (
<Space>
<Badge color={'cyan'} />
Low
</Space>
),
value: 'LOW',
key: 'LOW'
},
{
label: (
<Space>
<Badge color={'purple'} />
Lowest
</Space>
),
value: 'LOWEST',
key: 'LOWEST'
}
];
export const TimeoutNotifyStrategy: CheckboxOptionType[] = [
{
label: l('datastudio.header.pushdolphin.timeoutFlag.warn'),
value: 'WARN'
},
{
label: l('datastudio.header.pushdolphin.timeoutFlag.failed'),
value: 'FAILED'
}
];
/*
*
* 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 { DolphinTaskDefinition, PushDolphinParams } from '@/types/Studio/data.d';
export const transformPushDolphinParams = (
dolphinTaskDefinition: DolphinTaskDefinition,
pushDolphinParams: PushDolphinParams,
toFormValues: boolean
) => {
if (toFormValues && dolphinTaskDefinition) {
const transformValue: PushDolphinParams = {
...pushDolphinParams,
description: dolphinTaskDefinition.description,
timeoutFlag: dolphinTaskDefinition.timeoutFlag === 'OPEN',
flag: dolphinTaskDefinition.flag === 'YES',
upstreamCodes: dolphinTaskDefinition.upstreamTaskMap
? Object.keys(dolphinTaskDefinition.upstreamTaskMap)
: [],
timeoutNotifyStrategy:
dolphinTaskDefinition.timeoutNotifyStrategy === 'WARNFAILED'
? ['WARN', 'FAILED']
: [dolphinTaskDefinition.timeoutNotifyStrategy]
};
return transformValue;
} else {
const falseTransformValue: DolphinTaskDefinition = {
...dolphinTaskDefinition,
...pushDolphinParams,
description: pushDolphinParams.description,
timeoutFlag: pushDolphinParams.timeoutFlag ? 'OPEN' : 'CLOSE',
flag: pushDolphinParams.flag ? 'YES' : 'NO',
timeoutNotifyStrategy: (pushDolphinParams.timeoutNotifyStrategy as string[]).join('')
};
return falseTransformValue;
}
};
/*
*
* 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 { FormContextValue } from '@/components/Context/FormContext';
import { NORMAL_MODAL_OPTIONS, SWITCH_OPTIONS } from '@/services/constants';
import { l } from '@/utils/intl';
import {
ModalForm,
ProFormCheckbox,
ProFormDigit,
ProFormGroup,
ProFormSelect,
ProFormSwitch,
ProFormText,
ProFormTextArea
} from '@ant-design/pro-components';
import {
PriorityList,
TimeoutNotifyStrategy
} from '@/pages/DataStudio/HeaderContainer/PushDolphin/constants';
import { transformPushDolphinParams } from '@/pages/DataStudio/HeaderContainer/PushDolphin/function';
import { TaskDataType } from '@/pages/DataStudio/model';
import {
DolphinTaskDefinition,
DolphinTaskMinInfo,
PushDolphinParams
} from '@/types/Studio/data.d';
import { InitPushDolphinParams } from '@/types/Studio/init.d';
import { Button, Form, Tag } from 'antd';
import { DefaultOptionType } from 'antd/es/select';
import React from 'react';
type PushDolphinProps = {
onCancel: () => void;
dolphinTaskList: DolphinTaskMinInfo[];
dolphinDefinitionTask: Partial<DolphinTaskDefinition>;
modalVisible: boolean;
currentDinkyTaskValue: Partial<TaskDataType>;
loading: boolean;
onSubmit: (values: DolphinTaskDefinition) => void;
};
export const PushDolphin: React.FC<PushDolphinProps> = (props) => {
const {
onCancel,
onSubmit,
modalVisible,
dolphinTaskList,
dolphinDefinitionTask,
currentDinkyTaskValue,
loading
} = props;
const [formValues, setFormValues] = React.useState<PushDolphinParams>(
transformPushDolphinParams(
dolphinDefinitionTask as DolphinTaskDefinition,
{ ...InitPushDolphinParams, taskId: currentDinkyTaskValue?.id ?? '' },
true
) as PushDolphinParams
);
/**
* init form
*/
const [form] = Form.useForm<PushDolphinParams>();
/**
* init form context
*/
const formContext = React.useMemo<FormContextValue>(
() => ({
resetForm: () => form.resetFields() // 定义 resetForm 方法
}),
[form]
);
/**
* cancel choose
*/
const handleCancel = () => {
onCancel();
formContext.resetForm();
};
const handlePushDolphinSubmit = async () => {
const values = form.validateFields();
if (!values) {
return;
}
const transformPushDolphinParamsValue: DolphinTaskDefinition = transformPushDolphinParams(
dolphinDefinitionTask as DolphinTaskDefinition,
formValues,
false
) as DolphinTaskDefinition;
onSubmit(transformPushDolphinParamsValue);
console.log('transformPushDolphinParamsValue', transformPushDolphinParamsValue);
};
const renderFooter = () => {
return [
<Button key={'pushCancel'} onClick={handleCancel}>
{l('button.cancel')}
</Button>,
<Button
key={'push'}
type='primary'
htmlType={'submit'}
loading={loading}
onClick={() => handlePushDolphinSubmit()}
>
{l('button.finish')}
</Button>
];
};
const buildUpstreamTaskOptions = (
data: DolphinTaskMinInfo[] | undefined
): DefaultOptionType[] => {
if (data && data.length > 0) {
return data.map((item) => {
const label = (
<>
<Tag color={'purple'}>
{l('datastudio.header.pushdolphin.taskName', '', { name: item.taskName })}
</Tag>
<span style={{ color: '#8a8a8a' }}>
{l('datastudio.header.pushdolphin.taskNameExt', '', {
type: item.taskType,
processDefinitionName: item.processDefinitionName
})}
</span>
</>
);
return {
label: label,
value: item.taskCode.toString(),
key: item.taskCode
};
});
}
return [];
};
const handleValueChange = (changedValues: any, allValues: any) => {
if (allValues) {
setFormValues({ ...formValues, ...allValues });
}
};
const pushDolphinForm = () => {
return (
<>
<ProFormText name={'taskId'} label={l('datastudio.header.pushdolphin.taskId')} disabled />
<ProFormSelect
label={l('datastudio.header.pushdolphin.upstreamCodes')}
name={'upstreamCodes'}
showSearch
mode={'multiple'}
extra={l('datastudio.header.pushdolphin.upstreamCodesTip')}
options={buildUpstreamTaskOptions(dolphinTaskList)}
/>
<ProFormGroup>
<ProFormSelect
label={l('datastudio.header.pushdolphin.taskPriority')}
name={'taskPriority'}
width={'sm'}
options={PriorityList}
/>
<ProFormDigit
label={l('datastudio.header.pushdolphin.failRetryTimes')}
name={'failRetryTimes'}
initialValue={formValues.failRetryTimes}
width={'sm'}
min={0}
max={99}
fieldProps={{
precision: 0
}}
/>
<ProFormDigit
label={l('datastudio.header.pushdolphin.failRetryInterval')}
name={'failRetryInterval'}
width={'sm'}
rules={[
{
required: true,
message: l('datastudio.header.pushdolphin.failRetryIntervalPlaceholder')
}
]}
min={0}
fieldProps={{
precision: 0
}}
/>
<ProFormDigit
label={l('datastudio.header.pushdolphin.delayTime')}
name={'delayTime'}
width={'sm'}
rules={[
{ required: true, message: l('datastudio.header.pushdolphin.delayTimePlaceholder') }
]}
min={0}
fieldProps={{
precision: 0
}}
/>
<ProFormSwitch
label={l('datastudio.header.pushdolphin.timeoutFlag')}
rules={[{ required: true, message: l('datastudio.header.pushdolphin.timeoutFlagTip') }]}
{...SWITCH_OPTIONS()}
name={'timeoutFlag'}
/>
<ProFormSwitch
label={l('datastudio.header.pushdolphin.flag')}
rules={[{ required: true, message: l('datastudio.header.pushdolphin.flagTip') }]}
{...SWITCH_OPTIONS()}
name={'flag'}
/>
</ProFormGroup>
{/*如果是失败告警,则需要设置告警策略*/}
{formValues.timeoutFlag && (
<>
<ProFormGroup>
<ProFormCheckbox.Group
label={l('datastudio.header.pushdolphin.timeoutNotifyStrategy')}
name={'timeoutNotifyStrategy'}
rules={[
{
required: true,
message: l('datastudio.header.pushdolphin.timeoutNotifyStrategyTip')
}
]}
width={'sm'}
options={TimeoutNotifyStrategy}
/>
<ProFormDigit
label={l('datastudio.header.pushdolphin.timeout')}
name={'timeout'}
width={'sm'}
rules={[
{ required: true, message: l('datastudio.header.pushdolphin.timeoutPlaceholder') }
]}
min={0}
max={30}
fieldProps={{
precision: 0
}}
/>
</ProFormGroup>
</>
)}
<ProFormTextArea label={l('global.table.note')} name={'description'} />
</>
);
};
return (
<ModalForm<PushDolphinParams>
{...NORMAL_MODAL_OPTIONS}
title={l('datastudio.header.pushdolphin.title', '', {
name: currentDinkyTaskValue?.name ?? ''
})}
open={modalVisible}
form={form}
initialValues={formValues}
modalProps={{
onCancel: handleCancel,
destroyOnClose: true
}}
submitter={{ render: () => [...renderFooter()] }}
onValuesChange={handleValueChange}
loading={loading}
>
{pushDolphinForm()}
</ModalForm>
);
};
export default PushDolphin;
...@@ -17,8 +17,10 @@ ...@@ -17,8 +17,10 @@
* *
*/ */
import { isSql } from '@/pages/DataStudio/HeaderContainer/service';
import { TabsPageType, TaskDataType } from '@/pages/DataStudio/model'; import { TabsPageType, TaskDataType } from '@/pages/DataStudio/model';
import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants'; import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants';
import { DIALECT } from '@/services/constants';
import { EnvironmentOutlined } from '@ant-design/icons'; import { EnvironmentOutlined } from '@ant-design/icons';
/** /**
...@@ -46,3 +48,14 @@ export const isOnline = (data: TaskDataType | undefined) => { ...@@ -46,3 +48,14 @@ export const isOnline = (data: TaskDataType | undefined) => {
export const isRunning = (data: TaskDataType | undefined) => { export const isRunning = (data: TaskDataType | undefined) => {
return data ? JOB_STATUS.RUNNING == data.status : false; return data ? JOB_STATUS.RUNNING == data.status : false;
}; };
export const isCanPushDolphin = (data: TaskDataType | undefined) => {
return data
? JOB_LIFE_CYCLE.PUBLISH === data.step &&
!isSql(data?.dialect) &&
data?.dialect?.toLowerCase() !== DIALECT.FLINKSQLENV &&
data?.dialect?.toLowerCase() !== DIALECT.SCALA &&
data?.dialect?.toLowerCase() !== DIALECT.JAVA &&
data?.dialect?.toLowerCase() !== DIALECT.PYTHON_LONG
: false;
};
...@@ -18,16 +18,19 @@ ...@@ -18,16 +18,19 @@
*/ */
import { LoadingBtn } from '@/components/CallBackButton/LoadingBtn'; import { LoadingBtn } from '@/components/CallBackButton/LoadingBtn';
import { PushpinIcon } from '@/components/Icons/CustomIcons';
import { FlexCenterDiv } from '@/components/StyledComponents'; import { FlexCenterDiv } from '@/components/StyledComponents';
import { getCurrentData, getCurrentTab, mapDispatchToProps } from '@/pages/DataStudio/function'; import { getCurrentData, getCurrentTab, mapDispatchToProps } from '@/pages/DataStudio/function';
import Explain from '@/pages/DataStudio/HeaderContainer/Explain'; import Explain from '@/pages/DataStudio/HeaderContainer/Explain';
import FlinkGraph from '@/pages/DataStudio/HeaderContainer/FlinkGraph'; import FlinkGraph from '@/pages/DataStudio/HeaderContainer/FlinkGraph';
import { import {
buildBreadcrumbItems, buildBreadcrumbItems,
isCanPushDolphin,
isOnline, isOnline,
isRunning, isRunning,
projectCommonShow projectCommonShow
} from '@/pages/DataStudio/HeaderContainer/function'; } from '@/pages/DataStudio/HeaderContainer/function';
import PushDolphin from '@/pages/DataStudio/HeaderContainer/PushDolphin';
import { import {
cancelTask, cancelTask,
changeTaskLife, changeTaskLife,
...@@ -36,16 +39,21 @@ import { ...@@ -36,16 +39,21 @@ import {
getJobPlan, getJobPlan,
isSql isSql
} from '@/pages/DataStudio/HeaderContainer/service'; } from '@/pages/DataStudio/HeaderContainer/service';
import { DataStudioTabsItemType, StateType, TabsPageType, VIEW } from '@/pages/DataStudio/model'; import {
DataStudioTabsItemType,
StateType,
TabsPageType,
TaskDataType,
VIEW
} from '@/pages/DataStudio/model';
import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants'; import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants';
import { ConfigStateType } from '@/pages/SettingCenter/GlobalSetting/model'; import { SysConfigStateType } from '@/pages/SettingCenter/GlobalSetting/model';
import { SettingConfigKeyEnum } from '@/pages/SettingCenter/GlobalSetting/SettingOverView/constants'; import { SettingConfigKeyEnum } from '@/pages/SettingCenter/GlobalSetting/SettingOverView/constants';
import { handlePutDataJson } from '@/services/BusinessCrud'; import { handleOption, handlePutDataJson, queryDataByParams } from '@/services/BusinessCrud';
import { DIALECT } from '@/services/constants'; import { DIALECT } from '@/services/constants';
import { BaseConfigProperties } from '@/types/SettingCenter/data'; import { DolphinTaskDefinition, DolphinTaskMinInfo } from '@/types/Studio/data.d';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { SuccessMessageAsync } from '@/utils/messages'; import { SuccessMessageAsync } from '@/utils/messages';
import { connect } from '@@/exports';
import { import {
ApartmentOutlined, ApartmentOutlined,
BugOutlined, BugOutlined,
...@@ -57,9 +65,9 @@ import { ...@@ -57,9 +65,9 @@ import {
PauseOutlined, PauseOutlined,
RotateRightOutlined, RotateRightOutlined,
SaveOutlined, SaveOutlined,
ScheduleOutlined, ScheduleOutlined
SendOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
import { connect } from '@umijs/max';
import { Breadcrumb, Descriptions, Modal, Space } from 'antd'; import { Breadcrumb, Descriptions, Modal, Space } from 'antd';
import { ButtonProps } from 'antd/es/button/button'; import { ButtonProps } from 'antd/es/button/button';
import React, { memo, useEffect, useState } from 'react'; import React, { memo, useEffect, useState } from 'react';
...@@ -84,7 +92,7 @@ type ButtonRoute = { ...@@ -84,7 +92,7 @@ type ButtonRoute = {
props?: ButtonProps; props?: ButtonProps;
}; };
const HeaderContainer = (props: any) => { const HeaderContainer = (props: connect) => {
const { const {
size, size,
activeBreadcrumbTitle, activeBreadcrumbTitle,
...@@ -92,26 +100,66 @@ const HeaderContainer = (props: any) => { ...@@ -92,26 +100,66 @@ const HeaderContainer = (props: any) => {
saveTabs, saveTabs,
updateJobRunningMsg, updateJobRunningMsg,
queryDsConfig, queryDsConfig,
dsConfig enabledDs
} = props; } = props;
const [modal, contextHolder] = Modal.useModal(); const [modal, contextHolder] = Modal.useModal();
// 检查是否开启 ds 配置 & 如果 const [pushDolphinState, setPushDolphinState] = useState<{
const [enableDs] = useState<boolean>( modalVisible: boolean;
dsConfig.some( buttonLoading: boolean;
(item: BaseConfigProperties) => confirmLoading: boolean;
item.key === 'dolphinscheduler.settings.enable' && item.value === 'true' dolphinTaskList: DolphinTaskMinInfo[];
) dolphinDefinitionTask: Partial<DolphinTaskDefinition>;
); currentDinkyTaskValue: Partial<TaskDataType>;
}>({
const currentData = getCurrentData(panes, activeKey); modalVisible: false,
const currentTab = getCurrentTab(panes, activeKey) as DataStudioTabsItemType; buttonLoading: false,
confirmLoading: false,
dolphinTaskList: [],
dolphinDefinitionTask: {},
currentDinkyTaskValue: {}
});
useEffect(() => { useEffect(() => {
queryDsConfig(SettingConfigKeyEnum.DOLPHIN_SCHEDULER.toLowerCase()); queryDsConfig(SettingConfigKeyEnum.DOLPHIN_SCHEDULER.toLowerCase());
}, []); }, []);
const currentData = getCurrentData(panes, activeKey);
const currentTab = getCurrentTab(panes, activeKey) as DataStudioTabsItemType;
const handlePushDolphinOpen = async () => {
const dinkyTaskId = currentData?.id;
const dolphinTaskList: DolphinTaskMinInfo[] | undefined = await queryDataByParams<
DolphinTaskMinInfo[]
>('/api/scheduler/queryUpstreamTasks', { dinkyTaskId });
const dolphinTaskDefinition: DolphinTaskDefinition | undefined =
await queryDataByParams<DolphinTaskDefinition>('/api/scheduler/queryTaskDefinition', {
dinkyTaskId
});
setPushDolphinState((prevState) => ({
...prevState,
buttonLoading: true,
confirmLoading: false,
modalVisible: true,
dolphinTaskList: dolphinTaskList ?? [],
dolphinDefinitionTask: dolphinTaskDefinition ?? {},
currentDinkyTaskValue: currentData as TaskDataType
}));
};
const handlePushDolphinCancel = async () => {
setPushDolphinState((prevState) => ({
...prevState,
modalVisible: false,
buttonLoading: false,
dolphinTaskList: [],
confirmLoading: false,
dolphinDefinitionTask: {},
currentDinkyTaskValue: {}
}));
};
const handleSave = async () => { const handleSave = async () => {
const saved = await handlePutDataJson('/api/task', currentData); const saved = await handlePutDataJson('/api/task', currentData);
saveTabs({ ...props.tabs }); saveTabs({ ...props.tabs });
...@@ -271,10 +319,11 @@ const HeaderContainer = (props: any) => { ...@@ -271,10 +319,11 @@ const HeaderContainer = (props: any) => {
}, },
{ {
// 推送海豚, 此处需要将系统设置中的 ds 的配置拿出来做判断 启用才展示 // 推送海豚, 此处需要将系统设置中的 ds 的配置拿出来做判断 启用才展示
icon: <SendOutlined className={'blue-icon'} />, icon: <PushpinIcon loading={pushDolphinState.buttonLoading} className={'blue-icon'} />,
title: l('button.push'), title: l('button.push'),
hotKey: (e: KeyboardEvent) => e.ctrlKey && e.key === 's', hotKey: (e: KeyboardEvent) => e.ctrlKey && e.key === 's',
isShow: enableDs isShow: enabledDs && isCanPushDolphin(currentData),
click: () => handlePushDolphinOpen()
}, },
{ {
// 发布按钮 // 发布按钮
...@@ -417,6 +466,16 @@ const HeaderContainer = (props: any) => { ...@@ -417,6 +466,16 @@ const HeaderContainer = (props: any) => {
); );
}; };
const handlePushDolphinSubmit = async (value: DolphinTaskDefinition) => {
setPushDolphinState((prevState) => ({ ...prevState, loading: true }));
await handleOption(
'/api/scheduler/createOrUpdateTaskDefinition',
`推送任务[${currentData?.name}]至 DolphinScheduler`,
value
);
await handlePushDolphinCancel();
};
/** /**
* render * render
*/ */
...@@ -425,15 +484,27 @@ const HeaderContainer = (props: any) => { ...@@ -425,15 +484,27 @@ const HeaderContainer = (props: any) => {
<Descriptions.Item>{renderBreadcrumbItems()}</Descriptions.Item> <Descriptions.Item>{renderBreadcrumbItems()}</Descriptions.Item>
<Descriptions.Item contentStyle={{ display: 'flex', flexDirection: 'row-reverse' }}> <Descriptions.Item contentStyle={{ display: 'flex', flexDirection: 'row-reverse' }}>
{renderRightButtons()} {renderRightButtons()}
{pushDolphinState.modalVisible && (
<PushDolphin
onCancel={() => handlePushDolphinCancel()}
currentDinkyTaskValue={pushDolphinState.currentDinkyTaskValue}
modalVisible={pushDolphinState.modalVisible}
loading={pushDolphinState.confirmLoading}
dolphinDefinitionTask={pushDolphinState.dolphinDefinitionTask}
dolphinTaskList={pushDolphinState.dolphinTaskList}
onSubmit={(values) => handlePushDolphinSubmit(values)}
/>
)}
</Descriptions.Item> </Descriptions.Item>
</Descriptions> </Descriptions>
); );
}; };
export default connect( export default connect(
({ Studio, Config }: { Studio: StateType; Config: ConfigStateType }) => ({ ({ Studio, SysConfig }: { Studio: StateType; SysConfig: SysConfigStateType }) => ({
tabs: Studio.tabs, tabs: Studio.tabs,
dsConfig: Config.dsConfig dsConfig: SysConfig.dsConfig,
enabledDs: SysConfig.enabledDs
}), }),
mapDispatchToProps mapDispatchToProps
)(memo(HeaderContainer)); )(memo(HeaderContainer));
...@@ -23,25 +23,30 @@ import { createModelTypes } from '@/utils/modelUtils'; ...@@ -23,25 +23,30 @@ import { createModelTypes } from '@/utils/modelUtils';
import { Effect } from '@@/plugin-dva/types'; import { Effect } from '@@/plugin-dva/types';
import { Reducer } from 'umi'; import { Reducer } from 'umi';
export type ConfigStateType = { const SYS_CONFIG = 'SysConfig';
export type SysConfigStateType = {
dsConfig: BaseConfigProperties[]; dsConfig: BaseConfigProperties[];
enabledDs: boolean;
}; };
export type ConfigModelType = { export type ConfigModelType = {
namespace: string; namespace: string;
state: ConfigStateType; state: SysConfigStateType;
effects: { effects: {
queryDsConfig: Effect; queryDsConfig: Effect;
}; };
reducers: { reducers: {
saveDsConfig: Reducer<ConfigStateType>; saveDsConfig: Reducer<SysConfigStateType>;
updateEnabledDs: Reducer<SysConfigStateType>;
}; };
}; };
const ConfigModel: ConfigModelType = { const ConfigModel: ConfigModelType = {
namespace: 'Config', namespace: SYS_CONFIG,
state: { state: {
dsConfig: [] dsConfig: [],
enabledDs: false
}, },
effects: { effects: {
...@@ -51,6 +56,16 @@ const ConfigModel: ConfigModelType = { ...@@ -51,6 +56,16 @@ const ConfigModel: ConfigModelType = {
type: 'saveDsConfig', type: 'saveDsConfig',
payload: response || [] payload: response || []
}); });
if (response && response.length > 0) {
const enabledDs = response.some(
(item: BaseConfigProperties) =>
item.key === 'sys.dolphinscheduler.settings.enable' && item.value === true
);
yield put({
type: 'updateEnabledDs',
payload: enabledDs
});
}
} }
}, },
...@@ -60,6 +75,12 @@ const ConfigModel: ConfigModelType = { ...@@ -60,6 +75,12 @@ const ConfigModel: ConfigModelType = {
...state, ...state,
dsConfig: payload dsConfig: payload
}; };
},
updateEnabledDs(state, { payload }) {
return {
...state,
enabledDs: payload
};
} }
} }
}; };
......
...@@ -228,3 +228,83 @@ export enum JobStatus { ...@@ -228,3 +228,83 @@ export enum JobStatus {
RECONNECTING = 'RECONNECTING', RECONNECTING = 'RECONNECTING',
UNKNOWN = 'UNKNOWN' UNKNOWN = 'UNKNOWN'
} }
/**
* DolphinTaskMinInfo
*/
export interface DolphinTaskMinInfo {
id: number;
taskName: string;
taskCode: number;
taskVersion: number;
taskType: string;
taskCreateTime: Date;
taskUpdateTime: Date;
processDefinitionCode: number;
processDefinitionVersion: number;
processDefinitionName: string;
processReleaseState: string;
upstreamTaskMap: Map<number, string>;
upstreamTaskCode: number;
upstreamTaskName: string;
}
export interface TaskParamProperty {
prop: string;
direct: string;
type: string;
value: string;
}
export interface DolphinTaskDefinition {
id: number;
code: number;
name: string;
version: number;
description: string;
projectCode: number;
userId: number;
taskType: string;
taskParams: Map<string, string>;
taskParamList: TaskParamProperty[];
taskParamMap: Map<string, string>;
flag: string; // 0 no 1 yes
taskPriority: string; // 0 highest 1 high 2 medium 3 low 4 lowest
userName: string;
projectName: string;
workerGroup: string;
environmentCode: number;
failRetryTimes: number;
failRetryInterval: number;
timeoutFlag: string; // 0 close 1 open
timeoutNotifyStrategy: string; // 0 warning 1 failure 2 warning and failure
timeout: number;
delayTime: number;
resourceIds: string;
createTime: Date;
updateTime: Date;
modifyBy: string;
taskGroupId: number;
taskGroupPriority: number;
cpuQuota: number;
memoryMax: number;
taskExecuteType: number; // 0 batch 1 stream
processDefinitionCode: number;
processDefinitionVersion: number;
processDefinitionName: string;
upstreamTaskMap: Map<number, string>;
}
export interface PushDolphinParams {
taskId: number | string;
upstreamCodes: string[];
taskPriority: string;
failRetryTimes: number;
failRetryInterval: number;
delayTime: number;
timeout: number;
timeoutFlag: boolean | string;
flag: boolean | string;
timeoutNotifyStrategy: string[] | string;
description: string;
}
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
*/ */
import { InitContextMenuPosition } from '@/types/Public/state.d'; import { InitContextMenuPosition } from '@/types/Public/state.d';
import { ProjectState } from '@/types/Studio/state.d'; import { PushDolphinParams } from '@/types/Studio/data';
import { CateLogState, ProjectState } from '@/types/Studio/state.d';
export const InitProjectState: ProjectState = { export const InitProjectState: ProjectState = {
rightActiveKey: '', rightActiveKey: '',
...@@ -36,3 +37,34 @@ export const InitProjectState: ProjectState = { ...@@ -36,3 +37,34 @@ export const InitProjectState: ProjectState = {
isCut: false, isCut: false,
value: {} value: {}
}; };
export const InitPushDolphinParams: PushDolphinParams = {
taskId: '',
upstreamCodes: [],
taskPriority: 'MEDIUM',
failRetryTimes: 0,
failRetryInterval: 0,
delayTime: 0,
timeout: 30,
timeoutFlag: false,
flag: false,
timeoutNotifyStrategy: ['WARN'],
description: ''
};
export const InitCateLogState: CateLogState = {
catalog: '',
catalogSelect: [],
databaseName: '',
databaseId: -1,
tableName: '',
dialect: '',
fragment: true,
envId: -1,
engine: 'Flink',
treeData: [],
modalVisit: false,
rowData: {},
loading: false,
columnData: []
};
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