@nocobase/plugin-graph-collection-manager 0.9.1-alpha.1 → 0.9.2-alpha.1
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/lib/client/GraphCollectionProvider.js +8 -27
- package/lib/client/GraphCollectionShortcut.js +6 -37
- package/lib/client/GraphDrawPage.js +66 -271
- package/lib/client/action-hooks.js +26 -114
- package/lib/client/components/AddCollectionAction.js +1 -17
- package/lib/client/components/AddFieldAction.js +2 -21
- package/lib/client/components/CollectionNodeProvder.js +3 -11
- package/lib/client/components/EditCollectionAction.js +0 -16
- package/lib/client/components/EditFieldAction.js +5 -24
- package/lib/client/components/Entity.js +32 -101
- package/lib/client/components/FieldSummary.js +2 -26
- package/lib/client/components/OverrideFieldAction.js +4 -24
- package/lib/client/components/ViewFieldAction.js +3 -16
- package/lib/client/components/ViewNode.js +0 -7
- package/lib/client/index.js +0 -1
- package/lib/client/locale/en-US.d.ts +1 -0
- package/lib/client/locale/en-US.js +1 -0
- package/lib/client/locale/index.js +0 -4
- package/lib/client/locale/pt-BR.d.ts +16 -0
- package/lib/client/locale/pt-BR.js +22 -0
- package/lib/client/locale/zh-CN.d.ts +1 -0
- package/lib/client/locale/zh-CN.js +1 -0
- package/lib/client/style.js +0 -4
- package/lib/client/utils.d.ts +1 -1
- package/lib/client/utils.js +6 -63
- package/lib/index.js +0 -2
- package/lib/server/collections/graphPositions.js +1 -6
- package/lib/server/index.js +0 -14
- package/package.json +4 -4
|
@@ -4,192 +4,133 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.GraphDrawPage = exports.DirectionType = exports.ConnectionType = void 0;
|
|
7
|
-
|
|
8
7
|
function _icons() {
|
|
9
8
|
const data = require("@ant-design/icons");
|
|
10
|
-
|
|
11
9
|
_icons = function _icons() {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
function _x4() {
|
|
19
15
|
const data = require("@antv/x6");
|
|
20
|
-
|
|
21
16
|
_x4 = function _x4() {
|
|
22
17
|
return data;
|
|
23
18
|
};
|
|
24
|
-
|
|
25
19
|
return data;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
require("@antv/x6-react-shape");
|
|
29
|
-
|
|
30
22
|
function _css() {
|
|
31
23
|
const data = require("@emotion/css");
|
|
32
|
-
|
|
33
24
|
_css = function _css() {
|
|
34
25
|
return data;
|
|
35
26
|
};
|
|
36
|
-
|
|
37
27
|
return data;
|
|
38
28
|
}
|
|
39
|
-
|
|
40
29
|
function _react() {
|
|
41
30
|
const data = require("@formily/react");
|
|
42
|
-
|
|
43
31
|
_react = function _react() {
|
|
44
32
|
return data;
|
|
45
33
|
};
|
|
46
|
-
|
|
47
34
|
return data;
|
|
48
35
|
}
|
|
49
|
-
|
|
50
36
|
function _client() {
|
|
51
37
|
const data = require("@nocobase/client");
|
|
52
|
-
|
|
53
38
|
_client = function _client() {
|
|
54
39
|
return data;
|
|
55
40
|
};
|
|
56
|
-
|
|
57
41
|
return data;
|
|
58
42
|
}
|
|
59
|
-
|
|
60
43
|
function _ahooks() {
|
|
61
44
|
const data = require("ahooks");
|
|
62
|
-
|
|
63
45
|
_ahooks = function _ahooks() {
|
|
64
46
|
return data;
|
|
65
47
|
};
|
|
66
|
-
|
|
67
48
|
return data;
|
|
68
49
|
}
|
|
69
|
-
|
|
70
50
|
function _antd() {
|
|
71
51
|
const data = require("antd");
|
|
72
|
-
|
|
73
52
|
_antd = function _antd() {
|
|
74
53
|
return data;
|
|
75
54
|
};
|
|
76
|
-
|
|
77
55
|
return data;
|
|
78
56
|
}
|
|
79
|
-
|
|
80
57
|
function _dagre() {
|
|
81
58
|
const data = _interopRequireDefault(require("dagre"));
|
|
82
|
-
|
|
83
59
|
_dagre = function _dagre() {
|
|
84
60
|
return data;
|
|
85
61
|
};
|
|
86
|
-
|
|
87
62
|
return data;
|
|
88
63
|
}
|
|
89
|
-
|
|
90
64
|
function _lodash() {
|
|
91
65
|
const data = require("lodash");
|
|
92
|
-
|
|
93
66
|
_lodash = function _lodash() {
|
|
94
67
|
return data;
|
|
95
68
|
};
|
|
96
|
-
|
|
97
69
|
return data;
|
|
98
70
|
}
|
|
99
|
-
|
|
100
71
|
function _react2() {
|
|
101
72
|
const data = _interopRequireWildcard(require("react"));
|
|
102
|
-
|
|
103
73
|
_react2 = function _react2() {
|
|
104
74
|
return data;
|
|
105
75
|
};
|
|
106
|
-
|
|
107
76
|
return data;
|
|
108
77
|
}
|
|
109
|
-
|
|
110
78
|
var _actionHooks = require("./action-hooks");
|
|
111
|
-
|
|
112
79
|
var _AddCollectionAction = require("./components/AddCollectionAction");
|
|
113
|
-
|
|
114
80
|
var _Entity = _interopRequireDefault(require("./components/Entity"));
|
|
115
|
-
|
|
116
81
|
var _ViewNode = require("./components/ViewNode");
|
|
117
|
-
|
|
118
82
|
var _style = require("./style");
|
|
119
|
-
|
|
120
83
|
var _utils = require("./utils");
|
|
121
|
-
|
|
122
84
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
123
|
-
|
|
124
85
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
125
|
-
|
|
126
86
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
127
|
-
|
|
128
87
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
129
|
-
|
|
130
88
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
131
|
-
|
|
132
89
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
133
|
-
|
|
134
90
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
135
|
-
|
|
136
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
137
|
-
|
|
91
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
138
92
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
139
|
-
|
|
140
93
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
141
|
-
|
|
142
94
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
143
|
-
|
|
144
|
-
function
|
|
145
|
-
|
|
95
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
96
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
97
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
146
98
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
147
|
-
|
|
148
99
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
149
|
-
|
|
150
100
|
const LINE_HEIGHT = 40;
|
|
151
101
|
const NODE_WIDTH = 250;
|
|
152
102
|
let targetGraph;
|
|
153
103
|
let targetNode;
|
|
154
104
|
let dir = 'TB'; // LR RL TB BT 横排
|
|
155
|
-
|
|
156
105
|
var DirectionType;
|
|
157
106
|
exports.DirectionType = DirectionType;
|
|
158
|
-
|
|
159
107
|
(function (DirectionType) {
|
|
160
108
|
DirectionType["Both"] = "both";
|
|
161
109
|
DirectionType["Target"] = "target";
|
|
162
110
|
DirectionType["Source"] = "source";
|
|
163
111
|
})(DirectionType || (exports.DirectionType = DirectionType = {}));
|
|
164
|
-
|
|
165
112
|
var ConnectionType;
|
|
166
113
|
exports.ConnectionType = ConnectionType;
|
|
167
|
-
|
|
168
114
|
(function (ConnectionType) {
|
|
169
115
|
ConnectionType["Both"] = "both";
|
|
170
116
|
ConnectionType["Inherit"] = "inherited";
|
|
171
117
|
ConnectionType["Entity"] = "entity";
|
|
172
118
|
})(ConnectionType || (exports.ConnectionType = ConnectionType = {}));
|
|
173
|
-
|
|
174
119
|
const getGridData = (num, arr) => {
|
|
175
120
|
const newArr = [];
|
|
176
|
-
|
|
177
121
|
while (arr.length > 0 && num) {
|
|
178
122
|
newArr.push(arr.splice(0, num));
|
|
179
123
|
}
|
|
180
|
-
|
|
181
124
|
return newArr;
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
|
|
125
|
+
};
|
|
126
|
+
//初始布局
|
|
185
127
|
function layout(_x) {
|
|
186
128
|
return _layout.apply(this, arguments);
|
|
187
129
|
}
|
|
188
|
-
|
|
189
130
|
function _layout() {
|
|
190
131
|
_layout = _asyncToGenerator(function* (createPositions) {
|
|
191
132
|
const _targetGraph10 = targetGraph,
|
|
192
|
-
|
|
133
|
+
positions = _targetGraph10.positions;
|
|
193
134
|
let graphPositions = [];
|
|
194
135
|
const nodes = targetGraph.getNodes();
|
|
195
136
|
const edges = targetGraph.getEdges();
|
|
@@ -211,16 +152,13 @@ function _layout() {
|
|
|
211
152
|
height
|
|
212
153
|
});
|
|
213
154
|
});
|
|
214
|
-
|
|
215
155
|
_dagre().default.layout(g);
|
|
216
|
-
|
|
217
156
|
targetGraph.freeze();
|
|
218
157
|
const dNodes = getGridData(15, g.nodes());
|
|
219
158
|
dNodes.forEach((arr, row) => {
|
|
220
159
|
arr.forEach((id, index) => {
|
|
221
160
|
const node = targetGraph.getCell(id);
|
|
222
161
|
const col = index % 15;
|
|
223
|
-
|
|
224
162
|
if (node) {
|
|
225
163
|
const targetPosition = positions && positions.find(v => {
|
|
226
164
|
return v.collectionName === node.store.data.name;
|
|
@@ -230,7 +168,6 @@ function _layout() {
|
|
|
230
168
|
y: row * 400 + 60
|
|
231
169
|
};
|
|
232
170
|
node.position(targetPosition.x || calculatedPosition.x, targetPosition.y || calculatedPosition.y);
|
|
233
|
-
|
|
234
171
|
if (positions && !positions.find(v => v.collectionName === node.store.data.name)) {
|
|
235
172
|
// 位置表中没有的表都自动保存
|
|
236
173
|
graphPositions.push({
|
|
@@ -246,7 +183,6 @@ function _layout() {
|
|
|
246
183
|
optimizeEdge(edge);
|
|
247
184
|
});
|
|
248
185
|
targetGraph.unfreeze();
|
|
249
|
-
|
|
250
186
|
if (targetNode) {
|
|
251
187
|
typeof targetNode === 'string' ? targetGraph.positionCell((0, _lodash().last)(nodes), 'top', {
|
|
252
188
|
padding: 100
|
|
@@ -258,7 +194,6 @@ function _layout() {
|
|
|
258
194
|
padding: 100
|
|
259
195
|
});
|
|
260
196
|
}
|
|
261
|
-
|
|
262
197
|
if (graphPositions.length > 0) {
|
|
263
198
|
yield createPositions(graphPositions);
|
|
264
199
|
graphPositions = [];
|
|
@@ -266,7 +201,6 @@ function _layout() {
|
|
|
266
201
|
});
|
|
267
202
|
return _layout.apply(this, arguments);
|
|
268
203
|
}
|
|
269
|
-
|
|
270
204
|
function optimizeEdge(edge) {
|
|
271
205
|
const connectionType = edge.store.data.connectionType;
|
|
272
206
|
const source = edge.getSource();
|
|
@@ -292,7 +226,6 @@ function optimizeEdge(edge) {
|
|
|
292
226
|
vertices.forEach(() => {
|
|
293
227
|
return edge.removeVertexAt(0);
|
|
294
228
|
});
|
|
295
|
-
|
|
296
229
|
if (sorceNodeX - 100 > targeNodeX) {
|
|
297
230
|
edge.setSource({
|
|
298
231
|
cell: source.cell,
|
|
@@ -320,7 +253,6 @@ function optimizeEdge(edge) {
|
|
|
320
253
|
port: target.port,
|
|
321
254
|
anchor: leftAnchor
|
|
322
255
|
});
|
|
323
|
-
|
|
324
256
|
if (connectionType) {
|
|
325
257
|
edge.setVertices([{
|
|
326
258
|
x: sourceCell.position().x - 30,
|
|
@@ -351,11 +283,9 @@ function optimizeEdge(edge) {
|
|
|
351
283
|
});
|
|
352
284
|
}
|
|
353
285
|
}
|
|
354
|
-
|
|
355
286
|
function getNodes(nodes) {
|
|
356
287
|
targetGraph.addNodes(nodes);
|
|
357
288
|
}
|
|
358
|
-
|
|
359
289
|
function getEdges(edges) {
|
|
360
290
|
edges.forEach(item => {
|
|
361
291
|
if (item.source && item.target) {
|
|
@@ -368,13 +298,10 @@ function getEdges(edges) {
|
|
|
368
298
|
}
|
|
369
299
|
});
|
|
370
300
|
}
|
|
371
|
-
|
|
372
301
|
const getPopupContainer = () => {
|
|
373
302
|
return document.getElementById('graph_container');
|
|
374
303
|
};
|
|
375
|
-
|
|
376
304
|
const CollapsedContext = (0, _react2().createContext)({});
|
|
377
|
-
|
|
378
305
|
const formatNodeData = () => {
|
|
379
306
|
const layoutNodes = [];
|
|
380
307
|
const edges = targetGraph.getEdges();
|
|
@@ -391,17 +318,15 @@ const formatNodeData = () => {
|
|
|
391
318
|
}
|
|
392
319
|
});
|
|
393
320
|
return nodeGroup;
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
|
|
321
|
+
};
|
|
322
|
+
//自动布局
|
|
397
323
|
const handelResetLayout = () => {
|
|
398
324
|
const _formatNodeData = formatNodeData(),
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
325
|
+
_formatNodeData$linkN = _formatNodeData.linkNodes,
|
|
326
|
+
linkNodes = _formatNodeData$linkN === void 0 ? [] : _formatNodeData$linkN,
|
|
327
|
+
rawNodes = _formatNodeData.rawNodes;
|
|
403
328
|
const _targetGraph = targetGraph,
|
|
404
|
-
|
|
329
|
+
positions = _targetGraph.positions;
|
|
405
330
|
const nodes = linkNodes.concat(rawNodes);
|
|
406
331
|
const edges = targetGraph.getEdges();
|
|
407
332
|
const g = new (_dagre().default.graphlib.Graph)();
|
|
@@ -432,19 +357,15 @@ const handelResetLayout = () => {
|
|
|
432
357
|
const target = edge.getTarget();
|
|
433
358
|
g.setEdge(source.cell, target.cell, {});
|
|
434
359
|
});
|
|
435
|
-
|
|
436
360
|
_dagre().default.layout(g);
|
|
437
|
-
|
|
438
361
|
targetGraph.freeze();
|
|
439
362
|
const gNodes = g.nodes();
|
|
440
363
|
const nodeWithEdges = (0, _lodash().take)(gNodes, linkNodes.length);
|
|
441
364
|
const nodeWithoutEdges = (0, _lodash().drop)(gNodes, linkNodes.length);
|
|
442
365
|
nodeWithEdges.forEach(id => {
|
|
443
366
|
var _positions$find;
|
|
444
|
-
|
|
445
367
|
const node = targetGraph.getCell(id);
|
|
446
368
|
const positionId = (_positions$find = positions.find(v => v.collectionName === node.id)) === null || _positions$find === void 0 ? void 0 : _positions$find.id;
|
|
447
|
-
|
|
448
369
|
if (node) {
|
|
449
370
|
const pos = g.node(id);
|
|
450
371
|
updatePositionData.push({
|
|
@@ -455,10 +376,8 @@ const handelResetLayout = () => {
|
|
|
455
376
|
node.position(pos === null || pos === void 0 ? void 0 : pos.x, pos === null || pos === void 0 ? void 0 : pos.y);
|
|
456
377
|
}
|
|
457
378
|
});
|
|
458
|
-
|
|
459
379
|
if (nodeWithEdges.length) {
|
|
460
380
|
var _targetGraph$getCell;
|
|
461
|
-
|
|
462
381
|
maxY = targetGraph.getCellById((0, _lodash().maxBy)(nodeWithEdges, k => {
|
|
463
382
|
return targetGraph.getCellById(k).position().y;
|
|
464
383
|
})).position().y;
|
|
@@ -475,16 +394,13 @@ const handelResetLayout = () => {
|
|
|
475
394
|
num = Math.round(maxX / 320) || 1;
|
|
476
395
|
alternateNum = Math.floor((4500 - (maxX + 100 - referenceNode.x)) / 280);
|
|
477
396
|
rawEntity = getGridData(num, rawNodes);
|
|
478
|
-
|
|
479
397
|
if (alternateNum >= 1) {
|
|
480
398
|
const alternateNodes = (0, _lodash().take)(nodeWithoutEdges, alternateNum);
|
|
481
399
|
rawEntity = getGridData(num, (0, _lodash().drop)(nodeWithoutEdges, alternateNum));
|
|
482
400
|
alternateNodes.forEach((id, index) => {
|
|
483
401
|
const node = targetGraph.getCell(id);
|
|
484
|
-
|
|
485
402
|
if (node) {
|
|
486
403
|
var _positions$find2;
|
|
487
|
-
|
|
488
404
|
const calculatedPosition = {
|
|
489
405
|
x: referenceNode.x + 320 * index + 280,
|
|
490
406
|
y: referenceNode.y
|
|
@@ -506,15 +422,12 @@ const handelResetLayout = () => {
|
|
|
506
422
|
minX = 50;
|
|
507
423
|
maxY = 50;
|
|
508
424
|
}
|
|
509
|
-
|
|
510
425
|
rawEntity.forEach((arr, row) => {
|
|
511
426
|
arr.forEach((id, index) => {
|
|
512
427
|
const node = targetGraph.getCell(id);
|
|
513
428
|
const col = index % num;
|
|
514
|
-
|
|
515
429
|
if (node) {
|
|
516
430
|
var _positions$find3;
|
|
517
|
-
|
|
518
431
|
const calculatedPosition = {
|
|
519
432
|
x: col * 325 + minX,
|
|
520
433
|
y: row * 300 + maxY + 300
|
|
@@ -538,38 +451,29 @@ const handelResetLayout = () => {
|
|
|
538
451
|
});
|
|
539
452
|
targetGraph.updatePositionAction(updatePositionData, true);
|
|
540
453
|
};
|
|
541
|
-
|
|
542
454
|
const GraphDrawPage = _react2().default.memo(() => {
|
|
543
455
|
var _targetGraph7;
|
|
544
|
-
|
|
545
456
|
let options = (0, _react2().useContext)(_react().SchemaOptionsContext);
|
|
546
457
|
const ctx = (0, _react2().useContext)(_client().CollectionManagerContext);
|
|
547
458
|
const api = (0, _client().useAPIClient)();
|
|
548
459
|
const compile = (0, _client().useCompile)();
|
|
549
|
-
|
|
550
460
|
const _useGCMTranslation = (0, _utils.useGCMTranslation)(),
|
|
551
|
-
|
|
552
|
-
|
|
461
|
+
t = _useGCMTranslation.t;
|
|
553
462
|
const _useState = (0, _react2().useState)([]),
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
463
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
464
|
+
collectionData = _useState2[0],
|
|
465
|
+
setCollectionData = _useState2[1];
|
|
558
466
|
const _useState3 = (0, _react2().useState)([]),
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
467
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
468
|
+
collectionList = _useState4[0],
|
|
469
|
+
setCollectionList = _useState4[1];
|
|
563
470
|
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
564
|
-
|
|
565
|
-
|
|
471
|
+
refreshCM = _useCollectionManager.refreshCM;
|
|
566
472
|
const _useCurrentAppInfo = (0, _client().useCurrentAppInfo)(),
|
|
567
|
-
|
|
568
|
-
|
|
473
|
+
database = _useCurrentAppInfo.data.database;
|
|
474
|
+
const categoryCtx = (0, _react2().useContext)(_client().CollectionCategroriesContext);
|
|
569
475
|
const scope = _objectSpread({}, options === null || options === void 0 ? void 0 : options.scope);
|
|
570
|
-
|
|
571
476
|
const components = _objectSpread({}, options === null || options === void 0 ? void 0 : options.components);
|
|
572
|
-
|
|
573
477
|
const useSaveGraphPositionAction = /*#__PURE__*/function () {
|
|
574
478
|
var _ref = _asyncToGenerator(function* (data) {
|
|
575
479
|
yield api.resource('graphPositions').create({
|
|
@@ -577,12 +481,10 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
577
481
|
});
|
|
578
482
|
yield refreshPositions();
|
|
579
483
|
});
|
|
580
|
-
|
|
581
484
|
return function useSaveGraphPositionAction(_x2) {
|
|
582
485
|
return _ref.apply(this, arguments);
|
|
583
486
|
};
|
|
584
487
|
}();
|
|
585
|
-
|
|
586
488
|
const useUpdatePositionAction = /*#__PURE__*/function () {
|
|
587
489
|
var _ref2 = _asyncToGenerator(function* (data, isbatch = false) {
|
|
588
490
|
if (isbatch) {
|
|
@@ -597,39 +499,31 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
597
499
|
values: _objectSpread({}, data)
|
|
598
500
|
});
|
|
599
501
|
}
|
|
600
|
-
|
|
601
502
|
yield refreshPositions();
|
|
602
503
|
});
|
|
603
|
-
|
|
604
504
|
return function useUpdatePositionAction(_x3) {
|
|
605
505
|
return _ref2.apply(this, arguments);
|
|
606
506
|
};
|
|
607
507
|
}();
|
|
608
|
-
|
|
609
508
|
const refreshPositions = /*#__PURE__*/function () {
|
|
610
509
|
var _ref3 = _asyncToGenerator(function* () {
|
|
611
510
|
const _yield$api$resource$l = yield api.resource('graphPositions').list({
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
511
|
+
paginate: false
|
|
512
|
+
}),
|
|
513
|
+
data = _yield$api$resource$l.data;
|
|
616
514
|
targetGraph.positions = data.data;
|
|
617
515
|
return Promise.resolve();
|
|
618
516
|
});
|
|
619
|
-
|
|
620
517
|
return function refreshPositions() {
|
|
621
518
|
return _ref3.apply(this, arguments);
|
|
622
519
|
};
|
|
623
520
|
}();
|
|
624
|
-
|
|
625
521
|
const setTargetNode = node => {
|
|
626
522
|
targetNode = node;
|
|
627
|
-
|
|
628
523
|
if (node === 'destory') {
|
|
629
524
|
refreshPositions();
|
|
630
525
|
}
|
|
631
526
|
};
|
|
632
|
-
|
|
633
527
|
const refreshGM = /*#__PURE__*/function () {
|
|
634
528
|
var _ref4 = _asyncToGenerator(function* () {
|
|
635
529
|
const data = yield refreshCM();
|
|
@@ -638,19 +532,16 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
638
532
|
const currentNodes = targetGraph.getNodes();
|
|
639
533
|
setCollectionData(data);
|
|
640
534
|
setCollectionList(data);
|
|
641
|
-
|
|
642
535
|
if (!currentNodes.length) {
|
|
643
536
|
renderInitGraphCollection(data);
|
|
644
537
|
} else {
|
|
645
538
|
renderDiffGraphCollection(data);
|
|
646
539
|
}
|
|
647
540
|
});
|
|
648
|
-
|
|
649
541
|
return function refreshGM() {
|
|
650
542
|
return _ref4.apply(this, arguments);
|
|
651
543
|
};
|
|
652
544
|
}();
|
|
653
|
-
|
|
654
545
|
const initGraphCollections = () => {
|
|
655
546
|
targetGraph = new (_x4().Graph)({
|
|
656
547
|
container: document.getElementById('container'),
|
|
@@ -681,19 +572,16 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
681
572
|
padding: 10,
|
|
682
573
|
graphOptions: {
|
|
683
574
|
async: true,
|
|
684
|
-
|
|
685
575
|
getCellView(cell) {
|
|
686
576
|
if (cell.isNode()) {
|
|
687
577
|
return _ViewNode.SimpleNodeView;
|
|
688
578
|
}
|
|
689
579
|
},
|
|
690
|
-
|
|
691
580
|
createCellView(cell) {
|
|
692
581
|
if (cell.isEdge()) {
|
|
693
582
|
return null;
|
|
694
583
|
}
|
|
695
584
|
}
|
|
696
|
-
|
|
697
585
|
}
|
|
698
586
|
},
|
|
699
587
|
connecting: {
|
|
@@ -723,7 +611,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
723
611
|
targetGraph.connectionType = ConnectionType.Both;
|
|
724
612
|
targetGraph.direction = DirectionType.Target;
|
|
725
613
|
targetGraph.cacheCollection = {};
|
|
726
|
-
|
|
727
614
|
_x4().Graph.registerPortLayout('erPortPosition', portsPositionArgs => {
|
|
728
615
|
return portsPositionArgs.map((_, index) => {
|
|
729
616
|
return {
|
|
@@ -735,12 +622,10 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
735
622
|
};
|
|
736
623
|
});
|
|
737
624
|
}, true);
|
|
738
|
-
|
|
739
625
|
_x4().Graph.registerNode('er-rect', {
|
|
740
626
|
inherit: 'react-shape',
|
|
741
627
|
component: node => {
|
|
742
628
|
var _targetGraph2;
|
|
743
|
-
|
|
744
629
|
return _react2().default.createElement(_client().CurrentAppInfoContext.Provider, {
|
|
745
630
|
value: database
|
|
746
631
|
}, _react2().default.createElement(_client().APIClientProvider, {
|
|
@@ -749,7 +634,7 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
749
634
|
inherit: true,
|
|
750
635
|
scope: scope,
|
|
751
636
|
components: components
|
|
752
|
-
}, _react2().default.createElement(_client().CollectionCategroriesProvider,
|
|
637
|
+
}, _react2().default.createElement(_client().CollectionCategroriesProvider, _objectSpread({}, categoryCtx), _react2().default.createElement(_client().CollectionManagerProvider, {
|
|
753
638
|
collections: (_targetGraph2 = targetGraph) === null || _targetGraph2 === void 0 ? void 0 : _targetGraph2.collections,
|
|
754
639
|
refreshCM: refreshGM,
|
|
755
640
|
interfaces: ctx.interfaces
|
|
@@ -788,7 +673,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
788
673
|
refHeight: 100
|
|
789
674
|
}
|
|
790
675
|
}, true);
|
|
791
|
-
|
|
792
676
|
targetGraph.on('edge:mouseleave', ({
|
|
793
677
|
e,
|
|
794
678
|
edge: targetEdge
|
|
@@ -804,7 +688,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
804
688
|
const connectEdges = targetGraph.getConnectedEdges(node);
|
|
805
689
|
const currentPosition = node.position();
|
|
806
690
|
const oldPosition = targetGraph.positions.find(v => v.collectionName === node.store.data.name);
|
|
807
|
-
|
|
808
691
|
if (oldPosition) {
|
|
809
692
|
(oldPosition.x !== currentPosition.x || oldPosition.y !== currentPosition.y) && useUpdatePositionAction(_objectSpread({
|
|
810
693
|
collectionName: node.store.data.name
|
|
@@ -814,7 +697,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
814
697
|
collectionName: node.store.data.name
|
|
815
698
|
}, currentPosition));
|
|
816
699
|
}
|
|
817
|
-
|
|
818
700
|
connectEdges.forEach(edge => {
|
|
819
701
|
optimizeEdge(edge);
|
|
820
702
|
});
|
|
@@ -826,20 +708,16 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
826
708
|
}) => {
|
|
827
709
|
e.stopPropagation();
|
|
828
710
|
cell.toFront();
|
|
829
|
-
|
|
830
711
|
if (edge) {
|
|
831
712
|
handleEdgeActive(edge);
|
|
832
713
|
}
|
|
833
714
|
});
|
|
834
715
|
targetGraph.on('blank:click', e => {
|
|
835
716
|
var _targetGraph3, _targetGraph$collapse;
|
|
836
|
-
|
|
837
717
|
if ((_targetGraph3 = targetGraph) === null || _targetGraph3 === void 0 ? void 0 : _targetGraph3.activeEdge) {
|
|
838
718
|
var _targetGraph4;
|
|
839
|
-
|
|
840
719
|
handleEdgeUnActive((_targetGraph4 = targetGraph) === null || _targetGraph4 === void 0 ? void 0 : _targetGraph4.activeEdge);
|
|
841
720
|
}
|
|
842
|
-
|
|
843
721
|
(_targetGraph$collapse = targetGraph.collapseNodes) === null || _targetGraph$collapse === void 0 ? void 0 : _targetGraph$collapse.map(v => {
|
|
844
722
|
const node = targetGraph.getCell(Object.keys(v)[0]);
|
|
845
723
|
Object.values(v)[0] && node.setData({
|
|
@@ -865,19 +743,14 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
865
743
|
});
|
|
866
744
|
});
|
|
867
745
|
};
|
|
868
|
-
|
|
869
746
|
const handleEdgeUnActive = targetEdge => {
|
|
870
747
|
var _targetEdge$store;
|
|
871
|
-
|
|
872
748
|
targetGraph.activeEdge = null;
|
|
873
|
-
|
|
874
749
|
const _targetEdge$store$dat = (_targetEdge$store = targetEdge.store) === null || _targetEdge$store === void 0 ? void 0 : _targetEdge$store.data,
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
750
|
+
m2m = _targetEdge$store$dat.m2m,
|
|
751
|
+
connectionType = _targetEdge$store$dat.connectionType;
|
|
878
752
|
const m2mLineId = m2m === null || m2m === void 0 ? void 0 : m2m.find(v => v !== targetEdge.id);
|
|
879
753
|
const m2mEdge = targetGraph.getCellById(m2mLineId);
|
|
880
|
-
|
|
881
754
|
const lightsOut = edge => {
|
|
882
755
|
const targeNode = targetGraph.getCellById(edge.store.data.target.cell);
|
|
883
756
|
const sourceNode = targetGraph.getCellById(edge.store.data.source.cell);
|
|
@@ -911,24 +784,18 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
911
784
|
});
|
|
912
785
|
}));
|
|
913
786
|
};
|
|
914
|
-
|
|
915
787
|
lightsOut(targetEdge);
|
|
916
788
|
m2mEdge && lightsOut(m2mEdge);
|
|
917
789
|
};
|
|
918
|
-
|
|
919
790
|
const handleEdgeActive = targetEdge => {
|
|
920
791
|
var _targetEdge$store2;
|
|
921
|
-
|
|
922
792
|
targetGraph.activeEdge = targetEdge;
|
|
923
|
-
|
|
924
793
|
const _targetEdge$store$dat2 = (_targetEdge$store2 = targetEdge.store) === null || _targetEdge$store2 === void 0 ? void 0 : _targetEdge$store2.data,
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
794
|
+
associated = _targetEdge$store$dat2.associated,
|
|
795
|
+
m2m = _targetEdge$store$dat2.m2m,
|
|
796
|
+
connectionType = _targetEdge$store$dat2.connectionType;
|
|
929
797
|
const m2mLineId = m2m === null || m2m === void 0 ? void 0 : m2m.find(v => v !== targetEdge.id);
|
|
930
798
|
const m2mEdge = targetGraph.getCellById(m2mLineId);
|
|
931
|
-
|
|
932
799
|
const lightUp = edge => {
|
|
933
800
|
edge.toFront();
|
|
934
801
|
edge.setAttrs({
|
|
@@ -969,18 +836,15 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
969
836
|
associated
|
|
970
837
|
});
|
|
971
838
|
};
|
|
972
|
-
|
|
973
839
|
lightUp(targetEdge);
|
|
974
840
|
m2mEdge && lightUp(m2mEdge);
|
|
975
|
-
};
|
|
976
|
-
|
|
977
|
-
|
|
841
|
+
};
|
|
842
|
+
// 首次渲染
|
|
978
843
|
const renderInitGraphCollection = rawData => {
|
|
979
844
|
const _formatData = (0, _utils.formatData)(rawData),
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
845
|
+
nodesData = _formatData.nodesData,
|
|
846
|
+
edgesData = _formatData.edgesData,
|
|
847
|
+
inheritEdges = _formatData.inheritEdges;
|
|
984
848
|
targetGraph.data = {
|
|
985
849
|
nodes: nodesData,
|
|
986
850
|
edges: edgesData
|
|
@@ -989,18 +853,15 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
989
853
|
getEdges(edgesData);
|
|
990
854
|
getEdges(inheritEdges);
|
|
991
855
|
layout(useSaveGraphPositionAction);
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
|
|
856
|
+
};
|
|
857
|
+
// 增量渲染
|
|
995
858
|
const renderDiffGraphCollection = rawData => {
|
|
996
859
|
const _targetGraph5 = targetGraph,
|
|
997
|
-
|
|
998
|
-
|
|
860
|
+
positions = _targetGraph5.positions;
|
|
999
861
|
const _formatData2 = (0, _utils.formatData)(rawData),
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
862
|
+
nodesData = _formatData2.nodesData,
|
|
863
|
+
edgesData = _formatData2.edgesData,
|
|
864
|
+
inheritEdges = _formatData2.inheritEdges;
|
|
1004
865
|
const currentNodes = targetGraph.getNodes().map(v => v.store.data);
|
|
1005
866
|
const totalEdges = targetGraph.getEdges().map(v => v.store.data);
|
|
1006
867
|
const currentEdgesGroup = (0, _lodash().groupBy)(totalEdges, v => {
|
|
@@ -1019,7 +880,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1019
880
|
port
|
|
1020
881
|
}) => {
|
|
1021
882
|
const updateNode = targetGraph.getCellById(node.id);
|
|
1022
|
-
|
|
1023
883
|
switch (status) {
|
|
1024
884
|
case 'add':
|
|
1025
885
|
const maxY = (0, _lodash().maxBy)(positions, 'y').y;
|
|
@@ -1028,7 +888,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1028
888
|
});
|
|
1029
889
|
let referenceNode = (0, _lodash().maxBy)(yNodes, 'x');
|
|
1030
890
|
let position;
|
|
1031
|
-
|
|
1032
891
|
if (referenceNode.x > 4500) {
|
|
1033
892
|
const minX = (0, _lodash().minBy)(positions, 'x').x;
|
|
1034
893
|
referenceNode = (0, _lodash().minBy)(yNodes, 'x');
|
|
@@ -1042,7 +901,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1042
901
|
y: referenceNode.y
|
|
1043
902
|
};
|
|
1044
903
|
}
|
|
1045
|
-
|
|
1046
904
|
targetNode = targetGraph.addNode(_objectSpread(_objectSpread({}, node), {}, {
|
|
1047
905
|
position
|
|
1048
906
|
}));
|
|
@@ -1053,29 +911,23 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1053
911
|
padding: 200
|
|
1054
912
|
});
|
|
1055
913
|
break;
|
|
1056
|
-
|
|
1057
914
|
case 'insertPort':
|
|
1058
915
|
updateNode.insertPort(port.index, port.port);
|
|
1059
916
|
break;
|
|
1060
|
-
|
|
1061
917
|
case 'deletePort':
|
|
1062
918
|
updateNode.removePort(port.id);
|
|
1063
919
|
break;
|
|
1064
|
-
|
|
1065
920
|
case 'updateNode':
|
|
1066
921
|
updateNode.setProp({
|
|
1067
922
|
title: node.title
|
|
1068
923
|
});
|
|
1069
924
|
break;
|
|
1070
|
-
|
|
1071
925
|
case 'delete':
|
|
1072
926
|
targetGraph.removeCell(node.id);
|
|
1073
|
-
|
|
1074
927
|
default:
|
|
1075
928
|
return null;
|
|
1076
929
|
}
|
|
1077
930
|
});
|
|
1078
|
-
|
|
1079
931
|
const renderDiffEdges = data => {
|
|
1080
932
|
data.forEach(({
|
|
1081
933
|
status,
|
|
@@ -1086,25 +938,20 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1086
938
|
const newEdge = targetGraph.addEdge(_objectSpread({}, edge));
|
|
1087
939
|
optimizeEdge(newEdge);
|
|
1088
940
|
break;
|
|
1089
|
-
|
|
1090
941
|
case 'delete':
|
|
1091
942
|
targetGraph.removeCell(edge.id);
|
|
1092
943
|
break;
|
|
1093
|
-
|
|
1094
944
|
default:
|
|
1095
945
|
return null;
|
|
1096
946
|
}
|
|
1097
947
|
});
|
|
1098
948
|
};
|
|
1099
|
-
|
|
1100
949
|
setTimeout(() => {
|
|
1101
950
|
renderDiffEdges(diffEdges.concat(diffInheritEdge));
|
|
1102
951
|
});
|
|
1103
952
|
};
|
|
1104
|
-
|
|
1105
953
|
const handleSearchCollection = e => {
|
|
1106
954
|
const value = e.target.value.toLowerCase();
|
|
1107
|
-
|
|
1108
955
|
if (value) {
|
|
1109
956
|
const targetCollections = collectionData.filter(v => {
|
|
1110
957
|
const collectionTitle = compile(v.title).toLowerCase();
|
|
@@ -1114,15 +961,13 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1114
961
|
} else {
|
|
1115
962
|
setCollectionList(collectionData);
|
|
1116
963
|
}
|
|
1117
|
-
};
|
|
1118
|
-
|
|
1119
|
-
|
|
964
|
+
};
|
|
965
|
+
// 处理不同方向的继承关系表
|
|
1120
966
|
const hanleHighlightInheritedNode = (key, direction) => {
|
|
1121
967
|
if (direction === DirectionType.Target) {
|
|
1122
968
|
const INodes = (0, _utils.getInheritCollections)(targetGraph.collections, key);
|
|
1123
969
|
INodes.forEach(v => {
|
|
1124
970
|
var _targetGraph$getCellB;
|
|
1125
|
-
|
|
1126
971
|
(_targetGraph$getCellB = targetGraph.getCellById(v)) === null || _targetGraph$getCellB === void 0 ? void 0 : _targetGraph$getCellB.setAttrs({
|
|
1127
972
|
hightLight: true,
|
|
1128
973
|
direction,
|
|
@@ -1133,7 +978,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1133
978
|
const INodes = (0, _utils.getChildrenCollections)(targetGraph.collections, key);
|
|
1134
979
|
INodes.forEach(v => {
|
|
1135
980
|
var _targetGraph$getCellB2;
|
|
1136
|
-
|
|
1137
981
|
(_targetGraph$getCellB2 = targetGraph.getCellById(v.name)) === null || _targetGraph$getCellB2 === void 0 ? void 0 : _targetGraph$getCellB2.setAttrs({
|
|
1138
982
|
hightLight: true,
|
|
1139
983
|
direction,
|
|
@@ -1141,31 +985,25 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1141
985
|
});
|
|
1142
986
|
});
|
|
1143
987
|
}
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
|
|
988
|
+
};
|
|
989
|
+
// target index entity relation
|
|
1147
990
|
const handelTargetIndexEntity = key => {
|
|
1148
991
|
const node = targetGraph.getCellById(key);
|
|
1149
992
|
targetGraph.cacheCollection[key] = true;
|
|
1150
993
|
const connectedEdges = targetGraph.getConnectedEdges(node);
|
|
1151
994
|
let visibleEdges = connectedEdges.filter(v => {
|
|
1152
995
|
var _v$store$data;
|
|
1153
|
-
|
|
1154
996
|
return !((_v$store$data = v.store.data) === null || _v$store$data === void 0 ? void 0 : _v$store$data.connectionType) && v.getTargetCellId() === key;
|
|
1155
997
|
});
|
|
1156
998
|
visibleEdges.forEach(v => {
|
|
1157
999
|
var _node$store$data$attr2;
|
|
1158
|
-
|
|
1159
1000
|
if (v.store.data.m2m) {
|
|
1160
1001
|
v.store.data.m2m.forEach(i => {
|
|
1161
1002
|
const m2mEdge = targetGraph.getCellById(i);
|
|
1162
|
-
|
|
1163
1003
|
if (m2mEdge.getTargetCellId() === key) {
|
|
1164
1004
|
var _node$store$data$attr;
|
|
1165
|
-
|
|
1166
1005
|
const sourceId = m2mEdge.getSourceCellId();
|
|
1167
1006
|
const node = targetGraph.getCellById(sourceId);
|
|
1168
|
-
|
|
1169
1007
|
if (!((_node$store$data$attr = node.store.data.attrs) === null || _node$store$data$attr === void 0 ? void 0 : _node$store$data$attr.hightLight)) {
|
|
1170
1008
|
node.setAttrs({
|
|
1171
1009
|
hightLight: true,
|
|
@@ -1177,10 +1015,8 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1177
1015
|
}
|
|
1178
1016
|
});
|
|
1179
1017
|
}
|
|
1180
|
-
|
|
1181
1018
|
const sourceId = v.getSourceCellId();
|
|
1182
1019
|
const node = targetGraph.getCellById(sourceId);
|
|
1183
|
-
|
|
1184
1020
|
if (!((_node$store$data$attr2 = node.store.data.attrs) === null || _node$store$data$attr2 === void 0 ? void 0 : _node$store$data$attr2.hightLight)) {
|
|
1185
1021
|
node.setAttrs({
|
|
1186
1022
|
hightLight: true,
|
|
@@ -1190,30 +1026,24 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1190
1026
|
handelTargetIndexEntity(sourceId);
|
|
1191
1027
|
}
|
|
1192
1028
|
});
|
|
1193
|
-
};
|
|
1194
|
-
|
|
1195
|
-
|
|
1029
|
+
};
|
|
1030
|
+
// source index entity relation
|
|
1196
1031
|
const handelSourceIndexEntity = key => {
|
|
1197
1032
|
const node = targetGraph.getCellById(key);
|
|
1198
1033
|
const connectedEdges = targetGraph.getConnectedEdges(node);
|
|
1199
1034
|
const visibleEdges = connectedEdges.filter(v => {
|
|
1200
1035
|
var _v$store$data2;
|
|
1201
|
-
|
|
1202
1036
|
return !((_v$store$data2 = v.store.data) === null || _v$store$data2 === void 0 ? void 0 : _v$store$data2.connectionType) && v.getSourceCellId() === key;
|
|
1203
1037
|
});
|
|
1204
1038
|
visibleEdges.forEach(v => {
|
|
1205
1039
|
var _node$store$data$attr4;
|
|
1206
|
-
|
|
1207
1040
|
if (v.store.data.m2m) {
|
|
1208
1041
|
v.store.data.m2m.forEach(i => {
|
|
1209
1042
|
const m2mEdge = targetGraph.getCellById(i);
|
|
1210
|
-
|
|
1211
1043
|
if (m2mEdge.getSourceCellId() === key) {
|
|
1212
1044
|
var _node$store$data$attr3;
|
|
1213
|
-
|
|
1214
1045
|
const targetId = m2mEdge.getTargetCellId();
|
|
1215
1046
|
const node = targetGraph.getCellById(targetId);
|
|
1216
|
-
|
|
1217
1047
|
if (!((_node$store$data$attr3 = node.store.data.attrs) === null || _node$store$data$attr3 === void 0 ? void 0 : _node$store$data$attr3.hightLight)) {
|
|
1218
1048
|
node.setAttrs({
|
|
1219
1049
|
hightLight: true,
|
|
@@ -1225,10 +1055,8 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1225
1055
|
}
|
|
1226
1056
|
});
|
|
1227
1057
|
}
|
|
1228
|
-
|
|
1229
1058
|
const targetId = v.getTargetCellId();
|
|
1230
1059
|
const node = targetGraph.getCellById(targetId);
|
|
1231
|
-
|
|
1232
1060
|
if (!((_node$store$data$attr4 = node.store.data.attrs) === null || _node$store$data$attr4 === void 0 ? void 0 : _node$store$data$attr4.hightLight)) {
|
|
1233
1061
|
node.setAttrs({
|
|
1234
1062
|
hightLight: true,
|
|
@@ -1238,9 +1066,8 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1238
1066
|
handelSourceIndexEntity(targetId);
|
|
1239
1067
|
}
|
|
1240
1068
|
});
|
|
1241
|
-
};
|
|
1242
|
-
|
|
1243
|
-
|
|
1069
|
+
};
|
|
1070
|
+
// 处理不同方向的实体关系表
|
|
1244
1071
|
const handleHighlightRelationNodes = (nodekey, direction) => {
|
|
1245
1072
|
if (direction === DirectionType.Target) {
|
|
1246
1073
|
handelTargetIndexEntity(nodekey);
|
|
@@ -1248,26 +1075,20 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1248
1075
|
handelSourceIndexEntity(nodekey);
|
|
1249
1076
|
}
|
|
1250
1077
|
};
|
|
1251
|
-
|
|
1252
1078
|
const handleCleanHighlight = (key, currentDirection, currentConnectionType) => {
|
|
1253
1079
|
const nodes = targetGraph.getNodes().filter(v => {
|
|
1254
1080
|
var _v$store$data$attrs;
|
|
1255
|
-
|
|
1256
1081
|
return (_v$store$data$attrs = v.store.data.attrs) === null || _v$store$data$attrs === void 0 ? void 0 : _v$store$data$attrs.hightLight;
|
|
1257
1082
|
});
|
|
1258
1083
|
const length = nodes.length;
|
|
1259
|
-
|
|
1260
1084
|
for (let i = 0; i < length; i++) {
|
|
1261
1085
|
var _targetGraph$filterCo, _targetGraph$filterCo2;
|
|
1262
|
-
|
|
1263
1086
|
const _nodes$i$getAttrs = nodes[i].getAttrs(),
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1087
|
+
direction = _nodes$i$getAttrs.direction,
|
|
1088
|
+
connectionType = _nodes$i$getAttrs.connectionType;
|
|
1267
1089
|
const filterFlag = nodes[i].id !== key;
|
|
1268
1090
|
const directionFlag = key && ((_targetGraph$filterCo = targetGraph.filterConfig) === null || _targetGraph$filterCo === void 0 ? void 0 : _targetGraph$filterCo.key) === key ? direction !== currentDirection : true;
|
|
1269
1091
|
const renltionshipFlag = key && ((_targetGraph$filterCo2 = targetGraph.filterConfig) === null || _targetGraph$filterCo2 === void 0 ? void 0 : _targetGraph$filterCo2.key) === key ? connectionType !== currentConnectionType : true;
|
|
1270
|
-
|
|
1271
1092
|
if (nodes[i].id !== key) {
|
|
1272
1093
|
setTimeout(() => {
|
|
1273
1094
|
filterFlag && (directionFlag || renltionshipFlag) && nodes[i].setAttrs({
|
|
@@ -1277,15 +1098,13 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1277
1098
|
}
|
|
1278
1099
|
}
|
|
1279
1100
|
};
|
|
1280
|
-
|
|
1281
1101
|
const handleFiterCollections = value => {
|
|
1282
1102
|
const _targetGraph6 = targetGraph,
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1103
|
+
connectionType = _targetGraph6.connectionType,
|
|
1104
|
+
direction = _targetGraph6.direction,
|
|
1105
|
+
filterConfig = _targetGraph6.filterConfig;
|
|
1286
1106
|
const directionBothFlag1 = value === (filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.key) && direction === DirectionType.Both;
|
|
1287
1107
|
const relationshipBothFlag = value === (filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.key) && (connectionType === ConnectionType.Both || connectionType === filterConfig.connectionType);
|
|
1288
|
-
|
|
1289
1108
|
if (value) {
|
|
1290
1109
|
(!directionBothFlag1 || !relationshipBothFlag) && handleCleanHighlight(value, direction, connectionType);
|
|
1291
1110
|
targetNode = targetGraph.getCellById(value);
|
|
@@ -1306,7 +1125,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1306
1125
|
direction === DirectionType.Source && handleHighlightRelationNodes(value, direction);
|
|
1307
1126
|
}
|
|
1308
1127
|
}
|
|
1309
|
-
|
|
1310
1128
|
if ([ConnectionType.Inherit, ConnectionType.Both].includes(connectionType)) {
|
|
1311
1129
|
if (direction === DirectionType.Both) {
|
|
1312
1130
|
hanleHighlightInheritedNode(value, DirectionType.Target);
|
|
@@ -1315,7 +1133,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1315
1133
|
hanleHighlightInheritedNode(value, direction);
|
|
1316
1134
|
}
|
|
1317
1135
|
}
|
|
1318
|
-
|
|
1319
1136
|
targetGraph.filterConfig = {
|
|
1320
1137
|
key: value,
|
|
1321
1138
|
direction: direction,
|
|
@@ -1326,17 +1143,14 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1326
1143
|
handleCleanHighlight();
|
|
1327
1144
|
}
|
|
1328
1145
|
};
|
|
1329
|
-
|
|
1330
1146
|
const handleSetRelationshipType = type => {
|
|
1331
1147
|
handleSetEdgeVisible(type);
|
|
1332
1148
|
};
|
|
1333
|
-
|
|
1334
1149
|
const handleSetEdgeVisible = type => {
|
|
1335
1150
|
targetNode = null;
|
|
1336
1151
|
const edges = targetGraph.getEdges();
|
|
1337
1152
|
edges.forEach(v => {
|
|
1338
1153
|
const connectionType = v.store.data.connectionType;
|
|
1339
|
-
|
|
1340
1154
|
if (type === ConnectionType.Entity) {
|
|
1341
1155
|
if (connectionType) {
|
|
1342
1156
|
v.setVisible(false);
|
|
@@ -1354,7 +1168,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1354
1168
|
}
|
|
1355
1169
|
});
|
|
1356
1170
|
};
|
|
1357
|
-
|
|
1358
1171
|
(0, _react2().useLayoutEffect)(() => {
|
|
1359
1172
|
initGraphCollections();
|
|
1360
1173
|
return () => {
|
|
@@ -1371,22 +1184,18 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1371
1184
|
refreshGM();
|
|
1372
1185
|
});
|
|
1373
1186
|
}, []);
|
|
1374
|
-
|
|
1375
1187
|
const loadCollections = /*#__PURE__*/function () {
|
|
1376
1188
|
var _ref5 = _asyncToGenerator(function* () {
|
|
1377
1189
|
var _targetGraph$collecti;
|
|
1378
|
-
|
|
1379
1190
|
return (_targetGraph$collecti = targetGraph.collections) === null || _targetGraph$collecti === void 0 ? void 0 : _targetGraph$collecti.map(collection => ({
|
|
1380
1191
|
label: compile(collection.title),
|
|
1381
1192
|
value: collection.name
|
|
1382
1193
|
}));
|
|
1383
1194
|
});
|
|
1384
|
-
|
|
1385
1195
|
return function loadCollections() {
|
|
1386
1196
|
return _ref5.apply(this, arguments);
|
|
1387
1197
|
};
|
|
1388
1198
|
}();
|
|
1389
|
-
|
|
1390
1199
|
return _react2().default.createElement(_antd().Layout, null, _react2().default.createElement("div", {
|
|
1391
1200
|
className: (0, _css().cx)(_style.graphCollectionContainerClass)
|
|
1392
1201
|
}, _react2().default.createElement(_client().CollectionManagerProvider, {
|
|
@@ -1454,10 +1263,9 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1454
1263
|
'x-component-props': {
|
|
1455
1264
|
component: (0, _react2().forwardRef)(() => {
|
|
1456
1265
|
const _useFullscreen = (0, _ahooks().useFullscreen)(document.getElementById('graph_container')),
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1266
|
+
_useFullscreen2 = _slicedToArray(_useFullscreen, 2),
|
|
1267
|
+
isFullscreen = _useFullscreen2[0],
|
|
1268
|
+
toggleFullscreen = _useFullscreen2[1].toggleFullscreen;
|
|
1461
1269
|
return _react2().default.createElement(_antd().Tooltip, {
|
|
1462
1270
|
title: t('Full Screen'),
|
|
1463
1271
|
getPopupContainer: getPopupContainer
|
|
@@ -1470,7 +1278,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1470
1278
|
useAction: () => {
|
|
1471
1279
|
return {
|
|
1472
1280
|
run() {}
|
|
1473
|
-
|
|
1474
1281
|
};
|
|
1475
1282
|
}
|
|
1476
1283
|
}
|
|
@@ -1479,14 +1286,12 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1479
1286
|
type: 'void',
|
|
1480
1287
|
'x-component': () => {
|
|
1481
1288
|
const _useContext = (0, _react2().useContext)(CollapsedContext),
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1289
|
+
handleSearchCollection = _useContext.handleSearchCollection,
|
|
1290
|
+
collectionList = _useContext.collectionList;
|
|
1485
1291
|
const _useState5 = (0, _react2().useState)([]),
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1292
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1293
|
+
selectedKeys = _useState6[0],
|
|
1294
|
+
setSelectKey = _useState6[1];
|
|
1490
1295
|
const content = _react2().default.createElement("div", null, _react2().default.createElement(_antd().Input, {
|
|
1491
1296
|
style: {
|
|
1492
1297
|
margin: '4px 0'
|
|
@@ -1523,7 +1328,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1523
1328
|
}
|
|
1524
1329
|
}, _react2().default.createElement("span", null, compile(v.title)));
|
|
1525
1330
|
})));
|
|
1526
|
-
|
|
1527
1331
|
return _react2().default.createElement(_antd().Popover, {
|
|
1528
1332
|
content: content,
|
|
1529
1333
|
autoAdjustOverflow: true,
|
|
@@ -1542,7 +1346,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1542
1346
|
useAction: () => {
|
|
1543
1347
|
return {
|
|
1544
1348
|
run() {}
|
|
1545
|
-
|
|
1546
1349
|
};
|
|
1547
1350
|
}
|
|
1548
1351
|
}
|
|
@@ -1564,7 +1367,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1564
1367
|
useAction: () => {
|
|
1565
1368
|
return {
|
|
1566
1369
|
run() {}
|
|
1567
|
-
|
|
1568
1370
|
};
|
|
1569
1371
|
}
|
|
1570
1372
|
}
|
|
@@ -1582,7 +1384,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1582
1384
|
key: ConnectionType.Inherit,
|
|
1583
1385
|
label: 'Inheritance relationship only'
|
|
1584
1386
|
}];
|
|
1585
|
-
|
|
1586
1387
|
const content = _react2().default.createElement("div", null, _react2().default.createElement(_antd().Menu, {
|
|
1587
1388
|
defaultSelectedKeys: [ConnectionType.Both],
|
|
1588
1389
|
selectable: true,
|
|
@@ -1603,13 +1404,12 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1603
1404
|
onClick: e => {
|
|
1604
1405
|
targetGraph.connectionType = v.key;
|
|
1605
1406
|
const _targetGraph8 = targetGraph,
|
|
1606
|
-
|
|
1407
|
+
filterConfig = _targetGraph8.filterConfig;
|
|
1607
1408
|
filterConfig && handleFiterCollections(filterConfig.key);
|
|
1608
1409
|
handleSetRelationshipType(v.key);
|
|
1609
1410
|
}
|
|
1610
1411
|
}, _react2().default.createElement("span", null, t(v.label)));
|
|
1611
1412
|
})));
|
|
1612
|
-
|
|
1613
1413
|
return _react2().default.createElement(_antd().Popover, {
|
|
1614
1414
|
content: content,
|
|
1615
1415
|
autoAdjustOverflow: true,
|
|
@@ -1628,7 +1428,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1628
1428
|
useAction: () => {
|
|
1629
1429
|
return {
|
|
1630
1430
|
run() {}
|
|
1631
|
-
|
|
1632
1431
|
};
|
|
1633
1432
|
}
|
|
1634
1433
|
}
|
|
@@ -1646,7 +1445,6 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1646
1445
|
key: DirectionType.Source,
|
|
1647
1446
|
label: 'Source index'
|
|
1648
1447
|
}];
|
|
1649
|
-
|
|
1650
1448
|
const content = _react2().default.createElement("div", null, _react2().default.createElement(_antd().Menu, {
|
|
1651
1449
|
defaultSelectedKeys: [DirectionType.Target],
|
|
1652
1450
|
selectable: true,
|
|
@@ -1667,15 +1465,13 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1667
1465
|
onClick: e => {
|
|
1668
1466
|
targetGraph.direction = v.key;
|
|
1669
1467
|
const _targetGraph9 = targetGraph,
|
|
1670
|
-
|
|
1671
|
-
|
|
1468
|
+
filterConfig = _targetGraph9.filterConfig;
|
|
1672
1469
|
if (filterConfig) {
|
|
1673
1470
|
handleFiterCollections(filterConfig.key);
|
|
1674
1471
|
}
|
|
1675
1472
|
}
|
|
1676
1473
|
}, _react2().default.createElement("span", null, t(v.label)));
|
|
1677
1474
|
})));
|
|
1678
|
-
|
|
1679
1475
|
return _react2().default.createElement(_antd().Popover, {
|
|
1680
1476
|
content: content,
|
|
1681
1477
|
autoAdjustOverflow: true,
|
|
@@ -1731,5 +1527,4 @@ const GraphDrawPage = _react2().default.memo(() => {
|
|
|
1731
1527
|
}
|
|
1732
1528
|
})));
|
|
1733
1529
|
});
|
|
1734
|
-
|
|
1735
1530
|
exports.GraphDrawPage = GraphDrawPage;
|