@iobroker/json-config 9.1.1 → 10.0.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.
package/README.md CHANGED
@@ -802,6 +802,12 @@ Button to open a JSON(5) editor. JSON5 is supported from admin version 5.7.3
802
802
  | `doNotApplyWithError` | Do not allow to save the value if error in JSON or JSON5 (From 7.5.3) |
803
803
  | `readOnly` | Open the editor in read-only mode - editor can be opened but content cannot be modified |
804
804
 
805
+ The editor itself does not belong to this library: the host hands it in with the property `AceEditor`
806
+ of `JsonConfig` / `JsonConfigComponent`. `react-ace` brings the whole `ace-builds` with it, and it
807
+ would otherwise land in every bundle that uses this library, custom components of adapters included,
808
+ although only three of the sixty controls ever show an editor. Without it the field falls back to a
809
+ plain text area, which can still be read and written.
810
+
805
811
  ### `yamlEditor`
806
812
 
807
813
  Button to open a YAML editor with syntax validation. (From admin version 7.7.30)
@@ -931,10 +937,10 @@ allow the user to select a date input the returned string is a parseable date st
931
937
 
932
938
  horizontal line
933
939
 
934
- | Property | Description |
935
- |----------|--------------------------------------------------|
936
- | `height` | optional height |
937
- | `color` | optional divider color or `primary`, `secondary` |
940
+ | Property | Description |
941
+ |----------|-------------------------------------------------------------------|
942
+ | `height` | optional height: a number in pixels or any CSS length, like `1px` |
943
+ | `color` | optional divider color: any CSS color, or `primary`, `secondary` |
938
944
 
939
945
  ### `header`
940
946
 
@@ -1367,6 +1373,8 @@ Special input for ports. It checks automatically if the port is used by other in
1367
1373
  | `setOnEnterKey` | The value in this case will be sent only when the "Enter" button is pressed. It can be combined with `showEnterButton` |
1368
1374
  | `options` | Options for `select` in form `["value1", "value2", ...]` or `[{"value": "value", "label": "Value1", "color": "red"}, "value2", ...]`. If not defiled, the `common.states` in the object must exist. |
1369
1375
  | `digits` | Number of decimal places to display for numeric values in `text`/`html` mode (e.g. `2` turns `230.2764537654374` into `230.28`) |
1376
+ | `ack` | Write the value as acknowledged. A control writes a command by default (`false`), so that the adapter reacts to it |
1377
+ | `highlight` | Highlight the line on mouse over |
1370
1378
 
1371
1379
  ### `staticInfo`
1372
1380
 
@@ -1948,6 +1956,17 @@ The schema is used here: https://github.com/SchemaStore/schemastore/blob/6da29cd
1948
1956
  ### **WORK IN PROGRESS**
1949
1957
  -->
1950
1958
  ## Changelog
1959
+ ### 10.0.0 (2026-09-04)
1960
+
1961
+ - (@GermanBluefox) The schema allows the root property `command` of a JSON tab now. It was documented and honoured by admin, but every `jsonTab.json5` that uses it was reported as invalid: https://github.com/ioBroker/ioBroker.admin/issues/3610
1962
+ - (@GermanBluefox) The schema of `divider` accepts any CSS color and a height as a CSS length, as the control has always rendered them. Until now only `primary`/`secondary` and a number were allowed
1963
+ - (@GermanBluefox) Added `ack` to the `state` control: the value is written as a command (`ack: false`) by default, as before, and an adapter that only shows its own value can now ask for an acknowledged write
1964
+ - (@GermanBluefox) Added `highlight` to the `state` control, which highlights the line on mouse over, like `staticInfo` already did
1965
+ - (@GermanBluefox) **Breaking for hosts:** `react-ace` is not a dependency of this library anymore. The host hands the editor in with the new property `AceEditor` of `JsonConfig` / `JsonConfigComponent`, together with the modes `json`, `json5`, `yaml` and the themes `clouds_midnight`, `chrome`. Without it the editors are plain text areas. Until now every bundle that uses this library carried the whole `ace-builds` along, the custom components of all adapters included
1966
+
1967
+ ### 9.1.2 (2026-09-01)
1968
+ - (@GermanBluefox) Replaced `react-color` with the `ColorPicker` from `@iobroker/gui-components` in the `color` component
1969
+
1951
1970
  ### 9.1.1 (2026-08-31)
1952
1971
  - (@GermanBluefox) Do not show export import on narrow devices
1953
1972
 
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { I18n, Router, type AdminConnection, type IobTheme, type ThemeName, type ThemeType } from '@iobroker/gui-components';
3
3
  import type { ConfigItemAny, ConfigItemPanel, ConfigItemTabs } from './types';
4
4
  import ConfigGeneric, { type ConfigGenericProps, type DeviceManagerPropsProps } from './JsonConfigComponent/ConfigGeneric';
5
+ import type { AceEditorComponent } from './JsonConfigComponent/wrapper/Components/Editor';
5
6
  interface JsonConfigProps {
6
7
  adapterName: string;
7
8
  instance: number;
@@ -18,6 +19,8 @@ interface JsonConfigProps {
18
19
  configStored: (notChanged: boolean) => void;
19
20
  width: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
20
21
  DeviceManager?: React.FC<DeviceManagerPropsProps>;
22
+ /** Code editor for the editor items, see `JsonConfigComponentProps.AceEditor` */
23
+ AceEditor?: AceEditorComponent;
21
24
  customComponents?: {
22
25
  [componentType: string]: typeof ConfigGeneric<ConfigGenericProps, any>;
23
26
  };
@@ -566,7 +566,7 @@ class JsonConfig extends Router {
566
566
  else if (saveConfigDialog !== undefined) {
567
567
  this.setState({ saveConfigDialog });
568
568
  }
569
- }, DeviceManager: this.props.DeviceManager, theme: this.state.theme, customComponents: this.props.customComponents, imagePrefix: '.' }),
569
+ }, DeviceManager: this.props.DeviceManager, AceEditor: this.props.AceEditor, theme: this.state.theme, customComponents: this.props.customComponents, imagePrefix: '.' }),
570
570
  React.createElement(SaveCloseButtons, { isIFrame: false, dense: true, paddingLeft: 0, newReact: true, theme: this.state.theme, noTextOnButtons: this.props.width === 'xs' || this.props.width === 'sm' || this.props.width === 'md', changed: !!(this.state.error || this.state.changed), error: !!this.state.error, onSave: (close) => this.onSave(true, close), onClose: () => this.onSave(false) })));
571
571
  }
572
572
  }
