@riil-frontend/component-topology 12.0.0-dev.29 → 12.0.0-dev.30
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 +11 -11
- package/es/core/hooks/useCmpLinkAlarm.js +109 -15
- package/es/core/hooks/useGraphAlarmDisplay.js +3 -1
- package/es/core/models/TopoApp.js +1 -1
- package/es/style.js +1 -1
- package/lib/core/hooks/useCmpLinkAlarm.js +112 -14
- package/lib/core/hooks/useGraphAlarmDisplay.js +3 -1
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/style.js +1 -1
- package/package.json +2 -2
@@ -1,5 +1,9 @@
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
import
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
|
+
import { useEffect, useState, useMemo } from "react";
|
5
|
+
import { useRequest } from 'ahooks';
|
6
|
+
import DictCache from "../models/cache/DictCache";
|
3
7
|
|
4
8
|
function addCmpLinkOfflineStatusForDisplayLineColor(cis, cmpLinkRunStatusList) {
|
5
9
|
return cis.map(function (ci) {
|
@@ -16,6 +20,15 @@ function addCmpLinkOfflineStatusForDisplayLineColor(cis, cmpLinkRunStatusList) {
|
|
16
20
|
return ci;
|
17
21
|
});
|
18
22
|
}
|
23
|
+
|
24
|
+
function getCmpLinIds(datas) {
|
25
|
+
var linkIds = datas.filter(function (item) {
|
26
|
+
return item.isSubResource && item.typeCode === 'network_link';
|
27
|
+
}).map(function (item) {
|
28
|
+
return item.ciId;
|
29
|
+
});
|
30
|
+
return linkIds;
|
31
|
+
}
|
19
32
|
/**
|
20
33
|
* 分级链路下級鏈路
|
21
34
|
* @param {*} props
|
@@ -24,24 +37,21 @@ function addCmpLinkOfflineStatusForDisplayLineColor(cis, cmpLinkRunStatusList) {
|
|
24
37
|
|
25
38
|
|
26
39
|
export default function useCmpLinkAlarm(props) {
|
27
|
-
var topo = props.topo
|
40
|
+
var topo = props.topo,
|
41
|
+
resources = props.resources,
|
42
|
+
graphLoaded = props.graphLoaded;
|
28
43
|
|
29
44
|
var _topo$store$useModelS = topo.store.useModelState('topoBizMod'),
|
30
45
|
attrsAndMetrics = _topo$store$useModelS.attrsAndMetrics;
|
31
46
|
|
32
|
-
var
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
id: item.id,
|
41
|
-
runStatus: item.metrics.run_status
|
42
|
-
};
|
43
|
-
});
|
44
|
-
}, [cmpLinks]);
|
47
|
+
var _useState = useState(getCmpLinIds(resources)),
|
48
|
+
cmpLinkIds = _useState[0],
|
49
|
+
setCmpLinkIds = _useState[1];
|
50
|
+
|
51
|
+
var _useState2 = useState([]),
|
52
|
+
cmpLinkRunStatus = _useState2[0],
|
53
|
+
setCmpLinkRunStatus = _useState2[1];
|
54
|
+
|
45
55
|
var cmpLinkAlarmLevels = useMemo(function () {
|
46
56
|
return cmpLinkRunStatus // 3:fault:重要故障; 4:urgently:紧急故障 』为红色
|
47
57
|
.filter(function (item) {
|
@@ -53,6 +63,90 @@ export default function useCmpLinkAlarm(props) {
|
|
53
63
|
};
|
54
64
|
});
|
55
65
|
}, [cmpLinkRunStatus]);
|
66
|
+
useEffect(function () {
|
67
|
+
var ids = getCmpLinIds(resources);
|
68
|
+
|
69
|
+
if (cmpLinkIds.join(',') !== ids.join(',')) {
|
70
|
+
setCmpLinkIds(ids);
|
71
|
+
}
|
72
|
+
}, [resources]);
|
73
|
+
|
74
|
+
function getCmpLinkRunStatus(_x) {
|
75
|
+
return _getCmpLinkRunStatus.apply(this, arguments);
|
76
|
+
} // 轮询hooks
|
77
|
+
|
78
|
+
|
79
|
+
function _getCmpLinkRunStatus() {
|
80
|
+
_getCmpLinkRunStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ids) {
|
81
|
+
var _yield$Promise$all, ciMetricsResult;
|
82
|
+
|
83
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
84
|
+
while (1) switch (_context.prev = _context.next) {
|
85
|
+
case 0:
|
86
|
+
if (ids.length) {
|
87
|
+
_context.next = 2;
|
88
|
+
break;
|
89
|
+
}
|
90
|
+
|
91
|
+
return _context.abrupt("return", []);
|
92
|
+
|
93
|
+
case 2:
|
94
|
+
_context.t0 = Promise;
|
95
|
+
_context.t1 = // 查询指标值
|
96
|
+
topo.serverApi.ciInfo.batchQueryCiInfo({
|
97
|
+
ciId: [],
|
98
|
+
codes: ['run_status'],
|
99
|
+
relationId: ids.map(function (id) {
|
100
|
+
return {
|
101
|
+
ciId: id,
|
102
|
+
operation: "delete"
|
103
|
+
};
|
104
|
+
})
|
105
|
+
});
|
106
|
+
_context.next = 6;
|
107
|
+
return DictCache.init();
|
108
|
+
|
109
|
+
case 6:
|
110
|
+
_context.t2 = _context.sent;
|
111
|
+
_context.t3 = [_context.t1, _context.t2];
|
112
|
+
_context.next = 10;
|
113
|
+
return _context.t0.all.call(_context.t0, _context.t3);
|
114
|
+
|
115
|
+
case 10:
|
116
|
+
_yield$Promise$all = _context.sent;
|
117
|
+
ciMetricsResult = _yield$Promise$all[0];
|
118
|
+
return _context.abrupt("return", ciMetricsResult);
|
119
|
+
|
120
|
+
case 13:
|
121
|
+
case "end":
|
122
|
+
return _context.stop();
|
123
|
+
}
|
124
|
+
}, _callee);
|
125
|
+
}));
|
126
|
+
return _getCmpLinkRunStatus.apply(this, arguments);
|
127
|
+
}
|
128
|
+
|
129
|
+
var _useRequest = useRequest(getCmpLinkRunStatus, {
|
130
|
+
pollingInterval: 60 * 1000,
|
131
|
+
pollingWhenHidden: false,
|
132
|
+
// debounceInterval: 200,
|
133
|
+
manual: true,
|
134
|
+
onSuccess: function onSuccess(result) {
|
135
|
+
setCmpLinkRunStatus(result.map(function (item) {
|
136
|
+
return {
|
137
|
+
id: "sub:" + item.id,
|
138
|
+
runStatus: item.metrics.run_status
|
139
|
+
};
|
140
|
+
}));
|
141
|
+
}
|
142
|
+
}),
|
143
|
+
run = _useRequest.run;
|
144
|
+
|
145
|
+
useEffect(function () {
|
146
|
+
if (graphLoaded) {
|
147
|
+
run(cmpLinkIds);
|
148
|
+
}
|
149
|
+
}, [graphLoaded, cmpLinkIds]);
|
56
150
|
return {
|
57
151
|
cmpLinkRunStatus: cmpLinkRunStatus,
|
58
152
|
cmpLinkAlarmLevels: cmpLinkAlarmLevels,
|
@@ -91,7 +91,9 @@ export default function useGraphAlarmDisplay(options) {
|
|
91
91
|
var oldResources = topo.dataModel.useCis(); // 分级拓扑下级链路特殊处理
|
92
92
|
|
93
93
|
var _useCmpLinkAlarm = useCmpLinkAlarm({
|
94
|
-
topo: topo
|
94
|
+
topo: topo,
|
95
|
+
resources: oldResources,
|
96
|
+
graphLoaded: graphLoaded
|
95
97
|
}),
|
96
98
|
cmpLinkAlarmLevels = _useCmpLinkAlarm.cmpLinkAlarmLevels,
|
97
99
|
cmpLinkRunStatus = _useCmpLinkAlarm.cmpLinkRunStatus,
|
@@ -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 "12.0.0-dev.
|
27
|
+
var version = typeof "12.0.0-dev.30" === 'string' ? "12.0.0-dev.30" : null;
|
28
28
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
29
29
|
/**
|
30
30
|
* 拓扑显示和编辑
|
package/es/style.js
CHANGED
@@ -2,8 +2,8 @@ import '@riil-frontend/component-topology-graph/es/style';
|
|
2
2
|
import '@alifd/next/es/box/style';
|
3
3
|
import '@riil-frontend/component-topology-utils/es/style';
|
4
4
|
import '@alifd/next/es/message/style';
|
5
|
-
import '@riil-frontend/component-riil-event-emitter/es/style';
|
6
5
|
import '@riil-frontend/utils/es/style';
|
6
|
+
import '@riil-frontend/component-riil-event-emitter/es/style';
|
7
7
|
import '@alifd/next/es/menu-button/style';
|
8
8
|
import '@alifd/next/es/search/style';
|
9
9
|
import '@alifd/next/es/drawer/style';
|
@@ -5,10 +5,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
5
5
|
exports.__esModule = true;
|
6
6
|
exports["default"] = useCmpLinkAlarm;
|
7
7
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
9
|
+
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
11
|
+
|
8
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
13
|
|
10
14
|
var _react = require("react");
|
11
15
|
|
16
|
+
var _ahooks = require("ahooks");
|
17
|
+
|
18
|
+
var _DictCache = _interopRequireDefault(require("../models/cache/DictCache"));
|
19
|
+
|
12
20
|
function addCmpLinkOfflineStatusForDisplayLineColor(cis, cmpLinkRunStatusList) {
|
13
21
|
return cis.map(function (ci) {
|
14
22
|
var cmpLinkRunStatusData = cmpLinkRunStatusList.find(function (item) {
|
@@ -24,6 +32,15 @@ function addCmpLinkOfflineStatusForDisplayLineColor(cis, cmpLinkRunStatusList) {
|
|
24
32
|
return ci;
|
25
33
|
});
|
26
34
|
}
|
35
|
+
|
36
|
+
function getCmpLinIds(datas) {
|
37
|
+
var linkIds = datas.filter(function (item) {
|
38
|
+
return item.isSubResource && item.typeCode === 'network_link';
|
39
|
+
}).map(function (item) {
|
40
|
+
return item.ciId;
|
41
|
+
});
|
42
|
+
return linkIds;
|
43
|
+
}
|
27
44
|
/**
|
28
45
|
* 分级链路下級鏈路
|
29
46
|
* @param {*} props
|
@@ -32,24 +49,21 @@ function addCmpLinkOfflineStatusForDisplayLineColor(cis, cmpLinkRunStatusList) {
|
|
32
49
|
|
33
50
|
|
34
51
|
function useCmpLinkAlarm(props) {
|
35
|
-
var topo = props.topo
|
52
|
+
var topo = props.topo,
|
53
|
+
resources = props.resources,
|
54
|
+
graphLoaded = props.graphLoaded;
|
36
55
|
|
37
56
|
var _topo$store$useModelS = topo.store.useModelState('topoBizMod'),
|
38
57
|
attrsAndMetrics = _topo$store$useModelS.attrsAndMetrics;
|
39
58
|
|
40
|
-
var
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
id: item.id,
|
49
|
-
runStatus: item.metrics.run_status
|
50
|
-
};
|
51
|
-
});
|
52
|
-
}, [cmpLinks]);
|
59
|
+
var _useState = (0, _react.useState)(getCmpLinIds(resources)),
|
60
|
+
cmpLinkIds = _useState[0],
|
61
|
+
setCmpLinkIds = _useState[1];
|
62
|
+
|
63
|
+
var _useState2 = (0, _react.useState)([]),
|
64
|
+
cmpLinkRunStatus = _useState2[0],
|
65
|
+
setCmpLinkRunStatus = _useState2[1];
|
66
|
+
|
53
67
|
var cmpLinkAlarmLevels = (0, _react.useMemo)(function () {
|
54
68
|
return cmpLinkRunStatus // 3:fault:重要故障; 4:urgently:紧急故障 』为红色
|
55
69
|
.filter(function (item) {
|
@@ -61,6 +75,90 @@ function useCmpLinkAlarm(props) {
|
|
61
75
|
};
|
62
76
|
});
|
63
77
|
}, [cmpLinkRunStatus]);
|
78
|
+
(0, _react.useEffect)(function () {
|
79
|
+
var ids = getCmpLinIds(resources);
|
80
|
+
|
81
|
+
if (cmpLinkIds.join(',') !== ids.join(',')) {
|
82
|
+
setCmpLinkIds(ids);
|
83
|
+
}
|
84
|
+
}, [resources]);
|
85
|
+
|
86
|
+
function getCmpLinkRunStatus(_x) {
|
87
|
+
return _getCmpLinkRunStatus.apply(this, arguments);
|
88
|
+
} // 轮询hooks
|
89
|
+
|
90
|
+
|
91
|
+
function _getCmpLinkRunStatus() {
|
92
|
+
_getCmpLinkRunStatus = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(ids) {
|
93
|
+
var _yield$Promise$all, ciMetricsResult;
|
94
|
+
|
95
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
96
|
+
while (1) switch (_context.prev = _context.next) {
|
97
|
+
case 0:
|
98
|
+
if (ids.length) {
|
99
|
+
_context.next = 2;
|
100
|
+
break;
|
101
|
+
}
|
102
|
+
|
103
|
+
return _context.abrupt("return", []);
|
104
|
+
|
105
|
+
case 2:
|
106
|
+
_context.t0 = Promise;
|
107
|
+
_context.t1 = // 查询指标值
|
108
|
+
topo.serverApi.ciInfo.batchQueryCiInfo({
|
109
|
+
ciId: [],
|
110
|
+
codes: ['run_status'],
|
111
|
+
relationId: ids.map(function (id) {
|
112
|
+
return {
|
113
|
+
ciId: id,
|
114
|
+
operation: "delete"
|
115
|
+
};
|
116
|
+
})
|
117
|
+
});
|
118
|
+
_context.next = 6;
|
119
|
+
return _DictCache["default"].init();
|
120
|
+
|
121
|
+
case 6:
|
122
|
+
_context.t2 = _context.sent;
|
123
|
+
_context.t3 = [_context.t1, _context.t2];
|
124
|
+
_context.next = 10;
|
125
|
+
return _context.t0.all.call(_context.t0, _context.t3);
|
126
|
+
|
127
|
+
case 10:
|
128
|
+
_yield$Promise$all = _context.sent;
|
129
|
+
ciMetricsResult = _yield$Promise$all[0];
|
130
|
+
return _context.abrupt("return", ciMetricsResult);
|
131
|
+
|
132
|
+
case 13:
|
133
|
+
case "end":
|
134
|
+
return _context.stop();
|
135
|
+
}
|
136
|
+
}, _callee);
|
137
|
+
}));
|
138
|
+
return _getCmpLinkRunStatus.apply(this, arguments);
|
139
|
+
}
|
140
|
+
|
141
|
+
var _useRequest = (0, _ahooks.useRequest)(getCmpLinkRunStatus, {
|
142
|
+
pollingInterval: 60 * 1000,
|
143
|
+
pollingWhenHidden: false,
|
144
|
+
// debounceInterval: 200,
|
145
|
+
manual: true,
|
146
|
+
onSuccess: function onSuccess(result) {
|
147
|
+
setCmpLinkRunStatus(result.map(function (item) {
|
148
|
+
return {
|
149
|
+
id: "sub:" + item.id,
|
150
|
+
runStatus: item.metrics.run_status
|
151
|
+
};
|
152
|
+
}));
|
153
|
+
}
|
154
|
+
}),
|
155
|
+
run = _useRequest.run;
|
156
|
+
|
157
|
+
(0, _react.useEffect)(function () {
|
158
|
+
if (graphLoaded) {
|
159
|
+
run(cmpLinkIds);
|
160
|
+
}
|
161
|
+
}, [graphLoaded, cmpLinkIds]);
|
64
162
|
return {
|
65
163
|
cmpLinkRunStatus: cmpLinkRunStatus,
|
66
164
|
cmpLinkAlarmLevels: cmpLinkAlarmLevels,
|
@@ -102,7 +102,9 @@ function useGraphAlarmDisplay(options) {
|
|
102
102
|
var oldResources = topo.dataModel.useCis(); // 分级拓扑下级链路特殊处理
|
103
103
|
|
104
104
|
var _useCmpLinkAlarm = (0, _useCmpLinkAlarm2["default"])({
|
105
|
-
topo: topo
|
105
|
+
topo: topo,
|
106
|
+
resources: oldResources,
|
107
|
+
graphLoaded: graphLoaded
|
106
108
|
}),
|
107
109
|
cmpLinkAlarmLevels = _useCmpLinkAlarm.cmpLinkAlarmLevels,
|
108
110
|
cmpLinkRunStatus = _useCmpLinkAlarm.cmpLinkRunStatus,
|
@@ -54,7 +54,7 @@ var _SelectionModel = _interopRequireDefault(require("./SelectionModel"));
|
|
54
54
|
var _CiCache = _interopRequireDefault(require("./cache/CiCache"));
|
55
55
|
|
56
56
|
// eslint-disable-next-line no-undef
|
57
|
-
var version = typeof "12.0.0-dev.
|
57
|
+
var version = typeof "12.0.0-dev.30" === 'string' ? "12.0.0-dev.30" : null;
|
58
58
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
59
59
|
/**
|
60
60
|
* 拓扑显示和编辑
|
package/lib/style.js
CHANGED
@@ -2,8 +2,8 @@ require('@riil-frontend/component-topology-graph/lib/style');
|
|
2
2
|
require('@alifd/next/lib/box/style');
|
3
3
|
require('@riil-frontend/component-topology-utils/lib/style');
|
4
4
|
require('@alifd/next/lib/message/style');
|
5
|
-
require('@riil-frontend/component-riil-event-emitter/lib/style');
|
6
5
|
require('@riil-frontend/utils/lib/style');
|
6
|
+
require('@riil-frontend/component-riil-event-emitter/lib/style');
|
7
7
|
require('@alifd/next/lib/menu-button/style');
|
8
8
|
require('@alifd/next/lib/search/style');
|
9
9
|
require('@alifd/next/lib/drawer/style');
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@riil-frontend/component-topology",
|
3
|
-
"version": "12.0.0-dev.
|
3
|
+
"version": "12.0.0-dev.30",
|
4
4
|
"description": "拓扑",
|
5
5
|
"scripts": {
|
6
6
|
"start": "build-scripts start",
|
@@ -123,6 +123,6 @@
|
|
123
123
|
"access": "public"
|
124
124
|
},
|
125
125
|
"license": "MIT",
|
126
|
-
"homepage": "https://unpkg.com/@riil-frontend/component-topology@12.0.0-dev.
|
126
|
+
"homepage": "https://unpkg.com/@riil-frontend/component-topology@12.0.0-dev.30/build/index.html",
|
127
127
|
"gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
|
128
128
|
}
|