@riil-frontend/component-topology 6.0.10 → 6.0.12
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 +1 -1
- package/es/core/common/hooks/useHtElements.js +4 -0
- package/es/core/editor/components/Toolbar/widgets/AddResourceButton.js +8 -11
- package/es/core/editor/components/Toolbar/widgets/FontColorButton.js +1 -1
- package/es/core/models/TopoApp.js +1 -1
- package/es/networkTopo/services/funcAuth.js +39 -0
- package/es/networkTopo/services/index.js +2 -1
- package/es/networkTopo/store/functionAuth.js +85 -97
- package/lib/core/common/hooks/useHtElements.js +4 -0
- package/lib/core/editor/components/Toolbar/widgets/AddResourceButton.js +9 -11
- package/lib/core/editor/components/Toolbar/widgets/FontColorButton.js +1 -1
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/networkTopo/services/funcAuth.js +50 -0
- package/lib/networkTopo/services/index.js +3 -1
- package/lib/networkTopo/store/functionAuth.js +94 -109
- package/package.json +2 -2
@@ -13,8 +13,12 @@ export default function useHtElements(props) {
|
|
13
13
|
}
|
14
14
|
}, [ids, idList]);
|
15
15
|
var elements = useMemo(function () {
|
16
|
+
//
|
16
17
|
return idList.map(function (id) {
|
17
18
|
return topo.getDataModel().getDataById(id);
|
19
|
+
}) // 多选删除时,被删除的元素是undefined
|
20
|
+
.filter(function (element) {
|
21
|
+
return !!element;
|
18
22
|
});
|
19
23
|
}, [topo, idList]);
|
20
24
|
return elements;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
2
|
-
import {
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
2
|
+
import { isClusterHtElement } from "../../../../../utils/clusterUtil";
|
3
|
+
import { isGroup, isLayer } from "../../../../../utils/htElementUtils";
|
3
4
|
import useLayerAddResource from "../../../hooks/useLayerAddResource";
|
4
5
|
import LayerAddResourceDrawer from "../../settings/propertyViews/layer/DataTab/LayerAddResourceDrawer";
|
5
6
|
import ButtonBox from "./components/ButtonBox";
|
@@ -10,8 +11,8 @@ function getAddType(selection) {
|
|
10
11
|
var data = selection[0];
|
11
12
|
|
12
13
|
if (isLayer(data)) {
|
13
|
-
return 'layer';
|
14
|
-
} else if (isGroup(data)) {
|
14
|
+
return 'layer'; // 集群视为添加到视图
|
15
|
+
} else if (isGroup(data) && !isClusterHtElement(data)) {
|
15
16
|
return 'group';
|
16
17
|
}
|
17
18
|
}
|
@@ -24,13 +25,9 @@ function AddResourceButton(props) {
|
|
24
25
|
editorProps = props.editorProps; // 选中的元素
|
25
26
|
|
26
27
|
var selection = topo.selectionModel.useSelection();
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
setAddType = _useState[1];
|
31
|
-
|
32
|
-
useEffect(function () {
|
33
|
-
setAddType(getAddType(selection));
|
28
|
+
var addType = useMemo(function () {
|
29
|
+
var elements = selection.length ? topo.selectionModel.getSelection() : [];
|
30
|
+
return getAddType(elements);
|
34
31
|
}, [selection]); // 选中分层添加
|
35
32
|
|
36
33
|
var layerAddResource = useLayerAddResource({
|
@@ -25,7 +25,7 @@ function FontColorDropdown(props) {
|
|
25
25
|
var backOpacityChange = function backOpacityChange(value) {
|
26
26
|
topo.historyManager.beginTransaction();
|
27
27
|
onChange({
|
28
|
-
opacity:
|
28
|
+
opacity: (value / 100).toFixed(2)
|
29
29
|
});
|
30
30
|
topo.historyManager.endTransaction();
|
31
31
|
};
|
@@ -23,7 +23,7 @@ import topoFactory from "./topoFactory";
|
|
23
23
|
import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
|
24
24
|
import SelectionModel from "./SelectionModel"; // eslint-disable-next-line no-undef
|
25
25
|
|
26
|
-
var version = typeof "6.0.
|
26
|
+
var version = typeof "6.0.12" === 'string' ? "6.0.12" : null;
|
27
27
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
28
28
|
/**
|
29
29
|
* 拓扑显示和编辑
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
3
|
+
import authServices from '@riil-frontend/component-topology-common/es/services/authorization';
|
4
|
+
export default {
|
5
|
+
getFuncAuth: function getFuncAuth() {
|
6
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
7
|
+
var funcResult, permissions;
|
8
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
9
|
+
while (1) {
|
10
|
+
switch (_context.prev = _context.next) {
|
11
|
+
case 0:
|
12
|
+
_context.next = 2;
|
13
|
+
return authServices.checkFuncAuthentication([{
|
14
|
+
func: 'topo_createTopo'
|
15
|
+
}, {
|
16
|
+
func: 'topo_manageNavTree'
|
17
|
+
}, {
|
18
|
+
func: 'topo_setTopoPermission'
|
19
|
+
}, {
|
20
|
+
func: 'addResource'
|
21
|
+
}]);
|
22
|
+
|
23
|
+
case 2:
|
24
|
+
funcResult = _context.sent;
|
25
|
+
permissions = {};
|
26
|
+
funcResult.forEach(function (func) {
|
27
|
+
permissions[func.func.replace('topo_', '')] = func.passed === 'PASS';
|
28
|
+
});
|
29
|
+
return _context.abrupt("return", permissions);
|
30
|
+
|
31
|
+
case 6:
|
32
|
+
case "end":
|
33
|
+
return _context.stop();
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}, _callee);
|
37
|
+
}))();
|
38
|
+
}
|
39
|
+
};
|
@@ -3,7 +3,8 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
4
|
import topoService from '@riil-frontend/component-topology-common/es/services/topo';
|
5
5
|
import { request } from '@riil-frontend/component-topology-utils';
|
6
|
-
|
6
|
+
import funcAuth from "./funcAuth";
|
7
|
+
export default _extends({}, topoService, funcAuth, {
|
7
8
|
// 获取有权限的拓扑树
|
8
9
|
getTopoTreeByLoginUser: function getTopoTreeByLoginUser(params) {
|
9
10
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
@@ -6,111 +6,99 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
* 功能权限 Model
|
7
7
|
*/
|
8
8
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
var _this = this;
|
9
|
+
export default function (topo) {
|
10
|
+
return {
|
11
|
+
// 定义 model 的初始 state
|
12
|
+
state: {
|
13
|
+
permissions: {
|
14
|
+
createTopo: false,
|
15
|
+
manageNavTree: false,
|
16
|
+
setTopoPermission: false
|
17
|
+
}
|
18
|
+
},
|
19
|
+
// 定义改变该模型状态的纯函数
|
20
|
+
reducers: {
|
21
|
+
update: function update(prevState, payload) {
|
22
|
+
return _extends({}, prevState, payload);
|
23
|
+
}
|
24
|
+
},
|
25
|
+
// 定义处理该模型副作用的函数
|
26
|
+
effects: function effects(dispatch) {
|
27
|
+
return {
|
28
|
+
init: function init(payload, rootState) {
|
29
|
+
var _this = this;
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
32
|
+
var permissions;
|
33
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
34
|
+
while (1) {
|
35
|
+
switch (_context.prev = _context.next) {
|
36
|
+
case 0:
|
37
|
+
_context.next = 2;
|
38
|
+
return _this.getPermissions();
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
case 2:
|
41
|
+
permissions = _context.sent;
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
if (permissions) {
|
44
|
+
_this.update({
|
45
|
+
permissions: permissions
|
46
|
+
});
|
47
|
+
}
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
case 4:
|
50
|
+
case "end":
|
51
|
+
return _context.stop();
|
52
|
+
}
|
53
53
|
}
|
54
|
-
}
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
return authServices.checkFuncAuthentication([{
|
67
|
-
func: 'topo_createTopo'
|
68
|
-
}, {
|
69
|
-
func: 'topo_manageNavTree'
|
70
|
-
}, {
|
71
|
-
func: 'topo_setTopoPermission'
|
72
|
-
}, {
|
73
|
-
func: 'addResource'
|
74
|
-
}]);
|
54
|
+
}, _callee);
|
55
|
+
}))();
|
56
|
+
},
|
57
|
+
getPermissions: function getPermissions() {
|
58
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
59
|
+
var permissions;
|
60
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
61
|
+
while (1) {
|
62
|
+
switch (_context2.prev = _context2.next) {
|
63
|
+
case 0:
|
64
|
+
_context2.next = 2;
|
65
|
+
return topo.serverApi.getFuncAuth();
|
75
66
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
funcResult.forEach(function (func) {
|
80
|
-
permissions[func.func.replace('topo_', '')] = func.passed === 'PASS';
|
81
|
-
});
|
82
|
-
return _context2.abrupt("return", permissions);
|
67
|
+
case 2:
|
68
|
+
permissions = _context2.sent;
|
69
|
+
return _context2.abrupt("return", permissions);
|
83
70
|
|
84
|
-
|
85
|
-
|
86
|
-
|
71
|
+
case 4:
|
72
|
+
case "end":
|
73
|
+
return _context2.stop();
|
74
|
+
}
|
87
75
|
}
|
88
|
-
}
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
var _this2 = this;
|
76
|
+
}, _callee2);
|
77
|
+
}))();
|
78
|
+
},
|
79
|
+
checkAuth: function checkAuth(name, rootState) {
|
80
|
+
return rootState.functionAuth.permissions[name];
|
81
|
+
},
|
82
|
+
refresh: function refresh() {
|
83
|
+
var _this2 = this;
|
97
84
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
85
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
86
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
87
|
+
while (1) {
|
88
|
+
switch (_context3.prev = _context3.next) {
|
89
|
+
case 0:
|
90
|
+
_context3.next = 2;
|
91
|
+
return _this2.init();
|
105
92
|
|
106
|
-
|
107
|
-
|
108
|
-
|
93
|
+
case 2:
|
94
|
+
case "end":
|
95
|
+
return _context3.stop();
|
96
|
+
}
|
109
97
|
}
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
116
|
-
}
|
98
|
+
}, _callee3);
|
99
|
+
}))();
|
100
|
+
}
|
101
|
+
};
|
102
|
+
}
|
103
|
+
};
|
104
|
+
}
|
@@ -19,8 +19,12 @@ function useHtElements(props) {
|
|
19
19
|
}
|
20
20
|
}, [ids, idList]);
|
21
21
|
var elements = (0, _react.useMemo)(function () {
|
22
|
+
//
|
22
23
|
return idList.map(function (id) {
|
23
24
|
return topo.getDataModel().getDataById(id);
|
25
|
+
}) // 多选删除时,被删除的元素是undefined
|
26
|
+
.filter(function (element) {
|
27
|
+
return !!element;
|
24
28
|
});
|
25
29
|
}, [topo, idList]);
|
26
30
|
return elements;
|
@@ -7,7 +7,9 @@ exports["default"] = void 0;
|
|
7
7
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
9
9
|
|
10
|
-
var
|
10
|
+
var _clusterUtil = require("../../../../../utils/clusterUtil");
|
11
|
+
|
12
|
+
var _htElementUtils = require("../../../../../utils/htElementUtils");
|
11
13
|
|
12
14
|
var _useLayerAddResource = _interopRequireDefault(require("../../../hooks/useLayerAddResource"));
|
13
15
|
|
@@ -25,9 +27,9 @@ function getAddType(selection) {
|
|
25
27
|
if (selection.length === 1) {
|
26
28
|
var data = selection[0];
|
27
29
|
|
28
|
-
if ((0,
|
29
|
-
return 'layer';
|
30
|
-
} else if ((0,
|
30
|
+
if ((0, _htElementUtils.isLayer)(data)) {
|
31
|
+
return 'layer'; // 集群视为添加到视图
|
32
|
+
} else if ((0, _htElementUtils.isGroup)(data) && !(0, _clusterUtil.isClusterHtElement)(data)) {
|
31
33
|
return 'group';
|
32
34
|
}
|
33
35
|
}
|
@@ -40,13 +42,9 @@ function AddResourceButton(props) {
|
|
40
42
|
editorProps = props.editorProps; // 选中的元素
|
41
43
|
|
42
44
|
var selection = topo.selectionModel.useSelection();
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
setAddType = _useState[1];
|
47
|
-
|
48
|
-
(0, _react.useEffect)(function () {
|
49
|
-
setAddType(getAddType(selection));
|
45
|
+
var addType = (0, _react.useMemo)(function () {
|
46
|
+
var elements = selection.length ? topo.selectionModel.getSelection() : [];
|
47
|
+
return getAddType(elements);
|
50
48
|
}, [selection]); // 选中分层添加
|
51
49
|
|
52
50
|
var layerAddResource = (0, _useLayerAddResource["default"])({
|
@@ -43,7 +43,7 @@ function FontColorDropdown(props) {
|
|
43
43
|
var backOpacityChange = function backOpacityChange(value) {
|
44
44
|
topo.historyManager.beginTransaction();
|
45
45
|
onChange({
|
46
|
-
opacity:
|
46
|
+
opacity: (value / 100).toFixed(2)
|
47
47
|
});
|
48
48
|
topo.historyManager.endTransaction();
|
49
49
|
};
|
@@ -54,7 +54,7 @@ var _ElementTagTipConfig = _interopRequireDefault(require("./tagstips/ElementTag
|
|
54
54
|
var _SelectionModel = _interopRequireDefault(require("./SelectionModel"));
|
55
55
|
|
56
56
|
// eslint-disable-next-line no-undef
|
57
|
-
var version = typeof "6.0.
|
57
|
+
var version = typeof "6.0.12" === 'string' ? "6.0.12" : null;
|
58
58
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
59
59
|
/**
|
60
60
|
* 拓扑显示和编辑
|
@@ -0,0 +1,50 @@
|
|
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 _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
9
|
+
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
11
|
+
|
12
|
+
var _authorization = _interopRequireDefault(require("@riil-frontend/component-topology-common/es/services/authorization"));
|
13
|
+
|
14
|
+
var _default = {
|
15
|
+
getFuncAuth: function getFuncAuth() {
|
16
|
+
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
17
|
+
var funcResult, permissions;
|
18
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
19
|
+
while (1) {
|
20
|
+
switch (_context.prev = _context.next) {
|
21
|
+
case 0:
|
22
|
+
_context.next = 2;
|
23
|
+
return _authorization["default"].checkFuncAuthentication([{
|
24
|
+
func: 'topo_createTopo'
|
25
|
+
}, {
|
26
|
+
func: 'topo_manageNavTree'
|
27
|
+
}, {
|
28
|
+
func: 'topo_setTopoPermission'
|
29
|
+
}, {
|
30
|
+
func: 'addResource'
|
31
|
+
}]);
|
32
|
+
|
33
|
+
case 2:
|
34
|
+
funcResult = _context.sent;
|
35
|
+
permissions = {};
|
36
|
+
funcResult.forEach(function (func) {
|
37
|
+
permissions[func.func.replace('topo_', '')] = func.passed === 'PASS';
|
38
|
+
});
|
39
|
+
return _context.abrupt("return", permissions);
|
40
|
+
|
41
|
+
case 6:
|
42
|
+
case "end":
|
43
|
+
return _context.stop();
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}, _callee);
|
47
|
+
}))();
|
48
|
+
}
|
49
|
+
};
|
50
|
+
exports["default"] = _default;
|
@@ -15,7 +15,9 @@ var _topo = _interopRequireDefault(require("@riil-frontend/component-topology-co
|
|
15
15
|
|
16
16
|
var _componentTopologyUtils = require("@riil-frontend/component-topology-utils");
|
17
17
|
|
18
|
-
var
|
18
|
+
var _funcAuth = _interopRequireDefault(require("./funcAuth"));
|
19
|
+
|
20
|
+
var _default = (0, _extends2["default"])({}, _topo["default"], _funcAuth["default"], {
|
19
21
|
// 获取有权限的拓扑树
|
20
22
|
getTopoTreeByLoginUser: function getTopoTreeByLoginUser(params) {
|
21
23
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|