@iobroker/adapter-react-v5 4.4.8 → 4.5.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.
Files changed (84) hide show
  1. package/Components/CustomModal.js +6 -3
  2. package/Components/CustomModal.js.map +1 -1
  3. package/Components/FileBrowser.js +4 -2
  4. package/Components/FileBrowser.js.map +1 -1
  5. package/Components/FileViewer.d.ts +5 -0
  6. package/Components/FileViewer.js +34 -7
  7. package/Components/FileViewer.js.map +1 -1
  8. package/Components/JsonConfigComponent/ConfigAccordion.d.ts +1 -0
  9. package/Components/JsonConfigComponent/ConfigAccordion.js +3 -1
  10. package/Components/JsonConfigComponent/ConfigAccordion.js.map +1 -1
  11. package/Components/JsonConfigComponent/ConfigCRON.js +2 -4
  12. package/Components/JsonConfigComponent/ConfigCRON.js.map +1 -1
  13. package/Components/JsonConfigComponent/ConfigCheckLicense.js +29 -12
  14. package/Components/JsonConfigComponent/ConfigCheckLicense.js.map +1 -1
  15. package/Components/JsonConfigComponent/ConfigCustom.js +4 -5
  16. package/Components/JsonConfigComponent/ConfigCustom.js.map +1 -1
  17. package/Components/JsonConfigComponent/ConfigFile.js +9 -14
  18. package/Components/JsonConfigComponent/ConfigFile.js.map +1 -1
  19. package/Components/JsonConfigComponent/ConfigGeneric.d.ts +1 -0
  20. package/Components/JsonConfigComponent/ConfigGeneric.js +9 -8
  21. package/Components/JsonConfigComponent/ConfigGeneric.js.map +1 -1
  22. package/Components/JsonConfigComponent/ConfigIP.js +5 -0
  23. package/Components/JsonConfigComponent/ConfigIP.js.map +1 -1
  24. package/Components/JsonConfigComponent/ConfigNumber.js +42 -31
  25. package/Components/JsonConfigComponent/ConfigNumber.js.map +1 -1
  26. package/Components/JsonConfigComponent/ConfigPanel.js +2 -0
  27. package/Components/JsonConfigComponent/ConfigPanel.js.map +1 -1
  28. package/Components/JsonConfigComponent/ConfigPort.js +44 -29
  29. package/Components/JsonConfigComponent/ConfigPort.js.map +1 -1
  30. package/Components/JsonConfigComponent/ConfigSelect.js +29 -12
  31. package/Components/JsonConfigComponent/ConfigSelect.js.map +1 -1
  32. package/Components/JsonConfigComponent/ConfigSelectSendTo.js +11 -21
  33. package/Components/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
  34. package/Components/JsonConfigComponent/ConfigSendto.js +16 -20
  35. package/Components/JsonConfigComponent/ConfigSendto.js.map +1 -1
  36. package/Components/JsonConfigComponent/ConfigSetState.js +18 -19
  37. package/Components/JsonConfigComponent/ConfigSetState.js.map +1 -1
  38. package/Components/JsonConfigComponent/ConfigStaticText.js +14 -23
  39. package/Components/JsonConfigComponent/ConfigStaticText.js.map +1 -1
  40. package/Components/JsonConfigComponent/ConfigTable.js +12 -8
  41. package/Components/JsonConfigComponent/ConfigTable.js.map +1 -1
  42. package/Components/JsonConfigComponent/ConfigTabs.d.ts +1 -0
  43. package/Components/JsonConfigComponent/ConfigTabs.js +5 -4
  44. package/Components/JsonConfigComponent/ConfigTabs.js.map +1 -1
  45. package/Components/JsonConfigComponent/ConfigText.js +3 -7
  46. package/Components/JsonConfigComponent/ConfigText.js.map +1 -1
  47. package/Components/JsonConfigComponent/ConfigTextSendTo.js +3 -4
  48. package/Components/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
  49. package/Components/JsonConfigComponent/ConfigTimePicker.js.map +1 -1
  50. package/Components/JsonConfigComponent/ConfigUUID.js +5 -6
  51. package/Components/JsonConfigComponent/ConfigUUID.js.map +1 -1
  52. package/Components/JsonConfigComponent/index.js +2 -0
  53. package/Components/JsonConfigComponent/index.js.map +1 -1
  54. package/Components/ObjectBrowser.d.ts +23 -1
  55. package/Components/ObjectBrowser.js +460 -50
  56. package/Components/ObjectBrowser.js.map +1 -1
  57. package/Components/TabContainer.d.ts +3 -0
  58. package/Components/TabContainer.js +7 -2
  59. package/Components/TabContainer.js.map +1 -1
  60. package/Components/TabContent.d.ts +1 -0
  61. package/Components/TabContent.js +7 -0
  62. package/Components/TabContent.js.map +1 -1
  63. package/Components/TableResize.js +7 -4
  64. package/Components/TableResize.js.map +1 -1
  65. package/Components/ToggleThemeMenu.js +5 -5
  66. package/Components/ToggleThemeMenu.js.map +1 -1
  67. package/Components/UploadImage.js +10 -7
  68. package/Components/UploadImage.js.map +1 -1
  69. package/Components/Utils.d.ts +2 -1
  70. package/Components/Utils.js +105 -98
  71. package/Components/Utils.js.map +1 -1
  72. package/README.md +3 -0
  73. package/i18n/de.json +4 -2
  74. package/i18n/en.json +3 -1
  75. package/i18n/es.json +4 -2
  76. package/i18n/fr.json +3 -1
  77. package/i18n/it.json +3 -1
  78. package/i18n/nl.json +4 -2
  79. package/i18n/pl.json +3 -1
  80. package/i18n/pt.json +4 -2
  81. package/i18n/ru.json +5 -3
  82. package/i18n/uk.json +4 -2
  83. package/i18n/zh-cn.json +4 -2
  84. package/package.json +1 -1
