coolcare-lite-scada-component 4.1.4 → 4.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/es/components/DialogImagePicker/Gallery/index.js +7 -2
- package/es/integration/EditorGateway.js +85 -0
- package/es/integration/ThreeScene.js +315 -0
- package/es/integration/legacy-resource-adapter.js +819 -0
- package/es/integration/platform-resources.js +5 -0
- package/es/integration/platform-scenes.js +284 -0
- package/es/integration/platform-session.js +33 -0
- package/es/integration/platform-telemetry.js +436 -0
- package/es/integration/resource-adapter.js +1 -0
- package/es/integration/resource-groups.js +3 -0
- package/es/integration/resource-seed.json +3380 -0
- package/es/integration/scene-format.js +35 -0
- package/es/pages/display/index.js +74 -14
- package/es/pages/editor/PanelLeft/MineImgGroup/index.js +4 -1
- package/es/pages/editor/PanelLeft/SystemImgGroupList/index.js +4 -1
- package/es/pages/editor/PanelTop/Save/index.js +46 -33
- package/es/pages/editor/index.js +59 -35
- package/es/typings.d.ts +224 -223
- package/package.json +8 -5
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
export var SCENE_FORMAT = 'coolcare-scada-3d';
|
|
3
|
+
export var BRIDGE_CHANNEL = 'coolcare-scada-3d-v1';
|
|
4
|
+
export function sceneKind(value) {
|
|
5
|
+
if (value === null || value === undefined || value === '') return 'empty';
|
|
6
|
+
if (_typeof(value) !== 'object' || Array.isArray(value)) throw new Error('组态配置格式无效,已停止加载。');
|
|
7
|
+
var config = value;
|
|
8
|
+
if (config.format === SCENE_FORMAT) {
|
|
9
|
+
if (config.version !== 1 || !config.document || config.document.schemaVersion !== 1 || !Array.isArray(config.document.items) || !Array.isArray(config.document.pipes)) {
|
|
10
|
+
throw new Error('三维场景版本或格式不受支持,已停止加载。');
|
|
11
|
+
}
|
|
12
|
+
return '3d';
|
|
13
|
+
}
|
|
14
|
+
if (config.format || config.schemaVersion) throw new Error('未知组态格式,不能覆盖。');
|
|
15
|
+
return Object.keys(config).length ? 'legacy' : 'empty';
|
|
16
|
+
}
|
|
17
|
+
export function assertWritable(current, previous) {
|
|
18
|
+
if (sceneKind(current) === 'legacy') throw new Error('此记录包含旧二维组态,请新建组态后制作三维场景。');
|
|
19
|
+
if (JSON.stringify(current !== null && current !== void 0 ? current : {}) !== JSON.stringify(previous !== null && previous !== void 0 ? previous : {})) throw new Error('服务器场景已变化,请重新打开后再保存。当前编辑内容可导出备份。');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** 已保存格式优先;URL提示只决定尚未保存格式的空白记录。 */
|
|
23
|
+
export function editorKind(value, hint) {
|
|
24
|
+
var kind = sceneKind(value);
|
|
25
|
+
if (kind === 'legacy') return '2d';
|
|
26
|
+
if (kind === '3d') return '3d';
|
|
27
|
+
if (hint !== undefined && hint !== '' && hint !== '2d' && hint !== '3d') throw new Error('组态编辑器类型无效。');
|
|
28
|
+
return hint === '3d' ? '3d' : '2d';
|
|
29
|
+
}
|
|
30
|
+
export function assertLegacyScene(value) {
|
|
31
|
+
if (sceneKind(value) === '3d') throw new Error('此记录为三维组态,请重新打开三维编辑器,不能用二维覆盖。');
|
|
32
|
+
}
|
|
33
|
+
export function studioUrl(origin, player) {
|
|
34
|
+
return new URL("/scada/studio3d/index.html?embedded=1".concat(player ? '&mode=player' : ''), origin).href;
|
|
35
|
+
}
|
|
@@ -1,3 +1,9 @@
|
|
|
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
|
+
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
|
+
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
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
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); }
|
|
1
7
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
2
8
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
3
9
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
@@ -17,21 +23,25 @@ import { GetDeviceConfiguration } from "../../services/gateway/Device";
|
|
|
17
23
|
import { GetCompanyConfigurationPage } from "../../services/gateway/CompanyConfiguration";
|
|
18
24
|
import { setRequestENV, setRequrl } from "../../services/request";
|
|
19
25
|
import Player from "./Player";
|
|
26
|
+
import ThreeScene from "../../integration/ThreeScene";
|
|
27
|
+
import { sceneKind } from "../../integration/scene-format";
|
|
20
28
|
import ScadaEmpty from "./components/Empty";
|
|
21
29
|
import styles from "./index.css";
|
|
22
|
-
import {
|
|
30
|
+
import { initializePlatformSession } from "../../integration/platform-session";
|
|
23
31
|
var Display = function Display(_ref) {
|
|
24
32
|
var query_ = _ref.query_,
|
|
25
33
|
onEvent = _ref.onEvent;
|
|
26
34
|
var _useState = useState(),
|
|
27
35
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
loaded = _useState2[0],
|
|
37
|
+
setLoaded = _useState2[1];
|
|
30
38
|
var _useState3 = useState(true),
|
|
31
39
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
32
40
|
loading = _useState4[0],
|
|
33
41
|
setLoading = _useState4[1];
|
|
34
42
|
var q = query_ || queryToObject(window.location.href);
|
|
43
|
+
var contextKey = JSON.stringify(q);
|
|
44
|
+
var jsonConfig = (loaded === null || loaded === void 0 ? void 0 : loaded.key) === contextKey ? loaded.config : undefined;
|
|
35
45
|
useEffect(function () {
|
|
36
46
|
if (query_) {
|
|
37
47
|
// 被当成组件使用时(非 iframe ),设置接口请求的 prefix
|
|
@@ -44,10 +54,15 @@ var Display = function Display(_ref) {
|
|
|
44
54
|
// 获取组态配置
|
|
45
55
|
useEffect(function () {
|
|
46
56
|
var query = query_ || queryToObject(window.location.href);
|
|
57
|
+
var active = true;
|
|
58
|
+
var setJsonConfig = function setJsonConfig(config) {
|
|
59
|
+
if (active) setLoaded({
|
|
60
|
+
key: contextKey,
|
|
61
|
+
config: config
|
|
62
|
+
});
|
|
63
|
+
};
|
|
47
64
|
if (!query) return;
|
|
48
|
-
|
|
49
|
-
storeToken(query.token, query.xToken);
|
|
50
|
-
}
|
|
65
|
+
initializePlatformSession(query);
|
|
51
66
|
|
|
52
67
|
// 产品组态
|
|
53
68
|
if (query.scene === 'product') {
|
|
@@ -231,27 +246,72 @@ var Display = function Display(_ref) {
|
|
|
231
246
|
}();
|
|
232
247
|
_fetchDeviceScadaConfig();
|
|
233
248
|
}
|
|
234
|
-
|
|
249
|
+
return function () {
|
|
250
|
+
active = false;
|
|
251
|
+
};
|
|
252
|
+
}, [contextKey]);
|
|
235
253
|
useEffect(function () {
|
|
236
|
-
|
|
254
|
+
var receive = function receive(e) {
|
|
255
|
+
if (e.origin !== window.location.origin || e.source !== window.opener && (window.parent === window || e.source !== window.parent)) return;
|
|
237
256
|
var data = e.data;
|
|
238
|
-
if (data.event === 'product-scada-config-change') {
|
|
257
|
+
if (q.scene === 'product' && (data === null || data === void 0 ? void 0 : data.event) === 'product-scada-config-change' && Number(data.payload.productId) === Number(q.productId) && Number(data.payload.scadaType) === Number(q.scadaType)) {
|
|
239
258
|
try {
|
|
240
|
-
|
|
259
|
+
setLoaded({
|
|
260
|
+
key: contextKey,
|
|
261
|
+
config: JSON.parse(data.payload.data)
|
|
262
|
+
});
|
|
241
263
|
setLoading(false);
|
|
242
264
|
} catch (err) {
|
|
243
265
|
console.error(err);
|
|
244
266
|
}
|
|
245
267
|
}
|
|
246
|
-
}
|
|
247
|
-
|
|
268
|
+
};
|
|
269
|
+
window.addEventListener('message', receive);
|
|
270
|
+
return function () {
|
|
271
|
+
return window.removeEventListener('message', receive);
|
|
272
|
+
};
|
|
273
|
+
}, [contextKey]);
|
|
248
274
|
return /*#__PURE__*/React.createElement("div", {
|
|
249
275
|
className: styles.wrap,
|
|
250
276
|
id: "scada-body"
|
|
251
|
-
}, !!q && /*#__PURE__*/React.createElement(
|
|
252
|
-
|
|
277
|
+
}, !!q && jsonConfig && /*#__PURE__*/React.createElement(ScenePlayerByFormat, {
|
|
278
|
+
config: jsonConfig,
|
|
253
279
|
query: q,
|
|
254
280
|
onEvent: onEvent
|
|
255
281
|
}), !loading && !jsonConfig && /*#__PURE__*/React.createElement(ScadaEmpty, null));
|
|
256
282
|
};
|
|
283
|
+
var ScenePlayerByFormat = function ScenePlayerByFormat(_ref5) {
|
|
284
|
+
var config = _ref5.config,
|
|
285
|
+
query = _ref5.query,
|
|
286
|
+
onEvent = _ref5.onEvent;
|
|
287
|
+
var handleEvent = function handleEvent(event) {
|
|
288
|
+
if (onEvent) {
|
|
289
|
+
onEvent(event);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (window.parent !== window && event.event === 'freedom-scene-switch') {
|
|
293
|
+
var origin = window.location.origin;
|
|
294
|
+
try {
|
|
295
|
+
if (document.referrer) origin = new URL(document.referrer).origin;
|
|
296
|
+
} catch (_unused) {}
|
|
297
|
+
window.parent.postMessage(_objectSpread({
|
|
298
|
+
channel: 'coolcare-scada-player-v1'
|
|
299
|
+
}, event), origin);
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
try {
|
|
303
|
+
return sceneKind(config) === '3d' ? /*#__PURE__*/React.createElement(ThreeScene, {
|
|
304
|
+
config: config,
|
|
305
|
+
query: query
|
|
306
|
+
}) : /*#__PURE__*/React.createElement(Player, {
|
|
307
|
+
jsonConfig: config,
|
|
308
|
+
query: query,
|
|
309
|
+
onEvent: handleEvent
|
|
310
|
+
});
|
|
311
|
+
} catch (error) {
|
|
312
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
313
|
+
role: "alert"
|
|
314
|
+
}, error instanceof Error ? error.message : '无法识别组态格式。');
|
|
315
|
+
}
|
|
316
|
+
};
|
|
257
317
|
export default Display;
|
|
@@ -15,6 +15,7 @@ import { useModel } from 'umi';
|
|
|
15
15
|
import { CaretRightOutlined } from '@ant-design/icons';
|
|
16
16
|
import { GetConfigurationImgGroupPage, AddOrUpdateConfigurationImgGroup } from "../../../../services/product/ConfigurationImgGroup";
|
|
17
17
|
import ImgGroup from "../ImgGroup";
|
|
18
|
+
import { isThreeResourceGroup } from "../../../../integration/resource-groups";
|
|
18
19
|
import GroupManageDialog from "../GroupManageDialog";
|
|
19
20
|
var Panel = Collapse.Panel;
|
|
20
21
|
var MineImgGroup = function MineImgGroup(_ref) {
|
|
@@ -90,7 +91,9 @@ var MineImgGroup = function MineImgGroup(_ref) {
|
|
|
90
91
|
_context2.n = 4;
|
|
91
92
|
break;
|
|
92
93
|
case 3:
|
|
93
|
-
setGroupList((data === null || data === void 0 ? void 0 : data.list) || [])
|
|
94
|
+
setGroupList(((data === null || data === void 0 ? void 0 : data.list) || []).filter(function (group) {
|
|
95
|
+
return !isThreeResourceGroup(group);
|
|
96
|
+
}));
|
|
94
97
|
case 4:
|
|
95
98
|
_context2.n = 6;
|
|
96
99
|
break;
|
|
@@ -14,6 +14,7 @@ import { useModel } from 'umi';
|
|
|
14
14
|
import { Collapse } from 'antd';
|
|
15
15
|
import { CaretRightOutlined } from '@ant-design/icons';
|
|
16
16
|
import { GetConfigurationImgGroupPage } from "../../../../services/product/ConfigurationImgGroup";
|
|
17
|
+
import { isThreeResourceGroup } from "../../../../integration/resource-groups";
|
|
17
18
|
import GroupManageDialog from "../GroupManageDialog";
|
|
18
19
|
import ImgGroup from "../ImgGroup";
|
|
19
20
|
var Panel = Collapse.Panel;
|
|
@@ -55,7 +56,9 @@ var SystemImgGroupList = function SystemImgGroupList(_ref) {
|
|
|
55
56
|
success = _yield$GetConfigurati.success;
|
|
56
57
|
data = _yield$GetConfigurati.data;
|
|
57
58
|
if (success) {
|
|
58
|
-
setGroupList((data === null || data === void 0 ? void 0 : data.list) || [])
|
|
59
|
+
setGroupList(((data === null || data === void 0 ? void 0 : data.list) || []).filter(function (group) {
|
|
60
|
+
return !isThreeResourceGroup(group);
|
|
61
|
+
}));
|
|
59
62
|
}
|
|
60
63
|
_context.n = 3;
|
|
61
64
|
break;
|
|
@@ -21,6 +21,8 @@ import { useState } from 'react';
|
|
|
21
21
|
import { useModel } from 'umi';
|
|
22
22
|
import { EditDeviceConfiguration } from "../../../../services/gateway/Device";
|
|
23
23
|
import { AddOrUpdateCompanyConfiguration } from "../../../../services/gateway/CompanyConfiguration";
|
|
24
|
+
import { readPlatformScene } from "../../../../integration/platform-scenes";
|
|
25
|
+
import { assertLegacyScene } from "../../../../integration/scene-format";
|
|
24
26
|
import { useQuery } from "../../../../hooks";
|
|
25
27
|
import { buildScadaConfigChangePayload, buildScadaConfigSnapshot, captureScadaScreenshot, getCurrentOperatorId, getScadaConfigSnapshotFromStorage, setScadaConfigSnapshotToStorage } from "../../utils/scadaChangeLog";
|
|
26
28
|
var Save = function Save(_ref) {
|
|
@@ -76,13 +78,19 @@ var Save = function Save(_ref) {
|
|
|
76
78
|
}();
|
|
77
79
|
var handleSave = /*#__PURE__*/function () {
|
|
78
80
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
79
|
-
var _yield$buildSaveConfi, config, configChangeLog, configHasChanged, operationUserId, graphSnapshot, _window, _window$opener, payload, _window$opener2, res, msg, _payload, _res, _payload2, _t4, _t5;
|
|
81
|
+
var _yield$buildSaveConfi, config, configChangeLog, configHasChanged, operationUserId, graphSnapshot, _window, _window$opener, payload, _window$opener2, res, msg, _payload, _res, _payload2, _t4, _t5, _t6;
|
|
80
82
|
return _regenerator().w(function (_context2) {
|
|
81
83
|
while (1) switch (_context2.p = _context2.n) {
|
|
82
84
|
case 0:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
if (!loading) {
|
|
86
|
+
_context2.n = 1;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
return _context2.a(2);
|
|
85
90
|
case 1:
|
|
91
|
+
_context2.n = 2;
|
|
92
|
+
return buildSaveConfigPayload();
|
|
93
|
+
case 2:
|
|
86
94
|
_yield$buildSaveConfi = _context2.v;
|
|
87
95
|
config = _yield$buildSaveConfi.config;
|
|
88
96
|
configChangeLog = _yield$buildSaveConfi.configChangeLog;
|
|
@@ -113,12 +121,12 @@ var Save = function Save(_ref) {
|
|
|
113
121
|
});
|
|
114
122
|
}
|
|
115
123
|
if (!(query.scene === 'device')) {
|
|
116
|
-
_context2.n =
|
|
124
|
+
_context2.n = 8;
|
|
117
125
|
break;
|
|
118
126
|
}
|
|
119
|
-
_context2.p =
|
|
127
|
+
_context2.p = 3;
|
|
120
128
|
setLoading(true);
|
|
121
|
-
_context2.n =
|
|
129
|
+
_context2.n = 4;
|
|
122
130
|
return EditDeviceConfiguration({
|
|
123
131
|
deviceId: Number(query.deviceId),
|
|
124
132
|
config: config,
|
|
@@ -127,15 +135,15 @@ var Save = function Save(_ref) {
|
|
|
127
135
|
configHasChanged: configHasChanged,
|
|
128
136
|
deviceConfigurationType: Number(query.scadaType)
|
|
129
137
|
});
|
|
130
|
-
case
|
|
138
|
+
case 4:
|
|
131
139
|
res = _context2.v;
|
|
132
140
|
if (res.success) {
|
|
133
|
-
_context2.n =
|
|
141
|
+
_context2.n = 5;
|
|
134
142
|
break;
|
|
135
143
|
}
|
|
136
144
|
message.error('Update failed');
|
|
137
145
|
return _context2.a(2);
|
|
138
|
-
case
|
|
146
|
+
case 5:
|
|
139
147
|
message.success('Update success');
|
|
140
148
|
msg = {
|
|
141
149
|
event: 'device-scada-config-change',
|
|
@@ -150,25 +158,30 @@ var Save = function Save(_ref) {
|
|
|
150
158
|
setInitialScadaConfigSnapshot(_payload);
|
|
151
159
|
setScadaConfigSnapshotToStorage(query, graphSnapshot);
|
|
152
160
|
(_window$opener2 = window.opener) === null || _window$opener2 === void 0 ? void 0 : _window$opener2.postMessage(msg, '*');
|
|
153
|
-
_context2.n =
|
|
161
|
+
_context2.n = 7;
|
|
154
162
|
break;
|
|
155
|
-
case
|
|
156
|
-
_context2.p =
|
|
163
|
+
case 6:
|
|
164
|
+
_context2.p = 6;
|
|
157
165
|
_t4 = _context2.v;
|
|
158
166
|
console.error(_t4);
|
|
159
167
|
message.error('Update failed');
|
|
160
|
-
case 6:
|
|
161
|
-
_context2.p = 6;
|
|
162
|
-
setLoading(false);
|
|
163
|
-
return _context2.f(6);
|
|
164
168
|
case 7:
|
|
169
|
+
_context2.p = 7;
|
|
170
|
+
setLoading(false);
|
|
171
|
+
return _context2.f(7);
|
|
172
|
+
case 8:
|
|
165
173
|
if (!(query.scene === 'freedom')) {
|
|
166
|
-
_context2.n =
|
|
174
|
+
_context2.n = 15;
|
|
167
175
|
break;
|
|
168
176
|
}
|
|
169
177
|
setLoading(true);
|
|
170
|
-
_context2.p =
|
|
171
|
-
|
|
178
|
+
_context2.p = 9;
|
|
179
|
+
_t5 = assertLegacyScene;
|
|
180
|
+
_context2.n = 10;
|
|
181
|
+
return readPlatformScene(query);
|
|
182
|
+
case 10:
|
|
183
|
+
_t5(_context2.v.config);
|
|
184
|
+
_context2.n = 11;
|
|
172
185
|
return AddOrUpdateCompanyConfiguration({
|
|
173
186
|
companyId: Number(query.companyId),
|
|
174
187
|
companyConfigurationId: Number(query.scadaId),
|
|
@@ -180,34 +193,34 @@ var Save = function Save(_ref) {
|
|
|
180
193
|
configChangeLog: configChangeLog,
|
|
181
194
|
configHasChanged: configHasChanged
|
|
182
195
|
});
|
|
183
|
-
case
|
|
196
|
+
case 11:
|
|
184
197
|
_res = _context2.v;
|
|
185
198
|
if (_res.success) {
|
|
186
|
-
_context2.n =
|
|
199
|
+
_context2.n = 12;
|
|
187
200
|
break;
|
|
188
201
|
}
|
|
189
202
|
message.error('Update failed');
|
|
190
203
|
return _context2.a(2);
|
|
191
|
-
case
|
|
204
|
+
case 12:
|
|
192
205
|
message.success('Update success');
|
|
193
206
|
_payload2 = JSON.stringify(graphSnapshot);
|
|
194
207
|
setInitialScadaConfigSnapshot(_payload2);
|
|
195
208
|
setScadaConfigSnapshotToStorage(query, graphSnapshot);
|
|
196
|
-
_context2.n =
|
|
209
|
+
_context2.n = 14;
|
|
197
210
|
break;
|
|
198
|
-
case 11:
|
|
199
|
-
_context2.p = 11;
|
|
200
|
-
_t5 = _context2.v;
|
|
201
|
-
console.error(_t5);
|
|
202
|
-
message.error('Update failed');
|
|
203
|
-
case 12:
|
|
204
|
-
_context2.p = 12;
|
|
205
|
-
setLoading(false);
|
|
206
|
-
return _context2.f(12);
|
|
207
211
|
case 13:
|
|
212
|
+
_context2.p = 13;
|
|
213
|
+
_t6 = _context2.v;
|
|
214
|
+
console.error(_t6);
|
|
215
|
+
message.error(_t6 instanceof Error ? _t6.message : 'Update failed');
|
|
216
|
+
case 14:
|
|
217
|
+
_context2.p = 14;
|
|
218
|
+
setLoading(false);
|
|
219
|
+
return _context2.f(14);
|
|
220
|
+
case 15:
|
|
208
221
|
return _context2.a(2);
|
|
209
222
|
}
|
|
210
|
-
}, _callee2, null, [[
|
|
223
|
+
}, _callee2, null, [[9, 13, 14, 15], [3, 6, 7, 8]]);
|
|
211
224
|
}));
|
|
212
225
|
return function handleSave() {
|
|
213
226
|
return _ref3.apply(this, arguments);
|
package/es/pages/editor/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { GetCompanyConfigurationPage } from "../../services/gateway/CompanyConfi
|
|
|
11
11
|
import { useQuery } from "../../hooks";
|
|
12
12
|
import GraphCore from "../../graph/graphCore";
|
|
13
13
|
import { defaultDeviceMobileSize, defaultDevicePCSize } from "../../constant";
|
|
14
|
+
import { assertLegacyScene } from "../../integration/scene-format";
|
|
14
15
|
import { buildScadaConfigSnapshot, captureScadaScreenshot, setScadaConfigSnapshotToStorage } from "./utils/scadaChangeLog";
|
|
15
16
|
import Palette from "./Palette";
|
|
16
17
|
import PanelTop from "./PanelTop";
|
|
@@ -25,6 +26,8 @@ import "../../element/register";
|
|
|
25
26
|
// 濞夈劌鍞介懛顏勭暰娑?edge
|
|
26
27
|
import "../../edge/register";
|
|
27
28
|
export default (function () {
|
|
29
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
30
|
+
initialConfig = _ref.initialConfig;
|
|
28
31
|
var paletteWrapRef = useRef(null);
|
|
29
32
|
var query = useQuery();
|
|
30
33
|
var _useModel = useModel('useEditor', function (model) {
|
|
@@ -42,7 +45,7 @@ export default (function () {
|
|
|
42
45
|
fetchUserDeviceList = _useModel.fetchUserDeviceList,
|
|
43
46
|
setInitialScadaConfigSnapshot = _useModel.setInitialScadaConfigSnapshot;
|
|
44
47
|
var cacheScadaConfig = useCallback(/*#__PURE__*/function () {
|
|
45
|
-
var
|
|
48
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(pageConfigValue) {
|
|
46
49
|
var _graphCoreRef$current;
|
|
47
50
|
var graph, snapshot, _t, _t2, _t3;
|
|
48
51
|
return _regenerator().w(function (_context) {
|
|
@@ -64,7 +67,7 @@ export default (function () {
|
|
|
64
67
|
}, _callee);
|
|
65
68
|
}));
|
|
66
69
|
return function (_x) {
|
|
67
|
-
return
|
|
70
|
+
return _ref2.apply(this, arguments);
|
|
68
71
|
};
|
|
69
72
|
}(), [graphCoreRef, query, setInitialScadaConfigSnapshot]);
|
|
70
73
|
useEffect(function () {
|
|
@@ -75,7 +78,7 @@ export default (function () {
|
|
|
75
78
|
}, []);
|
|
76
79
|
useEffect(function () {
|
|
77
80
|
var handler = /*#__PURE__*/function () {
|
|
78
|
-
var
|
|
81
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e) {
|
|
79
82
|
var _graphCoreRef$current2;
|
|
80
83
|
var graph, data, configJSON, _graphCoreRef$current3, width, height, initialPageConfig;
|
|
81
84
|
return _regenerator().w(function (_context2) {
|
|
@@ -92,6 +95,7 @@ export default (function () {
|
|
|
92
95
|
break;
|
|
93
96
|
}
|
|
94
97
|
configJSON = JSON.parse(data.payload || '{}');
|
|
98
|
+
assertLegacyScene(configJSON);
|
|
95
99
|
graph === null || graph === void 0 ? void 0 : graph.fromJSON(configJSON);
|
|
96
100
|
// 缂傗晜鏂侀悽璇茬閸愬懎顔愰敍灞煎▏閻㈣绔烽崘鍛啇閸忓懏寮х憴鍡楀經
|
|
97
101
|
graph === null || graph === void 0 ? void 0 : graph.zoomToFit({
|
|
@@ -125,7 +129,7 @@ export default (function () {
|
|
|
125
129
|
}, _callee2);
|
|
126
130
|
}));
|
|
127
131
|
return function handler(_x2) {
|
|
128
|
-
return
|
|
132
|
+
return _ref3.apply(this, arguments);
|
|
129
133
|
};
|
|
130
134
|
}();
|
|
131
135
|
window.addEventListener('message', handler);
|
|
@@ -159,7 +163,7 @@ export default (function () {
|
|
|
159
163
|
}
|
|
160
164
|
if (query.scene === 'device') {
|
|
161
165
|
var fetchDeviceScadaConfig = /*#__PURE__*/function () {
|
|
162
|
-
var
|
|
166
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
163
167
|
var hideMsg, _yield$GetDeviceConfi, success, data, activeScada, configJSON, width, height, initialPageConfig, _t4;
|
|
164
168
|
return _regenerator().w(function (_context3) {
|
|
165
169
|
while (1) switch (_context3.p = _context3.n) {
|
|
@@ -190,6 +194,7 @@ export default (function () {
|
|
|
190
194
|
break;
|
|
191
195
|
}
|
|
192
196
|
configJSON = JSON.parse(activeScada.config || '{}');
|
|
197
|
+
assertLegacyScene(configJSON);
|
|
193
198
|
graphCore.graph.fromJSON(configJSON);
|
|
194
199
|
if (configJSON.pageConfig) {
|
|
195
200
|
setPageConfig(configJSON.pageConfig);
|
|
@@ -237,43 +242,62 @@ export default (function () {
|
|
|
237
242
|
}, _callee3, null, [[1, 7, 8, 9]]);
|
|
238
243
|
}));
|
|
239
244
|
return function fetchDeviceScadaConfig() {
|
|
240
|
-
return
|
|
245
|
+
return _ref4.apply(this, arguments);
|
|
241
246
|
};
|
|
242
247
|
}();
|
|
243
248
|
fetchDeviceScadaConfig();
|
|
244
249
|
}
|
|
245
250
|
if (query.scene === 'freedom') {
|
|
246
251
|
var fetchScadaConfig = /*#__PURE__*/function () {
|
|
247
|
-
var
|
|
248
|
-
var hideMsg, _data$list,
|
|
252
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
253
|
+
var hideMsg, _data$list, _ref6, success, data, scadaConfig, _configJSON$cells, configJSON, width, height, initialPageConfig, _t5, _t6;
|
|
249
254
|
return _regenerator().w(function (_context4) {
|
|
250
255
|
while (1) switch (_context4.p = _context4.n) {
|
|
251
256
|
case 0:
|
|
252
257
|
hideMsg = message.loading('Loading scada config');
|
|
253
258
|
_context4.p = 1;
|
|
254
|
-
|
|
259
|
+
if (!(initialConfig !== undefined)) {
|
|
260
|
+
_context4.n = 2;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
_t5 = {
|
|
264
|
+
success: true,
|
|
265
|
+
data: {
|
|
266
|
+
list: [{
|
|
267
|
+
config: JSON.stringify(initialConfig)
|
|
268
|
+
}]
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
_context4.n = 4;
|
|
272
|
+
break;
|
|
273
|
+
case 2:
|
|
274
|
+
_context4.n = 3;
|
|
255
275
|
return GetCompanyConfigurationPage({
|
|
256
276
|
companyConfigurationId: Number(query.scadaId),
|
|
257
277
|
isGetConfig: true,
|
|
258
278
|
companyId: Number(query.companyId)
|
|
259
279
|
});
|
|
260
|
-
case
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
280
|
+
case 3:
|
|
281
|
+
_t5 = _context4.v;
|
|
282
|
+
case 4:
|
|
283
|
+
_ref6 = _t5;
|
|
284
|
+
success = _ref6.success;
|
|
285
|
+
data = _ref6.data;
|
|
264
286
|
if (!(!success || !(data === null || data === void 0 ? void 0 : (_data$list = data.list) === null || _data$list === void 0 ? void 0 : _data$list.length))) {
|
|
265
|
-
_context4.n =
|
|
287
|
+
_context4.n = 5;
|
|
266
288
|
break;
|
|
267
289
|
}
|
|
268
290
|
message.error('Load configuration failed');
|
|
269
291
|
return _context4.a(2);
|
|
270
|
-
case
|
|
292
|
+
case 5:
|
|
271
293
|
scadaConfig = data.list[0].config;
|
|
272
294
|
if (!scadaConfig) {
|
|
273
|
-
_context4.n =
|
|
295
|
+
_context4.n = 7;
|
|
274
296
|
break;
|
|
275
297
|
}
|
|
276
|
-
configJSON = JSON.parse(scadaConfig || '{}');
|
|
298
|
+
configJSON = JSON.parse(scadaConfig || '{}');
|
|
299
|
+
assertLegacyScene(configJSON);
|
|
300
|
+
// 娣囶喖顦查崥搴n伂娣囨繂鐡ㄩ弫鐗堝祦閺冭绱濋崶鐖卻on閺佺増宓佺粔宥呯摠閸?%"閼板苯顕遍懛瀵告畱"%"閺佺増宓佹稉銏犮亼闂傤噣顣?
|
|
277
301
|
if (configJSON === null || configJSON === void 0 ? void 0 : (_configJSON$cells = configJSON.cells) === null || _configJSON$cells === void 0 ? void 0 : _configJSON$cells.length) {
|
|
278
302
|
configJSON === null || configJSON === void 0 ? void 0 : configJSON.cells.forEach(function (item) {
|
|
279
303
|
var _item$attrs, _item$attrs$body, _item$attrs2, _item$attrs2$body, _item$attrs2$body$ref, _item$attrs3, _item$attrs3$body, _item$attrs5, _item$attrs5$body, _item$attrs6, _item$attrs6$body, _item$attrs6$body$ref, _item$attrs7, _item$attrs7$body;
|
|
@@ -297,12 +321,12 @@ export default (function () {
|
|
|
297
321
|
// 鏉堢绐?
|
|
298
322
|
preserveAspectRatio: true // 閺勵垰鎯佹穱婵囧瘮闂€鍨啍濮f柣鈧?
|
|
299
323
|
});
|
|
300
|
-
_context4.n = 4;
|
|
301
|
-
return cacheScadaConfig(configJSON.pageConfig || {});
|
|
302
|
-
case 4:
|
|
303
324
|
_context4.n = 6;
|
|
325
|
+
return cacheScadaConfig(configJSON.pageConfig || {});
|
|
326
|
+
case 6:
|
|
327
|
+
_context4.n = 8;
|
|
304
328
|
break;
|
|
305
|
-
case
|
|
329
|
+
case 7:
|
|
306
330
|
width = 1366;
|
|
307
331
|
height = 768;
|
|
308
332
|
initialPageConfig = {
|
|
@@ -314,32 +338,32 @@ export default (function () {
|
|
|
314
338
|
};
|
|
315
339
|
setPageConfig(initialPageConfig);
|
|
316
340
|
graphCore.initScadaContainer(width, height);
|
|
317
|
-
_context4.n = 6;
|
|
318
|
-
return cacheScadaConfig(initialPageConfig);
|
|
319
|
-
case 6:
|
|
320
341
|
_context4.n = 8;
|
|
342
|
+
return cacheScadaConfig(initialPageConfig);
|
|
343
|
+
case 8:
|
|
344
|
+
_context4.n = 10;
|
|
321
345
|
break;
|
|
322
|
-
case
|
|
323
|
-
_context4.p =
|
|
324
|
-
|
|
325
|
-
console.error(
|
|
346
|
+
case 9:
|
|
347
|
+
_context4.p = 9;
|
|
348
|
+
_t6 = _context4.v;
|
|
349
|
+
console.error(_t6);
|
|
326
350
|
message.error('Load configuration failed');
|
|
327
|
-
case
|
|
328
|
-
_context4.p =
|
|
351
|
+
case 10:
|
|
352
|
+
_context4.p = 10;
|
|
329
353
|
hideMsg();
|
|
330
|
-
return _context4.f(
|
|
331
|
-
case
|
|
354
|
+
return _context4.f(10);
|
|
355
|
+
case 11:
|
|
332
356
|
return _context4.a(2);
|
|
333
357
|
}
|
|
334
|
-
}, _callee4, null, [[1,
|
|
358
|
+
}, _callee4, null, [[1, 9, 10, 11]]);
|
|
335
359
|
}));
|
|
336
360
|
return function fetchScadaConfig() {
|
|
337
|
-
return
|
|
361
|
+
return _ref5.apply(this, arguments);
|
|
338
362
|
};
|
|
339
363
|
}();
|
|
340
364
|
fetchScadaConfig();
|
|
341
365
|
}
|
|
342
|
-
}, [cacheScadaConfig, graphCoreRef, query, setPageConfig]);
|
|
366
|
+
}, [cacheScadaConfig, graphCoreRef, query, setPageConfig, initialConfig]);
|
|
343
367
|
useEffect(function () {
|
|
344
368
|
if (process.env.NODE_ENV === 'production') {
|
|
345
369
|
window.onbeforeunload = function (e) {
|