@iobroker/json-config 6.17.12 → 6.17.14
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/package.json +27 -27
- package/src/JsonConfig.tsx +0 -710
- package/src/JsonConfigComponent/ChipInput.tsx +0 -752
- package/src/JsonConfigComponent/ConfigAccordion.tsx +0 -278
- package/src/JsonConfigComponent/ConfigAlive.tsx +0 -74
- package/src/JsonConfigComponent/ConfigAutocomplete.tsx +0 -108
- package/src/JsonConfigComponent/ConfigAutocompleteSendTo.tsx +0 -183
- package/src/JsonConfigComponent/ConfigCRON.jsx +0 -101
- package/src/JsonConfigComponent/ConfigCertCollection.tsx +0 -102
- package/src/JsonConfigComponent/ConfigCertificateSelect.tsx +0 -92
- package/src/JsonConfigComponent/ConfigCertificates.tsx +0 -202
- package/src/JsonConfigComponent/ConfigCheckLicense.jsx +0 -662
- package/src/JsonConfigComponent/ConfigCheckbox.tsx +0 -67
- package/src/JsonConfigComponent/ConfigChip.jsx +0 -81
- package/src/JsonConfigComponent/ConfigColor.tsx +0 -86
- package/src/JsonConfigComponent/ConfigCoordinates.tsx +0 -234
- package/src/JsonConfigComponent/ConfigCustom.tsx +0 -246
- package/src/JsonConfigComponent/ConfigDatePicker.tsx +0 -48
- package/src/JsonConfigComponent/ConfigDeviceManager.tsx +0 -33
- package/src/JsonConfigComponent/ConfigFile.jsx +0 -181
- package/src/JsonConfigComponent/ConfigFileSelector.jsx +0 -520
- package/src/JsonConfigComponent/ConfigFunc.jsx +0 -90
- package/src/JsonConfigComponent/ConfigGeneric.tsx +0 -1027
- package/src/JsonConfigComponent/ConfigIP.jsx +0 -96
- package/src/JsonConfigComponent/ConfigImageSendTo.jsx +0 -79
- package/src/JsonConfigComponent/ConfigImageUpload.jsx +0 -114
- package/src/JsonConfigComponent/ConfigInstanceSelect.jsx +0 -172
- package/src/JsonConfigComponent/ConfigInterface.jsx +0 -112
- package/src/JsonConfigComponent/ConfigJsonEditor.jsx +0 -103
- package/src/JsonConfigComponent/ConfigLanguage.tsx +0 -153
- package/src/JsonConfigComponent/ConfigLicense.jsx +0 -148
- package/src/JsonConfigComponent/ConfigNumber.tsx +0 -207
- package/src/JsonConfigComponent/ConfigObjectId.jsx +0 -113
- package/src/JsonConfigComponent/ConfigPanel.tsx +0 -360
- package/src/JsonConfigComponent/ConfigPassword.jsx +0 -160
- package/src/JsonConfigComponent/ConfigPattern.jsx +0 -50
- package/src/JsonConfigComponent/ConfigPort.tsx +0 -232
- package/src/JsonConfigComponent/ConfigRoom.jsx +0 -90
- package/src/JsonConfigComponent/ConfigSelect.jsx +0 -124
- package/src/JsonConfigComponent/ConfigSelectSendTo.tsx +0 -251
- package/src/JsonConfigComponent/ConfigSendto.tsx +0 -340
- package/src/JsonConfigComponent/ConfigSetState.jsx +0 -116
- package/src/JsonConfigComponent/ConfigSlider.jsx +0 -97
- package/src/JsonConfigComponent/ConfigStaticDivider.jsx +0 -51
- package/src/JsonConfigComponent/ConfigStaticHeader.jsx +0 -63
- package/src/JsonConfigComponent/ConfigStaticImage.jsx +0 -48
- package/src/JsonConfigComponent/ConfigStaticText.jsx +0 -72
- package/src/JsonConfigComponent/ConfigTable.tsx +0 -1040
- package/src/JsonConfigComponent/ConfigTabs.tsx +0 -150
- package/src/JsonConfigComponent/ConfigText.tsx +0 -188
- package/src/JsonConfigComponent/ConfigTextSendTo.tsx +0 -102
- package/src/JsonConfigComponent/ConfigTimePicker.tsx +0 -63
- package/src/JsonConfigComponent/ConfigTopic.jsx +0 -78
- package/src/JsonConfigComponent/ConfigUUID.tsx +0 -55
- package/src/JsonConfigComponent/ConfigUser.jsx +0 -104
- package/src/JsonConfigComponent/index.tsx +0 -435
- package/src/JsonConfigComponent/wrapper/Components/CustomModal.jsx +0 -145
- package/src/JsonConfigComponent/wrapper/Components/Editor.jsx +0 -65
- package/src/Utils.jsx +0 -1683
- package/src/index.tsx +0 -14
- package/src/types.d.ts +0 -372
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import React, { type JSXElementConstructor } from 'react';
|
|
2
|
-
import { withStyles } from '@mui/styles';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
Grid,
|
|
6
|
-
Accordion,
|
|
7
|
-
AccordionSummary,
|
|
8
|
-
AccordionDetails,
|
|
9
|
-
Typography, type Theme,
|
|
10
|
-
} from '@mui/material';
|
|
11
|
-
|
|
12
|
-
import { ExpandMore as ExpandMoreIcon } from '@mui/icons-material';
|
|
13
|
-
|
|
14
|
-
import { Utils } from '@iobroker/adapter-react-v5';
|
|
15
|
-
import type { ConfigItemPanel } from '#JC/types';
|
|
16
|
-
|
|
17
|
-
import ConfigGeneric, { type ConfigGenericState, type ConfigGenericProps } from './ConfigGeneric';
|
|
18
|
-
// eslint-disable-next-line import/no-cycle
|
|
19
|
-
import ConfigAccordion from './ConfigAccordion';
|
|
20
|
-
import ConfigAlive from './ConfigAlive';
|
|
21
|
-
import ConfigAutocomplete from './ConfigAutocomplete';
|
|
22
|
-
import ConfigAutocompleteSendTo from './ConfigAutocompleteSendTo';
|
|
23
|
-
import ConfigCRON from './ConfigCRON';
|
|
24
|
-
import ConfigCertificateSelect from './ConfigCertificateSelect';
|
|
25
|
-
import ConfigCertificates from './ConfigCertificates';
|
|
26
|
-
import ConfigCertCollection from './ConfigCertCollection';
|
|
27
|
-
import ConfigCheckLicense from './ConfigCheckLicense';
|
|
28
|
-
import ConfigCheckbox from './ConfigCheckbox';
|
|
29
|
-
import ConfigChip from './ConfigChip';
|
|
30
|
-
import ConfigColor from './ConfigColor';
|
|
31
|
-
import ConfigCoordinates from './ConfigCoordinates';
|
|
32
|
-
import ConfigCustom from './ConfigCustom';
|
|
33
|
-
import ConfigDatePicker from './ConfigDatePicker';
|
|
34
|
-
import ConfigDeviceManager from './ConfigDeviceManager';
|
|
35
|
-
import ConfigFile from './ConfigFile';
|
|
36
|
-
import ConfigFileSelector from './ConfigFileSelector';
|
|
37
|
-
import ConfigFunc from './ConfigFunc';
|
|
38
|
-
import ConfigIP from './ConfigIP';
|
|
39
|
-
import ConfigImageSendTo from './ConfigImageSendTo';
|
|
40
|
-
import ConfigImageUpload from './ConfigImageUpload';
|
|
41
|
-
import ConfigInstanceSelect from './ConfigInstanceSelect';
|
|
42
|
-
import ConfigInterface from './ConfigInterface';
|
|
43
|
-
import ConfigJsonEditor from './ConfigJsonEditor';
|
|
44
|
-
import ConfigLanguage from './ConfigLanguage';
|
|
45
|
-
import ConfigLicense from './ConfigLicense';
|
|
46
|
-
import ConfigNumber from './ConfigNumber';
|
|
47
|
-
import ConfigObjectId from './ConfigObjectId';
|
|
48
|
-
import ConfigPassword from './ConfigPassword';
|
|
49
|
-
import ConfigPattern from './ConfigPattern';
|
|
50
|
-
import ConfigPort from './ConfigPort';
|
|
51
|
-
import ConfigRoom from './ConfigRoom';
|
|
52
|
-
import ConfigSelect from './ConfigSelect';
|
|
53
|
-
import ConfigSelectSendTo from './ConfigSelectSendTo';
|
|
54
|
-
import ConfigSendto from './ConfigSendto';
|
|
55
|
-
import ConfigSetState from './ConfigSetState';
|
|
56
|
-
import ConfigSlider from './ConfigSlider';
|
|
57
|
-
import ConfigStaticDivider from './ConfigStaticDivider';
|
|
58
|
-
import ConfigStaticHeader from './ConfigStaticHeader';
|
|
59
|
-
import ConfigStaticImage from './ConfigStaticImage';
|
|
60
|
-
import ConfigStaticText from './ConfigStaticText';
|
|
61
|
-
// eslint-disable-next-line import/no-cycle
|
|
62
|
-
import ConfigTable from './ConfigTable';
|
|
63
|
-
import ConfigText from './ConfigText';
|
|
64
|
-
import ConfigTextSendTo from './ConfigTextSendTo';
|
|
65
|
-
import ConfigTimePicker from './ConfigTimePicker';
|
|
66
|
-
import ConfigTopic from './ConfigTopic';
|
|
67
|
-
import ConfigUUID from './ConfigUUID';
|
|
68
|
-
import ConfigUser from './ConfigUser';
|
|
69
|
-
|
|
70
|
-
const components = {
|
|
71
|
-
accordion: ConfigAccordion,
|
|
72
|
-
alive: ConfigAlive,
|
|
73
|
-
autocomplete: ConfigAutocomplete,
|
|
74
|
-
autocompleteSendTo: ConfigAutocompleteSendTo,
|
|
75
|
-
certCollection: ConfigCertCollection,
|
|
76
|
-
certificate: ConfigCertificateSelect,
|
|
77
|
-
certificates: ConfigCertificates,
|
|
78
|
-
checkbox: ConfigCheckbox,
|
|
79
|
-
checkLicense: ConfigCheckLicense,
|
|
80
|
-
chip: ConfigChip, // deprecated. Use "chips"
|
|
81
|
-
chips: ConfigChip,
|
|
82
|
-
color: ConfigColor,
|
|
83
|
-
coordinates: ConfigCoordinates,
|
|
84
|
-
cron: ConfigCRON,
|
|
85
|
-
custom: ConfigCustom,
|
|
86
|
-
datePicker: ConfigDatePicker,
|
|
87
|
-
deviceManager: ConfigDeviceManager,
|
|
88
|
-
divider: ConfigStaticDivider,
|
|
89
|
-
file: ConfigFile,
|
|
90
|
-
fileSelector: ConfigFileSelector,
|
|
91
|
-
func: ConfigFunc,
|
|
92
|
-
header: ConfigStaticHeader,
|
|
93
|
-
image: ConfigImageUpload,
|
|
94
|
-
imageSendTo: ConfigImageSendTo,
|
|
95
|
-
instance: ConfigInstanceSelect,
|
|
96
|
-
interface: ConfigInterface,
|
|
97
|
-
ip: ConfigIP,
|
|
98
|
-
jsonEditor: ConfigJsonEditor,
|
|
99
|
-
language: ConfigLanguage,
|
|
100
|
-
license: ConfigLicense,
|
|
101
|
-
number: ConfigNumber,
|
|
102
|
-
objectId: ConfigObjectId,
|
|
103
|
-
password: ConfigPassword,
|
|
104
|
-
pattern: ConfigPattern,
|
|
105
|
-
port: ConfigPort,
|
|
106
|
-
room: ConfigRoom,
|
|
107
|
-
select: ConfigSelect,
|
|
108
|
-
selectSendTo: ConfigSelectSendTo,
|
|
109
|
-
sendto: ConfigSendto,
|
|
110
|
-
sendTo: ConfigSendto,
|
|
111
|
-
setState: ConfigSetState,
|
|
112
|
-
slider: ConfigSlider,
|
|
113
|
-
staticImage: ConfigStaticImage,
|
|
114
|
-
staticLink: ConfigStaticText,
|
|
115
|
-
staticText: ConfigStaticText,
|
|
116
|
-
table: ConfigTable,
|
|
117
|
-
text: ConfigText,
|
|
118
|
-
textSendTo: ConfigTextSendTo,
|
|
119
|
-
timePicker: ConfigTimePicker,
|
|
120
|
-
topic: ConfigTopic,
|
|
121
|
-
uuid: ConfigUUID,
|
|
122
|
-
user: ConfigUser,
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const styles: Record<string, any> = (theme: Theme) => ({
|
|
126
|
-
fullWidth: {
|
|
127
|
-
width: '100%',
|
|
128
|
-
// height: '100%',
|
|
129
|
-
},
|
|
130
|
-
paper: {
|
|
131
|
-
margin: 10,
|
|
132
|
-
height: 'calc(100vh - 235px) !important',
|
|
133
|
-
width: 'auto !important',
|
|
134
|
-
overflowY: 'auto',
|
|
135
|
-
paddingBottom: theme.spacing(1),
|
|
136
|
-
},
|
|
137
|
-
padding: {
|
|
138
|
-
padding: 10,
|
|
139
|
-
},
|
|
140
|
-
heading: {
|
|
141
|
-
|
|
142
|
-
},
|
|
143
|
-
primary: {
|
|
144
|
-
backgroundColor: theme.palette.primary.main,
|
|
145
|
-
color: theme.palette.mode === 'dark' ? 'inherit' : '#FFF',
|
|
146
|
-
},
|
|
147
|
-
secondary: {
|
|
148
|
-
backgroundColor: theme.palette.secondary.main,
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
interface ConfigPanelProps extends ConfigGenericProps {
|
|
153
|
-
schema: ConfigItemPanel;
|
|
154
|
-
}
|
|
155
|
-
interface ConfigPanelState extends ConfigGenericState {
|
|
156
|
-
expanded?: boolean;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
class ConfigPanel extends ConfigGeneric<ConfigPanelProps, ConfigPanelState> {
|
|
160
|
-
componentDidMount() {
|
|
161
|
-
super.componentDidMount();
|
|
162
|
-
if (this.props.schema && this.props.schema.collapsable) {
|
|
163
|
-
this.setState({ expanded: ((window as any)._localStorage as Storage || window.localStorage).getItem(`${this.props.adapterName}.${this.props.attr}`) === 'true' });
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
renderItems(items: Record<string, any>, disabled: boolean) {
|
|
168
|
-
const classes = this.props.classes || {};
|
|
169
|
-
|
|
170
|
-
return items ? Object.keys(items).map(attr => {
|
|
171
|
-
if (this.props.multiEdit && items[attr].noMultiEdit) {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const type = items[attr].type || 'panel';
|
|
176
|
-
let ItemComponent;
|
|
177
|
-
if (type === 'custom') {
|
|
178
|
-
// name
|
|
179
|
-
// url
|
|
180
|
-
if (items[attr].url) {
|
|
181
|
-
ItemComponent = ConfigCustom;
|
|
182
|
-
} else if (this.props.customs && this.props.customs[items[attr].component]) {
|
|
183
|
-
ItemComponent = this.props.customs[items[attr].component];
|
|
184
|
-
} else {
|
|
185
|
-
console.error(`Cannot find custom component: ${items[attr].component}`);
|
|
186
|
-
ItemComponent = ConfigGeneric;
|
|
187
|
-
}
|
|
188
|
-
} else if (type === 'panel') {
|
|
189
|
-
// eslint-disable-next-line no-use-before-define
|
|
190
|
-
ItemComponent = ConfigPanelStyled;
|
|
191
|
-
} else {
|
|
192
|
-
ItemComponent = (components as Record<string, JSXElementConstructor<any>>)[type] || ConfigGeneric;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// @ts-expect-error how to solve it?
|
|
196
|
-
return <ItemComponent
|
|
197
|
-
key={`${attr}_${this.props.index === undefined ? '' : this.props.index}`}
|
|
198
|
-
index={this.props.index}
|
|
199
|
-
changed={this.props.changed}
|
|
200
|
-
arrayIndex={this.props.arrayIndex}
|
|
201
|
-
globalData={this.props.globalData}
|
|
202
|
-
onCommandRunning={this.props.onCommandRunning}
|
|
203
|
-
commandRunning={this.props.commandRunning}
|
|
204
|
-
className={classes.panel}
|
|
205
|
-
socket={this.props.socket}
|
|
206
|
-
adapterName={this.props.adapterName}
|
|
207
|
-
instance={this.props.instance}
|
|
208
|
-
common={this.props.common}
|
|
209
|
-
customs={this.props.customs}
|
|
210
|
-
alive={this.props.alive}
|
|
211
|
-
themeType={this.props.themeType}
|
|
212
|
-
themeName={this.props.themeName}
|
|
213
|
-
data={this.props.data}
|
|
214
|
-
originalData={this.props.originalData}
|
|
215
|
-
systemConfig={this.props.systemConfig}
|
|
216
|
-
onError={this.props.onError}
|
|
217
|
-
onChange={this.props.onChange}
|
|
218
|
-
multiEdit={this.props.multiEdit}
|
|
219
|
-
dateFormat={this.props.dateFormat}
|
|
220
|
-
isFloatComma={this.props.isFloatComma}
|
|
221
|
-
disabled={disabled}
|
|
222
|
-
imagePrefix={this.props.imagePrefix}
|
|
223
|
-
changeLanguage={this.props.changeLanguage}
|
|
224
|
-
forceUpdate={this.props.forceUpdate}
|
|
225
|
-
registerOnForceUpdate={this.props.registerOnForceUpdate}
|
|
226
|
-
customObj={this.props.customObj}
|
|
227
|
-
instanceObj={this.props.instanceObj}
|
|
228
|
-
custom={this.props.custom}
|
|
229
|
-
schema={items[attr]}
|
|
230
|
-
attr={attr}
|
|
231
|
-
table={this.props.table}
|
|
232
|
-
/>;
|
|
233
|
-
}) : null;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
render(): React.JSX.Element | null {
|
|
237
|
-
const schema = this.props.schema;
|
|
238
|
-
|
|
239
|
-
if (!schema) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const { disabled, hidden } = this.calculate(schema);
|
|
244
|
-
|
|
245
|
-
const items = this.props.schema.items;
|
|
246
|
-
const classes = this.props.classes || {};
|
|
247
|
-
const style = this.props.schema.style || {};
|
|
248
|
-
|
|
249
|
-
if (hidden) {
|
|
250
|
-
if (schema.hideOnlyControl) {
|
|
251
|
-
const item = <Grid
|
|
252
|
-
item
|
|
253
|
-
xs={schema.xs || undefined}
|
|
254
|
-
lg={schema.lg || undefined}
|
|
255
|
-
md={schema.md || undefined}
|
|
256
|
-
sm={schema.sm || undefined}
|
|
257
|
-
style={({
|
|
258
|
-
marginBottom: 0, /* marginRight: 8, */
|
|
259
|
-
textAlign: 'left',
|
|
260
|
-
...schema.style,
|
|
261
|
-
...(this.props.themeType === 'dark' ? schema.darkStyle : {}),
|
|
262
|
-
})}
|
|
263
|
-
/>;
|
|
264
|
-
|
|
265
|
-
if (schema.newLine) {
|
|
266
|
-
return <>
|
|
267
|
-
<div style={{ flexBasis: '100%', height: 0 }} />
|
|
268
|
-
{item}
|
|
269
|
-
</>;
|
|
270
|
-
}
|
|
271
|
-
return item;
|
|
272
|
-
}
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (this.props.table) {
|
|
277
|
-
return this.renderItems(items, disabled) as any as React.JSX.Element;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (this.props.custom) {
|
|
281
|
-
return <Grid
|
|
282
|
-
key={`${this.props.attr}_${this.props.index}`}
|
|
283
|
-
container
|
|
284
|
-
className={classes.fullWidth}
|
|
285
|
-
spacing={2}
|
|
286
|
-
style={style}
|
|
287
|
-
>
|
|
288
|
-
{this.renderItems(items, disabled)}
|
|
289
|
-
</Grid>;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
let content;
|
|
293
|
-
if (schema.collapsable) {
|
|
294
|
-
content = <Accordion
|
|
295
|
-
key={`${this.props.attr}_${this.props.index}`}
|
|
296
|
-
className={classes.fullWidth}
|
|
297
|
-
expanded={!!this.state.expanded}
|
|
298
|
-
onChange={() => {
|
|
299
|
-
((window as any)._localStorage as Storage || window.localStorage).setItem(`${this.props.adapterName}.${this.props.attr}`, this.state.expanded ? 'false' : 'true');
|
|
300
|
-
this.setState({ expanded: !this.state.expanded });
|
|
301
|
-
}}
|
|
302
|
-
>
|
|
303
|
-
<AccordionSummary
|
|
304
|
-
expandIcon={<ExpandMoreIcon />}
|
|
305
|
-
style={({ ...schema.style, ...(this.props.themeType ? schema.darkStyle : {}) })}
|
|
306
|
-
className={Utils.clsx(classes.fullWidth, schema.color === 'primary' && classes.primary, schema.color === 'secondary' && classes.secondary)}
|
|
307
|
-
>
|
|
308
|
-
<Typography className={classes.heading}>{this.getText(schema.label)}</Typography>
|
|
309
|
-
</AccordionSummary>
|
|
310
|
-
<AccordionDetails>
|
|
311
|
-
<Grid container className={`${classes.fullWidth} ${classes.padding}`} spacing={2} style={style}>
|
|
312
|
-
{this.renderItems(items, disabled)}
|
|
313
|
-
</Grid>
|
|
314
|
-
</AccordionDetails>
|
|
315
|
-
</Accordion>;
|
|
316
|
-
} else {
|
|
317
|
-
content = <div
|
|
318
|
-
key={`${this.props.attr}_${this.props.index}`}
|
|
319
|
-
className={Utils.clsx(this.props.className, this.props.isParentTab && classes.paper, classes.fullWidth)}
|
|
320
|
-
style={style}
|
|
321
|
-
>
|
|
322
|
-
<Grid
|
|
323
|
-
container
|
|
324
|
-
className={Utils.clsx(classes.fullWidth, this.props.isParentTab && classes.padding)}
|
|
325
|
-
spacing={2}
|
|
326
|
-
style={this.props.schema.innerStyle}
|
|
327
|
-
>
|
|
328
|
-
{this.renderItems(items, disabled)}
|
|
329
|
-
</Grid>
|
|
330
|
-
</div>;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (!this.props.isParentTab) {
|
|
334
|
-
const item = <Grid
|
|
335
|
-
item
|
|
336
|
-
title={this.getText(schema.tooltip)}
|
|
337
|
-
xs={schema.xs || undefined}
|
|
338
|
-
lg={schema.lg || undefined}
|
|
339
|
-
md={schema.md || undefined}
|
|
340
|
-
sm={schema.sm || undefined}
|
|
341
|
-
style={({ marginBottom: 0, /* marginRight: 8, */textAlign: 'left', ...schema.style })}
|
|
342
|
-
>
|
|
343
|
-
{content}
|
|
344
|
-
</Grid>;
|
|
345
|
-
|
|
346
|
-
if (schema.newLine) {
|
|
347
|
-
return <>
|
|
348
|
-
<div style={{ flexBasis: '100%', height: 0 }} />
|
|
349
|
-
{item}
|
|
350
|
-
</>;
|
|
351
|
-
}
|
|
352
|
-
return item;
|
|
353
|
-
}
|
|
354
|
-
return content;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
const ConfigPanelStyled = withStyles(styles)(ConfigPanel);
|
|
359
|
-
|
|
360
|
-
export default ConfigPanelStyled;
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { withStyles } from '@mui/styles';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
TextField,
|
|
7
|
-
IconButton,
|
|
8
|
-
InputAdornment,
|
|
9
|
-
} from '@mui/material';
|
|
10
|
-
|
|
11
|
-
import { Visibility, VisibilityOff } from '@mui/icons-material';
|
|
12
|
-
|
|
13
|
-
import { I18n } from '@iobroker/adapter-react-v5';
|
|
14
|
-
|
|
15
|
-
import ConfigGeneric from './ConfigGeneric';
|
|
16
|
-
|
|
17
|
-
const styles = theme => ({
|
|
18
|
-
fullWidth: {
|
|
19
|
-
width: '100%',
|
|
20
|
-
display: 'inline-block',
|
|
21
|
-
},
|
|
22
|
-
halfWidth1: {
|
|
23
|
-
width: `calc(50% - ${theme.spacing(0.5)})`,
|
|
24
|
-
display: 'inline-block',
|
|
25
|
-
marginRight: theme.spacing(1),
|
|
26
|
-
},
|
|
27
|
-
halfWidth2: {
|
|
28
|
-
width: `calc(50% - ${theme.spacing(0.5)})`,
|
|
29
|
-
display: 'inline-block',
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const PASSWORD_PLACEHOLDER = '____ppp____';
|
|
34
|
-
|
|
35
|
-
class ConfigPassword extends ConfigGeneric {
|
|
36
|
-
componentDidMount() {
|
|
37
|
-
super.componentDidMount();
|
|
38
|
-
const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
|
|
39
|
-
this.setState({
|
|
40
|
-
_repeat: value ? PASSWORD_PLACEHOLDER : '',
|
|
41
|
-
_visible: false,
|
|
42
|
-
value: value ? PASSWORD_PLACEHOLDER : '',
|
|
43
|
-
_notEqual: false,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
onChangePassword(password, repeatPassword) {
|
|
48
|
-
if (password === undefined) {
|
|
49
|
-
password = this.state.value;
|
|
50
|
-
}
|
|
51
|
-
if (repeatPassword === undefined) {
|
|
52
|
-
repeatPassword = this.state._repeat;
|
|
53
|
-
}
|
|
54
|
-
const _notEqual = !!this.props.schema.repeat && repeatPassword !== password;
|
|
55
|
-
this.setState({ value: password, _repeat: repeatPassword, _notEqual }, () => {
|
|
56
|
-
if (_notEqual) {
|
|
57
|
-
this.onError(this.props.attr, I18n.t('ra_Passwords are not equal!'));
|
|
58
|
-
} else {
|
|
59
|
-
this.onError(this.props.attr); // clear error
|
|
60
|
-
this.onChange(this.props.attr, password);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
renderItem(error, disabled /* , defaultValue */) {
|
|
66
|
-
if (this.state._notEqual === undefined) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const password = <TextField
|
|
71
|
-
variant="standard"
|
|
72
|
-
fullWidth
|
|
73
|
-
type={this.state._visible && this.state.value !== PASSWORD_PLACEHOLDER ? 'text' : 'password'}
|
|
74
|
-
value={this.state.value}
|
|
75
|
-
error={!!error || this.state._notEqual}
|
|
76
|
-
disabled={!!disabled}
|
|
77
|
-
onChange={e => this.onChangePassword(e.target.value)}
|
|
78
|
-
label={this.getText(this.props.schema.label)}
|
|
79
|
-
inputProps={{
|
|
80
|
-
autoComplete: 'new-password',
|
|
81
|
-
form: { autoComplete: 'off' },
|
|
82
|
-
maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,
|
|
83
|
-
}}
|
|
84
|
-
helperText={this.state._notEqual ? I18n.t('ra_Passwords are not equal!') : this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}
|
|
85
|
-
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
86
|
-
InputProps={{
|
|
87
|
-
endAdornment: this.state.value && this.state.value !== PASSWORD_PLACEHOLDER && this.props.schema.visible ? <InputAdornment position="end">
|
|
88
|
-
<IconButton
|
|
89
|
-
size="large"
|
|
90
|
-
tabIndex={-1}
|
|
91
|
-
onClick={e => {
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
e.stopPropagation();
|
|
94
|
-
this.setState({ _visible: !this.state._visible });
|
|
95
|
-
}}
|
|
96
|
-
edge="end"
|
|
97
|
-
>
|
|
98
|
-
{this.state._visible ? <VisibilityOff /> : <Visibility />}
|
|
99
|
-
</IconButton>
|
|
100
|
-
</InputAdornment> : undefined,
|
|
101
|
-
}}
|
|
102
|
-
/>;
|
|
103
|
-
|
|
104
|
-
if (this.props.schema.repeat) {
|
|
105
|
-
const passwordRepeat = <TextField
|
|
106
|
-
variant="standard"
|
|
107
|
-
fullWidth
|
|
108
|
-
type={this.state._visible && this.state._repeat !== PASSWORD_PLACEHOLDER ? 'text' : 'password'}
|
|
109
|
-
value={this.state._repeat}
|
|
110
|
-
error={!!error || this.state._notEqual}
|
|
111
|
-
disabled={!!disabled}
|
|
112
|
-
onChange={e => this.onChangePassword(undefined, e.target.value)}
|
|
113
|
-
label={`${this.getText(this.props.schema.label)} (${I18n.t('ra_repeat')})`}
|
|
114
|
-
inputProps={{
|
|
115
|
-
autoComplete: 'new-password',
|
|
116
|
-
form: { autoComplete: 'off' },
|
|
117
|
-
maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,
|
|
118
|
-
}}
|
|
119
|
-
helperText={this.state._notEqual ? I18n.t('ra_Passwords are not equal!') : this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}
|
|
120
|
-
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
121
|
-
InputProps={{
|
|
122
|
-
endAdornment: this.state._repeat && this.state._repeat !== PASSWORD_PLACEHOLDER ? <InputAdornment position="end">
|
|
123
|
-
<IconButton
|
|
124
|
-
size="large"
|
|
125
|
-
tabIndex={-1}
|
|
126
|
-
onClick={e => {
|
|
127
|
-
e.preventDefault();
|
|
128
|
-
e.stopPropagation();
|
|
129
|
-
this.setState({ _visible: !this.state._visible });
|
|
130
|
-
}}
|
|
131
|
-
edge="end"
|
|
132
|
-
>
|
|
133
|
-
{this.state._visible ? <VisibilityOff /> : <Visibility />}
|
|
134
|
-
</IconButton>
|
|
135
|
-
</InputAdornment> : undefined,
|
|
136
|
-
}}
|
|
137
|
-
/>;
|
|
138
|
-
|
|
139
|
-
return <div className={this.props.classes.fullWidth}>
|
|
140
|
-
<div className={this.props.classes.halfWidth1}>{password}</div>
|
|
141
|
-
<div className={this.props.classes.halfWidth2}>{passwordRepeat}</div>
|
|
142
|
-
</div>;
|
|
143
|
-
}
|
|
144
|
-
return password;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
ConfigPassword.propTypes = {
|
|
149
|
-
socket: PropTypes.object.isRequired,
|
|
150
|
-
themeType: PropTypes.string,
|
|
151
|
-
themeName: PropTypes.string,
|
|
152
|
-
style: PropTypes.object,
|
|
153
|
-
className: PropTypes.string,
|
|
154
|
-
data: PropTypes.object.isRequired,
|
|
155
|
-
schema: PropTypes.object,
|
|
156
|
-
onError: PropTypes.func,
|
|
157
|
-
onChange: PropTypes.func,
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export default withStyles(styles)(ConfigPassword);
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
IconButton,
|
|
6
|
-
TextField,
|
|
7
|
-
} from '@mui/material';
|
|
8
|
-
|
|
9
|
-
import { IconCopy, Utils } from '@iobroker/adapter-react-v5';
|
|
10
|
-
import ConfigGeneric from './ConfigGeneric';
|
|
11
|
-
|
|
12
|
-
class ConfigPattern extends ConfigGeneric {
|
|
13
|
-
renderItem(error, disabled) {
|
|
14
|
-
return <TextField
|
|
15
|
-
variant="standard"
|
|
16
|
-
fullWidth
|
|
17
|
-
disabled={!!disabled}
|
|
18
|
-
InputProps={{
|
|
19
|
-
endAdornment: this.props.schema.copyToClipboard ?
|
|
20
|
-
<IconButton
|
|
21
|
-
size="small"
|
|
22
|
-
onClick={() => {
|
|
23
|
-
Utils.copyToClipboard(this.getPattern(this.props.schema.pattern));
|
|
24
|
-
window.alert('Copied');
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
<IconCopy />
|
|
28
|
-
</IconButton>
|
|
29
|
-
: undefined,
|
|
30
|
-
}}
|
|
31
|
-
value={this.getPattern(this.props.schema.pattern)}
|
|
32
|
-
label={this.getText(this.props.schema.label)}
|
|
33
|
-
helperText={this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}
|
|
34
|
-
/>;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
ConfigPattern.propTypes = {
|
|
39
|
-
socket: PropTypes.object.isRequired,
|
|
40
|
-
themeType: PropTypes.string,
|
|
41
|
-
themeName: PropTypes.string,
|
|
42
|
-
style: PropTypes.object,
|
|
43
|
-
className: PropTypes.string,
|
|
44
|
-
data: PropTypes.object.isRequired,
|
|
45
|
-
schema: PropTypes.object,
|
|
46
|
-
onError: PropTypes.func,
|
|
47
|
-
onChange: PropTypes.func,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default ConfigPattern;
|