@@ -48,7 +48,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
48
48
  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) { (0, _defineProperty2["default"])(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; }
49
49
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
50
50
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /**
51
- * Copyright 2020-2023, bluefox <dogafox@gmail.com>
51
+ * Copyright 2020-2023, Denis Haev <dogafox@gmail.com>
52
52
  *
53
53
  * MIT License
54
54
  *
@@ -710,6 +710,38 @@ var styles = function styles(theme) {
710
710
  invertedBackgroundFlex: {
711
711
  backgroundColor: theme.palette.mode === 'dark' ? '#9a9a9a' : '#565656',
712
712
  borderRadius: '0 2px 2px 0'
713
+ },
714
+ contextMenuEdit: {
715
+ color: theme.palette.mode === 'dark' ? '#ffee48' : '#cbb801'
716
+ },
717
+ contextMenuEditValue: {
718
+ color: theme.palette.mode === 'dark' ? '#5dff45' : '#1cd301'
719
+ },
720
+ contextMenuView: {
721
+ color: theme.palette.mode === 'dark' ? '#FFF' : '#000'
722
+ },
723
+ contextMenuCustom: {
724
+ color: theme.palette.mode === 'dark' ? '#42eaff' : '#01bbc2'
725
+ },
726
+ contextMenuACL: {
727
+ color: theme.palette.mode === 'dark' ? '#e079ff' : '#500070'
728
+ },
729
+ contextMenuRoom: {
730
+ color: theme.palette.mode === 'dark' ? '#ff9a33' : '#642a00'
731
+ },
732
+ contextMenuRole: {
733
+ color: theme.palette.mode === 'dark' ? '#ffdb43' : '#562d00'
734
+ },
735
+ contextMenuAlias: {
736
+ color: theme.palette.mode === 'dark' ? '#5cabfb' : '#011ed0'
737
+ },
738
+ contextMenuDelete: {
739
+ color: theme.palette.mode === 'dark' ? '#ff4f4f' : '#cf0000'
740
+ },
741
+ contextMenuKeys: {
742
+ marginLeft: theme.spacing(1),
743
+ opacity: 0.7,
744
+ fontSize: 'smaller'
713
745
  }
714
746
  };
715
747
  };
@@ -747,6 +779,25 @@ function binarySearch(list, find, _start, _end) {
747
779
  }
748
780
  return false;
749
781
  }
782
+
783
+ /**
784
+ * Check if browser is running on iOS
785
+ *
786
+ * @return {boolean}
787
+ */
788
+ // function isIOS() {
789
+ // return [
790
+ // 'iPad Simulator',
791
+ // 'iPhone Simulator',
792
+ // 'iPod Simulator',
793
+ // 'iPad',
794
+ // 'iPhone',
795
+ // 'iPod',
796
+ // ].includes(navigator.platform)
797
+ // // iPad on iOS 13 detection
798
+ // || (navigator.userAgent.includes('Mac') && 'ontouchend' in document);
799
+ // }
800
+
750
801
  function getName(name, lang) {
751
802
  if (name && (0, _typeof2["default"])(name) === 'object') {
752
803
  return (name[lang] || name.en || '').toString();
@@ -1755,6 +1806,19 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
1755
1806
  var _this;
1756
1807
  (0, _classCallCheck2["default"])(this, ObjectBrowser);
1757
1808
  _this = _super.call(this, props);
1809
+ /**
1810
+ * Context menu handler.
1811
+ */
1812
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onContextMenu", function (e) {
1813
+ // console.log(`CONTEXT MENU: ${this.contextMenu ? Date.now() - this.contextMenu.ts : 'false'}`);
1814
+ if (_this.contextMenu && Date.now() - _this.contextMenu.ts < 2000) {
1815
+ e.preventDefault();
1816
+ _this.setState({
1817
+ showContextMenu: _this.contextMenu.item
1818
+ });
1819
+ }
1820
+ _this.contextMenu = null;
1821
+ });
1758
1822
  /**
1759
1823
  * Called when a state changes.
1760
1824
  * @param {string} id
@@ -2522,7 +2586,10 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2522
2586
  scrollBarWidth: 16,
2523
2587
  customDialog: customDialog,
2524
2588
  editObjectDialog: '',
2589
+ editObjectAlias: false,
2590
+ // open the edit object dialog on alias tab
2525
2591
  viewFileDialog: '',
2592
+ showAliasEditor: '',
2526
2593
  enumDialog: null,
2527
2594
  roleDialog: null,
2528
2595
  statesView: statesView,
@@ -2536,7 +2603,8 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2536
2603
  customColumnDialogValueChanged: false,
2537
2604
  showExportDialog: false,
2538
2605
  linesEnabled: (window._localStorage || window.localStorage).getItem("".concat(props.dialogName || 'App', ".lines")) === 'true',
2539
- showDescription: (window._localStorage || window.localStorage).getItem("".concat(props.dialogName || 'App', ".desc")) !== 'false'
2606
+ showDescription: (window._localStorage || window.localStorage).getItem("".concat(props.dialogName || 'App', ".desc")) !== 'false',
2607
+ showContextMenu: null
2540
2608
  };
2541
2609
  _this.edit = {};
2542
2610
  _this.texts = {
@@ -2827,7 +2895,8 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2827
2895
  this.props.socket.subscribeObject('*', this.onObjectChange);
2828
2896
  }
2829
2897
  objectsAlreadyLoaded = true;
2830
- case 4:
2898
+ window.addEventListener('contextmenu', this.onContextMenu, true);
2899
+ case 5:
2831
2900
  case "end":
2832
2901
  return _context4.stop();
2833
2902
  }
@@ -2847,6 +2916,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2847
2916
  var _this4 = this;
2848
2917
  this.filterTimer && clearTimeout(this.filterTimer);
2849
2918
  this.filterTimer = null;
2919
+ window.removeEventListener('contextmenu', this.onContextMenu, true);
2850
2920
  if (this.props.objectsWorker) {
2851
2921
  this.props.objectsWorker.unregisterHandler(this.onObjectChange, true);
2852
2922
  } else {
@@ -2861,13 +2931,13 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2861
2931
  this.subscribes = [];
2862
2932
  this.objects = {};
2863
2933
  }
2864
-
2934
+ }, {
2935
+ key: "refreshComponent",
2936
+ value:
2865
2937
  /**
2866
2938
  * Called when component is mounted.
2867
2939
  */
2868
- }, {
2869
- key: "refreshComponent",
2870
- value: function refreshComponent() {
2940
+ function refreshComponent() {
2871
2941
  var _this5 = this;
2872
2942
  // remove all subscribes
2873
2943
  this.subscribes.forEach(function (pattern) {
@@ -2935,7 +3005,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2935
3005
  */
2936
3006
  }, {
2937
3007
  key: "onSelect",
2938
- value: function onSelect(toggleItem, isDouble) {
3008
+ value: function onSelect(toggleItem, isDouble, cb) {
2939
3009
  var _this7 = this;
2940
3010
  if (!this.props.multiSelect) {
2941
3011
  if (this.objects[toggleItem] && (!this.props.types || this.props.types.includes(this.objects[toggleItem].type))) {
@@ -2945,7 +3015,8 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2945
3015
  selected: [toggleItem],
2946
3016
  selectedNonObject: ''
2947
3017
  }, function () {
2948
- return _this7.onAfterSelect(isDouble);
3018
+ _this7.onAfterSelect(isDouble);
3019
+ cb && cb();
2949
3020
  });
2950
3021
  } else if (isDouble && this.props.onSelect) {
2951
3022
  this.onAfterSelect(isDouble);
@@ -2956,7 +3027,8 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2956
3027
  selected: [],
2957
3028
  selectedNonObject: toggleItem
2958
3029
  }, function () {
2959
- return _this7.onAfterSelect();
3030
+ _this7.onAfterSelect();
3031
+ cb && cb();
2960
3032
  });
2961
3033
  }
2962
3034
  } else if (this.objects[toggleItem] && (!this.props.types || this.props.types.includes(this.objects[toggleItem].type))) {
@@ -2973,7 +3045,8 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2973
3045
  selected: selected,
2974
3046
  selectedNonObject: ''
2975
3047
  }, function () {
2976
- return _this7.onAfterSelect(isDouble);
3048
+ _this7.onAfterSelect(isDouble);
3049
+ cb && cb();
2977
3050
  });
2978
3051
  }
2979
3052
  }
