ronds-metadata 1.3.32 → 1.3.33

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ import '../index.less';
2
+ interface NodeElementProps {
3
+ node?: Node;
4
+ }
5
+ declare const NodeElementForm: (props: NodeElementProps) => JSX.Element;
6
+ export default NodeElementForm;
@@ -0,0 +1,311 @@
1
+ import "antd/es/tooltip/style";
2
+ import _Tooltip from "antd/es/tooltip";
3
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
+ /*
6
+ * @Author: wangxian
7
+ * @Date: 2022-05-24 08:50:16
8
+ * @LastEditTime: 2024-02-29 17:05:37
9
+ */
10
+ import { GlobalOutlined } from '@ant-design/icons';
11
+ import { filter } from 'rxjs/operators';
12
+ import '../index.less';
13
+ import Icon from '../../Icons';
14
+ import { gDPGraph } from '../graph';
15
+ import React from 'react';
16
+ import MetadataForm from '../../MetadataForm';
17
+ var NodeElementForm = function NodeElementForm(props) {
18
+ var node = props.node;
19
+ var data = (node === null || node === void 0 ? void 0 : node.getData()) || {};
20
+ var id = data.id,
21
+ name = data.name,
22
+ icon = data.icon,
23
+ param = data.param;
24
+ var _React$useState = React.useState({}),
25
+ _React$useState2 = _slicedToArray(_React$useState, 2),
26
+ nodeStatus = _React$useState2[0],
27
+ setNodeStatus = _React$useState2[1];
28
+ var _React$useState3 = React.useState(false),
29
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
30
+ isNameEidt = _React$useState4[0],
31
+ setIsNameEdit = _React$useState4[1];
32
+ var _React$useState5 = React.useState(false),
33
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
34
+ isCanEidt = _React$useState6[0],
35
+ setIsCanEdit = _React$useState6[1];
36
+ React.useEffect(function () {
37
+ var sub = gDPGraph && gDPGraph.factory$.executionStatus.pipe(filter(function (x) {
38
+ return !!x;
39
+ })).subscribe(function (v) {
40
+ var _status = v.statusList.find(function (it) {
41
+ return (it === null || it === void 0 ? void 0 : it.nodeId) === id;
42
+ });
43
+ setNodeStatus(_objectSpread(_objectSpread({}, _status), {}, {
44
+ debugId: v.debugId
45
+ }));
46
+ });
47
+ return function () {
48
+ sub.unsubscribe();
49
+ };
50
+ }, [gDPGraph]);
51
+ React.useEffect(function () {
52
+ var sub = gDPGraph && gDPGraph.factory$.isUpdateNodeName.subscribe(function (v) {
53
+ setIsCanEdit(v);
54
+ });
55
+ return function () {
56
+ sub.unsubscribe();
57
+ };
58
+ }, [gDPGraph]);
59
+ var onStatusClick = function onStatusClick(e) {
60
+ e.stopPropagation();
61
+ gDPGraph.factory$.statusClick.next(_objectSpread(_objectSpread({}, data), {}, {
62
+ status: _objectSpread({
63
+ nodeId: id
64
+ }, nodeStatus)
65
+ }));
66
+ };
67
+ var onPressEnter = function onPressEnter(e) {
68
+ setIsNameEdit(false);
69
+ gDPGraph.updateNodeNameById(id, e.target.value);
70
+ };
71
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
72
+ className: "node-element-form"
73
+ }, /*#__PURE__*/React.createElement("div", {
74
+ style: {
75
+ display: 'flex',
76
+ alignItems: 'center'
77
+ }
78
+ }, /*#__PURE__*/React.createElement(_Tooltip, {
79
+ title: (param === null || param === void 0 ? void 0 : param.remark) !== name ? /*#__PURE__*/React.createElement("div", {
80
+ style: {
81
+ maxHeight: '200px',
82
+ whiteSpace: 'pre-line',
83
+ overflowY: 'auto',
84
+ overflowX: 'hidden',
85
+ wordBreak: 'break-all'
86
+ }
87
+ }, /*#__PURE__*/React.createElement("span", null, param === null || param === void 0 ? void 0 : param.remark)) : undefined
88
+ }, /*#__PURE__*/React.createElement("div", {
89
+ className: "icon",
90
+ style: {
91
+ cursor: 'pointer'
92
+ }
93
+ }, icon ? /*#__PURE__*/React.createElement(Icon, {
94
+ type: icon
95
+ }) : /*#__PURE__*/React.createElement(GlobalOutlined, null))), /*#__PURE__*/React.createElement("div", {
96
+ className: "notation"
97
+ }, /*#__PURE__*/React.createElement("div", {
98
+ className: "name",
99
+ title: name,
100
+ onDoubleClick: function onDoubleClick() {
101
+ if (isCanEidt) {
102
+ setIsNameEdit(true);
103
+ }
104
+ }
105
+ }, name))), /*#__PURE__*/React.createElement("div", {
106
+ style: {
107
+ maxHeight: '500px',
108
+ overflowY: 'auto'
109
+ }
110
+ }, /*#__PURE__*/React.createElement(MetadataForm, {
111
+ schema: SCHEMA
112
+ }))));
113
+ };
114
+ export default NodeElementForm;
115
+ var SCHEMA = [{
116
+ types: [{
117
+ type: 'object',
118
+ properties: [{
119
+ format: 'int',
120
+ id: 'batchDuration',
121
+ type: 'number',
122
+ fields: [{
123
+ id: 'Rule.Form',
124
+ refId: 'com.ronds.schema.default.Rule.Form',
125
+ type: 'ref',
126
+ value: {
127
+ common: {
128
+ require: true,
129
+ label: '批间隔'
130
+ },
131
+ 'common-en-US': {
132
+ require: true,
133
+ label: 'Batch interval'
134
+ }
135
+ }
136
+ }]
137
+ }, {
138
+ id: 'autoOffsetReset',
139
+ type: 'enum',
140
+ fields: [{
141
+ id: 'Rule.Form',
142
+ refId: 'com.ronds.schema.default.Rule.Form',
143
+ type: 'ref',
144
+ value: {
145
+ common: {
146
+ require: true,
147
+ label: '消费策略'
148
+ },
149
+ 'common-en-US': {
150
+ require: true,
151
+ label: 'Consumption strategy'
152
+ }
153
+ }
154
+ }],
155
+ enum: [{
156
+ value: 'earliest'
157
+ }, {
158
+ value: 'latest'
159
+ }]
160
+ }, {
161
+ type: 'text',
162
+ fields: [{
163
+ id: 'Rule.Form',
164
+ refId: 'com.ronds.schema.default.Rule.Form',
165
+ type: 'ref',
166
+ value: {
167
+ common: {
168
+ help: '非必填,默认工作流id',
169
+ require: false,
170
+ label: '消费者组'
171
+ },
172
+ 'common-en-US': {
173
+ help: 'Not required, Default workflow id',
174
+ require: false,
175
+ label: 'Consumer group'
176
+ },
177
+ text: {}
178
+ }
179
+ }],
180
+ id: 'groupId'
181
+ }, {
182
+ id: 'kafkaSource',
183
+ refId: 'KafkaSourceOption',
184
+ type: 'ref',
185
+ fields: [{
186
+ id: 'Rule.Form',
187
+ refId: 'com.ronds.schema.default.Rule.Form',
188
+ type: 'ref',
189
+ value: {
190
+ common: {
191
+ label: 'kafka数据源'
192
+ },
193
+ 'common-en-US': {
194
+ label: 'kafka data source'
195
+ }
196
+ }
197
+ }]
198
+ }],
199
+ id: 'KafkaSubscribeActivityOption.Config'
200
+ }, {
201
+ type: 'object',
202
+ properties: [{
203
+ id: 'source',
204
+ type: 'enum',
205
+ fields: [{
206
+ id: 'Rule.Form',
207
+ refId: 'com.ronds.schema.default.Rule.Form',
208
+ type: 'ref',
209
+ value: {
210
+ common: {
211
+ label: '选择数据源'
212
+ },
213
+ 'common-en-US': {
214
+ label: 'Select Data Source'
215
+ },
216
+ enum: {
217
+ http: {
218
+ method: 'post',
219
+ body: '{"type":"Kafka","level":1}',
220
+ value: 'name',
221
+ key: 'config',
222
+ url: '/dataset-web/source/cascade/data/v2'
223
+ }
224
+ }
225
+ }
226
+ }],
227
+ enum: []
228
+ }, {
229
+ id: 'levelTwo',
230
+ type: 'enum',
231
+ fields: [{
232
+ id: 'Rule.Form',
233
+ refId: 'com.ronds.schema.default.Rule.Form',
234
+ type: 'ref',
235
+ value: {
236
+ common: {
237
+ label: '选择主题'
238
+ },
239
+ 'common-en-US': {
240
+ label: 'Select Topic'
241
+ },
242
+ enum: {
243
+ http: {
244
+ method: 'post',
245
+ body: '{"type":"Kafka","level":2}',
246
+ value: 'name',
247
+ watch: 'source',
248
+ key: 'name',
249
+ url: '/dataset-web/source/cascade/data/v2'
250
+ },
251
+ isMutiple: true
252
+ }
253
+ }
254
+ }],
255
+ enum: []
256
+ }, {
257
+ type: 'text',
258
+ fields: [{
259
+ id: 'Rule.Form',
260
+ refId: 'com.ronds.schema.default.Rule.Form',
261
+ type: 'ref',
262
+ value: {
263
+ common: {
264
+ hidden: true,
265
+ defaultValue: 'KafkaSource'
266
+ },
267
+ 'common-en-US': {},
268
+ text: {}
269
+ }
270
+ }],
271
+ id: 'actType'
272
+ }],
273
+ id: 'KafkaSourceOption'
274
+ }],
275
+ id: 'KafkaSubscribeActivityOption',
276
+ type: 'object',
277
+ properties: [{
278
+ type: 'text',
279
+ fields: [{
280
+ id: 'Rule.Form',
281
+ refId: 'com.ronds.schema.default.Rule.Form',
282
+ type: 'ref',
283
+ value: {
284
+ common: {
285
+ hidden: true,
286
+ defaultValue: 'KafkaSubscribeActivity'
287
+ },
288
+ 'common-en-US': {},
289
+ text: {}
290
+ }
291
+ }],
292
+ id: 'actName'
293
+ }, {
294
+ id: 'actConfig',
295
+ refId: 'KafkaSubscribeActivityOption.Config',
296
+ type: 'ref',
297
+ fields: [{
298
+ id: 'Rule.Form',
299
+ refId: 'com.ronds.schema.default.Rule.Form',
300
+ type: 'ref',
301
+ value: {
302
+ common: {
303
+ label: '执行活动配置'
304
+ },
305
+ 'common-en-US': {
306
+ label: 'Perform activity configuration'
307
+ }
308
+ }
309
+ }]
310
+ }]
311
+ }];
@@ -0,0 +1,6 @@
1
+ import '../index.less';
2
+ interface NodeElementProps {
3
+ node?: Node;
4
+ }
5
+ declare const NodeElementNormal: (props: NodeElementProps) => JSX.Element;
6
+ export default NodeElementNormal;
@@ -7,16 +7,16 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
7
7
  /*
8
8
  * @Author: wangxian
9
9
  * @Date: 2022-05-24 08:50:16
10
- * @LastEditTime: 2024-02-01 15:14:11
10
+ * @LastEditTime: 2024-02-29 13:47:21
11
11
  */
