@iobroker/adapter-react-v5 0.0.2 → 0.1.0

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.
@@ -13,6 +13,10 @@ var _copyToClipboard = _interopRequireDefault(require("./copy-to-clipboard"));
13
13
 
14
14
  var _withStyles = _interopRequireDefault(require("@mui/styles/withStyles"));
15
15
 
16
+ var _styles = require("@mui/material/styles");
17
+
18
+ var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
19
+
16
20
  var _reactInlinesvg = _interopRequireDefault(require("react-inlinesvg"));
17
21
 
18
22
  var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
@@ -119,6 +123,10 @@ var _LooksOne = _interopRequireDefault(require("@mui/icons-material/LooksOne"));
119
123
 
120
124
  var _RoomService = _interopRequireDefault(require("@mui/icons-material/RoomService"));
121
125
 
126
+ var _Error = _interopRequireDefault(require("@mui/icons-material/Error"));
127
+
128
+ var _WifiOff = _interopRequireDefault(require("@mui/icons-material/WifiOff"));
129
+
122
130
  var _IconExpert = _interopRequireDefault(require("../icons/IconExpert"));
123
131
 
124
132
  var _IconAdapter = _interopRequireDefault(require("../icons/IconAdapter"));
@@ -163,18 +171,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
163
171
 
164
172
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
165
173
 
166
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
167
-
168
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
169
-
170
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
171
-
172
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
173
-
174
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
175
-
176
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
177
-
178
174
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
179
175
 
180
176
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -205,12 +201,37 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
205
201
 
206
202
  function _extends() { _extends = Object.assign || 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); }
207
203
 
