@iobroker/adapter-react-v5 3.1.0 → 3.1.3

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.
@@ -163,6 +163,8 @@ var _IconDevice = _interopRequireDefault(require("../icons/IconDevice"));
163
163
 
164
164
  var _IconDocument = _interopRequireDefault(require("../icons/IconDocument"));
165
165
 
166
+ var _IconDocumentReadOnly = _interopRequireDefault(require("../icons/IconDocumentReadOnly"));
167
+
166
168
  var _IconInstance = _interopRequireDefault(require("../icons/IconInstance"));
167
169
 
168
170
  var _IconState = _interopRequireDefault(require("../icons/IconState"));
@@ -286,7 +288,8 @@ var styles = function styles(theme) {
286
288
  headerRow: {
287
289
  paddingLeft: theme.spacing(1),
288
290
  height: 38,
289
- whiteSpace: 'nowrap'
291
+ whiteSpace: 'nowrap',
292
+ userSelect: 'none'
290
293
  },
291
294
  buttonClearFilter: {
292
295
  position: 'relative',
@@ -517,19 +520,6 @@ var styles = function styles(theme) {
517
520
  display: 'block'
518
521
  }
519
522
  },
520
- cellValueWritable: {
521
- '&:after': {
522
- content: '"*"',
523
- color: theme.palette.mode === 'dark' ? 'white' : 'black',
524
- position: 'absolute',
525
- zIndex: 1,
526
- top: -6,
527
- left: 0,
528
- fontSize: 9,
529
- width: 4,
530
- height: 4
531
- }
532
- },
533
523
  cellValueFile: {
534
524
  color: '#2837b9'
535
525
  },
@@ -796,6 +786,39 @@ var styles = function styles(theme) {
796
786
  top: 4,
797
787
  right: 50,
798
788
  width: 20
789
+ },
790
+ resizeHandle: {
791
+ display: 'block',
792
+ position: 'absolute',
793
+ cursor: 'col-resize',
794
+ width: 7,
795
+ top: 2,
796
+ bottom: 2,
797
+ zIndex: 1
798
+ },
799
+ resizeHandleRight: {
800
+ right: 3,
801
+ borderRight: '2px dotted #888',
802
+ '&:hover': {
803
+ borderColor: '#ccc',
804
+ borderRightStyle: 'solid'
805
+ },
806
+ '&.active': {
807
+ borderColor: '#517ea5',
808
+ borderRightStyle: 'solid'
809
+ }
810
+ },
811
+ resizeHandleLeft: {
812
+ left: -4,
813
+ borderLeft: '2px dotted #888',
814
+ '&:hover': {
815
+ borderColor: '#ccc',
816
+ borderLeftStyle: 'solid'
817
+ },
818
+ '&.active': {
819
+ borderColor: '#517ea5',
820
+ borderLeftStyle: 'solid'
821
+ }
799
822
  }
800
823
  };
801
824
  };
@@ -894,7 +917,7 @@ function applyFilter(item, filters, lang, objects, context, counter, customFilte
894
917
 
895
918
  if (!filteredOut && !filters.expertMode) {
896
919
  filteredOut = data.id === 'system' || data.id === 'enum' || // (data.obj && data.obj.type === 'meta') ||
897
- data.id.startsWith('system.') || data.id.startsWith('enum.') || data.id.startsWith('_design/') || common && common.expert;
920
+ data.id.startsWith('system.') || data.id.startsWith('enum.') || data.id.startsWith('_design/') || data.id.endsWith('.admin') || common && common.expert;
898
921
  }
899
922
 
900
923
  if (!filteredOut && context.id) {
@@ -1795,7 +1818,7 @@ var SCREEN_WIDTHS = {
1795
1818
  ///////////////
1796
1819
  // extra-large: 1920px
1797
1820
  xl: {
1798
- idWidth: 650,
1821
+ idWidth: 550,
1799
1822
  fields: ['name', 'type', 'role', 'room', 'func', 'val', 'buttons', 'changedFrom', 'qualityCode', 'timestamp', 'lastChange'],
1800
1823
  widths: {
1801
1824
  name: 400,
@@ -2438,6 +2461,111 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2438
2461
  return el;
2439
2462
  })) : '';
2440
2463
  });
