@iobroker/json-config 8.3.12 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/README.md +5 -1
  2. package/build/JsonConfigComponent/ConfigAccordion.d.ts +2 -2
  3. package/build/JsonConfigComponent/ConfigAccordion.js +21 -19
  4. package/build/JsonConfigComponent/ConfigAccordion.js.map +1 -1
  5. package/build/JsonConfigComponent/ConfigAlive.d.ts +3 -1
  6. package/build/JsonConfigComponent/ConfigAlive.js +22 -10
  7. package/build/JsonConfigComponent/ConfigAlive.js.map +1 -1
  8. package/build/JsonConfigComponent/ConfigAutocomplete.d.ts +1 -1
  9. package/build/JsonConfigComponent/ConfigAutocomplete.js +2 -2
  10. package/build/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
  11. package/build/JsonConfigComponent/ConfigAutocompleteSendTo.d.ts +1 -1
  12. package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js +3 -3
  13. package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
  14. package/build/JsonConfigComponent/ConfigCRON.d.ts +1 -1
  15. package/build/JsonConfigComponent/ConfigCRON.js +2 -2
  16. package/build/JsonConfigComponent/ConfigCRON.js.map +1 -1
  17. package/build/JsonConfigComponent/ConfigCertCollection.js +2 -2
  18. package/build/JsonConfigComponent/ConfigCertCollection.js.map +1 -1
  19. package/build/JsonConfigComponent/ConfigCertificateSelect.js +1 -1
  20. package/build/JsonConfigComponent/ConfigCertificateSelect.js.map +1 -1
  21. package/build/JsonConfigComponent/ConfigCertificates.js +2 -2
  22. package/build/JsonConfigComponent/ConfigCertificates.js.map +1 -1
  23. package/build/JsonConfigComponent/ConfigCheckDocker.js +1 -1
  24. package/build/JsonConfigComponent/ConfigCheckDocker.js.map +1 -1
  25. package/build/JsonConfigComponent/ConfigCheckLicense.d.ts +1 -1
  26. package/build/JsonConfigComponent/ConfigCheckLicense.js +7 -7
  27. package/build/JsonConfigComponent/ConfigCheckLicense.js.map +1 -1
  28. package/build/JsonConfigComponent/ConfigChip.d.ts +1 -1
  29. package/build/JsonConfigComponent/ConfigChip.js +2 -2
  30. package/build/JsonConfigComponent/ConfigChip.js.map +1 -1
  31. package/build/JsonConfigComponent/ConfigCoordinates.d.ts +1 -1
  32. package/build/JsonConfigComponent/ConfigCoordinates.js +3 -3
  33. package/build/JsonConfigComponent/ConfigCoordinates.js.map +1 -1
  34. package/build/JsonConfigComponent/ConfigDatePicker.d.ts +1 -1
  35. package/build/JsonConfigComponent/ConfigDatePicker.js +2 -2
  36. package/build/JsonConfigComponent/ConfigDatePicker.js.map +1 -1
  37. package/build/JsonConfigComponent/ConfigFile.d.ts +1 -1
  38. package/build/JsonConfigComponent/ConfigFile.js +2 -2
  39. package/build/JsonConfigComponent/ConfigFile.js.map +1 -1
  40. package/build/JsonConfigComponent/ConfigFileSelector.d.ts +1 -1
  41. package/build/JsonConfigComponent/ConfigFileSelector.js +2 -2
  42. package/build/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
  43. package/build/JsonConfigComponent/ConfigFunc.d.ts +1 -1
  44. package/build/JsonConfigComponent/ConfigFunc.js +2 -2
  45. package/build/JsonConfigComponent/ConfigFunc.js.map +1 -1
  46. package/build/JsonConfigComponent/ConfigGeneric.d.ts +22 -7
  47. package/build/JsonConfigComponent/ConfigGeneric.js +166 -52
  48. package/build/JsonConfigComponent/ConfigGeneric.js.map +1 -1
  49. package/build/JsonConfigComponent/ConfigIFrame.d.ts +1 -1
  50. package/build/JsonConfigComponent/ConfigIFrame.js +2 -2
  51. package/build/JsonConfigComponent/ConfigIFrame.js.map +1 -1
  52. package/build/JsonConfigComponent/ConfigIFrameSendTo.d.ts +2 -2
  53. package/build/JsonConfigComponent/ConfigIFrameSendTo.js +6 -6
  54. package/build/JsonConfigComponent/ConfigIFrameSendTo.js.map +1 -1
  55. package/build/JsonConfigComponent/ConfigIP.d.ts +1 -1
  56. package/build/JsonConfigComponent/ConfigIP.js +2 -2
  57. package/build/JsonConfigComponent/ConfigIP.js.map +1 -1
  58. package/build/JsonConfigComponent/ConfigImageSendTo.d.ts +2 -2
  59. package/build/JsonConfigComponent/ConfigImageSendTo.js +6 -6
  60. package/build/JsonConfigComponent/ConfigImageSendTo.js.map +1 -1
  61. package/build/JsonConfigComponent/ConfigImageUpload.d.ts +1 -1
  62. package/build/JsonConfigComponent/ConfigImageUpload.js +2 -2
  63. package/build/JsonConfigComponent/ConfigImageUpload.js.map +1 -1
  64. package/build/JsonConfigComponent/ConfigInstanceSelect.d.ts +1 -1
  65. package/build/JsonConfigComponent/ConfigInstanceSelect.js +2 -2
  66. package/build/JsonConfigComponent/ConfigInstanceSelect.js.map +1 -1
  67. package/build/JsonConfigComponent/ConfigInterface.d.ts +1 -1
  68. package/build/JsonConfigComponent/ConfigInterface.js +5 -5
  69. package/build/JsonConfigComponent/ConfigInterface.js.map +1 -1
  70. package/build/JsonConfigComponent/ConfigJsonEditor.d.ts +1 -1
  71. package/build/JsonConfigComponent/ConfigJsonEditor.js +2 -2
  72. package/build/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
  73. package/build/JsonConfigComponent/ConfigLanguage.d.ts +1 -1
  74. package/build/JsonConfigComponent/ConfigLanguage.js +2 -2
  75. package/build/JsonConfigComponent/ConfigLanguage.js.map +1 -1
  76. package/build/JsonConfigComponent/ConfigLicense.d.ts +1 -1
  77. package/build/JsonConfigComponent/ConfigLicense.js +2 -2
  78. package/build/JsonConfigComponent/ConfigLicense.js.map +1 -1
  79. package/build/JsonConfigComponent/ConfigNumber.d.ts +1 -1
  80. package/build/JsonConfigComponent/ConfigNumber.js +2 -2
  81. package/build/JsonConfigComponent/ConfigNumber.js.map +1 -1
  82. package/build/JsonConfigComponent/ConfigOAuth2.js +1 -1
  83. package/build/JsonConfigComponent/ConfigOAuth2.js.map +1 -1
  84. package/build/JsonConfigComponent/ConfigObjectId.d.ts +1 -1
  85. package/build/JsonConfigComponent/ConfigObjectId.js +3 -3
  86. package/build/JsonConfigComponent/ConfigObjectId.js.map +1 -1
  87. package/build/JsonConfigComponent/ConfigPanel.d.ts +1 -1
  88. package/build/JsonConfigComponent/ConfigPanel.js +11 -8
  89. package/build/JsonConfigComponent/ConfigPanel.js.map +1 -1
  90. package/build/JsonConfigComponent/ConfigPassword.d.ts +1 -1
  91. package/build/JsonConfigComponent/ConfigPassword.js +2 -2
  92. package/build/JsonConfigComponent/ConfigPassword.js.map +1 -1
  93. package/build/JsonConfigComponent/ConfigPattern.d.ts +8 -1
  94. package/build/JsonConfigComponent/ConfigPattern.js +29 -3
  95. package/build/JsonConfigComponent/ConfigPattern.js.map +1 -1
  96. package/build/JsonConfigComponent/ConfigPort.js +2 -2
  97. package/build/JsonConfigComponent/ConfigPort.js.map +1 -1
  98. package/build/JsonConfigComponent/ConfigQrCode.js +1 -1
  99. package/build/JsonConfigComponent/ConfigQrCode.js.map +1 -1
  100. package/build/JsonConfigComponent/ConfigQrCodeSendTo.d.ts +1 -1
  101. package/build/JsonConfigComponent/ConfigQrCodeSendTo.js +5 -5
  102. package/build/JsonConfigComponent/ConfigQrCodeSendTo.js.map +1 -1
  103. package/build/JsonConfigComponent/ConfigRoom.d.ts +1 -1
  104. package/build/JsonConfigComponent/ConfigRoom.js +2 -2
  105. package/build/JsonConfigComponent/ConfigRoom.js.map +1 -1
  106. package/build/JsonConfigComponent/ConfigSelect.d.ts +13 -11
  107. package/build/JsonConfigComponent/ConfigSelect.js +35 -29
  108. package/build/JsonConfigComponent/ConfigSelect.js.map +1 -1
  109. package/build/JsonConfigComponent/ConfigSelectSendTo.d.ts +16 -11
  110. package/build/JsonConfigComponent/ConfigSelectSendTo.js +26 -23
  111. package/build/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
  112. package/build/JsonConfigComponent/ConfigSendto.d.ts +1 -1
  113. package/build/JsonConfigComponent/ConfigSendto.js +8 -8
  114. package/build/JsonConfigComponent/ConfigSendto.js.map +1 -1
  115. package/build/JsonConfigComponent/ConfigSetState.js +2 -2
  116. package/build/JsonConfigComponent/ConfigSetState.js.map +1 -1
  117. package/build/JsonConfigComponent/ConfigSlider.d.ts +1 -1
  118. package/build/JsonConfigComponent/ConfigSlider.js +2 -2
  119. package/build/JsonConfigComponent/ConfigSlider.js.map +1 -1
  120. package/build/JsonConfigComponent/ConfigState.d.ts +2 -1
  121. package/build/JsonConfigComponent/ConfigState.js +32 -26
  122. package/build/JsonConfigComponent/ConfigState.js.map +1 -1
  123. package/build/JsonConfigComponent/ConfigTable.d.ts +1 -1
  124. package/build/JsonConfigComponent/ConfigTable.js +21 -19
  125. package/build/JsonConfigComponent/ConfigTable.js.map +1 -1
  126. package/build/JsonConfigComponent/ConfigTabs.d.ts +6 -0
  127. package/build/JsonConfigComponent/ConfigTabs.js +57 -21
  128. package/build/JsonConfigComponent/ConfigTabs.js.map +1 -1
  129. package/build/JsonConfigComponent/ConfigText.d.ts +1 -1
  130. package/build/JsonConfigComponent/ConfigText.js +2 -2
  131. package/build/JsonConfigComponent/ConfigText.js.map +1 -1
  132. package/build/JsonConfigComponent/ConfigTextSendTo.d.ts +1 -1
  133. package/build/JsonConfigComponent/ConfigTextSendTo.js +3 -3
  134. package/build/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
  135. package/build/JsonConfigComponent/ConfigTimePicker.d.ts +1 -1
  136. package/build/JsonConfigComponent/ConfigTimePicker.js +2 -2
  137. package/build/JsonConfigComponent/ConfigTimePicker.js.map +1 -1
  138. package/build/JsonConfigComponent/ConfigTopic.d.ts +1 -1
  139. package/build/JsonConfigComponent/ConfigTopic.js +2 -2
  140. package/build/JsonConfigComponent/ConfigTopic.js.map +1 -1
  141. package/build/JsonConfigComponent/ConfigUUID.js +2 -2
  142. package/build/JsonConfigComponent/ConfigUUID.js.map +1 -1
  143. package/build/JsonConfigComponent/ConfigUser.d.ts +1 -1
  144. package/build/JsonConfigComponent/ConfigUser.js +2 -2
  145. package/build/JsonConfigComponent/ConfigUser.js.map +1 -1
  146. package/build/JsonConfigComponent/ConfigYamlEditor.d.ts +1 -1
  147. package/build/JsonConfigComponent/ConfigYamlEditor.js +2 -2
  148. package/build/JsonConfigComponent/ConfigYamlEditor.js.map +1 -1
  149. package/build/JsonConfigComponent/index.d.ts +2 -0
  150. package/build/JsonConfigComponent/index.js +16 -1
  151. package/build/JsonConfigComponent/index.js.map +1 -1
  152. package/build/types.d.ts +1 -0
  153. package/package.json +1 -1
