@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,232 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withStyles } from '@mui/styles';
|
|
3
|
+
|
|
4
|
+
import { TextField } from '@mui/material';
|
|
5
|
+
|
|
6
|
+
import { I18n } from '@iobroker/adapter-react-v5';
|
|
7
|
+
|
|
8
|
+
import type { ConfigItemPort } from '#JC/types';
|
|
9
|
+
import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
|
|
10
|
+
|
|
11
|
+
const styles: Record<string, any> = {
|
|
12
|
+
indeterminate: {
|
|
13
|
+
opacity: 0.5,
|
|
14
|
+
},
|
|
15
|
+
control: {
|
|
16
|
+
flexDirection: 'row',
|
|
17
|
+
width: '100%',
|
|
18
|
+
},
|
|
19
|
+
warning: {
|
|
20
|
+
'& .Mui-error': {
|
|
21
|
+
color: 'orange',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
interface Port {
|
|
27
|
+
name: string;
|
|
28
|
+
port: number;
|
|
29
|
+
bind: string;
|
|
30
|
+
v6bind: string;
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface ConfigPortProps extends ConfigGenericProps {
|
|
35
|
+
schema: ConfigItemPort;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface ConfigPortState extends ConfigGenericState {
|
|
39
|
+
_value: string;
|
|
40
|
+
oldValue: string | null;
|
|
41
|
+
ports: Port[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class ConfigPort extends ConfigGeneric<ConfigPortProps, ConfigPortState> {
|
|
45
|
+
private updateTimeout?: ReturnType<typeof setTimeout>;
|
|
46
|
+
|
|
47
|
+
async componentDidMount(): Promise<void> {
|
|
48
|
+
super.componentDidMount();
|
|
49
|
+
let _value = ConfigGeneric.getValue(this.props.data, this.props.attr);
|
|
50
|
+
if (_value === null || _value === undefined) {
|
|
51
|
+
_value = '';
|
|
52
|
+
}
|
|
53
|
+
this.setState({ _value: _value.toString(), oldValue: _value.toString() });
|
|
54
|
+
|
|
55
|
+
// read all instances
|
|
56
|
+
const instances: ioBroker.InstanceObject[] = await this.props.socket.getAdapterInstances();
|
|
57
|
+
|
|
58
|
+
const ownId = `system.adapter.${this.props.adapterName}.${this.props.instance}`;
|
|
59
|
+
const instanceObj: ioBroker.InstanceObject = await this.props.socket.getObject(ownId) as ioBroker.InstanceObject;
|
|
60
|
+
const ownHostname = instanceObj?.common.host;
|
|
61
|
+
|
|
62
|
+
const ports: Port[] = [];
|
|
63
|
+
instances
|
|
64
|
+
.forEach(instance => {
|
|
65
|
+
// ignore own instance and instances on another host
|
|
66
|
+
if (!instance || instance._id === ownId || instance.common.host !== ownHostname) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// check port only if bind attribute is present too
|
|
70
|
+
if (!instance.native?.bind) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// if let's encrypt is enabled and update is enabled, then add port to check
|
|
75
|
+
if (instance?.native &&
|
|
76
|
+
instance.native.secure &&
|
|
77
|
+
instance.native.leEnabled &&
|
|
78
|
+
instance.native.leUpdate
|
|
79
|
+
) {
|
|
80
|
+
const port = parseInt(instance.native.leCheckPort || instance.native.lePort, 10);
|
|
81
|
+
port && ports.push({
|
|
82
|
+
name: `${instance._id.replace('system.adapter.', '')} (LE)`,
|
|
83
|
+
port,
|
|
84
|
+
v6bind: instance.native.bind.includes(':') ? instance.native.bind : instance.native.v6bind,
|
|
85
|
+
bind: instance.native.bind,
|
|
86
|
+
enabled: !!instance.common?.enabled,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const port = parseInt(instance?.native?.port, 10);
|
|
91
|
+
if (port) {
|
|
92
|
+
ports.push({
|
|
93
|
+
name: instance._id.replace('system.adapter.', ''),
|
|
94
|
+
bind: instance.native.bind,
|
|
95
|
+
v6bind: instance.native.bind.includes(':') ? instance.native.bind : instance.native.v6bind,
|
|
96
|
+
port,
|
|
97
|
+
enabled: !!instance.common?.enabled,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
this.setState({ ports });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static getDerivedStateFromProps(props: ConfigPortProps, state: ConfigPortState) {
|
|
105
|
+
const _value = ConfigGeneric.getValue(props.data, props.attr);
|
|
106
|
+
if (_value === null || _value === undefined ||
|
|
107
|
+
state.oldValue === null || state.oldValue === undefined ||
|
|
108
|
+
(_value.toString() !== parseInt(state._value, 10).toString() &&
|
|
109
|
+
_value.toString() !== state.oldValue.toString())
|
|
110
|
+
) {
|
|
111
|
+
return { _value };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
checkValue(value: string): string | null {
|
|
118
|
+
if (value === null || value === undefined) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const min = this.props.schema.min === undefined ? 20 : this.props.schema.min;
|
|
123
|
+
const max = this.props.schema.max || 0xFFFF;
|
|
124
|
+
|
|
125
|
+
value = value.toString().trim();
|
|
126
|
+
const f = value === '' ? 0 : parseInt(value, 10);
|
|
127
|
+
|
|
128
|
+
if (value !== '' && Number.isNaN(f)) {
|
|
129
|
+
return 'ra_Not a number';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// eslint-disable-next-line no-restricted-properties
|
|
133
|
+
if (value !== '' && window.isFinite(Number(value))) {
|
|
134
|
+
if (f < min) {
|
|
135
|
+
return 'ra_Too small';
|
|
136
|
+
}
|
|
137
|
+
if (f > max) {
|
|
138
|
+
return 'ra_Too big';
|
|
139
|
+
}
|
|
140
|
+
if (value === '' || value === '-' || Number.isNaN(f)) {
|
|
141
|
+
return 'ra_Not a number';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return 'ra_Not a number';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
renderItem(error: unknown, disabled: boolean): React.JSX.Element {
|
|
151
|
+
if (this.state.oldValue !== null && this.state.oldValue !== undefined) {
|
|
152
|
+
this.updateTimeout && clearTimeout(this.updateTimeout);
|
|
153
|
+
this.updateTimeout = setTimeout(() => {
|
|
154
|
+
this.updateTimeout = undefined;
|
|
155
|
+
this.setState({ oldValue: null });
|
|
156
|
+
}, 30);
|
|
157
|
+
} else if (this.updateTimeout) {
|
|
158
|
+
clearTimeout(this.updateTimeout);
|
|
159
|
+
this.updateTimeout = undefined;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const min = this.props.schema.min === undefined ? 20 : this.props.schema.min;
|
|
163
|
+
const max = this.props.schema.max || 0xFFFF;
|
|
164
|
+
|
|
165
|
+
let warning;
|
|
166
|
+
if (this.state.ports) {
|
|
167
|
+
const num = parseInt(this.state._value, 10);
|
|
168
|
+
|
|
169
|
+
if (num) {
|
|
170
|
+
// filter ports only with the same bind address
|
|
171
|
+
// todo: IPv6 (v6bind or '::/0')
|
|
172
|
+
const ports = this.state.ports.filter(item => !this.props.data.bind ||
|
|
173
|
+
this.props.data.bind === item.bind ||
|
|
174
|
+
this.props.data.bind === '0.0.0.0' ||
|
|
175
|
+
item.bind === '0.0.0.0');
|
|
176
|
+
|
|
177
|
+
let idx = ports.findIndex(item => item.port === num && item.enabled);
|
|
178
|
+
if (idx !== -1) {
|
|
179
|
+
error = I18n.t('ra_Port is already used by %s', this.state.ports[idx].name);
|
|
180
|
+
} else {
|
|
181
|
+
idx = ports.findIndex(item => item.port === num && !item.enabled);
|
|
182
|
+
if (idx !== -1) {
|
|
183
|
+
warning = true;
|
|
184
|
+
error = I18n.t('ra_Port could be used by %s', this.state.ports[idx].name);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (!error && this.state._value !== null && this.state._value !== undefined) {
|
|
191
|
+
error = this.checkValue(this.state._value);
|
|
192
|
+
if (typeof error === 'string') {
|
|
193
|
+
error = I18n.t(error);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return <TextField
|
|
198
|
+
variant="standard"
|
|
199
|
+
type="number"
|
|
200
|
+
fullWidth
|
|
201
|
+
inputProps={{
|
|
202
|
+
min,
|
|
203
|
+
max,
|
|
204
|
+
readOnly: this.props.schema.readOnly || false,
|
|
205
|
+
}}
|
|
206
|
+
value={this.state._value === null || this.state._value === undefined ? '' : this.state._value}
|
|
207
|
+
error={!!error}
|
|
208
|
+
disabled={!!disabled}
|
|
209
|
+
className={warning ? this.props.classes.warning : ''}
|
|
210
|
+
onChange={e => {
|
|
211
|
+
const _value = Number(e.target.value.toString().replace(/[^0-9]/g, '')).toString();
|
|
212
|
+
const _error = this.checkValue(_value);
|
|
213
|
+
if (_error) {
|
|
214
|
+
this.onError(this.props.attr, I18n.t(_error));
|
|
215
|
+
} else {
|
|
216
|
+
this.onError(this.props.attr); // clear error
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
this.setState({ _value, oldValue: this.state._value }, () => {
|
|
220
|
+
if (_value.trim() === parseInt(_value, 10).toString()) {
|
|
221
|
+
this.onChange(this.props.attr, parseInt(_value, 10) || 0);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}}
|
|
225
|
+
placeholder={this.getText(this.props.schema.placeholder)}
|
|
226
|
+
label={this.getText(this.props.schema.label)}
|
|
227
|
+
helperText={error && typeof error === 'string' ? error : this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}
|
|
228
|
+
/>;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export default withStyles(styles)(ConfigPort);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { withStyles } from '@mui/styles';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
InputLabel,
|
|
7
|
+
MenuItem,
|
|
8
|
+
FormHelperText,
|
|
9
|
+
FormControl,
|
|
10
|
+
Select,
|
|
11
|
+
} from '@mui/material';
|
|
12
|
+
|
|
13
|
+
import { TextWithIcon, I18n } from '@iobroker/adapter-react-v5';
|
|
14
|
+
|
|
15
|
+
import ConfigGeneric from './ConfigGeneric';
|
|
16
|
+
|
|
17
|
+
const styles = () => ({
|
|
18
|
+
fullWidth: {
|
|
19
|
+
width: '100%',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
class ConfigFunc extends ConfigGeneric {
|
|
24
|
+
componentDidMount() {
|
|
25
|
+
super.componentDidMount();
|
|
26
|
+
const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
|
|
27
|
+
|
|
28
|
+
this.props.socket.getEnums('rooms')
|
|
29
|
+
.then(enums => {
|
|
30
|
+
const selectOptions = Object.keys(enums)
|
|
31
|
+
.map(id => ({
|
|
32
|
+
value: this.props.schema.short ? id.replace('enum.rooms.', '') : id,
|
|
33
|
+
label: this.getText(enums[id].common.name),
|
|
34
|
+
obj: enums[id],
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
if (this.props.schema.allowDeactivate !== false) {
|
|
38
|
+
selectOptions.unshift({ label: I18n.t(ConfigGeneric.NONE_LABEL), value: ConfigGeneric.NONE_VALUE });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.setState({ value, selectOptions });
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
renderItem(error, disabled /* , defaultValue */) {
|
|
46
|
+
if (!this.state.selectOptions) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const item = this.state.selectOptions.find(it => it.value === this.state.value);
|
|
51
|
+
|
|
52
|
+
return <FormControl
|
|
53
|
+
variant="standard"
|
|
54
|
+
className={this.props.classes.fullWidth}
|
|
55
|
+
>
|
|
56
|
+
{this.props.schema.label ? <InputLabel>{this.getText(this.props.schema.label)}</InputLabel> : null}
|
|
57
|
+
<Select
|
|
58
|
+
variant="standard"
|
|
59
|
+
error={!!error}
|
|
60
|
+
disabled={!!disabled}
|
|
61
|
+
value={this.state.value || '_'}
|
|
62
|
+
renderValue={() => (item ? (item.obj ? <TextWithIcon value={item.obj} themeType={this.props.themeType} lang={I18n.getLanguage()} /> : item.label) : '')}
|
|
63
|
+
onChange={e => {
|
|
64
|
+
this.setState({ value: e.target.value === '_' ? '' : e.target.value }, () =>
|
|
65
|
+
this.onChange(this.props.attr, this.state.value));
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{this.state.selectOptions.map(it =>
|
|
69
|
+
<MenuItem key={it.value} value={it.value} style={it.value === ConfigGeneric.DIFFERENT_VALUE ? { opacity: 0.5 } : {}}>
|
|
70
|
+
{it.obj ? <TextWithIcon value={it.obj} themeType={this.props.themeType} lang={I18n.getLanguage()} /> : it.label}
|
|
71
|
+
</MenuItem>)}
|
|
72
|
+
</Select>
|
|
73
|
+
{this.props.schema.help ? <FormHelperText>{this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}</FormHelperText> : null}
|
|
74
|
+
</FormControl>;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ConfigFunc.propTypes = {
|
|
79
|
+
socket: PropTypes.object.isRequired,
|
|
80
|
+
themeType: PropTypes.string,
|
|
81
|
+
themeName: PropTypes.string,
|
|
82
|
+
style: PropTypes.object,
|
|
83
|
+
className: PropTypes.string,
|
|
84
|
+
data: PropTypes.object.isRequired,
|
|
85
|
+
schema: PropTypes.object,
|
|
86
|
+
onError: PropTypes.func,
|
|
87
|
+
onChange: PropTypes.func,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default withStyles(styles)(ConfigFunc);
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { withStyles } from '@mui/styles';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
InputLabel,
|
|
7
|
+
FormHelperText,
|
|
8
|
+
FormControl,
|
|
9
|
+
Select,
|
|
10
|
+
MenuItem,
|
|
11
|
+
ListSubheader,
|
|
12
|
+
} from '@mui/material';
|
|
13
|
+
|
|
14
|
+
import { Utils, I18n } from '@iobroker/adapter-react-v5';
|
|
15
|
+
|
|
16
|
+
import ConfigGeneric from './ConfigGeneric';
|
|
17
|
+
|
|
18
|
+
const styles = () => ({
|
|
19
|
+
fullWidth: {
|
|
20
|
+
width: '100%',
|
|
21
|
+
},
|
|
22
|
+
noMargin: {
|
|
23
|
+
'&>div': {
|
|
24
|
+
marginTop: 0,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
class ConfigSelect extends ConfigGeneric {
|
|
30
|
+
componentDidMount() {
|
|
31
|
+
super.componentDidMount();
|
|
32
|
+
const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
|
|
33
|
+
|
|
34
|
+
const selectOptions = [];
|
|
35
|
+
|
|
36
|
+
(this.props.schema.options || []).forEach(item => {
|
|
37
|
+
// if optgroup
|
|
38
|
+
if (Array.isArray(item.items)) {
|
|
39
|
+
selectOptions.push({ label: item.label, value: item.value, group: true });
|
|
40
|
+
item.items = item.items.forEach(it => selectOptions.push(it));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
selectOptions.push(item);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// if __different
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
this.initialValue = [...value];
|
|
50
|
+
selectOptions.unshift({ label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE });
|
|
51
|
+
this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });
|
|
52
|
+
} else {
|
|
53
|
+
this.setState({ value, selectOptions });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
renderItem(error, disabled /* , defaultValue */) {
|
|
58
|
+
if (!this.state.selectOptions) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const selectOptions = (this.state.selectOptions || []).filter(item => {
|
|
63
|
+
// if optgroup or no hidden function
|
|
64
|
+
if (!item.hidden) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if (this.props.custom) {
|
|
68
|
+
return !this.executeCustom(item.hidden, this.props.data, this.props.customObj, this.props.instanceObj, this.props.arrayIndex, this.props.globalData);
|
|
69
|
+
}
|
|
70
|
+
return !this.execute(item.hidden, this.props.schema.default, this.props.data, this.props.arrayIndex, this.props.globalData);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line
|
|
74
|
+
const item = selectOptions.find(it => it.value == this.state.value); // let "==" be and not ===
|
|
75
|
+
|
|
76
|
+
return <FormControl
|
|
77
|
+
variant="standard"
|
|
78
|
+
className={Utils.clsx(this.props.classes.fullWidth, this.props.table !== undefined && this.props.classes.noMargin)}
|
|
79
|
+
id={`jsonSelect_${this.props.schema.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}`}
|
|
80
|
+
>
|
|
81
|
+
{this.props.schema.label ? <InputLabel>{this.getText(this.props.schema.label)}</InputLabel> : null}
|
|
82
|
+
<Select
|
|
83
|
+
variant="standard"
|
|
84
|
+
error={!!error}
|
|
85
|
+
disabled={!!disabled}
|
|
86
|
+
value={this.state.value || '_'}
|
|
87
|
+
renderValue={() => this.getText(item?.label, this.props.schema.noTranslation)}
|
|
88
|
+
onChange={e => {
|
|
89
|
+
this.setState({ value: e.target.value === '_' ? '' : e.target.value }, () => {
|
|
90
|
+
if (this.state.value === ConfigGeneric.DIFFERENT_VALUE) {
|
|
91
|
+
this.onChange(this.props.attr, this.initialValue);
|
|
92
|
+
} else {
|
|
93
|
+
this.onChange(this.props.attr, this.state.value);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
{selectOptions.map((it, i) => {
|
|
99
|
+
if (it.group) {
|
|
100
|
+
return <ListSubheader key={i}>{this.getText(it.label, this.props.schema.noTranslation)}</ListSubheader>;
|
|
101
|
+
}
|
|
102
|
+
return <MenuItem key={i} value={it.value} style={it.value === ConfigGeneric.DIFFERENT_VALUE ? { opacity: 0.5 } : {}}>
|
|
103
|
+
{this.getText(it.label, this.props.schema.noTranslation)}
|
|
104
|
+
</MenuItem>;
|
|
105
|
+
})}
|
|
106
|
+
</Select>
|
|
107
|
+
{this.props.schema.help ? <FormHelperText>{this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}</FormHelperText> : null}
|
|
108
|
+
</FormControl>;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
ConfigSelect.propTypes = {
|
|
113
|
+
socket: PropTypes.object.isRequired,
|
|
114
|
+
themeType: PropTypes.string,
|
|
115
|
+
themeName: PropTypes.string,
|
|
116
|
+
style: PropTypes.object,
|
|
117
|
+
className: PropTypes.string,
|
|
118
|
+
data: PropTypes.object.isRequired,
|
|
119
|
+
schema: PropTypes.object,
|
|
120
|
+
onError: PropTypes.func,
|
|
121
|
+
onChange: PropTypes.func,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export default withStyles(styles)(ConfigSelect);
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withStyles } from '@mui/styles';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
InputLabel,
|
|
6
|
+
MenuItem,
|
|
7
|
+
FormHelperText,
|
|
8
|
+
FormControl,
|
|
9
|
+
Select,
|
|
10
|
+
TextField,
|
|
11
|
+
CircularProgress,
|
|
12
|
+
ListItemText,
|
|
13
|
+
Checkbox,
|
|
14
|
+
Chip,
|
|
15
|
+
Box, InputAdornment, IconButton,
|
|
16
|
+
} from '@mui/material';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
Close as CloseIcon,
|
|
20
|
+
} from '@mui/icons-material';
|
|
21
|
+
|
|
22
|
+
import { I18n } from '@iobroker/adapter-react-v5';
|
|
23
|
+
|
|
24
|
+
import type { ConfigItemSelectSendTo } from '#JC/types';
|
|
25
|
+
import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
|
|
26
|
+
|
|
27
|
+
const styles: Record<string, any> = {
|
|
28
|
+
fullWidth: {
|
|
29
|
+
width: '100%',
|
|
30
|
+
},
|
|
31
|
+
menuPaper: {
|
|
32
|
+
maxHeight: 800,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
to use this option, your adapter must implement listUart message
|
|
38
|
+
|
|
39
|
+
adapter.on('message', obj => {
|
|
40
|
+
if (obj) {
|
|
41
|
+
switch (obj.command) {
|
|
42
|
+
case 'command':
|
|
43
|
+
if (obj.callback) {
|
|
44
|
+
try {
|
|
45
|
+
const serialport = require('serialport');
|
|
46
|
+
if (serialport) {
|
|
47
|
+
// read all found serial ports
|
|
48
|
+
serialport.list()
|
|
49
|
+
.then(ports => {
|
|
50
|
+
adapter.log.info('List of port: ' + JSON.stringify(ports));
|
|
51
|
+
adapter.sendTo(obj.from, obj.command, ports.map(item =>
|
|
52
|
+
({label: item.path, value: item.path})), obj.callback);
|
|
53
|
+
})
|
|
54
|
+
.catch(e => {
|
|
55
|
+
adapter.sendTo(obj.from, obj.command, [], obj.callback);
|
|
56
|
+
adapter.log.error(e)
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
adapter.log.warn('Module serialport is not available');
|
|
60
|
+
adapter.sendTo(obj.from, obj.command, [{label: 'Not available', value: ''}], obj.callback);
|
|
61
|
+
}
|
|
62
|
+
} catch (e) {
|
|
63
|
+
adapter.sendTo(obj.from, obj.command, [{label: 'Not available', value: ''}], obj.callback);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
interface ConfigSelectSendToProps extends ConfigGenericProps {
|
|
74
|
+
schema: ConfigItemSelectSendTo;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface ConfigSelectSendToState extends ConfigGenericState {
|
|
78
|
+
list?: { label: string; value: string, hidden?: boolean }[];
|
|
79
|
+
context?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
class ConfigSelectSendTo extends ConfigGeneric<ConfigSelectSendToProps, ConfigSelectSendToState> {
|
|
83
|
+
componentDidMount() {
|
|
84
|
+
super.componentDidMount();
|
|
85
|
+
|
|
86
|
+
this.askInstance();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
askInstance() {
|
|
90
|
+
if (this.props.alive) {
|
|
91
|
+
let data: Record<string, any> | undefined = this.props.schema.data;
|
|
92
|
+
if (data === undefined && this.props.schema.jsonData) {
|
|
93
|
+
const dataStr: string = this.getPattern(this.props.schema.jsonData);
|
|
94
|
+
try {
|
|
95
|
+
data = JSON.parse(dataStr);
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error(`Cannot parse json data: ${dataStr}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (data === undefined) {
|
|
102
|
+
data = null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.props.socket.sendTo(`${this.props.adapterName}.${this.props.instance}`, this.props.schema.command || 'send', data)
|
|
106
|
+
.then(list =>
|
|
107
|
+
this.setState({ list, context: this.getContext() }));
|
|
108
|
+
} else {
|
|
109
|
+
const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
|
|
110
|
+
|
|
111
|
+
this.setState({ value });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
getContext(): string {
|
|
116
|
+
const context: Record<string, any> = {};
|
|
117
|
+
|
|
118
|
+
if (Array.isArray(this.props.schema.alsoDependsOn)) {
|
|
119
|
+
this.props.schema.alsoDependsOn.forEach(attr =>
|
|
120
|
+
context[attr] = ConfigGeneric.getValue(this.props.data, attr));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return JSON.stringify(context);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_getValue() {
|
|
127
|
+
let value = this.state.value === null || this.state.value === undefined ? ConfigGeneric.getValue(this.props.data, this.props.attr) : this.state.value;
|
|
128
|
+
|
|
129
|
+
if (this.props.schema.multiple) {
|
|
130
|
+
if (typeof value === 'string') {
|
|
131
|
+
value = [value];
|
|
132
|
+
} else if (value === null || value === undefined) {
|
|
133
|
+
value = [];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
renderItem(error: unknown, disabled: boolean /* , defaultValue */) {
|
|
141
|
+
if (this.props.alive) {
|
|
142
|
+
const context = this.getContext();
|
|
143
|
+
if (context !== this.state.context) {
|
|
144
|
+
setTimeout(() => this.askInstance(), 300);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const value = this._getValue();
|
|
149
|
+
|
|
150
|
+
if (!this.props.alive) {
|
|
151
|
+
if (this.props.schema.multiple || this.props.schema.manual === false) {
|
|
152
|
+
return I18n.t('ra_Cannot retrieve options, as instance is offline');
|
|
153
|
+
}
|
|
154
|
+
return <TextField
|
|
155
|
+
variant="standard"
|
|
156
|
+
fullWidth
|
|
157
|
+
value={value}
|
|
158
|
+
error={!!error}
|
|
159
|
+
disabled={!!disabled}
|
|
160
|
+
onChange={e => {
|
|
161
|
+
const value_ = e.target.value;
|
|
162
|
+
this.setState({ value: value_ }, () =>
|
|
163
|
+
this.onChange(this.props.attr, (value_ || '').trim()));
|
|
164
|
+
}}
|
|
165
|
+
placeholder={this.getText(this.props.schema.placeholder)}
|
|
166
|
+
label={this.getText(this.props.schema.label)}
|
|
167
|
+
helperText={this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}
|
|
168
|
+
InputProps={{
|
|
169
|
+
endAdornment: this.state.value && !this.props.schema.noClearButton ? <InputAdornment position="end">
|
|
170
|
+
<IconButton
|
|
171
|
+
size="small"
|
|
172
|
+
onClick={() => this.setState({ value: '' }, () =>
|
|
173
|
+
this.onChange(this.props.attr, ''))}
|
|
174
|
+
>
|
|
175
|
+
<CloseIcon />
|
|
176
|
+
</IconButton>
|
|
177
|
+
</InputAdornment> : null,
|
|
178
|
+
}}
|
|
179
|
+
/>;
|
|
180
|
+
}
|
|
181
|
+
if (!this.state.list) {
|
|
182
|
+
return <CircularProgress size="small" />;
|
|
183
|
+
}
|
|
184
|
+
const selectOptions = this.state.list
|
|
185
|
+
.filter(item => {
|
|
186
|
+
if (!item.hidden) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
if (this.props.custom) {
|
|
190
|
+
return !this.executeCustom(item.hidden, this.props.data, this.props.customObj, this.props.instanceObj, this.props.arrayIndex, this.props.globalData);
|
|
191
|
+
}
|
|
192
|
+
return !this.execute(item.hidden, this.props.schema.default, this.props.data, this.props.arrayIndex, this.props.globalData);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const item = selectOptions.find(it => it.value === value);
|
|
196
|
+
|
|
197
|
+
return <FormControl variant="standard" className={this.props.classes.fullWidth}>
|
|
198
|
+
{this.props.schema.label ? <InputLabel>{this.getText(this.props.schema.label)}</InputLabel> : null}
|
|
199
|
+
<Select
|
|
200
|
+
variant="standard"
|
|
201
|
+
error={!!error}
|
|
202
|
+
multiple={this.props.schema.multiple}
|
|
203
|
+
disabled={!!disabled}
|
|
204
|
+
value={value}
|
|
205
|
+
MenuProps={this.props.schema.multiple ? { classes: { paper: this.props.classes.menuPaper } } : undefined}
|
|
206
|
+
renderValue={val =>
|
|
207
|
+
(this.props.schema.multiple ?
|
|
208
|
+
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>
|
|
209
|
+
{val.map((v: string) => {
|
|
210
|
+
const it = selectOptions.find(_item => _item.value === v);
|
|
211
|
+
if (it || this.props.schema.showAllValues !== false) {
|
|
212
|
+
const label = it?.label || v;
|
|
213
|
+
return <Chip
|
|
214
|
+
key={v}
|
|
215
|
+
label={label}
|
|
216
|
+
/>;
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
})}
|
|
220
|
+
</Box>
|
|
221
|
+
:
|
|
222
|
+
(item?.label || val))}
|
|
223
|
+
onChange={e => {
|
|
224
|
+
this.onChange(this.props.attr, e.target.value);
|
|
225
|
+
}}
|
|
226
|
+
>
|
|
227
|
+
{selectOptions.map((it, i) =>
|
|
228
|
+
<MenuItem key={i} value={it.value}>
|
|
229
|
+
{ this.props.schema.multiple ? <Checkbox
|
|
230
|
+
checked={value.includes(it.value)}
|
|
231
|
+
onClick={() => {
|
|
232
|
+
const _value = JSON.parse(JSON.stringify(this._getValue()));
|
|
233
|
+
const pos = value.indexOf(it.value);
|
|
234
|
+
if (pos !== -1) {
|
|
235
|
+
_value.splice(pos, 1);
|
|
236
|
+
} else {
|
|
237
|
+
_value.push(it.value);
|
|
238
|
+
_value.sort();
|
|
239
|
+
}
|
|
240
|
+
this.setState({ value: _value }, () => this.onChange(this.props.attr, _value));
|
|
241
|
+
}}
|
|
242
|
+
/> : null }
|
|
243
|
+
<ListItemText primary={it.label} />
|
|
244
|
+
</MenuItem>)}
|
|
245
|
+
</Select>
|
|
246
|
+
{this.props.schema.help ? <FormHelperText>{this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}</FormHelperText> : null}
|
|
247
|
+
</FormControl>;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export default withStyles(styles)(ConfigSelectSendTo);
|