2464
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resizerMouseMove", function (e) {
2465
+ if (_this.resizerActiveDiv) {
2466
+ var width;
2467
+ var widthNext;
2468
+
2469
+ if (_this.resizeLeft) {
2470
+ width = _this.resizerOldWidth - e.clientX + _this.resizerPosition;
2471
+ widthNext = _this.resizerOldWidthNext + e.clientX - _this.resizerPosition;
2472
+ } else {
2473
+ width = _this.resizerOldWidth + e.clientX - _this.resizerPosition;
2474
+ widthNext = _this.resizerOldWidthNext - e.clientX + _this.resizerPosition;
2475
+ }
2476
+
2477
+ if ((!_this.resizerMin || width > _this.resizerMin) && (!_this.resizerNextMin || widthNext > _this.resizerNextMin)) {
2478
+ _this.resizerCurrentWidths[_this.resizerActiveName] = width;
2479
+ _this.resizerCurrentWidths[_this.resizerNextName] = widthNext;
2480
+ _this.resizerActiveDiv.style.width = width + 'px';
2481
+ _this.resizerNextDiv.style.width = widthNext + 'px';
2482
+ _this.columnsVisibility[_this.resizerActiveName] = width;
2483
+ _this.columnsVisibility[_this.resizerNextName] = widthNext;
2484
+
2485
+ if (_this.resizerNextName === 'nameHeader') {
2486
+ _this.columnsVisibility['name'] = widthNext - _this.state.scrollBarWidth;
2487
+ _this.resizerCurrentWidths['name'] = widthNext - _this.state.scrollBarWidth;
2488
+ } else if (_this.resizerActiveName === 'nameHeader') {
2489
+ _this.columnsVisibility['name'] = width - _this.state.scrollBarWidth;
2490
+ _this.resizerCurrentWidths['name'] = width - _this.state.scrollBarWidth;
2491
+ }
2492
+
2493
+ _this.customWidth = true;
2494
+ _this.resizeTimeout && clearTimeout(_this.resizeTimeout);
2495
+ _this.resizeTimeout = setTimeout(function () {
2496
+ _this.resizeTimeout = null;
2497
+
2498
+ _this.forceUpdate();
2499
+ }, 200);
2500
+ }
2501
+ }
2502
+ });
2503
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resizerMouseUp", function () {
2504
+ window.localStorage.setItem("".concat(_this.props.dialogName || 'App', ".table"), JSON.stringify(_this.resizerCurrentWidths));
2505
+ _this.resizerActiveName = null;
2506
+ _this.resizerNextName = null;
2507
+ _this.resizerActiveDiv = null;
2508
+ _this.resizerNextDiv = null;
2509
+ window.removeEventListener('mousemove', _this.resizerMouseMove);
2510
+ window.removeEventListener('mouseup', _this.resizerMouseUp);
2511
+ });
2512
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resizerMouseDown", function (e) {
2513
+ if (_this.resizerActiveIndex === null || _this.resizerActiveIndex === undefined) {
2514
+ if (!_this.storedWidths) {
2515
+ _this.storedWidths = JSON.parse(JSON.stringify(SCREEN_WIDTHS[_this.props.width]));
2516
+ }
2517
+
2518
+ _this.resizerCurrentWidths = _this.resizerCurrentWidths || {};
2519
+ _this.resizerActiveDiv = e.target.parentNode;
2520
+ _this.resizerActiveName = _this.resizerActiveDiv.dataset.name;
2521
+ var i = 0;
2522
+
2523
+ if (e.target.dataset.left === 'true') {
2524
+ _this.resizeLeft = true;
2525
+ _this.resizerNextDiv = _this.resizerActiveDiv.previousElementSibling;
2526
+
2527
+ var handle = _this.resizerNextDiv.querySelector('.' + _this.props.classes.resizeHandle);
2528
+
2529
+ while (_this.resizerNextDiv && !handle && i < 10) {
2530
+ _this.resizerNextDiv = _this.resizerNextDiv.previousElementSibling;
2531
+ handle = _this.resizerNextDiv.querySelector('.' + _this.props.classes.resizeHandle);
2532
+ i++;
2533
+ }
2534
+
2535
+ if (handle && handle.dataset.left !== 'true') {
2536
+ _this.resizerNextDiv = _this.resizerNextDiv.nextElementSibling;
2537
+ }
2538
+ } else {
2539
+ _this.resizeLeft = false;
2540
+ _this.resizerNextDiv = _this.resizerActiveDiv.nextElementSibling;
2541
+ /*while (this.resizerNextDiv && !this.resizerNextDiv.querySelector('.' + this.props.classes.resizeHandle) && i < 10) {
2542
+ this.resizerNextDiv = this.resizerNextDiv.nextElementSibling;
2543
+ i++;
2544
+ }*/
2545
+ }
2546
+
2547
+ _this.resizerNextName = _this.resizerNextDiv.dataset.name;
2548
+ _this.resizerMin = parseInt(_this.resizerActiveDiv.dataset.min, 10) || 0;
2549
+ _this.resizerNextMin = parseInt(_this.resizerNextDiv.dataset.min, 10) || 0;
2550
+ _this.resizerPosition = e.clientX;
2551
+ _this.resizerCurrentWidths[_this.resizerActiveName] = _this.resizerActiveDiv.offsetWidth;
2552
+ _this.resizerCurrentWidths[_this.resizerNextName] = _this.resizerNextDiv.offsetWidth;
2553
+ _this.resizerOldWidth = _this.resizerCurrentWidths[_this.resizerActiveName];
2554
+ _this.resizerOldWidthNext = _this.resizerCurrentWidths[_this.resizerNextName];
2555
+ window.addEventListener('mousemove', _this.resizerMouseMove);
2556
+ window.addEventListener('mouseup', _this.resizerMouseUp);
2557
+ }
2558
+ });
2559
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resizerReset", function () {
2560
+ _this.customWidth = false;
2561
+ SCREEN_WIDTHS[_this.props.width] = JSON.parse(JSON.stringify(_this.storedWidths));
2562
+
2563
+ _this.calculateColumnsVisibility();
2564
+
2565
+ window.localStorage.removeItem("".concat(_this.props.dialogName || 'App', ".table"));
2566
+
2567
+ _this.forceUpdate();
2568
+ });
2441
2569
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "extendObject", function (id, data) {
2442
2570
  return _this.props.socket.extendObject(id, data)["catch"](function (error) {
2443
2571
  return window.alert(error);
@@ -2553,7 +2681,13 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2553
2681
  foldersFirst = props.foldersFirst === undefined ? true : props.foldersFirst;
2554
2682
  }
2555
2683
 
2556
- var statesView = _this.props.objectStatesView ? JSON.parse(window.localStorage.getItem((props.dialogName || 'App') + '.objectStatesView')) || false : false;
2684
+ var statesView = false;
2685
+
2686
+ try {
2687
+ statesView = _this.props.objectStatesView ? JSON.parse(window.localStorage.getItem((props.dialogName || 'App') + '.objectStatesView')) || false : false;
2688
+ } catch (error) {// ignore
2689
+ }
2690
+
2557
2691
  _this.state = {
2558
2692
  loaded: false,
2559
2693
  foldersFirst: foldersFirst,
@@ -2637,6 +2771,25 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
2637
2771
  aclEveryone_write_state: props.t('ra_aclEveryone_write_state')
2638
2772
  };
2639
2773
  _this.levelPadding = props.levelPadding || ITEM_LEVEL;
2774
+ var resizerCurrentWidths = window.localStorage.getItem("".concat(_this.props.dialogName || 'App', ".table"));
2775
+
2776
+ if (resizerCurrentWidths) {
2777
+ try {
2778
+ resizerCurrentWidths = JSON.parse(resizerCurrentWidths);
2779
+ _this.storedWidths = JSON.parse(JSON.stringify(SCREEN_WIDTHS[_this.props.width]));
2780
+ Object.keys(resizerCurrentWidths).forEach(function (id) {
2781
+ if (id === 'id') {
2782
+ SCREEN_WIDTHS[_this.props.width].idWidth = resizerCurrentWidths.id;
2783
+ } else if (id === 'nameHeader') {
2784
+ SCREEN_WIDTHS[_this.props.width].widths['name'] = resizerCurrentWidths[id];
2785
+ } else if (SCREEN_WIDTHS[_this.props.width].widths[id] !== undefined) {
2786
+ SCREEN_WIDTHS[_this.props.width].widths[id] = resizerCurrentWidths[id];
2787
+ }
2788
+ });
2789
+ _this.customWidth = true;
2790
+ } catch (e) {// ignore
2791
+ }
2792
+ }
2640
2793
 
2641
2794
  _this.calculateColumnsVisibility();
2642
2795
 
@@ -4558,7 +4711,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
4558
4711
  }
4559
4712
  }, /*#__PURE__*/_react["default"].createElement("div", {
4560
4713
  style: info.style,
4561
- className: _Utils["default"].clsx(classes.cellValueText, obj.common && obj.common.write !== false && classes.cellValueWritable)
4714
+ className: classes.cellValueText
4562
4715
  }, val));
