coolcare-lite-scada-component 4.1.7 → 4.1.8

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.
@@ -29,6 +29,7 @@ import DialogHistory from "../../../components/DialogHistory";
29
29
  import DialogPointWrite from "../../../components/DialogPointWrite";
30
30
  import ModalFanDevicePoint from "../../../components/ModalFanDevicePoint";
31
31
  import emitter from "../../../utils/events";
32
+ import { createPointDispatcher } from "../../../utils/pointDispatcher";
32
33
  import { GetDeviceIndicator, GetDevicePoint } from "../../../services/gateway/Device";
33
34
  import "./index.css";
34
35
  import { GetTdIndicatorAggregateData, GetTdIndicatorHistoryData } from "../../../services/gateway/Point";
@@ -82,10 +83,16 @@ var getStatisticsTimeRange = function getStatisticsTimeRange() {
82
83
  var Player = function Player(_ref) {
83
84
  var _jsonConfig$pageConfi;
84
85
  var jsonConfig = _ref.jsonConfig,
85
- query = _ref.query,
86
+ queryProp = _ref.query,
86
87
  onEvent = _ref.onEvent,
87
88
  _ref$embedded = _ref.embedded,
88
89
  embedded = _ref$embedded === void 0 ? false : _ref$embedded;
90
+ // Hosts may recreate query objects on unrelated clicks. Only actual parameter
91
+ // changes should recreate the graph, reload cells or restart polling.
92
+ var queryKey = JSON.stringify(queryProp);
93
+ var query = useMemo(function () {
94
+ return JSON.parse(queryKey);
95
+ }, [queryKey]);
89
96
  var graphRef = useRef(null);
90
97
  var wrapRef = useRef(null);
91
98
  var playerRef = useRef(null);
@@ -447,6 +454,11 @@ var Player = function Player(_ref) {
447
454
  modifiers: ['ctrl', 'meta']
448
455
  }
449
456
  });
457
+ var graph = graphRef.current;
458
+ return function () {
459
+ graph.dispose();
460
+ if (graphRef.current === graph) graphRef.current = null;
461
+ };
450
462
  }, [query, mittMeta]);