208
- // FIXME checkout https://mui.com/components/use-media-query/#migrating-from-withwidth
204
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
205
+
206
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
207
+
208
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
209
+
210
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
211
+
212
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
213
+
214
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
215
+
216
+ function useWidth() {
217
+ var theme = (0, _styles.useTheme)();
218
+
219
+ var keys = _toConsumableArray(theme.breakpoints.keys).reverse();
220
+
221
+ return keys.reduce(function (output, key) {
222
+ // eslint-disable-next-line react-hooks/rules-of-hooks
223
+ var matches = (0, _useMediaQuery["default"])(theme.breakpoints.up(key));
224
+ return !output && matches ? key : output;
225
+ }, null) || 'xs';
226
+ } // FIXME checkout https://mui.com/components/use-media-query/#migrating-from-withwidth
227
+
228
+
209
229
  var withWidth = function withWidth() {
210
230
  return function (WrappedComponent) {
211
231
  return function (props) {
232
+ var width = useWidth();
212
233
  return /*#__PURE__*/_react["default"].createElement(WrappedComponent, _extends({}, props, {
213
- width: "xs"
234
+ width: width
214
235
  }));
215
236
  };
216
237
  };
@@ -222,6 +243,12 @@ var ITEM_LEVEL = 16;
222
243
  var SMALL_BUTTON_SIZE = 20;
223
244
  var COLOR_NAME_SYSTEM = '#ff6d69';
224
245
  var COLOR_NAME_SYSTEM_ADAPTER = '#5773ff';
246
+ var COLOR_NAME_ERROR_DARK = '#ff413c';
247
+ var COLOR_NAME_ERROR_LIGHT = '#86211f';
248
+ var COLOR_NAME_CONNECTED_DARK = '#57ff45';
249
+ var COLOR_NAME_CONNECTED_LIGHT = '#098c04';
250
+ var COLOR_NAME_DISCONNECTED_DARK = '#f3ad11';
251
+ var COLOR_NAME_DISCONNECTED_LIGHT = '#6c5008';
225
252
 
226
253
  var styles = function styles(theme) {
227
254
  return {
@@ -318,7 +345,7 @@ var styles = function styles(theme) {
318
345
  paddingTop: 0,
319
346
  //theme.spacing(1),
320
347
  paddingLeft: 0,
321
- width: "calc(100% - ".concat(theme.spacing(1), ")"),
348
+ width: "calc(100% - ".concat(theme.spacing(1), "px)"),
322
349
  height: "calc(100% - 38px)",
323
350
  overflow: 'auto'
324
351
  },
@@ -330,7 +357,7 @@ var styles = function styles(theme) {
330
357
  userSelect: 'none',
331
358
  width: '100%',
332
359
  '&:hover': {
333
- background: "".concat(theme.palette.primary.main, " !important"),
360
+ background: "".concat(theme.palette.mode === 'dark' ? theme.palette.primary.dark : theme.palette.primary.light, " !important"),
334
361
  color: _Utils["default"].invertColor(theme.palette.primary.main, true)
335
362
  },
336
363
  whiteSpace: 'nowrap',
@@ -431,7 +458,14 @@ var styles = function styles(theme) {
431
458
  fontSize: 14,
432
459
  marginLeft: 5,
433
460
  overflow: 'hidden',
434
- textOverflow: 'ellipsis'
461
+ textOverflow: 'ellipsis',
462
+ position: 'relative',
463
+ '& .copyButton': {
464
+ display: 'none'
465
+ },
466
+ '&:hover .copyButton': {
467
+ display: 'block'
468
+ }
435
469
  },
436
470
  cellIdAlias: {
437
471
  fontStyle: 'italic',
@@ -523,6 +557,9 @@ var styles = function styles(theme) {
523
557
  display: 'block'
524
558
  }
525
559
  },
560
+ cellValueFile: {
561
+ color: '#2837b9'
562
+ },
526
563
  cellValueTooltipTitle: {
527
564
  fontStyle: 'italic',
528
565
  width: 100,
@@ -642,7 +679,7 @@ var styles = function styles(theme) {
642
679
  opacity: 0.5
643
680
  },
644
681
  itemSelected: {
645
- background: "".concat(theme.palette.mode === 'dark' ? theme.palette.primary.light : theme.palette.primary.dark, " !important"),
682
+ background: "".concat(theme.palette.primary.main, " !important"),
646
683
  color: "".concat(_Utils["default"].invertColor(theme.palette.primary.main, true), " !important")
647
684
  },
648
685
  header: {
@@ -758,6 +795,30 @@ var styles = function styles(theme) {
758
795
  right: 0,
759
796
  borderRadius: 20,
760
797
  backgroundColor: theme.palette.background["default"]
798
+ },
799
+ iconDeviceConnected: {
800
+ color: theme.palette.mode === 'dark' ? COLOR_NAME_CONNECTED_DARK : COLOR_NAME_CONNECTED_LIGHT,
801
+ opacity: 0.8,
802
+ position: 'absolute',
803
+ top: 4,
804
+ right: 32,
805
+ width: 20
806
+ },
807
+ iconDeviceDisconnected: {
808
+ color: theme.palette.mode === 'dark' ? COLOR_NAME_DISCONNECTED_DARK : COLOR_NAME_DISCONNECTED_LIGHT,
809
+ opacity: 0.8,
810
+ position: 'absolute',
811
+ top: 4,
812
+ right: 32,
813
+ width: 20
814
+ },
815
+ iconDeviceError: {
816
+ color: theme.palette.mode === 'dark' ? COLOR_NAME_ERROR_DARK : COLOR_NAME_ERROR_LIGHT,
817
+ opacity: 0.8,
818
+ position: 'absolute',
819
+ top: 4,
820
+ right: 50,
821
+ width: 20
761
822
  }
762
823
  };
763
824
  };
@@ -1395,17 +1456,51 @@ function formatValue(id, state, obj, texts, dateFormat, isFloatComma) {
1395
1456
 
1396
1457
  var isCommon = obj.common;
1397
1458
  var valText = {};
1398
- var v = !state || state.val === null ? '(null)' : state.val === undefined ? '[undef]' : state.val;
1459
+ var v = isCommon && isCommon.type === 'file' ? '[file]' : !state || state.val === null ? '(null)' : state.val === undefined ? '[undef]' : state.val;
1399
1460
 
1400
1461
  var type = _typeof(v);
1401
1462
 
1402
1463
  if (isCommon && isCommon.role && typeof isCommon.role === 'string' && isCommon.role.match(/^value\.time|^date/)) {
1403
- if (typeof v === 'string' && v.length === 13) {
1404
- // warning, this solution only works till Nov 20 2286 18:46:39CET
1405
- v = parseInt(v, 10);
1406
- }
1464
+ if (v && typeof v === 'string') {
1465
+ if (v.length === 13) {
1466
+ // (length of "1647597254924") warning, this solution only works till Nov 20 2286 18:46:39CET
1467
+ v = new Date(parseInt(v, 10)).toString();
1468
+ } else if (v.length === 10) {
1469
+ // YYYY.MM.DD
1470
+ var parts = v.split(/[-.]/);
1471
+
1472
+ if (parts.length === 3) {
1473
+ if (parts[0].length === 4) {
1474
+ // YYYY.MM.DD
1475
+ v = new Date(parseInt(parts[0], 10), parseInt(parts[1], 10) + 1, parseInt(parts[2], 10));
1476
+ } else if (parts[0].length === 4) {
1477
+ // DD.MM.YYYY
1478
+ v = new Date(parseInt(parts[2], 10), parseInt(parts[1], 10) + 1, parseInt(parts[0], 10));
1479
+ }
1480
+ } else {
1481
+ v = new Date(v).toString(); // Let the browser convert it somehow
1482
+ }
1483
+ } else if (v.length === 8) {
1484
+ // YY.MM.DD
1485
+ var _parts2 = v.split(/[-.]/);
1407
1486
 
1408
- v = v ? new Date(v).toString() : v;
1487
+ if (_parts2.length === 3) {
1488
+ v = new Date(parseInt(_parts2[0], 10), parseInt(_parts2[1], 10) + 1, parseInt(_parts2[2], 10));
1489
+ } else {
1490
+ v = new Date(v).toString(); // Let the browser convert it somehow
1491
+ }
1492
+ } else {
1493
+ v = new Date(v).toString(); // Let the browser convert it somehow
1494
+ }
1495
+ } else {
1496
+ if (v === null || v === 'null') {
1497
+ v = 'null';
1498
+ } else if (v === undefined) {
1499
+ v = 'undefined';
1500
+ } else {
1501
+ v = v ? new Date(v).toString() : v;
1502
+ }
1503
+ }
1409
1504
  } else {
1410
1505
  if (type === 'number') {
1411
1506
  v = Math.round(v * 100000000) / 100000000; // remove 4.00000000000000001
@@ -1518,7 +1613,7 @@ function getSelectIdIcon(objects, id, imagePrefix) {
1518
1613
  // if not BASE64
1519
1614
  if (!aIcon.startsWith('data:image/')) {
1520
1615
  if (aIcon.includes('.')) {
1521
- src = imagePrefix + '/adapter/' + objects[_id_].common.name + '/' + aIcon;
1616
+ src = "".concat(imagePrefix, "/adapter/").concat(objects[_id_].common.name, "/").concat(aIcon);
1522
1617
  } else if (aIcon && aIcon.length < 3) {
1523
1618
  return aIcon; // utf-8
1524
1619
  } else {
@@ -1547,7 +1642,7 @@ function getSelectIdIcon(objects, id, imagePrefix) {
1547
1642
  var instance;
1548
1643
 
1549
1644
  if (objects[id].type === 'instance' || objects[id].type === 'adapter') {
1550
- src = imagePrefix + '/adapter/' + common.name + '/' + cIcon;
1645
+ src = "".concat(imagePrefix, "/adapter/").concat(common.name, "/").concat(cIcon);
1551
1646
  } else if (id && id.startsWith('system.adapter.')) {
1552
1647
  instance = id.split('.', 3);
1553
1648
 
@@ -1557,7 +1652,7 @@ function getSelectIdIcon(objects, id, imagePrefix) {
1557
1652
  instance[2] += '/' + cIcon;
1558
1653
  }
1559
1654
 
1560
- src = imagePrefix + '/adapter/' + instance[2];
1655
+ src = "".concat(imagePrefix, "/adapter/").concat(instance[2]);
1561
1656
  } else {
1562
1657
  instance = id.split('.', 2);
1563
1658
 
@@ -1567,7 +1662,7 @@ function getSelectIdIcon(objects, id, imagePrefix) {
1567
1662
  instance[0] += '/' + cIcon;
1568
1663
  }
1569
1664
 
1570
- src = imagePrefix + '/adapter/' + instance[0];
1665
+ src = "".concat(imagePrefix, "/adapter/").concat(instance[0]);
1571
1666
  }
1572
1667
  } else if (aIcon && aIcon.length < 3) {
1573
1668
  return aIcon; // utf-8
@@ -1827,8 +1922,6 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
1827
1922
  return;
1828
1923
  }
1829
1924
 
1830
- ;
1831
-
1832
1925
  if (event.id.startsWith('system.adapter.') && event.obj && event.obj.type === 'adapter') {
1833
1926
  var columnsForAdmin = JSON.parse(JSON.stringify(_this.state.columnsForAdmin));
1834
1927
 
@@ -2540,6 +2633,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2540
2633
  scrollBarWidth: 16,
2541
2634
  customDialog: customDialog,
2542
2635
  editObjectDialog: '',
2636
+ viewFileDialog: '',
2543
2637
  enumDialog: null,
2544
2638
  roleDialog: null,
2545
2639
  modalEmptyId: null,
@@ -2590,6 +2684,9 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2590
2684
  // State changed from
2591
2685
  ownerGroup: props.t('ra_Owner group'),
2592
2686
  ownerUser: props.t('ra_Owner user'),
2687
+ deviceError: props.t('ra_Error'),
2688
+ deviceDisconnected: props.t('ra_Disconnected'),
2689
+ deviceConnected: props.t('ra_Connected'),
2593
2690
  aclOwner_read_object: props.t('ra_aclOwner_read_object'),
2594
2691
  aclOwner_read_state: props.t('ra_aclOwner_read_state'),
2595
2692
  aclOwner_write_object: props.t('ra_aclOwner_write_object'),
@@ -3257,7 +3354,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
3257
3354
  }, {
3258
3355
  key: "checkUnsubscribes",
3259
3356
  value: function checkUnsubscribes() {
3260
- // Remove unused subscribed
3357
+ // Remove unused subscriptions
3261
3358
  for (var i = this.subscribes.length - 1; i >= 0; i--) {
3262
3359
  !this.recordStates.includes(this.subscribes[i]) && this.unsubscribe(this.subscribes[i]);
3263
3360
  }
@@ -4258,7 +4355,8 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
4258
4355
  function renderColumnButtons(id, item, classes) {
4259
4356
  var _this27 = this,
4260
4357
  _item$children2,
4261
- _item$data$obj$common;
4358
+ _item$data$obj$common,
4359
+ _item$data$obj$common3;
4262
4360
 
4263
4361
  if (!item.data.obj) {
4264
4362
  return this.props.onObjectDelete || this.props.objectEditOfAccessControl ? /*#__PURE__*/_react["default"].createElement("div", {
@@ -4334,7 +4432,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
4334
4432
  title: this.texts.deleteObject
4335
4433
  }, /*#__PURE__*/_react["default"].createElement(_Delete["default"], {
4336
4434
  className: classes.cellButtonsButtonIcon
4337
- })) : null, this.props.objectCustomDialog && this.info.hasSomeCustoms && item.data.obj.type === 'state' ? /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
4435
+ })) : null, this.props.objectCustomDialog && this.info.hasSomeCustoms && item.data.obj.type === 'state' && ((_item$data$obj$common3 = item.data.obj.common) === null || _item$data$obj$common3 === void 0 ? void 0 : _item$data$obj$common3.type) !== 'file' ? /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
4338
4436
  className: _Utils["default"].clsx(classes.cellButtonsButton, item.data.hasCustoms && classes.cellButtonsButtonWithCustoms),
4339
4437
  key: "custom",
4340
4438
  size: "small",
@@ -4423,15 +4521,20 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
4423
4521
  }, {
4424
4522
  key: "renderColumnValue",
4425
4523
  value: function renderColumnValue(id, item, classes) {
4426
- var _this29 = this;
4524
+ var _item$data$obj$common4,
4525
+ _this29 = this;
4427
4526
 
4428
4527
  if (!item.data.obj || !this.states) {
4429
4528
  return null;
4430
4529
  }
4431
4530
 
4432
- if (!this.states[id]) {
4531
+ if (((_item$data$obj$common4 = item.data.obj.common) === null || _item$data$obj$common4 === void 0 ? void 0 : _item$data$obj$common4.type) === 'file') {
4532
+ return /*#__PURE__*/_react["default"].createElement("div", {
4533
+ className: _Utils["default"].clsx(classes.cellValueText, classes.cellValueFile)
4534
+ }, "[file]");
4535
+ } else if (!this.states[id]) {
4433
4536
  if (item.data.obj.type === 'state') {
4434
- this.recordStates.push(id);
4537
+ !this.recordStates.includes(id) && this.recordStates.push(id);
4435
4538
  this.states[id] = {
4436
4539
  val: null
4437
4540
  };
@@ -4440,7 +4543,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
4440
4543
 
4441
4544
  return null;
4442
4545
  } else {
4443
- this.recordStates.push(id);
4546
+ !this.recordStates.includes(id) && this.recordStates.push(id);
4444
4547
  }
4445
4548
 
4446
4549
  var state = this.states[id];
@@ -5020,22 +5123,13 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5020
5123
  value: function renderLeaf(item, isExpanded, classes, counter) {
5021
5124
  var _item$data$obj,
5022
5125
  _this37 = this,
5023
- _item$data$obj2,
5024
- _item$data$obj2$commo,
5025
- _item$data$obj3,
5026
- _item$data$obj4,
5027
- _item$data$obj5,
5028
- _item$data$obj6,
5029
- _item$data$obj6$commo,
5030
- _item$data$obj6$commo2,
5031
- _item$data$obj7,
5032
- _item$data$obj7$commo,
5033
- _item$data$obj7$commo2,
5126
+ _common$alias,
5127
+ _common$alias2,
5034
5128
  _item$data,
5035
- _item$data$obj8,
5036
- _item$data$obj8$commo,
5129
+ _item$data$common,
5037
5130
  _this$states$id2,
5038
5131
  _item$data2,
5132
+ _item$data3,
5039
5133
  _this$states$id3,
5040
5134
  _this$states$id4,
5041
5135
  _this$states$id5;
@@ -5086,6 +5180,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5086
5180
  }
5087
5181
 
5088
5182
  var obj = item.data.obj;
5183
+ var common = obj === null || obj === void 0 ? void 0 : obj.common;
5089
5184
 
5090
5185
  var typeImg = obj && obj.type && ITEM_IMAGES[obj.type] || /*#__PURE__*/_react["default"].createElement("div", {
5091
5186
  className: "itemIcon"
@@ -5114,7 +5209,12 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5114
5209
  className: classes.checkBox,
5115
5210
  checked: this.state.selected.includes(id)
5116
5211
  }) : null;
5117
- var valueEditable = !this.props.notEditable && itemType === 'state' && (this.props.expertMode || ((_item$data$obj2 = item.data.obj) === null || _item$data$obj2 === void 0 ? void 0 : (_item$data$obj2$commo = _item$data$obj2.common) === null || _item$data$obj2$commo === void 0 ? void 0 : _item$data$obj2$commo.write) !== false);
5212
+ var valueEditable = !this.props.notEditable && itemType === 'state' && (this.props.expertMode || (common === null || common === void 0 ? void 0 : common.write) !== false);
5213
+
5214
+ if (this.props.objectBrowserViewFile && (common === null || common === void 0 ? void 0 : common.type) === 'file') {
5215
+ valueEditable = true;
5216
+ }
5217
+
5118
5218
  var enumEditable = !this.props.notEditable && this.objects[id] && (this.props.expertMode || itemType === 'state' || itemType === 'channel' || itemType === 'device');
5119
5219
  var checkVisibleObjectType = this.state.statesView && (itemType === 'state' || itemType === 'channel' || itemType === 'device');
5120
5220
  var newValue = '';
@@ -5139,56 +5239,59 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5139
5239
  }
5140
5240
  }
5141
5241
 
5142
- ((_item$data$obj3 = item.data.obj) === null || _item$data$obj3 === void 0 ? void 0 : _item$data$obj3.from) && newValueTitle.push(this.texts.objectChangedFrom + ' ' + item.data.obj.from.replace(/^system\.adapter\.|^system\./, ''));
5143
- ((_item$data$obj4 = item.data.obj) === null || _item$data$obj4 === void 0 ? void 0 : _item$data$obj4.user) && newValueTitle.push(this.texts.objectChangedBy + ' ' + item.data.obj.user.replace(/^system\.user\./, ''));
5144
- ((_item$data$obj5 = item.data.obj) === null || _item$data$obj5 === void 0 ? void 0 : _item$data$obj5.ts) && newValueTitle.push(this.texts.objectChangedByUser + ' ' + _Utils["default"].formatDate(new Date(item.data.obj.ts), this.props.dateFormat));
5145
- var readWriteAlias = _typeof((_item$data$obj6 = item.data.obj) === null || _item$data$obj6 === void 0 ? void 0 : (_item$data$obj6$commo = _item$data$obj6.common) === null || _item$data$obj6$commo === void 0 ? void 0 : (_item$data$obj6$commo2 = _item$data$obj6$commo.alias) === null || _item$data$obj6$commo2 === void 0 ? void 0 : _item$data$obj6$commo2.id) === 'object';
5146
- var alias = id.startsWith('alias.') && (_item$data$obj7 = item.data.obj) !== null && _item$data$obj7 !== void 0 && (_item$data$obj7$commo = _item$data$obj7.common) !== null && _item$data$obj7$commo !== void 0 && (_item$data$obj7$commo2 = _item$data$obj7$commo.alias) !== null && _item$data$obj7$commo2 !== void 0 && _item$data$obj7$commo2.id ? readWriteAlias ? /*#__PURE__*/_react["default"].createElement("div", {
5242
+ if (obj) {
5243
+ obj.from && newValueTitle.push(this.texts.objectChangedFrom + ' ' + obj.from.replace(/^system\.adapter\.|^system\./, ''));
5244
+ obj.user && newValueTitle.push(this.texts.objectChangedBy + ' ' + obj.user.replace(/^system\.user\./, ''));
5245
+ obj.ts && newValueTitle.push(this.texts.objectChangedByUser + ' ' + _Utils["default"].formatDate(new Date(obj.ts), this.props.dateFormat));
5246
+ }
5247
+
5248
+ var readWriteAlias = _typeof(common === null || common === void 0 ? void 0 : (_common$alias = common.alias) === null || _common$alias === void 0 ? void 0 : _common$alias.id) === 'object';
5249
+ var alias = id.startsWith('alias.') && common !== null && common !== void 0 && (_common$alias2 = common.alias) !== null && _common$alias2 !== void 0 && _common$alias2.id ? readWriteAlias ? /*#__PURE__*/_react["default"].createElement("div", {
5147
5250
  className: classes.cellIdAliasReadWriteDiv
5148
- }, item.data.obj.common.alias.id.read ? /*#__PURE__*/_react["default"].createElement("div", {
5251
+ }, obj.common.alias.id.read ? /*#__PURE__*/_react["default"].createElement("div", {
5149
5252
  onClick: function onClick(e) {
5150
5253
  e.stopPropagation();
5151
5254
  e.preventDefault();
5152
5255
 
5153
- _this37.onSelect(item.data.obj.common.alias.id.read);
5256
+ _this37.onSelect(obj.common.alias.id.read);
5154
5257
 
5155
5258
  setTimeout(function () {
5156
5259
  _this37.expandAllSelected(function () {
5157
- return _this37.scrollToItem(item.data.obj.common.alias.id.read);
5260
+ return _this37.scrollToItem(obj.common.alias.id.read);
5158
5261
  });
5159
5262
  }, 100);
5160
5263
  },
5161
5264
  className: _Utils["default"].clsx(classes.cellIdAlias, classes.cellIdAliasReadWrite)
5162
- }, "\u2190", item.data.obj.common.alias.id.read) : null, item.data.obj.common.alias.id.write ? /*#__PURE__*/_react["default"].createElement("div", {
5265
+ }, "\u2190", obj.common.alias.id.read) : null, obj.common.alias.id.write ? /*#__PURE__*/_react["default"].createElement("div", {
5163
5266
  onClick: function onClick(e) {
5164
5267
  e.stopPropagation();
5165
5268
  e.preventDefault();
5166
5269
 
5167
- _this37.onSelect(item.data.obj.common.alias.id.write);
5270
+ _this37.onSelect(obj.common.alias.id.write);
5168
5271
 
5169
5272
  setTimeout(function () {
5170
5273
  _this37.expandAllSelected(function () {
5171
- return _this37.scrollToItem(item.data.obj.common.alias.id.write);
5274
+ return _this37.scrollToItem(obj.common.alias.id.write);
5172
5275
  });
5173
5276
  }, 100);
5174
5277
  },
5175
5278
  className: _Utils["default"].clsx(classes.cellIdAlias, classes.cellIdAliasReadWrite)
5176
- }, "\u2192", item.data.obj.common.alias.id.write) : null) : /*#__PURE__*/_react["default"].createElement("div", {
5279
+ }, "\u2192", obj.common.alias.id.write) : null) : /*#__PURE__*/_react["default"].createElement("div", {
5177
5280
  onClick: function onClick(e) {
5178
5281
  e.stopPropagation();
5179
5282
  e.preventDefault();
5180
5283
 
5181
- _this37.onSelect(item.data.obj.common.alias.id);
5284
+ _this37.onSelect(obj.common.alias.id);
5182
5285
 
5183
5286
  setTimeout(function () {
5184
5287
  _this37.expandAllSelected(function () {
5185
- return _this37.scrollToItem(item.data.obj.common.alias.id);
5288
+ return _this37.scrollToItem(obj.common.alias.id);
5186
5289
  });
5187
5290
  }, 100);
5188
5291
  },
5189
5292
  className: _Utils["default"].clsx(classes.cellIdAlias, classes.cellIdAliasAlone)
5190
- }, "\u2192", item.data.obj.common.alias.id) : null;
5191
- var checkColor = (_item$data = item.data) === null || _item$data === void 0 ? void 0 : (_item$data$obj8 = _item$data.obj) === null || _item$data$obj8 === void 0 ? void 0 : (_item$data$obj8$commo = _item$data$obj8.common) === null || _item$data$obj8$commo === void 0 ? void 0 : _item$data$obj8$commo.color;
5293
+ }, "\u2192", obj.common.alias.id) : null;
5294
+ var checkColor = (_item$data = item.data) === null || _item$data === void 0 ? void 0 : (_item$data$common = _item$data.common) === null || _item$data$common === void 0 ? void 0 : _item$data$common.color;
5192
5295
  var invertBackground = 'none';
5193
5296
 
5194
5297
  if (checkColor && !this.state.selected.includes(id)) {
@@ -5199,6 +5302,111 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5199
5302
  checkColor = 'inherit';
5200
5303
  }
5201
5304
 
5305
+ var icons = [];
5306
+
5307
+ if (common !== null && common !== void 0 && common.statusStates) {
5308
+ var ids = {};
5309
+ Object.keys(common.statusStates).forEach(function (name) {
5310
+ var _id = common.statusStates[name];
5311
+
5312
+ if (_id.split('.').length < 3) {
5313
+ _id = id + '.' + _id;
5314
+ }
5315
+
5316
+ ids[name] = _id;
5317
+
5318
+ if (!_this37.states[_id]) {
5319
+ var _this37$objects$_id;
5320
+
5321
+ if (((_this37$objects$_id = _this37.objects[_id]) === null || _this37$objects$_id === void 0 ? void 0 : _this37$objects$_id.type) === 'state') {
5322
+ !_this37.recordStates.includes(_id) && _this37.recordStates.push(_id);
5323
+ _this37.states[_id] = {
5324
+ val: null
5325
+ };
5326
+
5327
+ _this37.subscribe(_id);
5328
+ }
5329
+ } else {
5330
+ !_this37.recordStates.includes(_id) && _this37.recordStates.push(_id);
5331
+ }
5332
+ }); // calculate color
5333
+ // errorId has priority
5334
+
5335
+ var colorSet = false;
5336
+
5337
+ if (common.statusStates.errorId && this.states[ids.errorId] && this.states[ids.errorId].val) {
5338
+ checkColor = this.props.themeType === 'dark' ? COLOR_NAME_ERROR_DARK : COLOR_NAME_ERROR_LIGHT;
5339
+ colorSet = true;
5340
+ icons.push( /*#__PURE__*/_react["default"].createElement(_Error["default"], {
5341
+ key: "error",
5342
+ title: this.texts.deviceError,
5343
+ className: this.props.classes.iconDeviceError
5344
+ }));
5345
+ }
5346
+
5347
+ if (ids.onlineId && this.states[ids.onlineId] && this.states[ids.onlineId].val !== null) {
5348
+ if (!colorSet) {
5349
+ if (this.states[ids.onlineId].val) {
5350
+ checkColor = this.props.themeType === 'dark' ? COLOR_NAME_CONNECTED_DARK : COLOR_NAME_CONNECTED_LIGHT;
5351
+ icons.push( /*#__PURE__*/_react["default"].createElement(_Wifi["default"], {
5352
+ key: "conn",
5353
+ title: this.texts.deviceError,
5354
+ className: this.props.classes.iconDeviceConnected
5355
+ }));
5356
+ } else {
5357
+ checkColor = this.props.themeType === 'dark' ? COLOR_NAME_DISCONNECTED_DARK : COLOR_NAME_DISCONNECTED_LIGHT;
5358
+ icons.push( /*#__PURE__*/_react["default"].createElement(_WifiOff["default"], {
5359
+ key: "disc",
5360
+ title: this.texts.deviceError,
5361
+ className: this.props.classes.iconDeviceDisconnected
5362
+ }));
5363
+ }
5364
+ } else if (this.states[ids.onlineId].val) {
5365
+ icons.push( /*#__PURE__*/_react["default"].createElement(_Wifi["default"], {
5366
+ key: "conn",
5367
+ title: this.texts.deviceError,
5368
+ className: this.props.classes.iconDeviceConnected
5369
+ }));
5370
+ } else {
5371
+ icons.push( /*#__PURE__*/_react["default"].createElement(_WifiOff["default"], {
5372
+ key: "disc",
5373
+ title: this.texts.deviceError,
5374
+ className: this.props.classes.iconDeviceDisconnected
5375
+ }));
5376
+ }
5377
+ } else if (ids.offlineId && this.states[ids.offlineId] && this.states[ids.offlineId].val !== null) {
5378
+ if (!colorSet) {
5379
+ if (this.states[ids.offlineId].val) {
5380
+ checkColor = this.props.themeType === 'dark' ? COLOR_NAME_DISCONNECTED_DARK : COLOR_NAME_DISCONNECTED_LIGHT;
5381
+ icons.push( /*#__PURE__*/_react["default"].createElement(_WifiOff["default"], {
5382
+ key: "disc",
5383
+ title: this.texts.deviceError,
5384
+ className: this.props.classes.iconDeviceDisconnected
5385
+ }));
5386
+ } else {
5387
+ checkColor = this.props.themeType === 'dark' ? COLOR_NAME_CONNECTED_DARK : COLOR_NAME_CONNECTED_LIGHT;
5388
+ icons.push( /*#__PURE__*/_react["default"].createElement(_Wifi["default"], {
5389
+ key: "conn",
5390
+ title: this.texts.deviceError,
5391
+ className: this.props.classes.iconDeviceConnected
5392
+ }));
5393
+ }
5394
+ } else if (this.states[ids.offlineId].val) {
5395
+ icons.push( /*#__PURE__*/_react["default"].createElement(_WifiOff["default"], {
5396
+ key: "disc",
5397
+ title: this.texts.deviceError,
5398
+ className: this.props.classes.iconDeviceDisconnected
5399
+ }));
5400
+ } else {
5401
+ icons.push( /*#__PURE__*/_react["default"].createElement(_Wifi["default"], {
5402
+ key: "conn",
5403
+ title: this.texts.deviceError,
5404
+ className: this.props.classes.iconDeviceConnected
5405
+ }));
5406
+ }
5407
+ }
5408
+ }
5409
+
5202
5410
  var q = checkVisibleObjectType ? _Utils["default"].quality2text(((_this$states$id2 = this.states[id]) === null || _this$states$id2 === void 0 ? void 0 : _this$states$id2.q) || 0).join(', ') : null;
5203
5411
  return /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
5204
5412
  container: true,
@@ -5242,7 +5450,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5242
5450
  background: invertBackground,
5243
5451
  color: id === 'system' ? COLOR_NAME_SYSTEM : id === 'system.adapter' ? COLOR_NAME_SYSTEM_ADAPTER : checkColor
5244
5452
  }
5245
- }, item.data.name, alias), /*#__PURE__*/_react["default"].createElement("div", {
5453
+ }, item.data.name, alias, icons), /*#__PURE__*/_react["default"].createElement("div", {
5246
5454
  style: {
5247
5455
  color: checkColor,
5248
5456
  background: invertBackground
@@ -5266,7 +5474,16 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5266
5474
  style: {
5267
5475
  width: this.columnsVisibility.name
5268
5476
  }
5269
- }, ((_item$data2 = item.data) === null || _item$data2 === void 0 ? void 0 : _item$data2.title) || '') : null, !this.state.statesView ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.columnsVisibility.type ? /*#__PURE__*/_react["default"].createElement("div", {
5477
+ }, ((_item$data2 = item.data) === null || _item$data2 === void 0 ? void 0 : _item$data2.title) || '', (_item$data3 = item.data) !== null && _item$data3 !== void 0 && _item$data3.title ? /*#__PURE__*/_react["default"].createElement("div", {
5478
+ style: {
5479
+ color: checkColor
5480
+ }
5481
+ }, /*#__PURE__*/_react["default"].createElement(_IconCopy["default"], {
5482
+ className: _Utils["default"].clsx(classes.cellCopyButton, 'copyButton'),
5483
+ onClick: function onClick(e) {
5484
+ return _this37.onCopy(e, item.data.title);
5485
+ }
5486
+ })) : null) : null, !this.state.statesView ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.columnsVisibility.type ? /*#__PURE__*/_react["default"].createElement("div", {
5270
5487
  className: classes.cellType,
5271
5488
  style: {
5272
5489
  width: this.columnsVisibility.type
@@ -5353,12 +5570,18 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5353
5570
  className: classes.cellValue,
5354
5571
  style: {
5355
5572
  width: this.columnsVisibility.val,
5356
- cursor: valueEditable ? item.data.button ? 'grab' : 'text' : 'default'
5573
+ cursor: valueEditable ? (common === null || common === void 0 ? void 0 : common.type) === 'file' ? 'zoom-in' : item.data.button ? 'grab' : 'text' : 'default'
5357
5574
  },
5358
5575
  onClick: valueEditable ? function () {
5359
- if (!item.data.obj || !_this37.states) {
5576
+ if (!obj || !_this37.states) {
5360
5577
  return null;
5361
- } // in non expert mode control button directly
5578
+ }
5579
+
5580
+ if ((common === null || common === void 0 ? void 0 : common.type) === 'file') {
5581
+ return _this37.setState({
5582
+ viewFileDialog: id
5583
+ });
5584
+ } // in non-expert mode control button directly
5362
5585
 
5363
5586
 
5364
5587
  if (!_this37.props.expertMode && item.data.button) {
@@ -5927,11 +6150,41 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5927
6150
  * @returns {JSX.Element | null}
5928
6151
  */
5929
6152
 
6153
+ }, {
6154
+ key: "renderViewObjectFileDialog",
6155
+ value: function renderViewObjectFileDialog() {
6156
+ var _this46 = this;
6157
+
6158
+ if (!this.state.viewFileDialog || !this.props.objectBrowserViewFile) {
6159
+ return null;
6160
+ }
6161
+
6162
+ var ObjectBrowserViewFile = this.props.objectBrowserViewFile;
6163
+ return /*#__PURE__*/_react["default"].createElement(ObjectBrowserViewFile, {
6164
+ key: "viewFile",
6165
+ obj: this.objects[this.state.viewFileDialog],
6166
+ themeType: this.props.themeType,
6167
+ socket: this.props.socket,
6168
+ dialogName: this.props.dialogName,
6169
+ t: this.props.t,
6170
+ expertMode: this.state.filter.expertMode,
6171
+ onClose: function onClose() {
6172
+ return _this46.setState({
6173
+ viewFileDialog: ''
6174
+ });
6175
+ }
6176
+ });
6177
+ }
6178
+ /**
6179
+ * @private
6180
+ * @returns {JSX.Element | null}
6181
+ */
6182
+
5930
6183
  }, {
5931
6184
  key: "renderEditValueDialog",
5932
6185
  value: function renderEditValueDialog() {
5933
6186
  var _this$objects$this$ed,
5934
- _this46 = this;
6187
+ _this47 = this;
5935
6188
 
5936
6189
  if (!this.state.updateOpened || !this.props.objectBrowserValue) {
5937
6190
  return null;
@@ -5952,11 +6205,11 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5952
6205
  defaultHistory: this.defaultHistory,
5953
6206
  dateFormat: this.props.dateFormat,
5954
6207
  onClose: function onClose(res) {
5955
- _this46.setState({
6208
+ _this47.setState({
5956
6209
  updateOpened: false
5957
6210
  });
5958
6211
 
5959
- res && _this46.onUpdate(res);
6212
+ res && _this47.onUpdate(res);
5960
6213
  }
5961
6214
  });
5962
6215
  }
@@ -5968,7 +6221,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5968
6221
  * @returns {JSX.Element}
5969
6222
  */
5970
6223
  function render() {
5971
- var _this47 = this;
6224
+ var _this48 = this;
5972
6225
 
5973
6226
  this.recordStates = [];
5974
6227
  this.unsubscribeTimer && clearTimeout(this.unsubscribeTimer); // apply filter if changed
@@ -5983,13 +6236,13 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5983
6236
 
5984
6237
  if (counter.count < 500 && !this.state.expandAllVisible) {
5985
6238
  setTimeout(function () {
5986
- return _this47.setState({
6239
+ return _this48.setState({
5987
6240
  expandAllVisible: true
5988
6241
  });
5989
6242
  });
5990
6243
  } else if (counter.count >= 500 && this.state.expandAllVisible) {
5991
6244
  setTimeout(function () {
5992
- return _this47.setState({
6245
+ return _this48.setState({
5993
6246
  expandAllVisible: false
5994
6247
  });
5995
6248
  });
@@ -5999,9 +6252,9 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5999
6252
  }
6000
6253
 
6001
6254
  this.unsubscribeTimer = setTimeout(function () {
6002
- _this47.unsubscribeTimer = null;
6255
+ _this48.unsubscribeTimer = null;
6003
6256
 
6004
- _this47.checkUnsubscribes();
6257
+ _this48.checkUnsubscribes();
6005
6258
  }, 200);
6006
6259
 
6007
6260
  if (!this.state.loaded) {
@@ -6016,7 +6269,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
6016
6269
  }, /*#__PURE__*/_react["default"].createElement(_TabHeader["default"], null, this.getToolbar()), /*#__PURE__*/_react["default"].createElement(_TabContent["default"], null, this.renderHeader(), /*#__PURE__*/_react["default"].createElement("div", {
6017
6270
  className: this.props.classes.tableDiv,
6018
6271
  ref: this.tableRef
6019
- }, items)), this.renderToast(), this.renderColumnsEditCustomDialog(), this.renderColumnsSelectorDialog(), this.renderCustomDialog(), this.renderEditValueDialog(), this.renderEditObjectDialog(), this.renderEditRoleDialog(), this.renderEnumDialog(), this.renderErrorDialog(), this.renderExportDialog(), this.state.modalNewObj && this.props.modalNewObject && this.props.modalNewObject(this), this.state.modalEditOfAccess && this.props.modalEditOfAccessControl && this.props.modalEditOfAccessControl(this, this.state.modalEditOfAccessObjData));
6272
+ }, items)), this.renderToast(), this.renderColumnsEditCustomDialog(), this.renderColumnsSelectorDialog(), this.renderCustomDialog(), this.renderEditValueDialog(), this.renderEditObjectDialog(), this.renderViewObjectFileDialog(), this.renderEditRoleDialog(), this.renderEnumDialog(), this.renderErrorDialog(), this.renderExportDialog(), this.state.modalNewObj && this.props.modalNewObject && this.props.modalNewObject(this), this.state.modalEditOfAccess && this.props.modalEditOfAccessControl && this.props.modalEditOfAccessControl(this, this.state.modalEditOfAccessObjData));
6020
6273
  }
6021
6274
  }
6022
6275
  }], [{
@@ -6095,6 +6348,8 @@ ObjectBrowser.propTypes = {
6095
6348
  objectBrowserEditObject: _propTypes["default"].object,
6096
6349
  objectBrowserEditRole: _propTypes["default"].object,
6097
6350
  // on Edit role
6351
+ objectBrowserViewFile: _propTypes["default"].func,
6352
+ // on view file state
6098
6353
  router: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].func]),
6099
6354
  types: _propTypes["default"].array,
6100
6355
  // optional ['state', 'instance', 'channel']
@@ -6103,7 +6358,7 @@ ObjectBrowser.propTypes = {
6103
6358
  objectsWorker: _propTypes["default"].object,
6104
6359
  // optional cache of objects
6105
6360
  filterFunc: _propTypes["default"].func,
6106
- // function to filter out all unneccessary objects. It cannot be used together with "types"
6361
+ // function to filter out all unnecessary objects. It cannot be used together with "types"
6107
6362
  // Example for function: `obj => obj.common && obj.common.type === 'boolean'` to show only boolean states
6108
6363
  dragSettings: _propTypes["default"].object,
6109
6364
  DragWrapper: _propTypes["default"].func,