4563
4716
  }
4564
4717
  /**
@@ -5081,9 +5234,15 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5081
5234
  }
5082
5235
  });
5083
5236
  } else {
5084
- iconFolder = /*#__PURE__*/_react["default"].createElement(_IconDocument["default"], {
5085
- className: classes.cellIdIconDocument
5086
- });
5237
+ if (obj.common && obj.common.write === false && obj.type === 'state') {
5238
+ iconFolder = /*#__PURE__*/_react["default"].createElement(_IconDocumentReadOnly["default"], {
5239
+ className: classes.cellIdIconDocument
5240
+ });
5241
+ } else {
5242
+ iconFolder = /*#__PURE__*/_react["default"].createElement(_IconDocument["default"], {
5243
+ className: classes.cellIdIconDocument
5244
+ });
5245
+ }
5087
5246
  }
5088
5247
 
5089
5248
  var iconItem = null;
@@ -5648,6 +5807,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5648
5807
  this.columnsVisibility = {
5649
5808
  id: SCREEN_WIDTHS[this.props.width].idWidth,
5650
5809
  name: this.visibleCols.includes('name') ? WIDTHS.name || 0 : 0,
5810
+ nameHeader: this.visibleCols.includes('name') ? WIDTHS.name || 0 : 0,
5651
5811
  type: this.visibleCols.includes('type') ? WIDTHS.type || 0 : 0,
5652
5812
  role: this.visibleCols.includes('role') ? WIDTHS.role || 0 : 0,
5653
5813
  room: this.visibleCols.includes('room') ? WIDTHS.room || 0 : 0,
@@ -5660,7 +5820,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5660
5820
  buttons: this.visibleCols.includes('buttons') ? WIDTHS.buttons || 0 : 0
5661
5821
  };
