@iobroker/json-config 8.0.3 → 8.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1214,31 +1214,34 @@ show device manager. For that, the adapter must support device manager protocol.
1214
1214
 
1215
1215
  Here is an example of how to show device manager in a tab:
1216
1216
 
1217
- ```json
1218
- "_deviceManager": {
1219
- "type": "panel",
1220
- "label": "Device manager",
1221
- "items": {
1222
- "_dm": {
1223
- "type": "deviceManager",
1224
- "sm": 12,
1225
- "style": {
1226
- "width": "100%",
1227
- "height": "100%",
1228
- "overflow": "hidden"
1229
- }
1217
+ ```json5
1218
+ {
1219
+ //...
1220
+ "_deviceManager": {
1221
+ "type": "panel",
1222
+ "label": "Device manager",
1223
+ "items": {
1224
+ "_dm": {
1225
+ "type": "deviceManager",
1226
+ "sm": 12,
1227
+ "style": {
1228
+ "width": "100%",
1229
+ "height": "100%",
1230
+ "overflow": "hidden"
1231
+ }
1232
+ }
1233
+ },
1234
+ "style": {
1235
+ "width": "100%",
1236
+ "height": "100%",
1237
+ "overflow": "hidden"
1238
+ },
1239
+ "innerStyle": {
1240
+ "width": "100%",
1241
+ "height": "100%",
1242
+ "overflow": "hidden"
1243
+ }
1230
1244
  }
1231
- },
1232
- "style": {
1233
- "width": "100%",
1234
- "height": "100%",
1235
- "overflow": "hidden"
1236
- },
1237
- "innerStyle": {
1238
- "width": "100%",
1239
- "height": "100%",
1240
- "overflow": "hidden"
1241
- }
1242
1245
  }
