@iobroker/dm-gui-components 8.0.9 → 9.0.0
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/README.md +3 -0
- package/build/Communication.d.ts +10 -36
- package/build/Communication.js +90 -67
- package/build/Communication.js.map +1 -1
- package/build/DeviceActionButton.d.ts +3 -3
- package/build/DeviceActionButton.js +2 -2
- package/build/DeviceActionButton.js.map +1 -1
- package/build/DeviceCard.d.ts +28 -9
- package/build/DeviceCard.js +161 -63
- package/build/DeviceCard.js.map +1 -1
- package/build/DeviceControl.d.ts +5 -5
- package/build/DeviceControl.js.map +1 -1
- package/build/DeviceImageUpload.d.ts +2 -1
- package/build/DeviceImageUpload.js +1 -1
- package/build/DeviceImageUpload.js.map +1 -1
- package/build/DeviceList.d.ts +5 -7
- package/build/DeviceList.js +96 -86
- package/build/DeviceList.js.map +1 -1
- package/build/DeviceStatus.d.ts +7 -4
- package/build/DeviceStatus.js +37 -30
- package/build/DeviceStatus.js.map +1 -1
- package/build/InstanceActionButton.d.ts +1 -1
- package/build/InstanceActionButton.js.map +1 -1
- package/build/StateOrObjectHandler.d.ts +10 -0
- package/build/StateOrObjectHandler.js +141 -0
- package/build/StateOrObjectHandler.js.map +1 -0
- package/build/TooltipButton.d.ts +1 -0
- package/build/TooltipButton.js +4 -3
- package/build/TooltipButton.js.map +1 -1
- package/build/Utils.d.ts +1 -2
- package/build/Utils.js.map +1 -1
- package/build/hooks.d.ts +3 -0
- package/build/hooks.js +10 -0
- package/build/hooks.js.map +1 -0
- package/build/i18n/de.json +2 -1
- package/build/i18n/en.json +1 -0
- package/build/i18n/es.json +1 -0
- package/build/i18n/fr.json +1 -0
- package/build/i18n/it.json +1 -0
- package/build/i18n/nl.json +1 -0
- package/build/i18n/pl.json +1 -0
- package/build/i18n/pt.json +1 -0
- package/build/i18n/ru.json +1 -0
- package/build/i18n/uk.json +1 -0
- package/build/i18n/zh-cn.json +1 -0
- package/build/protocol/DmProtocolBase.d.ts +29 -0
- package/build/protocol/DmProtocolBase.js +12 -0
- package/build/protocol/DmProtocolBase.js.map +1 -0
- package/build/protocol/DmProtocolV1.d.ts +12 -0
- package/build/protocol/DmProtocolV1.js +22 -0
- package/build/protocol/DmProtocolV1.js.map +1 -0
- package/build/protocol/DmProtocolV2.d.ts +5 -0
- package/build/protocol/DmProtocolV2.js +11 -0
- package/build/protocol/DmProtocolV2.js.map +1 -0
- package/build/protocol/DmProtocolV3.d.ts +12 -0
- package/build/protocol/DmProtocolV3.js +28 -0
- package/build/protocol/DmProtocolV3.js.map +1 -0
- package/build/protocol/UnknownDmProtocol.d.ts +13 -0
- package/build/protocol/UnknownDmProtocol.js +20 -0
- package/build/protocol/UnknownDmProtocol.js.map +1 -0
- package/build/protocol/api.d.ts +2 -0
- package/build/protocol/api.js +2 -0
- package/build/protocol/api.js.map +1 -0
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -23,6 +23,9 @@ render() {
|
|
|
23
23
|
-->
|
|
24
24
|
|
|
25
25
|
## Changelog
|
|
26
|
+
### 9.0.0 (2026-03-01)
|
|
27
|
+
- (@UncleSamSwiss) Implemented v3 protocol: added support to use states and objects as values
|
|
28
|
+
|
|
26
29
|
### 8.0.9 (2026-01-28)
|
|
27
30
|
- (@GermanBluefox) Analyze API version and do not show anything if version is higher than supported
|
|
28
31
|
|
package/build/Communication.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { type Connection, type IobTheme, type ThemeName, type ThemeType } from '@iobroker/adapter-react-v5';
|
|
1
2
|
import React, { Component } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
3
|
+
import type { ActionBase, ActionButton, CommunicationForm, ControlBase, ControlState, InstanceDetails, ProgressUpdate } from './protocol/api';
|
|
4
|
+
import type { CommandName, LoadDevicesCallback, Message } from './protocol/DmProtocolBase';
|
|
4
5
|
declare module '@mui/material/Button' {
|
|
5
6
|
interface ButtonPropsColorOverrides {
|
|
6
7
|
grey: true;
|
|
@@ -18,19 +19,6 @@ export type CommunicationProps = {
|
|
|
18
19
|
isFloatComma: boolean;
|
|
19
20
|
dateFormat: string;
|
|
20
21
|
};
|
|
21
|
-
interface CommunicationForm {
|
|
22
|
-
title?: ioBroker.StringOrTranslated | null | undefined;
|
|
23
|
-
label?: ioBroker.StringOrTranslated | null | undefined;
|
|
24
|
-
noTranslation?: boolean;
|
|
25
|
-
schema: JsonFormSchema;
|
|
26
|
-
data?: Record<string, any>;
|
|
27
|
-
buttons?: (ActionButton | 'apply' | 'cancel' | 'close')[];
|
|
28
|
-
maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
29
|
-
/** Minimal width of the dialog */
|
|
30
|
-
minWidth?: number;
|
|
31
|
-
/** Always allow the apply button. Even when nothing was changed */
|
|
32
|
-
ignoreApplyDisabled?: boolean;
|
|
33
|
-
}
|
|
34
22
|
interface CommunicationFormInState extends CommunicationForm {
|
|
35
23
|
handleClose?: (data?: Record<string, any>) => void;
|
|
36
24
|
originalData: string;
|
|
@@ -54,31 +42,17 @@ export type CommunicationState = {
|
|
|
54
42
|
handleClose: (confirmation?: boolean) => void;
|
|
55
43
|
} | null;
|
|
56
44
|
form: CommunicationFormInState | null;
|
|
57
|
-
progress:
|
|
58
|
-
open: boolean;
|
|
59
|
-
indeterminate: boolean;
|
|
60
|
-
} | {
|
|
61
|
-
open: boolean;
|
|
62
|
-
progress: number;
|
|
63
|
-
} | null;
|
|
45
|
+
progress: ProgressUpdate | null;
|
|
64
46
|
showConfirmation: InputAction | null;
|
|
65
47
|
showInput: InputAction | null;
|
|
66
48
|
inputValue: string | boolean | number | null;
|
|
49
|
+
selectedInstance: string;
|
|
67
50
|
};
|
|
68
|
-
interface Message {
|
|
69
|
-
actionId?: string;
|
|
70
|
-
deviceId?: string;
|
|
71
|
-
value?: unknown;
|
|
72
|
-
origin?: string;
|
|
73
|
-
confirm?: boolean;
|
|
74
|
-
data?: any;
|
|
75
|
-
/** Inform backend, how long the frontend will wait for an answer */
|
|
76
|
-
timeout?: number;
|
|
77
|
-
}
|
|
78
51
|
/**
|
|
79
|
-
*
|
|
52
|
+
* Communication Component
|
|
80
53
|
*/
|
|
81
54
|
export default class Communication<P extends CommunicationProps, S extends CommunicationState> extends Component<P, S> {
|
|
55
|
+
private protocol;
|
|
82
56
|
private responseTimeout;
|
|
83
57
|
instanceHandler: (action: ActionBase) => () => void;
|
|
84
58
|
deviceHandler: (deviceId: string, action: ActionBase, refresh: () => void) => () => void;
|
|
@@ -87,13 +61,13 @@ export default class Communication<P extends CommunicationProps, S extends Commu
|
|
|
87
61
|
constructor(props: P);
|
|
88
62
|
componentWillUnmount(): void;
|
|
89
63
|
loadData(): void;
|
|
90
|
-
sendActionToInstance: (command:
|
|
91
|
-
sendControlToInstance: (command:
|
|
64
|
+
sendActionToInstance: (command: CommandName, messageToSend: Message, refresh?: () => void) => void;
|
|
65
|
+
sendControlToInstance: (command: CommandName, messageToSend: {
|
|
92
66
|
deviceId: string;
|
|
93
67
|
controlId: string;
|
|
94
68
|
state?: ControlState;
|
|
95
69
|
}) => Promise<null | ioBroker.State>;
|
|
96
|
-
loadDevices(): Promise<
|
|
70
|
+
loadDevices(callback: LoadDevicesCallback): Promise<void>;
|
|
97
71
|
loadInstanceInfos(): Promise<InstanceDetails>;
|
|
98
72
|
renderMessageDialog(): React.JSX.Element | null;
|
|
99
73
|
renderConfirmDialog(): React.JSX.Element | null;
|
package/build/Communication.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import { Backdrop, Box, Button, Checkbox, CircularProgress, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, FormControl, FormControlLabel, Grid2, IconButton, Input, InputAdornment, InputLabel, LinearProgress, MenuItem, Select, Slider, Snackbar, TextField, Typography, } from '@mui/material';
|
|
3
|
-
import { Close, Check, ContentCopy } from '@mui/icons-material';
|
|
4
1
|
import { I18n, Icon, Utils, } from '@iobroker/adapter-react-v5';
|
|
5
|
-
import {
|
|
2
|
+
import { Check, Close, ContentCopy } from '@mui/icons-material';
|
|
3
|
+
import { Backdrop, Box, Button, Checkbox, CircularProgress, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, FormControl, FormControlLabel, Grid2, IconButton, Input, InputAdornment, InputLabel, LinearProgress, MenuItem, Select, Slider, Snackbar, TextField, Typography, } from '@mui/material';
|
|
4
|
+
import React, { Component } from 'react';
|
|
6
5
|
import JsonConfig from './JsonConfig';
|
|
6
|
+
import { DmProtocolV1 } from './protocol/DmProtocolV1';
|
|
7
|
+
import { DmProtocolV2 } from './protocol/DmProtocolV2';
|
|
8
|
+
import { DmProtocolV3 } from './protocol/DmProtocolV3';
|
|
9
|
+
import { UnknownDmProtocol } from './protocol/UnknownDmProtocol';
|
|
10
|
+
import { getTranslation } from './Utils';
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
12
|
+
* Communication Component
|
|
9
13
|
*/
|
|
10
14
|
export default class Communication extends Component {
|
|
15
|
+
protocol = new UnknownDmProtocol();
|
|
11
16
|
responseTimeout = null;
|
|
12
17
|
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
13
18
|
instanceHandler;
|
|
@@ -29,6 +34,7 @@ export default class Communication extends Component {
|
|
|
29
34
|
showConfirmation: null,
|
|
30
35
|
showInput: null,
|
|
31
36
|
inputValue: null,
|
|
37
|
+
selectedInstance: this.props.selectedInstance ?? (window.localStorage.getItem('dmSelectedInstance') || ''),
|
|
32
38
|
};
|
|
33
39
|
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
34
40
|
this.instanceHandler = action => () => {
|
|
@@ -76,39 +82,39 @@ export default class Communication extends Component {
|
|
|
76
82
|
sendActionToInstance = (command, messageToSend, refresh) => {
|
|
77
83
|
const send = async () => {
|
|
78
84
|
this.setState({ showSpinner: true });
|
|
79
|
-
if (!this.props.selectedInstance) {
|
|
80
|
-
throw new Error('No instance selected');
|
|
81
|
-
}
|
|
82
85
|
this.responseTimeout = setTimeout(() => {
|
|
83
86
|
this.setState({ showSpinner: false });
|
|
84
87
|
window.alert(I18n.t('ra_No response from the backend'));
|
|
85
88
|
}, messageToSend.timeout || 5000);
|
|
86
|
-
const response = await this.
|
|
89
|
+
const response = await this.protocol.sendAction(command, messageToSend);
|
|
87
90
|
if (this.responseTimeout) {
|
|
88
91
|
clearTimeout(this.responseTimeout);
|
|
89
92
|
this.responseTimeout = null;
|
|
90
93
|
}
|
|
91
94
|
const type = response.type;
|
|
92
|
-
console.log(`Response: ${
|
|
93
|
-
switch (type) {
|
|
94
|
-
case 'message':
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
console.log(`Response: ${type}`);
|
|
96
|
+
switch (response.type) {
|
|
97
|
+
case 'message': {
|
|
98
|
+
const message = getTranslation(response.message);
|
|
99
|
+
console.log(`Message received: ${message}`);
|
|
100
|
+
if (message) {
|
|
97
101
|
this.setState({
|
|
98
102
|
message: {
|
|
99
|
-
message
|
|
103
|
+
message,
|
|
100
104
|
handleClose: () => this.setState({ message: null }, () => this.sendActionToInstance('dm:actionProgress', { origin: response.origin }, refresh)),
|
|
101
105
|
},
|
|
102
106
|
showSpinner: false,
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
break;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
}
|
|
111
|
+
case 'confirm': {
|
|
112
|
+
const message = getTranslation(response.confirm);
|
|
113
|
+
console.log(`Confirm received: ${message}`);
|
|
114
|
+
if (message) {
|
|
109
115
|
this.setState({
|
|
110
116
|
confirm: {
|
|
111
|
-
message:
|
|
117
|
+
message: message,
|
|
112
118
|
handleClose: (confirm) => this.setState({ confirm: null }, () => this.sendActionToInstance('dm:actionProgress', {
|
|
113
119
|
origin: response.origin,
|
|
114
120
|
confirm,
|
|
@@ -118,6 +124,7 @@ export default class Communication extends Component {
|
|
|
118
124
|
});
|
|
119
125
|
}
|
|
120
126
|
break;
|
|
127
|
+
}
|
|
121
128
|
case 'form':
|
|
122
129
|
console.log('Form received');
|
|
123
130
|
if (response.form) {
|
|
@@ -149,8 +156,12 @@ export default class Communication extends Component {
|
|
|
149
156
|
}
|
|
150
157
|
break;
|
|
151
158
|
case 'progress':
|
|
159
|
+
console.log('Progress received', response.progress);
|
|
152
160
|
if (response.progress) {
|
|
153
|
-
if (
|
|
161
|
+
if (response.progress.open === false) {
|
|
162
|
+
this.setState({ progress: null, showSpinner: false });
|
|
163
|
+
}
|
|
164
|
+
else if (this.state.progress) {
|
|
154
165
|
const progress = { ...this.state.progress, ...response.progress };
|
|
155
166
|
this.setState({ progress, showSpinner: false });
|
|
156
167
|
}
|
|
@@ -162,20 +173,20 @@ export default class Communication extends Component {
|
|
|
162
173
|
break;
|
|
163
174
|
case 'result':
|
|
164
175
|
console.log('Response content', response.result);
|
|
165
|
-
if (response.result.refresh) {
|
|
166
|
-
if (response.result.refresh === true) {
|
|
176
|
+
if ('refresh' in response.result && response.result.refresh) {
|
|
177
|
+
if (response.result.refresh === true || response.result.refresh === 'all') {
|
|
167
178
|
console.log('Refreshing all');
|
|
168
179
|
this.loadData();
|
|
169
180
|
}
|
|
170
181
|
else if (response.result.refresh === 'instance') {
|
|
171
|
-
console.log(`Refreshing instance infos: ${this.
|
|
182
|
+
console.log(`Refreshing instance infos: ${this.state.selectedInstance}`);
|
|
172
183
|
}
|
|
173
|
-
else if (response.result.refresh === '
|
|
184
|
+
else if (response.result.refresh === 'devices') {
|
|
174
185
|
if (!refresh) {
|
|
175
|
-
console.log('No refresh function provided to refresh "
|
|
186
|
+
console.log('No refresh function provided to refresh "devices"');
|
|
176
187
|
}
|
|
177
188
|
else {
|
|
178
|
-
console.log(`Refreshing device infos: ${this.
|
|
189
|
+
console.log(`Refreshing device infos: ${this.state.selectedInstance}`);
|
|
179
190
|
refresh();
|
|
180
191
|
}
|
|
181
192
|
}
|
|
@@ -183,7 +194,7 @@ export default class Communication extends Component {
|
|
|
183
194
|
console.log('Not refreshing anything');
|
|
184
195
|
}
|
|
185
196
|
}
|
|
186
|
-
if (response.result.error) {
|
|
197
|
+
if ('error' in response.result && response.result.error) {
|
|
187
198
|
console.error(`Error: ${response.result.error.message}`);
|
|
188
199
|
this.setState({ showToast: response.result.error.message, showSpinner: false });
|
|
189
200
|
}
|
|
@@ -200,15 +211,12 @@ export default class Communication extends Component {
|
|
|
200
211
|
void send().catch(console.error);
|
|
201
212
|
};
|
|
202
213
|
sendControlToInstance = async (command, messageToSend) => {
|
|
203
|
-
|
|
204
|
-
throw new Error('No instance selected');
|
|
205
|
-
}
|
|
206
|
-
const response = await this.props.socket.sendTo(this.props.selectedInstance, command, messageToSend);
|
|
214
|
+
const response = await this.protocol.sendControl(command, messageToSend);
|
|
207
215
|
const type = response.type;
|
|
208
216
|
console.log(`Response: ${response.type}`);
|
|
209
217
|
if (response.type === 'result') {
|
|
210
218
|
console.log('Response content', response.result);
|
|
211
|
-
if (response.result
|
|
219
|
+
if ('error' in response.result) {
|
|
212
220
|
console.error(`Error: ${response.result.error.message}`);
|
|
213
221
|
this.setState({ showToast: response.result.error.message });
|
|
214
222
|
}
|
|
@@ -222,39 +230,52 @@ export default class Communication extends Component {
|
|
|
222
230
|
return null;
|
|
223
231
|
};
|
|
224
232
|
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
225
|
-
loadDevices() {
|
|
226
|
-
|
|
227
|
-
throw new Error('No instance selected');
|
|
228
|
-
}
|
|
229
|
-
return this.props.socket.sendTo(this.props.selectedInstance, 'dm:listDevices');
|
|
233
|
+
loadDevices(callback) {
|
|
234
|
+
return this.protocol.loadDevices(callback);
|
|
230
235
|
}
|
|
231
236
|
// eslint-disable-next-line react/no-unused-class-component-methods
|
|
232
|
-
loadInstanceInfos() {
|
|
233
|
-
if (!this.
|
|
237
|
+
async loadInstanceInfos() {
|
|
238
|
+
if (!this.state.selectedInstance) {
|
|
234
239
|
throw new Error('No instance selected');
|
|
235
240
|
}
|
|
236
|
-
|
|
241
|
+
const details = await this.props.socket.sendTo(this.state.selectedInstance, 'dm:instanceInfo');
|
|
242
|
+
console.log('Instance details of', this.state.selectedInstance, details);
|
|
243
|
+
if (details.apiVersion === 'v1') {
|
|
244
|
+
this.protocol = new DmProtocolV1(this.state.selectedInstance, this.props.socket);
|
|
245
|
+
}
|
|
246
|
+
else if (details.apiVersion === 'v2') {
|
|
247
|
+
this.protocol = new DmProtocolV2(this.state.selectedInstance, this.props.socket);
|
|
248
|
+
}
|
|
249
|
+
else if (details.apiVersion === 'v3') {
|
|
250
|
+
this.protocol = new DmProtocolV3(this.state.selectedInstance, this.props.socket);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
this.protocol = new UnknownDmProtocol();
|
|
254
|
+
}
|
|
255
|
+
return this.protocol.convertInstanceDetails(details);
|
|
237
256
|
}
|
|
238
257
|
renderMessageDialog() {
|
|
239
258
|
if (!this.state.message) {
|
|
240
259
|
return null;
|
|
241
260
|
}
|
|
242
|
-
|
|
261
|
+
const message = this.state.message;
|
|
262
|
+
return (React.createElement(Dialog, { open: !0, onClose: () => message.handleClose(), hideBackdrop: true, "aria-describedby": "message-dialog-description" },
|
|
243
263
|
React.createElement(DialogContent, null,
|
|
244
|
-
React.createElement(DialogContentText, { id: "message-dialog-description" },
|
|
264
|
+
React.createElement(DialogContentText, { id: "message-dialog-description" }, message.message)),
|
|
245
265
|
React.createElement(DialogActions, null,
|
|
246
|
-
React.createElement(Button, { color: "primary", onClick: () =>
|
|
266
|
+
React.createElement(Button, { color: "primary", onClick: () => message.handleClose(), variant: "contained", autoFocus: true }, getTranslation('okButtonText')))));
|
|
247
267
|
}
|
|
248
268
|
renderConfirmDialog() {
|
|
249
269
|
if (!this.state.confirm) {
|
|
250
270
|
return null;
|
|
251
271
|
}
|
|
252
|
-
|
|
272
|
+
const confirm = this.state.confirm;
|
|
273
|
+
return (React.createElement(Dialog, { open: !0, onClose: () => confirm.handleClose(), hideBackdrop: true, "aria-describedby": "confirm-dialog-description" },
|
|
253
274
|
React.createElement(DialogContent, null,
|
|
254
|
-
React.createElement(DialogContentText, { id: "confirm-dialog-description" }, getTranslation(
|
|
275
|
+
React.createElement(DialogContentText, { id: "confirm-dialog-description" }, getTranslation(confirm.message))),
|
|
255
276
|
React.createElement(DialogActions, null,
|
|
256
|
-
React.createElement(Button, { variant: "contained", color: "primary", onClick: () =>
|
|
257
|
-
React.createElement(Button, { variant: "contained", color: "grey", onClick: () =>
|
|
277
|
+
React.createElement(Button, { variant: "contained", color: "primary", onClick: () => confirm.handleClose(true), autoFocus: true }, getTranslation('yesButtonText')),
|
|
278
|
+
React.createElement(Button, { variant: "contained", color: "grey", onClick: () => confirm.handleClose(false), autoFocus: true }, getTranslation('noButtonText')))));
|
|
258
279
|
}
|
|
259
280
|
renderSnackbar() {
|
|
260
281
|
return (React.createElement(Snackbar, { open: !!this.state.showToast, autoHideDuration: 6_000, onClose: () => this.setState({ showToast: null }), message: this.state.showToast }));
|
|
@@ -288,13 +309,14 @@ export default class Communication extends Component {
|
|
|
288
309
|
if (!this.state.form?.schema) {
|
|
289
310
|
return null;
|
|
290
311
|
}
|
|
291
|
-
if (!this.
|
|
312
|
+
if (!this.state.selectedInstance) {
|
|
292
313
|
throw new Error('No instance selected');
|
|
293
314
|
}
|
|
315
|
+
const form = this.state.form;
|
|
294
316
|
let buttons;
|
|
295
|
-
if (
|
|
317
|
+
if (form.buttons) {
|
|
296
318
|
buttons = [];
|
|
297
|
-
|
|
319
|
+
form.buttons.forEach((button) => {
|
|
298
320
|
if (typeof button === 'object' && button.type === 'copyToClipboard') {
|
|
299
321
|
buttons.push(React.createElement(Button, { key: "copyToClipboard", variant: button.variant || 'outlined', color: button.color === 'primary'
|
|
300
322
|
? 'primary'
|
|
@@ -306,8 +328,8 @@ export default class Communication extends Component {
|
|
|
306
328
|
: undefined,
|
|
307
329
|
...(button.style || undefined),
|
|
308
330
|
}, onClick: () => {
|
|
309
|
-
if (button.copyToClipboardAttr &&
|
|
310
|
-
const val =
|
|
331
|
+
if (button.copyToClipboardAttr && form.data) {
|
|
332
|
+
const val = form.data[button.copyToClipboardAttr];
|
|
311
333
|
if (typeof val === 'string') {
|
|
312
334
|
Utils.copyToClipboard(val);
|
|
313
335
|
}
|
|
@@ -316,8 +338,8 @@ export default class Communication extends Component {
|
|
|
316
338
|
}
|
|
317
339
|
window.alert(I18n.t('copied'));
|
|
318
340
|
}
|
|
319
|
-
else if (
|
|
320
|
-
Utils.copyToClipboard(JSON.stringify(
|
|
341
|
+
else if (form.data) {
|
|
342
|
+
Utils.copyToClipboard(JSON.stringify(form.data, null, 2));
|
|
321
343
|
window.alert(I18n.t('copied'));
|
|
322
344
|
}
|
|
323
345
|
else {
|
|
@@ -336,18 +358,15 @@ export default class Communication extends Component {
|
|
|
336
358
|
else {
|
|
337
359
|
buttons = [this.getOkButton(), this.getCancelButton()];
|
|
338
360
|
}
|
|
339
|
-
return (React.createElement(Dialog, {
|
|
361
|
+
return (React.createElement(Dialog, { onClose: () => form.handleClose?.(), hideBackdrop: true, fullWidth: true, open: true, sx: {
|
|
340
362
|
'& .MuiDialog-paper': {
|
|
341
|
-
minWidth:
|
|
363
|
+
minWidth: form.minWidth || undefined,
|
|
342
364
|
},
|
|
343
|
-
}, maxWidth:
|
|
344
|
-
|
|
365
|
+
}, maxWidth: form.maxWidth || 'md' },
|
|
366
|
+
form.title ? (React.createElement(DialogTitle, null, getTranslation(form.label || form.title, form.noTranslation))) : null,
|
|
345
367
|
React.createElement(DialogContent, null,
|
|
346
|
-
React.createElement(JsonConfig, { instanceId: this.
|
|
368
|
+
React.createElement(JsonConfig, { instanceId: this.state.selectedInstance, schema: form.schema, data: form.data || {}, socket: this.props.socket, onChange: (data) => {
|
|
347
369
|
console.log('handleFormChange', { data });
|
|
348
|
-
const form = {
|
|
349
|
-
...this.state.form,
|
|
350
|
-
};
|
|
351
370
|
if (form) {
|
|
352
371
|
form.data = data;
|
|
353
372
|
form.changed = JSON.stringify(data) !== form.originalData;
|
|
@@ -357,10 +376,14 @@ export default class Communication extends Component {
|
|
|
357
376
|
React.createElement(DialogActions, null, buttons)));
|
|
358
377
|
}
|
|
359
378
|
renderProgressDialog() {
|
|
360
|
-
if (!this.state.progress
|
|
379
|
+
if (!this.state.progress) {
|
|
361
380
|
return null;
|
|
362
381
|
}
|
|
363
|
-
return (React.createElement(Dialog, {
|
|
382
|
+
return (React.createElement(Dialog, { onClose: () => { }, hideBackdrop: true, open: true },
|
|
383
|
+
this.state.progress.title && React.createElement(DialogTitle, null, getTranslation(this.state.progress.title)),
|
|
384
|
+
React.createElement(DialogContent, null,
|
|
385
|
+
this.state.progress.label && (React.createElement(DialogContentText, null, getTranslation(this.state.progress.label))),
|
|
386
|
+
React.createElement(LinearProgress, { variant: this.state.progress.indeterminate ? 'indeterminate' : 'determinate', value: this.state.progress.value }))));
|
|
364
387
|
}
|
|
365
388
|
// eslint-disable-next-line class-methods-use-this
|
|
366
389
|
renderContent() {
|
|
@@ -370,14 +393,14 @@ export default class Communication extends Component {
|
|
|
370
393
|
if (!this.state.showSpinner) {
|
|
371
394
|
return null;
|
|
372
395
|
}
|
|
373
|
-
return (React.createElement(Backdrop, { style: { zIndex: 1000 }, open:
|
|
396
|
+
return (React.createElement(Backdrop, { style: { zIndex: 1000 }, open: true },
|
|
374
397
|
React.createElement(CircularProgress, null)));
|
|
375
398
|
}
|
|
376
399
|
renderConfirmationDialog() {
|
|
377
400
|
if (!this.state.showConfirmation) {
|
|
378
401
|
return null;
|
|
379
402
|
}
|
|
380
|
-
return (React.createElement(Dialog, {
|
|
403
|
+
return (React.createElement(Dialog, { onClose: () => this.setState({ showConfirmation: null }), open: true },
|
|
381
404
|
React.createElement(DialogTitle, null, getTranslation(this.state.showConfirmation.confirmation === true
|
|
382
405
|
? getTranslation('areYouSureText')
|
|
383
406
|
: getTranslation(this.state.showConfirmation.confirmation))),
|
|
@@ -453,7 +476,7 @@ export default class Communication extends Component {
|
|
|
453
476
|
okDisabled = !this.state.inputValue;
|
|
454
477
|
}
|
|
455
478
|
}
|
|
456
|
-
return (React.createElement(Dialog, {
|
|
479
|
+
return (React.createElement(Dialog, { onClose: () => this.setState({ showInput: null }), open: true },
|
|
457
480
|
React.createElement(DialogTitle, null, getTranslation('pleaseEnterValueText')),
|
|
458
481
|
React.createElement(DialogContent, null,
|
|
459
482
|
this.state.showInput.inputBefore.type === 'text' ||
|