5662
5822
 
5663
- if (this.columnsVisibility.name) {
5823
+ if (this.columnsVisibility.name && !this.customWidth) {
5664
5824
  var widthSum = this.columnsVisibility.id; // id is always visible
5665
5825
 
5666
5826
  if (this.state.statesView) {
@@ -5679,7 +5839,7 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5679
5839
  widthSum += this.columnsVisibility.buttons;
5680
5840
  this.columnsVisibility.name = "calc(100% - ".concat(widthSum + 5, "px)");
5681
5841
  this.columnsVisibility.nameHeader = "calc(100% - ".concat(widthSum + 5 + this.state.scrollBarWidth, "px)");
5682
- } else {
5842
+ } else if (!this.customWidth) {
5683
5843
  // Calculate the with of ID
5684
5844
  var _widthSum = 0; // id is always visible
5685
5845
 
@@ -5781,14 +5941,14 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5781
5941
  }
5782
5942
  }
5783
5943
  }
5944
+ }, {
5945
+ key: "renderHeader",
5946
+ value:
5784
5947
  /**
5785
5948
  * @private
5786
5949
  * @returns {JSX.Element}
5787
5950
  */
5788
-
5789
- }, {
5790
- key: "renderHeader",
5791
- value: function renderHeader() {
5951
+ function renderHeader() {
5792
5952
  var _this40 = this;
5793
5953
 
5794
5954
  var classes = this.props.classes;
@@ -5812,53 +5972,79 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5812
5972
  }, /*#__PURE__*/_react["default"].createElement("div", {
5813
5973
  className: classes.headerCell,
5814
5974
  style: {
5815
- width: this.columnsVisibility.id
5816
- }
5817
- }, this.getFilterInput('id')), this.columnsVisibility.name ? /*#__PURE__*/_react["default"].createElement("div", {
5975
+ width: this.columnsVisibility.id,
5976
+ position: 'relative'
5977
+ },
5978
+ "data-min": 240,
5979
+ "data-name": "id"
5980
+ }, this.getFilterInput('id'), /*#__PURE__*/_react["default"].createElement("div", {
5981
+ className: this.props.classes.resizeHandle + ' ' + this.props.classes.resizeHandleRight,
5982
+ onMouseDown: this.resizerMouseDown,
5983
+ onDoubleClick: this.resizerReset,
5984
+ title: this.props.t('ra_Double click to reset table layout')
5985
+ })), this.columnsVisibility.name ? /*#__PURE__*/_react["default"].createElement("div", {
5818
5986
  className: classes.headerCell,
5819
5987
  style: {
5820
5988
  width: this.columnsVisibility.nameHeader
5821
- }
5989
+ },
5990
+ "data-min": 100,
5991
+ "data-name": "nameHeader"
5822
5992
  }, this.getFilterInput('name')) : null, !this.state.statesView && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.columnsVisibility.type ? /*#__PURE__*/_react["default"].createElement("div", {
5823
5993
  className: classes.headerCell,
5824
5994
  style: {
5825
5995
  width: this.columnsVisibility.type
5826
- }
5996
+ },
5997
+ "data-min": 100,
5998
+ "data-name": "type"
5827
5999
  }, this.getFilterSelectType()) : null, this.columnsVisibility.role ? /*#__PURE__*/_react["default"].createElement("div", {
5828
6000
  className: classes.headerCell,
5829
6001
  style: {
5830
6002
  width: this.columnsVisibility.role
5831
- }
6003
+ },
6004
+ "data-min": 100,
6005
+ "data-name": "role"
5832
6006
  }, this.getFilterSelectRole()) : null, this.columnsVisibility.room ? /*#__PURE__*/_react["default"].createElement("div", {
5833
6007
  className: classes.headerCell,
5834
6008
  style: {
5835
6009
  width: this.columnsVisibility.room
5836
- }
6010
+ },
6011
+ "data-min": 100,
6012
+ "data-name": "room"
5837
6013
  }, this.getFilterSelectRoom()) : null, this.columnsVisibility.func ? /*#__PURE__*/_react["default"].createElement("div", {
5838
6014
  className: classes.headerCell,
5839
6015
  style: {
5840
6016
  width: this.columnsVisibility.func
5841
- }
6017
+ },
6018
+ "data-min": 100,
6019
+ "data-name": "func"
5842
6020
  }, this.getFilterSelectFunction()) : null), this.state.statesView && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
