@iobroker/json-config 8.1.9 → 8.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -143,7 +143,7 @@ You can install it via GitHub icon in admin by entering `iobroker.jsonconfig-dem
143
143
  - [**`checkLicense`:**](#checklicense) Very special component to check the license online
144
144
  - [**`chips`:**](#chips) User can enter words that are added to an array
145
145
  - [**`color`:**](#color) Color picker
146
- - [**`coordinates`:**](#coordinates) Determines current location and used `system.config` coordinates if not possible in form "latitude,longitude"
146
+ - [**`coordinates`:**](#coordinates) Determines current location and used `system.config` coordinates if not possible in form `latitude,longitude`
147
147
  - [**`cron`:**](#cron) Configures cron expressions for scheduling tasks
148
148
  - [**`custom`:**](#custom) Integrates custom components for specific functionalities (Admin 6 only)
149
149
  - [**`datePicker`:**](#datepicker) Allows users to select a date
@@ -572,7 +572,7 @@ object ID: show it with name, color and icon
572
572
 
573
573
  `{common: {custom: '_dataSources'}}`
574
574
 
575
- ##### show only objects of custom settings for specific adapter (all instances)
575
+ ##### show only objects of custom settings for a specific adapter (all instances)
576
576
 
577
577
  `{common: {custom: 'adapterName.'}}`
578
578
 
@@ -648,7 +648,7 @@ Just text: Instance is running, Instance is not running
648
648
 
649
649
  ### `pattern`
650
650
 
651
- read-only field with pattern like 'https://${data.ip}:${data.port}' (will not be saved in config)
651
+ The read-only field with a pattern like 'https://${data.ip}:${data.port}' (will not be saved in config)
652
652
  Text input with the read-only flag, that shows a pattern.
653
653
 
654
654
  | Property | Description |
@@ -658,7 +658,7 @@ Text input with the read-only flag, that shows a pattern.
658
658
 
659
659
  ### `sendTo`
660
660
 
661
- button that sends request to instance (<https://github.com/iobroker-community-adapters/ioBroker.email/blob/master/admin/index_m.html#L128>)
661
+ Button that sends a request to the current instance (<https://github.com/iobroker-community-adapters/ioBroker.email/blob/master/admin/index_m.html#L128>)
662
662
 
663
663
  | Property | Description |
664
664
  |-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -876,7 +876,7 @@ Shows CRON settings. You have 3 options:
876
876
  | `simple` | show simple CRON settings |
877
877
 
878
878
  ### `fileSelector`
879
- Select a file from one folder as drop down menu. And if you want you can upload a new file to this folder.
879
+ Select a file from one folder as a drop-down menu. And if you want, you can upload a new file to this folder.
880
880
 
881
881
  only Admin6
882
882
 
@@ -1079,7 +1079,7 @@ Shows autocomplete control with the given from the instance values.
1079
1079
  | `alsoDependsOn` | by change of which attributes, the command must be resent |
1080
1080
  | `maxLength` | max length of the text in field |
1081
1081
 
1082
- To use this option, your adapter must implement message handler:
1082
+ To use this option, your adapter must implement a message handler:
1083
1083
 
1084
1084
  The result of command must be an array in form `["value1", {"value": "value2", "label": "Value2"}, ...]` (keys and names (values) must be unique)
1085
1085
  See `selectSendTo` for handler example
@@ -1104,7 +1104,7 @@ The result of command must be a string or object with the following parameters:
1104
1104
  {
1105
1105
  text: "text to show", // mandatory
1106
1106
  style: { color: "red" }, // optional
1107
- icon: "search", // optional. It could be base64 or link to image in the same folder as jsonConfig.json file
1107
+ icon: "search", // optional. It could be base64 or link to an image in the same folder as jsonConfig.json file
1108
1108
  // possible predefined names: edit, rename, delete, refresh, add, search, unpair, pair, identify, play, stop, pause, forward, backward, next, previous, lamp, backlight, dimmer, socket, settings, group, user, qrcode, connection, no-connection, visible
1109
1109
  iconStyle: { width: 30 }, // optional
1110
1110
  }
@@ -1153,7 +1153,7 @@ adapter.on("message", (obj) => {
1153
1153
 
1154
1154
  ### `coordinates`
1155
1155
 
1156
- Determines current location and used `system.config` coordinates if not possible in form "latitude,longitude"
1156
+ Determines current location and used `system.config` coordinates if not possible in form `latitude,longitude`
1157
1157
 
1158
1158
  | Property | Description |
1159
1159
  |-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -1174,7 +1174,7 @@ Select the interface of the host, where the instance runs
1174
1174
 
1175
1175
  ### `license`
1176
1176
 
1177
- shows the license information if not already accepted. One of attributes `texts` or `licenseUrl` must be defined. When the license is accepted, the defined configuration attribute will be set to `true`.
1177
+ It shows the license information if not already accepted. One of attributes `texts` or `licenseUrl` must be defined. When the license is accepted, the defined configuration attribute will be set to `true`.
1178
1178
 
1179
1179
  | Property | Description |
1180
1180
  |--------------|------------------------------------------------------------------------------------------------------------|
@@ -1209,7 +1209,7 @@ Show iobroker UUID
1209
1209
 
1210
1210
  ### `port`
1211
1211
 
1212
- Special input for ports. It checks automatically if port is used by other instances and shows a warning
1212
+ Special input for ports. It checks automatically if the port is used by other instances and shows a warning
1213
1213
 
1214
1214
  | Property | Description |
1215
1215
  |----------|-------------------------------------------------------------------------------------------------------------------------------|
@@ -1290,7 +1290,7 @@ Shows closable static text with optional title and icon. (From admin >= 7.6.19)
1290
1290
 
1291
1291
  show device manager. For that, the adapter must support device manager protocol. See iobroker/dm-utils.
1292
1292
 
1293
- Here is an example of how to show device manager in a tab:
1293
+ Here is an example of how to show the device manager in a tab:
1294
1294
 
1295
1295
  ```json5
