ronds-metadata 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/comps/DynamicPorts/comps/ContextMenu.css +8 -0
- package/es/comps/DynamicPorts/comps/ContextMenu.d.ts +7 -0
- package/es/comps/DynamicPorts/comps/ContextMenu.js +44 -0
- package/es/comps/DynamicPorts/comps/DragNode.d.ts +7 -0
- package/es/comps/DynamicPorts/comps/DragNode.js +49 -0
- package/es/comps/DynamicPorts/comps/GraphHandler/index.css +27 -0
- package/es/comps/DynamicPorts/comps/GraphHandler/index.d.ts +11 -0
- package/es/comps/DynamicPorts/comps/GraphHandler/index.js +50 -0
- package/es/comps/DynamicPorts/comps/NodeElement.js +1 -1
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.css +5 -0
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.d.ts +8 -0
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +42 -0
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.css +21 -0
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.d.ts +8 -0
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +40 -0
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.css +23 -0
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.d.ts +7 -0
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +55 -0
- package/es/comps/DynamicPorts/comps/shape/node.js +1 -1
- package/es/comps/DynamicPorts/constant/index.d.ts +2 -2
- package/es/comps/DynamicPorts/constant/index.js +3 -3
- package/es/comps/DynamicPorts/graph.d.ts +62 -0
- package/es/comps/DynamicPorts/graph.js +584 -0
- package/es/comps/DynamicPorts/index.css +23 -15
- package/es/comps/DynamicPorts/index.d.ts +16 -1
- package/es/comps/DynamicPorts/index.js +122 -168
- package/es/comps/DynamicPorts/interface.d.ts +34 -0
- package/es/comps/DynamicPorts/interface.js +6 -0
- package/es/comps/DynamicPorts/utils.d.ts +100 -0
- package/es/comps/DynamicPorts/utils.js +127 -0
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +63 -25
- package/es/comps/MetadataForm/utils.d.ts +1 -0
- package/es/comps/MetadataForm/utils.js +10 -1
- package/es/framework/graph/index.css +12 -0
- package/es/framework/graph/index.d.ts +60 -1
- package/es/framework/graph/index.js +425 -0
- package/es/framework/rxjs-hooks/useObservableState.d.ts +3 -0
- package/es/framework/rxjs-hooks/useObservableState.js +45 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/package.json +5 -1
@@ -1,187 +1,141 @@
|
|
1
|
-
import "
|
2
|
-
import
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
3
3
|
|
4
4
|
/*
|
5
5
|
* @Author: wangxian
|
6
6
|
* @Date: 2022-05-16 18:53:31
|
7
|
-
* @LastEditTime: 2022-05-
|
7
|
+
* @LastEditTime: 2022-05-27 14:24:06
|
8
8
|
*/
|
9
|
-
import { Graph, Markup } from '@antv/x6';
|
10
9
|
import React from 'react';
|
11
|
-
import
|
12
|
-
import {
|
13
|
-
import { DPNode } from './comps/shape/node';
|
14
|
-
import ReactDOM from 'react-dom';
|
10
|
+
import { filter } from 'rxjs';
|
11
|
+
import { useDrop } from 'react-dnd';
|
15
12
|
import "./index.css";
|
16
13
|
import './comps/shape/connector';
|
14
|
+
import { useDPGraph, useUnmountDPGraph } from './graph';
|
15
|
+
import { DRAGGABLE_COMPONENT, DRAGGABLE_MODEL } from './constant';
|
16
|
+
import { guid } from '../../utils';
|
17
|
+
import ContextMenu from './comps/ContextMenu';
|
18
|
+
import { GraphHandler } from './comps/GraphHandler';
|
17
19
|
|
18
|
-
var DynamicPorts = function DynamicPorts() {
|
20
|
+
var DynamicPorts = function DynamicPorts(props) {
|
21
|
+
var defaultValue = props.defaultValue,
|
22
|
+
onChange = props.onChange,
|
23
|
+
onNodeSelect = props.onNodeSelect;
|
19
24
|
var divRef = React.useRef(null);
|
25
|
+
var containerRef = React.useRef(null);
|
26
|
+
|
27
|
+
var _React$useState = React.useState(),
|
28
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
29
|
+
dpGraph = _React$useState2[0],
|
30
|
+
setGraph = _React$useState2[1];
|
31
|
+
|
32
|
+
var dpGraphRef = React.useRef();
|
33
|
+
var firstLoadRef = React.useRef(true); // 处理画布卸载
|
34
|
+
|
35
|
+
useUnmountDPGraph(); // 渲染画布
|
36
|
+
|
20
37
|
React.useEffect(function () {
|
21
|
-
if (
|
22
|
-
var
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}
|
38
|
+
if (firstLoadRef.current) {
|
39
|
+
var _dpGraph = useDPGraph(defaultValue);
|
40
|
+
|
41
|
+
dpGraphRef.current = _dpGraph;
|
42
|
+
setGraph(_dpGraph);
|
43
|
+
|
44
|
+
_dpGraph.renderGraph(containerRef.current, divRef.current); // 获取图信息的订阅
|
45
|
+
|
46
|
+
|
47
|
+
_dpGraph.factory$.dpGraph.pipe(filter(function (x) {
|
48
|
+
return !!x;
|
49
|
+
})).subscribe(function (v) {
|
50
|
+
onChange && onChange(v);
|
51
|
+
}); // 获取选中节点的订阅
|
52
|
+
|
53
|
+
|
54
|
+
_dpGraph.factory$.selectedNodes.subscribe(function (v) {
|
55
|
+
onNodeSelect && onNodeSelect(v[0]);
|
40
56
|
});
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
}
|
67
|
-
graph.addNode(new DPNode({
|
68
|
-
id: '2',
|
69
|
-
x: 300,
|
70
|
-
y: 35,
|
71
|
-
ports: {
|
72
|
-
items: [{
|
73
|
-
group: 'in',
|
74
|
-
id: 'in1',
|
75
|
-
connected: true
|
76
|
-
}, {
|
77
|
-
group: 'in',
|
78
|
-
id: 'in2'
|
79
|
-
}, {
|
80
|
-
group: 'out',
|
81
|
-
id: 'out1'
|
82
|
-
}, {
|
83
|
-
group: 'out',
|
84
|
-
id: 'out2'
|
85
|
-
}]
|
86
|
-
},
|
87
|
-
data: {
|
88
|
-
id: '2',
|
89
|
-
name: 'Kafka数据源'
|
90
|
-
},
|
91
|
-
shape: 'rz-rect-port',
|
92
|
-
component: /*#__PURE__*/React.createElement(NodeElement, null)
|
93
|
-
}));
|
94
|
-
graph.addEdge(new DPGroupEdge({
|
95
|
-
sourceAnchor: 'bottom',
|
96
|
-
source: {
|
97
|
-
cell: '1',
|
98
|
-
port: 'out11',
|
99
|
-
anchor: {
|
100
|
-
name: 'bottom'
|
101
|
-
}
|
102
|
-
},
|
103
|
-
target: {
|
104
|
-
cell: '2',
|
105
|
-
port: 'in1',
|
106
|
-
anchor: {
|
107
|
-
name: 'center'
|
108
|
-
}
|
109
|
-
},
|
110
|
-
zIndex: 1
|
111
|
-
}));
|
57
|
+
|
58
|
+
firstLoadRef.current = false;
|
59
|
+
}
|
60
|
+
}, []); // 处理组件拖拽落下事件
|
61
|
+
|
62
|
+
var _useDrop = useDrop({
|
63
|
+
accept: [DRAGGABLE_COMPONENT, DRAGGABLE_MODEL],
|
64
|
+
drop: function drop(item, monitor) {
|
65
|
+
var currentMouseOffset = monitor.getClientOffset();
|
66
|
+
var sourceMouseOffset = monitor.getInitialClientOffset();
|
67
|
+
var sourceElementOffset = monitor.getInitialSourceClientOffset();
|
68
|
+
var diffX = sourceMouseOffset.x - sourceElementOffset.x;
|
69
|
+
var diffY = sourceMouseOffset.y - sourceElementOffset.y;
|
70
|
+
var x = currentMouseOffset.x - diffX;
|
71
|
+
var y = currentMouseOffset.y - diffY;
|
72
|
+
|
73
|
+
if (dpGraphRef.current.isGraphReady()) {
|
74
|
+
dpGraphRef.current.addDragNode(_objectSpread(_objectSpread({}, item.comp), {}, {
|
75
|
+
libId: item.comp.id,
|
76
|
+
id: guid(),
|
77
|
+
x: x,
|
78
|
+
y: y
|
79
|
+
}));
|
80
|
+
} else {
|
81
|
+
console.warn('请稍后再尝试添加节点');
|
82
|
+
}
|
112
83
|
}
|
113
|
-
},
|
84
|
+
}),
|
85
|
+
_useDrop2 = _slicedToArray(_useDrop, 2),
|
86
|
+
dropRef = _useDrop2[1]; // 画布侧边 toolbar handler
|
87
|
+
|
88
|
+
|
89
|
+
var onHandleSideToolbar = React.useCallback(function (action) {
|
90
|
+
return function () {
|
91
|
+
// 确保画布已渲染
|
92
|
+
if (dpGraphRef.current.isGraphReady()) {
|
93
|
+
switch (action) {
|
94
|
+
case 'in':
|
95
|
+
dpGraphRef.current.zoomGraph(0.1);
|
96
|
+
break;
|
97
|
+
|
98
|
+
case 'out':
|
99
|
+
dpGraphRef.current.zoomGraph(-0.1);
|
100
|
+
break;
|
101
|
+
|
102
|
+
case 'fit':
|
103
|
+
dpGraphRef.current.zoomGraphToFit();
|
104
|
+
break;
|
105
|
+
|
106
|
+
case 'real':
|
107
|
+
dpGraphRef.current.zoomGraphRealSize();
|
108
|
+
break;
|
109
|
+
|
110
|
+
default:
|
111
|
+
}
|
112
|
+
}
|
113
|
+
};
|
114
|
+
}, [dpGraph]);
|
114
115
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
116
|
+
ref: function ref(elem) {
|
117
|
+
containerRef.current = elem;
|
118
|
+
dropRef(elem);
|
119
|
+
},
|
120
|
+
className: "dynamic-ports",
|
121
|
+
style: {
|
122
|
+
height: '100%',
|
123
|
+
width: '100%'
|
124
|
+
}
|
125
|
+
}, /*#__PURE__*/React.createElement(ContextMenu, {
|
126
|
+
graph: dpGraph
|
127
|
+
}), /*#__PURE__*/React.createElement(GraphHandler, {
|
128
|
+
onZoomIn: onHandleSideToolbar('in'),
|
129
|
+
onZoomOut: onHandleSideToolbar('out'),
|
130
|
+
onFitContent: onHandleSideToolbar('fit'),
|
131
|
+
onRealContent: onHandleSideToolbar('real')
|
132
|
+
}), /*#__PURE__*/React.createElement("div", {
|
115
133
|
style: {
|
116
|
-
|
117
|
-
|
134
|
+
height: '100%',
|
135
|
+
width: '100%'
|
118
136
|
},
|
119
137
|
ref: divRef
|
120
|
-
}));
|
138
|
+
})));
|
121
139
|
};
|
122
140
|
|
123
|
-
export default DynamicPorts;
|
124
|
-
var testNode = {
|
125
|
-
x: 40,
|
126
|
-
y: 35,
|
127
|
-
width: 160,
|
128
|
-
height: 30,
|
129
|
-
label: 'Hello',
|
130
|
-
attrs: {
|
131
|
-
body: {
|
132
|
-
strokeWidth: 1,
|
133
|
-
stroke: '#108ee9',
|
134
|
-
fill: '#fff',
|
135
|
-
rx: 5,
|
136
|
-
ry: 5
|
137
|
-
}
|
138
|
-
},
|
139
|
-
portMarkup: [Markup.getForeignObjectMarkup()],
|
140
|
-
ports: {
|
141
|
-
items: [{
|
142
|
-
group: 'in',
|
143
|
-
id: 'in1'
|
144
|
-
}, {
|
145
|
-
group: 'in',
|
146
|
-
id: 'in2'
|
147
|
-
}, {
|
148
|
-
group: 'out',
|
149
|
-
id: 'out1'
|
150
|
-
}, {
|
151
|
-
group: 'out',
|
152
|
-
id: 'out2'
|
153
|
-
}],
|
154
|
-
groups: {
|
155
|
-
in: {
|
156
|
-
position: {
|
157
|
-
name: 'top'
|
158
|
-
},
|
159
|
-
attrs: {
|
160
|
-
fo: {
|
161
|
-
width: 10,
|
162
|
-
height: 10,
|
163
|
-
x: -5,
|
164
|
-
y: -5,
|
165
|
-
magnet: 'true'
|
166
|
-
}
|
167
|
-
},
|
168
|
-
zIndex: 1
|
169
|
-
},
|
170
|
-
out: {
|
171
|
-
position: {
|
172
|
-
name: 'bottom'
|
173
|
-
},
|
174
|
-
attrs: {
|
175
|
-
fo: {
|
176
|
-
width: 10,
|
177
|
-
height: 10,
|
178
|
-
x: -5,
|
179
|
-
y: -5,
|
180
|
-
magnet: 'true'
|
181
|
-
}
|
182
|
-
},
|
183
|
-
zIndex: 1
|
184
|
-
}
|
185
|
-
}
|
186
|
-
}
|
187
|
-
};
|
141
|
+
export default DynamicPorts;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
export declare namespace NDPGraph {
|
2
|
+
interface GraphData {
|
3
|
+
nodes: Node[];
|
4
|
+
edges: Edge[];
|
5
|
+
}
|
6
|
+
interface Node {
|
7
|
+
id: string;
|
8
|
+
libId?: string;
|
9
|
+
name: string;
|
10
|
+
inPorts: InPort[];
|
11
|
+
outPorts: OutPort[];
|
12
|
+
x: number;
|
13
|
+
y: number;
|
14
|
+
param?: Param;
|
15
|
+
}
|
16
|
+
interface Edge {
|
17
|
+
source: string;
|
18
|
+
target: string;
|
19
|
+
outPortId: string;
|
20
|
+
inPortId: string;
|
21
|
+
}
|
22
|
+
interface OutPort extends Port {
|
23
|
+
}
|
24
|
+
interface InPort extends Port {
|
25
|
+
}
|
26
|
+
interface Port {
|
27
|
+
id: string;
|
28
|
+
name: string;
|
29
|
+
seq: number;
|
30
|
+
}
|
31
|
+
interface Param {
|
32
|
+
[key: string]: any;
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import { NDPGraph } from './interface';
|
2
|
+
import { Graph } from '@antv/x6';
|
3
|
+
export declare function graphPointToOffsetPoint(graph: Graph, graphPoint: {
|
4
|
+
x: number;
|
5
|
+
y: number;
|
6
|
+
}, containerElem: HTMLElement): {
|
7
|
+
x: number;
|
8
|
+
y: number;
|
9
|
+
};
|
10
|
+
export declare function formatNodeInfoToNodeMeta(nodeData: NDPGraph.Node, inputPortConnectedMap?: {
|
11
|
+
[k: string]: boolean;
|
12
|
+
}): {
|
13
|
+
x: number;
|
14
|
+
y: number;
|
15
|
+
type: string;
|
16
|
+
id: string;
|
17
|
+
width: number;
|
18
|
+
height: number;
|
19
|
+
data: {
|
20
|
+
type: string;
|
21
|
+
x: number;
|
22
|
+
y: number;
|
23
|
+
id: string;
|
24
|
+
libId?: string;
|
25
|
+
name: string;
|
26
|
+
inPorts: NDPGraph.InPort[];
|
27
|
+
outPorts: NDPGraph.OutPort[];
|
28
|
+
param?: NDPGraph.Param;
|
29
|
+
};
|
30
|
+
ports: {
|
31
|
+
items: any[];
|
32
|
+
};
|
33
|
+
zIndex: number;
|
34
|
+
libId?: string;
|
35
|
+
name: string;
|
36
|
+
inPorts: NDPGraph.InPort[];
|
37
|
+
outPorts: NDPGraph.OutPort[];
|
38
|
+
param?: NDPGraph.Param;
|
39
|
+
};
|
40
|
+
/**
|
41
|
+
* 将暴露给接口的图信息转换可渲染的结图结构信息
|
42
|
+
* @returns
|
43
|
+
*/
|
44
|
+
export declare function formatGraphData(graphData: NDPGraph.GraphData): {
|
45
|
+
nodes: {
|
46
|
+
x: number;
|
47
|
+
y: number;
|
48
|
+
type: string;
|
49
|
+
id: string;
|
50
|
+
width: number;
|
51
|
+
height: number;
|
52
|
+
data: {
|
53
|
+
type: string;
|
54
|
+
x: number;
|
55
|
+
y: number;
|
56
|
+
id: string;
|
57
|
+
libId?: string;
|
58
|
+
name: string;
|
59
|
+
inPorts: NDPGraph.InPort[];
|
60
|
+
outPorts: NDPGraph.OutPort[];
|
61
|
+
param?: NDPGraph.Param;
|
62
|
+
};
|
63
|
+
ports: {
|
64
|
+
items: any[];
|
65
|
+
};
|
66
|
+
zIndex: number;
|
67
|
+
libId?: string;
|
68
|
+
name: string;
|
69
|
+
inPorts: NDPGraph.InPort[];
|
70
|
+
outPorts: NDPGraph.OutPort[];
|
71
|
+
param?: NDPGraph.Param;
|
72
|
+
}[];
|
73
|
+
edges: {
|
74
|
+
data: {
|
75
|
+
source: string;
|
76
|
+
target: string;
|
77
|
+
outPortId: string;
|
78
|
+
inPortId: string;
|
79
|
+
};
|
80
|
+
sourceAnchor: string;
|
81
|
+
source: {
|
82
|
+
cell: string;
|
83
|
+
port: string;
|
84
|
+
anchor: {
|
85
|
+
name: string;
|
86
|
+
};
|
87
|
+
};
|
88
|
+
target: {
|
89
|
+
cell: string;
|
90
|
+
port: string;
|
91
|
+
anchor: {
|
92
|
+
name: string;
|
93
|
+
};
|
94
|
+
};
|
95
|
+
label: string;
|
96
|
+
zIndex: number;
|
97
|
+
outPortId: string;
|
98
|
+
inPortId: string;
|
99
|
+
}[];
|
100
|
+
};
|
@@ -0,0 +1,127 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
+
|
4
|
+
/*
|
5
|
+
* @Author: wangxian
|
6
|
+
* @Date: 2022-05-24 16:40:49
|
7
|
+
* @LastEditTime: 2022-05-27 16:02:48
|
8
|
+
*/
|
9
|
+
import { sortBy } from 'lodash-es';
|
10
|
+
import { NODE_HEIGHT, NODE_WIDTH } from './constant'; // 将画布上的点转换成相对于 offset parent 的点
|
11
|
+
|
12
|
+
export function graphPointToOffsetPoint(graph, graphPoint, containerElem) {
|
13
|
+
if (graph) {
|
14
|
+
var point = graph.localToPage({
|
15
|
+
x: graphPoint.x,
|
16
|
+
y: graphPoint.y
|
17
|
+
});
|
18
|
+
var clientRect = containerElem === null || containerElem === void 0 ? void 0 : containerElem.getBoundingClientRect();
|
19
|
+
var y = point.y - ((clientRect === null || clientRect === void 0 ? void 0 : clientRect.y) || 0); // ! offset parent 不能是画布容器,否则会影响内部布局,所以 offset parent 在外部,算上上方 toolbar 的高度
|
20
|
+
|
21
|
+
var x = point.x - ((clientRect === null || clientRect === void 0 ? void 0 : clientRect.x) || 0);
|
22
|
+
return {
|
23
|
+
x: x,
|
24
|
+
y: y
|
25
|
+
};
|
26
|
+
}
|
27
|
+
|
28
|
+
return {
|
29
|
+
x: 0,
|
30
|
+
y: 0
|
31
|
+
};
|
32
|
+
} // 格式化单个节点,新增节点时复用
|
33
|
+
|
34
|
+
export function formatNodeInfoToNodeMeta(nodeData) {
|
35
|
+
var inputPortConnectedMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
36
|
+
var portItems = [];
|
37
|
+
var id = nodeData.id,
|
38
|
+
_nodeData$x = nodeData.x,
|
39
|
+
x = _nodeData$x === void 0 ? 0 : _nodeData$x,
|
40
|
+
_nodeData$y = nodeData.y,
|
41
|
+
y = _nodeData$y === void 0 ? 0 : _nodeData$y,
|
42
|
+
inPorts = nodeData.inPorts,
|
43
|
+
outPorts = nodeData.outPorts;
|
44
|
+
sortBy(inPorts, 'seq').forEach(function (inPort) {
|
45
|
+
portItems.push(_objectSpread(_objectSpread({}, inPort), {}, {
|
46
|
+
group: 'in',
|
47
|
+
id: inPort.id.toString(),
|
48
|
+
connected: !!inputPortConnectedMap[inPort.id.toString()]
|
49
|
+
}));
|
50
|
+
});
|
51
|
+
sortBy(outPorts, 'seq').forEach(function (outPort) {
|
52
|
+
portItems.push(_objectSpread(_objectSpread({}, outPort), {}, {
|
53
|
+
group: 'out',
|
54
|
+
id: outPort.id.toString(),
|
55
|
+
connected: !!inputPortConnectedMap[outPort.id.toString()]
|
56
|
+
}));
|
57
|
+
});
|
58
|
+
return _objectSpread(_objectSpread({}, nodeData), {}, {
|
59
|
+
x: x,
|
60
|
+
y: y,
|
61
|
+
type: 'node',
|
62
|
+
id: id.toString(),
|
63
|
+
width: NODE_WIDTH,
|
64
|
+
height: NODE_HEIGHT,
|
65
|
+
data: _objectSpread(_objectSpread({}, nodeData), {}, {
|
66
|
+
type: 'node',
|
67
|
+
x: x,
|
68
|
+
y: y,
|
69
|
+
id: id.toString()
|
70
|
+
}),
|
71
|
+
ports: {
|
72
|
+
items: portItems
|
73
|
+
},
|
74
|
+
zIndex: 10
|
75
|
+
});
|
76
|
+
}
|
77
|
+
/**
|
78
|
+
* 将暴露给接口的图信息转换可渲染的结图结构信息
|
79
|
+
* @returns
|
80
|
+
*/
|
81
|
+
|
82
|
+
export function formatGraphData(graphData) {
|
83
|
+
var _graphData$nodes = graphData.nodes,
|
84
|
+
nodes = _graphData$nodes === void 0 ? [] : _graphData$nodes,
|
85
|
+
_graphData$edges = graphData.edges,
|
86
|
+
edges = _graphData$edges === void 0 ? [] : _graphData$edges; // 格式化边
|
87
|
+
|
88
|
+
var formattedEdges = edges.map(function (edges) {
|
89
|
+
var source = edges.source,
|
90
|
+
outPortId = edges.outPortId,
|
91
|
+
target = edges.target,
|
92
|
+
inPortId = edges.inPortId;
|
93
|
+
return _objectSpread(_objectSpread({}, edges), {}, {
|
94
|
+
data: _objectSpread({}, edges),
|
95
|
+
sourceAnchor: 'bottom',
|
96
|
+
source: {
|
97
|
+
cell: source.toString(),
|
98
|
+
port: outPortId.toString(),
|
99
|
+
anchor: {
|
100
|
+
name: 'bottom'
|
101
|
+
}
|
102
|
+
},
|
103
|
+
target: {
|
104
|
+
cell: target.toString(),
|
105
|
+
port: inPortId.toString(),
|
106
|
+
anchor: {
|
107
|
+
name: 'center'
|
108
|
+
}
|
109
|
+
},
|
110
|
+
label: '',
|
111
|
+
zIndex: 1
|
112
|
+
});
|
113
|
+
}); // 记录所有已连线的输入桩
|
114
|
+
|
115
|
+
var inputPortConnectedMap = formattedEdges.reduce(function (acc, edge) {
|
116
|
+
acc[edge.inPortId] = true;
|
117
|
+
return acc;
|
118
|
+
}, {}); // 格式化算法组件节点
|
119
|
+
|
120
|
+
var formattedNodes = nodes.map(function (nodeData) {
|
121
|
+
return formatNodeInfoToNodeMeta(nodeData, inputPortConnectedMap);
|
122
|
+
});
|
123
|
+
return {
|
124
|
+
nodes: _toConsumableArray(formattedNodes),
|
125
|
+
edges: formattedEdges
|
126
|
+
};
|
127
|
+
}
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import "antd/es/form/style";
|
2
2
|
import _Form from "antd/es/form";
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
5
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
6
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
5
7
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
6
8
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
7
9
|
import React, { useRef } from 'react';
|
@@ -10,6 +12,7 @@ import { JsonMetadataProvider } from '../../../../framework/metadata';
|
|
10
12
|
import Editable from '../../../../comps/Editable';
|
11
13
|
import useObservable from '../../../../framework/rxjs-hooks/useObservable';
|
12
14
|
import { MetadataFormContext } from '../../interface';
|
15
|
+
import { getLabelByProps } from '../../utils';
|
13
16
|
|
14
17
|
var TableArray = function TableArray(props) {
|
15
18
|
var initValue = props.initValue,
|
@@ -46,31 +49,68 @@ var TableArray = function TableArray(props) {
|
|
46
49
|
setList(_toConsumableArray(p.payload[name]));
|
47
50
|
}
|
48
51
|
}, [formContext.stream$]);
|
52
|
+
var getSchemaByRefId = React.useCallback( /*#__PURE__*/function () {
|
53
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(server, __TYPE__) {
|
54
|
+
var _schema, res, provider, FormCls, formCls, _fields;
|
55
|
+
|
56
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
57
|
+
while (1) {
|
58
|
+
switch (_context.prev = _context.next) {
|
59
|
+
case 0:
|
60
|
+
_schema = []; // 如果有内部类,优先在内部类里面找
|
61
|
+
|
62
|
+
if (__TYPE__.length > 0) {
|
63
|
+
_schema = __TYPE__.filter(function (it) {
|
64
|
+
return it.id === refId;
|
65
|
+
});
|
66
|
+
} // 内部类找不到 从接口里面拿
|
67
|
+
|
68
|
+
|
69
|
+
if (!(_schema.length === 0)) {
|
70
|
+
_context.next = 7;
|
71
|
+
break;
|
72
|
+
}
|
73
|
+
|
74
|
+
_context.next = 5;
|
75
|
+
return server.GetMetadataDetailById(refId);
|
76
|
+
|
77
|
+
case 5:
|
78
|
+
res = _context.sent;
|
79
|
+
|
80
|
+
if (res === null || res === void 0 ? void 0 : res.schema) {
|
81
|
+
_schema = JSON.parse(res === null || res === void 0 ? void 0 : res.schema);
|
82
|
+
}
|
83
|
+
|
84
|
+
case 7:
|
85
|
+
provider = new JsonMetadataProvider();
|
86
|
+
|
87
|
+
if (_schema.length > 0) {
|
88
|
+
provider.add_types(_schema);
|
89
|
+
FormCls = provider.get_type(_schema[0].id);
|
90
|
+
formCls = new FormCls();
|
91
|
+
_fields = formCls.__type__.__fields__;
|
92
|
+
refFieldsRef.current = _fields;
|
93
|
+
setRefFields(_objectSpread({}, _fields));
|
94
|
+
setSchema(_toConsumableArray(_schema));
|
95
|
+
setDefaultValue(_objectSpread({}, JSON.parse(JSON.stringify(formCls))));
|
96
|
+
}
|
97
|
+
|
98
|
+
case 9:
|
99
|
+
case "end":
|
100
|
+
return _context.stop();
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}, _callee);
|
104
|
+
}));
|
105
|
+
|
106
|
+
return function (_x, _x2) {
|
107
|
+
return _ref.apply(this, arguments);
|
108
|
+
};
|
109
|
+
}(), [refId]);
|
49
110
|
React.useEffect(function () {
|
50
111
|
if (refId) {
|
51
112
|
var server = new MetadataService();
|
52
|
-
server.
|
53
|
-
var provider = new JsonMetadataProvider();
|
54
|
-
|
55
|
-
if (res === null || res === void 0 ? void 0 : res.schema) {
|
56
|
-
var mySchema = JSON.parse(res.schema);
|
57
|
-
provider.add_types(mySchema);
|
58
|
-
var FormCls = provider.get_type(mySchema[0].id);
|
59
|
-
var formCls = new FormCls();
|
60
|
-
var _fields = formCls.__type__.__fields__;
|
61
|
-
refFieldsRef.current = _fields;
|
62
|
-
setRefFields(_objectSpread({}, _fields));
|
63
|
-
setSchema(_toConsumableArray(mySchema));
|
64
|
-
setDefaultValue(_objectSpread({}, JSON.parse(JSON.stringify(formCls))));
|
65
|
-
return function () {
|
66
|
-
provider = null;
|
67
|
-
};
|
68
|
-
}
|
69
|
-
|
70
|
-
return function () {
|
71
|
-
provider = null;
|
72
|
-
};
|
73
|
-
});
|
113
|
+
getSchemaByRefId(server, formContext.__TYPE__);
|
74
114
|
return function () {
|
75
115
|
server = null;
|
76
116
|
};
|
@@ -88,11 +128,9 @@ var TableArray = function TableArray(props) {
|
|
88
128
|
var _columns = [];
|
89
129
|
|
90
130
|
for (var i = 0; i < _properties.length; i++) {
|
91
|
-
var _it$fields$0$value, _it$fields$0$value$co, _it$fields$0$value2;
|
92
|
-
|
93
131
|
var it = _properties[i];
|
94
132
|
var obj = {
|
95
|
-
title: (it
|
133
|
+
title: getLabelByProps(it),
|
96
134
|
key: it.id,
|
97
135
|
dataIndex: it.id,
|
98
136
|
width: 100,
|