@riil-frontend/component-topology 9.0.0-a.20 → 9.0.0-a.21
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/build/index.js +9 -9
- package/es/core/editor/components/settings/core/updateElementProperty.js +6 -1
- package/es/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +104 -0
- package/es/core/editor/components/settings/propertyViews/node/data/Data.js +47 -14
- package/es/core/hooks/useTopoEdit.js +144 -16
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/utils/linkUtils.js +18 -0
- package/es/core/store/models/topoConfig.js +36 -7
- package/es/core/test/Test.js +3 -3
- package/es/networkTopo/services/link.js +1 -1
- package/es/networkTopo/services/topo/basic.js +26 -16
- package/es/networkTopo/services/topo/networkLink.js +45 -3
- package/es/networkTopo/utils/exitLinkUtil.js +224 -0
- package/es/utils/htElementUtils.js +21 -21
- package/lib/core/editor/components/settings/core/updateElementProperty.js +6 -1
- package/lib/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +120 -0
- package/lib/core/editor/components/settings/propertyViews/node/data/Data.js +49 -14
- package/lib/core/hooks/useTopoEdit.js +146 -15
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/utils/linkUtils.js +21 -1
- package/lib/core/store/models/topoConfig.js +37 -7
- package/lib/core/test/Test.js +3 -3
- package/lib/networkTopo/services/topo/basic.js +27 -16
- package/lib/networkTopo/services/topo/networkLink.js +45 -3
- package/lib/networkTopo/utils/exitLinkUtil.js +235 -0
- package/lib/utils/htElementUtils.js +21 -21
- package/package.json +2 -2
@@ -1,6 +1,11 @@
|
|
1
1
|
export default function updateElementProperty(topo, name, value) {
|
2
2
|
// const element = topo.getDataModel().getDataById(selection[0].id);
|
3
|
-
var element = topo.getSelectionModel().getFirstData();
|
3
|
+
var element = topo.getSelectionModel().getFirstData();
|
4
|
+
console.info("updateElementProperty", topo.getSelectionModel().getSelection(), {
|
5
|
+
element: element,
|
6
|
+
name: name,
|
7
|
+
value: value
|
8
|
+
});
|
4
9
|
|
5
10
|
if (name.startsWith('attrObject.')) {
|
6
11
|
element.setAttr(name.replace('attrObject.', ''), value);
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import _Button from "@alifd/next/es/button";
|
2
|
+
import _Input from "@alifd/next/es/input";
|
3
|
+
import _Form from "@alifd/next/es/form";
|
4
|
+
import React, { useState, useEffect } from "react";
|
5
|
+
import { isUniqueIp } from "../../../../../../../networkTopo/utils/exitLinkUtil";
|
6
|
+
var FormItem = _Form.Item;
|
7
|
+
/**
|
8
|
+
* @return {React.ReactNode | null}
|
9
|
+
*/
|
10
|
+
|
11
|
+
export default function BindIpInput(props) {
|
12
|
+
var _values$attrObjectBi;
|
13
|
+
|
14
|
+
var nodeElement = props.nodeElement,
|
15
|
+
topo = props.topo,
|
16
|
+
topoEditApi = props.topoEditApi,
|
17
|
+
values = props.values,
|
18
|
+
onChange = props.onChange,
|
19
|
+
fieldItem = props.fieldItem; // const currentResId = node.tag;
|
20
|
+
// console.log(
|
21
|
+
// "nodeElement, topo, topoEditApi, node",
|
22
|
+
// nodeElement,
|
23
|
+
// topo,
|
24
|
+
// topoEditApi,
|
25
|
+
// values
|
26
|
+
// );
|
27
|
+
|
28
|
+
var _useState = useState(""),
|
29
|
+
error = _useState[0],
|
30
|
+
setError = _useState[1];
|
31
|
+
|
32
|
+
var _useState2 = useState((_values$attrObjectBi = values["attrObject.bindIp"]) !== null && _values$attrObjectBi !== void 0 ? _values$attrObjectBi : ""),
|
33
|
+
txtValue = _useState2[0],
|
34
|
+
setTxtValue = _useState2[1];
|
35
|
+
|
36
|
+
var saveIp = function saveIp(v) {
|
37
|
+
fieldItem.validate(function (errors, vals) {
|
38
|
+
if (errors) {
|
39
|
+
console.error("saveIp-error", errors, vals);
|
40
|
+
} else {
|
41
|
+
console.log("saveIp", txtValue);
|
42
|
+
setError("");
|
43
|
+
onChange(txtValue);
|
44
|
+
topoEditApi.relateNodeIp(txtValue, nodeElement);
|
45
|
+
}
|
46
|
+
});
|
47
|
+
};
|
48
|
+
|
49
|
+
useEffect(function () {
|
50
|
+
fieldItem.reset();
|
51
|
+
setTxtValue(values["attrObject.bindIp"]);
|
52
|
+
}, [values]);
|
53
|
+
|
54
|
+
var inputChange = function inputChange(v) {
|
55
|
+
setTxtValue(v); // onChange(v);
|
56
|
+
}; // 图片节点验证ip唯一性
|
57
|
+
|
58
|
+
|
59
|
+
var checkIp = function checkIp(rule, value, callback) {
|
60
|
+
var dm = topo.getDataModel();
|
61
|
+
var rex = /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/;
|
62
|
+
var reg = value.match(rex);
|
63
|
+
|
64
|
+
if (reg === null) {
|
65
|
+
return callback();
|
66
|
+
}
|
67
|
+
|
68
|
+
var isUnique = isUniqueIp(dm, value, nodeElement);
|
69
|
+
console.log("checkIp", isUnique);
|
70
|
+
|
71
|
+
if (!isUnique) {
|
72
|
+
return callback("ip不能重复");
|
73
|
+
} else {
|
74
|
+
return callback();
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
return /*#__PURE__*/React.createElement("div", {
|
79
|
+
style: {
|
80
|
+
display: "flex"
|
81
|
+
}
|
82
|
+
}, /*#__PURE__*/React.createElement(FormItem, {
|
83
|
+
label: "\u5173\u8054IP",
|
84
|
+
pattern: /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/,
|
85
|
+
patternTrigger: "onBlur",
|
86
|
+
patternMessage: "IP\u5730\u5740\u683C\u5F0F\u4E0D\u6B63\u786E",
|
87
|
+
validator: checkIp
|
88
|
+
}, /*#__PURE__*/React.createElement(_Input, {
|
89
|
+
placeholder: "\u8BF7\u8F93\u5165Ip\u5730\u5740",
|
90
|
+
name: "attrObject.bindIp",
|
91
|
+
state: error,
|
92
|
+
value: txtValue,
|
93
|
+
maxLength: 128,
|
94
|
+
onChange: inputChange
|
95
|
+
})), /*#__PURE__*/React.createElement(_Button, {
|
96
|
+
type: "primary",
|
97
|
+
text: true,
|
98
|
+
onClick: saveIp,
|
99
|
+
style: {
|
100
|
+
marginLeft: 10,
|
101
|
+
marginTop: 27
|
102
|
+
}
|
103
|
+
}, "\u4FDD\u5B58"));
|
104
|
+
}
|
@@ -9,26 +9,29 @@ import React, { useEffect } from "react";
|
|
9
9
|
import textStyles from "../../../../../../common/text.module.scss";
|
10
10
|
import NodeRelateResourceButton from "./NodeRelateResourceButton";
|
11
11
|
import PlatformDisplay from "./PlatformDisplay";
|
12
|
+
import BindIpInput from "./BindIpInput";
|
13
|
+
import { isUniqueIp } from "../../../../../../../networkTopo/utils/exitLinkUtil";
|
12
14
|
var Option = _Select.Option;
|
13
15
|
var CollapsePanel = _Collapse.Panel;
|
14
16
|
|
15
17
|
function parseValues(values) {
|
16
18
|
return _extends({}, values, {
|
17
19
|
"attrObject.customName": values["attrObject.customName"] || values["attrObject.name"],
|
18
|
-
"attrObject.bindTopo": values["attrObject.bindTopo"] || ""
|
19
|
-
|
20
|
+
"attrObject.bindTopo": values["attrObject.bindTopo"] || "",
|
21
|
+
// 解决切换节点时关联拓扑选项未重置
|
22
|
+
"attrObject.bindIp": values["attrObject.bindIp"] || ""
|
20
23
|
});
|
21
24
|
}
|
22
25
|
|
23
26
|
function getBindType(values) {
|
24
|
-
if (values.tag) {
|
25
|
-
return "resource";
|
26
|
-
}
|
27
|
-
|
28
27
|
if (values.attrObject.bindType) {
|
29
28
|
return values.attrObject.bindType;
|
30
29
|
}
|
31
30
|
|
31
|
+
if (values.tag && !values.tag.startsWith("ip:")) {
|
32
|
+
return "resource";
|
33
|
+
}
|
34
|
+
|
32
35
|
return "none";
|
33
36
|
}
|
34
37
|
|
@@ -39,15 +42,21 @@ export default function Data(props) {
|
|
39
42
|
values = props.values,
|
40
43
|
_onChange = props.onChange,
|
41
44
|
editorProps = props.editorProps;
|
42
|
-
var bindType = getBindType(values);
|
45
|
+
var bindType = getBindType(values); // console.log("node, values", node, values);
|
43
46
|
|
44
47
|
var field = _Field.useField({
|
45
48
|
autoUnmount: false,
|
46
49
|
values: parseValues(values),
|
47
50
|
onChange: function onChange(name, value) {
|
48
|
-
|
51
|
+
field.validate(function (errors, vals) {
|
52
|
+
if (errors) {
|
53
|
+
console.error("field-Data", errors, vals);
|
54
|
+
} else {
|
55
|
+
var newValues = field.getValues();
|
49
56
|
|
50
|
-
|
57
|
+
_onChange(name, value, newValues);
|
58
|
+
}
|
59
|
+
});
|
51
60
|
}
|
52
61
|
});
|
53
62
|
|
@@ -107,7 +116,7 @@ export default function Data(props) {
|
|
107
116
|
}, /*#__PURE__*/React.createElement(_Form, {
|
108
117
|
field: field,
|
109
118
|
labelAlign: "top"
|
110
|
-
}, !values.tag && /*#__PURE__*/React.createElement(_Form.Item, {
|
119
|
+
}, (!values.tag || bindType === "ip") && /*#__PURE__*/React.createElement(_Form.Item, {
|
111
120
|
label: "\u5173\u8054\u7C7B\u578B"
|
112
121
|
}, /*#__PURE__*/React.createElement(_Select, {
|
113
122
|
name: "bindType",
|
@@ -121,7 +130,9 @@ export default function Data(props) {
|
|
121
130
|
value: "none"
|
122
131
|
}, "\u672A\u5173\u8054"), /*#__PURE__*/React.createElement(Option, {
|
123
132
|
value: "resource"
|
124
|
-
}, "\u5173\u8054\u8D44\u6E90"),
|
133
|
+
}, "\u5173\u8054\u8D44\u6E90"), /*#__PURE__*/React.createElement(Option, {
|
134
|
+
value: "ip"
|
135
|
+
}, "\u5173\u8054IP"), RelateTopoTree && /*#__PURE__*/React.createElement(Option, {
|
125
136
|
value: "topo"
|
126
137
|
}, "\u5173\u8054\u62D3\u6251"))), bindType === "resource" && /*#__PURE__*/React.createElement(_Form.Item, {
|
127
138
|
label: "\u5173\u8054\u8D44\u6E90"
|
@@ -135,7 +146,7 @@ export default function Data(props) {
|
|
135
146
|
flex: 1,
|
136
147
|
paddingRight: 16,
|
137
148
|
color: "#4D6277",
|
138
|
-
lineHeight:
|
149
|
+
lineHeight: "20px"
|
139
150
|
},
|
140
151
|
title: values.tag ? values.name : null
|
141
152
|
}, values.tag ? values.name : "—"), /*#__PURE__*/React.createElement(NodeRelateResourceButton, {
|
@@ -144,13 +155,35 @@ export default function Data(props) {
|
|
144
155
|
topo: topo,
|
145
156
|
topoEditApi: topoEditApi,
|
146
157
|
nodeBindResourceDrawerComponent: editorProps.nodeBindResourceDrawerComponent
|
147
|
-
}))), bindType === "
|
158
|
+
}))), bindType === "ip" &&
|
159
|
+
/*#__PURE__*/
|
160
|
+
// <Form.Item
|
161
|
+
// label="关联IP"
|
162
|
+
// // style={{ display: "flex" }}
|
163
|
+
// pattern={
|
164
|
+
// /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/
|
165
|
+
// }
|
166
|
+
// patternTrigger="onBlur"
|
167
|
+
// patternMessage="IP地址格式不正确"
|
168
|
+
// >
|
169
|
+
React.createElement(BindIpInput, {
|
170
|
+
nodeElement: node,
|
171
|
+
values: values,
|
172
|
+
topo: topo,
|
173
|
+
fieldItem: field,
|
174
|
+
topoEditApi: topoEditApi,
|
175
|
+
placeholder: "\u8BF7\u8F93\u5165",
|
176
|
+
name: "attrObject.bindIp",
|
177
|
+
onChange: _onChange,
|
178
|
+
maxLength: 128
|
179
|
+
}) // </Form.Item>
|
180
|
+
, bindType === "topo" && RelateTopoTree && /*#__PURE__*/React.createElement(_Form.Item, {
|
148
181
|
label: "\u5173\u8054\u62D3\u6251"
|
149
182
|
}, /*#__PURE__*/React.createElement(RelateTopoTree, {
|
150
183
|
name: "attrObject.bindTopo",
|
151
184
|
topo: topo,
|
152
185
|
onChange: handleBindTopoChange
|
153
|
-
})), (editorProps === null || editorProps === void 0 ? void 0 : editorProps.topoType) ===
|
186
|
+
})), (editorProps === null || editorProps === void 0 ? void 0 : editorProps.topoType) === "cmpTopo" && node.getTag() && /*#__PURE__*/React.createElement(_Form.Item, {
|
154
187
|
label: "\u6240\u5C5E\u5E73\u53F0"
|
155
188
|
}, /*#__PURE__*/React.createElement(PlatformDisplay, props)))));
|
156
189
|
}
|
@@ -4,16 +4,19 @@ import _Dialog from "@alifd/next/es/dialog";
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
6
6
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
7
|
+
import _ from "lodash";
|
7
8
|
import rlog from "@riil-frontend/component-topology-utils/es/rlog";
|
8
9
|
import { TopoEvent } from "@riil-frontend/component-topology-graph";
|
9
10
|
import { TPL_BLANK, TPL_TREE } from "../../utils/template";
|
10
11
|
import topoPermissonUtil from "../../utils/topoPermissionUtil";
|
11
|
-
import { getElements, getGroupElementByTag, isEdge, isExistedElement, isGroup, isLayer, isNode } from "../../utils/htElementUtils";
|
12
|
+
import { getElements, getGroupElementByTag, isEdge, isExistedElement, isGroup, isLayer, isNode, getNodes } from "../../utils/htElementUtils";
|
12
13
|
import useResourceConfig from "./useResourceConfig";
|
13
14
|
import useGroupAddResource from "./useGroupAddResource";
|
14
15
|
import { findGroupChildren } from "../../utils/topoData";
|
15
16
|
import { getGroupChildrenResourceElements } from "../../utils/htElementDataUtil";
|
16
17
|
import { isClusterHtElement, isClusterMemberHtElement } from "../../utils/clusterUtil";
|
18
|
+
import { mergeExportLinkData } from "../models/utils/linkUtils";
|
19
|
+
import { isUniqueIp } from "../../networkTopo/utils/exitLinkUtil";
|
17
20
|
|
18
21
|
var useTopoEdit = function useTopoEdit(params) {
|
19
22
|
var topo = params.topo,
|
@@ -315,7 +318,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
315
318
|
|
316
319
|
edges.map(function (edge) {
|
317
320
|
if (edge.a("dtype") === "link" && exportLinkIdList.indexOf(edge.getTag()) >= 0) {
|
318
|
-
// exLink.push(edge);
|
321
|
+
// exLink.push(edge);
|
319
322
|
topo.getGraphView().dm().remove(edge);
|
320
323
|
exportLinkIdList.splice(config.exportLinkIdList.indexOf(edge.getTag()), 1);
|
321
324
|
}
|
@@ -378,8 +381,8 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
378
381
|
};
|
379
382
|
/**
|
380
383
|
* 获得未存在的连线元素
|
381
|
-
* @param {*} elements
|
382
|
-
* @returns
|
384
|
+
* @param {*} elements
|
385
|
+
* @returns
|
383
386
|
*/
|
384
387
|
|
385
388
|
|
@@ -392,8 +395,8 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
392
395
|
}
|
393
396
|
/**
|
394
397
|
* 获得未存在的元素
|
395
|
-
* @param {Array} elements
|
396
|
-
* @returns
|
398
|
+
* @param {Array} elements
|
399
|
+
* @returns
|
397
400
|
*/
|
398
401
|
|
399
402
|
|
@@ -569,7 +572,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
569
572
|
elements = _yield$editDispatcher4.elements;
|
570
573
|
// 2022-11-10 修复 添加资源后分层重新布局问题,仅布局新增资源。替换api topo.updateElements(data)
|
571
574
|
newElements = findUNExistedElements(elements);
|
572
|
-
rlog.debug(
|
575
|
+
rlog.debug("添加分层资源", {
|
573
576
|
layer: group,
|
574
577
|
newElements: newElements
|
575
578
|
});
|
@@ -642,8 +645,8 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
642
645
|
}
|
643
646
|
/**
|
644
647
|
* 未选中元素添加资源
|
645
|
-
*
|
646
|
-
* @param {*} data
|
648
|
+
*
|
649
|
+
* @param {*} data
|
647
650
|
*/
|
648
651
|
|
649
652
|
|
@@ -800,7 +803,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
800
803
|
newLinkElements = findUNExistedLinkElements(elements);
|
801
804
|
createElementsData = null;
|
802
805
|
|
803
|
-
if (newData.type ===
|
806
|
+
if (newData.type === "group") {
|
804
807
|
groupChildren = findGroupChildren(elements, newData);
|
805
808
|
newGroupChildren = [];
|
806
809
|
existedGroupChildren = [];
|
@@ -817,10 +820,10 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
817
820
|
groups: [newData],
|
818
821
|
nodes: newGroupChildren,
|
819
822
|
links: newLinkElements.filter(function (item) {
|
820
|
-
return item.type ===
|
823
|
+
return item.type === "link";
|
821
824
|
}),
|
822
825
|
linkGroups: newLinkElements.filter(function (item) {
|
823
|
-
return item.type ===
|
826
|
+
return item.type === "linkGroup";
|
824
827
|
})
|
825
828
|
};
|
826
829
|
htTopo.createElements(createElementsData); // 切换前图上如果存在集群内的节点,切换节点为集群后,移到集群内
|
@@ -835,16 +838,16 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
835
838
|
groups: [],
|
836
839
|
nodes: [newData],
|
837
840
|
links: newLinkElements.filter(function (item) {
|
838
|
-
return item.type ===
|
841
|
+
return item.type === "link";
|
839
842
|
}),
|
840
843
|
linkGroups: newLinkElements.filter(function (item) {
|
841
|
-
return item.type ===
|
844
|
+
return item.type === "linkGroup";
|
842
845
|
})
|
843
846
|
};
|
844
847
|
htTopo.createElements(createElementsData);
|
845
848
|
}
|
846
849
|
|
847
|
-
rlog.debug(
|
850
|
+
rlog.debug("批量创建元素", createElementsData); // 恢复图标、大小、位置
|
848
851
|
|
849
852
|
newElement = dm.getDataByTag(newData.id);
|
850
853
|
|
@@ -960,6 +963,126 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
960
963
|
return _ref8.apply(this, arguments);
|
961
964
|
};
|
962
965
|
}();
|
966
|
+
/**
|
967
|
+
* 关联IP的图片节点
|
968
|
+
*/
|
969
|
+
|
970
|
+
|
971
|
+
function relateNodeIp(_x15, _x16) {
|
972
|
+
return _relateNodeIp.apply(this, arguments);
|
973
|
+
}
|
974
|
+
|
975
|
+
function _relateNodeIp() {
|
976
|
+
_relateNodeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(txtValue, nodeElement) {
|
977
|
+
var _configObj$linkIps;
|
978
|
+
|
979
|
+
var dm, htTopo, elements, configObj, _yield$editDispatcher5, elementDatas, isUnique, ids, ip, re, config, linksData, createElementsData;
|
980
|
+
|
981
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
982
|
+
while (1) {
|
983
|
+
switch (_context16.prev = _context16.next) {
|
984
|
+
case 0:
|
985
|
+
// console.log("bindIPtoNode", data);
|
986
|
+
// 根据配置查询拓扑数据
|
987
|
+
dm = topo.getDataModel();
|
988
|
+
htTopo = topo.getHtTopo();
|
989
|
+
elements = getNodes(dm); // 获取配置
|
990
|
+
|
991
|
+
configObj = topo.resourceConfig.getConfig();
|
992
|
+
console.log("configObj", configObj);
|
993
|
+
configObj.linkIps = [].concat((_configObj$linkIps = configObj.linkIps) !== null && _configObj$linkIps !== void 0 ? _configObj$linkIps : [], [txtValue]);
|
994
|
+
console.log("configObj---over", configObj);
|
995
|
+
_context16.next = 9;
|
996
|
+
return resourceConfig.updateConfig(configObj);
|
997
|
+
|
998
|
+
case 9:
|
999
|
+
_context16.next = 11;
|
1000
|
+
return editDispatchers.fetchDataByConfig();
|
1001
|
+
|
1002
|
+
case 11:
|
1003
|
+
_yield$editDispatcher5 = _context16.sent;
|
1004
|
+
elementDatas = _yield$editDispatcher5.elementDatas;
|
1005
|
+
console.log("bindIPtoNode", txtValue, nodeElement, elements);
|
1006
|
+
console.log("elementDatas", elementDatas); // 执行唯一性验证
|
1007
|
+
|
1008
|
+
isUnique = isUniqueIp(dm, txtValue, nodeElement);
|
1009
|
+
ids = [];
|
1010
|
+
elements.map(function (element) {
|
1011
|
+
if (element.getTag()) {
|
1012
|
+
ids.push(element.getTag());
|
1013
|
+
}
|
1014
|
+
});
|
1015
|
+
ip = {
|
1016
|
+
id: "ip:" + txtValue,
|
1017
|
+
name: txtValue,
|
1018
|
+
customName: null,
|
1019
|
+
// 'groupId': null,
|
1020
|
+
// 'groupTag': null,
|
1021
|
+
ipAddress: txtValue,
|
1022
|
+
// 'attributes': [],
|
1023
|
+
// 'metrics': [],
|
1024
|
+
type: "node",
|
1025
|
+
isbinding: true // 'dtype': 'device'
|
1026
|
+
|
1027
|
+
}; // 获取关联链路
|
1028
|
+
|
1029
|
+
if (!isUnique) {
|
1030
|
+
_context16.next = 30;
|
1031
|
+
break;
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
nodeElement.a(ip);
|
1035
|
+
nodeElement.setName(txtValue); // nodeElement.a("name", txtValue);
|
1036
|
+
// nodeElement.a("customName", null);
|
1037
|
+
|
1038
|
+
nodeElement.setTag("ip:" + txtValue);
|
1039
|
+
_context16.next = 25;
|
1040
|
+
return editDispatchers.queryAllLinkByIp({
|
1041
|
+
ids: ids,
|
1042
|
+
ip: txtValue
|
1043
|
+
});
|
1044
|
+
|
1045
|
+
case 25:
|
1046
|
+
re = _context16.sent;
|
1047
|
+
console.log("queryAllLinkByIp", re);
|
1048
|
+
config = resourceConfig.getConfig();
|
1049
|
+
console.log("resourceConfig.getConfig", config);
|
1050
|
+
|
1051
|
+
if (re && re.length > 0) {
|
1052
|
+
linksData = [];
|
1053
|
+
re.map(function (link) {
|
1054
|
+
var sourceId = link.attributes["network_link.source_device_id"];
|
1055
|
+
var source = dm.getDataByTag(sourceId);
|
1056
|
+
var target = nodeElement; // console.log("source, nodeElement, link", source, target, link);
|
1057
|
+
|
1058
|
+
if (source && target) {
|
1059
|
+
var linkData = mergeExportLinkData({
|
1060
|
+
source: source,
|
1061
|
+
target: target,
|
1062
|
+
link: link
|
1063
|
+
});
|
1064
|
+
console.log("linkData", linkData);
|
1065
|
+
linksData.push(linkData); // htTopo.createEdge(source, target, link);
|
1066
|
+
}
|
1067
|
+
});
|
1068
|
+
createElementsData = {
|
1069
|
+
groups: [],
|
1070
|
+
nodes: [],
|
1071
|
+
links: [].concat(linksData),
|
1072
|
+
linkGroups: []
|
1073
|
+
};
|
1074
|
+
htTopo.createElements(createElementsData); // htTopo.addElements({ lines: [...re] });
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
case 30:
|
1078
|
+
case "end":
|
1079
|
+
return _context16.stop();
|
1080
|
+
}
|
1081
|
+
}
|
1082
|
+
}, _callee16);
|
1083
|
+
}));
|
1084
|
+
return _relateNodeIp.apply(this, arguments);
|
1085
|
+
}
|
963
1086
|
|
964
1087
|
var onEvent = function onEvent(e) {
|
965
1088
|
var map = {};
|
@@ -977,7 +1100,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
977
1100
|
*/
|
978
1101
|
|
979
1102
|
var setViewMouseMode = function setViewMouseMode(mode) {
|
980
|
-
rlog.debug(
|
1103
|
+
rlog.debug("设置视图鼠标模式", mode);
|
981
1104
|
topo.getHtTopo().setViewMouseMode(mode);
|
982
1105
|
topoEditDispatchers.update({
|
983
1106
|
viewMouseMode: mode
|
@@ -1055,6 +1178,11 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
1055
1178
|
*/
|
1056
1179
|
onDeleteElement: onDeleteElement,
|
1057
1180
|
|
1181
|
+
/**
|
1182
|
+
* 绑定图片ip
|
1183
|
+
*/
|
1184
|
+
relateNodeIp: relateNodeIp,
|
1185
|
+
|
1058
1186
|
/**
|
1059
1187
|
* 拓扑图保存回调
|
1060
1188
|
*/
|
@@ -24,7 +24,7 @@ import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
|
|
24
24
|
import SelectionModel from "./SelectionModel";
|
25
25
|
import CiCache from "./cache/CiCache"; // eslint-disable-next-line no-undef
|
26
26
|
|
27
|
-
var version = typeof "9.0.0-a.
|
27
|
+
var version = typeof "9.0.0-a.21" === 'string' ? "9.0.0-a.21" : null;
|
28
28
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
29
29
|
/**
|
30
30
|
* 拓扑显示和编辑
|
@@ -188,4 +188,22 @@ export var showLinkByConfig = function showLinkByConfig(props) {
|
|
188
188
|
}
|
189
189
|
});
|
190
190
|
}
|
191
|
+
};
|
192
|
+
export var mergeExportLinkData = function mergeExportLinkData(props) {
|
193
|
+
var source = props.source,
|
194
|
+
target = props.target,
|
195
|
+
link = props.link;
|
196
|
+
var attrObj = link.attributes;
|
197
|
+
|
198
|
+
var linkData = _extends({}, link, {
|
199
|
+
name: attrObj.name,
|
200
|
+
source: attrObj["network_link.source_device_id"],
|
201
|
+
target: attrObj.destination_type === 'ip' ? target.getTag() : attrObj["network_link.destination_device_id"],
|
202
|
+
operation: attrObj.operation,
|
203
|
+
interfaceSource: attrObj["source_id"],
|
204
|
+
interfaceTarget: attrObj["destination_id"],
|
205
|
+
ciType: link.typeCode
|
206
|
+
});
|
207
|
+
|
208
|
+
return linkData;
|
191
209
|
};
|
@@ -13,6 +13,7 @@ import { removeFromArray } from "../../../utils/format";
|
|
13
13
|
import { DEFAULT_GROUP } from "../../../utils/template";
|
14
14
|
import { combTopoData, getCiTypes } from "../../../utils/topoData";
|
15
15
|
import { saveTopo as _saveTopo, resToConditions, getLayoutId } from "../../../core/models/topoData";
|
16
|
+
import networkLinkServer from "../../../networkTopo/services/topo/networkLink";
|
16
17
|
import { addLinkData, buildData as buildTopoData } from "../../../networkTopo/getTopoData";
|
17
18
|
|
18
19
|
var newGroupWithUUID = function newGroupWithUUID(group) {
|
@@ -244,19 +245,20 @@ export default function (topoApp) {
|
|
244
245
|
var _this2 = this;
|
245
246
|
|
246
247
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
247
|
-
var editState, resources, _editState$groups, groups, _editState$exportLink, exportLinkIdList, query, data;
|
248
|
+
var editState, resources, _editState$groups, groups, _editState$exportLink, exportLinkIdList, _editState$ipNodes, ipNodes, query, data;
|
248
249
|
|
249
250
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
250
251
|
while (1) {
|
251
252
|
switch (_context2.prev = _context2.next) {
|
252
253
|
case 0:
|
253
254
|
editState = rootState.topoConfig;
|
254
|
-
resources = editState.resources, _editState$groups = editState.groups, groups = _editState$groups === void 0 ? [] : _editState$groups, _editState$exportLink = editState.exportLinkIdList, exportLinkIdList = _editState$exportLink === void 0 ? [] : _editState$exportLink;
|
255
|
+
resources = editState.resources, _editState$groups = editState.groups, groups = _editState$groups === void 0 ? [] : _editState$groups, _editState$exportLink = editState.exportLinkIdList, exportLinkIdList = _editState$exportLink === void 0 ? [] : _editState$exportLink, _editState$ipNodes = editState.ipNodes, ipNodes = _editState$ipNodes === void 0 ? [] : _editState$ipNodes;
|
255
256
|
query = {
|
256
257
|
id: rootState.topoMod.topoId,
|
257
258
|
resources: resources,
|
258
259
|
groups: groups,
|
259
|
-
exportLinkIdList: exportLinkIdList
|
260
|
+
exportLinkIdList: exportLinkIdList,
|
261
|
+
ipNodes: ipNodes
|
260
262
|
};
|
261
263
|
_context2.next = 5;
|
262
264
|
return _this2.getTopoByConditions(query);
|
@@ -308,14 +310,14 @@ export default function (topoApp) {
|
|
308
310
|
var _this4 = this;
|
309
311
|
|
310
312
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
311
|
-
var topoId, resources, groups, exportLinkIdList, viewConditions, groupInfo, data, _yield$Promise$all, dataWithLinkDetail, _combTopoData, topoData, resAndMetrics, topoDataTrans;
|
313
|
+
var topoId, resources, groups, exportLinkIdList, ipNodes, viewConditions, groupInfo, data, _yield$Promise$all, dataWithLinkDetail, _combTopoData, topoData, resAndMetrics, topoDataTrans;
|
312
314
|
|
313
315
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
314
316
|
while (1) {
|
315
317
|
switch (_context4.prev = _context4.next) {
|
316
318
|
case 0:
|
317
319
|
// rlog.debug("getTopoByConditions--------", params);
|
318
|
-
topoId = params.id, resources = params.resources, groups = params.groups, exportLinkIdList = params.exportLinkIdList;
|
320
|
+
topoId = params.id, resources = params.resources, groups = params.groups, exportLinkIdList = params.exportLinkIdList, ipNodes = params.ipNodes;
|
319
321
|
viewConditions = resToConditions(resources);
|
320
322
|
groupInfo = isAvailableArray(groups) && groups.map(function (group) {
|
321
323
|
return _extends({}, group, {
|
@@ -325,7 +327,7 @@ export default function (topoApp) {
|
|
325
327
|
}); // rlog.debug("getTopoByConditions--------", viewConditions, groupInfo);
|
326
328
|
|
327
329
|
_context4.next = 5;
|
328
|
-
return topoApp.serverApi.getTopoDataByResource(topoId, viewConditions, groupInfo, exportLinkIdList);
|
330
|
+
return topoApp.serverApi.getTopoDataByResource(topoId, viewConditions, groupInfo, exportLinkIdList, ipNodes);
|
329
331
|
|
330
332
|
case 5:
|
331
333
|
data = _context4.sent;
|
@@ -393,7 +395,7 @@ export default function (topoApp) {
|
|
393
395
|
}].concat(displayConfig.saveHistories || [])
|
394
396
|
}))
|
395
397
|
};
|
396
|
-
rlog.debug(
|
398
|
+
rlog.debug("saveGlobalConfig", config);
|
397
399
|
_context5.next = 5;
|
398
400
|
return topoApp.serverApi.saveTopoSettings(topoApp.id, config);
|
399
401
|
|
@@ -461,6 +463,33 @@ export default function (topoApp) {
|
|
461
463
|
switchToViewMode: function switchToViewMode() {
|
462
464
|
this.reset();
|
463
465
|
dispatch.topoMod.switchToViewMode();
|
466
|
+
},
|
467
|
+
queryAllLinkByIp: function queryAllLinkByIp(data) {
|
468
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
469
|
+
var _result$data;
|
470
|
+
|
471
|
+
var ids, ip, result;
|
472
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
473
|
+
while (1) {
|
474
|
+
switch (_context8.prev = _context8.next) {
|
475
|
+
case 0:
|
476
|
+
ids = data.ids, ip = data.ip;
|
477
|
+
console.log("queryAllLinkByIp", ids, ip);
|
478
|
+
_context8.next = 4;
|
479
|
+
return networkLinkServer.queryLinksByIp(ids, ip);
|
480
|
+
|
481
|
+
case 4:
|
482
|
+
result = _context8.sent;
|
483
|
+
console.log("queryAllLinkByIp-result", result);
|
484
|
+
return _context8.abrupt("return", (_result$data = result === null || result === void 0 ? void 0 : result.data) !== null && _result$data !== void 0 ? _result$data : []);
|
485
|
+
|
486
|
+
case 7:
|
487
|
+
case "end":
|
488
|
+
return _context8.stop();
|
489
|
+
}
|
490
|
+
}
|
491
|
+
}, _callee8);
|
492
|
+
}))();
|
464
493
|
}
|
465
494
|
};
|
466
495
|
}
|
package/es/core/test/Test.js
CHANGED
@@ -34,7 +34,7 @@ var Test = /*#__PURE__*/function () {
|
|
34
34
|
|
35
35
|
var nodeElement = htTopo.getGraphView().sm().fd();
|
36
36
|
var ip = {
|
37
|
-
'id': '
|
37
|
+
'id': 'ip:1.1.1.1',
|
38
38
|
'name': '1.1.1.1',
|
39
39
|
customName: null,
|
40
40
|
// 'groupId': null,
|
@@ -46,12 +46,12 @@ var Test = /*#__PURE__*/function () {
|
|
46
46
|
|
47
47
|
};
|
48
48
|
nodeElement.a(ip);
|
49
|
-
nodeElement.setTag('
|
49
|
+
nodeElement.setTag('ip:1.1.1.1');
|
50
50
|
var link = {
|
51
51
|
'id': '0000000019b462d1',
|
52
52
|
'name': '172.17.160.116(Gi2/2/0/1) - 172.27.130.13(Gi 0/9)',
|
53
53
|
'source': '00000000029f9411',
|
54
|
-
'target': '
|
54
|
+
'target': 'ip:1.1.1.1',
|
55
55
|
'operation': 'delete',
|
56
56
|
'interfaceSource': '0000000018080aee',
|
57
57
|
'interfaceTarget': '000000000341b015',
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
3
|
-
import { request } from
|
3
|
+
import { request } from "@riil-frontend/component-topology-utils";
|
4
4
|
import rlog from "@riil-frontend/component-topology-utils/es/rlog";
|
5
5
|
export default {
|
6
6
|
/**
|