1296
1296
  {
@@ -1331,7 +1331,7 @@ These options are used to define the width of elements on different screen sizes
1331
1331
 
1332
1332
  Valid numbers are 1 to 12.
1333
1333
 
1334
- If you specify a number, for example 6, then the width of the element will be 6/12 (50%) of the screen width or for example 3, then the width of the element will be 3/12 (25%) of the screen width.
1334
+ If you specify a number, for example, 6, then the width of the element will be 6/12 (50%) of the screen width or, for example, 3, then the width of the element will be 3/12 (25%) of the screen width.
1335
1335
  Assign numbers to the different layout options specify the width of the element for the different screen sizes.
1336
1336
 
1337
1337
  | option | description |
@@ -1442,7 +1442,7 @@ Example:
1442
1442
  In this case input must be text, where shown `__different__`, with the autocomplete option of three possible values.
1443
1443
  Users can select from dropdown 1000, 2000 or 3000 or input their own new value, e.g., 500.
1444
1444
 
1445
- Boolean must support indeterminate if value is [false, true]
1445
+ Boolean must support indeterminate if a value is [false, true]
1446
1446
 
1447
1447
  For non changed `__different__` the value different must be returned:
1448
1448
 
@@ -1520,7 +1520,7 @@ If the `alive` status changes, so all fields must be updated, validated, disable
1520
1520
 
1521
1521
  The following variables are available in JS function in adapter settings:
1522
1522
 
1523
- - `data` - native settings for this instance or current line in the table (to access all settings use globalData)
1523
+ - `data` - native settings for this instance or current line in the table (to access all settings, use globalData)
1524
1524
  - `_system` - system configuration
1525
1525
  - `_alive` - is instance being alive
1526
1526
  - `_common` - common settings for this instance
@@ -1560,7 +1560,7 @@ const isValid = func(
1560
1560
 
1561
1561
  The following variables are available in JS function in custom settings:
1562
1562
 
1563
- - `data` - current custom settings or current line in the table (to access all settings use globalData)
1563
+ - `data` - current custom settings or current line in the table (to access all settings, use globalData)
1564
1564
  - `originalData` - Unchanged data
1565
1565
  - `_system` - system configuration
1566
1566
  - `instanceObj` - adapter instance object
@@ -1677,12 +1677,15 @@ The schema is used here: https://github.com/SchemaStore/schemastore/blob/6da29cd
1677
1677
  ### **WORK IN PROGRESS**
1678
1678
  -->
1679
1679
  ## Changelog
1680
+ ### 8.1.11 (2026-02-12)
1681
+ - (@GermanBluefox) Added the copy-to-clipboard dialog for `sendTo`
1682
+
1680
1683
  ### 8.1.9 (2026-02-10)
1681
1684
  - (@GermanBluefox) Hiding the whole line in the table if shown as card and the line is empty
1682
- - (@GermanBluefox) Added the header to table in the card mode
1685
+ - (@GermanBluefox) Added the header to the table in the card mode
1683
1686
 
1684
1687
  ### 8.1.3 (2026-02-09)
1685
- - (@GermanBluefox) Added component `yamlEditor` for editing yaml files in admin
1688
+ - (@GermanBluefox) Added component `yamlEditor` for editing YAML files in admin
1686
1689
 
1687
1690
  ### 8.1.1 (2026-02-06)
1688
1691
  - (@GermanBluefox) Added `iframe` and `iframeSendTo` components
@@ -9,8 +9,8 @@ interface ConfigCheckDockerState extends ConfigGenericState {
9
9
  interface ConfigCheckDockerProps extends ConfigGenericProps {
10
10
  schema: ConfigItemCheckDocker;
11
11
  }
12
- declare class ConfigCheckDocker extends ConfigGeneric<ConfigCheckDockerProps, ConfigCheckDockerState> {
12
+ export default class ConfigCheckDocker extends ConfigGeneric<ConfigCheckDockerProps, ConfigCheckDockerState> {
13
13
  componentDidMount(): Promise<void>;
14
- renderItem(error: unknown, disabled: boolean): JSX.Element;
14
+ renderItem(_error: unknown, disabled: boolean): JSX.Element;
15
15
  }
16
- export default ConfigCheckDocker;
16
+ export {};
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import { FormControlLabel, Checkbox, FormHelperText, FormControl, CircularProgress } from '@mui/material';
3
3
  import { I18n } from '@iobroker/adapter-react-v5';
4
4
  import ConfigGeneric from './ConfigGeneric';
5
- // Send to admin message to check if the docker available and if available, show checkbox, else show warning if specified in the schema
6
- class ConfigCheckDocker extends ConfigGeneric {
5
+ // Send to an admin message to check if the docker available and if available, show checkbox, else show warning if specified in the schema
6
+ export default class ConfigCheckDocker extends ConfigGeneric {
7
7
  async componentDidMount() {
8
8
  super.componentDidMount();
9
9
  const id = await this.props.oContext.socket.getCurrentInstance();
@@ -20,7 +20,7 @@ class ConfigCheckDocker extends ConfigGeneric {
20
20
  });
21
21
  });
22
22
  }
23
- renderItem(error, disabled) {
23
+ renderItem(_error, disabled) {
24
24
  const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
25
25
  if (this.state.requesting) {
26
26
  return React.createElement(CircularProgress, null);
@@ -48,5 +48,4 @@ class ConfigCheckDocker extends ConfigGeneric {
48
48
  this.props.schema.help ? (React.createElement(FormHelperText, null, this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation))) : null));
49
49
  }
50
50
  }
51
- export default ConfigCheckDocker;
52
51
  //# sourceMappingURL=ConfigCheckDocker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigCheckDocker.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigCheckDocker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,e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AK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAC9C;YACD,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAC9B,oBAAC,cAAc,QACV,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CACxD,CACpB,CAAC,CAAC,CAAC,IAAI;YACP,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,oBAAC,cAAc,QACV,IAAI,CAAC,UAAU,CACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACY,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ;AAED,eAAe,iBAAiB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { FormControlLabel, Checkbox, FormHelperText, FormControl, CircularProgress } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemCheckDocker } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface ConfigCheckDockerState extends ConfigGenericState {\n version: string;\n errorDocker: string;\n requesting: boolean;\n}\n\ninterface ConfigCheckDockerProps extends ConfigGenericProps {\n schema: ConfigItemCheckDocker;\n}\n\n// Send to admin message to check if the docker available and if available, show checkbox, else show warning if specified in the schema\nclass ConfigCheckDocker extends ConfigGeneric<ConfigCheckDockerProps, ConfigCheckDockerState> {\n async componentDidMount(): Promise<void> {\n super.componentDidMount();\n const id = await this.props.oContext.socket.getCurrentInstance();\n this.setState({ requesting: true }, async () => {\n const result: {\n version?: string;\n daemonRunning?: boolean;\n } = await this.props.oContext.socket.sendTo(id, 'checkDocker', null);\n this.setState({\n requesting: false,\n version: result?.version || '',\n errorDocker: result\n ? !result.daemonRunning\n ? I18n.t('ra_Docker is not installed or not running')\n : ''\n : I18n.t('ra_No response from admin'),\n });\n });\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n if (this.state.requesting) {\n return <CircularProgress />;\n }\n if (this.state.errorDocker && !value) {\n return (\n <FormHelperText style={{ color: 'orange' }}>\n {I18n.t('ra_Docker is not available')}:&nbsp;\n {I18n.t(`ra_${this.state.errorDocker}`).replace(/^ra_/, '')}\n </FormHelperText>\n );\n }\n return (\n <FormControl\n style={{ width: '100%' }}\n variant=\"standard\"\n >\n <FormControlLabel\n onClick={e => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!disabled) {\n const mayByPromise = this.onChange(this.props.attr, !value);\n if (mayByPromise instanceof Promise) {\n void mayByPromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n }\n }}\n control={\n <Checkbox\n checked={!!value}\n onChange={e => {\n void this.onChange(this.props.attr, e.target.checked);\n }}\n disabled={disabled || (!!this.state.errorDocker && !value)}\n />\n }\n label={this.getText(this.props.schema.label)}\n />\n {!this.props.schema.hideVersion ? (\n <FormHelperText>\n {this.state.errorDocker ? this.state.errorDocker : this.state.version}\n </FormHelperText>\n ) : null}\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}\n\nexport default ConfigCheckDocker;\n"]}
1
+ {"version":3,"file":"ConfigCheckDocker.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigCheckDocker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,gBAAgB,E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,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,GAC5D,EAEN,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAC9C;YACD,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAC9B,oBAAC,cAAc,QACV,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CACxD,CACpB,CAAC,CAAC,CAAC,IAAI;YACP,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,oBAAC,cAAc,QACV,IAAI,CAAC,UAAU,CACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACY,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { FormControlLabel, Checkbox, FormHelperText, FormControl, CircularProgress } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemCheckDocker } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\ninterface ConfigCheckDockerState extends ConfigGenericState {\n version: string;\n errorDocker: string;\n requesting: boolean;\n}\n\ninterface ConfigCheckDockerProps extends ConfigGenericProps {\n schema: ConfigItemCheckDocker;\n}\n\n// Send to an admin message to check if the docker available and if available, show checkbox, else show warning if specified in the schema\nexport default class ConfigCheckDocker extends ConfigGeneric<ConfigCheckDockerProps, ConfigCheckDockerState> {\n async componentDidMount(): Promise<void> {\n super.componentDidMount();\n const id = await this.props.oContext.socket.getCurrentInstance();\n this.setState({ requesting: true }, async () => {\n const result: {\n version?: string;\n daemonRunning?: boolean;\n } = await this.props.oContext.socket.sendTo(id, 'checkDocker', null);\n this.setState({\n requesting: false,\n version: result?.version || '',\n errorDocker: result\n ? !result.daemonRunning\n ? I18n.t('ra_Docker is not installed or not running')\n : ''\n : I18n.t('ra_No response from admin'),\n });\n });\n }\n\n renderItem(_error: unknown, disabled: boolean): JSX.Element {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n if (this.state.requesting) {\n return <CircularProgress />;\n }\n if (this.state.errorDocker && !value) {\n return (\n <FormHelperText style={{ color: 'orange' }}>\n {I18n.t('ra_Docker is not available')}:&nbsp;\n {I18n.t(`ra_${this.state.errorDocker}`).replace(/^ra_/, '')}\n </FormHelperText>\n );\n }\n return (\n <FormControl\n style={{ width: '100%' }}\n variant=\"standard\"\n >\n <FormControlLabel\n onClick={e => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!disabled) {\n const mayByPromise = this.onChange(this.props.attr, !value);\n if (mayByPromise instanceof Promise) {\n void mayByPromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n }\n }}\n control={\n <Checkbox\n checked={!!value}\n onChange={e => {\n void this.onChange(this.props.attr, e.target.checked);\n }}\n disabled={disabled || (!!this.state.errorDocker && !value)}\n />\n }\n label={this.getText(this.props.schema.label)}\n />\n {!this.props.schema.hideVersion ? (\n <FormHelperText>\n {this.state.errorDocker ? this.state.errorDocker : this.state.version}\n </FormHelperText>\n ) : null}\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}\n"]}
@@ -7,15 +7,21 @@ interface ConfigSendToProps extends ConfigGenericProps {
7
7
  interface ConfigSendToState extends ConfigGenericState {
8
8
  _error: string;
9
9
  _message: string;
10
+ _copyDialog: {
11
+ text: string;
12
+ title?: ioBroker.StringOrTranslated;
13
+ type?: 'json' | 'css' | 'html' | 'json5' | 'yaml';
14
+ };
10
15
  hostname: string;
11
16
  running?: boolean;
12
17
  }
13
- declare class ConfigSendto extends ConfigGeneric<ConfigSendToProps, ConfigSendToState> {
18
+ export default class ConfigSendto extends ConfigGeneric<ConfigSendToProps, ConfigSendToState> {
14
19
  componentDidMount(): Promise<void>;
15
20
  renderErrorDialog(): JSX.Element | null;
16
21
  renderMessageDialog(): JSX.Element | null;
22
+ renderCopyDialog(): JSX.Element | null;
17
23
  _onClick(): void;
18
24
  renderDialogConfirm(): JSX.Element | null;
19
25
  renderItem(error: Error | undefined, disabled: boolean): JSX.Element;
20
26
  }
21
- export default ConfigSendto;
27
+ export {};
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Button, CircularProgress } from '@mui/material';
3
3
  import { Warning as IconWarning, Error as IconError, Info as IconInfo } from '@mui/icons-material';
4
- import { DialogConfirm, DialogError, DialogMessage, I18n } from '@iobroker/adapter-react-v5';
4
+ import { DialogConfirm, DialogError, DialogMessage, I18n, copy } from '@iobroker/adapter-react-v5';
5
5
  import ConfigGeneric from './ConfigGeneric';
6
+ import Editor from './wrapper/Components/Editor';
7
+ import CustomModal from './wrapper/Components/CustomModal';
6
8
  const styles = {
7
9
  fullWidth: {
8
10
  width: '100%',
@@ -110,7 +112,7 @@ function findNetworkAddressOfHost(obj, localIp) {
110
112
  }
111
113
  return hostIp;
112
114
  }
113
- class ConfigSendto extends ConfigGeneric {
115
+ export default class ConfigSendto extends ConfigGeneric {
114
116
  async componentDidMount() {
115
117
  super.componentDidMount();
116
118
  let hostname = window.location.hostname;
@@ -151,6 +153,21 @@ class ConfigSendto extends ConfigGeneric {
151
153
  }
152
154
  return null;
153
155
  }
156
+ renderCopyDialog() {
157
+ if (this.state._copyDialog) {
158
+ return (React.createElement(CustomModal, { title: this.getText(this.state._copyDialog.title || I18n.t('ra_Result')), overflowHidden: true, onClose: () => {
159
+ this.setState({ _copyDialog: null });
160
+ }, onApply: () => {
161
+ // Copy to clipboard
162
+ copy(this.state._copyDialog.text);
163
+ window.alert(I18n.t('ra_Copied'));
164
+ this.setState({ _copyDialog: null });
165
+ }, titleButtonApply: I18n.t('ra_Copy content') },
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 }))));
168
+ }
169
+ return null;
170
+ }
154
171
  _onClick() {
155
172
  this.props.oContext.onCommandRunning(true);
156
173
  this.setState({ running: true });
@@ -194,7 +211,7 @@ class ConfigSendto extends ConfigGeneric {
194
211
  timeout = undefined;
195
212
  }
196
213
  if (response?.error) {
197
- if (this.props.schema.error && this.props.schema.error[response.error]) {
214
+ if (this.props.schema.error?.[response.error]) {
198
215
  let error = this.getText(this.props.schema.error[response.error]);
199
216
  response.args?.forEach((arg) => (error = error.replace('%s', arg)));
200
217
  this.setState({ _error: error });
@@ -235,6 +252,9 @@ class ConfigSendto extends ConfigGeneric {
235
252
  else if (response?.result) {
236
253
  window.alert(typeof response.result === 'object' ? JSON.stringify(response.result) : response.result);
237
254
  }
255
+ else if (response?.copyDialog) {
256
+ this.setState({ _copyDialog: response.copyDialog });
257
+ }
238
258
  else {
239
259
  window.alert(I18n.t('ra_Ok'));
240
260
  }
@@ -289,8 +309,8 @@ class ConfigSendto extends ConfigGeneric {
289
309
  this.props.schema.showProcess && this.state.running ? (React.createElement(CircularProgress, { size: 20, style: { marginRight: 8 } })) : null,
290
310
  this.getText(this.props.schema.label, this.props.schema.noTranslation)),
291
311
  this.renderErrorDialog(),
292
- this.renderMessageDialog()));
312
+ this.renderMessageDialog(),
313
+ this.renderCopyDialog()));
293
314
  }
294
315
  }
295
- export default ConfigSendto;
296
316
  //# sourceMappingURL=ConfigSendto.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigSend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AAE,EAChF,QAAQ,EAAE,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EACvC,SAAS,EAAE,IAAI,EACf,KAAK,EACD,IAAI,CAAC,KAAK,CAAC,KAAK;oBACZ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;oBAC7C,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAE5C,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;oBACpB,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,CACzB,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,YAAY,CAAC","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 } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemSendTo } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\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 {\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;\n}\n\ninterface ConfigSendToProps extends ConfigGenericProps {\n schema: ConfigItemSendTo;\n}\n\ninterface ConfigSendToState extends ConfigGenericState {\n _error: string;\n _message: string;\n hostname: string;\n running?: boolean;\n}\n\nclass ConfigSendto extends ConfigGeneric<ConfigSendToProps, ConfigSendToState> {\n async componentDidMount(): Promise<void> {\n 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.props.oContext.socket.getObject(\n `system.adapter.${adminInstance}` as ioBroker.ObjectIDs.Instance,\n );\n\n if (instanceObj) {\n const hostObj = await this.props.oContext.socket.getObject(`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();\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 _onClick(): 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> = this.props.schema.data;\n if (data === undefined && this.props.schema.jsonData) {\n const dataStr = this.getPattern(\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 if (data === undefined) {\n data = null;\n }\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('ra_Request timed out'), running: false });\n },\n parseInt(this.props.schema.timeout as any as string, 10) || 10000,\n );\n }\n\n void this.props.oContext.socket\n .sendTo(\n `${this.props.oContext.adapterName}.${this.props.oContext.instance}`,\n this.props.schema.command || 'send',\n data,\n )\n .then(async (response: Record<string, any>) => {\n if (timeout) {\n clearTimeout(timeout);\n timeout = undefined;\n }\n if (response?.error) {\n if (this.props.schema.error && 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('ra_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 {\n window.alert(I18n.t('ra_Ok'));\n }\n\n if (response?.saveConfig) {\n this.props.onChange(null, null, null, true);\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('ra_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 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('ra_Please confirm')}\n text={this.getText(confirm.text)}\n ok={this.getText(confirm.ok) || I18n.t('ra_Ok')}\n cancel={this.getText(confirm.cancel) || I18n.t('ra_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('ra_Instance is not alive')\n }\n onClick={() => {\n if (this.props.schema.confirm) {\n this.setState({ confirmDialog: true });\n } else {\n this._onClick();\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 </div>\n );\n }\n}\n\nexport default ConfigSendto;\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,4BAA4B,CAAC;AAGnG,OAAO,aAAmE,MAAM,iBAAiB,CAAC;A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AC,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;oBACpB,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/adapter-react-v5';\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 {\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;\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 };\n hostname: string;\n running?: boolean;\n}\n\nexport default class ConfigSendto extends ConfigGeneric<ConfigSendToProps, ConfigSendToState> {\n async componentDidMount(): Promise<void> {\n 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.props.oContext.socket.getObject(\n `system.adapter.${adminInstance}` as ioBroker.ObjectIDs.Instance,\n );\n\n if (instanceObj) {\n const hostObj = await this.props.oContext.socket.getObject(`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();\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('ra_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('ra_Copied'));\n this.setState({ _copyDialog: null });\n }}\n titleButtonApply={I18n.t('ra_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 _onClick(): 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> = this.props.schema.data;\n if (data === undefined && this.props.schema.jsonData) {\n const dataStr = this.getPattern(\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 if (data === undefined) {\n data = null;\n }\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('ra_Request timed out'), running: false });\n },\n parseInt(this.props.schema.timeout as any as string, 10) || 10000,\n );\n }\n\n void this.props.oContext.socket\n .sendTo(\n `${this.props.oContext.adapterName}.${this.props.oContext.instance}`,\n this.props.schema.command || 'send',\n data,\n )\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('ra_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('ra_Ok'));\n }\n\n if (response?.saveConfig) {\n this.props.onChange(null, null, null, 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('ra_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 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('ra_Please confirm')}\n text={this.getText(confirm.text)}\n ok={this.getText(confirm.ok) || I18n.t('ra_Ok')}\n cancel={this.getText(confirm.cancel) || I18n.t('ra_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('ra_Instance is not alive')\n }\n onClick={() => {\n if (this.props.schema.confirm) {\n this.setState({ confirmDialog: true });\n } else {\n this._onClick();\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"]}
package/build/types.d.ts CHANGED
@@ -737,8 +737,10 @@ export interface ConfigItemSendTo extends Omit<ConfigItem, 'data'> {
737
737
  command?: string;
738
738
  jsonData?: string;
739
739
  data?: Record<string, any>;
740
- result?: string;
741
- error?: string;
740
+ /** Translations for possible result codes. E.g. `{"RESULT_OK": "Operation successful"}`. The translation must exist in i18n files. */
741
+ result?: Record<string, ioBroker.StringOrTranslated>;
742
+ /** Translations for possible error codes. E.g. `{"ERR_NO_OBJECT": "Object not found"}`. The translation must exist in i18n files. */
743
+ error?: Record<string, ioBroker.StringOrTranslated>;
742
744
  variant?: 'contained' | 'outlined';
743
745
  openUrl?: boolean;
744
746
  reloadBrowser?: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iobroker/json-config",
3
3
  "description": "This package contains the ioBroker JSON config UI components",
4
- "version": "8.1.9",
4
+ "version": "8.1.11",
5
5
  "author": {
6
6
  "name": "bluefox",
7
7
  "email": "dogafox@gmail.com"