@iobroker/dm-gui-components 0.0.2 → 0.0.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.
- package/DeviceList.d.ts +2 -2
- package/DeviceList.js +8 -8
- package/README.md +1 -1
- package/package.json +1 -1
package/DeviceList.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import Communication, { CommunicationProps, CommunicationState } from './Communi
|
|
|
4
4
|
interface DeviceListProps extends CommunicationProps {
|
|
5
5
|
uploadImagesToInstance?: string;
|
|
6
6
|
filter?: string;
|
|
7
|
-
|
|
7
|
+
embedded?: boolean;
|
|
8
8
|
title?: string;
|
|
9
9
|
style: React.CSSProperties;
|
|
10
10
|
}
|
|
@@ -33,7 +33,7 @@ export default class DeviceList extends Communication<DeviceListProps, DeviceLis
|
|
|
33
33
|
private lastPropsFilter;
|
|
34
34
|
private lastInstance;
|
|
35
35
|
private filterTimeout;
|
|
36
|
-
private language;
|
|
36
|
+
private readonly language;
|
|
37
37
|
constructor(props: DeviceListProps);
|
|
38
38
|
componentDidMount(): Promise<void>;
|
|
39
39
|
componentWillUnmount(): void;
|
package/DeviceList.js
CHANGED
|
@@ -67,7 +67,7 @@ class DeviceList extends Communication_1.default {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
// @ts-ignore
|
|
70
|
-
Object.
|
|
70
|
+
Object.assign(this.state, {
|
|
71
71
|
devices: [],
|
|
72
72
|
filteredDevices: [],
|
|
73
73
|
filter: '',
|
|
@@ -81,7 +81,7 @@ class DeviceList extends Communication_1.default {
|
|
|
81
81
|
this.language = adapter_react_v5_1.I18n.getLanguage();
|
|
82
82
|
}
|
|
83
83
|
async componentDidMount() {
|
|
84
|
-
if (!this.props.
|
|
84
|
+
if (!this.props.embedded) {
|
|
85
85
|
try {
|
|
86
86
|
// check if instance is alive
|
|
87
87
|
const alive = await this.props.socket.getState(`system.adapter.${this.props.selectedInstance}.alive`);
|
|
@@ -106,7 +106,7 @@ class DeviceList extends Communication_1.default {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
componentWillUnmount() {
|
|
109
|
-
if (!this.props.
|
|
109
|
+
if (!this.props.embedded) {
|
|
110
110
|
this.props.socket.unsubscribeState(`system.adapter.${this.props.selectedInstance}.alive`, this.aliveHandler);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
@@ -129,7 +129,7 @@ class DeviceList extends Communication_1.default {
|
|
|
129
129
|
return text;
|
|
130
130
|
}
|
|
131
131
|
applyFilter() {
|
|
132
|
-
const filter = this.props.
|
|
132
|
+
const filter = this.props.embedded ? this.props.filter : this.state.filter;
|
|
133
133
|
// filter devices name
|
|
134
134
|
if (filter) {
|
|
135
135
|
const filteredDevices = this.state.devices.filter(device => this.getText(device.name).toLowerCase().includes(filter.toLowerCase()));
|
|
@@ -154,16 +154,16 @@ class DeviceList extends Communication_1.default {
|
|
|
154
154
|
const emptyStyle = {
|
|
155
155
|
padding: 25,
|
|
156
156
|
};
|
|
157
|
-
if (this.props.
|
|
157
|
+
if (this.props.embedded && this.lastPropsFilter !== this.props.filter) {
|
|
158
158
|
this.lastPropsFilter = this.props.filter;
|
|
159
159
|
setTimeout(() => this.applyFilter(), 50);
|
|
160
160
|
}
|
|
161
|
-
if (this.props.
|
|
161
|
+
if (this.props.embedded && this.lastInstance !== this.props.selectedInstance) {
|
|
162
162
|
this.lastInstance = this.props.selectedInstance;
|
|
163
163
|
setTimeout(() => this.loadData().catch(console.error), 50);
|
|
164
164
|
}
|
|
165
165
|
let list;
|
|
166
|
-
if (!this.props.
|
|
166
|
+
if (!this.props.embedded && !this.state.alive) {
|
|
167
167
|
list = react_1.default.createElement("div", { style: emptyStyle },
|
|
168
168
|
react_1.default.createElement("span", null, (0, Utils_1.getTranslation)('instanceNotAlive')));
|
|
169
169
|
}
|
|
@@ -178,7 +178,7 @@ class DeviceList extends Communication_1.default {
|
|
|
178
178
|
else {
|
|
179
179
|
list = this.state.filteredDevices.map(device => react_1.default.createElement(DeviceCard_1.default, { 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 }));
|
|
180
180
|
}
|
|
181
|
-
if (this.props.
|
|
181
|
+
if (this.props.embedded) {
|
|
182
182
|
return list;
|
|
183
183
|
}
|
|
184
184
|
return react_1.default.createElement("div", { style: { width: '100%', height: '100%', overflow: 'hidden' } },
|
package/README.md
CHANGED