12
12
  import { GlobalOutlined } from '@ant-design/icons';
13
13
  import { filter } from 'rxjs/operators';
14
14
  import '../index.less';
15
- import Icon from '../../../comps/Icons';
15
+ import Icon from '../../Icons';
16
16
  import { NodeStatus } from './NodeStatus';
17
17
  import { gDPGraph } from '../graph';
18
18
  import React from 'react';
19
- var NodeElement = function NodeElement(props) {
19
+ var NodeElementNormal = function NodeElementNormal(props) {
20
20
  var node = props.node;
21
21
  var data = (node === null || node === void 0 ? void 0 : node.getData()) || {};
22
22
  var id = data.id,
@@ -109,4 +109,4 @@ var NodeElement = function NodeElement(props) {
109
109
  status: nodeStatus.nodeStatus
110
110
  }))));
111
111
  };
112
- export default NodeElement;
112
+ export default NodeElementNormal;
@@ -5,7 +5,7 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  /*
6
6
  * @Author: wangxian
7
7
  * @Date: 2022-05-24 09:18:34
8
- * @LastEditTime: 2023-11-29 15:45:34
8
+ * @LastEditTime: 2024-02-29 17:04:36
9
9
  */
10
10
  import { Shape, Edge } from '@antv/x6';
11
11
  import './edge.less';
