@riil-frontend/component-topology 2.7.5 → 2.10.0-alpha-2
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/1.js +2 -2
- package/build/2.js +2 -2
- package/build/index.css +1 -1
- package/build/index.js +40 -40
- package/es/components/LayoutDirectionSelect/Item.js +11 -0
- package/es/components/LayoutDirectionSelect/Item.module.scss +9 -0
- package/es/components/LayoutDirectionSelect/LayoutDirectionSelect.js +48 -0
- package/es/components/LayoutDirectionSelect/LayoutDirectionSelect.module.scss +4 -0
- package/es/components/LayoutDirectionSelect/index.js +2 -0
- package/es/components/LayoutSelect/LayoutSelect.js +46 -0
- package/es/components/LayoutSelect/LayoutSelect.module.scss +4 -0
- package/es/components/LayoutSelect/README.md +1 -0
- package/es/components/LayoutSelect/index.js +2 -0
- package/es/components/{TemplateSelect → TagImageSelect}/index.js +6 -23
- package/es/components/{TemplateGroup → TagImageSelect}/index.module.scss +0 -0
- package/es/components/TagSelect/index.js +2 -2
- package/es/components/TagSelect/index.scss +0 -4
- package/es/components/TemplateButton/Icon.js +2 -1
- package/es/components/TemplateButton/assets/index.js +1 -5
- package/es/components/TemplateButton/index.js +7 -15
- package/es/core/editor/components/settings/common/LayoutSettings.js +1 -1
- package/es/core/models/utils/linkUtils.js +2 -2
- package/es/core/viewer/components/titlebar/ViewerTools.js +5 -1
- package/es/core/viewer/components/titlebar/useSetDefaultTopo.js +30 -0
- package/es/models/topoMod.js +3 -2
- package/es/style.js +1 -1
- package/es/topoCenter/store/topoTreeMod.js +4 -26
- package/es/utils/tree.js +19 -0
- package/lib/components/LayoutDirectionSelect/Item.js +25 -0
- package/lib/components/LayoutDirectionSelect/Item.module.scss +9 -0
- package/lib/components/LayoutDirectionSelect/LayoutDirectionSelect.js +64 -0
- package/lib/components/LayoutDirectionSelect/LayoutDirectionSelect.module.scss +4 -0
- package/lib/components/LayoutDirectionSelect/index.js +11 -0
- package/lib/components/LayoutSelect/LayoutSelect.js +61 -0
- package/lib/components/LayoutSelect/LayoutSelect.module.scss +4 -0
- package/lib/components/LayoutSelect/README.md +1 -0
- package/lib/components/LayoutSelect/index.js +11 -0
- package/lib/components/{TemplateSelect → TagImageSelect}/index.js +6 -27
- package/{es/components/TemplateSelect → lib/components/TagImageSelect}/index.module.scss +0 -0
- package/lib/components/TagSelect/index.js +2 -2
- package/lib/components/TagSelect/index.scss +0 -4
- package/lib/components/TemplateButton/Icon.js +2 -1
- package/lib/components/TemplateButton/assets/index.js +0 -6
- package/lib/components/TemplateButton/index.js +7 -15
- package/lib/core/editor/components/settings/common/LayoutSettings.js +2 -2
- package/lib/core/models/utils/linkUtils.js +2 -2
- package/lib/core/viewer/components/titlebar/ViewerTools.js +6 -1
- package/lib/core/viewer/components/titlebar/useSetDefaultTopo.js +40 -0
- package/lib/models/topoMod.js +3 -2
- package/lib/style.js +1 -1
- package/lib/topoCenter/store/topoTreeMod.js +3 -25
- package/lib/utils/tree.js +21 -0
- package/package.json +7 -6
- package/es/components/TemplateButton/assets/topo_tpl_blank.svg +0 -9
- package/es/components/TemplateButton/assets/topo_tpl_region.svg +0 -14
- package/es/components/TemplateGroup/index.js +0 -28
- package/lib/components/TemplateButton/assets/topo_tpl_blank.svg +0 -9
- package/lib/components/TemplateButton/assets/topo_tpl_region.svg +0 -14
- package/lib/components/TemplateGroup/index.js +0 -40
- package/lib/components/TemplateGroup/index.module.scss +0 -3
- package/lib/components/TemplateSelect/index.module.scss +0 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
|
+
import TemplateButton from "../TemplateButton";
|
|
4
|
+
import styles from "./Item.module.scss";
|
|
5
|
+
export default function Item(props) {
|
|
6
|
+
return /*#__PURE__*/React.createElement(TemplateButton, _extends({}, props, {
|
|
7
|
+
iconClassName: styles.icon,
|
|
8
|
+
textClassName: styles.text
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
|
+
import TagImageSelect from "../TagImageSelect";
|
|
4
|
+
import styles from "./LayoutDirectionSelect.module.scss";
|
|
5
|
+
import Item from "./Item";
|
|
6
|
+
var LAYOUTS = [{
|
|
7
|
+
id: 'towardsouth',
|
|
8
|
+
name: '自上向下',
|
|
9
|
+
icon: 'layout_toward'
|
|
10
|
+
}, // {
|
|
11
|
+
// id: 'towardnorth',
|
|
12
|
+
// name: '自下向上',
|
|
13
|
+
// icon: 'layout_toward',
|
|
14
|
+
// rotate: 180,
|
|
15
|
+
// },
|
|
16
|
+
{
|
|
17
|
+
id: 'towardeast',
|
|
18
|
+
name: '自左向右',
|
|
19
|
+
icon: 'layout_toward',
|
|
20
|
+
rotate: 270
|
|
21
|
+
} // {
|
|
22
|
+
// id: 'towardwest',
|
|
23
|
+
// name: '自右向左',
|
|
24
|
+
// icon: 'layout_toward',
|
|
25
|
+
// rotate: 90,
|
|
26
|
+
// },
|
|
27
|
+
];
|
|
28
|
+
export default function LayoutDirectionSelect(props) {
|
|
29
|
+
var value = props.value,
|
|
30
|
+
onSelect = props.onSelect;
|
|
31
|
+
var layoutOptions = LAYOUTS.map(function (item) {
|
|
32
|
+
return _extends({}, item, {
|
|
33
|
+
selected: value === item.id,
|
|
34
|
+
onSelect: onSelect
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
return /*#__PURE__*/React.createElement(TagImageSelect, {
|
|
38
|
+
data: layoutOptions,
|
|
39
|
+
boxProps: {
|
|
40
|
+
spacing: 12
|
|
41
|
+
},
|
|
42
|
+
tagProps: {
|
|
43
|
+
className: styles.layoutSelectItem
|
|
44
|
+
},
|
|
45
|
+
ItemComponent: Item
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
|
+
import TagImageSelect from "../TagImageSelect";
|
|
4
|
+
import styles from "./LayoutSelect.module.scss";
|
|
5
|
+
var LAYOUTS = [{
|
|
6
|
+
id: 'towardsouth',
|
|
7
|
+
name: '自上向下',
|
|
8
|
+
icon: 'layout_toward'
|
|
9
|
+
}, // {
|
|
10
|
+
// id: 'towardnorth',
|
|
11
|
+
// name: '自下向上',
|
|
12
|
+
// icon: 'layout_toward',
|
|
13
|
+
// rotate: 180,
|
|
14
|
+
// },
|
|
15
|
+
{
|
|
16
|
+
id: 'towardeast',
|
|
17
|
+
name: '自左向右',
|
|
18
|
+
icon: 'layout_toward',
|
|
19
|
+
rotate: 270
|
|
20
|
+
} // {
|
|
21
|
+
// id: 'towardwest',
|
|
22
|
+
// name: '自右向左',
|
|
23
|
+
// icon: 'layout_toward',
|
|
24
|
+
// rotate: 90,
|
|
25
|
+
// },
|
|
26
|
+
];
|
|
27
|
+
export default function LayoutSelect(props) {
|
|
28
|
+
var value = props.value,
|
|
29
|
+
onSelect = props.onSelect;
|
|
30
|
+
var layoutOptions = LAYOUTS.map(function (item) {
|
|
31
|
+
return _extends({}, item, {
|
|
32
|
+
selected: value === item.id,
|
|
33
|
+
onSelect: onSelect
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
return /*#__PURE__*/React.createElement(TagImageSelect, {
|
|
37
|
+
data: layoutOptions,
|
|
38
|
+
boxProps: {
|
|
39
|
+
spacing: 12
|
|
40
|
+
},
|
|
41
|
+
tagProps: {
|
|
42
|
+
className: styles.layoutSelectItem
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
自动布局选择
|
|
@@ -1,34 +1,28 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _Tag from "@alifd/next/lib/tag";
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import TemplateButton from "../TemplateButton";
|
|
5
|
-
import styles from "./index.module.scss";
|
|
6
|
-
import TemplateGroup from "../TemplateGroup";
|
|
7
4
|
import TagSelect from "../TagSelect";
|
|
8
|
-
var TagGroup = _Tag.Group,
|
|
9
|
-
SelectableTag = _Tag.Selectable;
|
|
10
5
|
|
|
11
|
-
var
|
|
6
|
+
var TagImageSelect = function TagImageSelect(props) {
|
|
12
7
|
var _data$filter$;
|
|
13
8
|
|
|
14
|
-
// return (
|
|
15
|
-
// <TemplateGroup {...props}/>
|
|
16
|
-
// )
|
|
17
9
|
var _props$data = props.data,
|
|
18
10
|
data = _props$data === void 0 ? [] : _props$data,
|
|
19
11
|
size = props.size,
|
|
20
12
|
boxProps = props.boxProps,
|
|
21
13
|
tagProps = props.tagProps,
|
|
22
|
-
itemProps = props.itemProps
|
|
14
|
+
itemProps = props.itemProps,
|
|
15
|
+
ItemComponent = props.ItemComponent;
|
|
23
16
|
var value = (_data$filter$ = data.filter(function (item) {
|
|
24
17
|
return item.selected;
|
|
25
18
|
})[0]) === null || _data$filter$ === void 0 ? void 0 : _data$filter$.id;
|
|
19
|
+
var Item = ItemComponent || TemplateButton;
|
|
26
20
|
return /*#__PURE__*/React.createElement(TagSelect, {
|
|
27
21
|
defaultValue: value,
|
|
28
22
|
dataSource: data.map(function (item) {
|
|
29
23
|
return {
|
|
30
24
|
key: item.id,
|
|
31
|
-
content: /*#__PURE__*/React.createElement(
|
|
25
|
+
content: /*#__PURE__*/React.createElement(Item, _extends({
|
|
32
26
|
key: item.id
|
|
33
27
|
}, item, {
|
|
34
28
|
size: size
|
|
@@ -38,17 +32,6 @@ var TemplateSelect = function TemplateSelect(props) {
|
|
|
38
32
|
boxProps: boxProps,
|
|
39
33
|
tagProps: tagProps
|
|
40
34
|
});
|
|
41
|
-
return /*#__PURE__*/React.createElement(TagGroup, null, data.map(function (item) {
|
|
42
|
-
return /*#__PURE__*/React.createElement(SelectableTag, {
|
|
43
|
-
key: item.name,
|
|
44
|
-
checked: item.selected,
|
|
45
|
-
onChange: function onChange() {}
|
|
46
|
-
}, /*#__PURE__*/React.createElement(TemplateButton, _extends({
|
|
47
|
-
key: item.id
|
|
48
|
-
}, item, {
|
|
49
|
-
size: size
|
|
50
|
-
}), item.name));
|
|
51
|
-
}));
|
|
52
35
|
};
|
|
53
36
|
|
|
54
|
-
export default
|
|
37
|
+
export default TagImageSelect;
|
|
File without changes
|
|
@@ -9,8 +9,8 @@ var SelectableTag = _Tag.Selectable;
|
|
|
9
9
|
var TagSelect = function TagSelect(props) {
|
|
10
10
|
var _onChange = props.onChange,
|
|
11
11
|
value = props.value,
|
|
12
|
-
dataSource = props.dataSource,
|
|
13
12
|
defaultValue = props.defaultValue,
|
|
13
|
+
dataSource = props.dataSource,
|
|
14
14
|
boxProps = props.boxProps,
|
|
15
15
|
tagProps = props.tagProps;
|
|
16
16
|
|
|
@@ -26,7 +26,7 @@ var TagSelect = function TagSelect(props) {
|
|
|
26
26
|
return /*#__PURE__*/React.createElement("div", {
|
|
27
27
|
className: "tag-select-wrap"
|
|
28
28
|
}, /*#__PURE__*/React.createElement(_Box, _extends({
|
|
29
|
-
spacing:
|
|
29
|
+
spacing: 12,
|
|
30
30
|
wrap: true,
|
|
31
31
|
direction: "row"
|
|
32
32
|
}, boxProps), dataSource.map(function (item) {
|
|
@@ -4,13 +4,14 @@ import Icons from "./assets";
|
|
|
4
4
|
var Icon = function Icon(props) {
|
|
5
5
|
var _props$alt = props.alt,
|
|
6
6
|
alt = _props$alt === void 0 ? '' : _props$alt,
|
|
7
|
+
img = props.img,
|
|
7
8
|
type = props.type,
|
|
8
9
|
className = props.className,
|
|
9
10
|
rotate = props.rotate;
|
|
10
11
|
var style = rotate ? {
|
|
11
12
|
transform: "rotate(" + rotate + "deg)"
|
|
12
13
|
} : null;
|
|
13
|
-
var src = Icons[type];
|
|
14
|
+
var src = img || Icons[type];
|
|
14
15
|
return /*#__PURE__*/React.createElement("img", {
|
|
15
16
|
className: className,
|
|
16
17
|
style: style,
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import IconTplRegion from "./topo_tpl_region.svg"; // import IconTplLayeredRing from './topo_tpl_layered_ring.svg';
|
|
3
|
-
|
|
1
|
+
// import IconTplLayeredRing from './topo_tpl_layered_ring.svg';
|
|
4
2
|
import IconLayoutCircular from "./topo_layout_circular.svg";
|
|
5
3
|
import IconLayoutHierarchical from "./topo_layout_hierarchical.svg";
|
|
6
4
|
import IconLayoutToward from "./topo_layout_toward.svg";
|
|
7
5
|
export default {
|
|
8
|
-
'tpl_blank': IconTplBlank,
|
|
9
|
-
'tpl_region': IconTplRegion,
|
|
10
6
|
// 'tpl_layered_ring': IconTplLayeredRing,
|
|
11
7
|
'layout_circular': IconLayoutCircular,
|
|
12
8
|
'layout_hierarchical': IconLayoutHierarchical,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["className", "children", "icon", "id", "selected", "onSelect", "
|
|
3
|
+
var _excluded = ["className", "children", "icon", "id", "selected", "onSelect", "img", "iconClassName", "textClassName"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
6
|
import Icon from "./Icon";
|
|
@@ -14,7 +14,9 @@ var TemplateButton = function TemplateButton(props) {
|
|
|
14
14
|
selected = props.selected,
|
|
15
15
|
_props$onSelect = props.onSelect,
|
|
16
16
|
onSelect = _props$onSelect === void 0 ? function () {} : _props$onSelect,
|
|
17
|
-
|
|
17
|
+
img = props.img,
|
|
18
|
+
iconClassName = props.iconClassName,
|
|
19
|
+
textClassName = props.textClassName,
|
|
18
20
|
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
19
21
|
|
|
20
22
|
var handleClick = function handleClick() {
|
|
@@ -27,21 +29,11 @@ var TemplateButton = function TemplateButton(props) {
|
|
|
27
29
|
}, /*#__PURE__*/React.createElement("div", {
|
|
28
30
|
className: styles.iconWrapper
|
|
29
31
|
}, /*#__PURE__*/React.createElement(Icon, _extends({
|
|
30
|
-
className: styles.icon,
|
|
32
|
+
className: classnames(styles.icon, iconClassName),
|
|
33
|
+
img: img,
|
|
31
34
|
type: icon
|
|
32
35
|
}, rest))), /*#__PURE__*/React.createElement("div", {
|
|
33
|
-
className: styles.text
|
|
34
|
-
}, children));
|
|
35
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
-
className: classnames(styles.card, className),
|
|
37
|
-
onClick: handleClick
|
|
38
|
-
}, /*#__PURE__*/React.createElement(Icon, _extends({
|
|
39
|
-
className: styles.icon,
|
|
40
|
-
type: icon
|
|
41
|
-
}, rest)), /*#__PURE__*/React.createElement("div", {
|
|
42
|
-
tabIndex: "0",
|
|
43
|
-
role: "button",
|
|
44
|
-
className: styles.text
|
|
36
|
+
className: classnames(styles.text, textClassName)
|
|
45
37
|
}, children));
|
|
46
38
|
};
|
|
47
39
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _Radio from "@alifd/next/lib/radio";
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
-
import TemplateGroup from "../../../../../components/
|
|
3
|
+
import TemplateGroup from "../../../../../components/TagImageSelect";
|
|
4
4
|
import styles from "./LayoutSettings.module.scss";
|
|
5
5
|
var LAYOUTS = {
|
|
6
6
|
circular: '星型布局',
|
|
@@ -7,8 +7,8 @@ export function mergeLinksData(links, relationDetails) {
|
|
|
7
7
|
return links.map(function (link) {
|
|
8
8
|
var relation = findItem(relationDetails, 'id', link.id);
|
|
9
9
|
return _extends({}, link, {
|
|
10
|
-
ciType: relation.typeCode,
|
|
11
|
-
name: relation.attributes.name,
|
|
10
|
+
ciType: relation === null || relation === void 0 ? void 0 : relation.typeCode,
|
|
11
|
+
name: relation === null || relation === void 0 ? void 0 : relation.attributes.name,
|
|
12
12
|
detail: relation
|
|
13
13
|
});
|
|
14
14
|
});
|
|
@@ -6,10 +6,14 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
6
6
|
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
7
7
|
import styles from "../../../components/titlebar/TitleBar.module.scss";
|
|
8
8
|
import EditButton from "./widgets/EditButton";
|
|
9
|
+
import useSetDefaultTopo from "./useSetDefaultTopo";
|
|
9
10
|
export default function ViewerTools(props) {
|
|
10
11
|
var topo = props.topo,
|
|
11
12
|
_props$showEditButton = props.showEditButton,
|
|
12
13
|
showEditButton = _props$showEditButton === void 0 ? true : _props$showEditButton;
|
|
14
|
+
var setDefaultTopo = useSetDefaultTopo({
|
|
15
|
+
topo: topo
|
|
16
|
+
});
|
|
13
17
|
return /*#__PURE__*/React.createElement("div", null, showEditButton && /*#__PURE__*/React.createElement(EditButton, _extends({
|
|
14
18
|
topo: topo
|
|
15
19
|
}, props)), /*#__PURE__*/React.createElement(_Dropdown, {
|
|
@@ -19,7 +23,7 @@ export default function ViewerTools(props) {
|
|
|
19
23
|
type: "ellipsis-vertical"
|
|
20
24
|
})),
|
|
21
25
|
triggerType: "click"
|
|
22
|
-
}, /*#__PURE__*/React.createElement(_Menu, null, /*#__PURE__*/React.createElement(_Menu.Item, {
|
|
26
|
+
}, /*#__PURE__*/React.createElement(_Menu, null, setDefaultTopo.renderMenuItem(), /*#__PURE__*/React.createElement(_Menu.Item, {
|
|
23
27
|
onClick: function onClick() {
|
|
24
28
|
topo.exportImage();
|
|
25
29
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import _Menu from "@alifd/next/lib/menu";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { findNodeById } from "../../../../utils/tree";
|
|
4
|
+
export default function useSetDefaultTopo(props) {
|
|
5
|
+
var _findNodeById;
|
|
6
|
+
|
|
7
|
+
var topo = props.topo;
|
|
8
|
+
var store = topo.store;
|
|
9
|
+
var functionAuthState = store.useModelState('functionAuth');
|
|
10
|
+
var topoModState = store.useModelState('topoMod');
|
|
11
|
+
|
|
12
|
+
var _store$useModel = store.useModel('topoTreeMod'),
|
|
13
|
+
topoTreeState = _store$useModel[0],
|
|
14
|
+
topoTreeDispatchers = _store$useModel[1];
|
|
15
|
+
|
|
16
|
+
var isDefault = (_findNodeById = findNodeById(topoTreeState.treeData, topoModState.topoId)) === null || _findNodeById === void 0 ? void 0 : _findNodeById.showDefault;
|
|
17
|
+
var showButton = !!functionAuthState.permissions.manageNavTree && !isDefault;
|
|
18
|
+
|
|
19
|
+
var setDefault = function setDefault() {
|
|
20
|
+
topoTreeDispatchers.setDefTopoOnTree(topoModState.topoId);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
renderMenuItem: function renderMenuItem() {
|
|
25
|
+
return showButton && /*#__PURE__*/React.createElement(_Menu.Item, {
|
|
26
|
+
onClick: setDefault
|
|
27
|
+
}, "\u8BBE\u4E3A\u9ED8\u8BA4\u62D3\u6251");
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
package/es/models/topoMod.js
CHANGED
|
@@ -21,6 +21,7 @@ export default function (topoApp) {
|
|
|
21
21
|
topoLoadError: false,
|
|
22
22
|
viewState: 'view',
|
|
23
23
|
// view, create, 2种模式
|
|
24
|
+
id: undefined,
|
|
24
25
|
topoId: '',
|
|
25
26
|
topoName: '',
|
|
26
27
|
topoData: null,
|
|
@@ -35,9 +36,9 @@ export default function (topoApp) {
|
|
|
35
36
|
topoAlarmIsOpen: false,
|
|
36
37
|
// 拓扑通道是否打开
|
|
37
38
|
alarmData: null,
|
|
38
|
-
// 概览抽屉中告警列表相关数据
|
|
39
|
+
// 概览抽屉中告警列表相关数据 TODO 抽取
|
|
39
40
|
currentCiInfo: null,
|
|
40
|
-
// 概览抽屉当前CI元数据
|
|
41
|
+
// 概览抽屉当前CI元数据 TODO 抽取
|
|
41
42
|
resAndMetrics: {
|
|
42
43
|
res: [],
|
|
43
44
|
metrics: [],
|
package/es/style.js
CHANGED
|
@@ -4,33 +4,11 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
4
4
|
import topoServer from '@riil-frontend/component-topology-common/es/services/topo';
|
|
5
5
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
|
6
6
|
import { treeMockData, topoInteData } from "../../utils/topoMocks";
|
|
7
|
-
import { formatTree, loopTree, loopTreeFun,
|
|
7
|
+
import { formatTree, loopTree, loopTreeFun, findParentIdsById, treeNodeCount } from "../../utils/tree";
|
|
8
8
|
|
|
9
9
|
var clone = function clone(data) {
|
|
10
10
|
return JSON.parse(JSON.stringify(data));
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function findSelectedParentIds(data, selectedId) {
|
|
15
|
-
// 选中 id 为 -1,则没有默认选中项
|
|
16
|
-
if (selectedId == '-1') return [];
|
|
17
|
-
var node = {};
|
|
18
|
-
loopTree(data, selectedId, function (item, index, arr, pid) {
|
|
19
|
-
node = {
|
|
20
|
-
item: item,
|
|
21
|
-
pid: pid
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
if (!node.item) return [];
|
|
25
|
-
|
|
26
|
-
if (node.pid != -1 && node.item.id) {
|
|
27
|
-
var _node$children;
|
|
28
|
-
|
|
29
|
-
return (_node$children = node.children) !== null && _node$children !== void 0 && _node$children.length ? ["" + node.item.id].concat(findSelectedParentIds(data, node.pid)) : [].concat(findSelectedParentIds(data, node.pid));
|
|
30
|
-
} else {
|
|
31
|
-
return ["" + node.item.id];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
11
|
+
};
|
|
34
12
|
/**
|
|
35
13
|
* TODO 导航树相关增删改移到拓扑中心
|
|
36
14
|
*/
|
|
@@ -83,7 +61,7 @@ export default function (topoApp) {
|
|
|
83
61
|
treeData: treeNodeCount(treeData),
|
|
84
62
|
defId: defId,
|
|
85
63
|
selectedNode: [selectedTopoId],
|
|
86
|
-
expandedKeys:
|
|
64
|
+
expandedKeys: findParentIdsById(treeData, selectedTopoId)
|
|
87
65
|
}); // console.log('resTreeData', resTreeData, rootState.topoMod.topoId);
|
|
88
66
|
|
|
89
67
|
|
|
@@ -368,7 +346,7 @@ export default function (topoApp) {
|
|
|
368
346
|
}
|
|
369
347
|
|
|
370
348
|
var expandedKeys = [].concat(treeState.expandedKeys || []);
|
|
371
|
-
var parentIds =
|
|
349
|
+
var parentIds = findParentIdsById(treeState.treeData, id);
|
|
372
350
|
expandedKeys.push.apply(expandedKeys, parentIds);
|
|
373
351
|
this.update({
|
|
374
352
|
selectedNode: ["" + id],
|
package/es/utils/tree.js
CHANGED
|
@@ -87,6 +87,25 @@ export function findNodeById(tree, id) {
|
|
|
87
87
|
});
|
|
88
88
|
return node;
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* 按id查找祖先节点id列表
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
export function findParentIdsById(tree, id) {
|
|
95
|
+
var node = findNodeById(tree, id);
|
|
96
|
+
|
|
97
|
+
if (!node) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
var parentId = "" + node.parentId;
|
|
102
|
+
|
|
103
|
+
if (parentId === '-1') {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return [parentId].concat(findParentIdsById(tree, parentId));
|
|
108
|
+
}
|
|
90
109
|
/**
|
|
91
110
|
* 递归循环遍历树匹配KEY
|
|
92
111
|
* @param {array} json
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
exports.__esModule = true;
|
|
8
|
+
exports["default"] = Item;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _TemplateButton = _interopRequireDefault(require("../TemplateButton"));
|
|
15
|
+
|
|
16
|
+
var _ItemModule = _interopRequireDefault(require("./Item.module.scss"));
|
|
17
|
+
|
|
18
|
+
function Item(props) {
|
|
19
|
+
return /*#__PURE__*/_react["default"].createElement(_TemplateButton["default"], (0, _extends2["default"])({}, props, {
|
|
20
|
+
iconClassName: _ItemModule["default"].icon,
|
|
21
|
+
textClassName: _ItemModule["default"].text
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
exports.__esModule = true;
|
|
8
|
+
exports["default"] = LayoutDirectionSelect;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _TagImageSelect = _interopRequireDefault(require("../TagImageSelect"));
|
|
15
|
+
|
|
16
|
+
var _LayoutDirectionSelectModule = _interopRequireDefault(require("./LayoutDirectionSelect.module.scss"));
|
|
17
|
+
|
|
18
|
+
var _Item = _interopRequireDefault(require("./Item"));
|
|
19
|
+
|
|
20
|
+
var LAYOUTS = [{
|
|
21
|
+
id: 'towardsouth',
|
|
22
|
+
name: '自上向下',
|
|
23
|
+
icon: 'layout_toward'
|
|
24
|
+
}, // {
|
|
25
|
+
// id: 'towardnorth',
|
|
26
|
+
// name: '自下向上',
|
|
27
|
+
// icon: 'layout_toward',
|
|
28
|
+
// rotate: 180,
|
|
29
|
+
// },
|
|
30
|
+
{
|
|
31
|
+
id: 'towardeast',
|
|
32
|
+
name: '自左向右',
|
|
33
|
+
icon: 'layout_toward',
|
|
34
|
+
rotate: 270
|
|
35
|
+
} // {
|
|
36
|
+
// id: 'towardwest',
|
|
37
|
+
// name: '自右向左',
|
|
38
|
+
// icon: 'layout_toward',
|
|
39
|
+
// rotate: 90,
|
|
40
|
+
// },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
function LayoutDirectionSelect(props) {
|
|
44
|
+
var value = props.value,
|
|
45
|
+
onSelect = props.onSelect;
|
|
46
|
+
var layoutOptions = LAYOUTS.map(function (item) {
|
|
47
|
+
return (0, _extends2["default"])({}, item, {
|
|
48
|
+
selected: value === item.id,
|
|
49
|
+
onSelect: onSelect
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return /*#__PURE__*/_react["default"].createElement(_TagImageSelect["default"], {
|
|
53
|
+
data: layoutOptions,
|
|
54
|
+
boxProps: {
|
|
55
|
+
spacing: 12
|
|
56
|
+
},
|
|
57
|
+
tagProps: {
|
|
58
|
+
className: _LayoutDirectionSelectModule["default"].layoutSelectItem
|
|
59
|
+
},
|
|
60
|
+
ItemComponent: _Item["default"]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _LayoutDirectionSelect = _interopRequireDefault(require("./LayoutDirectionSelect"));
|
|
9
|
+
|
|
10
|
+
var _default = _LayoutDirectionSelect["default"];
|
|
11
|
+
exports["default"] = _default;
|