@iobroker/adapter-react-v5 4.8.0 → 4.8.1
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/JsonConfigComponent/DeviceManager/Communication.d.ts +1 -1
- package/Components/JsonConfigComponent/DeviceManager/Communication.js +2 -2
- package/Components/JsonConfigComponent/DeviceManager/DeviceList.d.ts +1 -1
- package/Components/JsonConfigComponent/DeviceManager/DeviceList.js +30 -20
- package/README.md +1 -1
- package/package.json +4 -4
|
@@ -42,7 +42,7 @@ declare class Communication<P extends CommunicationProps, S extends Communicatio
|
|
|
42
42
|
controlHandler: (deviceId: string, control: ControlBase, state: ControlState) => () => Promise<ioBroker.State | null>;
|
|
43
43
|
controlStateHandler: (deviceId: string, control: ControlBase) => () => Promise<ioBroker.State | null>;
|
|
44
44
|
constructor(props: P);
|
|
45
|
-
loadData():
|
|
45
|
+
loadData(): void;
|
|
46
46
|
sendActionToInstance: (command: string, messageToSend: any, refresh?: () => void) => void;
|
|
47
47
|
sendControlToInstance: (command: string, messageToSend: {
|
|
48
48
|
deviceId: string;
|
|
@@ -104,7 +104,7 @@ class Communication extends react_1.Component {
|
|
|
104
104
|
console.log('Response content', response.result);
|
|
105
105
|
if (response.result.refresh) {
|
|
106
106
|
if (response.result.refresh === true) {
|
|
107
|
-
this.loadData()
|
|
107
|
+
this.loadData();
|
|
108
108
|
console.log('Refreshing all');
|
|
109
109
|
}
|
|
110
110
|
else if (response.result.refresh === 'instance') {
|
|
@@ -174,7 +174,7 @@ class Communication extends react_1.Component {
|
|
|
174
174
|
}
|
|
175
175
|
// eslint-disable-next-line class-methods-use-this
|
|
176
176
|
loadData() {
|
|
177
|
-
|
|
177
|
+
console.error('loadData not implemented');
|
|
178
178
|
}
|
|
179
179
|
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
180
180
|
loadDevices() {
|
|
@@ -42,7 +42,7 @@ export default class DeviceList extends Communication<DeviceListProps, DeviceLis
|
|
|
42
42
|
/**
|
|
43
43
|
* Load devices
|
|
44
44
|
*/
|
|
45
|
-
loadData():
|
|
45
|
+
loadData(): void;
|
|
46
46
|
getText(text: ioBroker.StringOrTranslated): string;
|
|
47
47
|
applyFilter(): void;
|
|
48
48
|
handleFilterChange(filter: string): void;
|
|
@@ -110,12 +110,7 @@ class DeviceList extends Communication_1.default {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
if (alive) {
|
|
113
|
-
|
|
114
|
-
await this.loadData();
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
console.error(error);
|
|
118
|
-
}
|
|
113
|
+
this.loadData();
|
|
119
114
|
}
|
|
120
115
|
}
|
|
121
116
|
componentWillUnmount() {
|
|
@@ -124,14 +119,23 @@ class DeviceList extends Communication_1.default {
|
|
|
124
119
|
/**
|
|
125
120
|
* Load devices
|
|
126
121
|
*/
|
|
127
|
-
|
|
128
|
-
this.setState({ loading: true })
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
122
|
+
loadData() {
|
|
123
|
+
this.setState({ loading: true }, async () => {
|
|
124
|
+
console.log(`Loading devices for ${this.props.selectedInstance}...`);
|
|
125
|
+
let devices;
|
|
126
|
+
try {
|
|
127
|
+
devices = await this.loadDevices();
|
|
128
|
+
if (!devices || !Array.isArray(devices)) {
|
|
129
|
+
console.error(`Message returned from sendTo() doesn't look like one from DeviceManagement, did you accidentally handle the message in your adapter? ${JSON.stringify(devices)}`);
|
|
130
|
+
devices = [];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
console.error(error);
|
|
135
|
+
devices = [];
|
|
136
|
+
}
|
|
137
|
+
this.setState({ devices, loading: false }, () => this.applyFilter());
|
|
138
|
+
});
|
|
135
139
|
}
|
|
136
140
|
getText(text) {
|
|
137
141
|
if (typeof text === 'object') {
|
|
@@ -171,7 +175,7 @@ class DeviceList extends Communication_1.default {
|
|
|
171
175
|
}
|
|
172
176
|
if (this.props.embedded && this.lastInstance !== this.props.selectedInstance) {
|
|
173
177
|
this.lastInstance = this.props.selectedInstance;
|
|
174
|
-
setTimeout(() => this.loadData()
|
|
178
|
+
setTimeout(() => this.loadData(), 50);
|
|
175
179
|
}
|
|
176
180
|
let list;
|
|
177
181
|
if (!this.props.embedded && !this.state.alive) {
|
|
@@ -190,14 +194,18 @@ class DeviceList extends Communication_1.default {
|
|
|
190
194
|
list = this.state.filteredDevices.map(device => react_1.default.createElement(DeviceCard_1.default, { alive: !!this.state.alive, key: device.id, id: device.id, title: this.getText(device.name), device: device, instanceId: this.props.selectedInstance, uploadImagesToInstance: this.props.uploadImagesToInstance, deviceHandler: this.deviceHandler, controlHandler: this.controlHandler, controlStateHandler: this.controlStateHandler, socket: this.props.socket }));
|
|
191
195
|
}
|
|
192
196
|
if (this.props.embedded) {
|
|
193
|
-
return
|
|
197
|
+
return react_1.default.createElement(react_1.default.Fragment, null,
|
|
198
|
+
this.state.loading ? react_1.default.createElement(material_1.LinearProgress, { style: { width: '100%' } }) : null,
|
|
199
|
+
list);
|
|
194
200
|
}
|
|
195
201
|
return react_1.default.createElement("div", { style: { width: '100%', height: '100%', overflow: 'hidden' } },
|
|
196
202
|
react_1.default.createElement(material_1.Toolbar, { variant: "dense", style: { backgroundColor: '#777', display: 'flex' } },
|
|
197
203
|
this.props.title,
|
|
198
|
-
this.
|
|
199
|
-
|
|
200
|
-
|
|
204
|
+
this.props.selectedInstance ? react_1.default.createElement(material_1.Tooltip, { title: (0, Utils_1.getTranslation)('refreshTooltip') },
|
|
205
|
+
react_1.default.createElement("span", null,
|
|
206
|
+
react_1.default.createElement(material_1.IconButton, { onClick: () => this.loadDevices().catch(console.error), disabled: !this.state.alive, size: "small" },
|
|
207
|
+
react_1.default.createElement(icons_material_1.Refresh, null)))) : null,
|
|
208
|
+
this.state.alive && ((_b = (_a = this.state.instanceInfo) === null || _a === void 0 ? void 0 : _a.actions) === null || _b === void 0 ? void 0 : _b.length) ? react_1.default.createElement("div", { style: { marginLeft: 20 } }, this.state.instanceInfo.actions.map(action => react_1.default.createElement(InstanceActionButton_1.default, { key: action.id, action: action, instanceHandler: this.instanceHandler }))) : null,
|
|
201
209
|
react_1.default.createElement("div", { style: { flexGrow: 1 } }),
|
|
202
210
|
this.state.alive ? react_1.default.createElement(material_1.TextField, { variant: "standard", style: { width: 200 }, size: "small", label: (0, Utils_1.getTranslation)('filterLabelText'), onChange: e => this.handleFilterChange(e.target.value), value: this.state.filter, autoComplete: "off", inputProps: {
|
|
203
211
|
autoComplete: 'new-password',
|
|
@@ -209,7 +217,9 @@ class DeviceList extends Communication_1.default {
|
|
|
209
217
|
react_1.default.createElement(material_1.IconButton, { onClick: () => this.handleFilterChange(''), edge: "end" },
|
|
210
218
|
react_1.default.createElement(icons_material_1.Clear, null))) : null,
|
|
211
219
|
} }) : null),
|
|
212
|
-
react_1.default.createElement("div", { style: Object.assign({ width: '100%', height: 'calc(100% - 56px)', marginTop: 8, overflow: 'auto' }, this.props.style) },
|
|
220
|
+
react_1.default.createElement("div", { style: Object.assign({ width: '100%', height: 'calc(100% - 56px)', marginTop: 8, overflow: 'auto' }, this.props.style) },
|
|
221
|
+
this.state.loading ? react_1.default.createElement(material_1.LinearProgress, { style: { width: '100%' } }) : null,
|
|
222
|
+
list));
|
|
213
223
|
}
|
|
214
224
|
}
|
|
215
225
|
DeviceList.i18nInitialized = false;
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/adapter-react-v5",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.1",
|
|
4
4
|
"description": "React classes to develop admin interfaces for ioBroker with react.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Denis Haev (bluefox)",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@emotion/react": "^11.11.1",
|
|
31
31
|
"@emotion/styled": "^11.11.0",
|
|
32
|
-
"@iobroker/socket-client": "^2.3.
|
|
32
|
+
"@iobroker/socket-client": "^2.3.13",
|
|
33
33
|
"@iobroker/types": "^5.0.17",
|
|
34
34
|
"@iobroker/dm-utils": "^0.1.4",
|
|
35
35
|
"@mui/icons-material": "^5.15.0",
|
|
36
36
|
"@mui/material": "5.14.14",
|
|
37
37
|
"@mui/styles": "5.14.14",
|
|
38
38
|
"@mui/x-date-pickers": "^6.18.5",
|
|
39
|
-
"@sentry/browser": "^7.
|
|
40
|
-
"@sentry/integrations": "^7.
|
|
39
|
+
"@sentry/browser": "^7.88.0",
|
|
40
|
+
"@sentry/integrations": "^7.88.0",
|
|
41
41
|
"react-color": "^2.19.3",
|
|
42
42
|
"react-colorful": "^5.6.1",
|
|
43
43
|
"react-cropper": "^2.3.3",
|