451
463
  useEffect(function () {
452
464
  var _jsonConfig$pageConfi3, _graphRef$current3;
@@ -473,6 +485,7 @@ var Player = function Player(_ref) {
473
485
 
474
486
  // scene === 'device' 加载设备点位数据
475
487
  useEffect(function () {
488
+ var dispatcher = createPointDispatcher();
476
489
  var fetchDevicePoints = /*#__PURE__*/function () {
477
490
  var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(deviceId) {
478
491
  var res, pointList;
@@ -495,7 +508,7 @@ var Player = function Player(_ref) {
495
508
  pointList = res.data || [];
496
509
  pointList.forEach(function (v) {
497
510
  var identifierName = getInfoFromPointId(v.pointId).identifierName;
498
- emitter.emit("point-update-".concat(identifierName, "-").concat(mittMeta.namespace), v);
511
+ dispatcher.emit("point-update-".concat(identifierName, "-").concat(mittMeta.namespace), v);
499
512
  });
500
513
  case 3:
501
514
  return _context6.a(2);
@@ -514,6 +527,7 @@ var Player = function Player(_ref) {
514
527
  }, RefreshFrequency);
515
528
  }
516
529
  return function () {
530
+ dispatcher.dispose();
517
531
  if (timer) {
518
532
  clearInterval(timer);
519
533
  }
@@ -522,6 +536,7 @@ var Player = function Player(_ref) {
522
536
  useEffect(function () {}, [query, jsonConfig, mittMeta]);
523
537
  // scene === 'freedom' 加载设备点位数据
524
538
  useEffect(function () {
539
+ var dispatcher = createPointDispatcher();
525
540
  var fetchDevicePoints = /*#__PURE__*/function () {
526
541
  var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(ids) {
527
542
  var res, pointList;
@@ -530,7 +545,7 @@ var Player = function Player(_ref) {
530
545
  case 0:
531
546
  _context7.n = 1;
532
547
  return GetDevicePoint({
533
- pointIdList: ids
548
+ pointIdList: _toConsumableArray(new Set(ids.filter(Boolean)))
534
549
  }, []);
535
550
  case 1:
536
551
  res = _context7.v;
@@ -543,7 +558,7 @@ var Player = function Player(_ref) {
543
558
  case 2:
544
559
  pointList = res.data || [];
545
560
  pointList.forEach(function (v) {
546
- emitter.emit("point-update-".concat(v.pointId, "-").concat(mittMeta.namespace), v);
561
+ dispatcher.emit("point-update-".concat(v.pointId, "-").concat(mittMeta.namespace), v);
547
562
  });
548
563
  case 3:
549
564
  return _context7.a(2);
@@ -562,7 +577,7 @@ var Player = function Player(_ref) {
562
577
  case 0:
563
578
  _context8.n = 1;
564
579
  return GetDeviceIndicator({
565
- indicatorNoList: ids,
580
+ indicatorNoList: _toConsumableArray(new Set(ids.filter(Boolean))),
566
581
  isGetIndicatorData: true
567
582
  }, []);
568
583
  case 1:
@@ -576,7 +591,7 @@ var Player = function Player(_ref) {
576
591
  case 2:
577
592
  pointList = res.data || [];
578
593
  pointList.forEach(function (v) {
579
- emitter.emit("point-update-".concat(v.indicatorNo, "-").concat(mittMeta.namespace), v);
594
+ dispatcher.emit("point-update-".concat(v.indicatorNo, "-").concat(mittMeta.namespace), v);
580
595
  });
581
596
  case 3:
582
597
  return _context8.a(2);
@@ -625,7 +640,7 @@ var Player = function Player(_ref) {
625
640
  var pointId = ids.find(function (id) {
626
641
  return id.includes(v.deviceNo);
627
642
  });
628
- emitter.emit("point-update-".concat(pointId, "-").concat(mittMeta.namespace), v);
643
+ dispatcher.emit("point-update-".concat(pointId, "-").concat(mittMeta.namespace), v);
629
644
  });
630
645
  case 3:
631
646
  return _context9.a(2);
@@ -642,10 +657,11 @@ var Player = function Player(_ref) {
642
657
  return _regenerator().w(function (_context0) {
643
658
  while (1) switch (_context0.n) {
644
659
  case 0:
660
+ ids = _toConsumableArray(new Set(ids.filter(Boolean)));
645
661
  _getStatisticsTimeRan2 = getStatisticsTimeRange(dateType), startTime = _getStatisticsTimeRan2.startTime, endTime = _getStatisticsTimeRan2.endTime;
646
662
  _context0.n = 1;
647
663
  return GetTdIndicatorHistoryData({
648
- indicatorNoList: ids,
664
+ indicatorNoList: _toConsumableArray(new Set(ids.filter(Boolean))),
649
665
  timeQuantum: {
650
666
  startDate: dayjs(startTime).format(HISTORY_DATE_TIME_FORMAT),
651
667
  endDate: dayjs(endTime).format(HISTORY_DATE_TIME_FORMAT)
@@ -665,7 +681,7 @@ var Player = function Player(_ref) {
665
681
  pointList.forEach(function (v, index) {
666
682
  var indicatorNo = v.indicatorNo || ids[index];
667
683
  var totalValue = getIndicatorHistoryTotalValue(v.indicatorDataList);
668
- emitter.emit("point-update-".concat(indicatorNo, "-").concat(mittMeta.namespace), _objectSpread(_objectSpread({}, v), {}, {
684
+ dispatcher.emit("point-update-".concat(indicatorNo, "-").concat(mittMeta.namespace), _objectSpread(_objectSpread({}, v), {}, {
669
685
  aggregateDataList: [{
670
686
  val: totalValue,
671
687
  ts: endTime
@@ -695,14 +711,14 @@ var Player = function Player(_ref) {
695
711
  _getStatisticsTimeRan3 = getStatisticsTimeRange(dateType), startTime = _getStatisticsTimeRan3.startTime, endTime = _getStatisticsTimeRan3.endTime;
696
712
  GetEnergyByMeterList({
697
713
  dataType: type,
698
- meterIdList: ids,
714
+ meterIdList: _toConsumableArray(new Set(ids.filter(Boolean))),
699
715
  startDateTime: startTime,
700
716
  endDateTime: endTime,
701
717
  dateType: 2
702
718
  }).then(function (res) {
703
719
  if (res.success) {
704
720
  res.data.forEach(function (item) {
705
- emitter.emit("point-update-".concat(item.id, "-").concat(mittMeta.namespace), item);
721
+ dispatcher.emit("point-update-".concat(item.id, "-").concat(mittMeta.namespace), item);
706
722
  });
707
723
  }
708
724
  });
@@ -842,6 +858,7 @@ var Player = function Player(_ref) {
842
858
  }
843
859
  }
844
860
  return function () {
861
+ dispatcher.dispose();
845
862
  if (pointTimer) {
846
863
  clearInterval(pointTimer);
847
864
  }
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html lang="en" style="overflow: hidden;">
2
+ <html lang="zh-CN" style="overflow: hidden;">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
@@ -15,7 +15,7 @@
15
15
  name="viewport"
16
16
  content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
17
17
  />
18
- <title>组态 CoolCare</title>
18
+ <title>&#x7EC4;&#x6001; CoolCare</title>
19
19
  <link rel="icon" href="https://front-end-assets.oss-cn-shanghai.aliyuncs.com/images/coolcarelitelogo/logo_light3.png" type="image/x-icon" />
20
20
  </head>
21
21
  <body>
@@ -1,7 +1,7 @@
1
- // This file is automatically generated.
2
- // Please do not change this file!
3
- interface CssExports {
4
- 'border-box-ele-item': string;
5
- }
6
- export const cssExports: CssExports;
7
- export default cssExports;
1
+ // This file is automatically generated.
2
+ // Please do not change this file!
3
+ interface CssExports {
4
+ 'border-box-ele-item': string;
5
+ }
6
+ export const cssExports: CssExports;
7
+ export default cssExports;
@@ -1,7 +1,7 @@
1
- // This file is automatically generated.
2
- // Please do not change this file!
3
- interface CssExports {
4
- 'decoration-ele-item': string;
5
- }
6
- export const cssExports: CssExports;
7
- export default cssExports;
1
+ // This file is automatically generated.
2
+ // Please do not change this file!
3
+ interface CssExports {
4
+ 'decoration-ele-item': string;
5
+ }
6
+ export const cssExports: CssExports;
7
+ export default cssExports;
@@ -33,10 +33,10 @@ var DragHandle = SortableHandle(function () {
33
33
  });
34
34
  });
35
35
 
36
- /**
37
- * @param color color
38
- * @param children children
39
- * @param onClick onClick
36
+ /**
37
+ * @param color color
38
+ * @param children children
39
+ * @param onClick onClick
40
40
  */
41
41
 
42
42
  var SortableItem = SortableElement(function (_ref) {
@@ -60,9 +60,9 @@ var PanelLeft = function PanelLeft() {
60
60
  var onChangeTab = function onChangeTab(key) {
61
61
  setTabActiveKey(key);
62
62
  };
63
- /**
64
- * 拖拽开始事件
65
- * @param e
63
+ /**
64
+ * 拖拽开始事件
65
+ * @param e
66
66
  */
67
67
  var handleDragStart = function handleDragStart(e, payload) {
68
68
  try {
@@ -1,7 +1,7 @@
1
- // This file is automatically generated.
2
- // Please do not change this file!
3
- interface CssExports {
4
- 'panel-right': string;
5
- }
6
- export const cssExports: CssExports;
7
- export default cssExports;
1
+ // This file is automatically generated.
2
+ // Please do not change this file!
3
+ interface CssExports {
4
+ 'panel-right': string;
5
+ }
6
+ export const cssExports: CssExports;
7
+ export default cssExports;
@@ -390,7 +390,7 @@ export default (function () {
390
390
  projectId: query.projectId ? Number(query.projectId) : undefined
391
391
  } : undefined);
392
392
  }, [query, fetchUserDeviceList]);
393
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Helmet, null, /*#__PURE__*/React.createElement("title", null, "\u7F02\u4F78\u5AED\u9227?CoolCare")), /*#__PURE__*/React.createElement("div", {
393
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Helmet, null, /*#__PURE__*/React.createElement("title", null, "\u7EC4\u6001 CoolCare")), /*#__PURE__*/React.createElement("div", {
394
394
  className: "".concat(styles.editor)
395
395
  }, /*#__PURE__*/React.createElement("header", {
396
396
  className: styles['header-tools']
@@ -1,15 +1,15 @@
1
- // @ts-ignore
2
- /* eslint-disable */
3
-
4
- declare namespace CommonAPI {
5
- type StringListResponseResult = {
6
- /** 请求是否成功 */
7
- success?: boolean;
8
- /** 响应代码 200 为成功, 非200为失败,Message为失败原因 */
9
- code?: number;
10
- /** 消息 */
11
- message?: string;
12
- /** 返回实体 */
13
- data?: string[];
14
- };
15
- }
1
+ // @ts-ignore
2
+ /* eslint-disable */
3
+
4
+ declare namespace CommonAPI {
5
+ type StringListResponseResult = {
6
+ /** 请求是否成功 */
7
+ success?: boolean;
8
+ /** 响应代码 200 为成功, 非200为失败,Message为失败原因 */
9
+ code?: number;
10
+ /** 消息 */
11
+ message?: string;
12
+ /** 返回实体 */
13
+ data?: string[];
14
+ };
15
+ }