@@ -4122,7 +4195,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
4122
4195
  */
4123
4196
  function renderColumnButtons(id, item, classes) {
4124
4197
  var _this27 = this,
4125
- _item$children2,
4198
+ _item$children3,
4126
4199
  _item$data$obj$common,
4127
4200
  _item$data$obj$common3;
4128
4201
  if (!item.data.obj) {
@@ -4143,6 +4216,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
4143
4216
  "aria-label": "delete",
4144
4217
  title: this.texts.deleteObject,
4145
4218
  onClick: function onClick() {
4219
+ var _item$children2;
4146
4220
  // calculate number of children
4147
4221
  var keys = Object.keys(_this27.objects);
4148
4222
  keys.sort();
@@ -4155,7 +4229,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
4155
4229
  break;
4156
4230
  }
4157
4231
  }
4158
- _this27.props.onObjectDelete(id, !!(item.children && item.children.length), false, count + 1);
4232
+ _this27.props.onObjectDelete(id, !!((_item$children2 = item.children) !== null && _item$children2 !== void 0 && _item$children2.length), false, count + 1);
4159
4233
  }
4160
4234
  }, /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Delete, {
4161
4235
  className: classes.cellButtonsButtonIcon
@@ -4193,18 +4267,19 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
4193
4267
  onClick: function onClick() {
4194
4268
  (window._localStorage || window.localStorage).setItem("".concat(_this27.props.dialogName || 'App', ".objectSelected"), id);
4195
4269
  _this27.setState({
4196
- editObjectDialog: id
4270
+ editObjectDialog: id,
4271
+ editObjectAlias: false
4197
4272
  });
4198
4273
  }
4199
4274
  }, /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Edit, {
4200
4275
  className: classes.cellButtonsButtonIcon
4201
- })), this.props.onObjectDelete && ((_item$children2 = item.children) !== null && _item$children2 !== void 0 && _item$children2.length || !((_item$data$obj$common = item.data.obj.common) !== null && _item$data$obj$common !== void 0 && _item$data$obj$common.dontDelete)) ? /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
4276
+ })), this.props.onObjectDelete && ((_item$children3 = item.children) !== null && _item$children3 !== void 0 && _item$children3.length || !((_item$data$obj$common = item.data.obj.common) !== null && _item$data$obj$common !== void 0 && _item$data$obj$common.dontDelete)) ? /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
4202
4277
  key: "delete",
