@iobroker/json-config 9.1.2 → 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 +20 -4
- package/build/JsonConfig.d.ts +3 -0
- package/build/JsonConfig.js +1 -1
- package/build/JsonConfig.js.map +1 -1
- package/build/JsonConfigComponent/ConfigJsonEditor.js +1 -1
- package/build/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSendto.js +1 -1
- package/build/JsonConfigComponent/ConfigSendto.js.map +1 -1
- package/build/JsonConfigComponent/ConfigState.d.ts +7 -0
- package/build/JsonConfigComponent/ConfigState.js +30 -13
- package/build/JsonConfigComponent/ConfigState.js.map +1 -1
- package/build/JsonConfigComponent/ConfigYamlEditor.js +1 -1
- package/build/JsonConfigComponent/ConfigYamlEditor.js.map +1 -1
- package/build/JsonConfigComponent/index.d.ts +9 -0
- package/build/JsonConfigComponent/index.js +1 -0
- package/build/JsonConfigComponent/index.js.map +1 -1
- package/build/JsonConfigComponent/wrapper/Components/Editor.d.ts +42 -7
- package/build/JsonConfigComponent/wrapper/Components/Editor.js +17 -13
- package/build/JsonConfigComponent/wrapper/Components/Editor.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js.map +1 -1
- package/build/types.d.ts +10 -0
- package/package.json +2 -2
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,14 @@ 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
|
+
|
|
1951
1967
|
### 9.1.2 (2026-09-01)
|
|
1952
1968
|
- (@GermanBluefox) Replaced `react-color` with the `ColorPicker` from `@iobroker/gui-components` in the `color` component
|
|
1953
1969
|
|
package/build/JsonConfig.d.ts
CHANGED
|
@@ -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
|
};
|
package/build/JsonConfig.js
CHANGED
|
@@ -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
|
}
|
package/build/JsonConfig.js.map
CHANGED
|
@@ -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,gBAAgB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,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,EAA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;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';\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"]}
|
|
@@ -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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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 />\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":"AA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AAK,EAChE,QAAQ,EACJ,UAAU;4BACN,CAAC,CAAC,SAAS;4BACX,CAAC,CAAC,QAAQ,CAAC,EAAE,CACP,IAAI,CAAC,QAAQ,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,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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigSendto.js","sourceRoot":"src/","sources":["JsonConfigComponent/ConfigSendto.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE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AAC,CAAC,CAAC;oBAC9D,CAAC;gBACL,CAAC;gBAEA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CACnD,oBAAC,gBAAgB,IACb,IAAI,EAAE,EAAE,EACR,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,GAC3B,CACL,CAAC,CAAC,CAAC,IAAI;gBACP,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAClE;YACR,IAAI,CAAC,iBAAiB,EAAE;YACxB,IAAI,CAAC,mBAAmB,EAAE;YAC1B,IAAI,CAAC,gBAAgB,EAAE,CACtB,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Button, CircularProgress } from '@mui/material';\n\nimport { Warning as IconWarning, Error as IconError, Info as IconInfo } from '@mui/icons-material';\n\nimport { DialogConfirm, DialogError, DialogMessage, I18n, copy } from '@iobroker/gui-components';\n\nimport type { BackEndCommand, ConfigItemSendTo } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\nimport Editor from './wrapper/Components/Editor';\nimport CustomModal from './wrapper/Components/CustomModal';\n\nconst styles: Record<string, React.CSSProperties> = {\n fullWidth: {\n width: '100%',\n },\n};\n\nfunction ip2int(ip: string): number {\n return ip.split('.').reduce((ipInt, octet) => (ipInt << 8) + parseInt(octet, 10), 0) >>> 0;\n}\n\n// copied from iobroker.admin/src-rx/src/Utils.js\nfunction findNetworkAddressOfHost(obj: Record<string, any>, localIp: string): string | null {\n const networkInterfaces = obj?.native?.hardware?.networkInterfaces;\n if (!networkInterfaces) {\n return null;\n }\n\n let hostIp: string | undefined;\n\n // check ipv4 addresses\n Object.keys(networkInterfaces).forEach(inter =>\n networkInterfaces[inter].forEach((ip: Record<string, any>) => {\n if (ip.internal) {\n return;\n }\n if (localIp.includes(':') && ip.family !== 'IPv6') {\n return;\n }\n if (localIp.includes('.') && !localIp.match(/[^.\\d]/) && ip.family !== 'IPv4') {\n return;\n }\n // if ip4 and not docker or wsl\n if (\n ip.family === 'IPv4' &&\n !ip.address.startsWith('172') &&\n (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\\d]/))\n ) {\n // if DNS name\n hostIp = ip.address;\n } else if (!hostIp) {\n if (\n ip.family === 'IPv4' &&\n localIp.includes('.') &&\n (ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))\n ) {\n hostIp = ip.address;\n } else {\n hostIp = ip.address;\n }\n }\n }),\n );\n\n // check ipv6 addresses\n if (!hostIp) {\n Object.keys(networkInterfaces).forEach(inter =>\n networkInterfaces[inter].forEach((ip: Record<string, any>) => {\n if (ip.internal) {\n return;\n }\n if (localIp.includes(':') && ip.family !== 'IPv6') {\n return;\n }\n if (localIp.includes('.') && !localIp.match(/[^.\\d]/) && ip.family !== 'IPv4') {\n return;\n }\n if (\n ip.family === 'IPv6' &&\n (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\\d]/))\n ) {\n // if DNS name\n hostIp = ip.address;\n } else if (!hostIp) {\n if (\n ip.family === 'IPv4' &&\n localIp.includes('.') &&\n (ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))\n ) {\n hostIp = ip.address;\n } else {\n hostIp = ip.address;\n }\n }\n }),\n );\n }\n\n if (!hostIp) {\n Object.keys(networkInterfaces).forEach(inter => {\n networkInterfaces[inter].forEach((ip: Record<string, any>) => {\n if (ip.internal) {\n return;\n }\n if (localIp.includes(':') && ip.family !== 'IPv6') {\n return;\n }\n if (localIp.includes('.') && !localIp.match(/[^.\\d]/) && ip.family !== 'IPv4') {\n return;\n }\n if (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\\d]/)) {\n // if DNS name\n hostIp = ip.address;\n } else {\n hostIp = ip.address;\n }\n });\n });\n }\n\n if (!hostIp) {\n Object.keys(networkInterfaces).forEach(inter => {\n networkInterfaces[inter].forEach((ip: Record<string, any>) => {\n if (ip.internal) {\n return;\n }\n hostIp = ip.address;\n });\n });\n }\n\n return hostIp || null;\n}\n\ninterface ConfigSendToProps extends ConfigGenericProps {\n schema: ConfigItemSendTo;\n}\n\ninterface ConfigSendToState extends ConfigGenericState {\n _error: string;\n _message: string;\n _copyDialog: {\n text: string;\n title?: ioBroker.StringOrTranslated;\n type?: 'json' | 'css' | 'html' | 'json5' | 'yaml';\n } | null;\n hostname: string;\n running?: boolean;\n}\n\nexport default class ConfigSendto extends ConfigGeneric<ConfigSendToProps, ConfigSendToState> {\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n\n let hostname = window.location.hostname;\n if (this.props.schema.openUrl) {\n // read admin host\n const adminInstance = await this.props.oContext.socket.getCurrentInstance();\n const instanceObj = await this.getCachedObject(\n `system.adapter.${adminInstance}` as ioBroker.ObjectIDs.Instance,\n );\n\n if (instanceObj) {\n const hostObj = await this.getCachedObject(`system.host.${instanceObj?.common?.host}`);\n if (hostObj) {\n const ip = findNetworkAddressOfHost(hostObj, window.location.hostname);\n if (ip) {\n hostname = `${ip}:${window.location.port}`;\n } else {\n console.warn(\n `Cannot find suitable IP in host ${instanceObj.common.host} for ${instanceObj._id}`,\n );\n return;\n }\n }\n }\n }\n\n await new Promise<void>(resolve => {\n this.setState({ _error: '', _message: '', hostname }, resolve);\n });\n\n if (this.props.schema.onLoaded) {\n this._onClick().catch((err: Error) => console.error(err));\n }\n }\n\n renderErrorDialog(): JSX.Element | null {\n if (this.state._error) {\n return (\n <DialogError\n text={this.state._error}\n onClose={() => this.setState({ _error: '' })}\n />\n );\n }\n return null;\n }\n\n renderMessageDialog(): JSX.Element | null {\n if (this.state._message) {\n return (\n <DialogMessage\n text={this.state._message}\n onClose={() => this.setState({ _message: '' })}\n />\n );\n }\n return null;\n }\n\n renderCopyDialog(): JSX.Element | null {\n if (this.state._copyDialog) {\n return (\n <CustomModal\n title={this.getText(this.state._copyDialog.title || I18n.t('jc_Result'))}\n overflowHidden\n onClose={() => {\n this.setState({ _copyDialog: null });\n }}\n onApply={() => {\n // Copy to clipboard\n copy(this.state._copyDialog!.text);\n window.alert(I18n.t('jc_Copied'));\n this.setState({ _copyDialog: null });\n }}\n titleButtonApply={I18n.t('jc_Copy content')}\n >\n <div style={{ width: 'calc(100vw - 40px)', height: 'calc(100vh - 188px)' }}>\n <Editor\n mode={this.state._copyDialog.type}\n value={this.state._copyDialog.text}\n name=\"CopyDialog\"\n themeType={this.props.oContext.themeType}\n />\n </div>\n </CustomModal>\n );\n }\n return null;\n }\n\n async _onClick(): Promise<void> {\n this.props.oContext.onCommandRunning(true);\n this.setState({ running: true });\n\n const _origin = `${window.location.protocol}//${window.location.host}${window.location.pathname.replace(/\\/index\\.html$/, '')}`;\n const _originIp = `${window.location.protocol}//${this.state.hostname.split(':').length > 3 ? `[${this.state.hostname}]` : this.state.hostname}${window.location.pathname.replace(/\\/index\\.html$/, '')}`;\n\n let data: Record<string, any> | undefined | null = this.props.schema.data;\n if (data === undefined && this.props.schema.jsonData) {\n const dataStr = await this.getPatternAsync(\n this.props.schema.jsonData,\n {\n _origin,\n _originIp,\n ...this.props.data,\n },\n true,\n );\n\n try {\n data = JSON.parse(dataStr);\n } catch {\n console.error(`Cannot parse json data: ${dataStr}`);\n }\n }\n data ??= null;\n if (this.props.schema.openUrl && !data) {\n data = {\n _origin,\n _originIp,\n };\n }\n let timeout: ReturnType<typeof setTimeout> | undefined;\n if (this.props.schema.timeout) {\n timeout = setTimeout(\n () => {\n this.props.oContext.onCommandRunning(false);\n this.setState({ _error: I18n.t('jc_Request timed out'), running: false });\n },\n parseInt(this.props.schema.timeout as any as string, 10) || 10000,\n );\n }\n const instance = await this.getPatternAsync(\n this.props.schema.instance || `${this.props.oContext.adapterName}.${this.props.oContext.instance}`,\n );\n // Check that instance is alive\n if (instance !== `${this.props.oContext.adapterName}.${this.props.oContext.instance}`) {\n const alive = await this.props.oContext.socket.getState(`system.adapter.${instance}.alive`);\n if (!alive?.val) {\n window.alert(I18n.t('jc_Instance %s is not alive', instance));\n return;\n }\n }\n void this.props.oContext.socket\n .sendTo(instance, this.props.schema.command || 'send', data)\n .then(\n async (response: {\n error?: string;\n args?: string[];\n command?: BackEndCommand;\n reloadBrowser?: boolean;\n openUrl?: string;\n window?: string;\n result?: string;\n native?: Record<string, any>;\n saveConfig?: boolean;\n /** Title for copy dialog */\n copyDialog?: {\n title?: ioBroker.StringOrTranslated;\n text: string;\n type?: 'json' | 'css' | 'html' | 'json5' | 'yaml';\n };\n }) => {\n if (timeout) {\n clearTimeout(timeout);\n timeout = undefined;\n }\n if (response?.error) {\n if (this.props.schema.error?.[response.error]) {\n let error = this.getText(this.props.schema.error[response.error]);\n response.args?.forEach((arg: string) => (error = error.replace('%s', arg)));\n this.setState({ _error: error });\n } else {\n this.setState({\n _error: response.error\n ? typeof response.error === 'string'\n ? I18n.t(response.error)\n : JSON.stringify(response.error)\n : I18n.t('jc_Error'),\n });\n }\n } else {\n if (response?.command) {\n // If backend requested to refresh the config\n this.props.oContext.onBackEndCommand?.(response.command);\n return;\n }\n if (response?.reloadBrowser && this.props.schema.reloadBrowser) {\n window.location.reload();\n } else if (response?.openUrl && this.props.schema.openUrl) {\n window.open(response.openUrl, response.window || this.props.schema.window || '_blank');\n } else if (response?.result && this.props.schema.result?.[response.result]) {\n let text = this.getText(this.props.schema.result[response.result]);\n response.args?.forEach((arg: string) => (text = text.replace('%s', arg)));\n window.alert(text);\n }\n\n if (response?.native && this.props.schema.useNative) {\n for (const [attr, val] of Object.entries(response.native)) {\n await this.onChangeAsync(attr, val);\n }\n\n setTimeout(\n () => this.props.oContext.forceUpdate(Object.keys(response.native!), this.props.data),\n 300,\n );\n } else if (response?.result) {\n window.alert(\n typeof response.result === 'object' ? JSON.stringify(response.result) : response.result,\n );\n } else if (response?.copyDialog) {\n this.setState({ _copyDialog: response.copyDialog });\n } else {\n window.alert(I18n.t('jc_Ok'));\n }\n\n if (response?.saveConfig) {\n this.props.onChange(undefined, null, undefined, true);\n }\n }\n },\n )\n .catch((e: any) => {\n if (this.props.schema.error && this.props.schema.error[e.toString()]) {\n this.setState({ _error: this.getText(this.props.schema.error[e.toString()]) });\n } else {\n this.setState({ _error: I18n.t(e.toString()) || I18n.t('jc_Error') });\n }\n })\n .then(() => {\n this.props.oContext.onCommandRunning(false);\n this.setState({ running: false });\n });\n }\n\n renderDialogConfirm(): JSX.Element | null {\n if (!this.state.confirmDialog) {\n return null;\n }\n const confirm = this.state.confirmData || this.props.schema.confirm;\n if (!confirm) {\n throw new Error('Confirm dialog requested but no confirm data provided');\n }\n let icon = null;\n if (confirm.type === 'warning') {\n icon = <IconWarning />;\n } else if (confirm.type === 'error') {\n icon = <IconError />;\n } else if (confirm.type === 'info') {\n icon = <IconInfo />;\n }\n\n return (\n <DialogConfirm\n title={this.getText(confirm.title) || I18n.t('jc_Please confirm')}\n text={this.getText(confirm.text)}\n ok={this.getText(confirm.ok) || I18n.t('jc_Ok')}\n cancel={this.getText(confirm.cancel) || I18n.t('jc_Cancel')}\n icon={icon || undefined}\n onClose={isOk => this.setState({ confirmDialog: false }, () => isOk && this._onClick())}\n />\n );\n }\n\n renderItem(error: Error | undefined, disabled: boolean): JSX.Element {\n const icon = this.getIcon();\n\n return (\n <div style={styles.fullWidth}>\n <Button\n variant={this.props.schema.variant || undefined}\n color={this.props.schema.color || 'grey'}\n style={{ ...styles.fullWidth, ...(this.props.schema.controlStyle || undefined) }}\n disabled={disabled || !this.props.alive}\n startIcon={icon}\n title={\n this.props.alive\n ? this.getText(this.props.schema.title) || ''\n : I18n.t('jc_Instance %s is not alive', this.props.oContext.instance.toString())\n }\n onClick={() => {\n if (this.props.schema.confirm) {\n this.setState({ confirmDialog: true });\n } else {\n this._onClick().catch((err: Error) => console.error(err));\n }\n }}\n >\n {this.props.schema.showProcess && this.state.running ? (\n <CircularProgress\n size={20}\n style={{ marginRight: 8 }}\n />\n ) : null}\n {this.getText(this.props.schema.label, this.props.schema.noTranslation)}\n </Button>\n {this.renderErrorDialog()}\n {this.renderMessageDialog()}\n {this.renderCopyDialog()}\n </div>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigSendto.js","sourceRoot":"src/","sources":["JsonConfigComponent/ConfigSendto.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,KAAK,IAAI,SAAS,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEnG,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGjG,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,MAAM,MAAM,6BAA6B,CAAC;AACjD,OAAO,WAAW,MAAM,kCAAkC,CAAC;AAE3D,MAAM,MAAM,GAAwC;IAChD,SAAS,EAAE;QACP,KAAK,EAAE,MAAM;KAChB;CACJ,CAAC;AAEF,SAAS,MAAM,CAAC,EAAU;IACtB,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAC/F,CAAC;AAED,iDAAiD;AACjD,SAAS,wBAAwB,CAAC,GAAwB,EAAE,OAAe;IACvE,MAAM,iBAAiB,GAAG,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,CAAC;IACnE,IAAI,CAAC,iBA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AAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;oBAC7C,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,6BAA6B,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAExF,OAAO,EAAE,GAAG,EAAE;oBACV,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;wBAC5B,IAAI,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;oBAC3C,CAAC;yBAAM,CAAC;wBACJ,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC9D,CAAC;gBACL,CAAC;gBAEA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CACnD,oBAAC,gBAAgB,IACb,IAAI,EAAE,EAAE,EACR,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,GAC3B,CACL,CAAC,CAAC,CAAC,IAAI;gBACP,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAClE;YACR,IAAI,CAAC,iBAAiB,EAAE;YACxB,IAAI,CAAC,mBAAmB,EAAE;YAC1B,IAAI,CAAC,gBAAgB,EAAE,CACtB,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Button, CircularProgress } from '@mui/material';\n\nimport { Warning as IconWarning, Error as IconError, Info as IconInfo } from '@mui/icons-material';\n\nimport { DialogConfirm, DialogError, DialogMessage, I18n, copy } from '@iobroker/gui-components';\n\nimport type { BackEndCommand, ConfigItemSendTo } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\nimport Editor from './wrapper/Components/Editor';\nimport CustomModal from './wrapper/Components/CustomModal';\n\nconst styles: Record<string, React.CSSProperties> = {\n fullWidth: {\n width: '100%',\n },\n};\n\nfunction ip2int(ip: string): number {\n return ip.split('.').reduce((ipInt, octet) => (ipInt << 8) + parseInt(octet, 10), 0) >>> 0;\n}\n\n// copied from iobroker.admin/src-rx/src/Utils.js\nfunction findNetworkAddressOfHost(obj: Record<string, any>, localIp: string): string | null {\n const networkInterfaces = obj?.native?.hardware?.networkInterfaces;\n if (!networkInterfaces) {\n return null;\n }\n\n let hostIp: string | undefined;\n\n // check ipv4 addresses\n Object.keys(networkInterfaces).forEach(inter =>\n networkInterfaces[inter].forEach((ip: Record<string, any>) => {\n if (ip.internal) {\n return;\n }\n if (localIp.includes(':') && ip.family !== 'IPv6') {\n return;\n }\n if (localIp.includes('.') && !localIp.match(/[^.\\d]/) && ip.family !== 'IPv4') {\n return;\n }\n // if ip4 and not docker or wsl\n if (\n ip.family === 'IPv4' &&\n !ip.address.startsWith('172') &&\n (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\\d]/))\n ) {\n // if DNS name\n hostIp = ip.address;\n } else if (!hostIp) {\n if (\n ip.family === 'IPv4' &&\n localIp.includes('.') &&\n (ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))\n ) {\n hostIp = ip.address;\n } else {\n hostIp = ip.address;\n }\n }\n }),\n );\n\n // check ipv6 addresses\n if (!hostIp) {\n Object.keys(networkInterfaces).forEach(inter =>\n networkInterfaces[inter].forEach((ip: Record<string, any>) => {\n if (ip.internal) {\n return;\n }\n if (localIp.includes(':') && ip.family !== 'IPv6') {\n return;\n }\n if (localIp.includes('.') && !localIp.match(/[^.\\d]/) && ip.family !== 'IPv4') {\n return;\n }\n if (\n ip.family === 'IPv6' &&\n (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\\d]/))\n ) {\n // if DNS name\n hostIp = ip.address;\n } else if (!hostIp) {\n if (\n ip.family === 'IPv4' &&\n localIp.includes('.') &&\n (ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))\n ) {\n hostIp = ip.address;\n } else {\n hostIp = ip.address;\n }\n }\n }),\n );\n }\n\n if (!hostIp) {\n Object.keys(networkInterfaces).forEach(inter => {\n networkInterfaces[inter].forEach((ip: Record<string, any>) => {\n if (ip.internal) {\n return;\n }\n if (localIp.includes(':') && ip.family !== 'IPv6') {\n return;\n }\n if (localIp.includes('.') && !localIp.match(/[^.\\d]/) && ip.family !== 'IPv4') {\n return;\n }\n if (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\\d]/)) {\n // if DNS name\n hostIp = ip.address;\n } else {\n hostIp = ip.address;\n }\n });\n });\n }\n\n if (!hostIp) {\n Object.keys(networkInterfaces).forEach(inter => {\n networkInterfaces[inter].forEach((ip: Record<string, any>) => {\n if (ip.internal) {\n return;\n }\n hostIp = ip.address;\n });\n });\n }\n\n return hostIp || null;\n}\n\ninterface ConfigSendToProps extends ConfigGenericProps {\n schema: ConfigItemSendTo;\n}\n\ninterface ConfigSendToState extends ConfigGenericState {\n _error: string;\n _message: string;\n _copyDialog: {\n text: string;\n title?: ioBroker.StringOrTranslated;\n type?: 'json' | 'css' | 'html' | 'json5' | 'yaml';\n } | null;\n hostname: string;\n running?: boolean;\n}\n\nexport default class ConfigSendto extends ConfigGeneric<ConfigSendToProps, ConfigSendToState> {\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n\n let hostname = window.location.hostname;\n if (this.props.schema.openUrl) {\n // read admin host\n const adminInstance = await this.props.oContext.socket.getCurrentInstance();\n const instanceObj = await this.getCachedObject(\n `system.adapter.${adminInstance}` as ioBroker.ObjectIDs.Instance,\n );\n\n if (instanceObj) {\n const hostObj = await this.getCachedObject(`system.host.${instanceObj?.common?.host}`);\n if (hostObj) {\n const ip = findNetworkAddressOfHost(hostObj, window.location.hostname);\n if (ip) {\n hostname = `${ip}:${window.location.port}`;\n } else {\n console.warn(\n `Cannot find suitable IP in host ${instanceObj.common.host} for ${instanceObj._id}`,\n );\n return;\n }\n }\n }\n }\n\n await new Promise<void>(resolve => {\n this.setState({ _error: '', _message: '', hostname }, resolve);\n });\n\n if (this.props.schema.onLoaded) {\n this._onClick().catch((err: Error) => console.error(err));\n }\n }\n\n renderErrorDialog(): JSX.Element | null {\n if (this.state._error) {\n return (\n <DialogError\n text={this.state._error}\n onClose={() => this.setState({ _error: '' })}\n />\n );\n }\n return null;\n }\n\n renderMessageDialog(): JSX.Element | null {\n if (this.state._message) {\n return (\n <DialogMessage\n text={this.state._message}\n onClose={() => this.setState({ _message: '' })}\n />\n );\n }\n return null;\n }\n\n renderCopyDialog(): JSX.Element | null {\n if (this.state._copyDialog) {\n return (\n <CustomModal\n title={this.getText(this.state._copyDialog.title || I18n.t('jc_Result'))}\n overflowHidden\n onClose={() => {\n this.setState({ _copyDialog: null });\n }}\n onApply={() => {\n // Copy to clipboard\n copy(this.state._copyDialog!.text);\n window.alert(I18n.t('jc_Copied'));\n this.setState({ _copyDialog: null });\n }}\n titleButtonApply={I18n.t('jc_Copy content')}\n >\n <div style={{ width: 'calc(100vw - 40px)', height: 'calc(100vh - 188px)' }}>\n <Editor\n mode={this.state._copyDialog.type}\n value={this.state._copyDialog.text}\n name=\"CopyDialog\"\n themeType={this.props.oContext.themeType}\n AceEditor={this.props.oContext.AceEditor}\n />\n </div>\n </CustomModal>\n );\n }\n return null;\n }\n\n async _onClick(): Promise<void> {\n this.props.oContext.onCommandRunning(true);\n this.setState({ running: true });\n\n const _origin = `${window.location.protocol}//${window.location.host}${window.location.pathname.replace(/\\/index\\.html$/, '')}`;\n const _originIp = `${window.location.protocol}//${this.state.hostname.split(':').length > 3 ? `[${this.state.hostname}]` : this.state.hostname}${window.location.pathname.replace(/\\/index\\.html$/, '')}`;\n\n let data: Record<string, any> | undefined | null = this.props.schema.data;\n if (data === undefined && this.props.schema.jsonData) {\n const dataStr = await this.getPatternAsync(\n this.props.schema.jsonData,\n {\n _origin,\n _originIp,\n ...this.props.data,\n },\n true,\n );\n\n try {\n data = JSON.parse(dataStr);\n } catch {\n console.error(`Cannot parse json data: ${dataStr}`);\n }\n }\n data ??= null;\n if (this.props.schema.openUrl && !data) {\n data = {\n _origin,\n _originIp,\n };\n }\n let timeout: ReturnType<typeof setTimeout> | undefined;\n if (this.props.schema.timeout) {\n timeout = setTimeout(\n () => {\n this.props.oContext.onCommandRunning(false);\n this.setState({ _error: I18n.t('jc_Request timed out'), running: false });\n },\n parseInt(this.props.schema.timeout as any as string, 10) || 10000,\n );\n }\n const instance = await this.getPatternAsync(\n this.props.schema.instance || `${this.props.oContext.adapterName}.${this.props.oContext.instance}`,\n );\n // Check that instance is alive\n if (instance !== `${this.props.oContext.adapterName}.${this.props.oContext.instance}`) {\n const alive = await this.props.oContext.socket.getState(`system.adapter.${instance}.alive`);\n if (!alive?.val) {\n window.alert(I18n.t('jc_Instance %s is not alive', instance));\n return;\n }\n }\n void this.props.oContext.socket\n .sendTo(instance, this.props.schema.command || 'send', data)\n .then(\n async (response: {\n error?: string;\n args?: string[];\n command?: BackEndCommand;\n reloadBrowser?: boolean;\n openUrl?: string;\n window?: string;\n result?: string;\n native?: Record<string, any>;\n saveConfig?: boolean;\n /** Title for copy dialog */\n copyDialog?: {\n title?: ioBroker.StringOrTranslated;\n text: string;\n type?: 'json' | 'css' | 'html' | 'json5' | 'yaml';\n };\n }) => {\n if (timeout) {\n clearTimeout(timeout);\n timeout = undefined;\n }\n if (response?.error) {\n if (this.props.schema.error?.[response.error]) {\n let error = this.getText(this.props.schema.error[response.error]);\n response.args?.forEach((arg: string) => (error = error.replace('%s', arg)));\n this.setState({ _error: error });\n } else {\n this.setState({\n _error: response.error\n ? typeof response.error === 'string'\n ? I18n.t(response.error)\n : JSON.stringify(response.error)\n : I18n.t('jc_Error'),\n });\n }\n } else {\n if (response?.command) {\n // If backend requested to refresh the config\n this.props.oContext.onBackEndCommand?.(response.command);\n return;\n }\n if (response?.reloadBrowser && this.props.schema.reloadBrowser) {\n window.location.reload();\n } else if (response?.openUrl && this.props.schema.openUrl) {\n window.open(response.openUrl, response.window || this.props.schema.window || '_blank');\n } else if (response?.result && this.props.schema.result?.[response.result]) {\n let text = this.getText(this.props.schema.result[response.result]);\n response.args?.forEach((arg: string) => (text = text.replace('%s', arg)));\n window.alert(text);\n }\n\n if (response?.native && this.props.schema.useNative) {\n for (const [attr, val] of Object.entries(response.native)) {\n await this.onChangeAsync(attr, val);\n }\n\n setTimeout(\n () => this.props.oContext.forceUpdate(Object.keys(response.native!), this.props.data),\n 300,\n );\n } else if (response?.result) {\n window.alert(\n typeof response.result === 'object' ? JSON.stringify(response.result) : response.result,\n );\n } else if (response?.copyDialog) {\n this.setState({ _copyDialog: response.copyDialog });\n } else {\n window.alert(I18n.t('jc_Ok'));\n }\n\n if (response?.saveConfig) {\n this.props.onChange(undefined, null, undefined, true);\n }\n }\n },\n )\n .catch((e: any) => {\n if (this.props.schema.error && this.props.schema.error[e.toString()]) {\n this.setState({ _error: this.getText(this.props.schema.error[e.toString()]) });\n } else {\n this.setState({ _error: I18n.t(e.toString()) || I18n.t('jc_Error') });\n }\n })\n .then(() => {\n this.props.oContext.onCommandRunning(false);\n this.setState({ running: false });\n });\n }\n\n renderDialogConfirm(): JSX.Element | null {\n if (!this.state.confirmDialog) {\n return null;\n }\n const confirm = this.state.confirmData || this.props.schema.confirm;\n if (!confirm) {\n throw new Error('Confirm dialog requested but no confirm data provided');\n }\n let icon = null;\n if (confirm.type === 'warning') {\n icon = <IconWarning />;\n } else if (confirm.type === 'error') {\n icon = <IconError />;\n } else if (confirm.type === 'info') {\n icon = <IconInfo />;\n }\n\n return (\n <DialogConfirm\n title={this.getText(confirm.title) || I18n.t('jc_Please confirm')}\n text={this.getText(confirm.text)}\n ok={this.getText(confirm.ok) || I18n.t('jc_Ok')}\n cancel={this.getText(confirm.cancel) || I18n.t('jc_Cancel')}\n icon={icon || undefined}\n onClose={isOk => this.setState({ confirmDialog: false }, () => isOk && this._onClick())}\n />\n );\n }\n\n renderItem(error: Error | undefined, disabled: boolean): JSX.Element {\n const icon = this.getIcon();\n\n return (\n <div style={styles.fullWidth}>\n <Button\n variant={this.props.schema.variant || undefined}\n color={this.props.schema.color || 'grey'}\n style={{ ...styles.fullWidth, ...(this.props.schema.controlStyle || undefined) }}\n disabled={disabled || !this.props.alive}\n startIcon={icon}\n title={\n this.props.alive\n ? this.getText(this.props.schema.title) || ''\n : I18n.t('jc_Instance %s is not alive', this.props.oContext.instance.toString())\n }\n onClick={() => {\n if (this.props.schema.confirm) {\n this.setState({ confirmDialog: true });\n } else {\n this._onClick().catch((err: Error) => console.error(err));\n }\n }}\n >\n {this.props.schema.showProcess && this.state.running ? (\n <CircularProgress\n size={20}\n style={{ marginRight: 8 }}\n />\n ) : null}\n {this.getText(this.props.schema.label, this.props.schema.noTranslation)}\n </Button>\n {this.renderErrorDialog()}\n {this.renderMessageDialog()}\n {this.renderCopyDialog()}\n </div>\n );\n }\n}\n"]}
|
|
@@ -16,6 +16,13 @@ declare class ConfigState extends ConfigGeneric<ConfigStateProps, ConfigStateSta
|
|
|
16
16
|
timer: ReturnType<typeof setTimeout> | null;
|
|
17
17
|
value: string | boolean | number | null;
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Acknowledged flag for every write of this control.
|
|
21
|
+
*
|
|
22
|
+
* A control writes a command by default (`ack: false`), so the adapter reacts to it. An adapter
|
|
23
|
+
* that only shows a value it has produced itself can set `ack: true` in the configuration.
|
|
24
|
+
*/
|
|
25
|
+
private get ack();
|
|
19
26
|
private getObjectID;
|
|
20
27
|
componentDidMount(): Promise<void>;
|
|
21
28
|
componentWillUnmount(): void;
|