@iobroker/adapter-react-v5 6.1.8 → 6.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Components/FileBrowser.js +24 -19
- package/Components/FileViewer.js +14 -5
- package/Components/ObjectBrowser.d.ts +2 -0
- package/Components/ObjectBrowser.js +185 -86
- package/README.md +18 -18
- package/package.json +10 -10
- package/src/Components/FileBrowser.tsx +48 -28
- package/src/Components/FileViewer.tsx +14 -5
- package/src/Components/ObjectBrowser.tsx +224 -107
|
@@ -251,7 +251,7 @@ const styles = {
|
|
|
251
251
|
// display: 'inline-block',
|
|
252
252
|
// verticalAlign: 'top',
|
|
253
253
|
},
|
|
254
|
-
//
|
|
254
|
+
// This style is used for simple div. Do not migrate it to "secondary.main"
|
|
255
255
|
cellIdIconFolder: (theme) => ({
|
|
256
256
|
marginRight: 8,
|
|
257
257
|
width: ROW_HEIGHT - 4,
|
|
@@ -390,9 +390,6 @@ const styles = {
|
|
|
390
390
|
},
|
|
391
391
|
cellValueButton: {
|
|
392
392
|
marginTop: 5,
|
|
393
|
-
'&:active': {
|
|
394
|
-
transform: 'scale(0.8)',
|
|
395
|
-
},
|
|
396
393
|
},
|
|
397
394
|
cellValueButtonFalse: {
|
|
398
395
|
opacity: 0.3,
|
|
@@ -408,7 +405,7 @@ const styles = {
|
|
|
408
405
|
width: '100%',
|
|
409
406
|
height: ROW_HEIGHT,
|
|
410
407
|
fontSize: 16,
|
|
411
|
-
display: '
|
|
408
|
+
display: 'flex',
|
|
412
409
|
overflow: 'hidden',
|
|
413
410
|
textOverflow: 'ellipsis',
|
|
414
411
|
position: 'relative',
|
|
@@ -455,6 +452,7 @@ const styles = {
|
|
|
455
452
|
cellValueTextUnit: {
|
|
456
453
|
marginLeft: 4,
|
|
457
454
|
opacity: 0.8,
|
|
455
|
+
display: 'inline-block',
|
|
458
456
|
},
|
|
459
457
|
cellValueTextState: {
|
|
460
458
|
opacity: 0.7,
|
|
@@ -529,7 +527,7 @@ const styles = {
|
|
|
529
527
|
cellDetailsName: {
|
|
530
528
|
fontWeight: 'bold',
|
|
531
529
|
marginRight: 8,
|
|
532
|
-
minWidth:
|
|
530
|
+
minWidth: 80,
|
|
533
531
|
},
|
|
534
532
|
filteredOut: {
|
|
535
533
|
opacity: 0.5,
|
|
@@ -750,6 +748,12 @@ const styles = {
|
|
|
750
748
|
display: 'flex',
|
|
751
749
|
},
|
|
752
750
|
};
|
|
751
|
+
function ButtonIcon(props) {
|
|
752
|
+
return react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 436 436", style: props === null || props === void 0 ? void 0 : props.style, width: "24", height: "24", className: "admin-button" },
|
|
753
|
+
react_1.default.createElement("g", { fill: "currentColor" },
|
|
754
|
+
react_1.default.createElement("path", { d: "m195.23077,24.30769c-36,3 -67,12 -96,26c-49,24 -82,61 -93,104l-3,11l-1,50c0,46 0,49 2,59l5,20c21,58 84,103 165,116c16,3 53,4 70,2c60,-6 111,-28 147,-64c21,-21 36,-49 40,-74a866,866 0 0 0 1,-104c-3,-18 -6,-28 -13,-43c-26,-52 -87,-90 -162,-101c-16,-2 -48,-3 -63,-2l1,0zm60,23c36,5 70,18 95,35c31,20 51,47 59,77c2,7 2,11 2,25c1,15 0,18 -2,26c-19,69 -104,117 -200,114c-47,-2 -90,-15 -124,-38c-31,-20 -51,-47 -59,-77c-3,-11 -4,-32 -2,-43c8,-42 41,-78 91,-101a260,260 0 0 1 140,-19l0,1zm-221,222c21,26 57,49 95,62c81,27 174,14 239,-32c14,-10 31,-27 41,-41c2,-2 2,-2 2,7c-1,23 -16,50 -38,72c-78,74 -233,74 -311,-1a121,121 0 0 1 -39,-76l0,-6l3,4l8,11z" }),
|
|
755
|
+
react_1.default.createElement("path", { d: "m201.23077,47.30769c-40,3 -79,19 -104,44c-55,55 -38,133 37,171c52,26 122,24 172,-5c30,-17 51,-42 58,-71c3,-11 3,-34 0,-45c-6,-23 -21,-44 -40,-60l-27,-16a184,184 0 0 0 -96,-18zm30,21c56,5 100,35 112,75c4,11 4,30 0,41c-8,25 -26,45 -54,59a166,166 0 0 1 -160,-8a98,98 0 0 1 -41,-53c-5,-18 -2,-39 8,-57c23,-39 79,-62 135,-57z" })));
|
|
756
|
+
}
|
|
753
757
|
/**
|
|
754
758
|
* Function that walks through all keys of an object or array and applies a function to each key.
|
|
755
759
|
*/
|
|
@@ -1136,7 +1140,9 @@ function getVisibleItems(item, type, objects, _result) {
|
|
|
1136
1140
|
_result = _result || [];
|
|
1137
1141
|
const data = item.data;
|
|
1138
1142
|
if (data.sumVisibility) {
|
|
1139
|
-
data.id && objects[data.id] && (!type || objects[data.id].type === type)
|
|
1143
|
+
if (data.id && objects[data.id] && (!type || objects[data.id].type === type)) {
|
|
1144
|
+
_result.push(data.id);
|
|
1145
|
+
}
|
|
1140
1146
|
(_b = item.children) === null || _b === void 0 ? void 0 : _b.forEach(_item => getVisibleItems(_item, type, objects, _result));
|
|
1141
1147
|
}
|
|
1142
1148
|
return _result;
|
|
@@ -1197,7 +1203,7 @@ function getIdFieldTooltip(data, lang) {
|
|
|
1197
1203
|
return react_1.default.createElement("span", { style: styles.cellIdTooltip }, tooltip || data.id || '');
|
|
1198
1204
|
}
|
|
1199
1205
|
function buildTree(objects, options) {
|
|
1200
|
-
var _b, _c, _d, _e, _f;
|
|
1206
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1201
1207
|
const imagePrefix = options.imagePrefix || '.';
|
|
1202
1208
|
let ids = Object.keys(objects);
|
|
1203
1209
|
ids.sort((a, b) => {
|
|
@@ -1322,6 +1328,8 @@ function buildTree(objects, options) {
|
|
|
1322
1328
|
typeof obj.common.role === 'string' &&
|
|
1323
1329
|
obj.common.role.startsWith('button') &&
|
|
1324
1330
|
((_f = obj.common) === null || _f === void 0 ? void 0 : _f.write) !== false,
|
|
1331
|
+
switch: obj.type === 'state' && ((_g = obj.common) === null || _g === void 0 ? void 0 : _g.type) === 'boolean' &&
|
|
1332
|
+
((_h = obj.common) === null || _h === void 0 ? void 0 : _h.write) !== false && ((_j = obj.common) === null || _j === void 0 ? void 0 : _j.read) !== false,
|
|
1325
1333
|
},
|
|
1326
1334
|
};
|
|
1327
1335
|
cRoot.children = cRoot.children || [];
|
|
@@ -1625,7 +1633,7 @@ function formatValue(options) {
|
|
|
1625
1633
|
};
|
|
1626
1634
|
}
|
|
1627
1635
|
/**
|
|
1628
|
-
* Get
|
|
1636
|
+
* Get CSS style for given state value
|
|
1629
1637
|
*/
|
|
1630
1638
|
function getValueStyle(options) {
|
|
1631
1639
|
const { state, isExpertMode, isButton } = options;
|
|
@@ -1876,7 +1884,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
1876
1884
|
newState = newInnerState;
|
|
1877
1885
|
}
|
|
1878
1886
|
});
|
|
1879
|
-
|
|
1887
|
+
if (newState) {
|
|
1888
|
+
this.setState(newState);
|
|
1889
|
+
}
|
|
1880
1890
|
this.afterObjectUpdated();
|
|
1881
1891
|
}
|
|
1882
1892
|
};
|
|
@@ -1885,7 +1895,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
1885
1895
|
if (filtered) {
|
|
1886
1896
|
return;
|
|
1887
1897
|
}
|
|
1888
|
-
|
|
1898
|
+
if (newInnerState) {
|
|
1899
|
+
this.setState(newInnerState);
|
|
1900
|
+
}
|
|
1889
1901
|
this.afterObjectUpdated();
|
|
1890
1902
|
};
|
|
1891
1903
|
this.getEnumsForId = (id) => {
|
|
@@ -2121,7 +2133,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2121
2133
|
this.resizerCurrentWidths.name = width - this.state.scrollBarWidth;
|
|
2122
2134
|
}
|
|
2123
2135
|
this.customWidth = true;
|
|
2124
|
-
|
|
2136
|
+
if (this.resizeTimeout) {
|
|
2137
|
+
clearTimeout(this.resizeTimeout);
|
|
2138
|
+
}
|
|
2125
2139
|
this.resizeTimeout = setTimeout(() => {
|
|
2126
2140
|
this.resizeTimeout = null;
|
|
2127
2141
|
this.forceUpdate();
|
|
@@ -2193,7 +2207,7 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2193
2207
|
const lastSelectedItems = JSON.parse(lastSelectedItemStr);
|
|
2194
2208
|
this.selectFirst = lastSelectedItems[0] || '';
|
|
2195
2209
|
}
|
|
2196
|
-
catch (
|
|
2210
|
+
catch (_b) {
|
|
2197
2211
|
// ignore
|
|
2198
2212
|
}
|
|
2199
2213
|
}
|
|
@@ -2205,7 +2219,7 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2205
2219
|
try {
|
|
2206
2220
|
expanded = JSON.parse(expandedStr);
|
|
2207
2221
|
}
|
|
2208
|
-
catch (
|
|
2222
|
+
catch (_c) {
|
|
2209
2223
|
expanded = [];
|
|
2210
2224
|
}
|
|
2211
2225
|
let filter;
|
|
@@ -2216,7 +2230,7 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2216
2230
|
try {
|
|
2217
2231
|
filter = JSON.parse(filterStr);
|
|
2218
2232
|
}
|
|
2219
|
-
catch (
|
|
2233
|
+
catch (_d) {
|
|
2220
2234
|
filter = Object.assign({}, DEFAULT_FILTER);
|
|
2221
2235
|
}
|
|
2222
2236
|
}
|
|
@@ -2237,7 +2251,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2237
2251
|
// remove type column if only one type must be selected
|
|
2238
2252
|
if (props.types && props.types.length === 1) {
|
|
2239
2253
|
const pos = this.visibleCols.indexOf('type');
|
|
2240
|
-
pos !== -1
|
|
2254
|
+
if (pos !== -1) {
|
|
2255
|
+
this.visibleCols.splice(pos, 1);
|
|
2256
|
+
}
|
|
2241
2257
|
}
|
|
2242
2258
|
this.possibleCols = SCREEN_WIDTHS.xl.fields;
|
|
2243
2259
|
let customDialog = null;
|
|
@@ -2262,14 +2278,14 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2262
2278
|
try {
|
|
2263
2279
|
columns = columnsStr ? JSON.parse(columnsStr) : null;
|
|
2264
2280
|
}
|
|
2265
|
-
catch (
|
|
2281
|
+
catch (_e) {
|
|
2266
2282
|
columns = null;
|
|
2267
2283
|
}
|
|
2268
2284
|
let columnsWidths = null; // this.localStorage.getItem(`${props.dialogName || 'App'}.columnsWidths`);
|
|
2269
2285
|
try {
|
|
2270
2286
|
columnsWidths = columnsWidths ? JSON.parse(columnsWidths) : {};
|
|
2271
2287
|
}
|
|
2272
|
-
catch (
|
|
2288
|
+
catch (_f) {
|
|
2273
2289
|
columnsWidths = {};
|
|
2274
2290
|
}
|
|
2275
2291
|
this.imagePrefix = props.imagePrefix || '.';
|
|
@@ -2290,7 +2306,7 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2290
2306
|
? JSON.parse(this.localStorage.getItem(`${props.dialogName || 'App'}.objectStatesView`) || '') || false
|
|
2291
2307
|
: false;
|
|
2292
2308
|
}
|
|
2293
|
-
catch (
|
|
2309
|
+
catch (_g) {
|
|
2294
2310
|
// ignore
|
|
2295
2311
|
}
|
|
2296
2312
|
this.state = {
|
|
@@ -2410,7 +2426,7 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2410
2426
|
});
|
|
2411
2427
|
this.customWidth = true;
|
|
2412
2428
|
}
|
|
2413
|
-
catch (
|
|
2429
|
+
catch (_h) {
|
|
2414
2430
|
// ignore
|
|
2415
2431
|
}
|
|
2416
2432
|
}
|
|
@@ -2510,7 +2526,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2510
2526
|
else {
|
|
2511
2527
|
this.objects = objects;
|
|
2512
2528
|
}
|
|
2513
|
-
|
|
2529
|
+
if (props.setObjectsReference) {
|
|
2530
|
+
props.setObjectsReference(this.objects);
|
|
2531
|
+
}
|
|
2514
2532
|
// read default history
|
|
2515
2533
|
this.defaultHistory = this.systemConfig.common.defaultHistory;
|
|
2516
2534
|
if (this.defaultHistory) {
|
|
@@ -2579,8 +2597,8 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2579
2597
|
this.localStorage.setItem(`${this.props.dialogName || 'App'}.objectExpanded`, JSON.stringify(expanded));
|
|
2580
2598
|
this.setState({ expanded }, cb);
|
|
2581
2599
|
}
|
|
2582
|
-
else {
|
|
2583
|
-
cb
|
|
2600
|
+
else if (cb) {
|
|
2601
|
+
cb();
|
|
2584
2602
|
}
|
|
2585
2603
|
}
|
|
2586
2604
|
/**
|
|
@@ -2596,7 +2614,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2596
2614
|
}
|
|
2597
2615
|
if (this.state.selected.length === 1 && this.objects[this.state.selected[0]]) {
|
|
2598
2616
|
const name = Utils_1.default.getObjectName(this.objects, this.state.selected[0], null, { language: this.props.lang });
|
|
2599
|
-
|
|
2617
|
+
if (this.props.onSelect) {
|
|
2618
|
+
this.props.onSelect(this.state.selected, name, isDouble);
|
|
2619
|
+
}
|
|
2600
2620
|
}
|
|
2601
2621
|
}
|
|
2602
2622
|
else {
|
|
@@ -2604,8 +2624,8 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2604
2624
|
if (this.state.selected.length) {
|
|
2605
2625
|
this.setState({ selected: [] }, () => this.props.onSelect && this.props.onSelect([], ''));
|
|
2606
2626
|
}
|
|
2607
|
-
else {
|
|
2608
|
-
this.props.onSelect
|
|
2627
|
+
else if (this.props.onSelect) {
|
|
2628
|
+
this.props.onSelect([], '');
|
|
2609
2629
|
}
|
|
2610
2630
|
}
|
|
2611
2631
|
}
|
|
@@ -2637,8 +2657,10 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2637
2657
|
* Called when component is unmounted.
|
|
2638
2658
|
*/
|
|
2639
2659
|
componentWillUnmount() {
|
|
2640
|
-
|
|
2641
|
-
|
|
2660
|
+
if (this.filterTimer) {
|
|
2661
|
+
clearTimeout(this.filterTimer);
|
|
2662
|
+
this.filterTimer = null;
|
|
2663
|
+
}
|
|
2642
2664
|
window.removeEventListener('contextmenu', this.onContextMenu, true);
|
|
2643
2665
|
if (this.props.objectsWorker) {
|
|
2644
2666
|
this.props.objectsWorker.unregisterHandler(this.onObjectChangeFromWorker, true);
|
|
@@ -2673,7 +2695,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2673
2695
|
break;
|
|
2674
2696
|
}
|
|
2675
2697
|
}
|
|
2676
|
-
|
|
2698
|
+
if (this.props.onObjectDelete) {
|
|
2699
|
+
this.props.onObjectDelete(id, !!((_b = item.children) === null || _b === void 0 ? void 0 : _b.length), !((_c = obj.common) === null || _c === void 0 ? void 0 : _c.dontDelete), count + 1);
|
|
2700
|
+
}
|
|
2677
2701
|
}
|
|
2678
2702
|
/**
|
|
2679
2703
|
* Called when component is mounted.
|
|
@@ -2722,7 +2746,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2722
2746
|
if (this.state.selected[0] !== toggleItem) {
|
|
2723
2747
|
this.setState({ selected: [toggleItem], selectedNonObject: '', focused: toggleItem }, () => {
|
|
2724
2748
|
this.onAfterSelect(isDouble);
|
|
2725
|
-
|
|
2749
|
+
if (cb) {
|
|
2750
|
+
cb();
|
|
2751
|
+
}
|
|
2726
2752
|
});
|
|
2727
2753
|
}
|
|
2728
2754
|
else if (isDouble && this.props.onSelect) {
|
|
@@ -2733,7 +2759,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2733
2759
|
this.localStorage.setItem(`${this.props.dialogName || 'App'}.selectedNonObject`, toggleItem);
|
|
2734
2760
|
this.setState({ selected: [], selectedNonObject: toggleItem, focused: toggleItem }, () => {
|
|
2735
2761
|
this.onAfterSelect();
|
|
2736
|
-
|
|
2762
|
+
if (cb) {
|
|
2763
|
+
cb();
|
|
2764
|
+
}
|
|
2737
2765
|
});
|
|
2738
2766
|
}
|
|
2739
2767
|
}
|
|
@@ -2751,7 +2779,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2751
2779
|
}
|
|
2752
2780
|
this.setState({ selected, selectedNonObject: '', focused: toggleItem }, () => {
|
|
2753
2781
|
this.onAfterSelect(isDouble);
|
|
2754
|
-
|
|
2782
|
+
if (cb) {
|
|
2783
|
+
cb();
|
|
2784
|
+
}
|
|
2755
2785
|
});
|
|
2756
2786
|
}
|
|
2757
2787
|
}
|
|
@@ -2878,7 +2908,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
2878
2908
|
checkUnsubscribes() {
|
|
2879
2909
|
// Remove unused subscriptions
|
|
2880
2910
|
for (let i = this.subscribes.length - 1; i >= 0; i--) {
|
|
2881
|
-
!this.recordStates.includes(this.subscribes[i])
|
|
2911
|
+
if (!this.recordStates.includes(this.subscribes[i])) {
|
|
2912
|
+
this.unsubscribe(this.subscribes[i]);
|
|
2913
|
+
}
|
|
2882
2914
|
}
|
|
2883
2915
|
this.recordStates = [];
|
|
2884
2916
|
}
|
|
@@ -3029,7 +3061,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3029
3061
|
if (!this.subscribes.includes(id)) {
|
|
3030
3062
|
this.subscribes.push(id);
|
|
3031
3063
|
console.log(`+ subscribe ${id}`);
|
|
3032
|
-
!this.pausedSubscribes
|
|
3064
|
+
if (!this.pausedSubscribes) {
|
|
3065
|
+
this.props.socket.subscribeState(id, this.onStateChange);
|
|
3066
|
+
}
|
|
3033
3067
|
}
|
|
3034
3068
|
}
|
|
3035
3069
|
unsubscribe(id) {
|
|
@@ -3112,7 +3146,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3112
3146
|
// style={{ marginTop: 0, marginBottom: 0 }}
|
|
3113
3147
|
margin: "dense" },
|
|
3114
3148
|
react_1.default.createElement(material_1.Input, { ref: this.filterRefs[filterName], classes: { underline: 'no-underline' }, id: filterName, placeholder: this.texts[`filter_${filterName}`], defaultValue: this.state.filter[filterName] || '', onChange: () => {
|
|
3115
|
-
|
|
3149
|
+
if (this.filterTimer) {
|
|
3150
|
+
clearTimeout(this.filterTimer);
|
|
3151
|
+
}
|
|
3116
3152
|
this.filterTimer = setTimeout(() => this.onFilter(), 400);
|
|
3117
3153
|
}, autoComplete: "off" }),
|
|
3118
3154
|
((_d = (_c = (_b = this.filterRefs[filterName]) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.firstChild) === null || _d === void 0 ? void 0 : _d.value) ? react_1.default.createElement("div", { style: {
|
|
@@ -3131,7 +3167,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3131
3167
|
const hasIcons = !!(values === null || values === void 0 ? void 0 : values.find(item => item.icon));
|
|
3132
3168
|
return react_1.default.createElement("div", { style: { position: 'relative' } },
|
|
3133
3169
|
react_1.default.createElement(material_1.Select, { variant: "standard", key: `${name}_${this.state.filterKey}`, ref: this.filterRefs[name], sx: styles.headerCellInput, className: "no-underline", onChange: () => {
|
|
3134
|
-
|
|
3170
|
+
if (this.filterTimer) {
|
|
3171
|
+
clearTimeout(this.filterTimer);
|
|
3172
|
+
}
|
|
3135
3173
|
this.filterTimer = setTimeout(() => this.onFilter(), 400);
|
|
3136
3174
|
}, defaultValue: this.state.filter[name] || '', inputProps: { name, id: name }, displayEmpty: true },
|
|
3137
3175
|
react_1.default.createElement(material_1.MenuItem, { key: "empty", value: "" },
|
|
@@ -3253,7 +3291,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3253
3291
|
if (this.state.depth < 9) {
|
|
3254
3292
|
const depth = this.state.depth + 1;
|
|
3255
3293
|
const expanded = [...this.state.expanded];
|
|
3256
|
-
|
|
3294
|
+
if (this.root) {
|
|
3295
|
+
this.expandDepth(this.root, depth, expanded);
|
|
3296
|
+
}
|
|
3257
3297
|
this.localStorage.setItem(`${this.props.dialogName || 'App'}.objectExpanded`, JSON.stringify(expanded));
|
|
3258
3298
|
this.setState({ depth, expanded });
|
|
3259
3299
|
}
|
|
@@ -3298,7 +3338,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3298
3338
|
}
|
|
3299
3339
|
try {
|
|
3300
3340
|
await this.props.socket.setObject(id, obj);
|
|
3301
|
-
|
|
3341
|
+
if (enums) {
|
|
3342
|
+
await this._createAllEnums(enums, obj._id);
|
|
3343
|
+
}
|
|
3302
3344
|
if (obj.type === 'state') {
|
|
3303
3345
|
if (val !== undefined && val !== null) {
|
|
3304
3346
|
try {
|
|
@@ -3678,7 +3720,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3678
3720
|
break;
|
|
3679
3721
|
}
|
|
3680
3722
|
}
|
|
3681
|
-
|
|
3723
|
+
if (this.props.onObjectDelete) {
|
|
3724
|
+
this.props.onObjectDelete(id, !!((_b = item.children) === null || _b === void 0 ? void 0 : _b.length), false, count + 1);
|
|
3725
|
+
}
|
|
3682
3726
|
} },
|
|
3683
3727
|
react_1.default.createElement(icons_material_1.Delete, { style: styles.cellButtonsButtonIcon })) : null) : null;
|
|
3684
3728
|
}
|
|
@@ -3720,7 +3764,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3720
3764
|
break;
|
|
3721
3765
|
}
|
|
3722
3766
|
}
|
|
3723
|
-
|
|
3767
|
+
if (this.props.onObjectDelete) {
|
|
3768
|
+
this.props.onObjectDelete(id, !!((_b = item.children) === null || _b === void 0 ? void 0 : _b.length), !((_d = (_c = item.data.obj) === null || _c === void 0 ? void 0 : _c.common) === null || _d === void 0 ? void 0 : _d.dontDelete), count);
|
|
3769
|
+
}
|
|
3724
3770
|
}, title: this.texts.deleteObject },
|
|
3725
3771
|
react_1.default.createElement(icons_material_1.Delete, { style: styles.cellButtonsButtonIcon })) : null,
|
|
3726
3772
|
this.props.objectCustomDialog &&
|
|
@@ -3811,14 +3857,18 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3811
3857
|
":\u00A0",
|
|
3812
3858
|
_item.v));
|
|
3813
3859
|
// <div style={styles.cellValueTooltipValue} key={item.t + '_v'}>{item.v}</div>,
|
|
3814
|
-
!_item.nbr
|
|
3860
|
+
if (!_item.nbr) {
|
|
3861
|
+
valFullRx.push(react_1.default.createElement("br", { key: `${_item.t}_br` }));
|
|
3862
|
+
}
|
|
3815
3863
|
}
|
|
3816
3864
|
else {
|
|
3817
3865
|
valFullRx.push(react_1.default.createElement("div", { style: styles.cellValueTooltipTitle, key: _item.t },
|
|
3818
3866
|
_item.t,
|
|
3819
3867
|
":\u00A0"));
|
|
3820
3868
|
valFullRx.push(react_1.default.createElement("div", { style: styles.cellValueTooltipValue, key: `${_item.t}_v` }, _item.v));
|
|
3821
|
-
!_item.nbr
|
|
3869
|
+
if (!_item.nbr) {
|
|
3870
|
+
valFullRx.push(react_1.default.createElement("br", { key: `${_item.t}_br` }));
|
|
3871
|
+
}
|
|
3822
3872
|
}
|
|
3823
3873
|
});
|
|
3824
3874
|
if (fileViewer === 'image') {
|
|
@@ -3843,13 +3893,17 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3843
3893
|
if (!this.states[id]) {
|
|
3844
3894
|
if (obj.type === 'state') {
|
|
3845
3895
|
// we are waiting for state
|
|
3846
|
-
!this.recordStates.includes(id)
|
|
3896
|
+
if (!this.recordStates.includes(id)) {
|
|
3897
|
+
this.recordStates.push(id);
|
|
3898
|
+
}
|
|
3847
3899
|
this.states[id] = { val: null };
|
|
3848
3900
|
this.subscribe(id);
|
|
3849
3901
|
}
|
|
3850
3902
|
return null;
|
|
3851
3903
|
}
|
|
3852
|
-
!this.recordStates.includes(id)
|
|
3904
|
+
if (!this.recordStates.includes(id)) {
|
|
3905
|
+
this.recordStates.push(id);
|
|
3906
|
+
}
|
|
3853
3907
|
const state = this.states[id];
|
|
3854
3908
|
let info = item.data.state;
|
|
3855
3909
|
if (!info) {
|
|
@@ -3863,31 +3917,55 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3863
3917
|
const valTextRx = [];
|
|
3864
3918
|
item.data.state = { valTextRx };
|
|
3865
3919
|
const copyText = valText.v || '';
|
|
3866
|
-
valTextRx.push(react_1.default.createElement("span", { className: `newValueBrowser-${this.props.themeType || 'light'}`, key: `${valText.v.toString()}valText
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3920
|
+
valTextRx.push(react_1.default.createElement("span", { className: `newValueBrowser-${this.props.themeType || 'light'}`, key: `${valText.v.toString()}valText`, style: {
|
|
3921
|
+
whiteSpace: 'nowrap',
|
|
3922
|
+
display: 'inline-block',
|
|
3923
|
+
overflow: 'hidden',
|
|
3924
|
+
textOverflow: 'ellipsis',
|
|
3925
|
+
} }, valText.v.toString()));
|
|
3926
|
+
if (valText.u) {
|
|
3927
|
+
valTextRx.push(react_1.default.createElement("span", { className: `newValueBrowser-${this.props.themeType || 'light'}`, style: styles.cellValueTextUnit, key: `${valText.v.toString()}unit` }, valText.u));
|
|
3928
|
+
}
|
|
3929
|
+
if (valText.s !== undefined) {
|
|
3930
|
+
valTextRx.push(react_1.default.createElement("span", { style: styles.cellValueTextState, className: `newValueBrowser-${this.props.themeType || 'light'}`, key: `${valText.v.toString()}states` },
|
|
3931
|
+
"(",
|
|
3932
|
+
valText.s,
|
|
3933
|
+
")"));
|
|
3934
|
+
}
|
|
3935
|
+
if (!narrowStyleWithDetails) {
|
|
3936
|
+
valTextRx.push(react_1.default.createElement(IconCopy_1.default, { className: "copyButton", style: this.styles.iconCopy, onClick: e => this.onCopy(e, copyText), key: "cc" }));
|
|
3937
|
+
}
|
|
3873
3938
|
// <IconEdit className="copyButton" style={{{ ...styles.cellButtonsValueButton, styles.cellButtonsValueButtonEdit)} key="ce" />
|
|
3874
3939
|
info = item.data.state;
|
|
3875
3940
|
}
|
|
3876
3941
|
info.style = getValueStyle({ state, isExpertMode: this.state.filter.expertMode, isButton: item.data.button });
|
|
3877
3942
|
let val = info.valTextRx;
|
|
3878
|
-
if (!this.state.filter.expertMode
|
|
3879
|
-
|
|
3943
|
+
if (!this.state.filter.expertMode) {
|
|
3944
|
+
if (item.data.button) {
|
|
3945
|
+
val = [react_1.default.createElement(ButtonIcon, { key: "button", style: Object.assign({ color: info.style.color }, styles.cellValueButton) })];
|
|
3946
|
+
}
|
|
3947
|
+
else if (item.data.switch) {
|
|
3948
|
+
val = [react_1.default.createElement(material_1.Switch, { key: "switch", sx: {
|
|
3949
|
+
'& .MuiSwitch-thumb': { color: info.style.color },
|
|
3950
|
+
'& .MuiSwitch-track': !!this.states[id].val && this.state.selected.includes(id) ?
|
|
3951
|
+
{ backgroundColor: this.props.themeType === 'dark' ? '#FFF !important' : '#111 !important' } : undefined,
|
|
3952
|
+
}, checked: !!this.states[id].val })];
|
|
3953
|
+
}
|
|
3880
3954
|
}
|
|
3881
3955
|
return react_1.default.createElement(material_1.Tooltip, { key: "value", title: (_c = this.state.tooltipInfo) === null || _c === void 0 ? void 0 : _c.el, componentsProps: {
|
|
3882
3956
|
popper: { sx: styles.cellValueTooltipBox },
|
|
3883
3957
|
tooltip: { sx: styles.cellValueTooltip },
|
|
3884
3958
|
}, onOpen: () => this.getTooltipInfo(id, () => this.readHistory(id)), onClose: () => { var _b; return ((_b = this.state.tooltipInfo) === null || _b === void 0 ? void 0 : _b.id) === id && this.setState({ tooltipInfo: null }); } },
|
|
3885
|
-
react_1.default.createElement(material_1.Box, { component: "div", style: info.style, sx: Object.assign(Object.assign({}, styles.cellValueText), { height: narrowStyleWithDetails ? undefined : ROW_HEIGHT
|
|
3959
|
+
react_1.default.createElement(material_1.Box, { component: "div", style: info.style, sx: Object.assign(Object.assign({}, styles.cellValueText), { height: narrowStyleWithDetails ? undefined : ROW_HEIGHT, '& .admin-button:active': {
|
|
3960
|
+
transform: 'translate(0, 2px)',
|
|
3961
|
+
} }) }, val));
|
|
3886
3962
|
}
|
|
3887
3963
|
_syncEnum(id, enumIds, newArray, cb) {
|
|
3888
3964
|
var _b, _c, _d;
|
|
3889
3965
|
if (!enumIds || !enumIds.length) {
|
|
3890
|
-
|
|
3966
|
+
if (cb) {
|
|
3967
|
+
cb();
|
|
3968
|
+
}
|
|
3891
3969
|
return;
|
|
3892
3970
|
}
|
|
3893
3971
|
const enumId = enumIds.pop() || '';
|
|
@@ -3896,7 +3974,7 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
3896
3974
|
if ((_c = this.info.objects[enumId].common.members) === null || _c === void 0 ? void 0 : _c.length) {
|
|
3897
3975
|
const pos = this.info.objects[enumId].common.members.indexOf(id);
|
|
3898
3976
|
if (pos !== -1 && !newArray.includes(enumId)) {
|
|
3899
|
-
// delete from members
|
|
3977
|
+
// delete it from members
|
|
3900
3978
|
const obj = JSON.parse(JSON.stringify(this.info.objects[enumId]));
|
|
3901
3979
|
obj.common.members.splice(pos, 1);
|
|
3902
3980
|
promises.push(this.props.socket
|
|
@@ -4276,11 +4354,15 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
4276
4354
|
}
|
|
4277
4355
|
}
|
|
4278
4356
|
if (obj) {
|
|
4279
|
-
obj.from
|
|
4357
|
+
if (obj.from) {
|
|
4280
4358
|
newValueTitle.push(`${this.texts.objectChangedFrom} ${obj.from.replace(/^system\.adapter\.|^system\./, '')}`);
|
|
4281
|
-
|
|
4282
|
-
obj.
|
|
4359
|
+
}
|
|
4360
|
+
if (obj.user) {
|
|
4361
|
+
newValueTitle.push(`${this.texts.objectChangedBy} ${obj.user.replace(/^system\.user\./, '')}`);
|
|
4362
|
+
}
|
|
4363
|
+
if (obj.ts) {
|
|
4283
4364
|
newValueTitle.push(`${this.texts.objectChangedByUser} ${Utils_1.default.formatDate(new Date(obj.ts), this.props.dateFormat || this.systemConfig.common.dateFormat)}`);
|
|
4365
|
+
}
|
|
4284
4366
|
}
|
|
4285
4367
|
const readWriteAlias = typeof ((_c = common === null || common === void 0 ? void 0 : common.alias) === null || _c === void 0 ? void 0 : _c.id) === 'object';
|
|
4286
4368
|
const alias = id.startsWith('alias.') && ((_d = common === null || common === void 0 ? void 0 : common.alias) === null || _d === void 0 ? void 0 : _d.id) ? (readWriteAlias ?
|
|
@@ -4355,13 +4437,15 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
4355
4437
|
ids[name] = _id;
|
|
4356
4438
|
if (!this.states[_id]) {
|
|
4357
4439
|
if (((_b = this.objects[_id]) === null || _b === void 0 ? void 0 : _b.type) === 'state') {
|
|
4358
|
-
!this.recordStates.includes(_id)
|
|
4440
|
+
if (!this.recordStates.includes(_id)) {
|
|
4441
|
+
this.recordStates.push(_id);
|
|
4442
|
+
}
|
|
4359
4443
|
this.states[_id] = { val: null };
|
|
4360
4444
|
this.subscribe(_id);
|
|
4361
4445
|
}
|
|
4362
4446
|
}
|
|
4363
|
-
else {
|
|
4364
|
-
|
|
4447
|
+
else if (!this.recordStates.includes(_id)) {
|
|
4448
|
+
this.recordStates.push(_id);
|
|
4365
4449
|
}
|
|
4366
4450
|
});
|
|
4367
4451
|
// calculate color
|
|
@@ -4566,7 +4650,7 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
4566
4650
|
}
|
|
4567
4651
|
let colCustom = ((_p = this.adapterColumns) === null || _p === void 0 ? void 0 : _p.map(it => react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.cellAdapter), { width: this.props.width !== 'xs' ? this.columnsVisibility[it.id] : undefined }), key: it.id, title: `${it.adapter} => ${it.pathText}` }, obj ? this.renderCustomValue(obj, it, item) : null))) || null;
|
|
4568
4652
|
const columnValue = narrowStyleWithDetails || this.columnsVisibility.val ? this.renderColumnValue(id, item, narrowStyleWithDetails) : null;
|
|
4569
|
-
let colValue = (narrowStyleWithDetails && columnValue) || this.columnsVisibility.val ? react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.cellValue), { width: this.props.width !== 'xs' ? this.columnsVisibility.val :
|
|
4653
|
+
let colValue = (narrowStyleWithDetails && columnValue) || this.columnsVisibility.val ? react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.cellValue), { width: this.props.width !== 'xs' ? this.columnsVisibility.val : 'calc(100% - 100px)', cursor: valueEditable ? ((common === null || common === void 0 ? void 0 : common.type) === 'file' ? 'zoom-in' : (item.data.button ? 'grab' : 'text')) : 'default' }), onClick: valueEditable ? () => {
|
|
4570
4654
|
if (!obj || !this.states) {
|
|
4571
4655
|
// return;
|
|
4572
4656
|
}
|
|
@@ -4580,6 +4664,12 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
4580
4664
|
.setState(id, true)
|
|
4581
4665
|
.catch(e => window.alert(`Cannot write state "${id}": ${e}`));
|
|
4582
4666
|
}
|
|
4667
|
+
else if (!this.state.filter.expertMode && item.data.switch) {
|
|
4668
|
+
// in non-expert mode control switch directly
|
|
4669
|
+
this.props.socket
|
|
4670
|
+
.setState(id, !this.states[id].val)
|
|
4671
|
+
.catch(e => window.alert(`Cannot write state "${id}": ${e}`));
|
|
4672
|
+
}
|
|
4583
4673
|
else {
|
|
4584
4674
|
this.edit = {
|
|
4585
4675
|
val: this.states[id] ? this.states[id].val : '',
|
|
@@ -4712,26 +4802,30 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
4712
4802
|
else {
|
|
4713
4803
|
leaf = result.row;
|
|
4714
4804
|
}
|
|
4715
|
-
root.data.id && leaf
|
|
4805
|
+
if (root.data.id && leaf) {
|
|
4806
|
+
items.push(leaf);
|
|
4807
|
+
}
|
|
4716
4808
|
if (result.details) {
|
|
4717
4809
|
items.push(result.details);
|
|
4718
4810
|
}
|
|
4719
4811
|
isExpanded = isExpanded === undefined ? binarySearch(this.state.expanded, root.data.id) : isExpanded;
|
|
4720
4812
|
if (!root.data.id || isExpanded) {
|
|
4721
4813
|
if (!this.state.foldersFirst) {
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
if (
|
|
4726
|
-
|
|
4814
|
+
if (root.children) {
|
|
4815
|
+
items.push(root.children.map(item => {
|
|
4816
|
+
// do not render too many items in column editor mode
|
|
4817
|
+
if (!this.state.columnsSelectorShow || counter.count < 15) {
|
|
4818
|
+
if (item.data.sumVisibility) {
|
|
4819
|
+
return this.renderItem(item, undefined, counter);
|
|
4820
|
+
}
|
|
4727
4821
|
}
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
}
|
|
4822
|
+
return null;
|
|
4823
|
+
}));
|
|
4824
|
+
}
|
|
4731
4825
|
}
|
|
4732
|
-
else {
|
|
4826
|
+
else if (root.children) {
|
|
4733
4827
|
// first only folder
|
|
4734
|
-
|
|
4828
|
+
items.push(root.children.map(item => {
|
|
4735
4829
|
if (item.children) {
|
|
4736
4830
|
// do not render too many items in column editor mode
|
|
4737
4831
|
if (!this.state.columnsSelectorShow || counter.count < 15) {
|
|
@@ -4743,7 +4837,7 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
4743
4837
|
return null;
|
|
4744
4838
|
}));
|
|
4745
4839
|
// then items
|
|
4746
|
-
|
|
4840
|
+
items.push(root.children.map(item => {
|
|
4747
4841
|
if (!item.children) {
|
|
4748
4842
|
// do not render too many items in column editor mode
|
|
4749
4843
|
if (!this.state.columnsSelectorShow || counter.count < 15) {
|
|
@@ -5053,12 +5147,11 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
5053
5147
|
scrollToItem(id) {
|
|
5054
5148
|
this.selectFirst = '';
|
|
5055
5149
|
const node = window.document.getElementById(id);
|
|
5056
|
-
node
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
});
|
|
5150
|
+
node === null || node === void 0 ? void 0 : node.scrollIntoView({
|
|
5151
|
+
behavior: 'auto',
|
|
5152
|
+
block: 'center',
|
|
5153
|
+
inline: 'center',
|
|
5154
|
+
});
|
|
5062
5155
|
}
|
|
5063
5156
|
renderCustomDialog() {
|
|
5064
5157
|
if (this.state.customDialog && this.props.objectCustomDialog) {
|
|
@@ -5421,7 +5514,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
5421
5514
|
react_1.default.createElement(icons_material_1.ArrowRight, null))));
|
|
5422
5515
|
if (((_b = this.state.showContextMenu) === null || _b === void 0 ? void 0 : _b.subItem) === key) {
|
|
5423
5516
|
items.push(react_1.default.createElement(material_1.Menu, { key: "subContextMenu", open: !0, anchorEl: this.state.showContextMenu.subAnchor, onClose: () => {
|
|
5424
|
-
|
|
5517
|
+
if (this.state.showContextMenu) {
|
|
5518
|
+
this.setState({ showContextMenu: { item: this.state.showContextMenu.item } });
|
|
5519
|
+
}
|
|
5425
5520
|
this.contextMenu = null;
|
|
5426
5521
|
} }, (_c = ITEMS[key].subMenu) === null || _c === void 0 ? void 0 : _c.map(subItem => (subItem.visibility ? react_1.default.createElement(material_1.MenuItem, { key: subItem.label, onClick: subItem.onClick, style: subItem.style },
|
|
5427
5522
|
react_1.default.createElement(material_1.ListItemIcon, { style: Object.assign(Object.assign({}, subItem.iconStyle), (subItem.listItemIconStyle || undefined)) }, subItem.icon),
|
|
@@ -5445,8 +5540,8 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
5445
5540
|
e.preventDefault();
|
|
5446
5541
|
if (e.altKey) {
|
|
5447
5542
|
Object.keys(ITEMS).forEach(key => {
|
|
5448
|
-
if (e.key === ITEMS[key].key) {
|
|
5449
|
-
ITEMS[key].onClick
|
|
5543
|
+
if (e.key === ITEMS[key].key && ITEMS[key].onClick) {
|
|
5544
|
+
ITEMS[key].onClick();
|
|
5450
5545
|
}
|
|
5451
5546
|
});
|
|
5452
5547
|
}
|
|
@@ -5475,7 +5570,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
5475
5570
|
const ObjectBrowserValue = this.props.objectBrowserValue;
|
|
5476
5571
|
return react_1.default.createElement(ObjectBrowserValue, { t: this.props.t, lang: this.props.lang, type: type, role: role || '', states: Utils_1.default.getStates(this.objects[this.edit.id]), themeType: this.props.themeType, theme: this.props.theme, expertMode: !!this.state.filter.expertMode, value: this.edit.val, socket: this.props.socket, object: this.objects[this.edit.id], defaultHistory: this.defaultHistory, dateFormat: this.props.dateFormat || this.systemConfig.common.dateFormat, isFloatComma: this.props.isFloatComma === undefined ? this.systemConfig.common.isFloatComma : this.props.isFloatComma, onClose: (res) => {
|
|
5477
5572
|
this.setState({ updateOpened: false });
|
|
5478
|
-
|
|
5573
|
+
if (res) {
|
|
5574
|
+
this.onUpdate(res);
|
|
5575
|
+
}
|
|
5479
5576
|
}, width: this.props.width });
|
|
5480
5577
|
}
|
|
5481
5578
|
/**
|
|
@@ -5483,7 +5580,9 @@ class ObjectBrowserClass extends react_1.Component {
|
|
|
5483
5580
|
*/
|
|
5484
5581
|
render() {
|
|
5485
5582
|
this.recordStates = [];
|
|
5486
|
-
|
|
5583
|
+
if (this.unsubscribeTimer) {
|
|
5584
|
+
clearTimeout(this.unsubscribeTimer);
|
|
5585
|
+
}
|
|
5487
5586
|
if (this.styleTheme !== this.props.themeType) {
|
|
5488
5587
|
this.styles = {
|
|
5489
5588
|
cellIdIconFolder: Utils_1.default.getStyle(this.props.theme, styles.cellIdIconFolder),
|