1243
1246
  ```
1244
1247
 
@@ -1289,30 +1292,30 @@ In the Settings of the Web developer tools, you can create your own devices with
1289
1292
 
1290
1293
  ### Further options
1291
1294
 
1292
- | option | description |
1293
- |--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1294
- | `type` | If element has no attribute `type`, assume it has default type 'panel'. Type of an element. For currently available options see [Common Control Elements:](#common-control-elements) |
1295
- | `newLine` | should be shown from new line |
1296
- | `label` | String or object like {en: 'Name', ru: 'Имя'} |
1297
- | `hidden` | JS function that could use `native.attribute` for calculation |
1298
- | `hideOnlyControl` | if hidden the place will be shown, but no control |
1299
- | `disabled` | JS function that could use `native.attribute` for calculation |
1300
- | `help` | help text (multi-language) |
1301
- | `helpLink` | href to help (could be used only together with `help`) |
1302
- | `style` | CSS style in ReactJS notation: `radiusBorder` and not `radius-border`. |
1303
- | `darkStyle` | CSS style for dark mode |
1304
- | `validator` | JS function: true no error, false - error |
1305
- | `validatorErrorText` | Text to show if validator fails |
1306
- | `validatorNoSaveOnError` | disable save button if error |
1307
- | `tooltip` | optional tooltip |
1308
- | `default` | default value |
1309
- | `defaultFunc` | JS function to calculate default value |
1310
- | `placeholder` | placeholder (for text control) |
1311
- | `noTranslation` | do not translate selects or other options (not for help, label or placeholder) |
1312
- | `onChange` | Structure in form `{"alsoDependsOn": ["attr1", "attr2"], "calculateFunc": "data.attr1 + data.attr2", "ignoreOwnChanges": true}` |
1313
- | `doNotSave` | Do not save this attribute as used only for internal calculations |
1314
- | `noMultiEdit` | if this flag set to true, this field will not be shown if user selected more than one object for edit. |
1315
- | `expertMode` | if this flag set to true, this field will be shown only if the expert mode is true (from Admin 7.4.3) |
1295
+ | option | description |
1296
+ |--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1297
+ | `type` | If element has no attribute `type`, assume it has default type 'panel'. Type of an element. For currently available options see [Common Control Elements:](#common-control-elements) |
1298
+ | `newLine` | should be shown from new line |
1299
+ | `label` | String or object like {en: 'Name', ru: 'Имя'} |
1300
+ | `hidden` | JS function that could use `native.attribute` for calculation |
1301
+ | `hideOnlyControl` | if hidden the place will be shown, but no control |
1302
+ | `disabled` | JS function that could use `native.attribute` for calculation |
1303
+ | `help` | help text (multi-language) |
1304
+ | `helpLink` | href to help (could be used only together with `help`) |
1305
+ | `style` | CSS style in ReactJS notation: `radiusBorder` and not `radius-border`. |
1306
+ | `darkStyle` | CSS style for dark mode |
1307
+ | `validator` | JS function: true no error, false - error |
1308
+ | `validatorErrorText` | Text to show if validator fails |
1309
+ | `validatorNoSaveOnError` | disable save button if error |
1310
+ | `tooltip` | optional tooltip |
1311
+ | `default` | default value |
1312
+ | `defaultFunc` | JS function to calculate default value |
1313
+ | `placeholder` | placeholder (for text control) |
1314
+ | `noTranslation` | do not translate selects or other options (not for help, label or placeholder) |
1315
+ | `onChange` | Structure in form `{"alsoDependsOn": ["attr1", "attr2"], "calculateFunc": "data.attr1 + data.attr2", "ignoreOwnChanges": true}` |
1316
+ | `doNotSave` | Do not save this attribute as used only for internal calculations |
1317
+ | `noMultiEdit` | if this flag set to true, this field will not be shown if user selected more than one object for edit. |
1318
+ | `expertMode` | if this flag set to true, this field will be shown only if the expert mode is true (from Admin 7.4.3) |
1316
1319
 
1317
1320
  ### Options with detailed configuration
1318
1321
 
@@ -1588,11 +1591,18 @@ Create an issue here: https://github.com/ioBroker/ioBroker.admin/issues
1588
1591
  ## For maintainer
1589
1592
  To update the location of JsonConfig schema, create pull request to this file: https://github.com/ioBroker/ioBroker.admin/blob/master/packages/jsonConfig/schemas/jsonConfig.json
1590
1593
 
1594
+ ## For developer
1595
+ The schema is used here: https://github.com/SchemaStore/schemastore/blob/6da29cd9d7cc240fb4980625f0de6cf7bd8dfd06/src/api/json/catalog.json#L3214
1596
+
1591
1597
  <!--
1592
1598
  Placeholder for the next version (at the beginning of the line):
1593
1599
  ### **WORK IN PROGRESS**
1594
1600
  -->
1595
1601
  ## Changelog
1602
+ ### 8.0.4 (2025-10-25)
1603
+ - (@GermanBluefox) Do not translate certificates names
1604
+ - (@GermanBluefox) Update packages
1605
+
1596
1606
  ### 8.0.3 (2025-10-23)
1597
1607
  - (@GermanBluefox) Do not translate certificates names
1598
1608
 
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigCertificateSelect.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigCertificateSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,O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, MenuItem, FormControl, Select, FormHelperText } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemCertificateSelect } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface ConfigCertificateSelectProps extends ConfigGenericProps {\n schema: ConfigItemCertificateSelect;\n}\n\ninterface ConfigCertificateSelectState extends ConfigGenericState {\n selectOptions?: { label: string; value: string }[];\n}\n\nexport default class ConfigCertificateSelect extends ConfigGeneric<\n ConfigCertificateSelectProps,\n ConfigCertificateSelectState\n> {\n async componentDidMount(): Promise<void> {\n super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n // Important: getCertificates is only available in AdminConnection\n const certificates = await this.props.oContext.socket.getCertificates();\n\n const selectOptions: { label: string; value: string }[] = certificates\n .filter(el => {\n const name = this.props.attr.toLowerCase();\n\n if (name.includes(el.type)) {\n return true;\n }\n if (el.type === 'public' && name.includes('cert')) {\n return true;\n }\n if (el.type === 'private' && (name.includes('priv') || name.includes('key'))) {\n return true;\n }\n return !!(el.type === 'chained' && (name.includes('chain') || name.includes('ca')));\n })\n .map(el => ({ label: el.name, value: el.name }));\n\n selectOptions.unshift({ label: I18n.t(ConfigGeneric.NONE_LABEL), value: ConfigGeneric.NONE_VALUE });\n\n this.setState({ value, selectOptions });\n }\n\n renderItem(error: unknown, disabled: boolean /* , defaultValue */): JSX.Element | null {\n if (!this.state.selectOptions) {\n return null;\n }\n\n const item = this.state.selectOptions?.find(_item => _item.value === this.state.value);\n\n return (\n <FormControl\n style={{ width: '100%' }}\n variant=\"standard\"\n >\n {this.props.schema.label ? (\n <InputLabel shrink>{this.getText(this.props.schema.label)}</InputLabel>\n ) : null}\n <Select\n variant=\"standard\"\n error={!!error}\n displayEmpty\n disabled={!!disabled}\n value={this.state.value}\n renderValue={() => this.getText(item?.label, this.props.schema.noTranslation !== false)}\n onChange={e =>\n this.setState({ value: e.target.value }, () => this.onChange(this.props.attr, this.state.value))\n }\n >\n {this.state.selectOptions?.map(item_ => (\n <MenuItem\n key={item_.value}\n value={item_.value}\n style={item_.value === ConfigGeneric.NONE_VALUE ? { opacity: 0.5 } : {}}\n >\n {this.getText(item_.label, this.props.schema.noTranslation !== false)}\n </MenuItem>\n ))}\n </Select>\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}"]}
1
+ {"version":3,"file":"ConfigCertificateSelect.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigCertificateSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAUlG,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,aAGpD;IACG,KAAK,CAAC,iBAAiB;QACnB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvE,kEAAkE;QAClE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;QAExE,MAAM,aAAa,GAAuC,YAAY;aACjE,MAAM,CAAC,EAAE,CAAC,EAAE;YACT,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAE3C,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC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AK,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,KAAK,KAAK,CAAC,CAC9D,CACd,CAAC,CACG;YACR,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,oBAAC,cAAc,QACV,IAAI,CAAC,UAAU,CACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACY,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { InputLabel, MenuItem, FormControl, Select, FormHelperText } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemCertificateSelect } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface ConfigCertificateSelectProps extends ConfigGenericProps {\n schema: ConfigItemCertificateSelect;\n}\n\ninterface ConfigCertificateSelectState extends ConfigGenericState {\n selectOptions?: { label: string; value: string }[];\n}\n\nexport default class ConfigCertificateSelect extends ConfigGeneric<\n ConfigCertificateSelectProps,\n ConfigCertificateSelectState\n> {\n async componentDidMount(): Promise<void> {\n super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n // Important: getCertificates is only available in AdminConnection\n const certificates = await this.props.oContext.socket.getCertificates();\n\n const selectOptions: { label: string; value: string }[] = certificates\n .filter(el => {\n const name = this.props.attr.toLowerCase();\n\n if (name.includes(el.type)) {\n return true;\n }\n if (el.type === 'public' && name.includes('cert')) {\n return true;\n }\n if (el.type === 'private' && (name.includes('priv') || name.includes('key'))) {\n return true;\n }\n return !!(el.type === 'chained' && (name.includes('chain') || name.includes('ca')));\n })\n .map(el => ({ label: el.name, value: el.name }));\n\n selectOptions.unshift({ label: I18n.t(ConfigGeneric.NONE_LABEL), value: ConfigGeneric.NONE_VALUE });\n\n this.setState({ value, selectOptions });\n }\n\n renderItem(error: unknown, disabled: boolean /* , defaultValue */): JSX.Element | null {\n if (!this.state.selectOptions) {\n return null;\n }\n\n const item = this.state.selectOptions?.find(_item => _item.value === this.state.value);\n\n return (\n <FormControl\n style={{ width: '100%' }}\n variant=\"standard\"\n >\n {this.props.schema.label ? (\n <InputLabel shrink>{this.getText(this.props.schema.label)}</InputLabel>\n ) : null}\n <Select\n variant=\"standard\"\n error={!!error}\n displayEmpty\n disabled={!!disabled}\n value={this.state.value}\n renderValue={() => this.getText(item?.label, this.props.schema.noTranslation !== false)}\n onChange={e =>\n this.setState({ value: e.target.value }, () => this.onChange(this.props.attr, this.state.value))\n }\n >\n {this.state.selectOptions?.map(item_ => (\n <MenuItem\n key={item_.value}\n value={item_.value}\n style={item_.value === ConfigGeneric.NONE_VALUE ? { opacity: 0.5 } : {}}\n >\n {this.getText(item_.label, this.props.schema.noTranslation !== false)}\n </MenuItem>\n ))}\n </Select>\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigInterface.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigInterface.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGrG,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAmBlG,MAAM,MAAM,GAAwC;IAChD,OAAO,EAAE;QACL,QAAQ,EAAE,SAAS;QACnB,OAAO,EAAE,GAAG;QACZ,UAAU,EAAE,CAAC;KAChB;CACJ,CAAC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AI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACY,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ;AAED,eAAe,eAAe,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { InputLabel, TextField, FormHelperText, MenuItem, FormControl, Select } from '@mui/material';\n\nimport type { ConfigItemInterface } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface NetworkInterfaceBase {\n address: string;\n netmask: string;\n mac: string;\n internal: boolean;\n cidr: string | null;\n}\ninterface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {\n family: 'IPv4';\n scopeid?: undefined;\n}\ninterface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {\n family: 'IPv6';\n scopeid: number;\n}\ntype NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;\n\nconst styles: Record<string, React.CSSProperties> = {\n address: {\n fontSize: 'smaller',\n opacity: 0.5,\n marginLeft: 8,\n },\n};\n\ninterface ConfigInterfaceProps extends ConfigGenericProps {\n schema: ConfigItemInterface;\n}\n\ninterface ConfigInterfaceState extends ConfigGenericState {\n interfaces?: { value: string; address: string }[];\n}\n\nclass ConfigInterface extends ConfigGeneric<ConfigInterfaceProps, ConfigInterfaceState> {\n componentDidMount(): void {\n super.componentDidMount();\n this.props.oContext.socket\n .getObject(`system.host.${this.props.common.host}`)\n .then(obj => {\n const interfaces: { value: string; address: string }[] = [];\n if (obj?.native?.hardware?.networkInterfaces) {\n const list = obj.native.hardware.networkInterfaces;\n Object.keys(list).forEach(inter => {\n if (this.props.schema.ignoreInternal && !list[inter].find(_ip => !_ip.internal)) {\n return;\n }\n if (\n this.props.schema.ignoreLoopback &&\n list[inter].find(_ip => _ip.address === '127.0.0.1' || _ip.address === '::1')\n ) {\n return;\n }\n\n // find ipv4 address\n let ip: NetworkInterfaceInfo = list[inter].find(_ip => _ip.family === 'IPv4') as NetworkInterfaceInfo;\n ip ||= list[inter].find(_ip => _ip.family === 'IPv6');\n interfaces.push({ value: inter, address: ip.address });\n });\n }\n\n this.setState({ interfaces });\n })\n .catch(e => window.alert(`Cannot read interfaces: ${e}`));\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n const item = this.state.interfaces?.find(it => it.value === value);\n\n return (\n <FormControl\n fullWidth\n variant=\"standard\"\n >\n {this.state.interfaces?.length && this.props.schema.label ? (\n <InputLabel>{this.getText(this.props.schema.label)}</InputLabel>\n ) : null}\n {!this.state.interfaces?.length ? (\n <TextField\n fullWidth\n variant=\"standard\"\n error={!!error}\n disabled={!!disabled}\n value={value}\n onChange={e => this.onChange(this.props.attr, e.target.value)}\n label={this.getText(this.props.schema.label)}\n />\n ) : (\n <Select\n variant=\"standard\"\n error={!!error}\n disabled={!!disabled}\n value={value}\n renderValue={val => {\n if (item) {\n return (\n <span>\n {item.value}\n <span style={styles.address}>{item.address}</span>\n </span>\n );\n }\n return val;\n }}\n onChange={e => this.onChange(this.props.attr, e.target.value)}\n >\n {this.state.interfaces.map((it, i) => (\n <MenuItem\n key={i}\n value={it.value}\n >\n <span>\n {it.value}\n <span style={styles.address}>{it.address}</span>\n </span>\n </MenuItem>\n ))}\n </Select>\n )}\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}\n\nexport default ConfigInterface;\n"]}
1
+ {"version":3,"file":"ConfigInterface.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigInterface.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,E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,OAAO,IAAG,EAAE,CAAC,OAAO,CAAQ,CAC7C,CACA,CACd,CAAC,CACG,CACZ;YACA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,oBAAC,cAAc,QACV,IAAI,CAAC,UAAU,CACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACY,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ;AAED,eAAe,eAAe,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { InputLabel, TextField, FormHelperText, MenuItem, FormControl, Select } from '@mui/material';\n\nimport type { ConfigItemInterface } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface NetworkInterfaceBase {\n address: string;\n netmask: string;\n mac: string;\n internal: boolean;\n cidr: string | null;\n}\ninterface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {\n family: 'IPv4';\n scopeid?: undefined;\n}\ninterface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {\n family: 'IPv6';\n scopeid: number;\n}\ntype NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;\n\nconst styles: Record<string, React.CSSProperties> = {\n address: {\n fontSize: 'smaller',\n opacity: 0.5,\n marginLeft: 8,\n },\n};\n\ninterface ConfigInterfaceProps extends ConfigGenericProps {\n schema: ConfigItemInterface;\n}\n\ninterface ConfigInterfaceState extends ConfigGenericState {\n interfaces?: { value: string; address: string }[];\n}\n\nclass ConfigInterface extends ConfigGeneric<ConfigInterfaceProps, ConfigInterfaceState> {\n componentDidMount(): void {\n super.componentDidMount();\n this.props.oContext.socket\n .getObject(`system.host.${this.props.common.host}`)\n .then(obj => {\n const interfaces: { value: string; address: string }[] = [];\n if (obj?.native?.hardware?.networkInterfaces) {\n const list = obj.native.hardware.networkInterfaces;\n Object.keys(list).forEach(inter => {\n if (this.props.schema.ignoreInternal && !list[inter].find(_ip => !_ip.internal)) {\n return;\n }\n if (\n this.props.schema.ignoreLoopback &&\n list[inter].find(_ip => _ip.address === '127.0.0.1' || _ip.address === '::1')\n ) {\n return;\n }\n\n // find ipv4 address\n let ip: NetworkInterfaceInfo = list[inter].find(\n _ip => _ip.family === 'IPv4',\n ) as NetworkInterfaceInfo;\n ip ||= list[inter].find(_ip => _ip.family === 'IPv6');\n interfaces.push({ value: inter, address: ip.address });\n });\n }\n\n this.setState({ interfaces });\n })\n .catch(e => window.alert(`Cannot read interfaces: ${e}`));\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n const item = this.state.interfaces?.find(it => it.value === value);\n\n return (\n <FormControl\n fullWidth\n variant=\"standard\"\n >\n {this.state.interfaces?.length && this.props.schema.label ? (\n <InputLabel>{this.getText(this.props.schema.label)}</InputLabel>\n ) : null}\n {!this.state.interfaces?.length ? (\n <TextField\n fullWidth\n variant=\"standard\"\n error={!!error}\n disabled={!!disabled}\n value={value}\n onChange={e => this.onChange(this.props.attr, e.target.value)}\n label={this.getText(this.props.schema.label)}\n />\n ) : (\n <Select\n variant=\"standard\"\n error={!!error}\n disabled={!!disabled}\n value={value}\n renderValue={val => {\n if (item) {\n return (\n <span>\n {item.value}\n <span style={styles.address}>{item.address}</span>\n </span>\n );\n }\n return val;\n }}\n onChange={e => this.onChange(this.props.attr, e.target.value)}\n >\n {this.state.interfaces.map((it, i) => (\n <MenuItem\n key={i}\n value={it.value}\n >\n <span>\n {it.value}\n <span style={styles.address}>{it.address}</span>\n </span>\n </MenuItem>\n ))}\n </Select>\n )}\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}\n\nexport default ConfigInterface;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"./src/","sources":["JsonConfigComponent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAwB,IAAI,EAAiD,MAAM,4BAA4B,CAAC;AAMvH,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,GAAwC;IAChD,IAAI,EAAE;QACF,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACjB;CACJ,CAAC;AA4CF,MAAM,OAAO,mBAAoB,SAAQ,SAA6D;IACjF,mBAAmB,CAAsC;IAElE,YAAY,GAAyC,IAAI,CAAC;IAE1D,WAAW,GAAkC,IAAI,CAAC;IAElD,QAAQ,CAAoB;IAEpC,YAAY,KAA+B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG;YACT,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YAC7C,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC;YACtC,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,KAAK;YACZ,cAAc,EAAE,KAAK;YACrB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SACxD,CAAC;QAEF,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;QAE9B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;Q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CAAC,MAAM,CAAC,CACjC,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["import React, { Component, type JSX } from 'react';\n\nimport { LinearProgress } from '@mui/material';\n\nimport { type AdminConnection, I18n, type ThemeName, type ThemeType, type IobTheme } from '@iobroker/adapter-react-v5';\n\nimport type { BackEndCommand, ConfigItemPanel, ConfigItemTabs, JsonConfigContext } from '../types';\nimport type ConfigGeneric from './ConfigGeneric';\n// eslint-disable-next-line no-duplicate-imports\nimport { type DeviceManagerPropsProps } from './ConfigGeneric';\nimport ConfigTabs from './ConfigTabs';\nimport ConfigPanel from './ConfigPanel';\n\nconst styles: Record<string, React.CSSProperties> = {\n root: {\n width: '100%',\n height: '100%',\n },\n};\n\ninterface JsonConfigComponentProps {\n socket: AdminConnection;\n themeName: ThemeName;\n themeType: ThemeType;\n adapterName: string;\n instance: number;\n isFloatComma: boolean;\n dateFormat: string;\n imagePrefix?: string;\n schema: ConfigItemTabs | ConfigItemPanel;\n common?: Record<string, any>;\n data: Record<string, any>;\n updateData?: number;\n onError: (error: boolean) => void;\n onChange?: (data: Record<string, any>, changed: boolean, saveConfig: boolean) => void;\n /** Backend request to refresh data */\n onBackEndCommand?: (command?: BackEndCommand) => void;\n custom?: boolean;\n onValueChange?: (attr: string, value: any, saveConfig: boolean) => void;\n embedded?: boolean;\n multiEdit?: boolean;\n instanceObj?: ioBroker.InstanceObject;\n customObj?: ioBroker.Object;\n customs?: Record<string, typeof ConfigGeneric>;\n DeviceManager?: React.FC<DeviceManagerPropsProps>;\n style?: React.CSSProperties;\n theme: IobTheme;\n expertMode?: boolean;\n withoutSaveButtons?: boolean;\n}\n\ninterface JsonConfigComponentState {\n originalData: string;\n changed: boolean;\n errors: Record<string, string>;\n systemConfig: ioBroker.SystemConfigCommon | null;\n updateData?: number;\n alive: boolean;\n commandRunning: boolean;\n schema: ConfigItemTabs | ConfigItemPanel;\n}\n\nexport class JsonConfigComponent extends Component<JsonConfigComponentProps, JsonConfigComponentState> {\n private readonly forceUpdateHandlers: Record<string, (data: any) => void>;\n\n private errorTimeout: ReturnType<typeof setTimeout> | null = null;\n\n private errorCached: Record<string, string> | null = null;\n\n private oContext: JsonConfigContext;\n\n constructor(props: JsonConfigComponentProps) {\n super(props);\n\n this.state = {\n originalData: JSON.stringify(this.props.data),\n changed: false,\n errors: {},\n updateData: this.props.updateData || 0,\n systemConfig: null,\n alive: false,\n commandRunning: false,\n schema: JSON.parse(JSON.stringify(this.props.schema)),\n };\n\n this.forceUpdateHandlers = {};\n\n this.buildDependencies(this.state.schema);\n\n this.readData();\n }\n\n static getDerivedStateFromProps(\n props: JsonConfigComponentProps,\n state: JsonConfigComponentState,\n ): Partial<JsonConfigComponentState> | null {\n if (props.updateData !== state.updateData) {\n return {\n updateData: props.updateData,\n originalData: JSON.stringify(props.data),\n schema: JSON.parse(JSON.stringify(props.schema)),\n };\n }\n return null;\n }\n\n static async loadI18n(\n socket: AdminConnection,\n i18n: boolean | string | Record<string, Record<ioBroker.Languages, string>>,\n adapterName: string,\n ): Promise<string> {\n if (i18n === true || (i18n && typeof i18n === 'string')) {\n const lang = I18n.getLanguage();\n const path = typeof i18n === 'string' ? i18n : 'i18n';\n let exists = await socket.fileExists(`${adapterName}.admin`, `${path}/${lang}.json`);\n let fileName;\n if (exists) {\n fileName = `${path}/${lang}.json`;\n } else {\n exists = await socket.fileExists(`${adapterName}.admin`, `${path}/${lang}/translations.json`);\n if (exists) {\n fileName = `${path}/${lang}/translations.json`;\n } else if (lang !== 'en') {\n // fallback to english\n exists = await socket.fileExists(`${adapterName}.admin`, `${path}/en.json`);\n if (exists) {\n fileName = `${path}/en.json`;\n } else {\n exists = await socket.fileExists(`${adapterName}.admin`, `${path}/en/translations.json`);\n if (exists) {\n fileName = `${path}/en/translations.json`;\n }\n }\n }\n }\n\n if (fileName) {\n const jsonFile = await socket.readFile(`${adapterName}.admin`, fileName);\n let jsonStr: string;\n if (jsonFile.file !== undefined) {\n jsonStr = jsonFile.file;\n } else {\n // @ts-expect-error deprecated\n jsonStr = jsonFile;\n }\n\n try {\n const json = JSON.parse(jsonStr);\n // apply file to I18n\n I18n.extendTranslations(json, lang);\n } catch (e) {\n console.error(`Cannot parse language file \"${adapterName}.admin/${fileName}: ${e}`);\n return '';\n }\n return fileName;\n }\n console.warn(`Cannot find i18n for ${adapterName} / ${fileName}`);\n return '';\n }\n if (i18n && typeof i18n === 'object') {\n I18n.extendTranslations(i18n);\n return '';\n }\n return '';\n }\n\n onCommandRunning = (commandRunning: boolean): void => this.setState({ commandRunning });\n\n readData(): void {\n void this.props.socket\n .getCompactSystemConfig()\n .then(systemConfig =>\n this.props.socket\n .getState(`system.adapter.${this.props.adapterName}.${this.props.instance}.alive`)\n .then(state =>\n this.setState({ systemConfig: systemConfig.common, alive: !!(state && state.val) }, () => {\n this.updateContext(true);\n if (!this.props.custom) {\n void this.props.socket.subscribeState(\n `system.adapter.${this.props.adapterName}.${this.props.instance}.alive`,\n this.onAlive,\n );\n }\n }),\n ),\n )\n .catch(e => console.error(`Cannot read system config: ${e}`));\n }\n\n onAlive = (_id: string, state?: ioBroker.State | null): void => {\n if (!!state?.val !== this.state.alive) {\n this.setState({ alive: !!state?.val });\n }\n };\n\n onChange = (attrOrData: string | Record<string, any>, value: any, cb?: () => void, saveConfig?: boolean): void => {\n if (this.props.onValueChange) {\n this.props.onValueChange(attrOrData as string, value, saveConfig);\n if (cb) {\n cb();\n }\n } else if (attrOrData && this.props.onChange) {\n const newState: Partial<JsonConfigComponentState> = {\n changed: JSON.stringify(attrOrData) !== this.state.originalData,\n };\n\n this.setState(newState as JsonConfigComponentState, () => {\n this.props.onChange(attrOrData as Record<string, any>, newState.changed, saveConfig);\n if (cb) {\n cb();\n }\n });\n } else if (saveConfig) {\n this.props.onChange(null, null, saveConfig);\n }\n };\n\n onError = (attr: string, error?: string): void => {\n this.errorCached = this.errorCached || JSON.parse(JSON.stringify(this.state.errors));\n const errors = this.errorCached;\n if (error) {\n errors[attr] = error;\n } else {\n delete errors[attr];\n }\n\n if (this.errorTimeout) {\n clearTimeout(this.errorTimeout);\n }\n if (JSON.stringify(errors) !== JSON.stringify(this.state.errors)) {\n this.errorTimeout = setTimeout(\n () =>\n this.setState({ errors: this.errorCached }, () => {\n this.errorTimeout = null;\n this.errorCached = null;\n this.props.onError(!!Object.keys(this.state.errors).length);\n }),\n 50,\n );\n } else {\n this.errorCached = null;\n }\n };\n\n flatten(schema: Record<string, any>, _list?: Record<string, any>): Record<string, any> {\n _list = _list || {};\n if (schema.items) {\n Object.keys(schema.items).forEach(attr => {\n _list[attr] = schema.items[attr];\n this.flatten(schema.items[attr], _list);\n });\n }\n\n return _list;\n }\n\n buildDependencies(schema: ConfigItemTabs | ConfigItemPanel): void {\n const attrs = this.flatten(schema as Record<string, any>);\n Object.keys(attrs).forEach(attr => {\n if (attrs[attr].confirm?.alsoDependsOn) {\n attrs[attr].confirm?.alsoDependsOn.forEach((dep: string) => {\n if (!attrs[dep]) {\n console.error(`[JsonConfigComponent] Attribute ${dep} does not exist!`);\n if (dep.startsWith('data.')) {\n console.warn(\n `[JsonConfigComponent] please use \"${dep.replace(/^data\\./, '')}\" instead of \"${dep}\"`,\n );\n }\n } else {\n attrs[dep].confirmDependsOn = attrs[dep].confirmDependsOn || [];\n\n const depObj = { ...attrs[attr], attr };\n if (depObj.confirm) {\n depObj.confirm.cancel = 'Undo';\n }\n\n attrs[dep].confirmDependsOn.push(depObj);\n }\n });\n }\n\n if (attrs[attr].onChange?.alsoDependsOn) {\n attrs[attr].onChange?.alsoDependsOn.forEach((dep: string) => {\n if (!attrs[dep]) {\n console.error(`[JsonConfigComponent] Attribute ${dep} does not exist!`);\n if (dep.startsWith('data.')) {\n console.warn(\n `[JsonConfigComponent] please use \"${dep.replace(/^data\\./, '')}\" instead of \"${dep}\"`,\n );\n }\n } else {\n attrs[dep].onChangeDependsOn = attrs[dep].onChangeDependsOn || [];\n\n const depObj = { ...attrs[attr], attr };\n\n attrs[dep].onChangeDependsOn.push(depObj);\n }\n });\n }\n\n if (attrs[attr].hidden?.alsoDependsOn) {\n attrs[attr].hidden?.alsoDependsOn.forEach((dep: string) => {\n if (!attrs[dep]) {\n console.error(`[JsonConfigComponent] Attribute ${dep} does not exist!`);\n if (dep.startsWith('data.')) {\n console.warn(\n `[JsonConfigComponent] please use \"${dep.replace(/^data\\./, '')}\" instead of \"${dep}\"`,\n );\n }\n } else {\n attrs[dep].hiddenDependsOn = attrs[dep].hiddenDependsOn || [];\n\n const depObj = { ...attrs[attr], attr };\n\n attrs[dep].hiddenDependsOn.push(depObj);\n }\n });\n }\n\n if (attrs[attr].label?.alsoDependsOn) {\n attrs[attr].label?.alsoDependsOn.forEach((dep: string) => {\n if (!attrs[dep]) {\n console.error(`[JsonConfigComponent] Attribute ${dep} does not exist!`);\n if (dep.startsWith('data.')) {\n console.warn(\n `[JsonConfigComponent] please use \"${dep.replace(/^data\\./, '')}\" instead of \"${dep}\"`,\n );\n }\n } else {\n attrs[dep].labelDependsOn = attrs[dep].labelDependsOn || [];\n\n const depObj = { ...attrs[attr], attr };\n\n attrs[dep].labelDependsOn.push(depObj);\n }\n });\n }\n\n if (attrs[attr].help?.alsoDependsOn) {\n attrs[attr].help?.alsoDependsOn.forEach((dep: string) => {\n if (!attrs[dep]) {\n console.error(`[JsonConfigComponent] Attribute ${dep} does not exist!`);\n if (dep.startsWith('data.')) {\n console.warn(\n `[JsonConfigComponent] please use \"${dep.replace(/^data\\./, '')}\" instead of \"${dep}\"`,\n );\n }\n } else {\n attrs[dep].helpDependsOn = attrs[dep].helpDependsOn || [];\n\n const depObj = { ...attrs[attr], attr };\n\n attrs[dep].helpDependsOn.push(depObj);\n }\n });\n }\n });\n }\n\n updateContext(forceUpdate?: boolean): void {\n this.oContext = {\n DeviceManager: this.props.DeviceManager,\n adapterName: this.props.adapterName,\n changeLanguage: this.changeLanguage,\n common: this.props.common,\n customs: this.props.customs,\n dateFormat: this.props.dateFormat,\n embedded: this.props.embedded,\n forceUpdate: this.forceAttrUpdate,\n imagePrefix: this.props.imagePrefix,\n instance: this.props.instance,\n instanceObj: this.props.instanceObj,\n isFloatComma: this.props.isFloatComma,\n multiEdit: this.props.multiEdit,\n onBackEndCommand: this.props.onBackEndCommand,\n onCommandRunning: this.onCommandRunning,\n onValueChange: this.props.onValueChange,\n registerOnForceUpdate: this.registerOnForceUpdate,\n socket: this.props.socket,\n systemConfig: this.state.systemConfig,\n theme: this.props.theme,\n // could be changed dynamically\n themeType: this.props.themeType,\n _themeName: this.props.themeName,\n updateData: this.state.updateData,\n } as JsonConfigContext;\n\n if (forceUpdate) {\n this.forceUpdate();\n }\n }\n\n renderItem(item: ConfigItemTabs | ConfigItemPanel): JSX.Element | null {\n if (item.type === 'tabs') {\n return (\n <ConfigTabs\n withoutSaveButtons={this.props.withoutSaveButtons}\n oContext={this.oContext}\n alive={this.state.alive}\n changed={this.state.changed}\n commandRunning={this.state.commandRunning}\n common={this.props.common}\n custom={this.props.custom}\n customObj={this.props.customObj}\n data={this.props.data}\n onChange={this.onChange}\n onError={(attr, error) => this.onError(attr, error)}\n originalData={JSON.parse(this.state.originalData)}\n root\n schema={item}\n expertMode={this.props.expertMode}\n themeName={this.props.themeName}\n />\n );\n }\n if (\n item.type === 'panel' ||\n // @ts-expect-error type could be empty\n !item.type\n ) {\n return (\n <ConfigPanel\n withoutSaveButtons={this.props.withoutSaveButtons}\n oContext={this.oContext}\n alive={this.state.alive}\n changed={this.state.changed}\n commandRunning={this.state.commandRunning}\n common={this.props.common}\n custom={this.props.custom}\n customObj={this.props.customObj}\n data={this.props.data}\n expertMode={this.props.expertMode}\n index={1000}\n isParentTab={!this.props.embedded && !this.props.withoutSaveButtons}\n onChange={this.onChange}\n onError={(attr, error) => this.onError(attr, error)}\n originalData={JSON.parse(this.state.originalData)}\n root\n schema={item}\n themeName={this.props.themeName}\n />\n );\n }\n console.error(`Unknown item type in root: ${JSON.stringify(item)}`);\n\n return null;\n }\n\n changeLanguage = (): void => {\n this.forceUpdate();\n };\n\n forceAttrUpdate = (attr: string | string[], data: any): void => {\n if (Array.isArray(attr)) {\n attr.forEach(a => this.forceUpdateHandlers[a] && this.forceUpdateHandlers[a](data));\n } else if (this.forceUpdateHandlers[attr]) {\n this.forceUpdateHandlers[attr](data);\n }\n };\n\n registerOnForceUpdate = (attr: string, cb?: ((data: any) => void) | null): void => {\n if (cb) {\n this.forceUpdateHandlers[attr] = cb;\n } else if (this.forceUpdateHandlers[attr]) {\n delete this.forceUpdateHandlers[attr];\n }\n };\n\n render(): JSX.Element {\n if (!this.state.systemConfig || !this.oContext) {\n return <LinearProgress />;\n }\n\n if (this.oContext._themeName !== this.props.themeName) {\n this.oContext._themeName = this.props.themeName;\n setTimeout(() => this.updateContext(true), 0);\n }\n\n return (\n <div\n style={{\n ...(!this.props.embedded || this.props.withoutSaveButtons ? styles.root : undefined),\n ...this.props.style,\n ...this.state.schema.style,\n }}\n >\n {this.renderItem(this.state.schema)}\n </div>\n );\n }\n}\n\nexport default JsonConfigComponent;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"./src/","sources":["JsonConfigComponent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAwB,IAAI,EAAiD,MAAM,4BAA4B,CAAC;AAKvH,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,GAAwC;IAChD,IAAI,EAAE;QACF,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACjB;CACJ,CAAC;AA4CF,MAAM,OAAO,mBAAoB,SAAQ,SAA6D;IACjF,mBAAmB,CAAsC;IAElE,YAAY,GAAyC,IAAI,CAAC;IAE1D,WAAW,GAAkC,IAAI,CAAC;IAElD,QAAQ,CAAoB;IAEpC,YAAY,KAA+B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KAAK,CAAC,SAAS,EAAE,CAAC;YACpD,IAAI,CAAC,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;YAChD,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,CACH,6BACI,KAAK,EAAE;gBACH,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpF,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;gBACnB,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;aAC7B,IAEA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CACjC,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["import React, { Component, type JSX } from 'react';\n\nimport { LinearProgress } from '@mui/material';\n\nimport { type AdminConnection, I18n, type ThemeName, type ThemeType, type IobTheme } from '@iobroker/adapter-react-v5';\n\nimport type { BackEndCommand, ConfigItemPanel, ConfigItemTabs, JsonConfigContext } from '../types';\nimport type ConfigGeneric from './ConfigGeneric';\nimport { type DeviceManagerPropsProps } from './ConfigGeneric';\nimport ConfigTabs from './ConfigTabs';\nimport ConfigPanel from './ConfigPanel';\n\nconst styles: Record<string, React.CSSProperties> = {\n root: {\n width: '100%',\n height: '100%',\n },\n};\n\ninterface JsonConfigComponentProps {\n socket: AdminConnection;\n themeName: ThemeName;\n themeType: ThemeType;\n adapterName: string;\n instance: number;\n isFloatComma: boolean;\n dateFormat: string;\n imagePrefix?: string;\n schema: ConfigItemTabs | ConfigItemPanel;\n common?: Record<string, any>;\n data: Record<string, any>;\n updateData?: number;\n onError: (error: boolean) => void;\n onChange?: (data: Record<string, any>, changed: boolean, saveConfig: boolean) => void;\n /** Backend request to refresh data */\n onBackEndCommand?: (command?: BackEndCommand) => void;\n custom?: boolean;\n onValueChange?: (attr: string, value: any, saveConfig: boolean) => void;\n embedded?: boolean;\n multiEdit?: boolean;\n instanceObj?: ioBroker.InstanceObject;\n customObj?: ioBroker.Object;\n customs?: Record<string, typeof ConfigGeneric>;\n DeviceManager?: React.FC<DeviceManagerPropsProps>;\n style?: React.CSSProperties;\n theme: IobTheme;\n expertMode?: boolean;\n withoutSaveButtons?: boolean;\n}\n\ninterface JsonConfigComponentState {\n originalData: string;\n changed: boolean;\n errors: Record<string, string>;\n systemConfig: ioBroker.SystemConfigCommon | null;\n updateData?: number;\n alive: boolean;\n commandRunning: boolean;\n schema: ConfigItemTabs | ConfigItemPanel;\n}\n\nexport class JsonConfigComponent extends Component<JsonConfigComponentProps, JsonConfigComponentState> {\n private readonly forceUpdateHandlers: Record<string, (data: any) => void>;\n\n private errorTimeout: ReturnType<typeof setTimeout> | null = null;\n\n private errorCached: Record<string, string> | null = null;\n\n private oContext: JsonConfigContext;\n\n constructor(props: JsonConfigComponentProps) {\n super(props);\n\n this.state = {\n originalData: JSON.stringify(this.props.data),\n changed: false,\n errors: {},\n updateData: this.props.updateData || 0,\n systemConfig: null,\n alive: false,\n commandRunning: false,\n schema: JSON.parse(JSON.stringify(this.props.schema)),\n };\n\n this.forceUpdateHandlers = {};\n\n this.buildDependencies(this.state.schema);\n\n this.readData();\n }\n\n static getDerivedStateFromProps(\n props: JsonConfigComponentProps,\n state: JsonConfigComponentState,\n ): Partial<JsonConfigComponentState> | null {\n if (props.updateData !== state.updateData) {\n return {\n updateData: props.updateData,\n originalData: JSON.stringify(props.data),\n schema: JSON.parse(JSON.stringify(props.schema)),\n };\n }\n return null;\n }\n\n static async loadI18n(\n socket: AdminConnection,\n i18n: boolean | string | Record<string, Record<ioBroker.Languages, string>>,\n adapterName: string,\n ): Promise<string> {\n if (i18n === true || (i18n && typeof i18n === 'string')) {\n const lang = I18n.getLanguage();\n const path = typeof i18n === 'string' ? i18n : 'i18n';\n let exists = await socket.fileExists(`${adapterName}.admin`, `${path}/${lang}.json`);\n let fileName;\n if (exists) {\n fileName = `${path}/${lang}.json`;\n } else {\n exists = await socket.fileExists(`${adapterName}.admin`, `${path}/${lang}/translations.json`);\n if (exists) {\n fileName = `${path}/${lang}/translations.json`;\n } else if (lang !== 'en') {\n // fallback to english\n exists = await socket.fileExists(`${adapterName}.admin`, `${path}/en.json`);\n if (exists) {\n fileName = `${path}/en.json`;\n } else {\n exists = await socket.fileExists(`${adapterName}.admin`, `${path}/en/translations.json`);\n if (exists) {\n fileName = `${path}/en/translations.json`;\n }\n }\n }\n }\n\n if (fileName) {\n const jsonFile = await socket.readFile(`${adapterName}.admin`, fileName);\n let jsonStr: string;\n if (jsonFile.file !== undefined) {\n jsonStr = jsonFile.file;\n } else {\n // @ts-expect-error deprecated\n jsonStr = jsonFile;\n }\n\n try {\n const json = JSON.parse(jsonStr);\n // apply file to I18n\n I18n.extendTranslations(json, lang);\n } catch (e) {\n console.error(`Cannot parse language file \"${adapterName}.admin/${fileName}: ${e}`);\n return '';\n }\n return fileName;\n }\n console.warn(`Cannot find i18n for ${adapterName} / ${fileName}`);\n return '';\n }\n if (i18n && typeof i18n === 'object') {\n I18n.extendTranslations(i18n);\n return '';\n }\n return '';\n }\n\n onCommandRunning = (commandRunning: boolean): void => this.setState({ commandRunning });\n\n readData(): void {\n void this.props.socket\n .getCompactSystemConfig()\n .then(systemConfig =>\n this.props.socket\n .getState(`system.adapter.${this.props.adapterName}.${this.props.instance}.alive`)\n .then(state =>\n this.setState({ systemConfig: systemConfig.common, alive: !!(state && state.val) }, () => {\n this.updateContext(true);\n if (!this.props.custom) {\n void this.props.socket.subscribeState(\n `system.adapter.${this.props.adapterName}.${this.props.instance}.alive`,\n this.onAlive,\n );\n }\n }),\n ),\n )\n .catch(e => console.error(`Cannot read system config: ${e}`));\n }\n\n onAlive = (_id: string, state?: ioBroker.State | null): void => {\n if (!!state?.val !== this.state.alive) {\n this.setState({ alive: !!state?.val });\n }\n };\n\n onChange = (attrOrData: string | Record<string, any>, value: any, cb?: () => void, saveConfig?: boolean): void => {\n if (this.props.onValueChange) {\n this.props.onValueChange(attrOrData as string, value, saveConfig);\n if (cb) {\n cb();\n }\n } else if (attrOrData && this.props.onChange) {\n const newState: Partial<JsonConfigComponentState> = {\n changed: JSON.stringify(attrOrData) !== this.state.originalData,\n };\n\n this.setState(newState as JsonConfigComponentState, () => {\n this.props.onChange(attrOrData as Record<string, any>, newState.changed, saveConfig);\n if (cb) {\n cb();\n }\n });\n } else if (saveConfig) {\n this.props.onChange(null, null, saveConfig);\n }\n };\n\n onError = (attr: string, error?: string): void => {\n this.errorCached = this.errorCached || JSON.parse(JSON.stringify(this.state.errors));\n const errors = this.errorCached;\n if (error) {\n errors[attr] = error;\n } else {\n delete errors[attr];\n }\n\n if (this.errorTimeout) {\n clearTimeout(this.errorTimeout);\n }\n if (JSON.stringify(errors) !== JSON.stringify(this.state.errors)) {\n this.errorTimeout = setTimeout(\n () =>\n this.setState({ errors: this.errorCached }, () => {\n this.errorTimeout = null;\n this.errorCached = null;\n this.props.onError(!!Object.keys(this.state.errors).length);\n }),\n 50,\n );\n } else {\n this.errorCached = null;\n }\n };\n\n flatten(schema: Record<string, any>, _list?: Record<string, any>): Record<string, any> {\n _list = _list || {};\n if (schema.items) {\n Object.keys(schema.items).forEach(attr => {\n _list[attr] = schema.items[attr];\n this.flatten(schema.items[attr], _list);\n });\n }\n\n return _list;\n }\n\n buildDependencies(schema: ConfigItemTabs | ConfigItemPanel): void {\n const attrs = this.flatten(schema as Record<string, any>);\n Object.keys(attrs).forEach(attr => {\n if (attrs[attr].confirm?.alsoDependsOn) {\n attrs[attr].confirm?.alsoDependsOn.forEach((dep: string) => {\n if (!attrs[dep]) {\n console.error(`[JsonConfigComponent] Attribute ${dep} does not exist!`);\n if (dep.startsWith('data.')) {\n console.warn(\n `[JsonConfigComponent] please use \"${dep.replace(/^data\\./, '')}\" instead of \"${dep}\"`,\n );\n }\n } else {\n attrs[dep].confirmDependsOn = attrs[dep].confirmDependsOn || [];\n\n const depObj = { ...attrs[attr], attr };\n if (depObj.confirm) {\n depObj.confirm.cancel = 'Undo';\n }\n\n attrs[dep].confirmDependsOn.push(depObj);\n }\n });\n }\n\n if (attrs[attr].onChange?.alsoDependsOn) {\n attrs[attr].onChange?.alsoDependsOn.forEach((dep: string) => {\n if (!attrs[dep]) {\n console.error(`[JsonConfigComponent] Attribute ${dep} does not exist!`);\n if (dep.startsWith('data.')) {\n console.warn(\n `[JsonConfigComponent] please use \"${dep.replace(/^data\\./, '')}\" instead of \"${dep}\"`,\n );\n }\n } else {\n attrs[dep].onChangeDependsOn = attrs[dep].onChangeDependsOn || [];\n\n const depObj = { ...attrs[attr], attr };\n\n attrs[dep].onChangeDependsOn.push(depObj);\n }\n });\n }\n\n if (attrs[attr].hidden?.alsoDependsOn) {\n attrs[attr].hidden?.alsoDependsOn.forEach((dep: string) => {\n if (!attrs[dep]) {\n console.error(`[JsonConfigComponent] Attribute ${dep} does not exist!`);\n if (dep.startsWith('data.')) {\n console.warn(\n `[JsonConfigComponent] please use \"${dep.replace(/^data\\./, '')}\" instead of \"${dep}\"`,\n );\n }\n } else {\n attrs[dep].hiddenDependsOn = attrs[dep].hiddenDependsOn || [];\n\n const depObj = { ...attrs[attr], attr };\n\n attrs[dep].hiddenDependsOn.push(depObj);\n }\n });\n }\n\n if (attrs[attr].label?.alsoDependsOn) {\n attrs[attr].label?.alsoDependsOn.forEach((dep: string) => {\n if (!attrs[dep]) {\n console.error(`[JsonConfigComponent] Attribute ${dep} does not exist!`);\n if (dep.startsWith('data.')) {\n console.warn(\n `[JsonConfigComponent] please use \"${dep.replace(/^data\\./, '')}\" instead of \"${dep}\"`,\n );\n }\n } else {\n attrs[dep].labelDependsOn = attrs[dep].labelDependsOn || [];\n\n const depObj = { ...attrs[attr], attr };\n\n attrs[dep].labelDependsOn.push(depObj);\n }\n });\n }\n\n if (attrs[attr].help?.alsoDependsOn) {\n attrs[attr].help?.alsoDependsOn.forEach((dep: string) => {\n if (!attrs[dep]) {\n console.error(`[JsonConfigComponent] Attribute ${dep} does not exist!`);\n if (dep.startsWith('data.')) {\n console.warn(\n `[JsonConfigComponent] please use \"${dep.replace(/^data\\./, '')}\" instead of \"${dep}\"`,\n );\n }\n } else {\n attrs[dep].helpDependsOn = attrs[dep].helpDependsOn || [];\n\n const depObj = { ...attrs[attr], attr };\n\n attrs[dep].helpDependsOn.push(depObj);\n }\n });\n }\n });\n }\n\n updateContext(forceUpdate?: boolean): void {\n this.oContext = {\n DeviceManager: this.props.DeviceManager,\n adapterName: this.props.adapterName,\n changeLanguage: this.changeLanguage,\n common: this.props.common,\n customs: this.props.customs,\n dateFormat: this.props.dateFormat,\n embedded: this.props.embedded,\n forceUpdate: this.forceAttrUpdate,\n imagePrefix: this.props.imagePrefix,\n instance: this.props.instance,\n instanceObj: this.props.instanceObj,\n isFloatComma: this.props.isFloatComma,\n multiEdit: this.props.multiEdit,\n onBackEndCommand: this.props.onBackEndCommand,\n onCommandRunning: this.onCommandRunning,\n onValueChange: this.props.onValueChange,\n registerOnForceUpdate: this.registerOnForceUpdate,\n socket: this.props.socket,\n systemConfig: this.state.systemConfig,\n theme: this.props.theme,\n // could be changed dynamically\n themeType: this.props.themeType,\n _themeName: this.props.themeName,\n updateData: this.state.updateData,\n } as JsonConfigContext;\n\n if (forceUpdate) {\n this.forceUpdate();\n }\n }\n\n renderItem(item: ConfigItemTabs | ConfigItemPanel): JSX.Element | null {\n if (item.type === 'tabs') {\n return (\n <ConfigTabs\n withoutSaveButtons={this.props.withoutSaveButtons}\n oContext={this.oContext}\n alive={this.state.alive}\n changed={this.state.changed}\n commandRunning={this.state.commandRunning}\n common={this.props.common}\n custom={this.props.custom}\n customObj={this.props.customObj}\n data={this.props.data}\n onChange={this.onChange}\n onError={(attr, error) => this.onError(attr, error)}\n originalData={JSON.parse(this.state.originalData)}\n root\n schema={item}\n expertMode={this.props.expertMode}\n themeName={this.props.themeName}\n />\n );\n }\n if (\n item.type === 'panel' ||\n // @ts-expect-error type could be empty\n !item.type\n ) {\n return (\n <ConfigPanel\n withoutSaveButtons={this.props.withoutSaveButtons}\n oContext={this.oContext}\n alive={this.state.alive}\n changed={this.state.changed}\n commandRunning={this.state.commandRunning}\n common={this.props.common}\n custom={this.props.custom}\n customObj={this.props.customObj}\n data={this.props.data}\n expertMode={this.props.expertMode}\n index={1000}\n isParentTab={!this.props.embedded && !this.props.withoutSaveButtons}\n onChange={this.onChange}\n onError={(attr, error) => this.onError(attr, error)}\n originalData={JSON.parse(this.state.originalData)}\n root\n schema={item}\n themeName={this.props.themeName}\n />\n );\n }\n console.error(`Unknown item type in root: ${JSON.stringify(item)}`);\n\n return null;\n }\n\n changeLanguage = (): void => {\n this.forceUpdate();\n };\n\n forceAttrUpdate = (attr: string | string[], data: any): void => {\n if (Array.isArray(attr)) {\n attr.forEach(a => this.forceUpdateHandlers[a] && this.forceUpdateHandlers[a](data));\n } else if (this.forceUpdateHandlers[attr]) {\n this.forceUpdateHandlers[attr](data);\n }\n };\n\n registerOnForceUpdate = (attr: string, cb?: ((data: any) => void) | null): void => {\n if (cb) {\n this.forceUpdateHandlers[attr] = cb;\n } else if (this.forceUpdateHandlers[attr]) {\n delete this.forceUpdateHandlers[attr];\n }\n };\n\n render(): JSX.Element {\n if (!this.state.systemConfig || !this.oContext) {\n return <LinearProgress />;\n }\n\n if (this.oContext._themeName !== this.props.themeName) {\n this.oContext._themeName = this.props.themeName;\n setTimeout(() => this.updateContext(true), 0);\n }\n\n return (\n <div\n style={{\n ...(!this.props.embedded || this.props.withoutSaveButtons ? styles.root : undefined),\n ...this.props.style,\n ...this.state.schema.style,\n }}\n >\n {this.renderItem(this.state.schema)}\n </div>\n );\n }\n}\n\nexport default JsonConfigComponent;\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iobroker/json-config",
3
3
  "description": "This package contains the ioBroker JSON config UI components",
4
- "version": "8.0.3",
4
+ "version": "8.0.4",
5
5
  "author": {
6
6
  "name": "bluefox",
7
7
  "email": "dogafox@gmail.com"
@@ -21,7 +21,7 @@
21
21
  "clean": "rimraf build",
22
22
  "prepublishOnly": "npm run build",
23
23
  "build:ts": "tsc -p tsconfig.json",
24
- "lint": "eslint -c eslint.config.mjs src",
24
+ "lint": "eslint -c eslint.config.mjs",
25
25
  "test": "tsc -p test/tsconfig.build.json && node test/testSchema.js",
26
26
  "tsc-test": "tsc -p test/tsconfig.build.json",
27
27
  "release": "release-script --noPush --yes --lf",
@@ -34,13 +34,13 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@iobroker/adapter-react-v5": "^8.0.3",
38
- "@module-federation/runtime": "^0.15.0",
37
+ "@iobroker/adapter-react-v5": "^8.0.4",
38
+ "@module-federation/runtime": "^0.21.1",
39
39
  "@mui/x-date-pickers": "^7.29.4",
40
40
  "crypto-js": "^4.2.0",
41
41
  "json5": "^2.2.3",
42
42
  "react-ace": "^14.0.1",
43
- "react-qr-code": "^2.0.15"
43
+ "react-qr-code": "^2.0.18"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@alcalzone/release-script": "^5.0.0",