@iobroker/json-config 1.0.0 → 1.0.2

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 (48) hide show
  1. package/build/JsonConfigComponent/DeviceManager/Communication.d.ts +63 -0
  2. package/build/JsonConfigComponent/DeviceManager/Communication.js +247 -0
  3. package/build/JsonConfigComponent/DeviceManager/Communication.js.map +1 -0
  4. package/build/JsonConfigComponent/DeviceManager/DeviceActionButton.d.ts +11 -0
  5. package/build/JsonConfigComponent/DeviceManager/DeviceActionButton.js +10 -0
  6. package/build/JsonConfigComponent/DeviceManager/DeviceActionButton.js.map +1 -0
  7. package/build/JsonConfigComponent/DeviceManager/DeviceCard.d.ts +53 -0
  8. package/build/JsonConfigComponent/DeviceManager/DeviceCard.js +308 -0
  9. package/build/JsonConfigComponent/DeviceManager/DeviceCard.js.map +1 -0
  10. package/build/JsonConfigComponent/DeviceManager/DeviceControl.d.ts +45 -0
  11. package/build/JsonConfigComponent/DeviceManager/DeviceControl.js +119 -0
  12. package/build/JsonConfigComponent/DeviceManager/DeviceControl.js.map +1 -0
  13. package/build/JsonConfigComponent/DeviceManager/DeviceImageUpload.d.ts +12 -0
  14. package/build/JsonConfigComponent/DeviceManager/DeviceImageUpload.js +65 -0
  15. package/build/JsonConfigComponent/DeviceManager/DeviceImageUpload.js.map +1 -0
  16. package/build/JsonConfigComponent/DeviceManager/DeviceList.d.ts +51 -0
  17. package/build/JsonConfigComponent/DeviceManager/DeviceList.js +235 -0
  18. package/build/JsonConfigComponent/DeviceManager/DeviceList.js.map +1 -0
  19. package/build/JsonConfigComponent/DeviceManager/DeviceStatus.d.ts +13 -0
  20. package/build/JsonConfigComponent/DeviceManager/DeviceStatus.js +106 -0
  21. package/build/JsonConfigComponent/DeviceManager/DeviceStatus.js.map +1 -0
  22. package/build/JsonConfigComponent/DeviceManager/InstanceActionButton.d.ts +7 -0
  23. package/build/JsonConfigComponent/DeviceManager/InstanceActionButton.js +11 -0
  24. package/build/JsonConfigComponent/DeviceManager/InstanceActionButton.js.map +1 -0
  25. package/build/JsonConfigComponent/DeviceManager/JsonConfig.d.ts +11 -0
  26. package/build/JsonConfigComponent/DeviceManager/JsonConfig.js +66 -0
  27. package/build/JsonConfigComponent/DeviceManager/JsonConfig.js.map +1 -0
  28. package/build/JsonConfigComponent/DeviceManager/TooltipButton.d.ts +10 -0
  29. package/build/JsonConfigComponent/DeviceManager/TooltipButton.js +17 -0
  30. package/build/JsonConfigComponent/DeviceManager/TooltipButton.js.map +1 -0
  31. package/build/JsonConfigComponent/DeviceManager/Utils.d.ts +12 -0
  32. package/build/JsonConfigComponent/DeviceManager/Utils.js +150 -0
  33. package/build/JsonConfigComponent/DeviceManager/Utils.js.map +1 -0
  34. package/build/JsonConfigComponent/DeviceManager/i18n/de.json +21 -0
  35. package/build/JsonConfigComponent/DeviceManager/i18n/en.json +21 -0
  36. package/build/JsonConfigComponent/DeviceManager/i18n/es.json +21 -0
  37. package/build/JsonConfigComponent/DeviceManager/i18n/fr.json +21 -0
  38. package/build/JsonConfigComponent/DeviceManager/i18n/it.json +21 -0
  39. package/build/JsonConfigComponent/DeviceManager/i18n/nl.json +21 -0
  40. package/build/JsonConfigComponent/DeviceManager/i18n/pl.json +21 -0
  41. package/build/JsonConfigComponent/DeviceManager/i18n/pt.json +21 -0
  42. package/build/JsonConfigComponent/DeviceManager/i18n/ru.json +21 -0
  43. package/build/JsonConfigComponent/DeviceManager/i18n/uk.json +21 -0
  44. package/build/JsonConfigComponent/DeviceManager/i18n/zh-cn.json +21 -0
  45. package/build/JsonConfigComponent/DeviceManager/index.d.ts +2 -0
  46. package/build/JsonConfigComponent/DeviceManager/index.js +3 -0
  47. package/build/JsonConfigComponent/DeviceManager/index.js.map +1 -0
  48. package/package.json +1 -1
