strategy-panel 1.0.4 → 1.0.6-beta.1

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.
Files changed (43) hide show
  1. package/es/components/canvas/component-tree-panel/category-tree/category-type.js +10 -6
  2. package/es/components/canvas/config-panel/config-common.d.ts +1 -11
  3. package/es/components/canvas/config-panel/config-common.js +26 -25
  4. package/es/components/canvas/config-panel/node-form.d.ts +1 -0
  5. package/es/components/canvas/config-panel/node-form.js +5 -1
  6. package/es/components/canvas/config-panel/style.less +4 -0
  7. package/es/components/canvas/dag-canvas/canvas-content.d.ts +1 -0
  8. package/es/components/canvas/dag-canvas/canvas-content.js +7 -4
  9. package/es/components/canvas/dag-canvas/index.d.ts +5 -0
  10. package/es/components/canvas/dag-canvas/index.js +4 -1
  11. package/es/components/canvas/dag-canvas/preview.d.ts +1 -0
  12. package/es/components/canvas/dag-canvas/preview.js +4 -2
  13. package/es/components/canvas/index.d.ts +5 -0
  14. package/es/components/canvas/index.js +5 -1
  15. package/es/packages/graph-canvas/graph-utils/graph.d.ts +6 -2
  16. package/es/packages/graph-canvas/graph-utils/graph.js +17 -6
  17. package/es/packages/graph-canvas/index.d.ts +1 -1
  18. package/es/packages/graph-canvas/index.js +27 -13
  19. package/es/packages/graph-model/node/index.d.ts +2 -0
  20. package/es/packages/graph-model/node/index.js +59 -4
  21. package/es/packages/graph-model/node/node-basic.less +2 -1
  22. package/lib/components/canvas/component-tree-panel/category-tree/category-type.js +10 -6
  23. package/lib/components/canvas/config-panel/config-common.d.ts +1 -11
  24. package/lib/components/canvas/config-panel/config-common.js +23 -22
  25. package/lib/components/canvas/config-panel/node-form.d.ts +1 -0
  26. package/lib/components/canvas/config-panel/node-form.js +5 -1
  27. package/lib/components/canvas/config-panel/style.less +4 -0
  28. package/lib/components/canvas/dag-canvas/canvas-content.d.ts +1 -0
  29. package/lib/components/canvas/dag-canvas/canvas-content.js +7 -4
  30. package/lib/components/canvas/dag-canvas/index.d.ts +5 -0
  31. package/lib/components/canvas/dag-canvas/index.js +4 -1
  32. package/lib/components/canvas/dag-canvas/preview.d.ts +1 -0
  33. package/lib/components/canvas/dag-canvas/preview.js +4 -2
  34. package/lib/components/canvas/index.d.ts +5 -0
  35. package/lib/components/canvas/index.js +5 -1
  36. package/lib/packages/graph-canvas/graph-utils/graph.d.ts +6 -2
  37. package/lib/packages/graph-canvas/graph-utils/graph.js +18 -7
  38. package/lib/packages/graph-canvas/index.d.ts +1 -1
  39. package/lib/packages/graph-canvas/index.js +27 -13
  40. package/lib/packages/graph-model/node/index.d.ts +2 -0
  41. package/lib/packages/graph-model/node/index.js +59 -4
  42. package/lib/packages/graph-model/node/node-basic.less +2 -1
  43. package/package.json +1 -1