4203
4278
  className: classes.cellButtonsButton,
4204
4279
  size: "small",
4205
4280
  "aria-label": "delete",
4206
4281
  onClick: function onClick() {
4207
- var _item$children3, _item$data$obj$common2;
4282
+ var _item$children4, _item$data$obj$common2;
4208
4283
  var keys = Object.keys(_this27.objects);
4209
4284
  keys.sort();
4210
4285
  var count = 0;
@@ -4216,7 +4291,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
4216
4291
  break;
4217
4292
  }
4218
4293
  }
4219
- _this27.props.onObjectDelete(id, !!((_item$children3 = item.children) !== null && _item$children3 !== void 0 && _item$children3.length), !((_item$data$obj$common2 = item.data.obj.common) !== null && _item$data$obj$common2 !== void 0 && _item$data$obj$common2.dontDelete), count);
4294
+ _this27.props.onObjectDelete(id, !!((_item$children4 = item.children) !== null && _item$children4 !== void 0 && _item$children4.length), !((_item$data$obj$common2 = item.data.obj.common) !== null && _item$data$obj$common2 !== void 0 && _item$data$obj$common2.dontDelete), count);
4220
4295
  },
4221
4296
  title: this.texts.deleteObject
4222
4297
  }, /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Delete, {
@@ -5086,8 +5161,25 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5086
5161
  className: _Utils["default"].clsx(classes.tableRow, this.state.linesEnabled && classes.tableRowLines, !this.props.dragEnabled && classes.tableRowNoDragging, alias && classes.tableRowAlias, readWriteAlias && classes.tableRowAliasReadWrite, !item.data.visible && classes.filteredOut, item.data.hasVisibleParent && !item.data.visible && !item.data.hasVisibleChildren && classes.filteredParentOut, this.state.selected.includes(id) && classes.itemSelected, this.state.selectedNonObject === id && classes.itemSelected),
5087
5162
  key: id,
5088
5163
  id: id,
5089
- onClick: function onClick() {
5090
- return _this36.onSelect(id);
5164
+ onMouseDown: function onMouseDown(e) {
5165
+ e.preventDefault();
5166
+ _this36.onSelect(id);
5167
+ var isRightMB;
5168
+ if ('which' in e) {
5169
+ // Gecko (Firefox), WebKit (Safari/Chrome) & Opera
5170
+ isRightMB = e.which === 3;
5171
+ } else if ('button' in e) {
5172
+ // IE, Opera
5173
+ isRightMB = e.button === 2;
5174
+ }
5175
+ if (isRightMB) {
5176
+ _this36.contextMenu = {
5177
+ item: item,
5178
+ ts: Date.now()
5179
+ };
5180
+ } else {
5181
+ _this36.contextMenu = null;
5182
+ }
5091
5183
  },
5092
5184
  onDoubleClick: function onDoubleClick() {
5093
5185
  if (!item.children) {
@@ -5801,12 +5893,14 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5801
5893
  themeName: this.props.themeName,
5802
5894
  socket: this.props.socket,
5803
5895
  dialogName: this.props.dialogName,
5896
+ aliasTab: this.state.editObjectAlias,
5804
5897
  t: this.props.t,
5805
5898
  expertMode: this.state.filter.expertMode,
5806
5899
  onNewObject: function onNewObject(obj) {
5807
5900
  return _this44.props.socket.setObject(obj._id, obj).then(function () {
5808
5901
  return _this44.setState({
5809
- editObjectDialog: obj._id
5902
+ editObjectDialog: obj._id,
5903
+ editObjectAlias: false
5810
5904
  }, function () {
5811
5905
  return _this44.onSelect(obj._id);
5812
5906
  });
@@ -5835,7 +5929,8 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5835
5929
  });
5836
5930
  }
5837
5931
  _this44.setState({
5838
- editObjectDialog: ''
5932
+ editObjectDialog: '',
5933
+ editObjectAlias: false
5839
5934
  });
5840
5935
  }
5841
5936
  });
@@ -5869,6 +5964,327 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5869
5964
  });
5870
5965
  }
5871
5966
 
