@iobroker/json-config 6.17.6 → 6.17.12
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/LICENSE +21 -21
- package/build/JsonConfig.d.ts +1 -1
- package/build/JsonConfig.js +18 -19
- package/build/JsonConfig.js.map +1 -1
- package/build/JsonConfigComponent/ChipInput.d.ts +89 -11
- package/build/JsonConfigComponent/ChipInput.js +48 -137
- package/build/JsonConfigComponent/ChipInput.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAccordion.d.ts +7 -14
- package/build/JsonConfigComponent/ConfigAccordion.js +10 -21
- package/build/JsonConfigComponent/ConfigAccordion.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAlive.d.ts +5 -1
- package/build/JsonConfigComponent/ConfigAlive.js +0 -1
- package/build/JsonConfigComponent/ConfigAlive.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAutocomplete.d.ts +5 -29
- package/build/JsonConfigComponent/ConfigAutocomplete.js +7 -5
- package/build/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.d.ts +5 -14
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js +3 -3
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCRON.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigCertCollection.d.ts +7 -13
- package/build/JsonConfigComponent/ConfigCertCollection.js +8 -18
- package/build/JsonConfigComponent/ConfigCertCollection.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCertificateSelect.d.ts +7 -13
- package/build/JsonConfigComponent/ConfigCertificateSelect.js +5 -18
- package/build/JsonConfigComponent/ConfigCertificateSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCertificates.d.ts +7 -13
- package/build/JsonConfigComponent/ConfigCertificates.js +7 -18
- package/build/JsonConfigComponent/ConfigCertificates.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCheckbox.d.ts +3 -11
- package/build/JsonConfigComponent/ConfigCheckbox.js +2 -2
- package/build/JsonConfigComponent/ConfigCheckbox.js.map +1 -1
- package/build/JsonConfigComponent/ConfigChip.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigColor.d.ts +13 -20
- package/build/JsonConfigComponent/ConfigColor.js +9 -23
- package/build/JsonConfigComponent/ConfigColor.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCoordinates.d.ts +8 -13
- package/build/JsonConfigComponent/ConfigCoordinates.js +29 -39
- package/build/JsonConfigComponent/ConfigCoordinates.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCustom.d.ts +4 -50
- package/build/JsonConfigComponent/ConfigCustom.js +0 -1
- package/build/JsonConfigComponent/ConfigCustom.js.map +1 -1
- package/build/JsonConfigComponent/ConfigDatePicker.d.ts +8 -3
- package/build/JsonConfigComponent/ConfigDatePicker.js +21 -13
- package/build/JsonConfigComponent/ConfigDatePicker.js.map +1 -1
- package/build/JsonConfigComponent/ConfigDeviceManager.d.ts +5 -1
- package/build/JsonConfigComponent/ConfigDeviceManager.js +1 -1
- package/build/JsonConfigComponent/ConfigDeviceManager.js.map +1 -1
- package/build/JsonConfigComponent/ConfigFile.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigFunc.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigGeneric.d.ts +46 -32
- package/build/JsonConfigComponent/ConfigGeneric.js +23 -12
- package/build/JsonConfigComponent/ConfigGeneric.js.map +1 -1
- package/build/JsonConfigComponent/ConfigIP.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigImageSendTo.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigInstanceSelect.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigInterface.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigJsonEditor.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigLanguage.d.ts +3 -2
- package/build/JsonConfigComponent/ConfigLanguage.js +2 -2
- package/build/JsonConfigComponent/ConfigLanguage.js.map +1 -1
- package/build/JsonConfigComponent/ConfigNumber.d.ts +3 -13
- package/build/JsonConfigComponent/ConfigNumber.js +2 -2
- package/build/JsonConfigComponent/ConfigNumber.js.map +1 -1
- package/build/JsonConfigComponent/ConfigObjectId.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigPanel.d.ts +7 -2
- package/build/JsonConfigComponent/ConfigPanel.js +5 -40
- package/build/JsonConfigComponent/ConfigPanel.js.map +1 -1
- package/build/JsonConfigComponent/ConfigPassword.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigPort.d.ts +6 -1
- package/build/JsonConfigComponent/ConfigPort.js +2 -3
- package/build/JsonConfigComponent/ConfigPort.js.map +1 -1
- package/build/JsonConfigComponent/ConfigRoom.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigSelect.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigSelectSendTo.d.ts +7 -16
- package/build/JsonConfigComponent/ConfigSelectSendTo.js +15 -61
- package/build/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSendto.d.ts +3 -20
- package/build/JsonConfigComponent/ConfigSendto.js +8 -8
- package/build/JsonConfigComponent/ConfigSendto.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSetState.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigSlider.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigStaticDivider.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigStaticHeader.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigStaticImage.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigStaticText.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigTable.d.ts +4 -25
- package/build/JsonConfigComponent/ConfigTable.js +5 -4
- package/build/JsonConfigComponent/ConfigTable.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTabs.d.ts +8 -33
- package/build/JsonConfigComponent/ConfigTabs.js +10 -43
- package/build/JsonConfigComponent/ConfigTabs.js.map +1 -1
- package/build/JsonConfigComponent/ConfigText.d.ts +7 -13
- package/build/JsonConfigComponent/ConfigText.js +13 -18
- package/build/JsonConfigComponent/ConfigText.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTextSendTo.d.ts +7 -9
- package/build/JsonConfigComponent/ConfigTextSendTo.js +11 -21
- package/build/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTimePicker.d.ts +9 -3
- package/build/JsonConfigComponent/ConfigTimePicker.js +28 -18
- package/build/JsonConfigComponent/ConfigTimePicker.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTopic.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigUUID.d.ts +12 -13
- package/build/JsonConfigComponent/ConfigUUID.js +1 -6
- package/build/JsonConfigComponent/ConfigUUID.js.map +1 -1
- package/build/JsonConfigComponent/ConfigUser.d.ts +1 -1
- package/build/JsonConfigComponent/index.d.ts +66 -25
- package/build/JsonConfigComponent/index.js +48 -61
- package/build/JsonConfigComponent/index.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/package.json +27 -26
- package/src/JsonConfig.tsx +710 -0
- package/src/JsonConfigComponent/ChipInput.tsx +752 -0
- package/src/JsonConfigComponent/ConfigAccordion.tsx +278 -0
- package/src/JsonConfigComponent/ConfigAlive.tsx +74 -0
- package/src/JsonConfigComponent/ConfigAutocomplete.tsx +108 -0
- package/src/JsonConfigComponent/ConfigAutocompleteSendTo.tsx +183 -0
- package/src/JsonConfigComponent/ConfigCRON.jsx +101 -0
- package/src/JsonConfigComponent/ConfigCertCollection.tsx +102 -0
- package/src/JsonConfigComponent/ConfigCertificateSelect.tsx +92 -0
- package/src/JsonConfigComponent/ConfigCertificates.tsx +202 -0
- package/src/JsonConfigComponent/ConfigCheckLicense.jsx +662 -0
- package/src/JsonConfigComponent/ConfigCheckbox.tsx +67 -0
- package/src/JsonConfigComponent/ConfigChip.jsx +81 -0
- package/src/JsonConfigComponent/ConfigColor.tsx +86 -0
- package/src/JsonConfigComponent/ConfigCoordinates.tsx +234 -0
- package/src/JsonConfigComponent/ConfigCustom.tsx +246 -0
- package/src/JsonConfigComponent/ConfigDatePicker.tsx +48 -0
- package/src/JsonConfigComponent/ConfigDeviceManager.tsx +33 -0
- package/src/JsonConfigComponent/ConfigFile.jsx +181 -0
- package/src/JsonConfigComponent/ConfigFileSelector.jsx +520 -0
- package/src/JsonConfigComponent/ConfigFunc.jsx +90 -0
- package/src/JsonConfigComponent/ConfigGeneric.tsx +1027 -0
- package/src/JsonConfigComponent/ConfigIP.jsx +96 -0
- package/src/JsonConfigComponent/ConfigImageSendTo.jsx +79 -0
- package/src/JsonConfigComponent/ConfigImageUpload.jsx +114 -0
- package/src/JsonConfigComponent/ConfigInstanceSelect.jsx +172 -0
- package/src/JsonConfigComponent/ConfigInterface.jsx +112 -0
- package/src/JsonConfigComponent/ConfigJsonEditor.jsx +103 -0
- package/src/JsonConfigComponent/ConfigLanguage.tsx +153 -0
- package/src/JsonConfigComponent/ConfigLicense.jsx +148 -0
- package/src/JsonConfigComponent/ConfigNumber.tsx +207 -0
- package/src/JsonConfigComponent/ConfigObjectId.jsx +113 -0
- package/src/JsonConfigComponent/ConfigPanel.tsx +360 -0
- package/src/JsonConfigComponent/ConfigPassword.jsx +160 -0
- package/src/JsonConfigComponent/ConfigPattern.jsx +50 -0
- package/src/JsonConfigComponent/ConfigPort.tsx +232 -0
- package/src/JsonConfigComponent/ConfigRoom.jsx +90 -0
- package/src/JsonConfigComponent/ConfigSelect.jsx +124 -0
- package/src/JsonConfigComponent/ConfigSelectSendTo.tsx +251 -0
- package/src/JsonConfigComponent/ConfigSendto.tsx +340 -0
- package/src/JsonConfigComponent/ConfigSetState.jsx +116 -0
- package/src/JsonConfigComponent/ConfigSlider.jsx +97 -0
- package/src/JsonConfigComponent/ConfigStaticDivider.jsx +51 -0
- package/src/JsonConfigComponent/ConfigStaticHeader.jsx +63 -0
- package/src/JsonConfigComponent/ConfigStaticImage.jsx +48 -0
- package/src/JsonConfigComponent/ConfigStaticText.jsx +72 -0
- package/src/JsonConfigComponent/ConfigTable.tsx +1040 -0
- package/src/JsonConfigComponent/ConfigTabs.tsx +150 -0
- package/src/JsonConfigComponent/ConfigText.tsx +188 -0
- package/src/JsonConfigComponent/ConfigTextSendTo.tsx +102 -0
- package/src/JsonConfigComponent/ConfigTimePicker.tsx +63 -0
- package/src/JsonConfigComponent/ConfigTopic.jsx +78 -0
- package/src/JsonConfigComponent/ConfigUUID.tsx +55 -0
- package/src/JsonConfigComponent/ConfigUser.jsx +104 -0
- package/src/JsonConfigComponent/index.tsx +435 -0
- package/src/JsonConfigComponent/wrapper/Components/CustomModal.jsx +145 -0
- package/src/JsonConfigComponent/wrapper/Components/Editor.jsx +65 -0
- package/src/Utils.jsx +1683 -0
- package/src/index.tsx +14 -0
- package/src/types.d.ts +372 -0
|
@@ -0,0 +1,360 @@
|
|
|
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;
|
|
@@ -0,0 +1,160 @@
|
|
|
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);
|
|
@@ -0,0 +1,50 @@
|
|
|
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;
|