@@ -0,0 +1,308 @@
1
+ import React, { Component } from 'react';
2
+ import { Button, Typography, Dialog, DialogActions, DialogContent, IconButton, Fab, DialogTitle, Card, CardActions, CardHeader, CardContent, Paper, } from '@mui/material';
3
+ import { MoreVert as MoreVertIcon, VideogameAsset as ControlIcon, Close as CloseIcon, } from '@mui/icons-material';
4
+ import Utils from '@/Utils';
5
+ import I18n from '@/JsonConfigComponent/wrapper/i18n';
6
+ import { Icon } from '@iobroker/adapter-react-v5';
7
+ import DeviceActionButton from './DeviceActionButton';
8
+ import DeviceControlComponent from './DeviceControl';
9
+ import DeviceStatus from './DeviceStatus';
10
+ import JsonConfig from './JsonConfig';
11
+ import DeviceImageUpload from './DeviceImageUpload';
12
+ import { getTranslation } from './Utils';
13
+ const NoImageIcon = (props) => React.createElement("svg", { viewBox: "0 0 24 24", width: "24", height: "24", style: props.style, className: props.className },
14
+ React.createElement("path", { fill: "currentColor", d: "M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z" }));
15
+ function getText(text) {
16
+ if (typeof text === 'object') {
17
+ return text[I18n.getLanguage()] || text.en;
18
+ }
19
+ return text;
20
+ }
21
+ /**
22
+ * Device Card Component
23
+ */
24
+ class DeviceCard extends Component {
25
+ constructor(props) {
26
+ super(props);
27
+ this.state = {
28
+ open: false,
29
+ details: null,
30
+ data: {},
31
+ icon: props.device.icon,
32
+ showControlDialog: false,
33
+ };
34
+ }
35
+ async fetchIcon() {
36
+ if (!this.props.device.icon) {
37
+ // try to load the icon from file storage
38
+ const fileName = `${this.props.device.manufacturer ? `${this.props.device.manufacturer}_` : ''}${this.props.device.model ? this.props.device.model : this.props.device.id}`;
39
+ try {
40
+ const file = await this.props.socket.readFile(this.props.instanceId.replace('system.adapter.', ''), `${fileName}.webp`, true);
41
+ this.setState({ icon: `data:image/${file.mimeType},${file}` });
42
+ // const response = await fetch(url);
43
+ // if (response.ok) {
44
+ // const blob = await response.blob();
45
+ // const reader = new FileReader();
46
+ // reader.onloadend = () => {
47
+ // setIcon(reader.result);
48
+ // };
49
+ // reader.readAsDataURL(blob);
50
+ // } else {
51
+ // throw new Error('Response not ok');
52
+ // }
53
+ }
54
+ catch (error) {
55
+ this.state.icon && this.setState({ icon: '' });
56
+ }
57
+ }
58
+ }
59
+ componentDidMount() {
60
+ this.fetchIcon()
61
+ .catch(e => console.error(e));
62
+ }
63
+ /**
64
+ * Load the device details
65
+ */
66
+ async loadDetails() {
67
+ console.log(`Loading device details for ${this.props.device.id}... from ${this.props.instanceId}`);
68
+ const details = await this.props.socket.sendTo(this.props.instanceId, 'dm:deviceDetails', this.props.device.id);
69
+ console.log(`Got device details for ${this.props.device.id}:`, details);
70
+ this.setState({ details, data: details?.data || {} });
71
+ }
72
+ /**
73
+ * Refresh the device details
74
+ */
75
+ refresh = () => {
76
+ this.setState({ details: null });
77
+ this.loadDetails().catch(console.error);
78
+ };
79
+ /**
80
+ * Copy the device ID to the clipboard
81
+ * @returns {void}
82
+ */
83
+ copyToClipboard = async () => {
84
+ const textToCopy = this.props.device.id;
85
+ Utils.copyToClipboard(textToCopy);
86
+ alert(`${getTranslation('copied')} ${textToCopy} ${getTranslation('toClipboard')}!`);
87
+ };
88
+ renderDialog() {
89
+ if (!this.state.open || !this.state.details) {
90
+ return null;
91
+ }
92
+ return React.createElement(Dialog, { open: !0, maxWidth: "md", onClose: () => this.setState({ open: false }) },
93
+ React.createElement(DialogContent, null,
94
+ React.createElement(JsonConfig, { instanceId: this.props.instanceId, socket: this.props.socket, schema: this.state.details.schema, data: this.state.data, onChange: (data) => this.setState({ data }) })),
95
+ React.createElement(DialogActions, null,
96
+ React.createElement(Button, { disabled: !this.props.alive, variant: "contained", color: "primary", onClick: () => this.setState({ open: false }), autoFocus: true }, getTranslation('closeButtonText'))));
97
+ }
98
+ renderControlDialog() {
99
+ if (!this.state.showControlDialog || !this.props.alive) {
100
+ return null;
101
+ }
102
+ const colors = { primary: '#111', secondary: '#888' };
103
+ return React.createElement(Dialog, { open: !0, onClose: () => this.setState({ showControlDialog: false }) },
104
+ React.createElement(DialogTitle, null,
105
+ this.props.title,
106
+ React.createElement(IconButton, { style: {
107
+ position: 'absolute',
108
+ top: 5,
109
+ right: 5,
110
+ zIndex: 10,
111
+ }, onClick: () => this.setState({ showControlDialog: false }) },
112
+ React.createElement(CloseIcon, null))),
113
+ React.createElement(DialogContent, { style: { display: 'flex', flexDirection: 'column' } }, this.props.device.controls?.map(control => React.createElement(DeviceControlComponent, { disabled: false, key: control.id, control: control, socket: this.props.socket, colors: colors, deviceId: this.props.device.id, controlHandler: this.props.controlHandler, controlStateHandler: this.props.controlStateHandler }))));
114
+ }
115
+ renderControls() {
116
+ const colors = { primary: '#111', secondary: '#888' };
117
+ const firstControl = this.props.device.controls?.[0];
118
+ if (this.props.device.controls?.length === 1 && firstControl && ((firstControl.type === 'icon' || firstControl.type === 'switch') && !firstControl.label)) {
119
+ // control can be placed in button icon
120
+ return React.createElement(DeviceControlComponent, { disabled: !this.props.alive, control: firstControl, colors: colors, socket: this.props.socket, deviceId: this.props.device.id, controlHandler: this.props.controlHandler, controlStateHandler: this.props.controlStateHandler });
121
+ }
122
+ if (this.props.device.controls?.length) {
123
+ // place button and show controls dialog
124
+ return React.createElement(Fab, { size: "small", disabled: !this.props.alive, onClick: () => this.setState({ showControlDialog: true }) },
125
+ React.createElement(ControlIcon, null));
126
+ }
127
+ return null;
128
+ }
129
+ renderActions() {
130
+ return this.props.device.actions?.length ? this.props.device.actions.map(a => React.createElement(DeviceActionButton, { disabled: !this.props.alive, key: a.id, deviceId: this.props.device.id, action: a, deviceHandler: this.props.deviceHandler, refresh: this.refresh })) : null;
131
+ }
132
+ renderSmall() {
133
+ const hasDetails = this.props.device.hasDetails;
134
+ const status = !this.props.device.status ? [] : Array.isArray(this.props.device.status) ? this.props.device.status : [this.props.device.status];
135
+ return React.createElement(Card, { sx: {
136
+ maxWidth: 345,
137
+ minWidth: 200,
138
+ } },
139
+ React.createElement(CardHeader, { sx: theme => ({
140
+ backgroundColor: this.props.device.color || theme.palette.secondary.main,
141
+ color: this.props.device.color ? Utils.invertColor(this.props.device.color, true) : theme.palette.secondary.contrastText,
142
+ maxWidth: 345,
143
+ }), avatar: React.createElement("div", null,
144
+ this.props.uploadImagesToInstance ? React.createElement(DeviceImageUpload, { uploadImagesToInstance: this.props.uploadImagesToInstance, deviceId: this.props.device.id, manufacturer: getText(this.props.device.manufacturer), model: getText(this.props.device.model), onImageSelect: async (imageData) => imageData && this.setState({ icon: imageData }), socket: this.props.socket }) : null,
145
+ this.state.icon ? React.createElement(Icon, { src: this.state.icon }) : React.createElement(NoImageIcon, null)), action: hasDetails ? React.createElement(IconButton, { "aria-label": "settings", onClick: () => {
146
+ if (!this.state.open) {
147
+ this.loadDetails().catch(console.error);
148
+ this.setState({ open: true });
149
+ }
150
+ } },
151
+ React.createElement(MoreVertIcon, null)) : null, title: this.props.title, subheader: this.props.device.manufacturer ? React.createElement("span", null,
152
+ React.createElement("b", { style: { marginRight: 4 } },
153
+ getTranslation('manufacturer'),
154
+ ":"),
155
+ getText(this.props.device.manufacturer)) : null }),
156
+ React.createElement(CardContent, { style: { position: 'relative' } },
157
+ status?.length ? React.createElement("div", { style: {
158
+ display: 'flex',
159
+ position: 'absolute',
160
+ top: -11,
161
+ background: '#88888880',
162
+ padding: '0 8px',
163
+ borderRadius: 5,
164
+ width: 'calc(100% - 46px)',
165
+ } }, status.map((s, i) => React.createElement(DeviceStatus, { key: i, status: s }))) : null,
166
+ React.createElement("div", null,
167
+ React.createElement(Typography, { variant: "body1" },
168
+ React.createElement("div", { onClick: this.copyToClipboard },
169
+ React.createElement("b", null, "ID:"),
170
+ React.createElement("span", { style: { marginLeft: 4 } }, this.props.device.id.replace(/.*\.\d\./, ''))),
171
+ this.props.device.manufacturer ? React.createElement("div", null,
172
+ React.createElement("b", { style: { marginRight: 4 } },
173
+ getTranslation('manufacturer'),
174
+ ":"),
175
+ getText(this.props.device.manufacturer)) : null,
176
+ this.props.device.model ? React.createElement("div", null,
177
+ React.createElement("b", { style: { marginRight: 4 } },
178
+ getTranslation('model'),
179
+ ":"),
180
+ getText(this.props.device.model)) : null))),
181
+ React.createElement(CardActions, { disableSpacing: true },
182
+ this.renderActions(),
183
+ React.createElement("div", { style: { flexGrow: 1 } }),
184
+ this.renderControls()),
185
+ this.renderDialog(),
186
+ this.renderControlDialog());
187
+ }
188
+ renderBig() {
189
+ const cardStyle = {
190
+ // backgroundColor: '#fafafa',
191
+ width: 300,
192
+ minHeight: 280,
193
+ margin: 10,
194
+ overflow: 'hidden',
195
+ display: 'inline-block',
196
+ };
197
+ /** @type {CSSProperties} */
198
+ const headerStyle = {
199
+ display: 'flex',
200
+ position: 'relative',
201
+ justifyContent: 'space-between',
202
+ minHeight: 60,
203
+ color: '#000',
204
+ padding: '0 10px 0 10px',
205
+ backgroundColor: '#77c7ff8c',
206
+ borderRadius: '4px 4px 0 0',
207
+ };
208
+ /** @type {CSSProperties} */
209
+ const imgAreaStyle = {
210
+ height: 45,
211
+ width: 45,
212
+ margin: 'auto',
213
+ justifyContent: 'center',
214
+ display: 'grid',
215
+ };
216
+ /** @type {CSSProperties} */
217
+ const imgStyle = {
218
+ zIndex: 2,
219
+ maxWidth: '100%',
220
+ maxHeight: '100%',
221
+ };
222
+ /** @type {CSSProperties} */
223
+ const titleStyle = {
224
+ color: '#333',
225
+ width: '100%',
226
+ fontSize: 16,
227
+ fontWeight: 'bold',
228
+ paddingTop: 16,
229
+ paddingLeft: 8,
230
+ whiteSpace: 'nowrap',
231
+ overflow: 'hidden',
232
+ textOverflow: 'ellipsis',
233
+ };
234
+ /** @type {CSSProperties} */
235
+ const detailsButtonStyle = {
236
+ right: 20,
237
+ bottom: -20,
238
+ position: 'absolute',
239
+ };
240
+ /** @type {CSSProperties} */
241
+ const bodyStyle = {
242
+ height: 'calc(100% - 116px)',
243
+ };
244
+ /** @type {CSSProperties} */
245
+ const deviceInfoStyle = {
246
+ padding: '20px 16px 0 16px',
247
+ height: 133,
248
+ };
249
+ /** @type {CSSProperties} */
250
+ const statusStyle = {
251
+ padding: '15px 15px 0 15px',
252
+ height: 41,
253
+ };
254
+ const status = !this.props.device.status ? [] : Array.isArray(this.props.device.status) ? this.props.device.status : [this.props.device.status];
255
+ return React.createElement(Paper, { style: cardStyle, key: this.props.id },
256
+ React.createElement("div", { style: headerStyle },
257
+ React.createElement("div", { style: imgAreaStyle },
258
+ this.props.uploadImagesToInstance ? React.createElement(DeviceImageUpload, { uploadImagesToInstance: this.props.uploadImagesToInstance, deviceId: this.props.device.id, manufacturer: getText(this.props.device.manufacturer), model: getText(this.props.device.model), onImageSelect: async (imageData) => imageData && this.setState({ icon: imageData }), socket: this.props.socket }) : null,
259
+ React.createElement(Icon, { src: this.state.icon, style: imgStyle })),
260
+ React.createElement("div", { style: titleStyle }, this.props.title),
261
+ this.props.device.hasDetails ? React.createElement(Fab, { disabled: !this.props.alive, size: "small", style: detailsButtonStyle, onClick: () => {
262
+ if (!this.state.open) {
263
+ this.loadDetails().catch(console.error);
264
+ this.setState({ open: true });
265
+ }
266
+ }, color: "primary" },
267
+ React.createElement(MoreVertIcon, null)) : null),
268
+ React.createElement("div", { style: statusStyle }, status.map((s, i) => React.createElement(DeviceStatus, { key: i, status: s }))),
269
+ React.createElement("div", { style: bodyStyle },
270
+ React.createElement(Typography, { variant: "body1", style: deviceInfoStyle },
271
+ React.createElement("div", { onClick: this.copyToClipboard },
272
+ React.createElement("b", { style: { marginRight: 4 } }, "ID:"),
273
+ this.props.device.id.replace(/.*\.\d\./, '')),
274
+ this.props.device.manufacturer ? React.createElement("div", null,
275
+ React.createElement("b", { style: { marginRight: 4 } },
276
+ getTranslation('manufacturer'),
277
+ ":"),
278
+ getText(this.props.device.manufacturer)) : null,
279
+ this.props.device.model ? React.createElement("div", null,
280
+ React.createElement("b", { style: { marginRight: 4 } },
281
+ getTranslation('model'),
282
+ ":"),
283
+ getText(this.props.device.model)) : null),
284
+ !!this.props.device.actions?.length && React.createElement("div", { style: {
285
+ flex: 1,
286
+ position: 'relative',
287
+ display: 'flex',
288
+ gap: 8,
289
+ paddingBottom: 5,
290
+ height: 34,
291
+ paddingLeft: 10,
292
+ paddingRight: 10,
293
+ } },
294
+ this.renderActions(),
295
+ React.createElement("div", { style: { flexGrow: 1 } }),
296
+ this.renderControls())),
297
+ this.renderDialog(),
298
+ this.renderControlDialog());
299
+ }
300
+ render() {
301
+ if (this.props.smallCards) {
302
+ return this.renderSmall();
303
+ }
304
+ return this.renderBig();
305
+ }
306
+ }
307
+ export default DeviceCard;
308
+ //# sourceMappingURL=DeviceCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeviceCard.js","sourceRoot":"./src/","sources":["JsonConfigComponent/DeviceManager/DeviceCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EACH,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAChD,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAC/C,WAAW,EAAE,KAAK,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACH,QAAQ,IAAI,YAAY,EACxB,cAAc,IAAI,WAAW,EAC7B,KAAK,IAAI,SAAS,GACrB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,IAAI,MAAM,oCAAoC,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,sBAAsB,MAAM,iBAAiB,CAAC;AACrD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,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cAAc,CAAC;gCAE/B;wBACH,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CACtC,CAAC,CAAC,CAAC,IAAI;oBACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;wBACvB,2BAAG,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;4BACvB,cAAc,CAAC,OAAO,CAAC;gCAExB;wBACH,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAC/B,CAAC,CAAC,CAAC,IAAI,CACJ;gBACZ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,IAAI,6BACpC,KAAK,EAAE;wBACH,IAAI,EAAE,CAAC;wBACP,QAAQ,EAAE,UAAU;wBACpB,OAAO,EAAE,MAAM;wBACf,GAAG,EAAE,CAAC;wBACN,aAAa,EAAE,CAAC;wBAChB,MAAM,EAAE,EAAE;wBACV,WAAW,EAAE,EAAE;wBACf,YAAY,EAAE,EAAE;qBACnB;oBAEA,IAAI,CAAC,aAAa,EAAE;oBACrB,6BAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAI;oBAC9B,IAAI,CAAC,cAAc,EAAE,CACpB,CACJ;YACL,IAAI,CAAC,YAAY,EAAE;YACnB,IAAI,CAAC,mBAAmB,EAAE,CACvB,CAAC;IACb,CAAC;IAED,MAAM;QACF,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;YACvB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;SAC7B;QAED,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC5B,CAAC;CACJ;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,45 @@
1
+ import React, { Component } from 'react';
2
+ import { ControlBase, ControlState } from '@iobroker/dm-utils/build/types/base';
3
+ interface DeviceControlProps {
4
+ deviceId: string;
5
+ control: any;
6
+ socket: any;
7
+ controlHandler: (deviceId: string, control: ControlBase, state: ControlState) => () => Promise<ioBroker.State | null>;
8
+ controlStateHandler: (deviceId: string, control: ControlBase) => () => Promise<ioBroker.State | null>;
9
+ colors: any;
10
+ disabled?: boolean;
11
+ }
12
+ interface DeviceControlState {
13
+ value: any;
14
+ ts: number;
15
+ }
16
+ /**
17
+ * Device Control component
18
+ * @param {object} props - Parameters
19
+ * @param {object} props.control - Control object
20
+ * @param {object} props.socket - Socket object
21
+ * @param {object} props.controlHandler - Control handler to set the state
22
+ * @param {object} props.controlStateHandler - Control handler to read the state
23
+ * @returns {React.JSX.Element|null}
24
+ * @constructor
25
+ */
26
+ export default class DeviceControl extends Component<DeviceControlProps, DeviceControlState> {
27
+ constructor(props: DeviceControlProps);
28
+ componentDidMount(): void;
29
+ stateHandler: (id: string, state: ioBroker.State) => Promise<void>;
30
+ componentWillUnmount(): void;
31
+ static getDerivedStateFromProps(props: DeviceControlProps, state: DeviceControlState): {
32
+ value: any;
33
+ ts: any;
34
+ };
35
+ sendControl(deviceId: string, control: ControlBase, value: ControlState): Promise<void>;
36
+ renderButton(): React.JSX.Element;
37
+ renderSwitch(): React.JSX.Element;
38
+ getColor(): any;
39
+ renderSelect(): void;
40
+ renderSlider(): void;
41
+ renderColor(): void;
42
+ renderIcon(): React.JSX.Element;
43
+ render(): React.JSX.Element;
44
+ }
45
+ export {};
@@ -0,0 +1,119 @@
1
+ import React, { Component } from 'react';
2
+ import { Button, Fab, Switch, } from '@mui/material';
3
+ import { renderIcon, getTranslation } from './Utils';
4
+ /**
5
+ * Device Control component
6
+ * @param {object} props - Parameters
7
+ * @param {object} props.control - Control object
8
+ * @param {object} props.socket - Socket object
9
+ * @param {object} props.controlHandler - Control handler to set the state
10
+ * @param {object} props.controlStateHandler - Control handler to read the state
11
+ * @returns {React.JSX.Element|null}
12
+ * @constructor
13
+ */
14
+ export default class DeviceControl extends Component {
15
+ constructor(props) {
16
+ super(props);
17
+ this.state = {
18
+ value: props.control.state?.val,
19
+ ts: props.control.state?.ts,
20
+ };
21
+ }
22
+ componentDidMount() {
23
+ if (this.props.control.stateId) {
24
+ this.props.socket.subscribeState(this.props.control.stateId, this.stateHandler);
25
+ }
26
+ }
27
+ stateHandler = async (id, state) => {
28
+ if (id === this.props.control.stateId && state) {
29
+ // request new state
30
+ const newState = await (this.props.controlStateHandler(this.props.deviceId, this.props.control)());
31
+ if (newState?.ts && (!this.state.ts || newState.ts > this.state.ts)) {
32
+ this.setState({
33
+ value: newState.val,
34
+ ts: newState.ts,
35
+ });
36
+ }
37
+ }
38
+ };
39
+ componentWillUnmount() {
40
+ if (this.props.control.stateId) {
41
+ this.props.socket.unsubscribeState(this.props.control.stateId, this.stateHandler);
42
+ }
43
+ }
44
+ static getDerivedStateFromProps(props, state) {
45
+ if (props.control.state?.ts && (!state.ts || props.control.state?.ts > state.ts)) {
46
+ return {
47
+ value: props.control.state.val,
48
+ ts: props.control.state.ts,
49
+ };
50
+ }
51
+ return null;
52
+ }
53
+ async sendControl(deviceId, control, value) {
54
+ const result = await (this.props.controlHandler(deviceId, control, value)());
55
+ if (result?.ts && (!this.state.ts || result?.ts > this.state.ts)) {
56
+ this.setState({
57
+ value: result.val,
58
+ ts: result.ts,
59
+ });
60
+ }
61
+ }
62
+ renderButton() {
63
+ const tooltip = getTranslation(this.props.control.description);
64
+ const icon = renderIcon(this.props.control, this.props.colors, this.state.value);
65
+ if (!this.props.control.label) {
66
+ return React.createElement(Fab, { disabled: this.props.disabled, title: tooltip, onClick: () => this.sendControl(this.props.deviceId, this.props.control, true) }, icon);
67
+ }
68
+ return React.createElement(Button, { disabled: this.props.disabled, title: tooltip, onClick: () => this.sendControl(this.props.deviceId, this.props.control, true), startIcon: icon }, this.props.control.label);
69
+ }
70
+ renderSwitch() {
71
+ const tooltip = getTranslation(this.props.control.description);
72
+ // const icon = renderIcon(this.props.control, this.props.colors, this.state.value);
73
+ return React.createElement(Switch, { disabled: this.props.disabled, title: tooltip, checked: this.state.value, onChange: e => this.sendControl(this.props.deviceId, this.props.control, e.target.checked) });
74
+ }
75
+ getColor() {
76
+ let color;
77
+ if (this.state.value) {
78
+ color = this.props.control.colorOn || 'primary';
79
+ }
80
+ else if (this.props.control.type === 'switch') {
81
+ color = this.props.control.color;
82
+ }
83
+ if (color === 'primary') {
84
+ return this.props.colors.primary;
85
+ }
86
+ if (color === 'secondary') {
87
+ return this.props.colors.secondary;
88
+ }
89
+ return color;
90
+ }
91
+ renderSelect() {
92
+ }
93
+ renderSlider() {
94
+ }
95
+ renderColor() {
96
+ }
97
+ renderIcon() {
98
+ const tooltip = getTranslation(this.props.control.description);
99
+ const icon = renderIcon(this.props.control, this.props.colors, this.state.value);
100
+ const color = this.getColor();
101
+ if (!this.props.control.label) {
102
+ return React.createElement(Fab, { disabled: this.props.disabled, size: "small", title: tooltip, color: color === this.props.colors.primary ? 'primary' : (color === this.props.colors.secondary ? 'secondary' : undefined), style: color === this.props.colors.primary || color === this.props.colors.secondary ? undefined : { color }, onClick: () => this.sendControl(this.props.deviceId, this.props.control, !this.state.value) }, icon);
103
+ }
104
+ return React.createElement(Button, { disabled: this.props.disabled, title: tooltip, color: color === this.props.colors.primary ? 'primary' : (color === this.props.colors.secondary ? 'secondary' : undefined), style: color === this.props.colors.primary || color === this.props.colors.secondary ? undefined : { color }, onClick: () => this.sendControl(this.props.deviceId, this.props.control, !this.state.value), startIcon: icon }, this.props.control.label);
105
+ }
106
+ render() {
107
+ if (this.props.control.type === 'button') {
108
+ return this.renderButton();
109
+ }
110
+ if (this.props.control.type === 'icon') {
111
+ return this.renderIcon();
112
+ }
113
+ if (this.props.control.type === 'switch') {
114
+ return this.renderSwitch();
115
+ }
116
+ return React.createElement("div", { style: { color: 'red' } }, this.props.control.type);
117
+ }
118
+ }
119
+ //# sourceMappingURL=DeviceControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeviceControl.js","sourceRoot":"./src/","sources":["JsonConfigComponent/DeviceManager/DeviceControl.ts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3G,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAC3F,SAAS,EAAE,IAAI,IAEd,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CACpB,CAAC;IACd,CAAC;IAED,MAAM;QACF,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;YACtC,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;SAC9B;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;YACpC,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;SAC5B;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;YACtC,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;SAC9B;QAED,OAAO,6BAAK,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAO,CAAC;IACzE,CAAC;CACJ"}
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { Connection } from '@iobroker/socket-client';
3
+ interface DeviceImageUploadProps {
4
+ socket: Connection;
5
+ manufacturer?: string;
6
+ model?: string;
7
+ deviceId: string;
8
+ onImageSelect: (image: string) => void;
9
+ uploadImagesToInstance: string;
10
+ }
11
+ declare function DeviceImageUpload(params: DeviceImageUploadProps): React.JSX.Element | null;
12
+ export default DeviceImageUpload;
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ function DeviceImageUpload(params) {
3
+ const { socket, manufacturer, model, deviceId, onImageSelect, uploadImagesToInstance, } = params;
4
+ const handleImageUpload = async (event) => {
5
+ const target = event.target;
6
+ const files = target.files;
7
+ if (!files || files.length === 0) {
8
+ return;
9
+ }
10
+ const file = files[0];
11
+ if (file) {
12
+ const reader = new FileReader();
13
+ reader.onload = async (e) => {
14
+ if (!e.target || !e.target.result) {
15
+ return;
16
+ }
17
+ const img = new Image();
18
+ img.src = e.target.result;
19
+ img.onload = async () => {
20
+ const maxWidth = 50;
21
+ const maxHeight = 50;
22
+ let width = img.width;
23
+ let height = img.height;
24
+ if (width > height) {
25
+ if (width > maxWidth) {
26
+ height *= maxWidth / width;
27
+ width = maxWidth;
28
+ }
29
+ }
30
+ else if (height > maxHeight) {
31
+ width *= maxHeight / height;
32
+ height = maxHeight;
33
+ }
34
+ const canvas = document.createElement('canvas');
35
+ const ctx = canvas.getContext('2d');
36
+ if (ctx) {
37
+ canvas.width = width;
38
+ canvas.height = height;
39
+ ctx.drawImage(img, 0, 0, width, height);
40
+ const resizedImage = canvas.toDataURL('image/webp');
41
+ // Build the file name from a manufacturer and model, if not available, use device id
42
+ const fileName = `${manufacturer ? `${manufacturer}_` : ''}${model || deviceId}`;
43
+ const base64Data = resizedImage.replace(/^data:image\/webp;base64,/, '');
44
+ const response = await socket.writeFile64(uploadImagesToInstance, fileName, base64Data);
45
+ console.log(`saveImage response: ${JSON.stringify(response)}`);
46
+ onImageSelect && onImageSelect(resizedImage);
47
+ }
48
+ };
49
+ };
50
+ reader.readAsDataURL(file);
51
+ }
52
+ };
53
+ const imageUploadButtonStyle = {
54
+ // make the button invisible but still clickable
55
+ opacity: 0,
56
+ position: 'absolute',
57
+ width: '45px',
58
+ height: '45px',
59
+ zIndex: 3,
60
+ };
61
+ return React.createElement("div", null,
62
+ React.createElement("input", { style: imageUploadButtonStyle, type: "file", accept: "image/*", onChange: handleImageUpload }));
63
+ }
64
+ export default DeviceImageUpload;
65
+ //# sourceMappingURL=DeviceImageUpload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeviceImageUpload.js","sourceRoot":"./src/","sources":["JsonConfigComponent/DeviceManager/DeviceImageUpload.tsx"],"names":[],"mappings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,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,CAAC;KACZ,CAAC;IAEF,OAAO;QACH,+BAAO,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,SAAS,EAAC,QAAQ,EAAE,iBAAiB,GAAI,CAChG,CAAC;AACX,CAAC;AAED,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { DeviceInfo, InstanceDetails } from '@iobroker/dm-utils';
3
+ import Communication, { CommunicationProps, CommunicationState } from './Communication';
4
+ interface DeviceListProps extends CommunicationProps {
5
+ uploadImagesToInstance?: string;
6
+ filter?: string;
7
+ embedded?: boolean;
8
+ title?: string;
9
+ style?: React.CSSProperties;
10
+ smallCards?: boolean;
11
+ }
12
+ interface DeviceListState extends CommunicationState {
13
+ devices: DeviceInfo[];
14
+ filteredDevices: DeviceInfo[];
15
+ filter: string;
16
+ instanceInfo: InstanceDetails;
17
+ loading: boolean;
18
+ alive: boolean | null;
19
+ }
20
+ /**
21
+ * Device List Component
22
+ * @param {object} params - Component parameters
23
+ * @param {object} params.socket - socket object
24
+ * @param {string} params.selectedInstance - Selected instance
25
+ * @param {string} params.uploadImagesToInstance - Instance to upload images to
26
+ * @param {string} params.filter - Filter
27
+ * @param {string} params.empbedded - true if this list used with multiple instances and false if only with one
28
+ * @param {string} params.title - Title in appbar (only in non-embedded mode)
29
+ * @param {string} params.style - Style of devices list
30
+ * @returns {*[]} - Array of device cards
31
+ */
32
+ export default class DeviceList extends Communication<DeviceListProps, DeviceListState> {
33
+ static i18nInitialized: boolean;
34
+ private lastPropsFilter;
35
+ private lastInstance;
36
+ private filterTimeout;
37
+ private readonly language;
38
+ constructor(props: DeviceListProps);
39
+ componentDidMount(): Promise<void>;
40
+ componentWillUnmount(): void;
41
+ aliveHandler: ioBroker.StateChangeHandler;
42
+ /**
43
+ * Load devices
44
+ */
45
+ loadData(): void;
46
+ getText(text: ioBroker.StringOrTranslated): string;
47
+ applyFilter(): void;
48
+ handleFilterChange(filter: string): void;
49
+ renderContent(): React.JSX.Element | React.JSX.Element[] | null;
50
+ }
51
+ export {};