dcim-topology2d 1.1.6 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. package/activity-diagram/src/final/final.d.ts +1 -1
  2. package/activity-diagram/src/final/final.rect.d.ts +1 -1
  3. package/activity-diagram/src/final/final.rect.js +1 -1
  4. package/activity-diagram/src/fork/fork.anchor.d.ts +1 -1
  5. package/activity-diagram/src/fork/fork.anchor.js +1 -1
  6. package/activity-diagram/src/fork/fork.d.ts +1 -1
  7. package/activity-diagram/src/fork/fork.rect.d.ts +1 -1
  8. package/activity-diagram/src/fork/fork.rect.js +1 -1
  9. package/activity-diagram/src/register.js +1 -1
  10. package/activity-diagram/src/swimlaneH/swimlaneH.d.ts +1 -1
  11. package/activity-diagram/src/swimlaneH/swimlaneH.rect.d.ts +1 -1
  12. package/activity-diagram/src/swimlaneH/swimlaneH.rect.js +1 -1
  13. package/activity-diagram/src/swimlaneV/swimlaneV.d.ts +1 -1
  14. package/activity-diagram/src/swimlaneV/swimlaneV.rect.d.ts +1 -1
  15. package/activity-diagram/src/swimlaneV/swimlaneV.rect.js +1 -1
  16. package/chart-diagram/index.d.ts +0 -2
  17. package/chart-diagram/index.js +0 -1
  18. package/chart-diagram/src/echarts/index.d.ts +2 -1
  19. package/chart-diagram/src/echarts/index.js +104 -106
  20. package/chart-diagram/src/register.js +8 -9
  21. package/class-diagram/src/class/class.d.ts +1 -1
  22. package/class-diagram/src/class/class.rect.d.ts +1 -1
  23. package/class-diagram/src/class/class.rect.js +1 -1
  24. package/class-diagram/src/register.js +1 -1
  25. package/core/index.d.ts +0 -1
  26. package/core/index.js +0 -1
  27. package/core/src/activeLayer.d.ts +10 -2
  28. package/core/src/activeLayer.js +41 -42
  29. package/core/src/animateLayer.d.ts +7 -3
  30. package/core/src/animateLayer.js +12 -10
  31. package/core/src/calling.d.ts +4 -1
  32. package/core/src/calling.js +41 -43
  33. package/core/src/canvas.d.ts +6 -1
  34. package/core/src/canvas.js +18 -17
  35. package/core/src/common.d.ts +5 -5
  36. package/core/src/common.js +202 -172
  37. package/core/src/core.d.ts +4 -3
  38. package/core/src/core.js +321 -339
  39. package/core/src/divLayer.d.ts +33 -2
  40. package/core/src/divLayer.js +292 -41
  41. package/core/src/healps/changeData.d.ts +1 -1
  42. package/core/src/healps/changeData.js +44 -102
  43. package/core/src/hoverLayer.d.ts +9 -2
  44. package/core/src/hoverLayer.js +34 -31
  45. package/core/src/middles/default.d.ts +3 -1
  46. package/core/src/middles/default.js +51 -51
  47. package/core/src/middles/index.js +2 -3
  48. package/core/src/middles/nodes/pentagon.rect.js +1 -1
  49. package/core/src/middles/nodes/rectangle.rect.js +1 -1
  50. package/core/src/models/data.d.ts +26 -0
  51. package/core/src/models/data.js +77 -0
  52. package/core/src/models/data.js.map +1 -0
  53. package/core/src/models/index.d.ts +1 -0
  54. package/core/src/models/index.js +1 -0
  55. package/core/src/models/node.d.ts +0 -6
  56. package/core/src/models/node.js +16 -29
  57. package/core/src/models/pen.js +7 -16
  58. package/core/src/mqtt.d.ts +14 -0
  59. package/core/src/mqtt.js +82 -0
  60. package/core/src/mqtt.js.map +1 -0
  61. package/core/src/offscreen.d.ts +4 -1
  62. package/core/src/offscreen.js +8 -10
  63. package/core/src/options.js +0 -1
  64. package/core/src/poll.js +2 -0
  65. package/core/src/preview.d.ts +13 -1
  66. package/core/src/preview.js +34 -56
  67. package/core/src/renderLayer.d.ts +3 -1
  68. package/core/src/renderLayer.js +31 -26
  69. package/core/src/socket.d.ts +10 -0
  70. package/core/src/socket.js +51 -0
  71. package/core/src/socket.js.map +1 -0
  72. package/core/src/utils/canvas.js +1 -1
  73. package/core/src/utils/conversion.d.ts +0 -7
  74. package/core/src/utils/conversion.js +0 -54
  75. package/core/src/utils/dom.d.ts +5 -6
  76. package/core/src/utils/dom.js +46 -82
  77. package/core/src/utils/index.d.ts +0 -1
  78. package/core/src/utils/index.js +0 -1
  79. package/core/src/utils/onmousevent.js +3 -12
  80. package/flow-diagram/src/comment/comment.anchor.d.ts +1 -1
  81. package/flow-diagram/src/comment/comment.anchor.js +1 -1
  82. package/flow-diagram/src/comment/comment.d.ts +1 -1
  83. package/flow-diagram/src/data/data.anchor.d.ts +1 -1
  84. package/flow-diagram/src/data/data.anchor.js +1 -1
  85. package/flow-diagram/src/data/data.d.ts +1 -1
  86. package/flow-diagram/src/data/data.rect.d.ts +1 -1
  87. package/flow-diagram/src/data/data.rect.js +1 -1
  88. package/flow-diagram/src/db/db.d.ts +1 -1
  89. package/flow-diagram/src/db/db.rect.d.ts +1 -1
  90. package/flow-diagram/src/db/db.rect.js +1 -1
  91. package/flow-diagram/src/display/display.anchor.d.ts +1 -1
  92. package/flow-diagram/src/display/display.anchor.js +1 -1
  93. package/flow-diagram/src/display/display.d.ts +1 -1
  94. package/flow-diagram/src/display/display.rect.d.ts +1 -1
  95. package/flow-diagram/src/display/display.rect.js +1 -1
  96. package/flow-diagram/src/document/document.anchor.d.ts +1 -1
  97. package/flow-diagram/src/document/document.anchor.js +1 -1
  98. package/flow-diagram/src/document/document.d.ts +1 -1
  99. package/flow-diagram/src/document/document.rect.d.ts +1 -1
  100. package/flow-diagram/src/document/document.rect.js +1 -1
  101. package/flow-diagram/src/externStorage/externStorage.anchor.d.ts +1 -1
  102. package/flow-diagram/src/externStorage/externStorage.anchor.js +1 -1
  103. package/flow-diagram/src/externStorage/externStorage.d.ts +1 -1
  104. package/flow-diagram/src/externStorage/externStorage.rect.d.ts +1 -1
  105. package/flow-diagram/src/externStorage/externStorage.rect.js +1 -1
  106. package/flow-diagram/src/internalStorage/internalStorage.d.ts +1 -1
  107. package/flow-diagram/src/internalStorage/internalStorage.rect.d.ts +1 -1
  108. package/flow-diagram/src/internalStorage/internalStorage.rect.js +1 -1
  109. package/flow-diagram/src/manually/manually.anchor.d.ts +1 -1
  110. package/flow-diagram/src/manually/manually.anchor.js +1 -1
  111. package/flow-diagram/src/manually/manually.d.ts +1 -1
  112. package/flow-diagram/src/manually/manually.rect.d.ts +1 -1
  113. package/flow-diagram/src/manually/manually.rect.js +1 -1
  114. package/flow-diagram/src/parallel/parallel.anchor.d.ts +1 -1
  115. package/flow-diagram/src/parallel/parallel.anchor.js +1 -1
  116. package/flow-diagram/src/parallel/parallel.d.ts +1 -1
  117. package/flow-diagram/src/queue/queue.d.ts +1 -1
  118. package/flow-diagram/src/queue/queue.rect.d.ts +1 -1
  119. package/flow-diagram/src/queue/queue.rect.js +1 -1
  120. package/flow-diagram/src/register.js +1 -1
  121. package/flow-diagram/src/subprocess/subprocess.d.ts +1 -1
  122. package/flow-diagram/src/subprocess/subprocess.rect.d.ts +1 -1
  123. package/flow-diagram/src/subprocess/subprocess.rect.js +1 -1
  124. package/layout/src/align.d.ts +1 -1
  125. package/layout/src/align.js +1 -1
  126. package/layout/src/layout.d.ts +1 -1
  127. package/layout/src/layout.js +1 -1
  128. package/myShape-diagram/myShape.js +1 -1
  129. package/package.json +1 -1
  130. package/sequence-diagram/src/focus/focus.anchor.d.ts +1 -1
  131. package/sequence-diagram/src/focus/focus.anchor.js +1 -1
  132. package/sequence-diagram/src/focus/focus.d.ts +1 -1
  133. package/sequence-diagram/src/focus/focus.rect.d.ts +1 -1
  134. package/sequence-diagram/src/focus/focus.rect.js +1 -1
  135. package/sequence-diagram/src/lifeline/lifeline.anchor.d.ts +1 -1
  136. package/sequence-diagram/src/lifeline/lifeline.anchor.js +1 -1
  137. package/sequence-diagram/src/lifeline/lifeline.d.ts +1 -1
  138. package/sequence-diagram/src/lifeline/lifeline.rect.d.ts +1 -1
  139. package/sequence-diagram/src/lifeline/lifeline.rect.js +1 -1
  140. package/sequence-diagram/src/register.js +1 -1
  141. package/chart-diagram/src/utils/changeOptions.d.ts +0 -4
  142. package/chart-diagram/src/utils/changeOptions.js +0 -163
  143. package/chart-diagram/src/utils/conversion.d.ts +0 -17
  144. package/chart-diagram/src/utils/conversion.js +0 -179
  145. package/chart-diagram/src/utils/drawGraphic.d.ts +0 -3
  146. package/chart-diagram/src/utils/drawGraphic.js +0 -97
  147. package/chart-diagram/src/utils/index.d.ts +0 -3
  148. package/chart-diagram/src/utils/index.js +0 -3
  149. package/core/src/middles/arrows/index.d.ts +0 -4
  150. package/core/src/middles/arrows/index.js +0 -5
  151. package/core/src/middles/lines/index.d.ts +0 -4
  152. package/core/src/middles/lines/index.js +0 -5
  153. package/core/src/middles/nodes/iframe.d.ts +0 -2
  154. package/core/src/middles/nodes/iframe.js +0 -12
  155. package/core/src/middles/nodes/index.d.ts +0 -46
  156. package/core/src/middles/nodes/index.js +0 -47
  157. package/core/src/store/common.d.ts +0 -9
  158. package/core/src/store/common.js +0 -5
  159. package/core/src/store/data.d.ts +0 -129
  160. package/core/src/store/data.js +0 -86
  161. package/core/src/store/index.d.ts +0 -2
  162. package/core/src/store/index.js +0 -2
  163. package/core/src/utils/assignment.d.ts +0 -3
  164. package/core/src/utils/assignment.js +0 -69
  165. package/static/echartsDefaultData.js +0 -239
  166. package/static/echartsStore.js +0 -14
  167. package/static/index.js +0 -2
  168. package/style/index.css +0 -13