5967
+ /**
5968
+ * @private
5969
+ * @returns {JSX.Element | null}
5970
+ */
5971
+ }, {
5972
+ key: "renderAliasEditorDialog",
5973
+ value: function renderAliasEditorDialog() {
5974
+ var _this46 = this;
5975
+ if (!this.props.objectBrowserAliasEditor || !this.state.showAliasEditor) {
5976
+ return null;
5977
+ }
5978
+ var ObjectBrowserAliasEditor = this.props.objectBrowserAliasEditor;
5979
+ return /*#__PURE__*/_react["default"].createElement(ObjectBrowserAliasEditor, {
5980
+ key: "editAlias",
5981
+ obj: this.objects[this.state.showAliasEditor],
5982
+ objects: this.objects,
5983
+ themeType: this.props.themeType,
5984
+ socket: this.props.socket,
5985
+ dialogName: this.props.dialogName,
5986
+ t: this.props.t,
5987
+ expertMode: this.state.filter.expertMode,
5988
+ onClose: function onClose() {
5989
+ return _this46.setState({
5990
+ showAliasEditor: ''
5991
+ });
5992
+ },
5993
+ onRedirect: function onRedirect(id) {
5994
+ return _this46.setState({
5995
+ editObjectDialog: id,
5996
+ showAliasEditor: false,
5997
+ editObjectAlias: true
5998
+ });
5999
+ }
6000
+ });
6001
+ }
6002
+
6003
+ /**
6004
+ * @private
6005
+ * @returns {JSX.Element | null}
6006
+ */
6007
+ }, {
6008
+ key: "renderContextMenu",
6009
+ value: function renderContextMenu() {
6010
+ var _this47 = this,
6011
+ _obj$common6,
6012
+ _obj$common7,
6013
+ _obj$common8,
6014
+ _obj$common9,
6015
+ _obj$common10,
6016
+ _item$children5,
6017
+ _obj$common12;
6018
+ if (!this.state.showContextMenu) {
6019
+ return null;
6020
+ }
6021
+ var item = this.state.showContextMenu;
6022
+ var id = item.data.id;
6023
+ var items = [];
6024
+ // const ctrl = isIOS() ? '⌘' : (this.props.lang === 'de' ? 'Strg+' : 'Ctrl+');
6025
+
6026
+ var obj = item.data.obj;
6027
+ var showACL = '';
6028
+ if (this.props.objectEditOfAccessControl && this.state.filter.expertMode) {
6029
+ if (!obj) {
6030
+ showACL = '---';
6031
+ } else {
6032
+ var acl = obj.acl ? obj.type === 'state' ? obj.acl.state : obj.acl.object : 0;
6033
+ var aclSystemConfig = obj.acl && (obj.type === 'state' ? this.systemConfig.common.defaultNewAcl.state : this.systemConfig.common.defaultNewAcl.object);
6034
+ showACL = Number.isNaN(Number(acl)) ? Number(aclSystemConfig).toString(16) : Number(acl).toString(16);
6035
+ }
6036
+ }
6037
+ var enumEditable = !this.props.notEditable && obj && (this.state.filter.expertMode || obj.type === 'state' || obj.type === 'channel' || obj.type === 'device');
6038
+ var ITEMS = {
6039
+ EDIT: {
6040
+ key: '0',
6041
+ visibility: this.props.objectBrowserEditObject && obj,
6042
+ icon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Edit, {
6043
+ fontSize: "small",
6044
+ className: this.props.classes.contextMenuEdit
6045
+ }),
6046
+ label: this.texts.editObject,
6047
+ onClick: function onClick() {
6048
+ return _this47.setState({
6049
+ editObjectDialog: item.data.id,
6050
+ showContextMenu: null,
6051
+ editObjectAlias: false
6052
+ });
6053
+ }
6054
+ },
6055
+ EDIT_VALUE: {
6056
+ key: '1',
6057
+ visibility: this.states && !this.props.notEditable && obj && obj.type === 'state' && ((_obj$common6 = obj.common) === null || _obj$common6 === void 0 ? void 0 : _obj$common6.type) !== 'file' && (this.state.filter.expertMode || obj.common.write !== false),
6058
+ icon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.FormatItalic, {
6059
+ fontSize: "small",
6060
+ className: this.props.classes.contextMenuEditValue
6061
+ }),
6062
+ label: this.props.t('ra_Edit value'),
6063
+ onClick: function onClick() {
6064
+ _this47.edit = {
6065
+ val: _this47.states[id] ? _this47.states[id].val : '',
6066
+ q: _this47.states[id] ? _this47.states[id].q || 0 : 0,
6067
+ ack: false,
6068
+ id: id
6069
+ };
6070
+ _this47.setState({
6071
+ updateOpened: true,
6072
+ showContextMenu: null
6073
+ });
6074
+ }
6075
+ },
6076
+ VIEW: {
6077
+ visibility: this.props.objectBrowserViewFile && obj && obj.type === 'state' && ((_obj$common7 = obj.common) === null || _obj$common7 === void 0 ? void 0 : _obj$common7.type) === 'file',
6078
+ icon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.FindInPage, {
6079
+ fontSize: "small",
6080
+ className: this.props.classes.contextMenuView
6081
+ }),
6082
+ className: '',
6083
+ label: this.props.t('ra_View file'),
6084
+ onClick: function onClick() {
6085
+ return _this47.setState({
6086
+ viewFileDialog: obj._id,
6087
+ showContextMenu: null
6088
+ });
6089
+ }
6090
+ },
6091
+ CUSTOM: {
6092
+ key: '2',
6093
+ visibility: this.props.objectCustomDialog && this.info.hasSomeCustoms && obj && obj.type === 'state' && ((_obj$common8 = obj.common) === null || _obj$common8 === void 0 ? void 0 : _obj$common8.type) !== 'file',
6094
+ icon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Settings, {
6095
+ fontSize: "small",
6096
+ className: item.data.hasCustoms ? this.props.classes.cellButtonsButtonWithCustoms : this.props.classes.cellButtonsButtonWithoutCustoms
6097
+ }),
6098
+ className: this.props.classes.contextMenuCustom,
6099
+ label: this.texts.customConfig,
6100
+ onClick: function onClick() {
6101
+ _this47.pauseSubscribe(true);
6102
+ _this47.props.router && _this47.props.router.doNavigate(null, 'customs', id);
6103
+ _this47.setState({
6104
+ customDialog: [id],
6105
+ showContextMenu: null
6106
+ });
6107
+ }
6108
+ },
6109
+ ACL: {
6110
+ key: '3',
6111
+ visibility: !!showACL,
6112
+ icon: showACL,
6113
+ iconStyle: {
6114
+ fontSize: 'smaller'
6115
+ },
6116
+ listItemIconClass: this.props.classes.contextMenuACL,
6117
+ className: this.props.classes.contextMenuACL,
6118
+ label: this.props.t('ra_Edit ACL'),
6119
+ onClick: function onClick() {
6120
+ return _this47.setState({
6121
+ showContextMenu: null,
6122
+ modalEditOfAccess: true,
6123
+ modalEditOfAccessObjData: item.data
6124
+ });
6125
+ }
6126
+ },
6127
+ ROLE: {
6128
+ key: '4',
6129
+ visibility: this.state.filter.expertMode && enumEditable && this.props.objectBrowserEditRole,
6130
+ icon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.BorderColor, {
6131
+ fontSize: "small",
6132
+ className: this.props.classes.contextMenuRole
6133
+ }),
6134
+ className: '',
6135
+ label: this.props.t('ra_Edit role'),
6136
+ onClick: function onClick() {
6137
+ return _this47.setState({
6138
+ roleDialog: item.data.id,
6139
+ showContextMenu: null
6140
+ });
6141
+ }
6142
+ },
6143
+ FUNCTION: {
6144
+ key: '5',
6145
+ visibility: enumEditable,
6146
+ icon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.BedroomParent, {
6147
+ fontSize: "small",
6148
+ className: this.props.classes.contextMenuRole
6149
+ }),
6150
+ className: '',
6151
+ label: this.props.t('ra_Edit function'),
6152
+ onClick: function onClick() {
6153
+ var enums = findEnumsForObjectAsIds(_this47.info, item.data.id, 'funcEnums');
6154
+ _this47.setState({
6155
+ enumDialogEnums: enums,
6156
+ enumDialog: {
6157
+ item: item,
6158
+ type: 'func',
6159
+ enumsOriginal: JSON.parse(JSON.stringify(enums))
6160
+ },
6161
+ showContextMenu: null
6162
+ });
6163
+ }
6164
+ },
6165
+ ROOM: {
6166
+ key: '6',
6167
+ visibility: enumEditable,
6168
+ icon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Construction, {
6169
+ fontSize: "small",
6170
+ className: this.props.classes.contextMenuRoom
6171
+ }),
6172
+ className: '',
6173
+ label: this.props.t('ra_Edit room'),
6174
+ onClick: function onClick() {
6175
+ var enums = findEnumsForObjectAsIds(_this47.info, item.data.id, 'roomEnums');
6176
+ _this47.setState({
6177
+ enumDialogEnums: enums,
6178
+ enumDialog: {
6179
+ item: item,
6180
+ type: 'room',
6181
+ enumsOriginal: JSON.parse(JSON.stringify(enums))
6182
+ },
6183
+ showContextMenu: null
6184
+ });
6185
+ }
6186
+ },
6187
+ ALIAS: {
6188
+ key: '7',
6189
+ visibility: !this.props.notEditable && this.props.objectBrowserAliasEditor && this.props.objectBrowserEditObject && this.state.filter.expertMode && obj && obj.type === 'state' && ((_obj$common9 = obj.common) === null || _obj$common9 === void 0 ? void 0 : _obj$common9.type) !== 'file',
6190
+ icon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Link, {
6191
+ className: obj !== null && obj !== void 0 && (_obj$common10 = obj.common) !== null && _obj$common10 !== void 0 && _obj$common10.alias ? this.props.classes.cellButtonsButtonWithCustoms : this.props.classes.cellButtonsButtonWithoutCustoms
6192
+ }),
6193
+ className: '',
6194
+ label: this.props.t('ra_Edit alias'),
6195
+ onClick: function onClick() {
6196
+ var _obj$common11;
6197
+ if ((_obj$common11 = obj.common) !== null && _obj$common11 !== void 0 && _obj$common11.alias) {
6198
+ _this47.setState({
6199
+ editObjectDialog: item.data.id,
6200
+ showContextMenu: null,
6201
+ editObjectAlias: true
6202
+ });
6203
+ } else {
6204
+ _this47.setState({
6205
+ showContextMenu: null,
6206
+ showAliasEditor: item.data.id
6207
+ });
6208
+ }
6209
+ }
6210
+ },
6211
+ DELETE: {
6212
+ key: 'Delete',
6213
+ visibility: this.props.onObjectDelete && (((_item$children5 = item.children) === null || _item$children5 === void 0 ? void 0 : _item$children5.length) || obj && !((_obj$common12 = obj.common) !== null && _obj$common12 !== void 0 && _obj$common12.dontDelete)),
6214
+ icon: /*#__PURE__*/_react["default"].createElement(_iconsMaterial.Delete, {
6215
+ fontSize: "small",
6216
+ className: this.props.classes.contextMenuDelete
6217
+ }),
6218
+ className: this.props.classes.contextMenuDelete,
6219
+ label: this.texts.deleteObject,
6220
+ onClick: function onClick() {
6221
+ _this47.setState({
6222
+ showContextMenu: null
6223
+ }, function () {
6224
+ var _item$children6, _obj$common13;
6225
+ // calculate number of children
6226
+ var keys = Object.keys(_this47.objects);
6227
+ keys.sort();
6228
+ var count = 0;
6229
+ var start = "".concat(id, ".");
6230
+ for (var i = 0; i < keys.length; i++) {
6231
+ if (keys[i].startsWith(start)) {
6232
+ count++;
6233
+ } else if (keys[i] > start) {
6234
+ break;
6235
+ }
6236
+ }
6237
+ _this47.props.onObjectDelete(id, !!((_item$children6 = item.children) !== null && _item$children6 !== void 0 && _item$children6.length), !((_obj$common13 = obj.common) !== null && _obj$common13 !== void 0 && _obj$common13.dontDelete), count + 1);
6238
+ });
6239
+ }
6240
+ }
6241
+ };
6242
+ Object.keys(ITEMS).forEach(function (key) {
6243
+ if (ITEMS[key].visibility) {
6244
+ items.push( /*#__PURE__*/_react["default"].createElement(_material.MenuItem, {
6245
+ key: key,
6246
+ onClick: ITEMS[key].onClick,
6247
+ className: ITEMS[key].className
6248
+ }, /*#__PURE__*/_react["default"].createElement(_material.ListItemIcon, {
6249
+ style: ITEMS[key].iconStyle,
6250
+ className: ITEMS[key].listItemIconClass
6251
+ }, ITEMS[key].icon), /*#__PURE__*/_react["default"].createElement(_material.ListItemText, null, ITEMS[key].label), ITEMS[key].key ? /*#__PURE__*/_react["default"].createElement("div", {
6252
+ className: _this47.props.classes.contextMenuKeys
6253
+ }, "Alt+".concat(ITEMS[key].key === 'Delete' ? _this47.props.t('ra_Del') : ITEMS[key].key)) : null));
6254
+ }
6255
+ });
6256
+ if (!items.length) {
6257
+ setTimeout(function () {
6258
+ return _this47.setState({
6259
+ showContextMenu: null
6260
+ });
6261
+ }, 100);
6262
+ return null;
6263
+ }
6264
+ var el = document.getElementById(id);
6265
+ return /*#__PURE__*/_react["default"].createElement(_material.Menu, {
6266
+ key: "contextMenu",
6267
+ open: !0,
6268
+ onKeyUp: function onKeyUp(e) {
6269
+ e.preventDefault();
6270
+ if (e.altKey) {
6271
+ Object.keys(ITEMS).forEach(function (key) {
6272
+ if (e.key === ITEMS[key].key) {
6273
+ ITEMS[key].onClick();
6274
+ }
6275
+ });
6276
+ }
6277
+ },
6278
+ anchorEl: el,
6279
+ onClose: function onClose() {
6280
+ _this47.setState({
6281
+ showContextMenu: null
6282
+ });
6283
+ _this47.contextMenu = null;
6284
+ }
6285
+ }, items);
6286
+ }
6287
+
5872
6288
  /**
5873
6289
  * @private
5874
6290
  * @returns {JSX.Element | null}
@@ -5877,7 +6293,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5877
6293
  key: "renderEditValueDialog",
5878
6294
  value: function renderEditValueDialog() {
5879
6295
  var _this$objects$this$ed,
5880
- _this46 = this;
6296
+ _this48 = this;
5881
6297
  if (!this.state.updateOpened || !this.props.objectBrowserValue) {
5882
6298
  return null;
5883
6299
  }
@@ -5904,22 +6320,14 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5904
6320
  defaultHistory: this.defaultHistory,
5905
6321
  dateFormat: this.props.dateFormat,
5906
6322
  onClose: function onClose(res) {
5907
- _this46.setState({
6323
+ _this48.setState({
5908
6324
  updateOpened: false
5909
6325
  });
5910
- res && _this46.onUpdate(res);
6326
+ res && _this48.onUpdate(res);
5911
6327
  }
5912
6328
  });
5913
6329
  }
5914
6330
 
5915
- // extendObject = (id, data) =>
5916
- // this.props.socket.extendObject(id, data)
5917
- // .catch(error => window.alert(error));
5918
-
5919
- // setObject = (id, data) =>
5920
- // this.props.socket.setObject(id, data)
5921
- // .catch(error => window.alert(error));
5922
-
5923
6331
  /**
5924
6332
  * The rendering method of this component.
5925
6333
  * @returns {JSX.Element}
@@ -5927,7 +6335,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5927
6335
  }, {
5928
6336
  key: "render",
5929
6337
  value: function render() {
5930
- var _this47 = this;
6338
+ var _this49 = this;
5931
6339
  this.recordStates = [];
5932
6340
  this.unsubscribeTimer && clearTimeout(this.unsubscribeTimer);
5933
6341
 
@@ -5940,13 +6348,13 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5940
6348
  applyFilter(this.root, this.state.filter, this.props.lang, this.objects, null, counter, this.props.customFilter, this.props.types);
5941
6349
  if (counter.count < 500 && !this.state.expandAllVisible) {
5942
6350
  setTimeout(function () {
5943
- return _this47.setState({
6351
+ return _this49.setState({
5944
6352
  expandAllVisible: true
5945
6353
  });
5946
6354
  });
5947
6355
  } else if (counter.count >= 500 && this.state.expandAllVisible) {
5948
6356
  setTimeout(function () {
5949
- return _this47.setState({
6357
+ return _this49.setState({
5950
6358
  expandAllVisible: false
5951
6359
  });
5952
6360
  });
@@ -5954,8 +6362,8 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5954
6362
  this.lastAppliedFilter = jsonFilter;
5955
6363
  }
5956
6364
  this.unsubscribeTimer = setTimeout(function () {
5957
- _this47.unsubscribeTimer = null;
5958
- _this47.checkUnsubscribes();
6365
+ _this49.unsubscribeTimer = null;
6366
+ _this49.checkUnsubscribes();
5959
6367
  }, 200);
5960
6368
  if (!this.state.loaded) {
5961
6369
  return /*#__PURE__*/_react["default"].createElement(_material.CircularProgress, {
@@ -5968,7 +6376,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5968
6376
  key: this.props.dialogName,
5969
6377
  classes: {},
5970
6378
  onKeyDown: function onKeyDown(event) {
5971
- return _this47.navigateKeyPress(event);
6379
+ return _this49.navigateKeyPress(event);
5972
6380
  },
5973
6381
  tabIndex: 0
5974
6382
  }, /*#__PURE__*/_react["default"].createElement(_TabHeader["default"], null, this.getToolbar()), /*#__PURE__*/_react["default"].createElement(_TabContent["default"], {
@@ -5976,7 +6384,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5976
6384
  }, this.renderHeader(), /*#__PURE__*/_react["default"].createElement("div", {
5977
6385
  className: this.props.classes.tableDiv,
5978
6386
  ref: this.tableRef
5979
- }, 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));
6387
+ }, items)), this.renderContextMenu(), this.renderToast(), this.renderColumnsEditCustomDialog(), this.renderColumnsSelectorDialog(), this.renderCustomDialog(), this.renderEditValueDialog(), this.renderEditObjectDialog(), this.renderViewObjectFileDialog(), this.renderAliasEditorDialog(), 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));
5980
6388
  }