@@ -5,8 +5,8 @@ import { Utils, I18n } from '@iobroker/adapter-react-v5';
5
5
  import ConfigGeneric from './ConfigGeneric';
6
6
  export default class ConfigUUID extends ConfigGeneric {
7
7
  async componentDidMount() {
8
- super.componentDidMount();
9
- const uuidObj = await this.props.oContext.socket.getObject('system.meta.uuid');
8
+ await super.componentDidMount();
9
+ const uuidObj = await this.props.oContext.getCachedObject('system.meta.uuid');
10
10
  this.setState({ uuid: uuidObj?.native?.uuid || 'unknown' });
11
11
  }
12
12
  renderItem(error, disabled) {
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigUUID.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigUUID.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,WAAW,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGzD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAUlG,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,aAA+C;IACnF,KAAK,CAAC,iBAAiB;QACnB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAE1B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;QAC/E,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,IAAI,SAAS,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,UAAU,CAAC,KAAc,EAAE,QAAiB;QACxC,OAAO,CACH,oBAAC,SAAS,IACN,OAAO,EAAC,UAAU,EAClB,SAAS,QACT,KAAK,EAAE,CAAC,CAAC,KAAK,EACd,QAAQ,EAAE,CAAC,CAAC,QAAQ,EACpB,SAAS,EAAE;gBACP,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC7B,KAAK,EAAE;oBACH,YAAY,EAAE,CACV,oBAAC,UAAU,IACP,QAAQ,EAAE,CAAC,CAAC,EACZ,OAAO,EAAE,GAAG,EAAE;4BACV,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;4BACvC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;wBAC1D,CAAC;wBAED,oBAAC,QAAQ,OAAG,CACH,CAChB;iBACJ;aACJ,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,EAC5B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,yBAAyB,CAAC,EACjF,UAAU,EAAE,IAAI,CAAC,UAAU,CACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,GACH,CACL,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { TextField, IconButton } from '@mui/material';\n\nimport { ContentCopy as IconCopy } from '@mui/icons-material';\n\nimport { Utils, I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemUUID } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface ConfigUUIDProps extends ConfigGenericProps {\n schema: ConfigItemUUID;\n}\n\ninterface ConfigUUIDState extends ConfigGenericState {\n uuid?: string;\n}\n\nexport default class ConfigUUID extends ConfigGeneric<ConfigUUIDProps, ConfigUUIDState> {\n async componentDidMount(): Promise<void> {\n super.componentDidMount();\n\n const uuidObj = await this.props.oContext.socket.getObject('system.meta.uuid');\n this.setState({ uuid: uuidObj?.native?.uuid || 'unknown' });\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element {\n return (\n <TextField\n variant=\"standard\"\n fullWidth\n error={!!error}\n disabled={!!disabled}\n slotProps={{\n htmlInput: { readOnly: true },\n input: {\n endAdornment: (\n <IconButton\n tabIndex={-1}\n onClick={() => {\n Utils.copyToClipboard(this.state.uuid);\n window.alert(I18n.t('ra_Copied %s', this.state.uuid));\n }}\n >\n <IconCopy />\n </IconButton>\n ),\n },\n }}\n value={this.state.uuid || ''}\n label={this.getText(this.props.schema.label) || I18n.t('ra_Serial number (UUID)')}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n />\n );\n }\n}\n"]}
1
+ {"version":3,"file":"ConfigUUID.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigUUID.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,WAAW,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGzD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAUlG,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,aAA+C;IACnF,KA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IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,GACH,CACL,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { TextField, IconButton } from '@mui/material';\n\nimport { ContentCopy as IconCopy } from '@mui/icons-material';\n\nimport { Utils, I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemUUID } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface ConfigUUIDProps extends ConfigGenericProps {\n schema: ConfigItemUUID;\n}\n\ninterface ConfigUUIDState extends ConfigGenericState {\n uuid?: string;\n}\n\nexport default class ConfigUUID extends ConfigGeneric<ConfigUUIDProps, ConfigUUIDState> {\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n\n const uuidObj = await this.props.oContext.getCachedObject('system.meta.uuid');\n this.setState({ uuid: uuidObj?.native?.uuid || 'unknown' });\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element {\n return (\n <TextField\n variant=\"standard\"\n fullWidth\n error={!!error}\n disabled={!!disabled}\n slotProps={{\n htmlInput: { readOnly: true },\n input: {\n endAdornment: (\n <IconButton\n tabIndex={-1}\n onClick={() => {\n Utils.copyToClipboard(this.state.uuid);\n window.alert(I18n.t('ra_Copied %s', this.state.uuid));\n }}\n >\n <IconCopy />\n </IconButton>\n ),\n },\n }}\n value={this.state.uuid || ''}\n label={this.getText(this.props.schema.label) || I18n.t('ra_Serial number (UUID)')}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n />\n );\n }\n}\n"]}
@@ -12,7 +12,7 @@ interface ConfigUserState extends ConfigGenericState {
12
12
  }>;
13
13
  }
14
14
  declare class ConfigUser extends ConfigGeneric<ConfigUserProps, ConfigUserState> {
15
- componentDidMount(): void;
15
+ componentDidMount(): Promise<void>;
16
16
  renderItem(error: string, disabled: boolean): JSX.Element;
17
17
  }
18
18
  export default ConfigUser;
@@ -10,8 +10,8 @@ const styles = {
10
10
  },
11
11
  };
12
12
  class ConfigUser extends ConfigGeneric {
13
- componentDidMount() {
14
- super.componentDidMount();
13
+ async componentDidMount() {
14
+ await super.componentDidMount();
15
15
  this.props.oContext.socket
16
16
  .getUsers()
17
17
  .then(users => {
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigUser.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigUser.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAErG,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAG/D,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,IAAI,EAAE;QACF,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,CAAC;KACjB;CACJ,CAAC;AAUF,MAAM,UAAW,SAAQ,aAA+C;IACpE,iBAAiB;QACb,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM;aACrB,QAAQ,EAAE;aACV,IAAI,CAAC,KAAK,CAAC,EAAE;YACV,MAAM,MAAM,GAAoE,EAAE,CAAC;YACnF,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YAEhC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBAC1B,KAAK,CAAC,OAAO,CACT,IAAI,CAAC,EAAE,CACH,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;oBAChB,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK;oBACzB,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI;oBACvB,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V,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,UAAU,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { InputLabel, TextField, MenuItem, FormHelperText, FormControl, Select } from '@mui/material';\n\nimport { Icon, Utils, I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemUser } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n icon: {\n width: 16,\n height: 16,\n marginRight: 8,\n },\n};\n\ninterface ConfigUserProps extends ConfigGenericProps {\n schema: ConfigItemUser;\n}\n\ninterface ConfigUserState extends ConfigGenericState {\n users: Record<string, { color?: string; icon?: string; name: string }>;\n}\n\nclass ConfigUser extends ConfigGeneric<ConfigUserProps, ConfigUserState> {\n componentDidMount(): void {\n super.componentDidMount();\n this.props.oContext.socket\n .getUsers()\n .then(users => {\n const _users: Record<string, { color?: string; icon?: string; name: string }> = {};\n const lang = I18n.getLanguage();\n\n if (this.props.schema.short) {\n users.forEach(\n user =>\n (_users[user._id] = {\n color: user.common?.color,\n icon: user.common?.icon,\n name: Utils.getObjectNameFromObj(user, lang),\n }),\n );\n } else {\n users.forEach(\n user =>\n (_users[user._id.replace(/^system\\.user\\./, '')] = {\n color: user.common?.color,\n icon: user.common?.icon,\n name: Utils.getObjectNameFromObj(user, lang),\n }),\n );\n }\n\n this.setState({ users: _users });\n })\n .catch(e => console.error(`Cannot get users: ${e}`));\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n return (\n <FormControl\n variant=\"standard\"\n fullWidth\n >\n {this.state.users && this.props.schema.label ? (\n <InputLabel>{this.getText(this.props.schema.label)}</InputLabel>\n ) : null}\n {!this.state.users ? (\n <TextField\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 <span>\n {this.state.users && this.state.users[val]?.icon ? (\n <Icon\n src={this.state.users && this.state.users[val]?.icon}\n style={styles.icon}\n />\n ) : null}\n {(this.state.users && this.state.users[val]?.name) || val || ''}\n </span>\n )}\n style={{\n color: (this.state.users && this.state.users[value]?.color) || undefined,\n backgroundColor: Utils.getInvertedColor(\n this.state.users && this.state.users[value]?.color,\n this.props.oContext.themeType,\n ),\n }}\n onChange={e => this.onChange(this.props.attr, e.target.value)}\n >\n {this.state.users &&\n Object.keys(this.state.users).map(id => (\n <MenuItem\n style={{\n color: this.state.users[id].color || undefined,\n backgroundColor: Utils.getInvertedColor(\n this.state.users[id].color,\n this.props.oContext.themeType,\n ),\n }}\n key={id}\n value={id}\n >\n {this.state.users[id].icon ? (\n <Icon\n src={this.state.users[id].icon}\n style={styles.icon}\n />\n ) : null}\n {this.state.users[id].name}\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 ConfigUser;\n"]}
1
+ {"version":3,"file":"ConfigUser.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigUser.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eA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K,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CACpC,oBAAC,QAAQ,IACL,KAAK,EAAE;wBACH,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,SAAS;wBAC9C,eAAe,EAAE,KAAK,CAAC,gBAAgB,CACnC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,EAC1B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAChC;qBACJ,EACD,GAAG,EAAE,EAAE,EACP,KAAK,EAAE,EAAE;oBAER,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACzB,oBAAC,IAAI,IACD,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,EAC9B,KAAK,EAAE,MAAM,CAAC,IAAI,GACpB,CACL,CAAC,CAAC,CAAC,IAAI;oBACP,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CACnB,CACd,CAAC,CACD,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,UAAU,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { InputLabel, TextField, MenuItem, FormHelperText, FormControl, Select } from '@mui/material';\n\nimport { Icon, Utils, I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemUser } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n icon: {\n width: 16,\n height: 16,\n marginRight: 8,\n },\n};\n\ninterface ConfigUserProps extends ConfigGenericProps {\n schema: ConfigItemUser;\n}\n\ninterface ConfigUserState extends ConfigGenericState {\n users: Record<string, { color?: string; icon?: string; name: string }>;\n}\n\nclass ConfigUser extends ConfigGeneric<ConfigUserProps, ConfigUserState> {\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n this.props.oContext.socket\n .getUsers()\n .then(users => {\n const _users: Record<string, { color?: string; icon?: string; name: string }> = {};\n const lang = I18n.getLanguage();\n\n if (this.props.schema.short) {\n users.forEach(\n user =>\n (_users[user._id] = {\n color: user.common?.color,\n icon: user.common?.icon,\n name: Utils.getObjectNameFromObj(user, lang),\n }),\n );\n } else {\n users.forEach(\n user =>\n (_users[user._id.replace(/^system\\.user\\./, '')] = {\n color: user.common?.color,\n icon: user.common?.icon,\n name: Utils.getObjectNameFromObj(user, lang),\n }),\n );\n }\n\n this.setState({ users: _users });\n })\n .catch(e => console.error(`Cannot get users: ${e}`));\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n return (\n <FormControl\n variant=\"standard\"\n fullWidth\n >\n {this.state.users && this.props.schema.label ? (\n <InputLabel>{this.getText(this.props.schema.label)}</InputLabel>\n ) : null}\n {!this.state.users ? (\n <TextField\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 <span>\n {this.state.users && this.state.users[val]?.icon ? (\n <Icon\n src={this.state.users && this.state.users[val]?.icon}\n style={styles.icon}\n />\n ) : null}\n {(this.state.users && this.state.users[val]?.name) || val || ''}\n </span>\n )}\n style={{\n color: (this.state.users && this.state.users[value]?.color) || undefined,\n backgroundColor: Utils.getInvertedColor(\n this.state.users && this.state.users[value]?.color,\n this.props.oContext.themeType,\n ),\n }}\n onChange={e => this.onChange(this.props.attr, e.target.value)}\n >\n {this.state.users &&\n Object.keys(this.state.users).map(id => (\n <MenuItem\n style={{\n color: this.state.users[id].color || undefined,\n backgroundColor: Utils.getInvertedColor(\n this.state.users[id].color,\n this.props.oContext.themeType,\n ),\n }}\n key={id}\n value={id}\n >\n {this.state.users[id].icon ? (\n <Icon\n src={this.state.users[id].icon}\n style={styles.icon}\n />\n ) : null}\n {this.state.users[id].name}\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 ConfigUser;\n"]}
@@ -10,7 +10,7 @@ interface ConfigYamlEditorState extends ConfigGenericState {
10
10
  yamlError?: boolean;
11
11
  }
12
12
  export default class ConfigYamlEditor extends ConfigGeneric<ConfigYamlEditorProps, ConfigYamlEditorState> {
13
- componentDidMount(): void;
13
+ componentDidMount(): Promise<void>;
14
14
  validateYaml(value: string | null | undefined): boolean;
15
15
  renderItem(_error: string, disabled: boolean): JSX.Element | null;
16
16
  }
@@ -22,8 +22,8 @@ const styles = {
22
22
  },
23
23
  };
24
24
  export default class ConfigYamlEditor extends ConfigGeneric {
25
- componentDidMount() {
26
- super.componentDidMount();
25
+ async componentDidMount() {
26
+ await super.componentDidMount();
27
27
  const { data, attr } = this.props;
28
28
  const value = ConfigGeneric.getValue(data, attr) || '';
29
29
  this.setState({ value, initialized: true, yamlError: this.validateYaml(value) });
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigYamlEditor.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigYamlEditor.tsx"],"names":[],"mappings":"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,QAAQ,CAAC,SAAS,GAC1C,CACA,CACI,CACjB,CAAC,CAAC,CAAC,IAAI;YACP,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CACnC,oBAAC,cAAc,QACV,IAAI,CAAC,KAAK,CAAC,SAAS;gBACjB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC;gBAC3B,CAAC,CAAC,IAAI,CAAC,UAAU,CACX,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACM,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\nimport { parse } from 'yaml';\n\nimport { FormHelperText, FormControl, Button } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemYamlEditor } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\nimport CustomModal from './wrapper/Components/CustomModal';\nimport Editor from './wrapper/Components/Editor';\n\nconst styles: Record<string, React.CSSProperties> = {\n fullWidth: {\n width: '100%',\n },\n flex: {\n display: 'flex',\n },\n button: {\n height: 48,\n minWidth: 48,\n },\n wrapper: {\n width: 'calc(100vw - 40px)',\n height: 'calc(100vh - 188px)',\n },\n};\n\ninterface ConfigYamlEditorProps extends ConfigGenericProps {\n schema: ConfigItemYamlEditor;\n}\n\ninterface ConfigYamlEditorState extends ConfigGenericState {\n initialized?: boolean;\n showSelectId?: boolean;\n yamlError?: boolean;\n}\n\nexport default class ConfigYamlEditor extends ConfigGeneric<ConfigYamlEditorProps, ConfigYamlEditorState> {\n componentDidMount(): void {\n super.componentDidMount();\n const { data, attr } = this.props;\n const value: string = ConfigGeneric.getValue(data, attr) || '';\n this.setState({ value, initialized: true, yamlError: this.validateYaml(value) });\n }\n\n validateYaml(value: string | null | undefined): boolean {\n let yamlError = false;\n if (this.props.schema.validateYaml !== false) {\n if (value || !this.props.schema.allowEmpty) {\n try {\n parse(value);\n } catch (err: unknown) {\n console.log('Error in YAML', err);\n yamlError = true;\n }\n }\n }\n\n return yamlError;\n }\n\n renderItem(_error: string, disabled: boolean /* , defaultValue */): JSX.Element | null {\n if (!this.state.initialized) {\n return null;\n }\n\n const { schema, data, attr } = this.props;\n const { value, showSelectId } = this.state;\n const isReadOnly = schema.readOnly === true || disabled;\n\n return (\n <FormControl\n fullWidth\n variant=\"standard\"\n >\n <div style={styles.flex}>\n <Button\n color=\"grey\"\n style={styles.button}\n size=\"small\"\n variant=\"outlined\"\n onClick={() => this.setState({ showSelectId: true })}\n >\n {I18n.t('ra_YAML editor')}\n </Button>\n </div>\n {showSelectId ? (\n <CustomModal\n title={this.getText(schema.label)}\n overflowHidden\n applyDisabled={(this.state.yamlError && this.props.schema.doNotApplyWithError) || isReadOnly}\n onClose={() => {\n if (isReadOnly) {\n this.setState({ showSelectId: false });\n } else {\n this.setState({ showSelectId: false, value: ConfigGeneric.getValue(data, attr) || '' });\n }\n }}\n onApply={\n isReadOnly\n ? undefined\n : () => this.setState({ showSelectId: false }, () => this.onChange(attr, value))\n }\n >\n <div\n style={{\n ...styles.wrapper,\n border: this.state.yamlError ? '2px solid red' : '2px solid transparent',\n }}\n >\n <Editor\n mode=\"yaml\"\n value={typeof value === 'object' ? JSON.stringify(value) : value}\n onChange={\n isReadOnly\n ? undefined\n : newValue =>\n this.setState({\n value: newValue,\n yamlError: this.validateYaml(newValue),\n })\n }\n name=\"ConfigYamlEditor\"\n themeType={this.props.oContext.themeType}\n />\n </div>\n </CustomModal>\n ) : null}\n {schema.help || this.state.yamlError ? (\n <FormHelperText>\n {this.state.yamlError\n ? I18n.t('ra_Invalid YAML')\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
+ {"version":3,"file":"ConfigYamlEditor.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigYamlEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAC3D,OAAO,MAAM,MAAM,6BAA6B,CAAC;AAEjD,MAAM,MAAM,GAAwC;IAChD,SAAS,EAAE;QACP,KAAK,EAAE,MAAM;KAChB;IACD,IAAI,EAAE;QACF,OAAO,EAAE,MAAM;KAClB;IACD,MAAM,EAAE;QACJ,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;KACf;IACD,OAAO,EAAE;QACL,KAAK,EAAE,oBAAoB;QAC3B,MAAM,EAAE,qBAAqB;KAChC;CACJ,CAAC;AAYF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,aAA2D;IACrG,KAAK,CAAC,iBAAiB;QACnB,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAChC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAClC,MAAM,KAAK,GAAW,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/D,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,YAAY,CAAC,KAAgC;QACzC,IAAI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,CAAC;gCACV,KAAK,EAAE,QAAQ;gCACf,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;6BACzC,CAAC,EAEhB,IAAI,EAAC,kBAAkB,EACvB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,GAC1C,CACA,CACI,CACjB,CAAC,CAAC,CAAC,IAAI;YACP,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CACnC,oBAAC,cAAc,QACV,IAAI,CAAC,KAAK,CAAC,SAAS;gBACjB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC;gBAC3B,CAAC,CAAC,IAAI,CAAC,UAAU,CACX,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACM,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\nimport { parse } from 'yaml';\n\nimport { FormHelperText, FormControl, Button } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemYamlEditor } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\nimport CustomModal from './wrapper/Components/CustomModal';\nimport Editor from './wrapper/Components/Editor';\n\nconst styles: Record<string, React.CSSProperties> = {\n fullWidth: {\n width: '100%',\n },\n flex: {\n display: 'flex',\n },\n button: {\n height: 48,\n minWidth: 48,\n },\n wrapper: {\n width: 'calc(100vw - 40px)',\n height: 'calc(100vh - 188px)',\n },\n};\n\ninterface ConfigYamlEditorProps extends ConfigGenericProps {\n schema: ConfigItemYamlEditor;\n}\n\ninterface ConfigYamlEditorState extends ConfigGenericState {\n initialized?: boolean;\n showSelectId?: boolean;\n yamlError?: boolean;\n}\n\nexport default class ConfigYamlEditor extends ConfigGeneric<ConfigYamlEditorProps, ConfigYamlEditorState> {\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n const { data, attr } = this.props;\n const value: string = ConfigGeneric.getValue(data, attr) || '';\n this.setState({ value, initialized: true, yamlError: this.validateYaml(value) });\n }\n\n validateYaml(value: string | null | undefined): boolean {\n let yamlError = false;\n if (this.props.schema.validateYaml !== false) {\n if (value || !this.props.schema.allowEmpty) {\n try {\n parse(value);\n } catch (err: unknown) {\n console.log('Error in YAML', err);\n yamlError = true;\n }\n }\n }\n\n return yamlError;\n }\n\n renderItem(_error: string, disabled: boolean /* , defaultValue */): JSX.Element | null {\n if (!this.state.initialized) {\n return null;\n }\n\n const { schema, data, attr } = this.props;\n const { value, showSelectId } = this.state;\n const isReadOnly = schema.readOnly === true || disabled;\n\n return (\n <FormControl\n fullWidth\n variant=\"standard\"\n >\n <div style={styles.flex}>\n <Button\n color=\"grey\"\n style={styles.button}\n size=\"small\"\n variant=\"outlined\"\n onClick={() => this.setState({ showSelectId: true })}\n >\n {I18n.t('ra_YAML editor')}\n </Button>\n </div>\n {showSelectId ? (\n <CustomModal\n title={this.getText(schema.label)}\n overflowHidden\n applyDisabled={(this.state.yamlError && this.props.schema.doNotApplyWithError) || isReadOnly}\n onClose={() => {\n if (isReadOnly) {\n this.setState({ showSelectId: false });\n } else {\n this.setState({ showSelectId: false, value: ConfigGeneric.getValue(data, attr) || '' });\n }\n }}\n onApply={\n isReadOnly\n ? undefined\n : () => this.setState({ showSelectId: false }, () => this.onChange(attr, value))\n }\n >\n <div\n style={{\n ...styles.wrapper,\n border: this.state.yamlError ? '2px solid red' : '2px solid transparent',\n }}\n >\n <Editor\n mode=\"yaml\"\n value={typeof value === 'object' ? JSON.stringify(value) : value}\n onChange={\n isReadOnly\n ? undefined\n : newValue =>\n this.setState({\n value: newValue,\n yamlError: this.validateYaml(newValue),\n })\n }\n name=\"ConfigYamlEditor\"\n themeType={this.props.oContext.themeType}\n />\n </div>\n </CustomModal>\n ) : null}\n {schema.help || this.state.yamlError ? (\n <FormHelperText>\n {this.state.yamlError\n ? I18n.t('ra_Invalid YAML')\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"]}
@@ -52,6 +52,7 @@ export declare class JsonConfigComponent extends Component<JsonConfigComponentPr
52
52
  private errorTimeout;
53
53
  private errorCached;
54
54
  private oContext;
55
+ private cachedObjects;
55
56
  constructor(props: JsonConfigComponentProps);
56
57
  static getDerivedStateFromProps(props: JsonConfigComponentProps, state: JsonConfigComponentState): Partial<JsonConfigComponentState> | null;
57
58
  static loadI18n(socket: AdminConnection, i18n: boolean | string | Record<string, Record<ioBroker.Languages, string>>, adapterName: string): Promise<string>;
@@ -62,6 +63,7 @@ export declare class JsonConfigComponent extends Component<JsonConfigComponentPr
62
63
  onError: (attr: string, error?: string) => void;
63
64
  flatten(schema: Record<string, any>, _list?: Record<string, any>): Record<string, any>;
64
65
  buildDependencies(schema: ConfigItemTabs | ConfigItemPanel): void;
66
+ getCachedObject: (id: string) => Promise<ioBroker.Object | null>;
65
67
  updateContext(forceUpdate?: boolean): void;
66
68
  renderItem(item: ConfigItemTabs | ConfigItemPanel): JSX.Element | null;
67
69
  changeLanguage: () => void;
@@ -14,6 +14,7 @@ export class JsonConfigComponent extends Component {
14
14
  errorTimeout = null;
15
15
  errorCached = null;
16
16
  oContext;
17
+ cachedObjects = {};
17
18
  constructor(props) {
18
19
  super(props);
19
20
  this.state = {
@@ -106,7 +107,7 @@ export class JsonConfigComponent extends Component {
106
107
  systemConfig = await this.props.socket.getCompactSystemConfig();
107
108
  }
108
109
  else {
109
- systemConfig = await this.props.socket.getObject('system.config');
110
+ systemConfig = ((await this.getCachedObject('system.config')) || undefined);
110
111
  }
111
112
  const state = await this.props.socket.getState(`system.adapter.${this.props.adapterName}.${this.props.instance}.alive`);
112
113
  this.setState({ systemConfig: systemConfig.common, alive: !!(state && state.val) }, () => {
@@ -263,6 +264,19 @@ export class JsonConfigComponent extends Component {
263
264
  }
264
265
  });
265
266
  }
267
+ getCachedObject = async (id) => {
268
+ if (this.cachedObjects[id] !== undefined) {
269
+ return this.cachedObjects[id];
270
+ }
271
+ try {
272
+ this.cachedObjects[id] = (await this.props.socket.getObject(id)) ?? null;
273
+ }
274
+ catch (e) {
275
+ console.error(e);
276
+ this.cachedObjects[id] = null;
277
+ }
278
+ return this.cachedObjects[id];
279
+ };
266
280
  updateContext(forceUpdate) {
267
281
  this.oContext = {
268
282
  DeviceManager: this.props.DeviceManager,
@@ -289,6 +303,7 @@ export class JsonConfigComponent extends Component {
289
303
  themeType: this.props.themeType,
290
304
  _themeName: this.props.themeName,
291
305
  updateData: this.state.updateData,
306
+ getCachedObject: this.getCachedObject,
292
307
  };
293
308
  if (forceUpdate) {
294
309
  this.forceUpdate();
@@ -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;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;AA8CF,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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B,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QACxC,CAAC;aAAM,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC,CAAC;IAEF,MAAM;QACF,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC7C,OAAO,oBAAC,cAAc,OAAG,CAAC;QAC9B,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,KAAK,IAAI,CAAC,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, type ConfigGenericProps } 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 /** User can provide their own components for specific input fields */\n customComponents?: { [componentType: string]: typeof ConfigGeneric<ConfigGenericProps, any> };\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 void this.readData().catch(error => console.error(`Cannot read data: ${error}`));\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 async readData(): Promise<void> {\n let systemConfig: ioBroker.SystemConfigObject | undefined;\n try {\n if (this.props.socket.getCompactSystemConfig) {\n systemConfig = await this.props.socket.getCompactSystemConfig();\n } else {\n systemConfig = await this.props.socket.getObject('system.config');\n }\n const state = await this.props.socket.getState(\n `system.adapter.${this.props.adapterName}.${this.props.instance}.alive`,\n );\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 } catch (error) {\n console.error(`Cannot read system config: ${error}`);\n }\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 customComponents={this.props.customComponents}\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 customComponents={this.props.customComponents}\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;AA8CF,MAAM,OAAO,mBAAoB,SAAQ,SAA6D;IACjF,mBAAmB,CAAsC;IAClE,YAAY,GAAyC,IAAI,CAAC;IAC1D,WAAW,GAAkC,IAAI,CAAC;IAClD,QAAQ,CAAoB;IAC5B,aAAa,GAA2C,EAAE,CAAC;IAEnE,YAAY,K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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, type ConfigGenericProps } 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 /** User can provide their own components for specific input fields */\n customComponents?: { [componentType: string]: typeof ConfigGeneric<ConfigGenericProps, any> };\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 private errorTimeout: ReturnType<typeof setTimeout> | null = null;\n private errorCached: Record<string, string> | null = null;\n private oContext: JsonConfigContext;\n private cachedObjects: Record<string, ioBroker.Object | null> = {};\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 void this.readData().catch(error => console.error(`Cannot read data: ${error}`));\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 async readData(): Promise<void> {\n let systemConfig: ioBroker.SystemConfigObject | undefined;\n try {\n if (this.props.socket.getCompactSystemConfig) {\n systemConfig = await this.props.socket.getCompactSystemConfig();\n } else {\n systemConfig = ((await this.getCachedObject('system.config')) || undefined) as\n | ioBroker.SystemConfigObject\n | undefined;\n }\n const state = await this.props.socket.getState(\n `system.adapter.${this.props.adapterName}.${this.props.instance}.alive`,\n );\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 } catch (error) {\n console.error(`Cannot read system config: ${error}`);\n }\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 getCachedObject = async (id: string): Promise<ioBroker.Object | null> => {\n if (this.cachedObjects[id] !== undefined) {\n return this.cachedObjects[id];\n }\n try {\n this.cachedObjects[id] = (await this.props.socket.getObject(id)) ?? null;\n } catch (e) {\n console.error(e);\n this.cachedObjects[id] = null;\n }\n return this.cachedObjects[id];\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 getCachedObject: this.getCachedObject,\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 customComponents={this.props.customComponents}\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 customComponents={this.props.customComponents}\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/build/types.d.ts CHANGED
@@ -1234,6 +1234,7 @@ export type JsonConfigContext = {
1234
1234
  onCommandRunning: (commandRunning: boolean) => void;
1235
1235
  onValueChange?: (attr: string, value: any, saveConfig: boolean) => void;
1236
1236
  registerOnForceUpdate?: (attr: string, cb?: (data: any) => void) => void;
1237
+ getCachedObject: (id: string) => Promise<ioBroker.Object | null>;
1237
1238
  };
1238
1239
 
1239
1240
  // Notification GUI
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.3.12",
4
+ "version": "8.4.0",
5
5
  "author": {
6
6
  "name": "bluefox",
7
7
  "email": "dogafox@gmail.com"