@iobroker/json-config 8.4.1 → 8.4.3
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 +3 -0
- package/build/JsonConfigComponent/ConfigCertCollection.js +1 -1
- package/build/JsonConfigComponent/ConfigCertCollection.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCertificates.js +1 -1
- package/build/JsonConfigComponent/ConfigCertificates.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCheckLicense.js +5 -5
- package/build/JsonConfigComponent/ConfigCheckLicense.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCoordinates.js +1 -1
- package/build/JsonConfigComponent/ConfigCoordinates.js.map +1 -1
- package/build/JsonConfigComponent/ConfigGeneric.d.ts +1 -0
- package/build/JsonConfigComponent/ConfigGeneric.js +7 -0
- package/build/JsonConfigComponent/ConfigGeneric.js.map +1 -1
- package/build/JsonConfigComponent/ConfigObjectId.js +1 -1
- package/build/JsonConfigComponent/ConfigObjectId.js.map +1 -1
- package/build/JsonConfigComponent/ConfigPort.js +1 -1
- package/build/JsonConfigComponent/ConfigPort.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSelect.js +1 -1
- package/build/JsonConfigComponent/ConfigSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSendto.js +2 -2
- package/build/JsonConfigComponent/ConfigSendto.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSetState.js +1 -1
- package/build/JsonConfigComponent/ConfigSetState.js.map +1 -1
- package/build/JsonConfigComponent/ConfigState.js +1 -1
- package/build/JsonConfigComponent/ConfigState.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTable.js +1 -1
- package/build/JsonConfigComponent/ConfigTable.js.map +1 -1
- package/build/JsonConfigComponent/ConfigUUID.js +1 -1
- package/build/JsonConfigComponent/ConfigUUID.js.map +1 -1
- package/build/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Con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,EAAE,CAAC;wBACpD,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;wBAC/E,IAAI,YAAY,YAAY,OAAO,EAAE,CAAC;4BAClC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;gCACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC;4BACrE,CAAC,CAAC,CAAC;wBACP,CAAC;oBACL,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC,EACD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,EACxD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,UAAU,EACN,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAC9B,CAAC,CAAC,KAAK;gBACP,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,GAEb,CACL,CAAC;IACN,CAAC;CACJ;AAED,eAAe,UAAU,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { TextField } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemPort } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, any> = {\n warning: {\n '& .Mui-error': {\n color: 'orange',\n },\n },\n};\n\ninterface Port {\n name: string;\n port: number;\n bind: string;\n v6bind: string;\n enabled: boolean;\n}\n\ninterface ConfigPortProps extends ConfigGenericProps {\n schema: ConfigItemPort;\n}\n\ninterface ConfigPortState extends ConfigGenericState {\n _value: string;\n oldValue: string | null;\n ports: Port[];\n}\n\nclass ConfigPort extends ConfigGeneric<ConfigPortProps, ConfigPortState> {\n private updateTimeout?: ReturnType<typeof setTimeout>;\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n let _value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n if (_value === null || _value === undefined) {\n _value = '';\n }\n this.setState({ _value: _value.toString(), oldValue: _value.toString() });\n\n // read all instances\n const instances: ioBroker.InstanceObject[] = await this.props.oContext.socket.getAdapterInstances();\n\n const ownId = `system.adapter.${this.props.oContext.adapterName}.${this.props.oContext.instance}`;\n const instanceObj: ioBroker.InstanceObject = (await this.props.oContext.getCachedObject(\n ownId,\n )) as ioBroker.InstanceObject;\n const ownHostname = instanceObj?.common.host;\n\n const ports: Port[] = [];\n instances.forEach(instance => {\n // ignore own instance and instances on another host\n if (!instance || instance._id === ownId || instance.common.host !== ownHostname) {\n return;\n }\n // check port only if bind attribute is present too\n if (!instance.native?.bind) {\n return;\n }\n\n // if let's encrypt is enabled and update is enabled, then add port to check\n if (instance?.native && instance.native.secure && instance.native.leEnabled && instance.native.leUpdate) {\n const port = parseInt(instance.native.leCheckPort || instance.native.lePort, 10);\n if (port) {\n ports.push({\n name: `${instance._id.replace('system.adapter.', '')} (LE)`,\n port,\n v6bind: instance.native.bind.includes(':') ? instance.native.bind : instance.native.v6bind,\n bind: instance.native.bind,\n enabled: !!instance.common?.enabled,\n });\n }\n }\n\n const port = parseInt(instance?.native?.port, 10);\n if (port) {\n ports.push({\n name: instance._id.replace('system.adapter.', ''),\n bind: instance.native.bind,\n v6bind: instance.native.bind.includes(':') ? instance.native.bind : instance.native.v6bind,\n port,\n enabled: !!instance.common?.enabled,\n });\n }\n });\n this.setState({ ports });\n }\n\n static getDerivedStateFromProps(props: ConfigPortProps, state: ConfigPortState): Partial<ConfigPortState> | null {\n const _value = ConfigGeneric.getValue(props.data, props.attr);\n if (\n _value === null ||\n _value === undefined ||\n state.oldValue === null ||\n state.oldValue === undefined ||\n (_value.toString() !== parseInt(state._value, 10).toString() &&\n _value.toString() !== state.oldValue.toString())\n ) {\n return { _value };\n }\n\n return null;\n }\n\n checkValue(value: string): string | null {\n if (value === null || value === undefined) {\n return null;\n }\n\n const min = this.props.schema.min ?? 20;\n const max = this.props.schema.max || 0xffff;\n\n value = value.toString().trim();\n const f = value === '' ? 0 : parseInt(value, 10);\n\n if (value !== '' && Number.isNaN(f)) {\n return 'ra_Not a number';\n }\n\n if (value !== '' && window.isFinite(Number(value))) {\n if (f < min) {\n return 'ra_Too small';\n }\n if (f > max) {\n return 'ra_Too big';\n }\n if (value === '' || value === '-' || Number.isNaN(f)) {\n return 'ra_Not a number';\n }\n\n return null;\n }\n\n return 'ra_Not a number';\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element {\n if (this.state.oldValue !== null && this.state.oldValue !== undefined) {\n if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n }\n this.updateTimeout = setTimeout(() => {\n this.updateTimeout = undefined;\n this.setState({ oldValue: null });\n }, 30);\n } else if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n this.updateTimeout = undefined;\n }\n\n const min = this.props.schema.min ?? 20;\n const max = this.props.schema.max || 0xffff;\n\n let warning;\n if (this.state.ports) {\n const num = parseInt(this.state._value, 10);\n\n if (num) {\n // Filter ports that would actually conflict with our configuration\n // A port conflict occurs when:\n // 1. Same port AND (no bind address specified OR bind addresses would conflict)\n // 2. Bind addresses conflict when:\n // - Both bind to the same specific IP address, OR\n // - One binds to 0.0.0.0/:: (all interfaces) and the other to any address, OR\n // - One binds to a specific IP and the other binds to 0.0.0.0/::\n const currentBind = this.props.data.bind;\n const ports = this.state.ports.filter(item => {\n if (item.port !== num) {\n return false; // Different port, no conflict\n }\n\n // Same port, check if bind addresses would conflict\n const itemBind = item.bind;\n const itemV6bind = item.v6bind;\n\n // If current config has no bind address, use old behavior (check all)\n if (!currentBind) {\n return true;\n }\n\n // If other adapter has no bind address, assume it could conflict\n if (!itemBind) {\n return true;\n }\n\n // Check for IPv4 conflicts\n if (currentBind === '0.0.0.0' || itemBind === '0.0.0.0') {\n // One binds to all interfaces, so there's a conflict\n return true;\n }\n\n // Check for IPv6 conflicts\n if (currentBind === '::' || itemV6bind === '::') {\n // One binds to all IPv6 interfaces, so there's a conflict\n return true;\n }\n\n // Check for exact bind address match\n if (currentBind === itemBind || currentBind === itemV6bind) {\n return true;\n }\n\n // Different specific bind addresses, no conflict\n return false;\n });\n\n let idx = ports.findIndex(item => item.port === num && item.enabled);\n if (idx !== -1) {\n // Find the original port info to get the correct name\n const originalPort = this.state.ports.find(\n p => p.port === num && p.enabled && ports.some(fp => fp.name === p.name && fp.bind === p.bind),\n );\n error = I18n.t('ra_Port is already used by %s', originalPort?.name || ports[idx].name);\n } else {\n idx = ports.findIndex(item => item.port === num && !item.enabled);\n if (idx !== -1) {\n warning = true;\n const originalPort = this.state.ports.find(\n p =>\n p.port === num &&\n !p.enabled &&\n ports.some(fp => fp.name === p.name && fp.bind === p.bind),\n );\n error = I18n.t('ra_Port could be used by %s', originalPort?.name || ports[idx].name);\n }\n }\n }\n }\n\n if (!error && this.state._value !== null && this.state._value !== undefined) {\n error = this.checkValue(this.state._value);\n if (typeof error === 'string') {\n error = I18n.t(error);\n }\n }\n\n return (\n <TextField\n variant=\"standard\"\n type=\"number\"\n fullWidth\n slotProps={{\n htmlInput: {\n min,\n max,\n readOnly: this.props.schema.readOnly || false,\n },\n }}\n value={this.state._value ?? ''}\n error={!!error}\n disabled={!!disabled}\n sx={warning ? styles.warning : undefined}\n onChange={e => {\n const _value = Number(e.target.value.toString().replace(/[^0-9]/g, '')).toString();\n const _error = this.checkValue(_value);\n if (_error) {\n this.onError(this.props.attr, I18n.t(_error));\n } else {\n this.onError(this.props.attr); // clear error\n }\n\n this.setState({ _value, oldValue: this.state._value }, () => {\n if (_value.trim() === parseInt(_value, 10).toString()) {\n const maybePromise = this.onChange(this.props.attr, parseInt(_value, 10) || 0);\n if (maybePromise instanceof Promise) {\n maybePromise.catch(err => {\n console.error(`Cannot set value for ${this.props.attr}: ${err}`);\n });\n }\n }\n });\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={\n error && typeof error === 'string'\n ? error\n : this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )\n }\n />\n );\n }\n}\n\nexport default ConfigPort;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigPort.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigPort.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwB;IAChC,OAAO,EAAE;QACL,cAAc,EAAE;YACZ,KAAK,EAAE,QAAQ;SAClB;KACJ;CACJ,CAAC;AAoBF,MAAM,UAAW,SAAQ,aAA+C;IAC5D,aAAa,CAAiC;IAEtD,KAAK,CAAC,iBAAiB;QACnB,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAChC,IAAI,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1C,MAAM,GAAG,EAAE,CAAC;QAChB,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,EAA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MAAM,CAAC,aAAa,CAClC,GAEb,CACL,CAAC;IACN,CAAC;CACJ;AAED,eAAe,UAAU,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { TextField } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemPort } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, any> = {\n warning: {\n '& .Mui-error': {\n color: 'orange',\n },\n },\n};\n\ninterface Port {\n name: string;\n port: number;\n bind: string;\n v6bind: string;\n enabled: boolean;\n}\n\ninterface ConfigPortProps extends ConfigGenericProps {\n schema: ConfigItemPort;\n}\n\ninterface ConfigPortState extends ConfigGenericState {\n _value: string;\n oldValue: string | null;\n ports: Port[];\n}\n\nclass ConfigPort extends ConfigGeneric<ConfigPortProps, ConfigPortState> {\n private updateTimeout?: ReturnType<typeof setTimeout>;\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n let _value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n if (_value === null || _value === undefined) {\n _value = '';\n }\n this.setState({ _value: _value.toString(), oldValue: _value.toString() });\n\n // read all instances\n const instances: ioBroker.InstanceObject[] = await this.props.oContext.socket.getAdapterInstances();\n\n const ownId = `system.adapter.${this.props.oContext.adapterName}.${this.props.oContext.instance}`;\n const instanceObj: ioBroker.InstanceObject = (await this.getCachedObject(ownId)) as ioBroker.InstanceObject;\n const ownHostname = instanceObj?.common.host;\n\n const ports: Port[] = [];\n instances.forEach(instance => {\n // ignore own instance and instances on another host\n if (!instance || instance._id === ownId || instance.common.host !== ownHostname) {\n return;\n }\n // check port only if bind attribute is present too\n if (!instance.native?.bind) {\n return;\n }\n\n // if let's encrypt is enabled and update is enabled, then add port to check\n if (instance?.native && instance.native.secure && instance.native.leEnabled && instance.native.leUpdate) {\n const port = parseInt(instance.native.leCheckPort || instance.native.lePort, 10);\n if (port) {\n ports.push({\n name: `${instance._id.replace('system.adapter.', '')} (LE)`,\n port,\n v6bind: instance.native.bind.includes(':') ? instance.native.bind : instance.native.v6bind,\n bind: instance.native.bind,\n enabled: !!instance.common?.enabled,\n });\n }\n }\n\n const port = parseInt(instance?.native?.port, 10);\n if (port) {\n ports.push({\n name: instance._id.replace('system.adapter.', ''),\n bind: instance.native.bind,\n v6bind: instance.native.bind.includes(':') ? instance.native.bind : instance.native.v6bind,\n port,\n enabled: !!instance.common?.enabled,\n });\n }\n });\n this.setState({ ports });\n }\n\n static getDerivedStateFromProps(props: ConfigPortProps, state: ConfigPortState): Partial<ConfigPortState> | null {\n const _value = ConfigGeneric.getValue(props.data, props.attr);\n if (\n _value === null ||\n _value === undefined ||\n state.oldValue === null ||\n state.oldValue === undefined ||\n (_value.toString() !== parseInt(state._value, 10).toString() &&\n _value.toString() !== state.oldValue.toString())\n ) {\n return { _value };\n }\n\n return null;\n }\n\n checkValue(value: string): string | null {\n if (value === null || value === undefined) {\n return null;\n }\n\n const min = this.props.schema.min ?? 20;\n const max = this.props.schema.max || 0xffff;\n\n value = value.toString().trim();\n const f = value === '' ? 0 : parseInt(value, 10);\n\n if (value !== '' && Number.isNaN(f)) {\n return 'ra_Not a number';\n }\n\n if (value !== '' && window.isFinite(Number(value))) {\n if (f < min) {\n return 'ra_Too small';\n }\n if (f > max) {\n return 'ra_Too big';\n }\n if (value === '' || value === '-' || Number.isNaN(f)) {\n return 'ra_Not a number';\n }\n\n return null;\n }\n\n return 'ra_Not a number';\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element {\n if (this.state.oldValue !== null && this.state.oldValue !== undefined) {\n if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n }\n this.updateTimeout = setTimeout(() => {\n this.updateTimeout = undefined;\n this.setState({ oldValue: null });\n }, 30);\n } else if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n this.updateTimeout = undefined;\n }\n\n const min = this.props.schema.min ?? 20;\n const max = this.props.schema.max || 0xffff;\n\n let warning;\n if (this.state.ports) {\n const num = parseInt(this.state._value, 10);\n\n if (num) {\n // Filter ports that would actually conflict with our configuration\n // A port conflict occurs when:\n // 1. Same port AND (no bind address specified OR bind addresses would conflict)\n // 2. Bind addresses conflict when:\n // - Both bind to the same specific IP address, OR\n // - One binds to 0.0.0.0/:: (all interfaces) and the other to any address, OR\n // - One binds to a specific IP and the other binds to 0.0.0.0/::\n const currentBind = this.props.data.bind;\n const ports = this.state.ports.filter(item => {\n if (item.port !== num) {\n return false; // Different port, no conflict\n }\n\n // Same port, check if bind addresses would conflict\n const itemBind = item.bind;\n const itemV6bind = item.v6bind;\n\n // If current config has no bind address, use old behavior (check all)\n if (!currentBind) {\n return true;\n }\n\n // If other adapter has no bind address, assume it could conflict\n if (!itemBind) {\n return true;\n }\n\n // Check for IPv4 conflicts\n if (currentBind === '0.0.0.0' || itemBind === '0.0.0.0') {\n // One binds to all interfaces, so there's a conflict\n return true;\n }\n\n // Check for IPv6 conflicts\n if (currentBind === '::' || itemV6bind === '::') {\n // One binds to all IPv6 interfaces, so there's a conflict\n return true;\n }\n\n // Check for exact bind address match\n if (currentBind === itemBind || currentBind === itemV6bind) {\n return true;\n }\n\n // Different specific bind addresses, no conflict\n return false;\n });\n\n let idx = ports.findIndex(item => item.port === num && item.enabled);\n if (idx !== -1) {\n // Find the original port info to get the correct name\n const originalPort = this.state.ports.find(\n p => p.port === num && p.enabled && ports.some(fp => fp.name === p.name && fp.bind === p.bind),\n );\n error = I18n.t('ra_Port is already used by %s', originalPort?.name || ports[idx].name);\n } else {\n idx = ports.findIndex(item => item.port === num && !item.enabled);\n if (idx !== -1) {\n warning = true;\n const originalPort = this.state.ports.find(\n p =>\n p.port === num &&\n !p.enabled &&\n ports.some(fp => fp.name === p.name && fp.bind === p.bind),\n );\n error = I18n.t('ra_Port could be used by %s', originalPort?.name || ports[idx].name);\n }\n }\n }\n }\n\n if (!error && this.state._value !== null && this.state._value !== undefined) {\n error = this.checkValue(this.state._value);\n if (typeof error === 'string') {\n error = I18n.t(error);\n }\n }\n\n return (\n <TextField\n variant=\"standard\"\n type=\"number\"\n fullWidth\n slotProps={{\n htmlInput: {\n min,\n max,\n readOnly: this.props.schema.readOnly || false,\n },\n }}\n value={this.state._value ?? ''}\n error={!!error}\n disabled={!!disabled}\n sx={warning ? styles.warning : undefined}\n onChange={e => {\n const _value = Number(e.target.value.toString().replace(/[^0-9]/g, '')).toString();\n const _error = this.checkValue(_value);\n if (_error) {\n this.onError(this.props.attr, I18n.t(_error));\n } else {\n this.onError(this.props.attr); // clear error\n }\n\n this.setState({ _value, oldValue: this.state._value }, () => {\n if (_value.trim() === parseInt(_value, 10).toString()) {\n const maybePromise = this.onChange(this.props.attr, parseInt(_value, 10) || 0);\n if (maybePromise instanceof Promise) {\n maybePromise.catch(err => {\n console.error(`Cannot set value for ${this.props.attr}: ${err}`);\n });\n }\n }\n });\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={\n error && typeof error === 'string'\n ? error\n : this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )\n }\n />\n );\n }\n}\n\nexport default ConfigPort;\n"]}
|
|
@@ -147,7 +147,7 @@ export default class ConfigSelect extends ConfigGeneric {
|
|
|
147
147
|
const selectOptions = this.state.selectOptions.filter(it => !it.hiddenValue);
|
|
148
148
|
const value = this._getValue();
|
|
149
149
|
const item = this.props.schema.multiple ? null : selectOptions.find(it => it.value == value); // let "==" be and not ===
|
|
150
|
-
return (React.createElement(FormControl, { variant: "standard", fullWidth: true, sx: this.props.table !== undefined
|
|
150
|
+
return (React.createElement(FormControl, { variant: "standard", fullWidth: true, sx: this.props.table !== undefined ? styles.noMargin : undefined, id: `jsonSelect_${this.props.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}` },
|
|
151
151
|
this.props.schema.label ? React.createElement(InputLabel, null, this.getText(this.props.schema.label)) : null,
|
|
152
152
|
React.createElement(Select, { variant: "standard", error: !!error, multiple: this.props.schema.multiple, disabled: !!disabled, value: value || '_', renderValue: (val) => this.props.schema.multiple ? (React.createElement("div", { style: { display: 'flex', flexWrap: 'wrap', gap: 0.5 } }, val.map((v) => {
|
|
153
153
|
const it = selectOptions.find(_item => _item.value === v);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigSelect.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EACH,UAAU,EACV,cAAc,EACd,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,EACR,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,KAAK,EACL,gBAAgB,EAChB,UAAU,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwB;IAChC,SAAS,EAAE;QACP,KAAK,EAAE,MAAM;KAChB;IACD,QAAQ,EAAE;QACN,OAAO,EAAE;YACL,SAAS,EAAE,CAAC;SACf;KACJ;IACD,IAAI,EAAE;QACF,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,CAAC;KACjB;CACJ,CAAC;AAqBF,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,aAAmE;IACjG,YAAY,GAAsB,EAAE,CAAC;IAE7C,KAAK,CAAC,iBAAiB;QACnB,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAChC,IAAI,KAAK,GAAsB,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAExF,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC7B,IAAI,OAAO,KAAK,KAA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oBACR,oBAAC,YAAY,IACT,OAAO,EAAE,EAAE,CAAC,KAAK,EACjB,SAAS,EAAE,EAAE,CAAC,WAAW,EACzB,SAAS,EAAE;4BACP,SAAS,EAAE;gCACP,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE;6BACpE;yBACJ,EACD,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,GAC5B,CACK,CACd,CAAC;YACN,CAAC,CAAC,CACG;YACR,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,oBAAC,cAAc,QACV,IAAI,CAAC,UAAU,CACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACY,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport {\n InputLabel,\n FormHelperText,\n FormControl,\n FormLabel,\n Select,\n MenuItem,\n ListSubheader,\n Chip,\n ListItemText,\n Checkbox,\n RadioGroup,\n Radio,\n FormControlLabel,\n Typography,\n} from '@mui/material';\n\nimport { I18n, Icon } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemSelect, ConfigItemSelectOption } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, any> = {\n fullWidth: {\n width: '100%',\n },\n noMargin: {\n '&>div': {\n marginTop: 0,\n },\n },\n icon: {\n width: 20,\n height: 20,\n marginRight: 4,\n },\n};\n\ninterface ConfigInstanceSelectProps extends ConfigGenericProps {\n schema: ConfigItemSelect;\n}\n\ninterface SelectItem {\n label: string;\n value: number | string;\n group?: boolean;\n hidden?: string | boolean;\n color?: string;\n description?: string;\n icon?: string;\n hiddenValue?: boolean;\n}\n\ninterface ConfigInstanceSelectState extends ConfigGenericState {\n selectOptions?: SelectItem[];\n}\n\nexport default class ConfigSelect extends ConfigGeneric<ConfigInstanceSelectProps, ConfigInstanceSelectState> {\n private initialValue: string | string[] = '';\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n let value: string | string[] = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n if (this.props.schema.multiple) {\n if (typeof value === 'string') {\n value = [value];\n } else if (value === null || value === undefined) {\n value = [];\n }\n }\n\n const selectOptions: {\n label: string;\n value: number | string;\n group?: boolean;\n hidden?: string | boolean;\n color?: string;\n description?: string;\n icon?: string;\n hiddenValue?: boolean;\n }[] = [];\n\n for (const item of this.props.schema.options || []) {\n // if optgroup\n const groupItem: {\n items: ConfigItemSelectOption[];\n label: ioBroker.StringOrTranslated;\n value?: number | string;\n hidden?: string | boolean;\n description?: string;\n } = item as {\n items: ConfigItemSelectOption[];\n label: ioBroker.StringOrTranslated;\n value?: number | string;\n hidden?: string | boolean;\n description?: string;\n };\n if (Array.isArray(groupItem.items)) {\n const selectItem: SelectItem = {\n label: this.getText(item.label, this.props.schema.noTranslation),\n value: item.value,\n group: true,\n color: item.color,\n description: this.getText(item.description),\n };\n selectItem.hiddenValue = await this.isHidden(selectItem);\n selectOptions.push(selectItem);\n for (const it of groupItem.items) {\n const selectSubItem: SelectItem = {\n label: this.getText(it.label, this.props.schema.noTranslation),\n value: it.value,\n hidden: it.hidden,\n color: item.color,\n description: this.getText(item.description),\n icon: it.icon,\n };\n selectSubItem.hiddenValue = await this.isHidden(selectSubItem);\n selectOptions.push(selectSubItem);\n }\n } else {\n const selectItem: SelectItem = {\n label: this.getText(item.label, this.props.schema.noTranslation),\n value: item.value,\n hidden: item.hidden,\n color: item.color,\n description: this.getText(item.description),\n icon: item.icon,\n };\n selectItem.hiddenValue = await this.isHidden(selectItem);\n selectOptions.push(selectItem);\n }\n }\n\n // Report value-to-label mapping to parent table for filtering\n if (this.props.onFilterLabelUpdate && this.props.table) {\n const valueToLabel: Record<string, string> = {};\n for (const opt of selectOptions) {\n if (!opt.group && opt.value !== ConfigGeneric.DIFFERENT_VALUE) {\n valueToLabel[opt.value.toString()] = opt.label;\n }\n }\n this.props.onFilterLabelUpdate(this.props.attr, valueToLabel);\n }\n\n // if __different\n if (Array.isArray(value) && !this.props.schema.multiple) {\n this.initialValue = [...value];\n selectOptions.unshift({\n label: I18n.t(ConfigGeneric.DIFFERENT_LABEL),\n value: ConfigGeneric.DIFFERENT_VALUE,\n });\n this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });\n } else {\n this.setState({ value, selectOptions });\n }\n }\n\n _getValue(): string | string[] {\n let value =\n this.state.value === null || this.state.value === undefined\n ? ConfigGeneric.getValue(this.props.data, this.props.attr)\n : this.state.value;\n\n if (this.props.schema.multiple) {\n if (typeof value === 'string') {\n value = [value];\n } else if (value === null || value === undefined) {\n value = [];\n }\n }\n\n return value;\n }\n\n private async isHidden(item: SelectItem): Promise<boolean> {\n // if optgroup or no hidden function\n if (!item.hidden) {\n return false;\n }\n\n if (this.props.custom) {\n return !!(await this.executeCustom(\n item.hidden,\n this.props.data,\n this.props.customObj,\n this.props.oContext.instanceObj,\n this.props.arrayIndex,\n this.props.globalData,\n ));\n }\n return !!(await this.execute(\n item.hidden,\n this.props.schema.default,\n this.props.data,\n this.props.arrayIndex,\n this.props.globalData,\n ));\n }\n\n renderRadio(error: string, disabled: boolean): JSX.Element {\n const selectOptions = this.state.selectOptions.filter(it => !it.hiddenValue && !it.group);\n const value = this._getValue();\n\n return (\n <FormControl\n fullWidth\n error={!!error}\n disabled={!!disabled}\n id={`jsonSelect_${this.props.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}`}\n >\n {this.props.schema.label ? <FormLabel>{this.getText(this.props.schema.label)}</FormLabel> : null}\n <RadioGroup\n row={!!this.props.schema.horizontal}\n value={value === undefined || value === null ? '' : value.toString()}\n onChange={e => {\n // find the original option value to preserve its type (number vs. string)\n const opt = selectOptions.find(it => it.value.toString() === e.target.value);\n const newValue = opt ? opt.value : e.target.value;\n this.setState({ value: newValue }, () => {\n const mayBePromise = this.onChange(this.props.attr, newValue);\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(e));\n }\n });\n }}\n >\n {selectOptions.map((it, i) => (\n <FormControlLabel\n key={i}\n value={it.value.toString()}\n control={<Radio />}\n title={it.description || ''}\n label={\n <span style={{ display: 'flex', alignItems: 'center' }}>\n {it.icon ? (\n <Icon\n src={it.icon}\n style={styles.icon}\n />\n ) : null}\n <Typography\n component=\"span\"\n style={{ color: it.color }}\n >\n {it.label}\n </Typography>\n </span>\n }\n style={it.value === ConfigGeneric.DIFFERENT_VALUE ? { opacity: 0.5 } : {}}\n />\n ))}\n </RadioGroup>\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 renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n if (!this.state.selectOptions) {\n return null;\n }\n\n if (this.props.schema.format === 'radio') {\n return this.renderRadio(error, disabled);\n }\n\n const selectOptions = this.state.selectOptions.filter(it => !it.hiddenValue);\n\n const value = this._getValue();\n\n const item = this.props.schema.multiple ? null : selectOptions.find(it => it.value == value); // let \"==\" be and not ===\n\n return (\n <FormControl\n variant=\"standard\"\n fullWidth\n sx={this.props.table !== undefined && styles.noMargin}\n id={`jsonSelect_${this.props.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}`}\n >\n {this.props.schema.label ? <InputLabel>{this.getText(this.props.schema.label)}</InputLabel> : null}\n <Select\n variant=\"standard\"\n error={!!error}\n multiple={this.props.schema.multiple}\n disabled={!!disabled}\n value={value || '_'}\n renderValue={(val: string | string[]) =>\n this.props.schema.multiple ? (\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>\n {(val as string[]).map((v: string) => {\n const it = selectOptions.find(_item => _item.value === v);\n if (it || this.props.schema.showAllValues !== false) {\n const label = it?.label || v;\n return (\n <Chip\n key={v}\n label={label}\n />\n );\n }\n return null;\n })}\n </div>\n ) : item?.color ? (\n <span style={{ display: 'flex', alignItems: 'center' }}>\n {item.icon ? (\n <Icon\n src={item.icon}\n style={styles.icon}\n />\n ) : null}\n <span>\n <div style={{ color: item.color }}>{item.label ?? val}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </span>\n </span>\n ) : item?.label === undefined ? (\n item?.icon ? (\n <span style={{ display: 'flex', alignItems: 'center' }}>\n <Icon\n src={item.icon}\n style={styles.icon}\n />\n {val}\n </span>\n ) : (\n val\n )\n ) : (\n <span style={{ display: 'flex', alignItems: 'center' }}>\n {item.icon ? (\n <Icon\n src={item.icon}\n style={styles.icon}\n />\n ) : null}\n <span>\n <div>{item.label}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </span>\n </span>\n )\n }\n onChange={e => {\n this.setState({ value: e.target.value === '_' ? '' : e.target.value }, () => {\n let mayBePromise: void | Promise<void>;\n if (this.state.value === ConfigGeneric.DIFFERENT_VALUE) {\n mayBePromise = this.onChange(this.props.attr, this.initialValue);\n } else {\n mayBePromise = this.onChange(this.props.attr, this.state.value);\n }\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(e));\n }\n });\n }}\n >\n {selectOptions.map((it, i) => {\n if (it.group) {\n return (\n <ListSubheader\n key={i}\n style={{ color: it.color }}\n >\n <div>{it.label}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </ListSubheader>\n );\n }\n return (\n <MenuItem\n key={i}\n value={it.value}\n style={it.value === ConfigGeneric.DIFFERENT_VALUE ? { opacity: 0.5 } : {}}\n >\n {this.props.schema.multiple ? (\n <Checkbox\n checked={value.includes(it.value as string)}\n onClick={() => {\n const _value = JSON.parse(JSON.stringify(this._getValue()));\n const pos = value.indexOf(it.value as string);\n if (pos !== -1) {\n _value.splice(pos, 1);\n } else {\n _value.push(it.value);\n _value.sort();\n }\n this.setState({ value: _value }, () =>\n this.onChange(this.props.attr, _value),\n );\n }}\n />\n ) : null}\n {it.icon ? (\n <Icon\n src={it.icon}\n style={styles.icon}\n />\n ) : null}\n <ListItemText\n primary={it.label}\n secondary={it.description}\n slotProps={{\n secondary: {\n style: { fontSize: 'smaller', fontStyle: 'italic', opacity: 0.7 },\n },\n }}\n style={{ color: it.color }}\n />\n </MenuItem>\n );\n })}\n </Select>\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigSelect.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EACH,UAAU,EACV,cAAc,EACd,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,EACR,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,KAAK,EACL,gBAAgB,EAChB,UAAU,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwB;IAChC,SAAS,EAAE;QACP,KAAK,EAAE,MAAM;KAChB;IACD,QAAQ,EAAE;QACN,OAAO,EAAE;YACL,SAAS,EAAE,CAAC;SACf;KACJ;IACD,IAAI,EAAE;QACF,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,\n FormLabel,\n Select,\n MenuItem,\n ListSubheader,\n Chip,\n ListItemText,\n Checkbox,\n RadioGroup,\n Radio,\n FormControlLabel,\n Typography,\n} from '@mui/material';\n\nimport { I18n, Icon } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemSelect, ConfigItemSelectOption } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, any> = {\n fullWidth: {\n width: '100%',\n },\n noMargin: {\n '&>div': {\n marginTop: 0,\n },\n },\n icon: {\n width: 20,\n height: 20,\n marginRight: 4,\n },\n};\n\ninterface ConfigInstanceSelectProps extends ConfigGenericProps {\n schema: ConfigItemSelect;\n}\n\ninterface SelectItem {\n label: string;\n value: number | string;\n group?: boolean;\n hidden?: string | boolean;\n color?: string;\n description?: string;\n icon?: string;\n hiddenValue?: boolean;\n}\n\ninterface ConfigInstanceSelectState extends ConfigGenericState {\n selectOptions?: SelectItem[];\n}\n\nexport default class ConfigSelect extends ConfigGeneric<ConfigInstanceSelectProps, ConfigInstanceSelectState> {\n private initialValue: string | string[] = '';\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n let value: string | string[] = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n if (this.props.schema.multiple) {\n if (typeof value === 'string') {\n value = [value];\n } else if (value === null || value === undefined) {\n value = [];\n }\n }\n\n const selectOptions: {\n label: string;\n value: number | string;\n group?: boolean;\n hidden?: string | boolean;\n color?: string;\n description?: string;\n icon?: string;\n hiddenValue?: boolean;\n }[] = [];\n\n for (const item of this.props.schema.options || []) {\n // if optgroup\n const groupItem: {\n items: ConfigItemSelectOption[];\n label: ioBroker.StringOrTranslated;\n value?: number | string;\n hidden?: string | boolean;\n description?: string;\n } = item as {\n items: ConfigItemSelectOption[];\n label: ioBroker.StringOrTranslated;\n value?: number | string;\n hidden?: string | boolean;\n description?: string;\n };\n if (Array.isArray(groupItem.items)) {\n const selectItem: SelectItem = {\n label: this.getText(item.label, this.props.schema.noTranslation),\n value: item.value,\n group: true,\n color: item.color,\n description: this.getText(item.description),\n };\n selectItem.hiddenValue = await this.isHidden(selectItem);\n selectOptions.push(selectItem);\n for (const it of groupItem.items) {\n const selectSubItem: SelectItem = {\n label: this.getText(it.label, this.props.schema.noTranslation),\n value: it.value,\n hidden: it.hidden,\n color: item.color,\n description: this.getText(item.description),\n icon: it.icon,\n };\n selectSubItem.hiddenValue = await this.isHidden(selectSubItem);\n selectOptions.push(selectSubItem);\n }\n } else {\n const selectItem: SelectItem = {\n label: this.getText(item.label, this.props.schema.noTranslation),\n value: item.value,\n hidden: item.hidden,\n color: item.color,\n description: this.getText(item.description),\n icon: item.icon,\n };\n selectItem.hiddenValue = await this.isHidden(selectItem);\n selectOptions.push(selectItem);\n }\n }\n\n // Report value-to-label mapping to parent table for filtering\n if (this.props.onFilterLabelUpdate && this.props.table) {\n const valueToLabel: Record<string, string> = {};\n for (const opt of selectOptions) {\n if (!opt.group && opt.value !== ConfigGeneric.DIFFERENT_VALUE) {\n valueToLabel[opt.value.toString()] = opt.label;\n }\n }\n this.props.onFilterLabelUpdate(this.props.attr, valueToLabel);\n }\n\n // if __different\n if (Array.isArray(value) && !this.props.schema.multiple) {\n this.initialValue = [...value];\n selectOptions.unshift({\n label: I18n.t(ConfigGeneric.DIFFERENT_LABEL),\n value: ConfigGeneric.DIFFERENT_VALUE,\n });\n this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });\n } else {\n this.setState({ value, selectOptions });\n }\n }\n\n _getValue(): string | string[] {\n let value =\n this.state.value === null || this.state.value === undefined\n ? ConfigGeneric.getValue(this.props.data, this.props.attr)\n : this.state.value;\n\n if (this.props.schema.multiple) {\n if (typeof value === 'string') {\n value = [value];\n } else if (value === null || value === undefined) {\n value = [];\n }\n }\n\n return value;\n }\n\n private async isHidden(item: SelectItem): Promise<boolean> {\n // if optgroup or no hidden function\n if (!item.hidden) {\n return false;\n }\n\n if (this.props.custom) {\n return !!(await this.executeCustom(\n item.hidden,\n this.props.data,\n this.props.customObj,\n this.props.oContext.instanceObj,\n this.props.arrayIndex,\n this.props.globalData,\n ));\n }\n return !!(await this.execute(\n item.hidden,\n this.props.schema.default,\n this.props.data,\n this.props.arrayIndex,\n this.props.globalData,\n ));\n }\n\n renderRadio(error: string, disabled: boolean): JSX.Element {\n const selectOptions = this.state.selectOptions.filter(it => !it.hiddenValue && !it.group);\n const value = this._getValue();\n\n return (\n <FormControl\n fullWidth\n error={!!error}\n disabled={!!disabled}\n id={`jsonSelect_${this.props.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}`}\n >\n {this.props.schema.label ? <FormLabel>{this.getText(this.props.schema.label)}</FormLabel> : null}\n <RadioGroup\n row={!!this.props.schema.horizontal}\n value={value === undefined || value === null ? '' : value.toString()}\n onChange={e => {\n // find the original option value to preserve its type (number vs. string)\n const opt = selectOptions.find(it => it.value.toString() === e.target.value);\n const newValue = opt ? opt.value : e.target.value;\n this.setState({ value: newValue }, () => {\n const mayBePromise = this.onChange(this.props.attr, newValue);\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(e));\n }\n });\n }}\n >\n {selectOptions.map((it, i) => (\n <FormControlLabel\n key={i}\n value={it.value.toString()}\n control={<Radio />}\n title={it.description || ''}\n label={\n <span style={{ display: 'flex', alignItems: 'center' }}>\n {it.icon ? (\n <Icon\n src={it.icon}\n style={styles.icon}\n />\n ) : null}\n <Typography\n component=\"span\"\n style={{ color: it.color }}\n >\n {it.label}\n </Typography>\n </span>\n }\n style={it.value === ConfigGeneric.DIFFERENT_VALUE ? { opacity: 0.5 } : {}}\n />\n ))}\n </RadioGroup>\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 renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n if (!this.state.selectOptions) {\n return null;\n }\n\n if (this.props.schema.format === 'radio') {\n return this.renderRadio(error, disabled);\n }\n\n const selectOptions = this.state.selectOptions.filter(it => !it.hiddenValue);\n\n const value = this._getValue();\n\n const item = this.props.schema.multiple ? null : selectOptions.find(it => it.value == value); // let \"==\" be and not ===\n\n return (\n <FormControl\n variant=\"standard\"\n fullWidth\n sx={this.props.table !== undefined ? styles.noMargin : undefined}\n id={`jsonSelect_${this.props.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}`}\n >\n {this.props.schema.label ? <InputLabel>{this.getText(this.props.schema.label)}</InputLabel> : null}\n <Select\n variant=\"standard\"\n error={!!error}\n multiple={this.props.schema.multiple}\n disabled={!!disabled}\n value={value || '_'}\n renderValue={(val: string | string[]) =>\n this.props.schema.multiple ? (\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>\n {(val as string[]).map((v: string) => {\n const it = selectOptions.find(_item => _item.value === v);\n if (it || this.props.schema.showAllValues !== false) {\n const label = it?.label || v;\n return (\n <Chip\n key={v}\n label={label}\n />\n );\n }\n return null;\n })}\n </div>\n ) : item?.color ? (\n <span style={{ display: 'flex', alignItems: 'center' }}>\n {item.icon ? (\n <Icon\n src={item.icon}\n style={styles.icon}\n />\n ) : null}\n <span>\n <div style={{ color: item.color }}>{item.label ?? val}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </span>\n </span>\n ) : item?.label === undefined ? (\n item?.icon ? (\n <span style={{ display: 'flex', alignItems: 'center' }}>\n <Icon\n src={item.icon}\n style={styles.icon}\n />\n {val}\n </span>\n ) : (\n val\n )\n ) : (\n <span style={{ display: 'flex', alignItems: 'center' }}>\n {item.icon ? (\n <Icon\n src={item.icon}\n style={styles.icon}\n />\n ) : null}\n <span>\n <div>{item.label}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </span>\n </span>\n )\n }\n onChange={e => {\n this.setState({ value: e.target.value === '_' ? '' : e.target.value }, () => {\n let mayBePromise: void | Promise<void>;\n if (this.state.value === ConfigGeneric.DIFFERENT_VALUE) {\n mayBePromise = this.onChange(this.props.attr, this.initialValue);\n } else {\n mayBePromise = this.onChange(this.props.attr, this.state.value);\n }\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(e));\n }\n });\n }}\n >\n {selectOptions.map((it, i) => {\n if (it.group) {\n return (\n <ListSubheader\n key={i}\n style={{ color: it.color }}\n >\n <div>{it.label}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </ListSubheader>\n );\n }\n return (\n <MenuItem\n key={i}\n value={it.value}\n style={it.value === ConfigGeneric.DIFFERENT_VALUE ? { opacity: 0.5 } : {}}\n >\n {this.props.schema.multiple ? (\n <Checkbox\n checked={value.includes(it.value as string)}\n onClick={() => {\n const _value = JSON.parse(JSON.stringify(this._getValue()));\n const pos = value.indexOf(it.value as string);\n if (pos !== -1) {\n _value.splice(pos, 1);\n } else {\n _value.push(it.value);\n _value.sort();\n }\n this.setState({ value: _value }, () =>\n this.onChange(this.props.attr, _value),\n );\n }}\n />\n ) : null}\n {it.icon ? (\n <Icon\n src={it.icon}\n style={styles.icon}\n />\n ) : null}\n <ListItemText\n primary={it.label}\n secondary={it.description}\n slotProps={{\n secondary: {\n style: { fontSize: 'smaller', fontStyle: 'italic', opacity: 0.7 },\n },\n }}\n style={{ color: it.color }}\n />\n </MenuItem>\n );\n })}\n </Select>\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}\n"]}
|
|
@@ -119,9 +119,9 @@ export default class ConfigSendto extends ConfigGeneric {
|
|
|
119
119
|
if (this.props.schema.openUrl) {
|
|
120
120
|
// read admin host
|
|
121
121
|
const adminInstance = await this.props.oContext.socket.getCurrentInstance();
|
|
122
|
-
const instanceObj = await this.
|
|
122
|
+
const instanceObj = await this.getCachedObject(`system.adapter.${adminInstance}`);
|
|
123
123
|
if (instanceObj) {
|
|
124
|
-
const hostObj = await this.
|
|
124
|
+
const hostObj = await this.getCachedObject(`system.host.${instanceObj?.common?.host}`);
|
|
125
125
|
if (hostObj) {
|
|
126
126
|
const ip = findNetworkAddressOfHost(hostObj, window.location.hostname);
|
|
127
127
|
if (ip) {
|
|
@@ -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,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;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;AA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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,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/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 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.props.oContext.getCachedObject(\n `system.adapter.${adminInstance}` as ioBroker.ObjectIDs.Instance,\n );\n\n if (instanceObj) {\n const hostObj = await this.props.oContext.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('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 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> = 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 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 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('ra_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('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 %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,4BAA4B,CAAC;AAGnG,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,MAAM,MAAM,6BAA6B,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,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 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('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 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> = 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 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 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('ra_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('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 %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"]}
|
|
@@ -13,7 +13,7 @@ class ConfigSetState extends ConfigGeneric {
|
|
|
13
13
|
let val = this.props.schema.val;
|
|
14
14
|
if (typeof val === 'string' && val.includes('${')) {
|
|
15
15
|
val = await this.getPatternAsync(val, null, true);
|
|
16
|
-
const obj = await this.
|
|
16
|
+
const obj = await this.getCachedObject(this.props.schema.id);
|
|
17
17
|
if (obj?.common?.type === 'number') {
|
|
18
18
|
val = parseFloat(val);
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigSetState.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigSetState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,KAAK,IAAI,SAAS,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEnG,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,SAAS,EAAE;QACP,KAAK,EAAE,MAAM;KAChB;CACJ,CAAC;AAMF,MAAM,cAAe,SAAQ,aAA4D;IACrF,KAAK,CAAC,QAAQ;QACV,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;QAChC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,GAAG,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAClD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"ConfigSetState.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigSetState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,KAAK,IAAI,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KAAK,EAAE,MAAM,CAAC,SAAS,EACvB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,KAAK,IAAI,EAAE;gBAChB,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBAC5B,IAAI,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC3C,CAAC;qBAAM,CAAC;oBACJ,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC1B,CAAC;YACL,CAAC,EACD,SAAS,EAAE,IAAI,IAAI,SAAS,IAE3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAClE,CACZ,CAAC;IACN,CAAC;CACJ;AAED,eAAe,cAAc,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Button } from '@mui/material';\n\nimport { Warning as IconWarning, Error as IconError, Info as IconInfo } from '@mui/icons-material';\n\nimport { DialogConfirm, I18n } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemSetState } 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\ninterface ConfigInstanceSelectProps extends ConfigGenericProps {\n schema: ConfigItemSetState;\n}\n\nclass ConfigSetState extends ConfigGeneric<ConfigInstanceSelectProps, ConfigGenericState> {\n async _onClick(): Promise<void> {\n let val = this.props.schema.val;\n if (typeof val === 'string' && val.includes('${')) {\n val = await this.getPatternAsync(val, null, true);\n const obj = await this.getCachedObject(this.props.schema.id);\n if (obj?.common?.type === 'number') {\n val = parseFloat(val);\n } else if (obj?.common?.type === 'boolean') {\n // @ts-expect-error val could be anything\n val = val === 'true' || val === true || val === '1' || val === 1;\n }\n }\n\n const id = (this.props.schema.id || '').replace(/%INSTANCE%/g, (this.props.oContext.instance || 0).toString());\n\n try {\n await this.props.oContext.socket.setState(id, { val, ack: !!this.props.schema.ack });\n if (this.props.schema.okText) {\n window.alert(this.getText(this.props.schema.okText));\n }\n } catch (e) {\n if (this.props.schema.error && this.props.schema.error[e.toString()]) {\n window.alert(this.getText(this.props.schema.error[e.toString()]));\n } else {\n window.alert(I18n.t(e.toString()) || I18n.t('ra_Error'));\n }\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}\n onClose={isOk => this.setState({ confirmDialog: false }, () => isOk && this._onClick())}\n />\n );\n }\n\n renderItem(_error: string, disabled: boolean /* , defaultValue */): JSX.Element | null {\n const icon = this.getIcon();\n return (\n <Button\n variant={this.props.schema.variant || undefined}\n color={this.props.schema.color || 'grey'}\n style={styles.fullWidth}\n disabled={disabled}\n onClick={async () => {\n if (this.props.schema.confirm) {\n this.setState({ confirmDialog: true });\n } else {\n await this._onClick();\n }\n }}\n startIcon={icon || undefined}\n >\n {this.getText(this.props.schema.label, this.props.schema.noTranslation)}\n </Button>\n );\n }\n}\n\nexport default ConfigSetState;\n"]}
|
|
@@ -51,7 +51,7 @@ class ConfigState extends ConfigGeneric {
|
|
|
51
51
|
async componentDidMount() {
|
|
52
52
|
await super.componentDidMount();
|
|
53
53
|
const objId = await this.getObjectID();
|
|
54
|
-
const obj = (await this.
|
|
54
|
+
const obj = (await this.getCachedObject(objId));
|
|
55
55
|
if (obj?.common?.states && !this.props.schema.options) {
|
|
56
56
|
// Normalize states to object
|
|
57
57
|
if (Array.isArray(obj?.common?.states)) {
|