@@ -3,14 +3,14 @@ import {DivLayer} from './divLayer';
3
3
  import {AnimateLayer} from './animateLayer';
4
4
  import {RenderLayer} from './renderLayer';
5
5
  import {Offscreen} from './offscreen';
6
- import {Line, Node, Point} from './models';
7
- import {setConfItemNode, setStatisticalData} from './healps';
8
- import {s8, formatPadding, getRect, setInitNodeDataValidat, setDefaultNodeValidat} from './utils';
9
- import { useStore, clearStore, syncMqttData } from './store'
6
+ import {Socket} from './socket';
7
+ import {Line, Node, Pen, Point, TopologyData, EventAction} from './models';
8
+ import {setConfItemNode} from './healps';
9
+ import {s8, formatPadding, getRect, previewType} from './utils';
10
+ import {DefalutOptions} from './options';
10
11
  import {POLL} from './poll';
11
12
  import axios from 'axios';
12
13
  import * as mqtt from './mqtt.min';
13
- import { destroyEcharts } from "../../static";
14
14
 
15
15
  var MoveInType;
16
16
  (function (MoveInType) {
@@ -29,33 +29,28 @@ var Common = /** @class */ (function () {
29
29
  function Common(parent, options) {
30
30
  var _this = this;
31
31
  _this.moveInType = MoveInType;
32
- this.mqttDataSouse = axios.CancelToken.source();
33
32
  this.mouseDown = null;
34
- this.renderTimer = 0;
35
- this.lastRender = 0;
36
- this.id = s8();
37
- this.store = useStore(this.id);
38
33
  if (typeof parent === 'string') {
39
- this.store.parentElem = document.getElementById(parent);
34
+ this.parentElem = document.getElementById(parent);
40
35
  } else {
41
- this.store.parentElem = parent;
36
+ this.parentElem = parent;
42
37
  }
43
38
  if (!options) {
44
39
  options = {};
45
40
  }
46
- this.store.parentElem.style.position = 'relative';
47
- this.store.parentElem.style.overflow = 'auto';
48
- //var font = Object.assign({}, DefalutOptions.font, options.font);
49
- //options.font = font;
50
- // this.options = Object.assign({}, DefalutOptions, options);
51
- Object.assign(this.store.options, options);
52
- this.store.options.interval = 50;
53
- //Store.set(this.generateStoreKey('topology-data'), this.data);
41
+ this.parentElem.style.position = 'relative';
42
+ this.parentElem.style.overflow = 'auto';
43
+ var font = Object.assign({}, DefalutOptions.font, options.font);
44
+ options.font = font;
45
+ this.options = Object.assign({}, DefalutOptions, options);
46
+ this.data = new TopologyData();
47
+ this.id = s8();
48
+ Store.set(this.generateStoreKey('topology-data'), this.data);
54
49
  var id = this.id;
55
- this.animateLayer = new AnimateLayer(id);
56
- this.offscreen = new Offscreen(id);
57
- this.canvas = new RenderLayer(id);
58
- this.divLayer = new DivLayer(id);
50
+ this.animateLayer = new AnimateLayer(this.options, id);
51
+ this.offscreen = new Offscreen(this.parentElem, this.options, id);
52
+ this.canvas = new RenderLayer(this.parentElem, this.options, id);
53
+ this.divLayer = new DivLayer(this.parentElem, this.options, id);
59
54
  this.divLayer.canvas.tabIndex = 0;
60
55
  this.divLayer.canvas.ondblclick = this.ondblclick;
61
56
  this.divLayer.canvas.onblur = function () {
@@ -114,6 +109,7 @@ var Common = /** @class */ (function () {
114
109
  };
115
110
  this.openCount = 0;
116
111
  this.timmerByTopology = null;
112
+ this.ratioCord = null;
117
113
  this.lastTranlated = {x: 0, y: 0};
118
114
  this.moveIn = {
119
115
  type: 'None',
@@ -140,6 +136,7 @@ var Common = /** @class */ (function () {
140
136
  this.tip = '';
141
137
  this.rendering = false;
142
138
  this.isFullScreen = false;
139
+ this.socket = null;
143
140
  this.inputObj = null;
144
141
  this.input = document.createElement('textarea');
145
142
  this.input.style.position = 'absolute';
@@ -150,11 +147,11 @@ var Common = /** @class */ (function () {
150
147
  this.input.style.outline = 'none';
151
148
  this.input.style.border = '1px solid #cdcdcd';
152
149
  this.input.style.resize = 'none';
153
- this.store.parentElem.appendChild(this.input);
150
+ this.parentElem.appendChild(this.input);
154
151
  this.paginationPageListBox = document.createElement('ul');
155
152
  this.pagenationPageInput = document.createElement('input');
156
153
  this.tablePaginationPageStyle();
157
- this.store.parentElem.appendChild(this.paginationPageListBox);
154
+ this.parentElem.appendChild(this.paginationPageListBox);
158
155
  // 列表数据选取
159
156
  this.paginationPageListNode = function (ev) {
160
157
  const node = _this.moveIn.activeNode;
@@ -177,63 +174,61 @@ var Common = /** @class */ (function () {
177
174
  window.topology = this;
178
175
  }
179
176
 
180
- Common.prototype.conversionData = function (obj, type) {
181
- this.clear();
177
+ Common.prototype.conversionData = function (obj) {
178
+ this.parentElem.scrollLeft = 0;
179
+ this.parentElem.scrollTop = 0;
180
+ this.canvas.clearBkImg();
181
+ this.divLayer.clear();
182
182
  let data = JSON.parse(JSON.stringify(obj));
183
183
  if (!data) {
184
184
  data = {pens: []};
185
185
  }
186
- Object.assign(this.store.data, data);
187
- this.store.data.pens = [];
186
+ Object.assign(this.data, data);
187
+ this.setBKImageRect();
188
+ this.ratioCord = {
189
+ ratio: 1,
190
+ scaleX: 1,
191
+ scaleY: 1
192
+ };
188
193
  this.openCount = 0
194
+ this.data.pens = [];
189
195
  // for old data.
190
196
  if (data.nodes) {
191
197
  for (var _i = 0, _a = data.nodes; _i < _a.length; _i++) {
192
- setInitNodeDataValidat(_a[_i], this.id);
193
- const item = new Node(_a[_i]);
194
- this.store.data.pens.push(item);
195
- this.store.pens[item.id] = item;
198
+ var item = new Node(_a[_i]);
199
+ this.data.pens.push(item);
196
200
  this.setSwitchTabData(item, _i);
197
- // 初始化图表数据
198
- if (item.name === 'echarts' && item.data && type !== 'mqtt') {
199
- item.data.echarts.option = setStatisticalData(item, 'def');
200
- }
201
201
  }
202
202
  for (var _b = 0, _c = data.lines; _b < _c.length; _b++) {
203
- _c[_b].TID = this.id;
204
- const item = new Line(_c[_b]);
205
- this.store.data.pens.push(item);
206
- this.store.pens[item.id] = item;
203
+ var item = _c[_b];
204
+ this.data.pens.push(new Line(item));
207
205
  }
208
206
  }
209
207
  // end.
210
208
  if (data.pens) {
211
209
  for (var _d = 0, _e = data.pens; _d < _e.length; _d++) {
212
- const item = _e[_d];
210
+ var item = _e[_d];
213
211
  if (!item.from) {
214
- setInitNodeDataValidat(item, this.id);
215
- const node = new Node(item);
216
- this.store.data.pens.push(node);
217
- this.store.pens[item.id] = node;
212
+ var node = new Node(item);
213
+ this.data.pens.push(node);
218
214
  this.setSwitchTabData(node, _d);
219
- // 初始化图表数据
220
- if (node.name === 'echarts' && node.data && type !== 'mqtt') {
221
- node.data.echarts.option = setStatisticalData(node, 'def');
222
- }
223
215
  } else {
224
- const linNode = new Line(item);
225
- this.store.data.pens.push(linNode);
226
- this.store.pens[item.id] = linNode;
216
+ this.data.pens.push(new Line(item));
227
217
  }
228
218
  }
229
219
  }
230
220
  };
231
- Common.prototype.clear = function (del){
232
- clearStore(this.store, del);
233
- this.canvas.clearBkImg();
234
- this.divLayer.clear();
235
- this.store.parentElem.scrollLeft = 0;
236
- this.store.parentElem.scrollTop = 0;
221
+ Common.prototype.setBKImageRect = function () {
222
+ if (this.data.bkImageRect) {
223
+ this.data.bkImageRect.x = this.data.bkImageRect.x ? Number(this.data.bkImageRect.x) : 0;
224
+ this.data.bkImageRect.y = this.data.bkImageRect.y ? Number(this.data.bkImageRect.y) : 0;
225
+ this.data.bkImageRect.width = this.data.bkImageRect.width ? Number(this.data.bkImageRect.width) : this.canvas.width;
226
+ this.data.bkImageRect.height = this.data.bkImageRect.height ? Number(this.data.bkImageRect.height) : this.canvas.height;
227
+ this.data.bkImageRect.center = {
228
+ x: this.data.bkImageRect.x + this.data.bkImageRect.width / 2,
229
+ y: this.data.bkImageRect.y + this.data.bkImageRect.height / 2
230
+ }
231
+ }
237
232
  };
238
233
  Common.prototype.setSwitchTabData = function (node, index, type) {
239
234
  if (type) {
@@ -267,40 +262,20 @@ var Common = /** @class */ (function () {
267
262
  }
268
263
  };
269
264
  Common.prototype.canvasResize = function (size) {
270
- try {
271
- this.canvas.resize(size);
272
- //this.canvas.bkImgRectResize(size);
273
- this.offscreen.resize(size);
274
- this.divLayer.resize(size);
275
- }catch (err) {
276
- //console.log('resize-----', err)
277
- }
265
+ this.canvas.resize(size);
266
+ //this.canvas.bkImgRectResize(size);
267
+ this.offscreen.resize(size);
268
+ this.divLayer.resize(size);
278
269
  };
279
270
  // Render or redraw
280
271
  Common.prototype.render = function (noFocus) {
281
- try {
282
- const _this = this;
283
- const now = performance.now();
284
- if (now - _this.lastRender < _this.store.options.interval && !noFocus) {
285
- if (_this.renderTimer) {
286
- cancelAnimationFrame(_this.renderTimer);
287
- }
288
- _this.renderTimer = requestAnimationFrame(_this.render);
289
-
290
- return;
291
- }
292
- this.renderTimer = 0;
293
- this.lastRender = now;
294
- if (this.rendering) {
295
- return this;
296
- }
297
- this.rendering = true;
298
- this.offscreen.render();
299
- this.canvas.render();
300
- this.rendering = false;
301
- }catch (e) {
302
- //console.log(e)
272
+ if (this.rendering) {
273
+ return this;
303
274
  }
275
+ this.rendering = true;
276
+ this.offscreen.render();
277
+ this.canvas.render();
278
+ this.rendering = false;
304
279
  };
305
280
  Common.prototype.generateStoreKey = function (key) {
306
281
  return this.id + "-" + key;
@@ -383,7 +358,7 @@ var Common = /** @class */ (function () {
383
358
  this.pagenationPageInput.style.left = node.paginationData.targetPageLocal.x + 'px';
384
359
  this.pagenationPageInput.style.top = node.paginationData.targetPageLocal.y + 'px';
385
360
  this.pagenationPageInput.style.height = node.rect.height + 'px';
386
- this.store.parentElem.appendChild(this.pagenationPageInput);
361
+ this.parentElem.appendChild(this.pagenationPageInput);
387
362
  };
388
363
  // 展开分页列表
389
364
  Common.prototype.spreadPageListHandle = function (node, e) {
@@ -451,8 +426,8 @@ var Common = /** @class */ (function () {
451
426
  // 如果存在按钮组节点数据
452
427
  if (changeNode[node.id]) {
453
428
  for (let switchNode of Object.values(changeNode)) {
454
- if (this.store.data.pens[switchNode.tagOrder]) {
455
- this.store.data.pens[switchNode.tagOrder].activeImgeIndex = switchNode.id !== node.id;
429
+ if (this.data.pens[switchNode.tagOrder]) {
430
+ this.data.pens[switchNode.tagOrder].activeImgeIndex = switchNode.id !== node.id;
456
431
  }
457
432
  }
458
433
  }
@@ -471,32 +446,31 @@ var Common = /** @class */ (function () {
471
446
  Common.prototype.s8 = function () {
472
447
  return s8()
473
448
  };
474
- // Common.prototype.openSocket = function (url) {
475
- // this.closeSocket();
476
- // if (url || this.store.data.websocket) {
477
- // this.socket = new Socket(url || this.store.data.websocket, this.store.data);
478
- // }
479
- // };
480
- // Common.prototype.closeSocket = function () {
481
- // if (this.socket) {
482
- // this.socket.close();
483
- // }
484
- // };
449
+ Common.prototype.openSocket = function (url) {
450
+ this.closeSocket();
451
+ if (url || this.data.websocket) {
452
+ this.socket = new Socket(url || this.data.websocket, this.data);
453
+ }
454
+ };
455
+ Common.prototype.closeSocket = function () {
456
+ if (this.socket) {
457
+ this.socket.close();
458
+ }
459
+ };
485
460
  Common.prototype.openMqtt = function (url, options) {
486
461
  this.closeMqtt();
487
- if (url || this.store.data.mqttUrl) {
488
- url = url || this.store.data.mqttUrl;
489
- const mqttTopics = this.initData && this.initData.mqttTopics ? this.initData.mqttTopics : this.store.data.mqttTopics;
490
- options = options || this.store.data.mqttOptions
462
+ if (url || this.data.mqttUrl) {
463
+ url = url || this.data.mqttUrl;
464
+ const mqttTopics = this.initData && this.initData.mqttTopics ? this.initData.mqttTopics : this.data.mqttTopics;
465
+ options = options || this.data.mqttOptions
491
466
  let topics = mqttTopics
492
467
  this.isEnd = false;
493
468
  // let num = 0; // 记录推送的次数,用于判单丢失情况
494
- //console.log('mqtt.connect======', url)
495
469
  this.mqttClient = mqtt.connect(url, options);
496
470
  var _this = this;
497
471
  this.mqttClient.on('message', function (topic, message) {
498
472
  //console.log('openMqtt11===================', topic, message)
499
- if (!_this.store.data.pens.length || !topic || topic != _this.store.data.mqttTopics) {
473
+ if (!_this.data.pens.length || !topic || topic != _this.data.mqttTopics) {
500
474
  return;
501
475
  }
502
476
  if (!this.isEnd) {
@@ -510,7 +484,7 @@ var Common = /** @class */ (function () {
510
484
  };
511
485
  Common.prototype.openPoll = function (message, val) {
512
486
  if (message) {
513
- this.poll = new POLL(this.store.data, message, val);
487
+ this.poll = new POLL(this.data, message, val);
514
488
  }
515
489
  };
516
490
  Common.prototype.clearInterValAll = function () {
@@ -538,10 +512,10 @@ var Common = /** @class */ (function () {
538
512
  this.inputObj = null;
539
513
  };
540
514
  Common.prototype.showInput = function (item) {
541
- if (this.store.data.locked ||
515
+ if (this.data.locked ||
542
516
  item.locked ||
543
517
  item.hideInput ||
544
- this.store.options.hideInput) {
518
+ this.options.hideInput) {
545
519
  return;
546
520
  }
547
521
  this.inputObj = item;
@@ -560,9 +534,9 @@ var Common = /** @class */ (function () {
560
534
  this.input.focus();
561
535
  };
562
536
  Common.prototype.getRect = function (pens) {
563
- if (!this.store || !this.store.data) return;
537
+ if (!this.data) return;
564
538
  if (!pens) {
565
- pens = this.store.data.pens;
539
+ pens = this.data.pens;
566
540
  }
567
541
  return getRect(pens);
568
542
  };
@@ -580,7 +554,7 @@ var Common = /** @class */ (function () {
580
554
  }
581
555
  var offsetX = x - this.lastTranlated.x;
582
556
  var offsetY = y - this.lastTranlated.y;
583
- for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
557
+ for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
584
558
  var item = _a[_i];
585
559
  item.translate(offsetX, offsetY);
586
560
  }
@@ -599,7 +573,7 @@ var Common = /** @class */ (function () {
599
573
  var viewCenter = this.getViewCenter(padding);
600
574
  var center = rect.center;
601
575
  this.translate(viewCenter.x - center.x, viewCenter.y - center.y);
602
- var parentElem = this.store.parentElem;
576
+ var parentElem = this.canvas.parentElem;
603
577
  var x = (parentElem.scrollWidth - parentElem.offsetWidth) / 2;
604
578
  var y = (parentElem.scrollHeight - parentElem.offsetHeight) / 2;
605
579
  parentElem.scrollTo(x, y);
@@ -610,7 +584,7 @@ var Common = /** @class */ (function () {
610
584
  return !(rect.width === 99999 || rect.height === 99999);
611
585
  };
612
586
  Common.prototype.getViewCenter = function (viewPadding) {
613
- var padding = formatPadding(viewPadding || this.store.options.viewPadding);
587
+ var padding = formatPadding(viewPadding || this.options.viewPadding);
614
588
  var _a = this.canvas, width = _a.width, height = _a.height;
615
589
  return {
616
590
  x: (width - padding[1] - padding[3]) / 2 + padding[3],
@@ -674,7 +648,7 @@ var Common = /** @class */ (function () {
674
648
  }
675
649
  var tipMarkdownMarginLeft = count * 3 + 11
676
650
 
677
- var parentRect = this.store.parentElem.getBoundingClientRect();
651
+ var parentRect = this.parentElem.getBoundingClientRect();
678
652
  var elemRect = elem.getBoundingClientRect();
679
653
  var x = parentRect.left + dataRect.x;
680
654
  var y = pos.y + parentRect.top;
@@ -682,8 +656,8 @@ var Common = /** @class */ (function () {
682
656
  x = x + dataRect.width / 2 - tipMarkdownMarginLeft
683
657
  y = parentRect.top + dataRect.ey - dataRect.height - 46
684
658
  }
685
- x -= this.store.parentElem.scrollLeft;
686
- y -= this.store.parentElem.scrollTop;
659
+ x -= this.parentElem.scrollLeft;
660
+ y -= this.parentElem.scrollTop;
687
661
  if (x < 0) {
688
662
  x = 0;
689
663
  }
@@ -715,11 +689,10 @@ var Common = /** @class */ (function () {
715
689
  this.tip = '';
716
690
  };
717
691
  Common.prototype.dispatch = function (event, data) {
718
- if(!this.store || !this.store.options) return;
719
- if (this.store.options.on) {
720
- this.store.options.on(event, data);
692
+ if (this.options.on) {
693
+ this.options.on(event, data);
721
694
  }
722
- if (event === 'node' && data.name == 'tablePagination' && this.store.options.type !== 'topology') {
695
+ if (event === 'node' && data.name == 'tablePagination' && this.options.type !== 'topology') {
723
696
  const tableNodes = Store.get('FORM:tableData').data.tableNodes[data.paginationData.bindFromTableId];
724
697
  const pageSize = data.paginationData.pageSize;
725
698
  const offset = (parseInt(data.paginationData.pageNumber) - 1) * pageSize;
@@ -745,7 +718,7 @@ var Common = /** @class */ (function () {
745
718
  }
746
719
  this.initType = type
747
720
  this.initData = data
748
- const canvasData = data ? data : this.store.data
721
+ const canvasData = data ? data : this.data
749
722
  //this.topologyDetailData = initData
750
723
  const url = canvasData.mqttUrl
751
724
  // if(url && url.indexOf('://') > -1){
@@ -785,7 +758,7 @@ var Common = /** @class */ (function () {
785
758
  };
786
759
  Common.prototype.initTagParams = async function (eventType) {
787
760
  this.clearTagParams(eventType)
788
- const pensData = this.store.data.pens
761
+ const pensData = this.data.pens
789
762
  let tagParams = this.getTagParams(pensData, eventType);
790
763
  // 详情页面,即URL配置了资产id的页面
791
764
  let assetId = this.getUrlParams('assetId')
@@ -799,7 +772,7 @@ var Common = /** @class */ (function () {
799
772
  if (this.assetPoperties) {
800
773
  // 更新画布上固定的资产详情对应的值
801
774
  //const canvasPens = this.pathRewrite ? canvasData.pens : this.canvas.data.pens
802
- this.renderForAssetPoperties(pensData);
775
+ this.renderForAssetPoperties(this.canvas.data.pens);
803
776
  }
804
777
  }
805
778
  };
@@ -873,18 +846,18 @@ var Common = /** @class */ (function () {
873
846
  }
874
847
  };
875
848
  Common.prototype.getMqttData = async function (tagParams, panelData) {
876
- let ret = null;
849
+ let ret = {};
877
850
  let data = {};
878
851
  let path = '';
879
852
  let assetData = null;
880
853
  let pathRewrite = this.pathRewrite;
881
- let canvasData = this.store.data;
882
- let mqttTopics = this.store.data.mqttTopics;
854
+ let canvasData = JSON.parse(JSON.stringify(this.canvas.data));
855
+ let mqttTopics = this.data.mqttTopics;
883
856
  let tagParamsData = tagParams;
884
857
  let detailJson = null;
885
858
  Store.set('TIMEOUT:currentPage', `locationPath${this.s8()}`);
886
859
  if (panelData) {
887
- this.store.data.mqttTopics = mqttTopics
860
+ this.data.mqttTopics = mqttTopics
888
861
  pathRewrite = panelData.pathRewrite;
889
862
  canvasData = JSON.parse(JSON.stringify(panelData.data));
890
863
  mqttTopics = panelData.mqttTopics;
@@ -920,24 +893,10 @@ var Common = /** @class */ (function () {
920
893
  this.theData = data
921
894
  }
922
895
  let drawedData = null
923
- data.cancelToken = this.mqttDataSouse.token;
924
- ret = await axios.post(path, data).catch(function(th) {
925
- if(axios.isCancel(th)) {
926
- console.log('请求取消了----', th.message);
927
- } else {
928
- console.log('请求失败----')
929
- }
930
- });
896
+ ret = await axios.post(path, data);
931
897
  if (ret.data && ret.data.data) {
932
- if (assetData) ret.data.data.asset = assetData;
933
- drawedData = ret.data.data;
934
- if(panelData) {
935
- syncMqttData.data = drawedData; // 初始化调用
936
- Store.set('mqtt:responseData', drawedData);
937
- }else {
938
- syncMqttData.data = null;
939
- this.mqttDataDrawing(canvasData, drawedData);
940
- }
898
+ if (assetData) ret.data.data.asset = assetData
899
+ drawedData = this.mqttDataDrawing(canvasData, ret.data.data, detailJson)
941
900
  }
942
901
  this.clearInterValAll();
943
902
  this.timmerByTopology = setTimeout(() => {
@@ -951,29 +910,103 @@ var Common = /** @class */ (function () {
951
910
  } else {
952
911
  return {
953
912
  mqttData: drawedData,
954
- // detailData: detailJson
913
+ detailData: detailJson
955
914
  }
956
915
  }
957
916
  };
958
917
  Common.prototype.mqttDataDrawing = function (data, retData, detailJson) {
959
918
  const syncData = retData
960
- //const detailData = detailJson ? detailJson.data : [];
919
+ const detailData = detailJson ? detailJson.data : [];
961
920
  // console.log('收到消息', syncData)
962
921
  Store.set('mqtt:responseData', syncData);
963
922
  data.pens.map((item) => {
964
- if (item.children && item.children.length) {
923
+ if (item.children != undefined) {
965
924
  item.children.map((_item) => {
966
- setDefaultNodeValidat(_item, syncData);
925
+ item.defaultFillStyle = item.fillStyle;
926
+ item.defaultFontColor = item.font.color;
927
+ if (item.name === 'line') item.defaultLineColor = item.strokeStyle;
928
+ if (!_item.data) return
929
+ //const node = detailData.length > 0 ? detailData : syncData
930
+ const functionData = _item.events.filter((ev) => {
931
+ return ev.action === EventAction.Function
932
+ })
933
+ const dataValue = functionData[0]
934
+ if (functionData.length > 0 && dataValue.value && retData) {
935
+ _item.data.map((d) => {
936
+ const {kpiData, tagData} = retData;
937
+ const key = d.key;
938
+ const value = d.value;
939
+ const _syncItem = key === 'tagId' ? tagData[value] : kpiData[value];
940
+ if ((key === 'tagId' || key === 'kpiAddr') && _syncItem) {
941
+ const isControl = parseInt(_syncItem.isControlDis); // 是否可控,0可控,1不可控
942
+ if (!isControl) {
943
+ d.tagVal = value
944
+ d.controlParams = _syncItem
945
+ // delete _syncItem[value]
946
+ // Object.assign(d, _syncItem)
947
+ }
948
+ }
949
+ })
950
+ //console.log('定制函数=====')
951
+ console.log('定制函数------')
952
+ const func = new Function('pen', 'params', dataValue.value)
953
+ func(_item, JSON.stringify(retData))
954
+ } else {
955
+ // console.log('默认函数')
956
+ setConfItemNode(_item, syncData);
957
+ }
958
+ this.machAnimateReset(item);
967
959
  })
968
960
  } else {
969
- setDefaultNodeValidat(item, syncData);
961
+ item.defaultFillStyle = item.fillStyle;
962
+ item.defaultFontColor = item.font.color;
963
+ if (item.name === 'line') item.defaultLineColor = item.strokeStyle;
964
+ if (!item.data) return
965
+ //const node = detailData.length > 0 ? detailData : syncData
966
+ const functionData = item.events.filter((ev) => {
967
+ return ev.action === EventAction.Function
968
+ })
969
+ const dataValue = functionData[0]
970
+ if (functionData.length > 0 && dataValue.value && retData) {
971
+ item.data.map((d) => {
972
+ const {kpiData, tagData} = retData;
973
+ const key = d.key;
974
+ const value = d.value;
975
+ const _syncItem = key === 'tagId' ? tagData[value] : kpiData[value];
976
+ if ((key === 'tagId' || key === 'kpiAddr') && _syncItem) {
977
+ const isControl = parseInt(_syncItem.isControlDis); // 是否可控,0可控,1不可控
978
+ if (!isControl) {
979
+ d.tagVal = value;
980
+ d.controlParams = _syncItem;
981
+ // delete _syncItem[value]
982
+ // Object.assign(d, _syncItem)
983
+ }
984
+ }
985
+ });
986
+ const func = new Function('pen', 'params', dataValue.value);
987
+ func(item, JSON.stringify(retData));
988
+ //const machData = func(item, JSON.stringify(retData));
989
+ console.log('定制函数------------');
990
+ } else {
991
+ // console.log('默认函数')
992
+ setConfItemNode(item, syncData);
993
+ }
994
+ this.machAnimateReset(item);
970
995
  }
971
996
  })
972
- //console.log('执行完毕-----', this.store.data.pens)
997
+ // console.log('执行完毕')
973
998
  this.render();
974
999
  this.animate(true);
975
1000
  return data
976
1001
  };
1002
+ Common.prototype.machAnimateReset = function (pen) {
1003
+ if (!pen.animateFrames || pen.animateFrames.length <= 0) return;
1004
+ for (var _a = 0, _af = pen.animateFrames; _a < _af.length; _a++) {
1005
+ var ani = _af[_a];
1006
+ ani.state.strokeStyle = pen.strokeStyle;
1007
+ ani.state.fillStyle = pen.fillStyle;
1008
+ }
1009
+ };
977
1010
  Common.prototype.getTagParamsForKpiAddrs = async function (assetId, tagParams, apiStr) {
978
1011
  let params = {
979
1012
  assetId: assetId,
@@ -1036,11 +1069,11 @@ var Common = /** @class */ (function () {
1036
1069
  }
1037
1070
  };
1038
1071
  Common.prototype.onMqttContent = async function (tagParams) {
1039
- if (!this.initType) this.store.data.mqttTopics = 'mqtt-' + s8();
1072
+ if (!this.initType) this.data.mqttTopics = 'mqtt-' + s8();
1040
1073
  // 告知MQTT属性中数据的集合
1041
1074
  const ret = !this.initType ? await this.getMqttData(tagParams) : this.initType;
1042
1075
  if (ret) {
1043
- let mqttUrlStr = this.store.data.mqttUrl, mqttOption = this.store.data.mqttOptions
1076
+ let mqttUrlStr = this.data.mqttUrl, mqttOption = this.data.mqttOptions
1044
1077
  if (this.initData) {
1045
1078
  const {mqttUrl, mqttOptions} = this.initData
1046
1079
  mqttUrlStr = mqttUrl
@@ -1056,8 +1089,8 @@ var Common = /** @class */ (function () {
1056
1089
  const index = eventType[4] ? eventType[4] : ''
1057
1090
  // const url = 'pollUrl'+index;
1058
1091
  // const second = 'pollSecond'+index;
1059
- const pollUrl = this.store.data['pollUrl' + index]
1060
- const pollSecond = this.store.data['pollSecond' + index]
1092
+ const pollUrl = this.data['pollUrl' + index]
1093
+ const pollSecond = this.data['pollSecond' + index]
1061
1094
  this.onpollStop(eventType);
1062
1095
  if (pollUrl && pollSecond) {
1063
1096
  this.renderForPoll(tagParams, pollUrl, eventType);
@@ -1104,9 +1137,10 @@ var Common = /** @class */ (function () {
1104
1137
  this.getMqttData(this.tagParams.Mqtt);
1105
1138
  };
1106
1139
  Common.prototype.doMqttDrow = function (ret) {
1107
- let canvasData = this.store.data;
1140
+ let canvasData = this.canvas.data;
1108
1141
  ret = JSON.parse(ret);
1109
- //console.log('处理消息', ret)
1142
+ // console.log('处理消息')
1143
+ // console.log('this.canvas.data',this.canvas.data)
1110
1144
  this.mqttDataDrawing(canvasData, ret)
1111
1145
  };
1112
1146
  Common.prototype.hidePenByTag = function (pens, val) {
@@ -1121,11 +1155,11 @@ var Common = /** @class */ (function () {
1121
1155
  Common.prototype.hidePenVal = function (pen, val) {
1122
1156
  const tags = pen.tags
1123
1157
  const obj = val ? JSON.parse(val) : {}
1124
- const visibleRange = obj.visibleRange ? obj.visibleRange.trim() : ''
1125
- const visibleFnRange = obj.visibleFnRange ? obj.visibleFnRange.trim() : ''
1126
- const visibleValue = obj.visibleValue ? obj.visibleValue.trim() : ''
1127
- const hiddenRange = obj.hiddenRange ? obj.hiddenRange.trim() : ''
1128
- const tabsValue = obj.tabsValue ? obj.tabsValue.trim() : ''
1158
+ const visibleRange = obj.visibleRange
1159
+ const visibleFnRange = obj.visibleFnRange
1160
+ const visibleValue = obj.visibleValue
1161
+ const hiddenRange = obj.hiddenRange
1162
+ const tabsValue = obj.tabsValue
1129
1163
  if (tags.length > 0) {
1130
1164
  if (visibleRange == '1') {
1131
1165
  if (this.openCount % 2 == 0) {
@@ -1166,13 +1200,10 @@ var Common = /** @class */ (function () {
1166
1200
  this.render();
1167
1201
  };
1168
1202
  Common.prototype.destroyStatic = function () {
1169
- this.mqttDataSouse.cancel();
1170
- this.clear('destroy');
1171
1203
  this.clearInterValAll();
1172
- //this.closeSocket();
1204
+ this.closeSocket();
1173
1205
  this.closeMqtt();
1174
1206
  this.closePoll();
1175
- cancelAnimationFrame(this.renderTimer);
1176
1207
  this.subcribe.unsubscribe();
1177
1208
  this.subcribeRender.unsubscribe();
1178
1209
  this.subcribeImage.unsubscribe();
@@ -1186,8 +1217,7 @@ var Common = /** @class */ (function () {
1186
1217
  this.canvas = null;
1187
1218
  this.offscreen.destroy();
1188
1219
  this.offscreen = null;
1189
- this.store.parentElem = null;
1190
- destroyEcharts();
1220
+ this.data = null;
1191
1221
  Store.set('form:tableData', null);
1192
1222
  Store.set('TIMEOUT:currentPage', `empty${this.s8()}`);
1193
1223
  Store.set('FORM:tableData', {