@@ -38,7 +38,7 @@ export var DPEdge = /*#__PURE__*/function (_BaseEdge) {
38
38
  DPEdge.config({
39
39
  shape: 'DPEdge',
40
40
  connector: {
41
- name: 'pai'
41
+ name: 'normal'
42
42
  },
43
43
  zIndex: 1,
44
44
  attrs: {
@@ -9,3 +9,7 @@ export declare class DPNode extends BaseNode {
9
9
  export declare class DPGroupNode extends BaseNode {
10
10
  isGroup(): boolean;
11
11
  }
12
+ export declare class DPNodeForm extends BaseNode {
13
+ getInPorts(): import("@antv/x6/lib/model/port").PortManager.PortMetadata[];
14
+ getOutPorts(): import("@antv/x6/lib/model/port").PortManager.PortMetadata[];
15
+ }
@@ -174,4 +174,89 @@ DPGroupNode.config({
174
174
  }]
175
175
  }]
176
176
  }]
177
+ });
178
+ export var DPNodeForm = /*#__PURE__*/function (_BaseNode3) {
179
+ _inherits(DPNodeForm, _BaseNode3);
180
+ var _super4 = _createSuper(DPNodeForm);
181
+ function DPNodeForm() {
182
+ _classCallCheck(this, DPNodeForm);
183
+ return _super4.apply(this, arguments);
184
+ }
185
+ _createClass(DPNodeForm, [{
186
+ key: "getInPorts",
187
+ value: function getInPorts() {
188
+ return this.getPortsByGroup('in');
189
+ }
190
+ }, {
191
+ key: "getOutPorts",
192
+ value: function getOutPorts() {
193
+ return this.getPortsByGroup('out');
194
+ }
195
+ }]);
196
+ return DPNodeForm;
197
+ }(BaseNode);
198
+ Node.registry.register('rz-rect-port-form', DPNodeForm);
199
+ DPNodeForm.config({
200
+ width: NODE_WIDTH,
201
+ height: NODE_HEIGHT,
202
+ shape: 'rz-rect-port',
203
+ ports: {
204
+ groups: {
205
+ in: {
206
+ position: {
207
+ name: 'left'
208
+ },
209
+ zIndex: 2
210
+ },
211
+ out: {
212
+ position: {
213
+ name: 'right'
214
+ },
215
+ zIndex: 2
216
+ }
217
+ }
218
+ },
219
+ attrs: {
220
+ body: {
221
+ magnet: false,
222
+ fill: 'none',
223
+ stroke: 'none',
224
+ refWidth: '100%',
225
+ refHeight: '100%',
226
+ zIndex: 1
227
+ }
228
+ },
229
+ portMarkup: [{
230
+ tagName: 'foreignObject',
231
+ selector: 'fo',
232
+ attrs: {
233
+ width: 6,
234
+ height: 6,
235
+ x: -3,
236
+ y: -3,
237
+ zIndex: 10,
238
+ // magnet决定是否可交互
239
+ magnet: 'true'
240
+ },
241
+ children: [{
242
+ ns: Dom.ns.xhtml,
243
+ tagName: 'body',
244
+ selector: 'foBody',
245
+ attrs: {
246
+ xmlns: Dom.ns.xhtml
247
+ },
248
+ style: {
249
+ width: '100%',
250
+ height: '100%'
251
+ },
252
+ children: [{
253
+ tagName: 'span',
254
+ selector: 'content',
255
+ style: {
256
+ width: '100%',
257
+ height: '100%'
258
+ }
259
+ }]
260
+ }]
261
+ }]
177
262
  });