@@ -1 +1 @@
1
- {"version":3,"file":"JsonConfig.js","sourceRoot":"src/","sources":["JsonConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,eAAe,CAAC;AAEhC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EACH,IAAI,EACJ,MAAM,EACN,gBA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AAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;oBAClE,CAAC;yBAAM,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;wBACxC,IAAI,CAAC,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC;oBACxC,CAAC;gBACL,CAAC,EACD,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAC7C,WAAW,EAAE,GAAG,GAClB;YACF,oBAAC,gBAAgB,IACb,QAAQ,EAAE,KAAK,EACf,KAAK,QACL,WAAW,EAAE,CAAC,EACd,QAAQ,QACR,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,eAAe,EACX,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,EAEvF,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EACnD,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EACzB,MAAM,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EACpD,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GACnC,CACA,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,UAAU,CAAC","sourcesContent":["import React from 'react';\nimport JSON5 from 'json5';\nimport MD5 from 'crypto-js/md5';\n\nimport { Box, Fab, Tooltip, LinearProgress } from '@mui/material';\nimport { Publish as PublishIcon } from '@mui/icons-material';\n\nimport {\n I18n,\n Router,\n SaveCloseButtons,\n Theme,\n DialogConfirm,\n type AdminConnection,\n type IobTheme,\n type ThemeName,\n type ThemeType,\n Utils,\n} from '@iobroker/gui-components';\n\nimport type { ConfigItemAny, ConfigItemPanel, ConfigItemTabs } from './types';\nimport ConfigGeneric, {\n type ConfigGenericProps,\n type DeviceManagerPropsProps,\n} from './JsonConfigComponent/ConfigGeneric';\nimport JsonConfigComponent from './JsonConfigComponent';\n\nconst styles: Record<string, React.CSSProperties> = {\n root: {\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n position: 'relative',\n },\n scroll: {\n height: 'calc(100% - 48px)',\n overflowY: 'auto',\n },\n exportImportButtons: {\n position: 'absolute',\n top: 5,\n right: 0,\n zIndex: 3,\n },\n button: {\n marginRight: '5px',\n },\n tooltip: {\n pointerEvents: 'none',\n },\n};\n\n/**\n * Decrypt the password/value with given key\n *\n * @param key - Secret key\n * @param value - value to decrypt\n */\nfunction decryptLegacy(key: string, value: string): string {\n let result = '';\n for (let i = 0; i < value.length; i++) {\n result += String.fromCharCode(key[i % key.length].charCodeAt(0) ^ value.charCodeAt(i));\n }\n return result;\n}\n\n/**\n * Encrypt the password/value with given key\n *\n * @param key - Secret key\n * @param value - value to encrypt\n */\nfunction encryptLegacy(key: string, value: string): string {\n let result = '';\n for (let i = 0; i < value.length; i++) {\n result += String.fromCharCode(key[i % key.length].charCodeAt(0) ^ value.charCodeAt(i));\n }\n return result;\n}\n\n/**\n * Decrypt the password/value with the given key\n * Usage:\n * ```js\n * function load(settings, onChange) {\n * if (settings.password) {\n * settings.password = decrypt(systemSecret, settings.password);\n * // same as\n * settings.password = decrypt(settings.password);\n * }\n * // ...\n * }\n * ```\n *\n * @param key - Secret key\n * @param value - value to decrypt\n */\nfunction decrypt(key: string, value: string): string {\n if (typeof value !== 'string') {\n return value;\n }\n\n // if not encrypted as aes-192 or key not a valid 48-digit hex -> fallback\n if (!value.startsWith('$/aes-192-cbc:') || !/^[0-9a-f]{48}$/.test(key)) {\n return decryptLegacy(key, value);\n }\n\n // algorithm:iv:encryptedValue\n const textParts = value.split(':', 3);\n\n const _key = window.CryptoJS.enc.Hex.parse(key);\n const iv = window.CryptoJS.enc.Hex.parse(textParts[1]);\n\n const cipherParams = window.CryptoJS.lib.CipherParams.create({\n ciphertext: window.CryptoJS.enc.Hex.parse(textParts[2]),\n });\n\n const decryptedBinary = window.CryptoJS.AES.decrypt(cipherParams, _key, { iv });\n\n return window.CryptoJS.enc.Utf8.stringify(decryptedBinary);\n}\n\n/**\n * Encrypt the password/value with given key\n * Usage:\n * ```\n * function save(callback) {\n * ...\n * if (obj.password) {\n * obj.password = encrypt(systemSecret, obj.password);\n * // same as\n * obj.password = decrypt(obj.password);\n * }\n * ...\n * }\n * ```\n *\n * @param key - Secret key\n * @param value - value to encrypt\n * @param _iv - optional initial vector for tests\n */\nfunction encrypt(key: string, value: string, _iv?: string): string {\n if (typeof value !== 'string') {\n return value;\n }\n\n if (!/^[0-9a-f]{48}$/.test(key)) {\n // key length is not matching for AES-192-CBC, or key is no valid hex - fallback to old encryption\n return encryptLegacy(key, value);\n }\n\n let iv;\n if (_iv) {\n iv = window.CryptoJS.enc.Hex.parse(_iv);\n } else {\n iv = window.CryptoJS.lib.WordArray.random(128 / 8);\n }\n\n const _key = window.CryptoJS.enc.Hex.parse(key);\n const encrypted = window.CryptoJS.AES.encrypt(value, _key, { iv }).ciphertext;\n\n return `$/aes-192-cbc:${window.CryptoJS.enc.Hex.stringify(iv)}:${encrypted}`;\n}\n\nfunction loadScript(\n src: string,\n id: string,\n): ((this: GlobalEventHandlers, ev: Event) => any) | null | undefined | Promise<void> {\n if (!id || !document.getElementById(id)) {\n return new Promise(resolve => {\n const script = document.createElement('script');\n script.setAttribute('id', id);\n script.onload = resolve as unknown as (this: GlobalEventHandlers, ev: Event) => any;\n script.src = src;\n document.getElementsByTagName('head')[0].appendChild(script);\n });\n }\n return document.getElementById(id)?.onload;\n}\n\ninterface BufferObject {\n type: 'Buffer';\n data: Buffer;\n}\n\ninterface JsonConfigProps {\n adapterName: string;\n instance: number;\n isFloatComma: boolean;\n dateFormat: string;\n secret?: string;\n socket: AdminConnection;\n theme: IobTheme;\n themeName: ThemeName;\n themeType: ThemeType;\n expertMode?: boolean;\n /** Translate method */\n t: typeof I18n.t;\n configStored: (notChanged: boolean) => void;\n width: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n DeviceManager?: React.FC<DeviceManagerPropsProps>;\n customComponents?: { [componentType: string]: typeof ConfigGeneric<ConfigGenericProps, any> };\n}\n\ninterface JsonConfigState {\n schema?: ConfigItemPanel | ConfigItemTabs;\n data?: Record<string, unknown>;\n originalData?: Record<string, unknown>;\n updateData: number;\n common?: ioBroker.InstanceCommon;\n changed: boolean;\n confirmDialog: boolean;\n theme: IobTheme;\n saveConfigDialog: boolean;\n hash: string;\n error?: boolean;\n}\n\nclass JsonConfig extends Router<JsonConfigProps, JsonConfigState> {\n private fileSubscribed: string[] = [];\n\n private fileLangSubscribed = '';\n\n private secret: string;\n\n constructor(props: JsonConfigProps) {\n super(props);\n\n this.state = {\n updateData: 0,\n changed: false,\n confirmDialog: false,\n theme: Theme(props.themeName), // buttons require special theme\n saveConfigDialog: false,\n hash: '_',\n };\n\n this.secret = props.secret || '';\n\n void this.getInstanceObject().then(obj =>\n this.getConfigFile().then(schema =>\n // load language\n JsonConfigComponent.loadI18n(this.props.socket, schema?.i18n, this.props.adapterName).then(\n (langFileName: string) => {\n if (langFileName) {\n // subscribe on changes\n if (!this.fileLangSubscribed) {\n this.fileLangSubscribed = langFileName;\n void this.props.socket.subscribeFiles(\n `${this.props.adapterName}.admin`,\n this.fileLangSubscribed,\n this.onFileChange,\n );\n }\n }\n\n if (obj) {\n this.setState({\n schema: schema || undefined,\n data: obj.native,\n common: obj.common,\n hash: MD5(JSON.stringify(schema)).toString(),\n });\n } else {\n window.alert(\n `Instance system.adapter.${this.props.adapterName}.${this.props.instance} not found!`,\n );\n }\n },\n ),\n ),\n );\n }\n\n componentWillUnmount(): void {\n super.componentWillUnmount();\n if (this.fileSubscribed.length) {\n this.props.socket.unsubscribeFiles(\n `${this.props.adapterName}.admin`,\n this.fileSubscribed,\n this.onFileChange,\n );\n this.fileSubscribed = [];\n }\n if (this.fileLangSubscribed) {\n this.props.socket.unsubscribeFiles(\n `${this.props.adapterName}.admin`,\n this.fileLangSubscribed,\n this.onFileChange,\n );\n this.fileLangSubscribed = '';\n }\n }\n\n private handleFileSelect = (evt: Record<string, any>): void => {\n const f = evt.target.files[0];\n if (f) {\n const r = new FileReader();\n r.onload = (e: ProgressEvent<FileReader>): void => {\n if (!e.target) {\n return;\n }\n\n const contents = e.target.result as string;\n try {\n const data = JSON.parse(contents);\n this.setState({ data, changed: JSON.stringify(data) !== JSON.stringify(this.state.originalData) });\n } catch {\n window.alert(I18n.t('jc_[JsonConfig] Failed to parse JSON file'));\n }\n };\n r.readAsText(f);\n } else {\n window.alert(I18n.t('jc_[JsonConfig] Failed to open JSON File'));\n }\n };\n\n getExportImportButtons(): React.JSX.Element {\n return (\n <Box\n sx={{\n ...styles.exportImportButtons,\n // On xs displays the buttons would hide the tabs, so do not show them there\n display: { xs: 'none', sm: 'block' },\n }}\n >\n <Tooltip\n title={this.props.t('jc_Import settings from JSON file')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <Fab\n size=\"small\"\n sx={{ '&.MuiFab-root': styles.button }}\n onClick={() => {\n const input = document.createElement('input');\n input.setAttribute('type', 'file');\n input.setAttribute('id', 'files');\n // @ts-expect-error check\n input.setAttribute('opacity', 0);\n input.addEventListener('change', e => this.handleFileSelect(e), false);\n input.click();\n }}\n >\n <PublishIcon />\n </Fab>\n </Tooltip>\n <Tooltip\n title={this.props.t('jc_Export setting to JSON file')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <Fab\n size=\"small\"\n sx={{ '&.MuiFab-root': styles.button }}\n onClick={() => {\n if (!this.state.data) {\n return;\n }\n\n Utils.generateFile(\n `${this.props.adapterName}.${this.props.instance}.json`,\n this.state.data,\n );\n }}\n >\n <PublishIcon style={{ transform: 'rotate(180deg)' }} />\n </Fab>\n </Tooltip>\n </Box>\n );\n }\n\n onFileChange = async (id: string, fileName: string, size: number | null): Promise<void> => {\n if (id === `${this.props.adapterName}.admin` && size) {\n if (fileName === this.fileLangSubscribed) {\n try {\n await JsonConfigComponent.loadI18n(\n this.props.socket,\n this.state.schema?.i18n,\n this.props.adapterName,\n );\n this.setState({ hash: `${this.state.hash}1` });\n } catch {\n // ignore errors\n }\n } else if (this.fileSubscribed.includes(fileName)) {\n try {\n const schema = await this.getConfigFile(this.fileSubscribed[0]);\n this.setState({ schema: schema || undefined, hash: MD5(JSON.stringify(schema)).toString() });\n } catch {\n // ignore errors\n }\n }\n }\n };\n\n async getInstanceObject(): Promise<ioBroker.InstanceObject | null> {\n try {\n const obj = await this.props.socket.getObject(\n `system.adapter.${this.props.adapterName}.${this.props.instance}`,\n );\n // decode all native attributes listed in obj.encryptedNative\n if (Array.isArray(obj?.encryptedNative)) {\n if (!this.secret) {\n const systemConfig = await this.props.socket.getSystemConfig();\n await loadScript('../../lib/js/crypto-js/crypto-js.js', 'crypto-js');\n this.secret = systemConfig.native.secret;\n }\n obj.encryptedNative?.forEach(attr => {\n if (obj.native[attr]) {\n obj.native[attr] = decrypt(this.secret, obj.native[attr]);\n }\n });\n return obj;\n }\n return obj || null;\n } catch (e) {\n window.alert(`[JsonConfig] Cannot read instance object: ${e}`);\n }\n return null;\n }\n\n renderDialogConfirm(): React.JSX.Element | null {\n if (!this.state.confirmDialog) {\n return null;\n }\n return (\n <DialogConfirm\n title={I18n.t('jc_Please confirm')}\n text={I18n.t('jc_Some data are not stored. Discard?')}\n ok={I18n.t('jc_Discard')}\n cancel={I18n.t('jc_Cancel')}\n onClose={(isYes: boolean) =>\n this.setState({ confirmDialog: false }, () => isYes && Router.doNavigate(null))\n }\n />\n );\n }\n\n async scanForInclude(json: Record<string, any>, filePaths: string[]): Promise<Record<string, any>> {\n if (typeof json['#include'] === 'string') {\n // load file\n const data = await this._getConfigFile(json['#include'], [...filePaths]);\n delete json['#include'];\n if (data) {\n // merge data\n json = { ...json, ...data };\n }\n return json;\n }\n const keys = Object.keys(json);\n for (let k = 0; k < keys.length; k++) {\n if (json[keys[k]] && typeof json[keys[k]] === 'object') {\n json[keys[k]] = await this.scanForInclude(json[keys[k]], filePaths);\n }\n }\n return json;\n }\n\n async getConfigFile(fileName?: string): Promise<ConfigItemPanel | ConfigItemTabs | null> {\n return this._getConfigFile(fileName);\n }\n\n async _getConfigFile(fileName?: string, _filePaths?: string[]): Promise<ConfigItemPanel | ConfigItemTabs | null> {\n fileName = fileName || 'jsonConfig.json5';\n _filePaths = _filePaths || [];\n\n if (_filePaths.includes(fileName)) {\n window.alert(`[JsonConfig] Circular reference in file: ${fileName} => ${_filePaths.join(' => ')}`);\n return null;\n }\n _filePaths.push(fileName);\n\n try {\n const exist = await this.props.socket.fileExists(`${this.props.adapterName}.admin`, fileName);\n if (!exist) {\n fileName = 'jsonConfig.json';\n }\n const data: {\n file: string;\n mimeType: string;\n } = await this.props.socket.readFile(`${this.props.adapterName}.admin`, fileName);\n let content = '';\n let file: string | BufferObject = '';\n\n if (data.file !== undefined) {\n file = data.file;\n }\n\n if (typeof file === 'string') {\n content = file;\n // @ts-expect-error revisit\n } else if (file.type === 'Buffer') {\n let binary = '';\n // @ts-expect-error revisit\n const bytes = new Uint8Array(file.data);\n const len = bytes.byteLength;\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n content = binary;\n }\n\n // subscribe on changes\n if (!this.fileSubscribed.includes(fileName)) {\n this.fileSubscribed.push(fileName);\n await this.props.socket.subscribeFiles(`${this.props.adapterName}.admin`, fileName, this.onFileChange);\n }\n\n try {\n // detect #include attr\n return (await this.scanForInclude(JSON5.parse(content), _filePaths)) as\n ConfigItemPanel | ConfigItemTabs;\n } catch (e) {\n window.alert('[JsonConfig] Cannot parse json5 config!');\n console.log(e);\n }\n } catch (e1) {\n if (!this.state.schema) {\n window.alert(`[JsonConfig] Cannot read file \"${fileName}: ${e1}`);\n }\n }\n return null;\n }\n\n renderSaveConfigDialog(): React.JSX.Element | null {\n if (!this.state.saveConfigDialog) {\n return null;\n }\n return (\n <DialogConfirm\n title={I18n.t('jc_Please confirm')}\n text={I18n.t('jc_Save configuration?')}\n ok={I18n.t('jc_Save')}\n cancel={I18n.t('jc_Cancel')}\n onClose={(isYes: boolean) =>\n this.setState({ saveConfigDialog: false }, () => isYes && this.onSave(true))\n }\n />\n );\n }\n\n findAttr(attr: string, schema?: ConfigItemPanel | ConfigItemTabs): ConfigItemAny | null {\n schema = schema || this.state.schema;\n if (schema?.items) {\n if (attr in schema.items) {\n return schema.items[attr];\n }\n for (const _item of Object.values(schema.items)) {\n const item = this.findAttr(attr, _item as ConfigItemPanel | ConfigItemTabs);\n if (item) {\n return item;\n }\n }\n }\n\n return null;\n }\n\n // this function is called recursively and trims all text fields that must be trimmed\n postProcessing(data: Record<string, unknown>, attr: string, schema: ConfigItemAny): void {\n schema = schema || this.state.schema;\n if (!data) {\n // should not happen\n console.error(`Data is empty in postProcessing: ${attr}, ${JSON.stringify(schema)}`);\n return;\n }\n\n const dataAttr = data[attr];\n\n if ((schema as ConfigItemTabs).items) {\n if (schema.type === 'table') {\n const table = dataAttr;\n\n if (!Array.isArray(table)) {\n return;\n }\n\n for (const entry of table) {\n if (schema.items) {\n for (const tItem of schema.items) {\n if (tItem.attr) {\n this.postProcessing(entry, tItem.attr, tItem);\n }\n }\n }\n }\n } else {\n for (const [_attr, item] of Object.entries((schema as ConfigItemTabs).items)) {\n if (\n (item as any).type === 'panel' ||\n (item as any).type === 'tabs' ||\n (item as any).type === 'accordion'\n ) {\n return;\n }\n this.postProcessing(data, _attr, item);\n }\n }\n } else if (attr && typeof dataAttr === 'string') {\n // postprocessing\n if (schema.type === 'text') {\n if (schema.trim !== false) {\n data[attr] = dataAttr.trim();\n }\n } else if (schema.type === 'ip') {\n // should not happen\n data[attr] = dataAttr.trim();\n } else if (schema.type === 'number') {\n const dataVal = parseFloat(dataAttr.toString().replace(',', '.'));\n\n if (schema.min !== undefined && dataVal < schema.min) {\n data[attr] = schema.min;\n } else if (schema.max !== undefined && dataVal > schema.max) {\n data[attr] = schema.max;\n } else {\n data[attr] = dataVal;\n }\n } else if (schema.type === 'port') {\n const dataVal = parseInt(dataAttr.toString(), 10);\n if (schema.min !== undefined && dataVal < schema.min) {\n data[attr] = schema.min;\n } else if (schema.max !== undefined && dataVal > schema.max) {\n data[attr] = schema.max;\n }\n if (data[attr] !== 0 && dataVal < 20) {\n data[attr] = 20;\n } else if (dataVal > 0xffff) {\n data[attr] = 0xffff;\n } else {\n data[attr] = dataVal;\n }\n } else if (schema.type === 'checkbox') {\n // should not happen\n data[attr] =\n data[attr] === true ||\n data[attr] === 'true' ||\n data[attr] === 'on' ||\n data[attr] === 1 ||\n data[attr] === '1';\n }\n }\n }\n\n async onSave(doSave: boolean, close?: boolean): Promise<void> {\n if (doSave) {\n const obj = await this.getInstanceObject();\n\n if (!obj) {\n console.error('Something went wrong: may be no connection?');\n window.alert('Something went wrong: may be no connection?');\n return;\n }\n\n if (!this.state.data || !this.state.schema) {\n return;\n }\n\n const doNotSaveAttributes: Record<string, any> = {};\n\n for (const attr of Object.keys(this.state.data)) {\n const item = this.findAttr(attr);\n if ((!item || !item.doNotSave || item.type === 'state') && !attr.startsWith('_')) {\n ConfigGeneric.setValue(obj.native, attr, this.state.data[attr]);\n } else {\n ConfigGeneric.setValue(obj.native, attr, null);\n doNotSaveAttributes[attr] = this.state.data[attr];\n }\n }\n\n try {\n const encryptedObj = JSON.parse(JSON.stringify(obj));\n // encode all native attributes listed in obj.encryptedNative\n if (Array.isArray(encryptedObj.encryptedNative)) {\n await loadScript('../../lib/js/crypto-js/crypto-js.js', 'crypto-js');\n\n for (const attr of encryptedObj.encryptedNative) {\n if (encryptedObj.native[attr]) {\n encryptedObj.native[attr] = encrypt(this.secret, encryptedObj.native[attr]);\n }\n }\n }\n\n await this.props.socket.setObject(encryptedObj._id, encryptedObj);\n } catch (e) {\n window.alert(`[JsonConfig] Cannot set object: ${e}`);\n }\n\n /** We want to preserve the doNotSaveAttributes too, just not save it */\n const nativeWithNonSaved = { ...obj.native, ...doNotSaveAttributes };\n console.log(nativeWithNonSaved);\n\n this.setState(\n {\n changed: false,\n data: nativeWithNonSaved,\n updateData: this.state.updateData + 1,\n originalData: nativeWithNonSaved,\n },\n () => close && Router.doNavigate(null),\n );\n } else if (this.state.changed) {\n this.setState({ confirmDialog: true });\n } else {\n Router.doNavigate(null);\n }\n }\n\n componentDidUpdate(_prevProps: JsonConfigProps, prevState: JsonConfigState): void {\n if (prevState.changed !== this.state.changed) {\n this.props.configStored(!this.state.changed);\n }\n }\n\n /**\n * Validate the JSON config once on mount\n */\n async componentDidMount(): Promise<void> {\n const link = `${window.location.protocol}//${window.location.host}${window.location.pathname}validate_config/${this.props.adapterName}`;\n console.log(`fetch ${link}`);\n await fetch(link);\n }\n\n render(): React.JSX.Element {\n if (!this.state.data || !this.state.schema) {\n return <LinearProgress />;\n }\n\n return (\n <div style={styles.root}>\n {this.renderDialogConfirm()}\n {this.getExportImportButtons()}\n {this.renderSaveConfigDialog()}\n <JsonConfigComponent\n key={this.state.hash}\n style={styles.scroll}\n socket={this.props.socket}\n themeName={this.props.themeName}\n themeType={this.props.themeType}\n adapterName={this.props.adapterName}\n instance={this.props.instance}\n isFloatComma={this.props.isFloatComma}\n dateFormat={this.props.dateFormat}\n schema={this.state.schema}\n common={this.state.common}\n expertMode={this.props.expertMode}\n data={this.state.data}\n updateData={this.state.updateData}\n onError={error => this.setState({ error })}\n onChange={(data, changed, saveConfigDialog) => {\n if (saveConfigDialog && this.state.error) {\n window.alert(I18n.t('jc_Cannot save configuration because of error in configuration'));\n saveConfigDialog = false;\n }\n if (saveConfigDialog && !this.state.changed && !changed) {\n saveConfigDialog = false;\n }\n if (data) {\n this.setState({ data, changed: !!changed, saveConfigDialog });\n } else if (saveConfigDialog !== undefined) {\n this.setState({ saveConfigDialog });\n }\n }}\n DeviceManager={this.props.DeviceManager}\n theme={this.state.theme}\n customComponents={this.props.customComponents}\n imagePrefix={'.'}\n />\n <SaveCloseButtons\n isIFrame={false}\n dense\n paddingLeft={0}\n newReact\n theme={this.state.theme}\n noTextOnButtons={\n this.props.width === 'xs' || this.props.width === 'sm' || this.props.width === 'md'\n }\n changed={!!(this.state.error || this.state.changed)}\n error={!!this.state.error}\n onSave={(close: boolean) => this.onSave(true, close)}\n onClose={() => this.onSave(false)}\n />\n </div>\n );\n }\n}\n\nexport default JsonConfig;\n"]}
1
+ {"version":3,"file":"JsonConfig.js","sourceRoot":"src/","sources":["JsonConfig.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,eAAe,CAAC;AAEhC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EACH,IAAI,EACJ,MAAM,EACN,gBAAgB,EAChB,KAAK,EACL,aAAa,EAKb,KAAK,GACR,MAAM,0BAA0B,CAAC;AAGlC,OAAO,aAGN,MAAM,qCAAqC,CAAC;AAC7C,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAGxD,MAAM,MAAM,GAAwC;IAChD,IAAI,EAAE;QACF,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,UAAU;KACvB;IACD,MAAM,EAAE;QACJ,MAAM,EAAE,mBAAmB;QAC3B,SAAS,EAAE,MAAM;KACpB;IACD,mBAAmB,EAAE;QACjB,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,CAAC;QACN,KAAK,EAAE,C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F,oBAAC,gBAAgB,IACb,QAAQ,EAAE,KAAK,EACf,KAAK,QACL,WAAW,EAAE,CAAC,EACd,QAAQ,QACR,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,eAAe,EACX,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,EAEvF,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EACnD,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EACzB,MAAM,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EACpD,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GACnC,CACA,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,UAAU,CAAC","sourcesContent":["import React from 'react';\nimport JSON5 from 'json5';\nimport MD5 from 'crypto-js/md5';\n\nimport { Box, Fab, Tooltip, LinearProgress } from '@mui/material';\nimport { Publish as PublishIcon } from '@mui/icons-material';\n\nimport {\n I18n,\n Router,\n SaveCloseButtons,\n Theme,\n DialogConfirm,\n type AdminConnection,\n type IobTheme,\n type ThemeName,\n type ThemeType,\n Utils,\n} from '@iobroker/gui-components';\n\nimport type { ConfigItemAny, ConfigItemPanel, ConfigItemTabs } from './types';\nimport ConfigGeneric, {\n type ConfigGenericProps,\n type DeviceManagerPropsProps,\n} from './JsonConfigComponent/ConfigGeneric';\nimport JsonConfigComponent from './JsonConfigComponent';\nimport type { AceEditorComponent } from './JsonConfigComponent/wrapper/Components/Editor';\n\nconst styles: Record<string, React.CSSProperties> = {\n root: {\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n position: 'relative',\n },\n scroll: {\n height: 'calc(100% - 48px)',\n overflowY: 'auto',\n },\n exportImportButtons: {\n position: 'absolute',\n top: 5,\n right: 0,\n zIndex: 3,\n },\n button: {\n marginRight: '5px',\n },\n tooltip: {\n pointerEvents: 'none',\n },\n};\n\n/**\n * Decrypt the password/value with given key\n *\n * @param key - Secret key\n * @param value - value to decrypt\n */\nfunction decryptLegacy(key: string, value: string): string {\n let result = '';\n for (let i = 0; i < value.length; i++) {\n result += String.fromCharCode(key[i % key.length].charCodeAt(0) ^ value.charCodeAt(i));\n }\n return result;\n}\n\n/**\n * Encrypt the password/value with given key\n *\n * @param key - Secret key\n * @param value - value to encrypt\n */\nfunction encryptLegacy(key: string, value: string): string {\n let result = '';\n for (let i = 0; i < value.length; i++) {\n result += String.fromCharCode(key[i % key.length].charCodeAt(0) ^ value.charCodeAt(i));\n }\n return result;\n}\n\n/**\n * Decrypt the password/value with the given key\n * Usage:\n * ```js\n * function load(settings, onChange) {\n * if (settings.password) {\n * settings.password = decrypt(systemSecret, settings.password);\n * // same as\n * settings.password = decrypt(settings.password);\n * }\n * // ...\n * }\n * ```\n *\n * @param key - Secret key\n * @param value - value to decrypt\n */\nfunction decrypt(key: string, value: string): string {\n if (typeof value !== 'string') {\n return value;\n }\n\n // if not encrypted as aes-192 or key not a valid 48-digit hex -> fallback\n if (!value.startsWith('$/aes-192-cbc:') || !/^[0-9a-f]{48}$/.test(key)) {\n return decryptLegacy(key, value);\n }\n\n // algorithm:iv:encryptedValue\n const textParts = value.split(':', 3);\n\n const _key = window.CryptoJS.enc.Hex.parse(key);\n const iv = window.CryptoJS.enc.Hex.parse(textParts[1]);\n\n const cipherParams = window.CryptoJS.lib.CipherParams.create({\n ciphertext: window.CryptoJS.enc.Hex.parse(textParts[2]),\n });\n\n const decryptedBinary = window.CryptoJS.AES.decrypt(cipherParams, _key, { iv });\n\n return window.CryptoJS.enc.Utf8.stringify(decryptedBinary);\n}\n\n/**\n * Encrypt the password/value with given key\n * Usage:\n * ```\n * function save(callback) {\n * ...\n * if (obj.password) {\n * obj.password = encrypt(systemSecret, obj.password);\n * // same as\n * obj.password = decrypt(obj.password);\n * }\n * ...\n * }\n * ```\n *\n * @param key - Secret key\n * @param value - value to encrypt\n * @param _iv - optional initial vector for tests\n */\nfunction encrypt(key: string, value: string, _iv?: string): string {\n if (typeof value !== 'string') {\n return value;\n }\n\n if (!/^[0-9a-f]{48}$/.test(key)) {\n // key length is not matching for AES-192-CBC, or key is no valid hex - fallback to old encryption\n return encryptLegacy(key, value);\n }\n\n let iv;\n if (_iv) {\n iv = window.CryptoJS.enc.Hex.parse(_iv);\n } else {\n iv = window.CryptoJS.lib.WordArray.random(128 / 8);\n }\n\n const _key = window.CryptoJS.enc.Hex.parse(key);\n const encrypted = window.CryptoJS.AES.encrypt(value, _key, { iv }).ciphertext;\n\n return `$/aes-192-cbc:${window.CryptoJS.enc.Hex.stringify(iv)}:${encrypted}`;\n}\n\nfunction loadScript(\n src: string,\n id: string,\n): ((this: GlobalEventHandlers, ev: Event) => any) | null | undefined | Promise<void> {\n if (!id || !document.getElementById(id)) {\n return new Promise(resolve => {\n const script = document.createElement('script');\n script.setAttribute('id', id);\n script.onload = resolve as unknown as (this: GlobalEventHandlers, ev: Event) => any;\n script.src = src;\n document.getElementsByTagName('head')[0].appendChild(script);\n });\n }\n return document.getElementById(id)?.onload;\n}\n\ninterface BufferObject {\n type: 'Buffer';\n data: Buffer;\n}\n\ninterface JsonConfigProps {\n adapterName: string;\n instance: number;\n isFloatComma: boolean;\n dateFormat: string;\n secret?: string;\n socket: AdminConnection;\n theme: IobTheme;\n themeName: ThemeName;\n themeType: ThemeType;\n expertMode?: boolean;\n /** Translate method */\n t: typeof I18n.t;\n configStored: (notChanged: boolean) => void;\n width: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n DeviceManager?: React.FC<DeviceManagerPropsProps>;\n /** Code editor for the editor items, see `JsonConfigComponentProps.AceEditor` */\n AceEditor?: AceEditorComponent;\n customComponents?: { [componentType: string]: typeof ConfigGeneric<ConfigGenericProps, any> };\n}\n\ninterface JsonConfigState {\n schema?: ConfigItemPanel | ConfigItemTabs;\n data?: Record<string, unknown>;\n originalData?: Record<string, unknown>;\n updateData: number;\n common?: ioBroker.InstanceCommon;\n changed: boolean;\n confirmDialog: boolean;\n theme: IobTheme;\n saveConfigDialog: boolean;\n hash: string;\n error?: boolean;\n}\n\nclass JsonConfig extends Router<JsonConfigProps, JsonConfigState> {\n private fileSubscribed: string[] = [];\n\n private fileLangSubscribed = '';\n\n private secret: string;\n\n constructor(props: JsonConfigProps) {\n super(props);\n\n this.state = {\n updateData: 0,\n changed: false,\n confirmDialog: false,\n theme: Theme(props.themeName), // buttons require special theme\n saveConfigDialog: false,\n hash: '_',\n };\n\n this.secret = props.secret || '';\n\n void this.getInstanceObject().then(obj =>\n this.getConfigFile().then(schema =>\n // load language\n JsonConfigComponent.loadI18n(this.props.socket, schema?.i18n, this.props.adapterName).then(\n (langFileName: string) => {\n if (langFileName) {\n // subscribe on changes\n if (!this.fileLangSubscribed) {\n this.fileLangSubscribed = langFileName;\n void this.props.socket.subscribeFiles(\n `${this.props.adapterName}.admin`,\n this.fileLangSubscribed,\n this.onFileChange,\n );\n }\n }\n\n if (obj) {\n this.setState({\n schema: schema || undefined,\n data: obj.native,\n common: obj.common,\n hash: MD5(JSON.stringify(schema)).toString(),\n });\n } else {\n window.alert(\n `Instance system.adapter.${this.props.adapterName}.${this.props.instance} not found!`,\n );\n }\n },\n ),\n ),\n );\n }\n\n componentWillUnmount(): void {\n super.componentWillUnmount();\n if (this.fileSubscribed.length) {\n this.props.socket.unsubscribeFiles(\n `${this.props.adapterName}.admin`,\n this.fileSubscribed,\n this.onFileChange,\n );\n this.fileSubscribed = [];\n }\n if (this.fileLangSubscribed) {\n this.props.socket.unsubscribeFiles(\n `${this.props.adapterName}.admin`,\n this.fileLangSubscribed,\n this.onFileChange,\n );\n this.fileLangSubscribed = '';\n }\n }\n\n private handleFileSelect = (evt: Record<string, any>): void => {\n const f = evt.target.files[0];\n if (f) {\n const r = new FileReader();\n r.onload = (e: ProgressEvent<FileReader>): void => {\n if (!e.target) {\n return;\n }\n\n const contents = e.target.result as string;\n try {\n const data = JSON.parse(contents);\n this.setState({ data, changed: JSON.stringify(data) !== JSON.stringify(this.state.originalData) });\n } catch {\n window.alert(I18n.t('jc_[JsonConfig] Failed to parse JSON file'));\n }\n };\n r.readAsText(f);\n } else {\n window.alert(I18n.t('jc_[JsonConfig] Failed to open JSON File'));\n }\n };\n\n getExportImportButtons(): React.JSX.Element {\n return (\n <Box\n sx={{\n ...styles.exportImportButtons,\n // On xs displays the buttons would hide the tabs, so do not show them there\n display: { xs: 'none', sm: 'block' },\n }}\n >\n <Tooltip\n title={this.props.t('jc_Import settings from JSON file')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <Fab\n size=\"small\"\n sx={{ '&.MuiFab-root': styles.button }}\n onClick={() => {\n const input = document.createElement('input');\n input.setAttribute('type', 'file');\n input.setAttribute('id', 'files');\n // @ts-expect-error check\n input.setAttribute('opacity', 0);\n input.addEventListener('change', e => this.handleFileSelect(e), false);\n input.click();\n }}\n >\n <PublishIcon />\n </Fab>\n </Tooltip>\n <Tooltip\n title={this.props.t('jc_Export setting to JSON file')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <Fab\n size=\"small\"\n sx={{ '&.MuiFab-root': styles.button }}\n onClick={() => {\n if (!this.state.data) {\n return;\n }\n\n Utils.generateFile(\n `${this.props.adapterName}.${this.props.instance}.json`,\n this.state.data,\n );\n }}\n >\n <PublishIcon style={{ transform: 'rotate(180deg)' }} />\n </Fab>\n </Tooltip>\n </Box>\n );\n }\n\n onFileChange = async (id: string, fileName: string, size: number | null): Promise<void> => {\n if (id === `${this.props.adapterName}.admin` && size) {\n if (fileName === this.fileLangSubscribed) {\n try {\n await JsonConfigComponent.loadI18n(\n this.props.socket,\n this.state.schema?.i18n,\n this.props.adapterName,\n );\n this.setState({ hash: `${this.state.hash}1` });\n } catch {\n // ignore errors\n }\n } else if (this.fileSubscribed.includes(fileName)) {\n try {\n const schema = await this.getConfigFile(this.fileSubscribed[0]);\n this.setState({ schema: schema || undefined, hash: MD5(JSON.stringify(schema)).toString() });\n } catch {\n // ignore errors\n }\n }\n }\n };\n\n async getInstanceObject(): Promise<ioBroker.InstanceObject | null> {\n try {\n const obj = await this.props.socket.getObject(\n `system.adapter.${this.props.adapterName}.${this.props.instance}`,\n );\n // decode all native attributes listed in obj.encryptedNative\n if (Array.isArray(obj?.encryptedNative)) {\n if (!this.secret) {\n const systemConfig = await this.props.socket.getSystemConfig();\n await loadScript('../../lib/js/crypto-js/crypto-js.js', 'crypto-js');\n this.secret = systemConfig.native.secret;\n }\n obj.encryptedNative?.forEach(attr => {\n if (obj.native[attr]) {\n obj.native[attr] = decrypt(this.secret, obj.native[attr]);\n }\n });\n return obj;\n }\n return obj || null;\n } catch (e) {\n window.alert(`[JsonConfig] Cannot read instance object: ${e}`);\n }\n return null;\n }\n\n renderDialogConfirm(): React.JSX.Element | null {\n if (!this.state.confirmDialog) {\n return null;\n }\n return (\n <DialogConfirm\n title={I18n.t('jc_Please confirm')}\n text={I18n.t('jc_Some data are not stored. Discard?')}\n ok={I18n.t('jc_Discard')}\n cancel={I18n.t('jc_Cancel')}\n onClose={(isYes: boolean) =>\n this.setState({ confirmDialog: false }, () => isYes && Router.doNavigate(null))\n }\n />\n );\n }\n\n async scanForInclude(json: Record<string, any>, filePaths: string[]): Promise<Record<string, any>> {\n if (typeof json['#include'] === 'string') {\n // load file\n const data = await this._getConfigFile(json['#include'], [...filePaths]);\n delete json['#include'];\n if (data) {\n // merge data\n json = { ...json, ...data };\n }\n return json;\n }\n const keys = Object.keys(json);\n for (let k = 0; k < keys.length; k++) {\n if (json[keys[k]] && typeof json[keys[k]] === 'object') {\n json[keys[k]] = await this.scanForInclude(json[keys[k]], filePaths);\n }\n }\n return json;\n }\n\n async getConfigFile(fileName?: string): Promise<ConfigItemPanel | ConfigItemTabs | null> {\n return this._getConfigFile(fileName);\n }\n\n async _getConfigFile(fileName?: string, _filePaths?: string[]): Promise<ConfigItemPanel | ConfigItemTabs | null> {\n fileName = fileName || 'jsonConfig.json5';\n _filePaths = _filePaths || [];\n\n if (_filePaths.includes(fileName)) {\n window.alert(`[JsonConfig] Circular reference in file: ${fileName} => ${_filePaths.join(' => ')}`);\n return null;\n }\n _filePaths.push(fileName);\n\n try {\n const exist = await this.props.socket.fileExists(`${this.props.adapterName}.admin`, fileName);\n if (!exist) {\n fileName = 'jsonConfig.json';\n }\n const data: {\n file: string;\n mimeType: string;\n } = await this.props.socket.readFile(`${this.props.adapterName}.admin`, fileName);\n let content = '';\n let file: string | BufferObject = '';\n\n if (data.file !== undefined) {\n file = data.file;\n }\n\n if (typeof file === 'string') {\n content = file;\n // @ts-expect-error revisit\n } else if (file.type === 'Buffer') {\n let binary = '';\n // @ts-expect-error revisit\n const bytes = new Uint8Array(file.data);\n const len = bytes.byteLength;\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n content = binary;\n }\n\n // subscribe on changes\n if (!this.fileSubscribed.includes(fileName)) {\n this.fileSubscribed.push(fileName);\n await this.props.socket.subscribeFiles(`${this.props.adapterName}.admin`, fileName, this.onFileChange);\n }\n\n try {\n // detect #include attr\n return (await this.scanForInclude(JSON5.parse(content), _filePaths)) as\n ConfigItemPanel | ConfigItemTabs;\n } catch (e) {\n window.alert('[JsonConfig] Cannot parse json5 config!');\n console.log(e);\n }\n } catch (e1) {\n if (!this.state.schema) {\n window.alert(`[JsonConfig] Cannot read file \"${fileName}: ${e1}`);\n }\n }\n return null;\n }\n\n renderSaveConfigDialog(): React.JSX.Element | null {\n if (!this.state.saveConfigDialog) {\n return null;\n }\n return (\n <DialogConfirm\n title={I18n.t('jc_Please confirm')}\n text={I18n.t('jc_Save configuration?')}\n ok={I18n.t('jc_Save')}\n cancel={I18n.t('jc_Cancel')}\n onClose={(isYes: boolean) =>\n this.setState({ saveConfigDialog: false }, () => isYes && this.onSave(true))\n }\n />\n );\n }\n\n findAttr(attr: string, schema?: ConfigItemPanel | ConfigItemTabs): ConfigItemAny | null {\n schema = schema || this.state.schema;\n if (schema?.items) {\n if (attr in schema.items) {\n return schema.items[attr];\n }\n for (const _item of Object.values(schema.items)) {\n const item = this.findAttr(attr, _item as ConfigItemPanel | ConfigItemTabs);\n if (item) {\n return item;\n }\n }\n }\n\n return null;\n }\n\n // this function is called recursively and trims all text fields that must be trimmed\n postProcessing(data: Record<string, unknown>, attr: string, schema: ConfigItemAny): void {\n schema = schema || this.state.schema;\n if (!data) {\n // should not happen\n console.error(`Data is empty in postProcessing: ${attr}, ${JSON.stringify(schema)}`);\n return;\n }\n\n const dataAttr = data[attr];\n\n if ((schema as ConfigItemTabs).items) {\n if (schema.type === 'table') {\n const table = dataAttr;\n\n if (!Array.isArray(table)) {\n return;\n }\n\n for (const entry of table) {\n if (schema.items) {\n for (const tItem of schema.items) {\n if (tItem.attr) {\n this.postProcessing(entry, tItem.attr, tItem);\n }\n }\n }\n }\n } else {\n for (const [_attr, item] of Object.entries((schema as ConfigItemTabs).items)) {\n if (\n (item as any).type === 'panel' ||\n (item as any).type === 'tabs' ||\n (item as any).type === 'accordion'\n ) {\n return;\n }\n this.postProcessing(data, _attr, item);\n }\n }\n } else if (attr && typeof dataAttr === 'string') {\n // postprocessing\n if (schema.type === 'text') {\n if (schema.trim !== false) {\n data[attr] = dataAttr.trim();\n }\n } else if (schema.type === 'ip') {\n // should not happen\n data[attr] = dataAttr.trim();\n } else if (schema.type === 'number') {\n const dataVal = parseFloat(dataAttr.toString().replace(',', '.'));\n\n if (schema.min !== undefined && dataVal < schema.min) {\n data[attr] = schema.min;\n } else if (schema.max !== undefined && dataVal > schema.max) {\n data[attr] = schema.max;\n } else {\n data[attr] = dataVal;\n }\n } else if (schema.type === 'port') {\n const dataVal = parseInt(dataAttr.toString(), 10);\n if (schema.min !== undefined && dataVal < schema.min) {\n data[attr] = schema.min;\n } else if (schema.max !== undefined && dataVal > schema.max) {\n data[attr] = schema.max;\n }\n if (data[attr] !== 0 && dataVal < 20) {\n data[attr] = 20;\n } else if (dataVal > 0xffff) {\n data[attr] = 0xffff;\n } else {\n data[attr] = dataVal;\n }\n } else if (schema.type === 'checkbox') {\n // should not happen\n data[attr] =\n data[attr] === true ||\n data[attr] === 'true' ||\n data[attr] === 'on' ||\n data[attr] === 1 ||\n data[attr] === '1';\n }\n }\n }\n\n async onSave(doSave: boolean, close?: boolean): Promise<void> {\n if (doSave) {\n const obj = await this.getInstanceObject();\n\n if (!obj) {\n console.error('Something went wrong: may be no connection?');\n window.alert('Something went wrong: may be no connection?');\n return;\n }\n\n if (!this.state.data || !this.state.schema) {\n return;\n }\n\n const doNotSaveAttributes: Record<string, any> = {};\n\n for (const attr of Object.keys(this.state.data)) {\n const item = this.findAttr(attr);\n if ((!item || !item.doNotSave || item.type === 'state') && !attr.startsWith('_')) {\n ConfigGeneric.setValue(obj.native, attr, this.state.data[attr]);\n } else {\n ConfigGeneric.setValue(obj.native, attr, null);\n doNotSaveAttributes[attr] = this.state.data[attr];\n }\n }\n\n try {\n const encryptedObj = JSON.parse(JSON.stringify(obj));\n // encode all native attributes listed in obj.encryptedNative\n if (Array.isArray(encryptedObj.encryptedNative)) {\n await loadScript('../../lib/js/crypto-js/crypto-js.js', 'crypto-js');\n\n for (const attr of encryptedObj.encryptedNative) {\n if (encryptedObj.native[attr]) {\n encryptedObj.native[attr] = encrypt(this.secret, encryptedObj.native[attr]);\n }\n }\n }\n\n await this.props.socket.setObject(encryptedObj._id, encryptedObj);\n } catch (e) {\n window.alert(`[JsonConfig] Cannot set object: ${e}`);\n }\n\n /** We want to preserve the doNotSaveAttributes too, just not save it */\n const nativeWithNonSaved = { ...obj.native, ...doNotSaveAttributes };\n console.log(nativeWithNonSaved);\n\n this.setState(\n {\n changed: false,\n data: nativeWithNonSaved,\n updateData: this.state.updateData + 1,\n originalData: nativeWithNonSaved,\n },\n () => close && Router.doNavigate(null),\n );\n } else if (this.state.changed) {\n this.setState({ confirmDialog: true });\n } else {\n Router.doNavigate(null);\n }\n }\n\n componentDidUpdate(_prevProps: JsonConfigProps, prevState: JsonConfigState): void {\n if (prevState.changed !== this.state.changed) {\n this.props.configStored(!this.state.changed);\n }\n }\n\n /**\n * Validate the JSON config once on mount\n */\n async componentDidMount(): Promise<void> {\n const link = `${window.location.protocol}//${window.location.host}${window.location.pathname}validate_config/${this.props.adapterName}`;\n console.log(`fetch ${link}`);\n await fetch(link);\n }\n\n render(): React.JSX.Element {\n if (!this.state.data || !this.state.schema) {\n return <LinearProgress />;\n }\n\n return (\n <div style={styles.root}>\n {this.renderDialogConfirm()}\n {this.getExportImportButtons()}\n {this.renderSaveConfigDialog()}\n <JsonConfigComponent\n key={this.state.hash}\n style={styles.scroll}\n socket={this.props.socket}\n themeName={this.props.themeName}\n themeType={this.props.themeType}\n adapterName={this.props.adapterName}\n instance={this.props.instance}\n isFloatComma={this.props.isFloatComma}\n dateFormat={this.props.dateFormat}\n schema={this.state.schema}\n common={this.state.common}\n expertMode={this.props.expertMode}\n data={this.state.data}\n updateData={this.state.updateData}\n onError={error => this.setState({ error })}\n onChange={(data, changed, saveConfigDialog) => {\n if (saveConfigDialog && this.state.error) {\n window.alert(I18n.t('jc_Cannot save configuration because of error in configuration'));\n saveConfigDialog = false;\n }\n if (saveConfigDialog && !this.state.changed && !changed) {\n saveConfigDialog = false;\n }\n if (data) {\n this.setState({ data, changed: !!changed, saveConfigDialog });\n } else if (saveConfigDialog !== undefined) {\n this.setState({ saveConfigDialog });\n }\n }}\n DeviceManager={this.props.DeviceManager}\n AceEditor={this.props.AceEditor}\n theme={this.state.theme}\n customComponents={this.props.customComponents}\n imagePrefix={'.'}\n />\n <SaveCloseButtons\n isIFrame={false}\n dense\n paddingLeft={0}\n newReact\n theme={this.state.theme}\n noTextOnButtons={\n this.props.width === 'xs' || this.props.width === 'sm' || this.props.width === 'md'\n }\n changed={!!(this.state.error || this.state.changed)}\n error={!!this.state.error}\n onSave={(close: boolean) => this.onSave(true, close)}\n onClose={() => this.onSave(false)}\n />\n </div>\n );\n }\n}\n\nexport default JsonConfig;\n"]}
@@ -1,15 +1,10 @@
1
1
  import { type JSX } from 'react';
2
- import type { ConfigItemText } from '../types';
2
+ import type { ConfigItemColor } from '../types';
3
3
  import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
4
4
  interface ConfigColorProps extends ConfigGenericProps {
5
- schema: ConfigItemText;
5
+ schema: ConfigItemColor;
6
6
  }
7
- interface ConfigColorState extends ConfigGenericState {
8
- showColorDialog?: boolean;
9
- colorDialogValue?: string;
10
- }
11
- declare class ConfigColor extends ConfigGeneric<ConfigColorProps, ConfigColorState> {
12
- renderColorDialog(): JSX.Element | null;
7
+ declare class ConfigColor extends ConfigGeneric<ConfigColorProps, ConfigGenericState> {
13
8
  renderItem(_error: unknown, disabled: boolean): JSX.Element;
14
9
  }
15
10
  export default ConfigColor;
@@ -1,49 +1,23 @@
1
1
  import React from 'react';
2
- import { ChromePicker } from 'react-color';
3
- import { IconButton, TextField, Dialog } from '@mui/material';
4
- import { Close as ClearIcon } from '@mui/icons-material';
5
- import { Utils } from '@iobroker/gui-components';
2
+ import { ColorPicker } from '@iobroker/gui-components';
6
3
  import ConfigGeneric from './ConfigGeneric';
7
4
  class ConfigColor extends ConfigGeneric {
8
- renderColorDialog() {
9
- return this.state.showColorDialog ? (React.createElement(Dialog, { onClose: () => this.setState({ showColorDialog: false }), open: this.state.showColorDialog },
10
- React.createElement(ChromePicker, { color: this.state.colorDialogValue, onChange: (color) => this.setState({ colorDialogValue: color.hex }, () => this.props.attr && this.onChange(this.props.attr, this.state.colorDialogValue)) }))) : null;
11
- }
12
5
  renderItem(_error, disabled /* , defaultValue */) {
13
6
  const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
14
- const textColor = Utils.isUseBright(value);
15
- return (React.createElement(React.Fragment, null,
16
- this.renderColorDialog(),
17
- React.createElement(TextField, { variant: "standard", disabled: !!disabled, style: { minWidth: 100, width: 'calc(100% - 8px)' }, label: this.getText(this.props.schema.label), value: value || '', onClick: () => !this.props.schema.readOnly &&
18
- this.setState({ showColorDialog: true, colorDialogValue: value || '' }), onChange: e => {
19
- const color = e.target.value;
20
- const mayBePromise = this.props.attr && this.onChange(this.props.attr, color);
21
- if (mayBePromise instanceof Promise) {
22
- void mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));
23
- }
24
- }, slotProps: {
25
- htmlInput: {
26
- style: {
27
- // paddingLeft: noPadding ? 0 : 8,
28
- backgroundColor: value,
29
- color: textColor ? '#FFF' : '#000',
30
- },
31
- readOnly: this.props.schema.readOnly || false,
32
- },
33
- input: {
34
- endAdornment: !this.props.schema.readOnly && value && !this.props.schema.noClearButton ? (React.createElement(IconButton, { tabIndex: -1, size: "small", onClick: e => {
35
- e.stopPropagation();
36
- const mayBePromise = this.props.attr && this.onChange(this.props.attr, '');
37
- if (mayBePromise instanceof Promise) {
38
- void mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));
39
- }
40
- } },
41
- React.createElement(ClearIcon, null))) : undefined,
42
- },
43
- inputLabel: {
44
- shrink: true,
45
- },
46
- } })));
7
+ return (React.createElement(ColorPicker, { id: `color_${this.props.attr || ''}_${this.props.index ?? ''}`, disabled: !!disabled, style: { minWidth: 100, width: 'calc(100% - 8px)' }, label: this.getText(this.props.schema.label), value: value || '',
8
+ // the previous picker always reported the color as #rrggbb
9
+ format: "hex", sx: this.props.schema.noClearButton
10
+ ? {
11
+ // the color picker has no option to hide the clear button, so it is done via CSS
12
+ '& > .MuiIconButton-root': { display: 'none' },
13
+ '& > .MuiFormControl-root': { width: 'calc(100% - 56px)', mr: 1 },
14
+ }
15
+ : undefined, onChange: color => {
16
+ const mayBePromise = this.props.attr && this.onChange(this.props.attr, color);
17
+ if (mayBePromise instanceof Promise) {
18
+ void mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));
19
+ }
20
+ } }));
47
21
  }