@@ -25,10 +25,10 @@ export var componentsData = [{
25
25
  isDir: true,
26
26
  tooltip: '触发组件是规则运行的触发条件,作为策略树中的第一个节点,目前支持设备触发、时间触发和手动触发',
27
27
  children: [{
28
+ nodeType: 'counter',
28
29
  id: SCENE_DISPLAY.EQUIPMENT,
29
30
  name: '设备触发',
30
- imgUrl: device,
31
- number: 1
31
+ imgUrl: device
32
32
  }, {
33
33
  id: SCENE_DISPLAY.MANUAL,
34
34
  name: '手动按钮',
@@ -57,7 +57,8 @@ export var componentsData = [{
57
57
  }, {
58
58
  id: SCENE_DISPLAY.TIME,
59
59
  name: '时间触发',
60
- imgUrl: time
60
+ imgUrl: time,
61
+ description: "说明:在指定区间单位的时间内,发生报警才会生效,时间区间范围外则不会生效;"
61
62
  }]
62
63
  }, {
63
64
  id: COMPONENTS_TYPE.MOTION_OPERATION,
@@ -71,15 +72,18 @@ export var componentsData = [{
71
72
  }, {
72
73
  id: MOTION_OPERATION.ALARM,
73
74
  name: '报警',
74
- imgUrl: alarm
75
+ imgUrl: alarm,
76
+ description: "执行报警通知"
75
77
  }, {
76
78
  id: MOTION_OPERATION.NOTICE,
77
79
  name: '通知',
78
- imgUrl: notice
80
+ imgUrl: notice,
81
+ description: "执行通知规则"
79
82
  }, {
80
83
  id: MOTION_OPERATION.ORDER,
81
84
  name: '派发工单',
82
- imgUrl: order
85
+ imgUrl: order,
86
+ description: "达到条件生成工单任务"
83
87
  }, {
84
88
  id: MOTION_OPERATION.CONTROL,
85
89
  name: '远程控制',
@@ -11,16 +11,6 @@ export declare const getComponentConfig: (experimentId: string) => {
11
11
  label: string;
12
12
  value: string;
13
13
  }[];
14
- }[] | {
15
- name: string;
16
- type: string;
17
- component: React.JSX.Element;
18
- }[] | {
19
- name: string;
20
- label: string;
21
- required: boolean;
22
- type: string;
23
- component: React.JSX.Element;
24
14
  }[] | ({
25
15
  name: string;
26
16
  label: string;
@@ -36,4 +26,4 @@ export declare const getComponentConfig: (experimentId: string) => {
36
26
  }[];
37
27
  })[];
38
28
  };
39
- export declare const getFormatComponent: (data: any, mode: ModeType) => React.JSX.Element | undefined;
29
+ export declare const getFormatComponent: (data: any, viewMode: ModeType) => React.JSX.Element | undefined;
@@ -3,20 +3,18 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
3
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
4
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
5
  import React from 'react';
6
- import { Form, Input, Select } from 'antd';
6
+ import { Form, Input, InputNumber, Select } from 'antd';
7
7
  import { withMode } from "../../../packages/hooks/withMode";
8
- import { MOTION_OPERATION,
8
+ import { MOTION_OPERATION
9
9
  // COMPONENTS_TYPE,
10
10
  // COMMONLY_USED,
11
- SCENE_DISPLAY, SIGN_OPERATION
11
+ , SIGN_OPERATION
12
12
  // MOTION_OPERATION,
13
13
  } from "../../../packages/graph-canvas/node-types";
14
- import TimeTrigger from "./components/time-trigger";
15
- import ConditionConfiguration from "./components/condition-configuration";
16
14
  import "./style.less";
17
15
  var Option = Select.Option;
18
16
  export var getComponentConfig = function getComponentConfig(experimentId) {
19
- return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, SIGN_OPERATION.LOGICAL, [{
17
+ return _defineProperty(_defineProperty({}, SIGN_OPERATION.LOGICAL, [{
20
18
  name: 'operator',
21
19
  label: '逻辑符号',
22
20
  type: 'select',
@@ -31,18 +29,6 @@ export var getComponentConfig = function getComponentConfig(experimentId) {
31
29
  label: '异',
32
30
  value: '^'
33
31
  }]
34
- }]), SCENE_DISPLAY.TIME, [{
35
- name: 'timeControl',
36
- type: 'auto',
37
- component: /*#__PURE__*/React.createElement(TimeTrigger, null)
38
- }]), SIGN_OPERATION.CONDITION, [{
39
- name: 'condition',
40
- label: '条件配置',
41
- required: true,
42
- type: 'auto',
43
- component: /*#__PURE__*/React.createElement(ConditionConfiguration, {
44
- experimentId: experimentId
45
- })
46
32
  }]), MOTION_OPERATION.CONTROL, [{
47
33
  name: 'name',
48
34
  label: '控制名称',
@@ -66,14 +52,15 @@ export var getComponentConfig = function getComponentConfig(experimentId) {
66
52
  }]
67
53
  }]);
68
54
  };
69
- export var getFormatComponent = function getFormatComponent(data, mode) {
55
+ export var getFormatComponent = function getFormatComponent(data, viewMode) {
70
56
  var type = data.type,
71
57
  name = data.name,
72
58
  label = data.label,
73
59
  disabled = data.disabled,
74
60
  selectData = data.selectData,
75
61
  component = data.component,
76
- required = data.required;
62
+ required = data.required,
63
+ mode = data.mode;
77
64
  var formComponent = undefined;
78
65
  var rules = [{
79
66
  required: required,
@@ -81,11 +68,10 @@ export var getFormatComponent = function getFormatComponent(data, mode) {
81
68
  }];
82
69
 
83
70
  //
84
- var withModeComponent = withMode(component, mode);
71
+ var withModeComponent = withMode(component, viewMode);
85
72
 
86
73
  // console.log('withMode(component, mode)', withModeComponent.type)
87
- // console.log('component', component.type)
88
-
74
+ console.log('getFormatComponent', data);
89
75
  switch (type) {
90
76
  case 'input':
91
77
  formComponent = /*#__PURE__*/React.createElement("div", {
@@ -97,7 +83,20 @@ export var getFormatComponent = function getFormatComponent(data, mode) {
97
83
  rules: rules,
98
84
  className: "no-margin-bottom"
99
85
  }, /*#__PURE__*/React.createElement(Input, {
100
- disabled: mode === 'view' ? true : disabled
86
+ disabled: viewMode === 'view' ? true : disabled
87
+ })));
88
+ break;
89
+ case 'inputNumber':
90
+ formComponent = /*#__PURE__*/React.createElement("div", {
91
+ className: "border-bottom",
92
+ key: name
93
+ }, /*#__PURE__*/React.createElement(Form.Item, {
94
+ label: label,
95
+ name: name,
96
+ rules: rules,
97
+ className: "no-margin-bottom"
98
+ }, /*#__PURE__*/React.createElement(InputNumber, {
99
+ disabled: viewMode === 'view' ? true : disabled
101
100
  })));
102
101
  break;
103
102
  case 'select':
@@ -110,7 +109,9 @@ export var getFormatComponent = function getFormatComponent(data, mode) {
110
109
  rules: rules,
111
110
  className: "no-margin-bottom"
112
111
  }, /*#__PURE__*/React.createElement(Select, {
113
- disabled: mode === 'view' ? true : disabled
112
+ mode: mode,
113
+ maxTagCount: "responsive",
114
+ disabled: viewMode === 'view' ? true : disabled
114
115
  }, selectData === null || selectData === void 0 ? void 0 : selectData.map(function (item) {
115
116
  return /*#__PURE__*/React.createElement(Option, {
116
117
  key: item.value,
@@ -8,6 +8,7 @@ export declare type configDataItem = Record<string, {
8
8
  required?: boolean;
9
9
  component?: React.ReactNode;
10
10
  disabled?: boolean;
11
+ mode?: 'multiple';
11
12
  selectData?: {
12
13
  label: string;
13
14
  value: any;
@@ -44,6 +44,8 @@ var NodeForm = function NodeForm(_ref) {
44
44
  }
45
45
  }, [node === null || node === void 0 ? void 0 : node.nodeData]);
46
46
  var idsSplit = node === null || node === void 0 || (_node$id = node.id) === null || _node$id === void 0 ? void 0 : _node$id.split('-');
47
+ console.log("nodexxxxx ======", node, configData);
48
+ console.log("allConfigDataxxxx", allConfigData, extraConfigData);
47
49
  return /*#__PURE__*/React.createElement(Form, {
48
50
  form: form,
49
51
  className: "config-panel-form",
@@ -66,6 +68,8 @@ var NodeForm = function NodeForm(_ref) {
66
68
  className: "no-margin-bottom"
67
69
  }, /*#__PURE__*/React.createElement(Input, null))), configData === null || configData === void 0 ? void 0 : configData.map(function (item) {
68
70
  return getFormatComponent(item, mode);
69
- }));
71
+ }), (node === null || node === void 0 ? void 0 : node.description) && /*#__PURE__*/React.createElement("div", {
72
+ className: "config-description"
73
+ }, "\u8BF4\u660E: ", node === null || node === void 0 ? void 0 : node.description));
70
74
  };
71
75
  export default NodeForm;
@@ -88,3 +88,7 @@
88
88
  .section-detail-select{
89
89
  display: flex;
90
90
  }
91
+
92
+ .config-description{
93
+ padding: 0 10px 12px;
94
+ }
@@ -6,6 +6,7 @@ interface Props {
6
6
  className?: string;
7
7
  viewData?: any;
8
8
  dragEnable: boolean;
9
+ methodMap?: Record<string, any[]>;
9
10
  }
10
11
  export declare const CanvasContent: React.FC<Props>;
11
12
  export {};
@@ -16,7 +16,9 @@ export var CanvasContent = function CanvasContent(props) {
16
16
  var experimentId = props.experimentId,
17
17
  className = props.className,
18
18
  viewData = props.viewData,
19
- dragEnable = props.dragEnable;
19
+ dragEnable = props.dragEnable,
20
+ _props$methodMap = props.methodMap,
21
+ methodMap = _props$methodMap === void 0 ? {} : _props$methodMap;
20
22
  var viewDataJSON = JSON.stringify(viewData);
21
23
  console.log('dragEnable', dragEnable);
22
24
  var containerRef = useRef(null);
@@ -26,7 +28,8 @@ export var CanvasContent = function CanvasContent(props) {
26
28
  // 渲染画布
27
29
  useEffect(function () {
28
30
  window.requestIdleCallback(function () {
29
- expGraph.renderGraph(containerRef.current, canvasRef.current);
31
+ console.log('renderGraphxxx', methodMap);
32
+ expGraph.renderGraph(containerRef.current, canvasRef.current, {}, methodMap);
30
33
  if (viewData) {
31
34
  var _expGraph$graph, _expGraph$graph2, _expGraph$graph2$zoom;
32
35
  // console.log('=====================>>>>>>>>>>>>>>>>', viewData)
@@ -37,7 +40,7 @@ export var CanvasContent = function CanvasContent(props) {
37
40
  });
38
41
  }
39
42
  });
40
- }, [expGraph, viewDataJSON]);
43
+ }, [expGraph, viewDataJSON, methodMap]);
41
44
  var checkNodeNumber = function checkNodeNumber(_ref) {
42
45
  var _expGraph$graph3;
43
46
  var id = _ref.id,
@@ -70,7 +73,7 @@ export var CanvasContent = function CanvasContent(props) {
70
73
  clientX: x,
71
74
  clientY: y,
72
75
  nodeMeta: item.component
73
- });
76
+ }, methodMap);
74
77
  } else {
75
78
  message.error("".concat(item.component.name, "\u7EC4\u4EF6\u53EA\u80FD\u5B58\u5728\u4E00\u4E2A"));
76
79
  }
@@ -18,6 +18,11 @@ interface Props {
18
18
  * @description.zh-CN 拖拽可创建
19
19
  */
20
20
  dragEnable?: boolean;
21
+ /**
22
+ * @description methodMap
23
+ * @description.zh-CN 方法映射
24
+ */
25
+ methodMap?: any;
21
26
  }
22
27
  declare const DAGCanvas: React.FC<Props>;
23
28
  export default DAGCanvas;
@@ -8,7 +8,9 @@ var DAGCanvas = function DAGCanvas(props) {
8
8
  className = props.className,
9
9
  viewData = props.viewData,
10
10
  _props$dragEnable = props.dragEnable,
11
- dragEnable = _props$dragEnable === void 0 ? true : _props$dragEnable;
11
+ dragEnable = _props$dragEnable === void 0 ? true : _props$dragEnable,
12
+ _props$methodMap = props.methodMap,
13
+ methodMap = _props$methodMap === void 0 ? {} : _props$methodMap;
12
14
  var expGraph = useExperimentGraph(experimentId);
13
15
 
14
16
  // 处理画布卸载
@@ -26,6 +28,7 @@ var DAGCanvas = function DAGCanvas(props) {
26
28
  }, /*#__PURE__*/React.createElement(CanvasContent, {
27
29
  dragEnable: dragEnable,
28
30
  viewData: viewData,
31
+ methodMap: methodMap,
29
32
  experimentId: experimentId,
30
33
  className: "canvas-content"
31
34
  }));
@@ -5,6 +5,7 @@ interface Props {
5
5
  experimentId: string;
6
6
  className?: string;
7
7
  viewData?: any;
8
+ methodMap?: any;
8
9
  }
9
10
  declare const CanvasContent: React.FC<Props>;
10
11
  export default CanvasContent;
@@ -6,7 +6,9 @@ import "./canvas-content.less";
6
6
  var CanvasContent = function CanvasContent(props) {
7
7
  var experimentId = props.experimentId,
8
8
  className = props.className,
9
- viewData = props.viewData;
9
+ viewData = props.viewData,
10
+ _props$methodMap = props.methodMap,
11
+ methodMap = _props$methodMap === void 0 ? {} : _props$methodMap;
10
12
  var viewDataJSON = JSON.stringify(viewData);
11
13
 
12
14
  // 处理画布卸载
@@ -22,7 +24,7 @@ var CanvasContent = function CanvasContent(props) {
22
24
  var _expGraph$graph, _expGraph$graph2, _expGraph$graph3;
23
25
  expGraph.renderGraph(containerRef.current, canvasRef.current, {
24
26
  interacting: false
25
- });
27
+ }, methodMap);
26
28
  expGraph === null || expGraph === void 0 || (_expGraph$graph = expGraph.graph) === null || _expGraph$graph === void 0 || _expGraph$graph.hideGrid();
27
29
  expGraph === null || expGraph === void 0 || (_expGraph$graph2 = expGraph.graph) === null || _expGraph$graph2 === void 0 || _expGraph$graph2.disableKeyboard();
28
30
  expGraph.onClearSelectNodes();
@@ -43,6 +43,11 @@ interface Props extends Omit<HeaderProps, 'experimentId'> {
43
43
  * @description.zh-CN 拖拽可创建
44
44
  */
45
45
  dragEnable?: boolean;
46
+ /**
47
+ * @description methodMap
48
+ * @description.zh-CN 方法映射
49
+ */
50
+ methodMap?: any;
46
51
  }
47
52
  declare const StrategyCanvas: React.FC<Props>;
48
53
  export default StrategyCanvas;
@@ -1,4 +1,4 @@
1
- var _excluded = ["experimentId", "headerVisible", "panelData", "configData", "mode", "viewData", "dragEnable"];
1
+ var _excluded = ["experimentId", "headerVisible", "panelData", "configData", "mode", "viewData", "dragEnable", "methodMap"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -26,6 +26,8 @@ var StrategyCanvas = function StrategyCanvas(props) {
26
26
  viewData = _props$viewData === void 0 ? {} : _props$viewData,
27
27
  _props$dragEnable = props.dragEnable,
28
28
  dragEnable = _props$dragEnable === void 0 ? true : _props$dragEnable,
29
+ _props$methodMap = props.methodMap,
30
+ methodMap = _props$methodMap === void 0 ? {} : _props$methodMap,
29
31
  rest = _objectWithoutProperties(props, _excluded);
30
32
  console.log('userAgent', (_window = window) === null || _window === void 0 ? void 0 : _window.openDatebase);
31
33
  if ((_window2 = window) !== null && _window2 !== void 0 && _window2.openDatebase) {
@@ -42,6 +44,7 @@ var StrategyCanvas = function StrategyCanvas(props) {
42
44
  }, /*#__PURE__*/React.createElement("div", {
43
45
  className: "experiment-edit-panel"
44
46
  }, /*#__PURE__*/React.createElement(CanvasPreview, {
47
+ methodMap: methodMap,
45
48
  viewData: viewData,
46
49
  experimentId: "".concat(experimentId),
47
50
  className: "panel-dag-canvas"
@@ -66,6 +69,7 @@ var StrategyCanvas = function StrategyCanvas(props) {
66
69
  className: "experiment-edit-panel"
67
70
  }, /*#__PURE__*/React.createElement(DAGCanvas, {
68
71
  viewData: viewData,
72
+ methodMap: methodMap,
69
73
  experimentId: "".concat(experimentId),
70
74
  className: "panel-dag-canvas",
71
75
  dragEnable: dragEnable
@@ -6,6 +6,7 @@ interface NodeParams {
6
6
  y: number;
7
7
  applicationImgUrl?: string;
8
8
  nodeData?: string;
9
+ description?: string;
9
10
  }
10
11
  export declare const createNodePorts: (id: string, timestamp: string) => {
11
12
  inPorts: {
@@ -22,7 +23,7 @@ export declare const createNodePorts: (id: string, timestamp: string) => {
22
23
  group: string;
23
24
  })[];
24
25
  };
25
- export declare const createNode: ({ id, name, imgUrl, applicationImgUrl, x, y, nodeData }: NodeParams) => {
26
+ export declare const createNode: ({ id, name, imgUrl, applicationImgUrl, x, y, nodeData, description, ...restParams }: NodeParams) => {
26
27
  inPorts: {
27
28
  id: string;
28
29
  sequence: number;
@@ -40,11 +41,12 @@ export declare const createNode: ({ id, name, imgUrl, applicationImgUrl, x, y, n
40
41
  name: string;
41
42
  imgUrl: string;
42
43
  applicationImgUrl: string | undefined;
44
+ description: string | undefined;
43
45
  positionX: number;
44
46
  positionY: number;
45
47
  nodeData: string | undefined;
46
48
  };
47
- export declare const copyNode: ({ id, name, imgUrl, applicationImgUrl, x, y, nodeData }: NodeParams) => {
49
+ export declare const copyNode: ({ id, name, imgUrl, applicationImgUrl, x, y, nodeData, description, ...restParams }: NodeParams) => {
48
50
  inPorts: {
49
51
  id: string;
50
52
  sequence: number;
@@ -62,6 +64,7 @@ export declare const copyNode: ({ id, name, imgUrl, applicationImgUrl, x, y, nod
62
64
  name: string;
63
65
  imgUrl: string;
64
66
  applicationImgUrl: string | undefined;
67
+ description: string | undefined;
65
68
  positionX: number;
66
69
  positionY: number;
67
70
  nodeData: string | undefined;
@@ -84,6 +87,7 @@ export declare const addNode: (params: NodeParams) => {
84
87
  name: string;
85
88
  imgUrl: string;
86
89
  applicationImgUrl: string | undefined;
90
+ description: string | undefined;
87
91
  positionX: number;
88
92
  positionY: number;
89
93
  nodeData: string | undefined;
@@ -1,9 +1,13 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["id", "name", "imgUrl", "applicationImgUrl", "x", "y", "nodeData", "description"],
3
+ _excluded2 = ["id", "name", "imgUrl", "applicationImgUrl", "x", "y", "nodeData", "description"];
2
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
6
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
7
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
8
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
7
11
  import random from 'lodash/random';
8
12
  import { SIGN_OPERATION } from "../node-types";
9
13
  export var createNodePorts = function createNodePorts(id, timestamp) {
@@ -68,18 +72,21 @@ export var createNode = function createNode(_ref) {
68
72
  applicationImgUrl = _ref.applicationImgUrl,
69
73
  x = _ref.x,
70
74
  y = _ref.y,
71
- nodeData = _ref.nodeData;
75
+ nodeData = _ref.nodeData,
76
+ description = _ref.description,
77
+ restParams = _objectWithoutProperties(_ref, _excluded);
72
78
  var timestamp = "".concat(Date.now());
73
79
  var portsParams = createNodePorts(id, timestamp);
74
- return _objectSpread({
80
+ return _objectSpread(_objectSpread({
75
81
  id: id ? "".concat(id, "-").concat(timestamp) : "".concat(timestamp),
76
82
  name: name,
77
83
  imgUrl: imgUrl,
78
84
  applicationImgUrl: applicationImgUrl,
85
+ description: description,
79
86
  positionX: x,
80
87
  positionY: y,
81
88
  nodeData: nodeData
82
- }, portsParams);
89
+ }, restParams), portsParams);
83
90
  };
84
91
  export var copyNode = function copyNode(_ref2) {
85
92
  var _id$split;
@@ -89,17 +96,21 @@ export var copyNode = function copyNode(_ref2) {
89
96
  applicationImgUrl = _ref2.applicationImgUrl,
90
97
  x = _ref2.x,
91
98
  y = _ref2.y,
92
- nodeData = _ref2.nodeData;
99
+ nodeData = _ref2.nodeData,
100
+ description = _ref2.description,
101
+ restParams = _objectWithoutProperties(_ref2, _excluded2);
93
102
  var nodeId = id === null || id === void 0 || (_id$split = id.split('-')) === null || _id$split === void 0 ? void 0 : _id$split[0];
94
- return createNode({
103
+ return createNode(_objectSpread(_objectSpread({
95
104
  id: nodeId,
96
105
  name: name,
97
106
  imgUrl: imgUrl,
98
107
  applicationImgUrl: applicationImgUrl,
99
108
  nodeData: nodeData,
109
+ description: description
110
+ }, restParams), {}, {
100
111
  x: x + 200 + random(20, false),
101
112
  y: y + 15 + random(20, false)
102
- });
113
+ }));
103
114
  };
104
115
  export var addNode = function addNode(params) {
105
116
  return createNode(params);
@@ -30,7 +30,7 @@ declare class ExperimentGraph extends GraphCore<BaseNode, BaseEdge> {
30
30
  updateExperimentGraph(nodes?: NExperimentGraph.Node[], links?: NExperimentGraph.Link[]): Promise<void>;
31
31
  delExperimentGraphElement(nodes?: string[], links?: NExperimentGraph.Link[]): Promise<void>;
32
32
  isGraphReady(): boolean;
33
- renderGraph: (wrapper: HTMLElement, container: HTMLElement, options?: any) => void;
33
+ renderGraph: (wrapper: HTMLElement, container: HTMLElement, options?: any, nodeConfig?: Record<string, any>) => void;
34
34
  registerEdge: () => void;
35
35
  createTypeNodeMeta: (nodeMeta: NodeMeta, nodeType: any, experimentId: string) => BaseNode | undefined;
36
36
  renderNode(nodeMeta: NodeMeta): BaseNode | undefined;
@@ -104,7 +104,7 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
104
104
  // 当 snap 设置为 true 时连线的过程中距离节点或者连接桩 50px 时会触发自动吸附,可以通过配置 radius 属性自定义触发吸附的距离。当 snap 设置为 false 时不会触发自动吸附。默认值为 false。
105
105
  allowBlank: false,
106
106
  // 是否允许连接到画布空白位置的点
107
- allowMulti: false,
107
+ allowMulti: "withPort",
108
108
  highlight: true,
109
109
  // 拖动边时,是否高亮显示所有可用的连接桩或节点
110
110
  router: 'manhattan',
@@ -142,7 +142,10 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
142
142
  // 是否触发交互事件 点击 magnet 时 根据 validateMagnet 返回值来判断是否新增边,触发时机是 magnet 被按下,如果返回 false,则没有任何反应,如果返回 true,会在当前 magnet 创建一条新的边。
143
143
  validateMagnet: function validateMagnet(_ref) {
144
144
  var magnet = _ref.magnet;
145
- return magnet.getAttribute('port-group') !== 'in';
145
+ var portGroup = magnet.getAttribute('port-group');
146
+ // console.log('validateMagnet', portGroup, portGroup !== 'in')
147
+ // 允许从除了'in'和'method'之外的端口发起连接
148
+ return !['in', 'method'].includes(portGroup);
146
149
  },
147
150
  // 显示可用的链接桩 在移动边的时候判断连接是否有效,如果返回 false,当鼠标放开的时候,不会连接到当前元素,否则会连接到当前元素。
148
151
  validateConnection: function validateConnection(_ref2) {
@@ -150,6 +153,7 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
150
153
  targetView = _ref2.targetView,
151
154
  sourceMagnet = _ref2.sourceMagnet,
152
155
  targetMagnet = _ref2.targetMagnet;
156
+ // console.log("validateConnection", sourceView, targetView, sourceMagnet, targetMagnet)
153
157
  // 不允许连接到自己
154
158
  if (sourceView === targetView) {
155
159
  return false;
@@ -160,8 +164,9 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
160
164
  return false;
161
165
  }
162
166
 
163
- // 只能连接到输入链接桩
164
- if (!targetMagnet || targetMagnet.getAttribute('port-group') !== 'in') {
167
+ // 只能连接到输入链接桩或方法端口
168
+ var targetPortGroup = targetMagnet === null || targetMagnet === void 0 ? void 0 : targetMagnet.getAttribute('port-group');
169
+ if (!targetMagnet || !['in', 'method'].includes(targetPortGroup)) {
165
170
  return false;
166
171
  }
167
172
 
@@ -257,7 +262,9 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
257
262
  // 渲染画布
258
263
  _defineProperty(_assertThisInitialized(_this), "renderGraph", function (wrapper, container) {
259
264
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
260
- console.log('renderGraph');
265
+ var nodeConfig = arguments.length > 3 ? arguments[3] : undefined;
266
+ _this.nodeConfig = nodeConfig;
267
+ console.log('renderGraphxxx =====>1', nodeConfig, _this.nodeConfig);
261
268
  _this.experimentGraphSub = _this.experimentGraph$.pipe(filter(function (x) {
262
269
  return !!x;
263
270
  }),
@@ -273,7 +280,8 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
273
280
  container: container,
274
281
  nodes: nodes,
275
282
  edges: edges,
276
- options: options
283
+ options: options,
284
+ nodeConfig: nodeConfig
277
285
  });
278
286
  }
279
287
  });
@@ -289,7 +297,9 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
289
297
  Graph.registerEdge('group-edge', GroupEdge);
290
298
  });
291
299
  _defineProperty(_assertThisInitialized(_this), "createTypeNodeMeta", function (nodeMeta, nodeType, experimentId) {
292
- console.log('===================== createTypeNodeMeta', nodeMeta);
300
+ var _assertThisInitialize = _assertThisInitialized(_this),
301
+ nodeConfig = _assertThisInitialize.nodeConfig;
302
+ console.log('===================== createTypeNodeMeta', nodeType, _this.nodeConfig);
293
303
  var data = nodeMeta.data;
294
304
  var _ref3 = data,
295
305
  type = _ref3.type;
@@ -298,6 +308,7 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
298
308
  /* 条件判断 */
299
309
  if (nodeType === SIGN_OPERATION.CONDITION) {
300
310
  return _this.graph.addNode(new ConditionJudgment(_objectSpread(_objectSpread({}, nodeMeta), {}, {
311
+ nodeConfig: nodeConfig,
301
312
  shape: 'condition-judgement-element',
302
313
  component: /*#__PURE__*/React.createElement(ConditionElement, {
303
314
  experimentId: experimentId
@@ -307,6 +318,7 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
307
318
  /* 逻辑运算 */
308
319
  if (nodeType === SIGN_OPERATION.LOGICAL || nodeType === COMMONLY_USED.LOCKED) {
309
320
  return _this.graph.addNode(new LogicalNode(_objectSpread(_objectSpread({}, nodeMeta), {}, {
321
+ nodeConfig: nodeConfig,
310
322
  shape: 'logical-node',
311
323
  component: /*#__PURE__*/React.createElement(LogicalElement, {
312
324
  experimentId: experimentId
@@ -315,6 +327,7 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
315
327
  }
316
328
  if ((nodeType === null || nodeType === void 0 ? void 0 : nodeType.indexOf(COMPONENTS_TYPE.APPLICATION)) === 0) {
317
329
  return _this.graph.addNode(new ApplicationNode(_objectSpread(_objectSpread({}, nodeMeta), {}, {
330
+ nodeConfig: nodeConfig,
318
331
  shape: 'application-node',
319
332
  component: /*#__PURE__*/React.createElement(ApplicationElement, {
320
333
  experimentId: experimentId
@@ -322,7 +335,8 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
322
335
  })));
323
336
  }
324
337
  return _this.graph.addNode(new CommonNode(_objectSpread(_objectSpread({}, nodeMeta), {}, {
325
- shape: 'application-node',
338
+ shape: 'base-rect-node',
339
+ nodeConfig: nodeConfig,
326
340
  component: /*#__PURE__*/React.createElement(NodeElement, {
327
341
  experimentId: experimentId
328
342
  })
@@ -351,12 +365,12 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
351
365
  // 发起请求增加节点
352
366
  _defineProperty(_assertThisInitialized(_this), "requestAddNode", /*#__PURE__*/function () {
353
367
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(param) {
354
- var _assertThisInitialize, graph, nodeMeta, clientX, clientY, pos, nodeRes, newNode;
368
+ var _assertThisInitialize2, graph, nodeMeta, clientX, clientY, pos, nodeRes, newNode;
355
369
  return _regeneratorRuntime().wrap(function _callee$(_context) {
356
370
  while (1) switch (_context.prev = _context.next) {
357
371
  case 0:
358
372
  console.log('requestAddNode');
359
- _assertThisInitialize = _assertThisInitialized(_this), graph = _assertThisInitialize.graph;
373
+ _assertThisInitialize2 = _assertThisInitialized(_this), graph = _assertThisInitialize2.graph;
360
374
  if (!graph) {
361
375
  _context.next = 14;
362
376
  break;
@@ -528,8 +542,8 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
528
542
  }());
529
543
  // 清除选中节点
530
544
  _defineProperty(_assertThisInitialized(_this), "unSelectNode", function () {
531
- var _assertThisInitialize2 = _assertThisInitialized(_this),
532
- graph = _assertThisInitialize2.graph;
545
+ var _assertThisInitialize3 = _assertThisInitialized(_this),
546
+ graph = _assertThisInitialize3.graph;
533
547
  if (graph) {
534
548
  graph.cleanSelection();
535
549
  }
@@ -600,7 +614,7 @@ var ExperimentGraph = /*#__PURE__*/function (_GraphCore) {
600
614
  return _resetGraphData.apply(this, arguments);
601
615
  }
602
616
  return resetGraphData;
603
- }()
617
+ }() // 初始化预览数据
604
618
  }, {
605
619
  key: "initPreviewData",
606
620
  value: function () {
@@ -2,6 +2,8 @@ import { ReactShape } from '@antv/x6-react-shape';
2
2
  import type { Node } from '@antv/x6/src/model/node';
3
3
  import './node-basic.less';
4
4
  export default class BaseNode extends ReactShape {
5
+ methodList: any;
5
6
  constructor(metadata?: Node.Metadata);
7
+ addMethodPorts(methods: any[]): void;
6
8
  isGroup(): boolean;
7
9
  }