5843
6021
  className: _Utils["default"].clsx(classes.headerCell, classes.headerCellValue),
5844
6022
  style: {
5845
6023
  width: this.columnsVisibility.changedFrom
5846
- }
6024
+ },
6025
+ "data-min": 100,
6026
+ "data-name": "changedFrom"
5847
6027
  }, this.props.t('ra_Changed from')), /*#__PURE__*/_react["default"].createElement("div", {
5848
6028
  className: _Utils["default"].clsx(classes.headerCell, classes.headerCellValue),
5849
6029
  style: {
5850
6030
  width: this.columnsVisibility.qualityCode
5851
- }
6031
+ },
6032
+ "data-min": 100,
6033
+ "data-name": "qualityCode"
5852
6034
  }, this.props.t('ra_Quality code')), /*#__PURE__*/_react["default"].createElement("div", {
5853
6035
  className: _Utils["default"].clsx(classes.headerCell, classes.headerCellValue),
5854
6036
  style: {
5855
6037
  width: this.columnsVisibility.timestamp
5856
- }
6038
+ },
6039
+ "data-min": 100,
6040
+ "data-name": "timestamp"
5857
6041
  }, this.props.t('ra_Timestamp')), /*#__PURE__*/_react["default"].createElement("div", {
5858
6042
  className: _Utils["default"].clsx(classes.headerCell, classes.headerCellValue),
5859
6043
  style: {
5860
6044
  width: this.columnsVisibility.lastChange
5861
- }
6045
+ },
6046
+ "data-min": 100,
6047
+ "data-name": "lastChange"
5862
6048
  }, this.props.t('ra_Last change'))), this.adapterColumns.map(function (item) {
5863
6049
  return /*#__PURE__*/_react["default"].createElement("div", {
5864
6050
  className: _Utils["default"].clsx(classes.headerCell, classes.headerCellValue),
@@ -5866,14 +6052,25 @@ var ObjectBrowser = /*#__PURE__*/function (_Component) {
5866
6052
  width: _this40.columnsVisibility[item.id]
5867
6053
  },
5868
6054
  title: item.adapter,
5869
- key: item.id
6055
+ key: item.id,
6056
+ "data-min": 100,
6057
+ "data-name": item.id
5870
6058
  }, item.name);
5871
6059
  }), this.columnsVisibility.val ? /*#__PURE__*/_react["default"].createElement("div", {
5872
6060
  className: _Utils["default"].clsx(classes.headerCell, classes.headerCellValue),
5873
6061
  style: {
5874
- width: this.columnsVisibility.val
5875
- }
5876
- }, this.props.t('ra_Value'), filterClearInValue) : null, this.columnsVisibility.buttons ? /*#__PURE__*/_react["default"].createElement("div", {
6062
+ width: this.columnsVisibility.val,
6063
+ position: 'relative'
6064
+ },
6065
+ "data-min": 120,
6066
+ "data-name": "val"
6067
+ }, /*#__PURE__*/_react["default"].createElement("div", {
6068
+ className: this.props.classes.resizeHandle + ' ' + this.props.classes.resizeHandleLeft,
6069
+ "data-left": "true",
6070
+ onMouseDown: this.resizerMouseDown,
6071
+ onDoubleClick: this.resizerReset,
6072
+ title: this.props.t('ra_Double click to reset table layout')
6073
+ }), this.props.t('ra_Value'), filterClearInValue) : null, this.columnsVisibility.buttons ? /*#__PURE__*/_react["default"].createElement("div", {
5877
6074
  className: classes.headerCell,
5878
6075
  style: {
5879
6076
  width: this.columnsVisibility.buttons