48
22
  }
49
23
  export default ConfigColor;
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigColor.js","sourceRoot":"src/","sources":["JsonConfigComponent/ConfigColor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGjD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAWlG,MAAM,WAAY,SAAQ,aAAiD;IACvE,iBAAiB;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAChC,oBAAC,MAAM,IACH,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,EACxD,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,eAAe;YAEhC,oBAAC,YAAY,IACT,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAClC,QAAQ,EAAE,CAAC,KAAkB,EAAE,EAAE,CAC7B,IAAI,CAAC,QAAQ,CACT,EAAE,gBAAgB,EAAE,KAAK,CAAC,GAAG,EAAE,EAC/B,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CACvF,GAEP,CACG,CACZ,CAAC,CAAC,CAAC,IAAI,CAAC;IACb,CAAC;IAED,UAAU,CAAC,MAAe,EAAE,QAAiB,CAAC,oBAAoB;QAC9D,MAAM,KAAK,GAAG,aAAa,CA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E,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;yBACrC;wBACD,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,IAAI,KAAK;qBAChD;oBACD,KAAK,EAAE;wBACH,YAAY,EACR,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CACvE,oBAAC,UAAU,IACP,QAAQ,EAAE,CAAC,CAAC,EACZ,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,CAAC,CAAC,EAAE;gCACT,CAAC,CAAC,eAAe,EAAE,CAAC;gCACpB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gCAC3E,IAAI,YAAY,YAAY,OAAO,EAAE,CAAC;oCAClC,KAAK,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC;gCAC1E,CAAC;4BACL,CAAC;4BAED,oBAAC,SAAS,OAAG,CACJ,CAChB,CAAC,CAAC,CAAC,SAAS;qBACpB;oBACD,UAAU,EAAE;wBACR,MAAM,EAAE,IAAI;qBACf;iBACJ,GACH,CACH,CACN,CAAC;IACN,CAAC;CACJ;AAED,eAAe,WAAW,CAAC","sourcesContent":["import React, { type JSX } from 'react';\nimport { ChromePicker, type ColorResult } from 'react-color';\n\nimport { IconButton, TextField, Dialog } from '@mui/material';\n\nimport { Close as ClearIcon } from '@mui/icons-material';\n\nimport { Utils } from '@iobroker/gui-components';\n\nimport type { ConfigItemText } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface ConfigColorProps extends ConfigGenericProps {\n schema: ConfigItemText;\n}\n\ninterface ConfigColorState extends ConfigGenericState {\n showColorDialog?: boolean;\n colorDialogValue?: string;\n}\n\nclass ConfigColor extends ConfigGeneric<ConfigColorProps, ConfigColorState> {\n renderColorDialog(): JSX.Element | null {\n return this.state.showColorDialog ? (\n <Dialog\n onClose={() => this.setState({ showColorDialog: false })}\n open={this.state.showColorDialog}\n >\n <ChromePicker\n color={this.state.colorDialogValue}\n onChange={(color: ColorResult) =>\n this.setState(\n { colorDialogValue: color.hex },\n () => this.props.attr && this.onChange(this.props.attr, this.state.colorDialogValue),\n )\n }\n />\n </Dialog>\n ) : null;\n }\n\n renderItem(_error: unknown, disabled: boolean /* , defaultValue */): JSX.Element {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n const textColor = Utils.isUseBright(value);\n\n return (\n <>\n {this.renderColorDialog()}\n <TextField\n variant=\"standard\"\n disabled={!!disabled}\n style={{ minWidth: 100, width: 'calc(100% - 8px)' }}\n label={this.getText(this.props.schema.label)}\n value={value || ''}\n onClick={() =>\n !this.props.schema.readOnly &&\n this.setState({ showColorDialog: true, colorDialogValue: value || '' })\n }\n onChange={e => {\n const color = e.target.value;\n const mayBePromise = this.props.attr && this.onChange(this.props.attr, color);\n if (mayBePromise instanceof Promise) {\n void mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n }}\n slotProps={{\n htmlInput: {\n style: {\n // paddingLeft: noPadding ? 0 : 8,\n backgroundColor: value,\n color: textColor ? '#FFF' : '#000',\n },\n readOnly: this.props.schema.readOnly || false,\n },\n input: {\n endAdornment:\n !this.props.schema.readOnly && value && !this.props.schema.noClearButton ? (\n <IconButton\n tabIndex={-1}\n size=\"small\"\n onClick={e => {\n e.stopPropagation();\n const mayBePromise = this.props.attr && this.onChange(this.props.attr, '');\n if (mayBePromise instanceof Promise) {\n void mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n }}\n >\n <ClearIcon />\n </IconButton>\n ) : undefined,\n },\n inputLabel: {\n shrink: true,\n },\n }}\n />\n </>\n );\n }\n}\n\nexport default ConfigColor;\n"]}
1
+ {"version":3,"file":"ConfigColor.js","sourceRoot":"src/","sources":["JsonConfigComponent/ConfigColor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAMlG,MAAM,WAAY,SAAQ,aAAmD;IACzE,UAAU,CAAC,MAAe,EAAE,QAAiB,CAAC,oBAAoB;QAC9D,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEvE,OAAO,CACH,oBAAC,WAAW,IACR,EAAE,EAAE,SAAS,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,EAC9D,QAAQ,EAAE,CAAC,CAAC,QAAQ,EACpB,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,kBAAkB,EAAE,EACnD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,KAAK,EAAE,KAAK,IAAI,EAAE;YAClB,2DAA2D;YAC3D,MAAM,EAAC,KAAK,EACZ,EAAE,EACE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa;gBAC3B,CAAC,CAAC;oBACI,iFAAiF;oBACjF,yBAAyB,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;oBAC9C,0BAA0B,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,EAAE,EAAE,CAAC,EAAE;iBACpE;gBACH,CAAC,CAAC,SAAS,EAEnB,QAAQ,EAAE,KAAK,CAAC,EAAE;gBACd,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBAC9E,IAAI,YAAY,YAAY,OAAO,EAAE,CAAC;oBAClC,KAAK,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC1E,CAAC;YACL,CAAC,GACH,CACL,CAAC;IACN,CAAC;CACJ;AAED,eAAe,WAAW,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { ColorPicker } from '@iobroker/gui-components';\n\nimport type { ConfigItemColor } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface ConfigColorProps extends ConfigGenericProps {\n schema: ConfigItemColor;\n}\n\nclass ConfigColor extends ConfigGeneric<ConfigColorProps, ConfigGenericState> {\n renderItem(_error: unknown, disabled: boolean /* , defaultValue */): JSX.Element {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n return (\n <ColorPicker\n id={`color_${this.props.attr || ''}_${this.props.index ?? ''}`}\n disabled={!!disabled}\n style={{ minWidth: 100, width: 'calc(100% - 8px)' }}\n label={this.getText(this.props.schema.label)}\n value={value || ''}\n // the previous picker always reported the color as #rrggbb\n format=\"hex\"\n sx={\n this.props.schema.noClearButton\n ? {\n // the color picker has no option to hide the clear button, so it is done via CSS\n '& > .MuiIconButton-root': { display: 'none' },\n '& > .MuiFormControl-root': { width: 'calc(100% - 56px)', mr: 1 },\n }\n : undefined\n }\n onChange={color => {\n const mayBePromise = this.props.attr && this.onChange(this.props.attr, color);\n if (mayBePromise instanceof Promise) {\n void mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n }}\n />\n );\n }\n}\n\nexport default ConfigColor;\n"]}
@@ -78,7 +78,7 @@ export default class ConfigJsonEditor extends ConfigGeneric {
78
78
  : newValue => this.setState({
79
79
  value: newValue,
80
80
  jsonError: this.validateJson(newValue),
81
- }), name: "ConfigJsonEditor", themeType: this.props.oContext.themeType })))) : null,
81
+ }), name: "ConfigJsonEditor", themeType: this.props.oContext.themeType, AceEditor: this.props.oContext.AceEditor })))) : null,
82
82
  schema.help || this.state.jsonError ? (React.createElement(FormHelperText, null, this.state.jsonError
83
83
  ? I18n.t('jc_Invalid JSON')
84
84
  : this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation))) : null));
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigJsonEditor.js","sourceRoot":"src/","sources":["JsonConfigComponent/ConfigJsonEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD,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,iBAAiB;QACjB,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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CACE,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\nimport JSON5 from 'json5';\n\nimport { FormHelperText, FormControl, Button } from '@mui/material';\n\nimport { I18n } from '@iobroker/gui-components';\nimport type { ConfigItemJsonEditor } 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 // marginLeft: 4,\n minWidth: 48,\n },\n wrapper: {\n width: 'calc(100vw - 40px)',\n height: 'calc(100vh - 188px)',\n },\n};\n\ninterface ConfigJsonEditorProps extends ConfigGenericProps {\n schema: ConfigItemJsonEditor;\n}\n\ninterface ConfigJsonEditorState extends ConfigGenericState {\n initialized?: boolean;\n showSelectId?: boolean;\n jsonError?: boolean;\n}\n\nexport default class ConfigJsonEditor extends ConfigGeneric<ConfigJsonEditorProps, ConfigJsonEditorState> {\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, jsonError: this.validateJson(value) });\n }\n\n validateJson(value: string | null | undefined): boolean {\n let jsonError = false;\n if (this.props.schema.validateJson !== false) {\n if (value || !this.props.schema.allowEmpty) {\n try {\n if (this.props.schema.json5) {\n JSON5.parse(value as string);\n } else {\n JSON.parse(value as string);\n }\n } catch (err: unknown) {\n console.log('Error in JSON', err);\n jsonError = true;\n }\n }\n }\n\n return jsonError;\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('jc_JSON editor')}\n </Button>\n </div>\n {showSelectId ? (\n <CustomModal\n title={this.getText(schema.label)}\n overflowHidden\n applyDisabled={(this.state.jsonError && 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 }, () => attr && this.onChange(attr, value))\n }\n >\n <div\n style={{\n ...styles.wrapper,\n border: this.state.jsonError ? '2px solid red' : '2px solid transparent',\n }}\n >\n <Editor\n mode={this.props.schema.json5 ? 'json5' : 'json'}\n value={typeof value === 'object' ? JSON.stringify(value) : value}\n onChange={\n isReadOnly\n ? undefined\n : newValue =>\n this.setState({\n value: newValue,\n jsonError: this.validateJson(newValue),\n })\n }\n name=\"ConfigJsonEditor\"\n themeType={this.props.oContext.themeType}\n />\n </div>\n </CustomModal>\n ) : null}\n {schema.help || this.state.jsonError ? (\n <FormHelperText>\n {this.state.jsonError\n ? I18n.t('jc_Invalid JSON')\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":"ConfigJsonEditor.js","sourceRoot":"src/","sources":["JsonConfigComponent/ConfigJsonEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;A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AkB,EACvB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,EACxC,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 JSON5 from 'json5';\n\nimport { FormHelperText, FormControl, Button } from '@mui/material';\n\nimport { I18n } from '@iobroker/gui-components';\nimport type { ConfigItemJsonEditor } 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 // marginLeft: 4,\n minWidth: 48,\n },\n wrapper: {\n width: 'calc(100vw - 40px)',\n height: 'calc(100vh - 188px)',\n },\n};\n\ninterface ConfigJsonEditorProps extends ConfigGenericProps {\n schema: ConfigItemJsonEditor;\n}\n\ninterface ConfigJsonEditorState extends ConfigGenericState {\n initialized?: boolean;\n showSelectId?: boolean;\n jsonError?: boolean;\n}\n\nexport default class ConfigJsonEditor extends ConfigGeneric<ConfigJsonEditorProps, ConfigJsonEditorState> {\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, jsonError: this.validateJson(value) });\n }\n\n validateJson(value: string | null | undefined): boolean {\n let jsonError = false;\n if (this.props.schema.validateJson !== false) {\n if (value || !this.props.schema.allowEmpty) {\n try {\n if (this.props.schema.json5) {\n JSON5.parse(value as string);\n } else {\n JSON.parse(value as string);\n }\n } catch (err: unknown) {\n console.log('Error in JSON', err);\n jsonError = true;\n }\n }\n }\n\n return jsonError;\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('jc_JSON editor')}\n </Button>\n </div>\n {showSelectId ? (\n <CustomModal\n title={this.getText(schema.label)}\n overflowHidden\n applyDisabled={(this.state.jsonError && 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 }, () => attr && this.onChange(attr, value))\n }\n >\n <div\n style={{\n ...styles.wrapper,\n border: this.state.jsonError ? '2px solid red' : '2px solid transparent',\n }}\n >\n <Editor\n mode={this.props.schema.json5 ? 'json5' : 'json'}\n value={typeof value === 'object' ? JSON.stringify(value) : value}\n onChange={\n isReadOnly\n ? undefined\n : newValue =>\n this.setState({\n value: newValue,\n jsonError: this.validateJson(newValue),\n })\n }\n name=\"ConfigJsonEditor\"\n themeType={this.props.oContext.themeType}\n AceEditor={this.props.oContext.AceEditor}\n />\n </div>\n </CustomModal>\n ) : null}\n {schema.help || this.state.jsonError ? (\n <FormHelperText>\n {this.state.jsonError\n ? I18n.t('jc_Invalid JSON')\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"]}
@@ -164,7 +164,7 @@ export default class ConfigSendto extends ConfigGeneric {
164
164
  this.setState({ _copyDialog: null });
165
165
  }, titleButtonApply: I18n.t('jc_Copy content') },
166
166
  React.createElement("div", { style: { width: 'calc(100vw - 40px)', height: 'calc(100vh - 188px)' } },
167
- React.createElement(Editor, { mode: this.state._copyDialog.type, value: this.state._copyDialog.text, name: "CopyDialog", themeType: this.props.oContext.themeType }))));
167
+ React.createElement(Editor, { mode: this.state._copyDialog.type, value: this.state._copyDialog.text, name: "CopyDialog", themeType: this.props.oContext.themeType, AceEditor: this.props.oContext.AceEditor }))));
168
168
  }
169
169
  return null;
170
170
  }