Skip to content

Commit

Permalink
feature: refactor ws_di_job
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqi committed Feb 21, 2024
1 parent d9ed27a commit 6dc9fa4
Show file tree
Hide file tree
Showing 16 changed files with 469 additions and 313 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public ResponseEntity<WsArtifactSeaTunnelDTO> selectOne(@PathVariable("id") Long
@Logging
@PutMapping
@Operation(summary = "新增 seatunnel", description = "新增 seatunnel")
public ResponseEntity<ResponseVO> insert(@RequestBody @Valid WsArtifactSeaTunnelAddParam param) {
wsArtifactSeaTunnelService.insert(param);
return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK);
public ResponseEntity<ResponseVO<WsArtifactSeaTunnelDTO>> insert(@RequestBody @Valid WsArtifactSeaTunnelAddParam param) {
WsArtifactSeaTunnelDTO dto = wsArtifactSeaTunnelService.insert(param);
return new ResponseEntity<>(ResponseVO.success(dto), HttpStatus.OK);
}

@Logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public static SeaTunnelVersion of(String value) {
.findAny().orElseThrow(() -> new EnumConstantNotPresentException(SeaTunnelVersion.class, value));
}

public static SeaTunnelVersion current() {
return values()[values().length - 1];
}

@EnumValue
private String value;
private String label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package cn.sliew.scaleph.dag.service.dto;

import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

Expand All @@ -31,12 +30,6 @@
@Schema(name = "Dag", description = "DAG")
public class DagDTO extends DagInstanceDTO {

@Schema(description = "元数据")
private JsonNode dagMeta;

@Schema(description = "属性")
private JsonNode dagAttrs;

@Schema(description = "连线")
private List<DagLinkDTO> links;

Expand Down
5 changes: 3 additions & 2 deletions scaleph-ui-react2/src/locales/zh-CN/pages/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ export default {
'pages.project.artifact.sql': 'SQL',

'pages.project.artifact.seatunnel': 'SeaTunnel',
'pages.project.artifact.seatunnel.jobEngine': 'Engine',
'pages.project.artifact.seatunnel.seaTunnelEngine': 'Engine',
'pages.project.artifact.seatunnel.seaTunnelVersion': 'SeaTunnel 版本',
'pages.project.artifact.cdc': 'CDC',
'pages.project.artifact.cdc.flinkCDCVersion': 'Flink CDC Version',
'pages.project.artifact.cdc.flinkCDCVersion': 'Flink CDC 版本',

'pages.project.job.jar': 'Jar',
'pages.project.job.jar.args': 'Main Args',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, {useEffect, useState} from 'react';
import {Tree} from 'antd';
import SearchInput from './search';
import {Props} from "@/typings";
import {WsDiJob} from "@/services/project/typings";
import {WsSeaTunnelService} from "@/services/project/SeaTunnelService";
import {WsArtifactSeaTunnel, WsDiJob} from "@/services/project/typings";
import {WsArtifactSeaTunnelService} from "@/services/project/WsArtifactSeaTunnelService";
import styles from './dnd.less';
import {DndNode} from "../node/dnd-node";

Expand All @@ -22,12 +22,12 @@ type ComponentTreeItem = {
}[];
};

const Dnd: React.FC<Props<WsDiJob>> = ({data}) => {
const Dnd: React.FC<Props<WsArtifactSeaTunnel>> = ({data}) => {
const [treeItems, setTreeItems] = useState<ComponentTreeItem[]>([]);
const [searchComponents, setSearchComponents] = useState<ComponentTreeItem[]>([]);

useEffect(() => {
WsSeaTunnelService.getDnds(data.jobEngine?.value).then((response) => {
WsArtifactSeaTunnelService.getDnds(data.seaTunnelEngine?.value).then((response) => {
if (response.success) {
setTreeItems(response.data)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import {Menubar} from "@antv/x6-react-components";
import {JSONDebugModal} from "@/pages/Project/Workspace/Artifact/DI/DiJobFlow/Dag/menubar/json";
import {SeaTunnelConfModal} from "@/pages/Project/Workspace/Artifact/DI/DiJobFlow/Dag/menubar/seatunnel";
import {Props} from "@/typings";
import {WsDiJob, WsDiJobGraphParam} from "@/services/project/typings";
import {WsArtifactSeaTunnel, WsArtifactSeaTunnelGraphParam, WsDiJob} from "@/services/project/typings";
import {WsDiJobService} from "@/services/project/WsDiJobService";
import {WsArtifactSeaTunnelService} from "@/services/project/WsArtifactSeaTunnelService";

const CustomMenubar: React.FC<Props<WsDiJob>> = ({data}) => {
const CustomMenubar: React.FC<Props<WsArtifactSeaTunnel>> = ({data}) => {
const intl = useIntl();
const graph = useGraphInstance();
const nodes = useGraphStore((state) => state.nodes);
Expand Down Expand Up @@ -54,14 +55,14 @@ const CustomMenubar: React.FC<Props<WsDiJob>> = ({data}) => {
};

const onSave = () => {
let param: WsDiJobGraphParam = {
jobId: data.id,
let param: WsArtifactSeaTunnelGraphParam = {
id: data.id,
jobGraph: {
nodes: nodes,
edges: edges,
}
}
WsDiJobService.saveJobDetail(param)
WsArtifactSeaTunnelService.updateGraph(param)
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import React, {useEffect, useRef, useState} from 'react';
import {Drawer} from "antd";
import Editor, {useMonaco} from "@monaco-editor/react";
import {ModalFormProps} from "@/typings";
import {WsDiJob} from "@/services/project/typings";
import {WsArtifactSeaTunnel} from "@/services/project/typings";
import {WsDiJobService} from "@/services/project/WsDiJobService";

const SeaTunnelConfModal: React.FC<ModalFormProps<WsDiJob>> = ({visible, onVisibleChange, onCancel, data}) => {
const SeaTunnelConfModal: React.FC<ModalFormProps<WsArtifactSeaTunnel>> = ({
visible,
onVisibleChange,
onCancel,
data
}) => {
const editorRef = useRef(null);
const monaco = useMonaco();
const [conf, setConf] = useState<string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {useIntl} from '@umijs/max';
import {useGraphStore} from '@antv/xflow';
import {EdgeOptions, NodeOptions} from "@antv/xflow/src/types";
import {Props} from "@/typings";
import {WsDiJob} from "@/services/project/typings";
import {WsDiJobService} from "@/services/project/WsDiJobService";
import {WsArtifactSeaTunnel} from "@/services/project/typings";
import {DAG_EDGE, DAG_NODE} from './canvas-node';
import {WsArtifactSeaTunnelService} from "@/services/project/WsArtifactSeaTunnelService";

const titleCase = (title: string) => {
let tmpStrArr: string[] = title.split(' ');
Expand All @@ -15,48 +15,48 @@ const titleCase = (title: string) => {
return tmpStrArr.join(' ');
}

const InitShape: React.FC<Props<WsDiJob>> = ({data}) => {
const InitShape: React.FC<Props<WsArtifactSeaTunnel>> = ({data}) => {
const intl = useIntl()
const addNodes = useGraphStore((state) => state.addNodes);
const addEdges = useGraphStore((state) => state.addEdges);

useEffect(() => {
WsDiJobService.selectJobById(data.id).then((response) => {
WsArtifactSeaTunnelService.selectOne(data.id).then((response) => {
let jobInfo = response;
let nodes: NodeOptions[] = [];
let edges: EdgeOptions[] = [];
jobInfo.jobStepList?.map((step) => {
jobInfo.dag?.steps?.map((step) => {
nodes.push({
id: step.stepCode,
id: step.stepId,
shape: DAG_NODE,
view: "react-shape-view",
position: {
x: step.positionX,
y: step.positionY
},
ports: {
items: createItems(step.stepMeta.type as string, step.stepCode)
items: createItems(step.stepMeta?.type as string, step.stepId)
},
data: {
label: step.stepTitle,
label: step.stepName,
meta: step.stepMeta,
attrs: step.stepAttrs
},
});
});
addNodes(nodes)

jobInfo.jobLinkList?.map((link) => {
jobInfo.dag?.links?.map((link) => {
edges.push({
id: link.linkCode,
id: link.linkId,
shape: DAG_EDGE,
source: {
cell: link.fromStepCode,
port: link.fromStepCode + '-bottom'
cell: link.fromStepId,
port: link.fromStepId + '-bottom'
},
target: {
cell: link.toStepCode,
port: link.fromStepCode + '-top',
cell: link.toStepId,
port: link.toStepId + '-top',
},
zIndex: -1
});
Expand Down Expand Up @@ -93,91 +93,91 @@ const InitShape: React.FC<Props<WsDiJob>> = ({data}) => {
}

const createGroups = (type: string, name: string) => {
if (type === 'source') {
return {
top: {
position: "top",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
if (type === 'source') {
return {
top: {
position: "top",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
}
}
}
},
bottom: {
position: "bottom",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
},
bottom: {
position: "bottom",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
}
}
}
}
}
} else if (type === 'sink') {
return {
top: {
position: "top",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
} else if (type === 'sink') {
return {
top: {
position: "top",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
}
}
}
},
bottom: {
position: "bottom",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
},
bottom: {
position: "bottom",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
}
}
}
}
}
} else if (type === 'transform') {
return {
top: {
position: "top",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
} else if (type === 'transform') {
return {
top: {
position: "top",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
}
}
}
},
bottom: {
position: "bottom",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
},
bottom: {
position: "bottom",
attrs: {
circle: {
r: 4,
magnet: true,
stroke: '#C2C8D5',
strokeWidth: 1,
fill: "#fff"
}
}
}
}
} else {
return []
}
} else {
return []
}
}
return null;
}
;
Expand Down
Loading

0 comments on commit 6dc9fa4

Please sign in to comment.