5981
6389
  }], [{
5982
6390
  key: "getDerivedStateFromProps",
@@ -6123,18 +6531,20 @@ ObjectBrowser.propTypes = {
6123
6531
  // optional function (id, hasChildren, objectExists, childrenCount+1) { }
6124
6532
  customFilter: _propTypes["default"].object,
6125
6533
  // optional
6126
- // `{common: {custom: true}}` - show only objects with some custom settings
6127
- // `{common: {custom: 'sql.0'}}` - show only objects with sql.0 custom settings (only of the specific instance)
6128
- // `{common: {custom: '_dataSources'}}` - show only objects of adapters `influxdb' or 'sql' or 'history'
6129
- // `{common: {custom: 'adapterName.'}}` - show only objects of custom settings of specific adapter (all instances)
6130
- // `{type: 'channel'}` - show only channels
6131
- // `{type: ['channel', 'device']}` - show only channels and devices
6132
- // `{common: {type: 'number'}` - show only states of type 'number
6133
- // `{common: {type: ['number', 'string']}` - show only states of type 'number and string
6134
- // `{common: {role: 'switch']}` - show only states with roles starting from switch
6135
- // `{common: {role: ['switch', 'button]}` - show only states with roles starting from `switch` and `button`
6534
+ // `{common: {custom: true}}` - show only objects with some custom settings
6535
+ // `{common: {custom: 'sql.0'}}` - show only objects with sql.0 custom settings (only of the specific instance)
6536
+ // `{common: {custom: '_dataSources'}}` - show only objects of adapters `influxdb' or 'sql' or 'history'
6537
+ // `{common: {custom: 'adapterName.'}}` - show only objects of custom settings of specific adapter (all instances)
6538
+ // `{type: 'channel'}` - show only channels
6539
+ // `{type: ['channel', 'device']}` - show only channels and devices
6540
+ // `{common: {type: 'number'}` - show only states of type 'number
6541
+ // `{common: {type: ['number', 'string']}` - show only states of type 'number and string
6542
+ // `{common: {role: 'switch']}` - show only states with roles starting from switch
6543
+ // `{common: {role: ['switch', 'button]}` - show only states with roles starting from `switch` and `button`
6136
6544
  objectBrowserValue: _propTypes["default"].object,
6137
6545
  objectBrowserEditObject: _propTypes["default"].object,
6546
+ objectBrowserAliasEditor: _propTypes["default"].func,
6547
+ // on edit alias
6138
6548
  objectBrowserEditRole: _propTypes["default"].object,
6139
6549
  // on Edit role
6140
6550
  objectBrowserViewFile: _propTypes["default"].func,
@@ -6152,7 +6562,7 @@ ObjectBrowser.propTypes = {
6152
6562
  // optional cache of objects
6153
6563
  filterFunc: _propTypes["default"].func,
6154
6564
  // function to filter out all unnecessary objects. It cannot be used together with "types"
6155
- // Example for function: `obj => obj.common && obj.common.type === 'boolean'` to show only boolean states
6565
+ // Example for function: `obj => obj.common && obj.common.type === 'boolean'` to show only boolean states
6156
6566
 
6157
6567
  DragWrapper: _propTypes["default"].func,
6158
6568
  dragEnabled: _propTypes["default"].bool