@@ -2,7 +2,7 @@ import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
2
2
  import { Subscription } from 'rxjs/internal/Subscription';
3
3
  import { ConnectionRemovedArgs, ContextMenuInfo, GraphCore } from '../../framework/graph';
4
4
  import { BaseEdge, DPEdge } from './comps/shape/edge';
5
- import { BaseNode, DPNode } from './comps/shape/node';
5
+ import { BaseNode, DPNode, DPNodeForm } from './comps/shape/node';
6
6
  import { NDPGraph } from './interface';
7
7
  import { formatGraphData } from './utils';
8
8
  type NodeMeta = ReturnType<typeof formatGraphData>['nodes'][number];
@@ -42,10 +42,12 @@ declare class DPGraph extends GraphCore<BaseNode, BaseEdge> {
42
42
  factory$: IFactory$;
43
43
  dpGraphSub?: Subscription;
44
44
  queryStatusSub?: Subscription;
45
- constructor(graphData?: NDPGraph.GraphData);
45
+ mode?: string;
46
+ constructor(graphData?: NDPGraph.GraphData, mode?: string);
46
47
  initialize(graphData?: NDPGraph.GraphData): Promise<void>;
47
48
  loadDPGraph(graphData: any): Promise<void>;
48
49
  isGraphReady(): boolean;
50
+ switchNode: (nodeMeta: NodeMeta) => DPNode | DPNodeForm;
49
51
  renderGraph: (wrapper: HTMLElement, container: HTMLElement) => void;
50
52
  renderGraphData: (graphData: NDPGraph.GraphData) => Promise<void>;
51
53
  renderNode(nodeMeta: NodeMeta): BaseNode | undefined;
@@ -84,5 +86,5 @@ declare class DPGraph extends GraphCore<BaseNode, BaseEdge> {
84
86
  }
85
87
  export declare let gDPGraph: DPGraph;
86
88
  export default DPGraph;
87
- export declare const useDPGraph: (graphData?: NDPGraph.GraphData) => DPGraph;
89
+ export declare const useDPGraph: (graphData?: NDPGraph.GraphData, mode?: string) => DPGraph;
88
90
  export declare const useUnmountDPGraph: (dispose: boolean, dpGraph: any) => void;
@@ -2,8 +2,8 @@ import "antd/es/message/style";
2
2
  import _message from "antd/es/message";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
6
5
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
6
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
7
7
  import "antd/es/tooltip/style";
8
8
  import _Tooltip from "antd/es/tooltip";
9
9
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
@@ -16,7 +16,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
16
16
  /*
17
17
  * @Author: wangxian
18
18
  * @Date: 2022-05-24 14:31:01
19
- * @LastEditTime: 2024-02-01 15:08:03
19
+ * @LastEditTime: 2024-02-29 13:40:06
20
20
  */
21
21
  import _regeneratorRuntime from "@babel/runtime/regenerator";
22
22
  import produce from 'immer';
@@ -27,17 +27,18 @@ import { filter, take } from 'rxjs/operators';
27
27
  import { timer } from 'rxjs';
28
28
  import { round } from 'lodash-es';
29
29
  import { GraphCore } from '../../framework/graph';
30
- import NodeElement from './comps/NodeElement';
30
+ import NodeElementNormal from './comps/NodeElementNormal';
31
31
  import { DPEdge } from './comps/shape/edge';
32
- import { DPNode } from './comps/shape/node';
32
+ import { DPNode, DPNodeForm } from './comps/shape/node';
33
33
  import { formatGraphData, copy, formatNodeInfoToNodeMeta, formattedEdgesToEdgeMeta, isClipboardEmpty, cleanClipboard, getCellsInClipboard } from './utils';
34
34
  import { deepClone, guid } from '../../utils';
35
35
  import { MetadataService } from '../../framework/metadata/MetadataService';
36
36
  import { tr } from '../../framework/locale';
37
+ import NodeElementForm from './comps/NodeElementForm';
37
38
  var DPGraph = /*#__PURE__*/function (_GraphCore) {
38
39
  _inherits(DPGraph, _GraphCore);
39
40
  var _super = _createSuper(DPGraph);
40
- function DPGraph(_graphData) {
41
+ function DPGraph(_graphData, mode) {
41
42
  var _thisSuper, _this;
42
43
  _classCallCheck(this, DPGraph);
43
44
  _this = _super.call(this, {
@@ -197,6 +198,27 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
197
198
  _this.dpGraphSub = void 0;
198
199
  // 查询执行状态的定时器订阅
199
200
  _this.queryStatusSub = void 0;
201
+ // 节点模式
202
+ _this.mode = void 0;
203
+ _this.switchNode = function (nodeMeta) {
204
+ switch (_this.mode) {
205
+ case 'normal':
206
+ return new DPNode(_objectSpread(_objectSpread({}, nodeMeta), {}, {
207
+ shape: 'dp-rect-port',
208
+ component: /*#__PURE__*/React.createElement(NodeElementNormal, null)
209
+ }));
210
+ case 'form':
211
+ return new DPNodeForm(_objectSpread(_objectSpread({}, nodeMeta), {}, {
212
+ shape: 'dp-rect-port',
213
+ component: /*#__PURE__*/React.createElement(NodeElementForm, null)
214
+ }));
215
+ default:
216
+ return new DPNode(_objectSpread(_objectSpread({}, nodeMeta), {}, {
217
+ shape: 'dp-rect-port',
218
+ component: /*#__PURE__*/React.createElement(NodeElementNormal, null)
219
+ }));
220
+ }
221
+ };
200
222
  // 渲染画布
201
223
  _this.renderGraph = function (wrapper, container) {
202
224
  _this.dpGraphSub = _this.factory$.dpGraph.pipe(filter(function (x) {
@@ -228,10 +250,7 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
228
250
  _this.clearGraphCells();
229
251
  _formatGraphData2 = formatGraphData(graphData), nodes = _formatGraphData2.nodes, edges = _formatGraphData2.edges;
230
252
  dpNodes = nodes.map(function (it) {
231
- return new DPNode(_objectSpread(_objectSpread({}, it), {}, {
232
- shape: 'dp-rect-port',
233
- component: /*#__PURE__*/React.createElement(NodeElement, null)
234
- }));
253
+ return _this.switchNode(it);
235
254
  });
236
255
  dpEdges = edges.map(function (it) {
237
256
  return new DPEdge(it);
@@ -434,6 +453,7 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
434
453
  return _ref7.apply(this, arguments);
435
454
  };
436
455
  }();
456
+ _this.mode = mode || 'normal';
437
457
  _this.initialize(_graphData);
438
458
  return _this;
439
459
  }
@@ -504,10 +524,7 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
504
524
  var data = nodeMeta.data;
505
525
  var type = data.type;
506
526
  if (type === 'node') {
507
- var node = this.graph.addNode(new DPNode(_objectSpread(_objectSpread({}, nodeMeta), {}, {
508
- shape: 'dp-rect-port',
509
- component: /*#__PURE__*/React.createElement(NodeElement, null)
510
- })));
527
+ var node = this.graph.addNode(this.switchNode(nodeMeta));
511
528
  return node;
512
529
  }
513
530
  return undefined;
@@ -899,8 +916,8 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
899
916
  export var gDPGraph;
900
917
  export default DPGraph;
901
918
  // 获取图的实例
902
- export var useDPGraph = function useDPGraph(graphData) {
903
- gDPGraph = new DPGraph(graphData);
919
+ export var useDPGraph = function useDPGraph(graphData, mode) {
920
+ gDPGraph = new DPGraph(graphData, mode);
904
921
  return gDPGraph;
905
922
  };
906
923
  export var useUnmountDPGraph = function useUnmountDPGraph(dispose, dpGraph) {
@@ -7,6 +7,10 @@ interface IDynamicPortsProps {
7
7
  * 渲染图结构
8
8
  */
9
9
  defaultValue?: NDPGraph.GraphData;
10
+ /**
11
+ * 节点图模式
12
+ */
13
+ mode?: 'normal' | 'form';
10
14
  /**
11
15
  * 离开销毁
12
16
  */
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  /*
4
4
  * @Author: wangxian
5
5
  * @Date: 2022-05-16 18:53:31
6
- * @LastEditTime: 2024-02-01 14:44:28
6
+ * @LastEditTime: 2024-02-29 11:32:12
7
7
  */
8
8
  import React from 'react';
9
9
  import { filter } from 'rxjs';
@@ -17,7 +17,9 @@ import { guid } from '../../utils';
17
17
  import ContextMenu from './comps/ContextMenu';
18
18
  import { GraphHandler } from './comps/GraphHandler';
19
19
  var DynamicPorts = function DynamicPorts(props) {
20
- var defaultValue = props.defaultValue,
20
+ var _props$mode = props.mode,
21
+ mode = _props$mode === void 0 ? 'normal' : _props$mode,
22
+ defaultValue = props.defaultValue,
21
23
  isSelection = props.isSelection,
22
24
  _props$dispose = props.dispose,
23
25
  dispose = _props$dispose === void 0 ? true : _props$dispose,
@@ -55,7 +57,7 @@ var DynamicPorts = function DynamicPorts(props) {
55
57
  // 渲染画布
56
58
  React.useEffect(function () {
57
59
  if (firstLoadRef.current) {
58
- var _dpGraph = useDPGraph(defaultValue);
60
+ var _dpGraph = useDPGraph(defaultValue, mode);
59
61
  dpGraphRef.current = _dpGraph;
60
62
  setGraph(_dpGraph);
61
63
  _dpGraph.renderGraph(containerRef.current, divRef.current);
@@ -82,7 +84,7 @@ var DynamicPorts = function DynamicPorts(props) {
82
84
  getDPGraphInstance && getDPGraphInstance(_dpGraph);
83
85
  firstLoadRef.current = false;
84
86
  }
85
- }, [defaultValue]);
87
+ }, [defaultValue, mode]);
86
88
  React.useEffect(function () {
87
89
  if (isSelection && dpGraph) {
88
90
  var _dpGraphRef$current3, _dpGraphRef$current3$;
@@ -92,7 +92,8 @@
92
92
  }
93
93
 
94
94
  .x6-node-selected {
95
- .node-element {
95
+ .node-element,
96
+ .node-element-form {
96
97
  background-color: var(--ronds-metadata-color-bg-4);
97
98
  border: 1px solid #1890ff;
98
99
  box-shadow: 0 0 3px 3px rgba(64, 169, 255, 0.2);
@@ -120,6 +121,21 @@
120
121
  background-color: transparent;
121
122
  }
122
123
 
124
+ .node-element-form {
125
+ .dp-port.connected {
126
+ width: 0;
127
+ height: 0;
128
+ margin-top: 3px;
129
+ margin-left: -1px;
130
+ border-width: 5px 4px 0;
131
+ border-style: solid;
132
+ border-color: #808080 transparent transparent;
133
+ border-radius: 0;
134
+ background-color: transparent;
135
+ transform: rotate(-90deg);
136
+ }
137
+ }
138
+
123
139
  .x6-port-body.available {
124
140
  overflow: visible;
125
141
  }
@@ -220,3 +236,72 @@
220
236
  }
221
237
  }
222
238
  }
239
+
240
+ .node-element-form {
241
+ box-sizing: border-box;
242
+ overflow: hidden;
243
+ min-height: 32px;
244
+ background-color: var(--ronds-metadata-color-bg-4);
245
+ color: var(--ronds-metadata-color-text-1);
246
+ border-radius: 4px;
247
+ box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.08);
248
+
249
+ &.selected,
250
+ &:hover {
251
+ background-color: var(--ronds-metadata-color-bg-4);
252
+ color: var(--ronds-metadata-color-text-1);
253
+ border: 1px solid #1890ff;
254
+ box-shadow: 0 0 3px 3px rgba(64, 169, 255, 0.2);
255
+
256
+ .icon {
257
+ width: 32px;
258
+ height: 30px;
259
+ margin: 0 1px 0 -1px;
260
+ }
261
+ }
262
+
263
+ & > * {
264
+ flex-grow: 1;
265
+ }
266
+ .icon {
267
+ display: inline-flex;
268
+ flex-grow: 0;
269
+ align-items: center;
270
+ justify-content: center;
271
+ width: 32px;
272
+ height: 32px;
273
+ background-color: var(--ronds-metadata-color-bg-6);
274
+ border-radius: 4px 0 0 4px;
275
+ }
276
+
277
+ .notation {
278
+ display: inline-flex;
279
+ align-items: center;
280
+ width: calc(100% - 32px);
281
+ padding: 0 8px;
282
+ user-select: none;
283
+
284
+ & > * {
285
+ flex-grow: 1;
286
+ }
287
+
288
+ .name {
289
+ overflow-x: hidden;
290
+ color: var(--ronds-metadata-color-text-1);
291
+ font-size: 12px;
292
+ white-space: nowrap;
293
+ text-overflow: ellipsis;
294
+ vertical-align: middle;
295
+ }
296
+
297
+ .statusIcon {
298
+ display: inline-flex;
299
+ flex-grow: 0;
300
+ align-items: center;
301
+ font-size: 14px;
302
+ cursor: pointer;
303
+ transform: translateZ(0);
304
+ z-index: 1000;
305
+ }
306
+ }
307
+ }
@@ -0,0 +1 @@
1
+ export declare function pdlToJSON(pdl: string): string;
@@ -0,0 +1,41 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
3
+ /*
4
+ * @Author: wangxian
5
+ * @Date: 2024-03-02 09:43:50
6
+ * @LastEditTime: 2024-03-02 09:44:37
7
+ */
8
+ // 解析PDL并转换为JSON
9
+ export function pdlToJSON(pdl) {
10
+ // 删除注释和空白行
11
+ var cleanedPDL = pdl.replace(/\/\/.*\n/g, '').replace(/\n\s*\n/g, '\n');
12
+ // 提取record定义部分
13
+ var recordStart = cleanedPDL.indexOf('record');
14
+ var recordEnd = cleanedPDL.lastIndexOf('}');
15
+ var recordPDL = cleanedPDL.substring(recordStart, recordEnd + 1);
16
+ // 解析record定义
17
+ var recordName = recordPDL.split(' ')[1].trim();
18
+ var fields = recordPDL.substring(recordPDL.indexOf('{') + 1, recordPDL.lastIndexOf('}')).trim().split('\n');
19
+ // 构建JSON对象
20
+ var json = {};
21
+ json[recordName] = {};
22
+ var _iterator = _createForOfIteratorHelper(fields),
23
+ _step;
24
+ try {
25
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
26
+ var field = _step.value;
27
+ var _field$trim$split$map = field.trim().split(':').map(function (part) {
28
+ return part.trim();
29
+ }),
30
+ _field$trim$split$map2 = _slicedToArray(_field$trim$split$map, 2),
31
+ key = _field$trim$split$map2[0],
32
+ value = _field$trim$split$map2[1];
33
+ json[recordName][key] = value;
34
+ }
35
+ } catch (err) {
36
+ _iterator.e(err);
37
+ } finally {
38
+ _iterator.f();
39
+ }
40
+ return JSON.stringify(json, null, 2);
41
+ }
@@ -1 +1,10 @@
1
1
  export declare function transProtobuf2Json(base64: string, protoSchema: string, message: string): any;
2
+ export declare function transMqttProbuf2Json(base64: string, variableProtoSchema: string, variableMessage: string, bodyProtoSchema: string, bodyMessage: string): {
3
+ formatType: number;
4
+ compressType: number;
5
+ sendTime: number;
6
+ variableLength: number;
7
+ contentLength: number;
8
+ variableContent: any;
9
+ content: any;
10
+ };
@@ -29,4 +29,59 @@ export function transProtobuf2Json(base64, protoSchema, message) {
29
29
  console.error('解码失败:', err);
30
30
  return null;
31
31
  }
32
+ }
33
+ export function transMqttProbuf2Json(base64, variableProtoSchema, variableMessage, bodyProtoSchema, bodyMessage) {
34
+ var variableRoot = protobuf.parse(variableProtoSchema, {
35
+ keepCase: true
36
+ }).root;
37
+ var bodyRoot = protobuf.parse(bodyProtoSchema, {
38
+ keepCase: true
39
+ }).root;
40
+ var variableRootTransferMessage = variableRoot.lookupType(variableMessage);
41
+ var bodyRootTransferMessage = bodyRoot.lookupType(bodyMessage);
42
+ // 解析Mqtt消息
43
+ var uint8Array = transBase642byte(base64);
44
+ try {
45
+ // 解码包体格式
46
+ var formatValue = uint8Array.slice(0, 1);
47
+ var formatType = parseInt(Array.from(formatValue).map(function (byte) {
48
+ return byte.toString(2).padStart(8, '0');
49
+ }).join(''), 2);
50
+ // 解码压缩类型
51
+ var compressValue = uint8Array.slice(1, 2);
52
+ var compressType = parseInt(Array.from(compressValue).map(function (byte) {
53
+ return byte.toString(2).padStart(8, '0');
54
+ }).join(''), 2);
55
+ // 解码时间戳
56
+ var sendTimeValue = uint8Array.slice(2, 6);
57
+ var sendTime = parseInt(Array.from(sendTimeValue).map(function (byte) {
58
+ return byte.toString(2).padStart(8, '0');
59
+ }).join(''), 2);
60
+ // 解码可变内容长度、包体内容长度
61
+ var variableValue = uint8Array.slice(6, 8);
62
+ var bodyValue = uint8Array.slice(8, 12);
63
+ var variableLength = parseInt(Array.from(variableValue).map(function (byte) {
64
+ return byte.toString(2).padStart(8, '0');
65
+ }).join(''), 2);
66
+ var bodyLength = parseInt(Array.from(bodyValue).map(function (byte) {
67
+ return byte.toString(2).padStart(8, '0');
68
+ }).join(''), 2);
69
+ // 解码可变内容、包体内容
70
+ var variableData = uint8Array.slice(12, 12 + variableLength);
71
+ var bodyData = uint8Array.slice(12 + variableLength, 12 + variableLength + bodyLength);
72
+ var variableContent = variableRootTransferMessage.decode(variableData);
73
+ var bodyContent = bodyRootTransferMessage.decode(bodyData);
74
+ return {
75
+ formatType: formatType,
76
+ compressType: compressType,
77
+ sendTime: sendTime,
78
+ variableLength: variableLength,
79
+ contentLength: bodyLength,
80
+ variableContent: variableContent,
81
+ content: bodyContent
82
+ };
83
+ } catch (err) {
84
+ console.error('解码失败:', err);
85
+ return null;
86
+ }
32
87
  }
package/es/index.d.ts CHANGED
@@ -24,4 +24,4 @@ export { registerMetadataAPI } from './framework/metadata/MetadataService';
24
24
  export { FormRobot } from './framework/fg/index';
25
25
  export { globalSettingStream } from './config';
26
26
  export { handleMd2Doc } from './utils';
27
- export { transProtobuf2Json } from './framework/proto/index';
27
+ export { transProtobuf2Json, transMqttProbuf2Json } from './framework/proto/index';
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author:wangxian
3
3
  * @Date: 2021-09-18 14:15:04
4
- * @LastEditTime: 2023-11-23 15:48:15
4
+ * @LastEditTime: 2024-03-04 11:03:41
5
5
  */
6
6
  import './theme.less';
7
7
  export { default as MetadataEdit } from './comps/MetadataEdit';
@@ -31,4 +31,4 @@ export { registerMetadataAPI } from './framework/metadata/MetadataService';
31
31
  export { FormRobot } from './framework/fg/index';
32
32
  export { globalSettingStream } from './config';
33
33
  export { handleMd2Doc } from './utils';
34
- export { transProtobuf2Json } from './framework/proto/index';
34
+ export { transProtobuf2Json, transMqttProbuf2Json } from './framework/proto/index';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.3.32",
4
+ "version": "1.3.33",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",
@@ -1,6 +0,0 @@
1
- import '../index.less';
2
- interface NodeElementProps {
3
- node?: Node;
4
- }
5
- declare const NodeElement: (props: NodeElementProps) => JSX.Element;
6
- export default NodeElement;