@iobroker/json-config 8.4.10 → 8.4.12
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 +8 -0
- package/build/JsonConfigComponent/ConfigFile.d.ts +2 -2
- package/build/JsonConfigComponent/ConfigFile.js +1 -2
- package/build/JsonConfigComponent/ConfigFile.js.map +1 -1
- package/build/JsonConfigComponent/ConfigFileSelector.d.ts +2 -2
- package/build/JsonConfigComponent/ConfigFileSelector.js +6 -4
- package/build/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
- package/build/JsonConfigComponent/ConfigGeneric.d.ts +12 -2
- package/build/JsonConfigComponent/ConfigGeneric.js +54 -20
- package/build/JsonConfigComponent/ConfigGeneric.js.map +1 -1
- package/build/JsonConfigComponent/ConfigObjectId.d.ts +2 -2
- package/build/JsonConfigComponent/ConfigObjectId.js +1 -2
- package/build/JsonConfigComponent/ConfigObjectId.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSelect.js +2 -2
- package/build/JsonConfigComponent/ConfigSelect.js.map +1 -1
- package/build/JsonConfigComponent/i18n/de.json +20 -0
- package/build/JsonConfigComponent/i18n/es.json +20 -0
- package/build/JsonConfigComponent/i18n/fr.json +20 -0
- package/build/JsonConfigComponent/i18n/it.json +20 -0
- package/build/JsonConfigComponent/i18n/nl.json +20 -0
- package/build/JsonConfigComponent/i18n/pl.json +20 -0
- package/build/JsonConfigComponent/i18n/pt.json +20 -0
- package/build/JsonConfigComponent/i18n/ru.json +20 -0
- package/build/JsonConfigComponent/i18n/uk.json +20 -0
- package/build/JsonConfigComponent/i18n/zh-cn.json +20 -0
- package/build/types.d.ts +8 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1822,6 +1822,14 @@ The schema is used here: https://github.com/SchemaStore/schemastore/blob/6da29cd
|
|
|
1822
1822
|
### **WORK IN PROGRESS**
|
|
1823
1823
|
-->
|
|
1824
1824
|
## Changelog
|
|
1825
|
+
### 8.4.12 (2026-06-29)
|
|
1826
|
+
- (@GermanBluefox) Corrected the file selector component
|
|
1827
|
+
- (@GermanBluefox) Implemented no translation for select component
|
|
1828
|
+
- (@GermanBluefox) Implemented debug mode for components to analyze JS functions
|
|
1829
|
+
|
|
1830
|
+
### 8.4.11 (2026-06-21)
|
|
1831
|
+
- (@GermanBluefox) Added missing translations
|
|
1832
|
+
|
|
1825
1833
|
### 8.4.10 (2026-06-20)
|
|
1826
1834
|
- (@GermanBluefox) Fixed state component
|
|
1827
1835
|
|
|
@@ -7,7 +7,7 @@ interface ConfigFileProps extends ConfigGenericProps {
|
|
|
7
7
|
interface ConfigFileState extends ConfigGenericState {
|
|
8
8
|
showFileBrowser?: boolean;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
export default class ConfigFile extends ConfigGeneric<ConfigFileProps, ConfigFileState> {
|
|
11
11
|
private imagePrefix;
|
|
12
12
|
componentDidMount(): Promise<void>;
|
|
13
13
|
static getDerivedStateFromProps(props: ConfigFileProps, state: ConfigFileState): Partial<ConfigFileState> | null;
|
|
@@ -20,4 +20,4 @@ declare class ConfigFile extends ConfigGeneric<ConfigFileProps, ConfigFileState>
|
|
|
20
20
|
renderFileBrowser(): JSX.Element | null;
|
|
21
21
|
renderItem(error: string, disabled: boolean): JSX.Element;
|
|
22
22
|
}
|
|
23
|
-
export
|
|
23
|
+
export {};
|
|
@@ -28,7 +28,7 @@ const AUDIO_EXT = ['mp3', 'ogg', 'wav', 'aac'];
|
|
|
28
28
|
const VIDEO_EXT = ['avi', 'mp4', 'mov'];
|
|
29
29
|
const DOC_EXT = ['txt', 'log', 'html', 'htm'];
|
|
30
30
|
const JS_EXT = ['json', 'js', 'ts'];
|
|
31
|
-
class ConfigFile extends ConfigGeneric {
|
|
31
|
+
export default class ConfigFile extends ConfigGeneric {
|
|
32
32
|
imagePrefix = '../..';
|
|
33
33
|
async componentDidMount() {
|
|
34
34
|
await super.componentDidMount();
|
|
@@ -119,5 +119,4 @@ class ConfigFile extends ConfigGeneric {
|
|
|
119
119
|
this.renderFileBrowser()));
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
export default ConfigFile;
|
|
123
122
|
//# sourceMappingURL=ConfigFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigFile.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigFile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EACH,OAAO,IAAI,QAAQ,EACnB,IAAI,IAAI,QAAQ,EAChB,SAAS,IAAI,QAAQ,EACrB,QAAQ,IAAI,SAAS,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,MAAM,MAAM,GAAwC;IAChD,SAAS,EAAE;QACP,KAAK,EAAE,MAAM;KAChB;IACD,kBAAkB,EAAE;QAChB,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EAAE,CAAC;KACjB;IACD,aAAa,EAAE;QACX,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EAAE,CAAC;KACjB;IACD,aAAa,EAAE;QACX,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,OAAO,EAAE,cAAc;QACvB,WAAW,EAAE,CAAC;KACjB;CACJ,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACvF,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAC/C,MAAM,SAAS,G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AAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,UAAU,EAAE,IAAI,CAAC,UAAU,CACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,GACH;YACF,oBAAC,MAAM,IACH,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAC,UAAU,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,UAGlD;YACR,IAAI,CAAC,iBAAiB,EAAE,CACvB,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,UAAU,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Button, TextField, IconButton } from '@mui/material';\n\nimport {\n Article as IconText,\n Code as IconCode,\n PlayArrow as IconPlay,\n Videocam as IconVideo,\n} from '@mui/icons-material';\n\nimport { DialogSelectFile } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemFile } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\nimport ConfigFileSelector from './ConfigFileSelector';\n\nconst styles: Record<string, React.CSSProperties> = {\n fullWidth: {\n width: '100%',\n },\n fullWidthOneButton: {\n width: 'calc(100% - 69px)',\n marginRight: 4,\n },\n fullWidthIcon: {\n width: 'calc(100% - 119px)',\n marginRight: 4,\n },\n selectedImage: {\n height: 40,\n width: 40,\n display: 'inline-block',\n marginRight: 8,\n },\n};\n\nconst IMAGE_EXT = ['jpg', 'jpeg', 'svg', 'png', 'webp', 'gif', 'apng', 'avif', 'webp'];\nconst AUDIO_EXT = ['mp3', 'ogg', 'wav', 'aac'];\nconst VIDEO_EXT = ['avi', 'mp4', 'mov'];\nconst DOC_EXT = ['txt', 'log', 'html', 'htm'];\nconst JS_EXT = ['json', 'js', 'ts'];\n\ninterface ConfigFileProps extends ConfigGenericProps {\n schema: ConfigItemFile;\n}\n\ninterface ConfigFileState extends ConfigGenericState {\n showFileBrowser?: boolean;\n}\n\nclass ConfigFile extends ConfigGeneric<ConfigFileProps, ConfigFileState> {\n private imagePrefix = '../..';\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n this.imagePrefix = this.props.oContext.imagePrefix ?? './files';\n this.setState({ value: value ?? '' });\n }\n\n static getDerivedStateFromProps(props: ConfigFileProps, state: ConfigFileState): Partial<ConfigFileState> | null {\n const value = ConfigGeneric.getValue(props.data, props.attr);\n if (\n value === null ||\n value === undefined ||\n value.toString().trim() !== (state.value || '').toString().trim()\n ) {\n return { value: value ?? '' };\n }\n return null;\n }\n\n loadFile(): Promise<{ file: string; mimeType: string } | null> {\n const pos = this.state.value.indexOf('/');\n if (pos !== -1) {\n const adapter = this.state.value.substring(0, pos);\n const path = this.state.value.substring(pos + 1);\n return this.props.oContext.socket.readFile(adapter, path, true);\n }\n\n return Promise.resolve(null);\n }\n\n play(): void {\n void this.loadFile().then(data => {\n if (typeof AudioContext !== 'undefined' && data?.file) {\n const oContext = new AudioContext();\n const buf: ArrayBuffer = ConfigFileSelector.base64ToArrayBuffer(data.file) as ArrayBuffer;\n void oContext.decodeAudioData(\n buf,\n (buffer: AudioBuffer): void => {\n const source = oContext.createBufferSource(); // creates a sound source\n source.buffer = buffer; // tell the source which sounds to play\n source.connect(oContext.destination); // connect the source to the oContext's destination (the speakers)\n source.start(0);\n },\n (err: DOMException): void => window.alert(`Cannot play: ${err.message}`),\n );\n }\n });\n }\n\n getIcon(): JSX.Element | null {\n const extension = this.state.value.split('.').pop().toLowerCase();\n if (IMAGE_EXT.includes(extension)) {\n return (\n <div\n style={{\n ...styles.selectedImage,\n backgroundImage: `url(${this.imagePrefix}/${this.state.value})`,\n backgroundSize: 'contain',\n backgroundRepeat: 'no-repeat',\n }}\n />\n );\n }\n if (AUDIO_EXT.includes(extension)) {\n return (\n <IconButton\n style={{ color: '#00FF00' }}\n onClick={() => this.play()}\n >\n <IconPlay />\n </IconButton>\n );\n }\n if (DOC_EXT.includes(extension)) {\n return <IconText />;\n }\n if (VIDEO_EXT.includes(extension)) {\n return <IconVideo />;\n }\n if (JS_EXT.includes(extension)) {\n return <IconCode />;\n }\n return null;\n }\n\n renderFileBrowser(): JSX.Element | null {\n if (!this.state.showFileBrowser) {\n return null;\n }\n return (\n <DialogSelectFile\n imagePrefix={this.props.oContext.imagePrefix}\n socket={this.props.oContext.socket}\n selected={this.state.value}\n onClose={() => this.setState({ showFileBrowser: false })}\n onOk={_value => {\n const value = Array.isArray(_value) ? _value[0] : _value;\n this.setState({ value }, () =>\n this.onChange(this.props.attr, this.props.schema.trim === false ? value : (value || '').trim()),\n );\n }}\n selectOnlyFolders={this.props.schema.selectOnlyFolders}\n allowUpload={this.props.schema.allowUpload}\n allowDownload={this.props.schema.allowDownload}\n allowCreateFolder={this.props.schema.allowCreateFolder}\n allowView={this.props.schema.allowView}\n showToolbar={this.props.schema.showToolbar}\n limitPath={this.props.schema.limitPath}\n theme={this.props.oContext.theme}\n />\n );\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n const icon = this.getIcon();\n\n return (\n <div style={styles.fullWidth}>\n {icon}\n <TextField\n variant=\"standard\"\n style={icon ? styles.fullWidthIcon : styles.fullWidthOneButton}\n value={this.state.value ?? ''}\n error={!!error}\n disabled={!!disabled}\n slotProps={{\n htmlInput: {\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\n readOnly: !!this.props.schema.disableEdit,\n },\n }}\n onChange={e => {\n const value = e.target.value;\n this.setState({ value }, () =>\n this.onChange(\n this.props.attr,\n this.props.schema.trim === false ? value : (value || '').trim(),\n ),\n );\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n />\n <Button\n disabled={disabled}\n variant=\"outlined\"\n onClick={() => this.setState({ showFileBrowser: true })}\n >\n ...\n </Button>\n {this.renderFileBrowser()}\n </div>\n );\n }\n}\n\nexport default ConfigFile;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigFile.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigFile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EACH,OAAO,IAAI,QAAQ,EACnB,IAAI,IAAI,QAAQ,EAChB,SAAS,IAAI,QAAQ,EACrB,QAAQ,IAAI,SAAS,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,MAAM,MAAM,GAAwC;IAChD,SAAS,EAAE;QACP,KAAK,EAAE,MAAM;KAChB;IACD,kBAAkB,EAAE;QAChB,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EAAE,CAAC;KACjB;IACD,aAAa,EAAE;QACX,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EAAE,CAAC;KACjB;IACD,aAAa,EAAE;QACX,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,OAAO,EAAE,cAAc;QACvB,WAAW,EAAE,CAAC;KACjB;CACJ,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACvF,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KA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AAK,CAAC,MAAM,CAAC,WAAW,CAAC,EACxD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,UAAU,EAAE,IAAI,CAAC,UAAU,CACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,GACH;YACF,oBAAC,MAAM,IACH,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAC,UAAU,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,UAGlD;YACR,IAAI,CAAC,iBAAiB,EAAE,CACvB,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Button, TextField, IconButton } from '@mui/material';\n\nimport {\n Article as IconText,\n Code as IconCode,\n PlayArrow as IconPlay,\n Videocam as IconVideo,\n} from '@mui/icons-material';\n\nimport { DialogSelectFile } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemFile } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\nimport ConfigFileSelector from './ConfigFileSelector';\n\nconst styles: Record<string, React.CSSProperties> = {\n fullWidth: {\n width: '100%',\n },\n fullWidthOneButton: {\n width: 'calc(100% - 69px)',\n marginRight: 4,\n },\n fullWidthIcon: {\n width: 'calc(100% - 119px)',\n marginRight: 4,\n },\n selectedImage: {\n height: 40,\n width: 40,\n display: 'inline-block',\n marginRight: 8,\n },\n};\n\nconst IMAGE_EXT = ['jpg', 'jpeg', 'svg', 'png', 'webp', 'gif', 'apng', 'avif', 'webp'];\nconst AUDIO_EXT = ['mp3', 'ogg', 'wav', 'aac'];\nconst VIDEO_EXT = ['avi', 'mp4', 'mov'];\nconst DOC_EXT = ['txt', 'log', 'html', 'htm'];\nconst JS_EXT = ['json', 'js', 'ts'];\n\ninterface ConfigFileProps extends ConfigGenericProps {\n schema: ConfigItemFile;\n}\n\ninterface ConfigFileState extends ConfigGenericState {\n showFileBrowser?: boolean;\n}\n\nexport default class ConfigFile extends ConfigGeneric<ConfigFileProps, ConfigFileState> {\n private imagePrefix = '../..';\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n this.imagePrefix = this.props.oContext.imagePrefix ?? './files';\n this.setState({ value: value ?? '' });\n }\n\n static getDerivedStateFromProps(props: ConfigFileProps, state: ConfigFileState): Partial<ConfigFileState> | null {\n const value = ConfigGeneric.getValue(props.data, props.attr);\n if (\n value === null ||\n value === undefined ||\n value.toString().trim() !== (state.value || '').toString().trim()\n ) {\n return { value: value ?? '' };\n }\n return null;\n }\n\n loadFile(): Promise<{ file: string; mimeType: string } | null> {\n const pos = this.state.value.indexOf('/');\n if (pos !== -1) {\n const adapter = this.state.value.substring(0, pos);\n const path = this.state.value.substring(pos + 1);\n return this.props.oContext.socket.readFile(adapter, path, true);\n }\n\n return Promise.resolve(null);\n }\n\n play(): void {\n void this.loadFile().then(data => {\n if (typeof AudioContext !== 'undefined' && data?.file) {\n const oContext = new AudioContext();\n const buf: ArrayBuffer = ConfigFileSelector.base64ToArrayBuffer(data.file) as ArrayBuffer;\n void oContext.decodeAudioData(\n buf,\n (buffer: AudioBuffer): void => {\n const source = oContext.createBufferSource(); // creates a sound source\n source.buffer = buffer; // tell the source which sounds to play\n source.connect(oContext.destination); // connect the source to the oContext's destination (the speakers)\n source.start(0);\n },\n (err: DOMException): void => window.alert(`Cannot play: ${err.message}`),\n );\n }\n });\n }\n\n getIcon(): JSX.Element | null {\n const extension = this.state.value.split('.').pop().toLowerCase();\n if (IMAGE_EXT.includes(extension)) {\n return (\n <div\n style={{\n ...styles.selectedImage,\n backgroundImage: `url(${this.imagePrefix}/${this.state.value})`,\n backgroundSize: 'contain',\n backgroundRepeat: 'no-repeat',\n }}\n />\n );\n }\n if (AUDIO_EXT.includes(extension)) {\n return (\n <IconButton\n style={{ color: '#00FF00' }}\n onClick={() => this.play()}\n >\n <IconPlay />\n </IconButton>\n );\n }\n if (DOC_EXT.includes(extension)) {\n return <IconText />;\n }\n if (VIDEO_EXT.includes(extension)) {\n return <IconVideo />;\n }\n if (JS_EXT.includes(extension)) {\n return <IconCode />;\n }\n return null;\n }\n\n renderFileBrowser(): JSX.Element | null {\n if (!this.state.showFileBrowser) {\n return null;\n }\n return (\n <DialogSelectFile\n imagePrefix={this.props.oContext.imagePrefix}\n socket={this.props.oContext.socket}\n selected={this.state.value}\n onClose={() => this.setState({ showFileBrowser: false })}\n onOk={_value => {\n const value = Array.isArray(_value) ? _value[0] : _value;\n this.setState({ value }, () =>\n this.onChange(this.props.attr, this.props.schema.trim === false ? value : (value || '').trim()),\n );\n }}\n selectOnlyFolders={this.props.schema.selectOnlyFolders}\n allowUpload={this.props.schema.allowUpload}\n allowDownload={this.props.schema.allowDownload}\n allowCreateFolder={this.props.schema.allowCreateFolder}\n allowView={this.props.schema.allowView}\n showToolbar={this.props.schema.showToolbar}\n limitPath={this.props.schema.limitPath}\n theme={this.props.oContext.theme}\n />\n );\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n const icon = this.getIcon();\n\n return (\n <div style={styles.fullWidth}>\n {icon}\n <TextField\n variant=\"standard\"\n style={icon ? styles.fullWidthIcon : styles.fullWidthOneButton}\n value={this.state.value ?? ''}\n error={!!error}\n disabled={!!disabled}\n slotProps={{\n htmlInput: {\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\n readOnly: !!this.props.schema.disableEdit,\n },\n }}\n onChange={e => {\n const value = e.target.value;\n this.setState({ value }, () =>\n this.onChange(\n this.props.attr,\n this.props.schema.trim === false ? value : (value || '').trim(),\n ),\n );\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n />\n <Button\n disabled={disabled}\n variant=\"outlined\"\n onClick={() => this.setState({ showFileBrowser: true })}\n >\n ...\n </Button>\n {this.renderFileBrowser()}\n </div>\n );\n }\n}\n"]}
|
|
@@ -13,7 +13,7 @@ interface ConfigFileSelectorState extends ConfigGenericState {
|
|
|
13
13
|
}[];
|
|
14
14
|
deleteFile?: string;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
export default class ConfigFileSelector extends ConfigGeneric<ConfigFileSelectorProps, ConfigFileSelectorState> {
|
|
17
17
|
private readonly dropzoneRef;
|
|
18
18
|
private readonly imagePrefix;
|
|
19
19
|
private objectID;
|
|
@@ -49,4 +49,4 @@ declare class ConfigFileSelector extends ConfigGeneric<ConfigFileSelectorProps,
|
|
|
49
49
|
}): JSX.Element | null;
|
|
50
50
|
renderItem(error: string, disabled: boolean): JSX.Element | null;
|
|
51
51
|
}
|
|
52
|
-
export
|
|
52
|
+
export {};
|
|
@@ -87,7 +87,7 @@ const AUDIO_EXT = ['mp3', 'ogg', 'wav', 'aac'];
|
|
|
87
87
|
const VIDEO_EXT = ['avi', 'mp4', 'mov'];
|
|
88
88
|
const DOC_EXT = ['txt', 'log', 'html', 'htm'];
|
|
89
89
|
const JS_EXT = ['json', 'js', 'ts'];
|
|
90
|
-
class ConfigFileSelector extends ConfigGeneric {
|
|
90
|
+
export default class ConfigFileSelector extends ConfigGeneric {
|
|
91
91
|
dropzoneRef;
|
|
92
92
|
imagePrefix;
|
|
93
93
|
objectID;
|
|
@@ -113,7 +113,7 @@ class ConfigFileSelector extends ConfigGeneric {
|
|
|
113
113
|
void this.updateFiles().then(() => {
|
|
114
114
|
const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
|
|
115
115
|
this.setState({ value });
|
|
116
|
-
// subscribe
|
|
116
|
+
// subscribe to this folder
|
|
117
117
|
this.props.oContext.socket
|
|
118
118
|
.subscribeFiles(this.objectID, `${this.path}/*`, this.onFolderChanged)
|
|
119
119
|
.catch(e => console.error(`Cannot subscribe: ${e}`));
|
|
@@ -348,7 +348,10 @@ class ConfigFileSelector extends ConfigGeneric {
|
|
|
348
348
|
} }, selectOptions.map(it => (React.createElement(MenuItem, { key: it.value, value: it.value },
|
|
349
349
|
React.createElement(ListItemIcon, null, this.getFileIcon(it)),
|
|
350
350
|
React.createElement(ListItemText, null, it.label),
|
|
351
|
-
this.props.schema.delete &&
|
|
351
|
+
this.props.schema.delete && it.value ? (React.createElement(IconButton, { style: styles.deleteButton, size: "small", onClick: e => {
|
|
352
|
+
e.stopPropagation();
|
|
353
|
+
this.setState({ deleteFile: it.value });
|
|
354
|
+
} },
|
|
352
355
|
React.createElement(IconDelete, null))) : null)))),
|
|
353
356
|
this.props.schema.help ? (React.createElement(FormHelperText, null, this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation))) : null),
|
|
354
357
|
this.props.schema.refresh && (React.createElement(IconButton, { onClick: () => this.updateFiles() },
|
|
@@ -446,5 +449,4 @@ class ConfigFileSelector extends ConfigGeneric {
|
|
|
446
449
|
this.renderDeleteDialog()))));
|
|
447
450
|
}
|
|
448
451
|
}
|
|
449
|
-
export default ConfigFileSelector;
|
|
450
452
|
//# sourceMappingURL=ConfigFileSelector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigFileSelector.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigFileSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,QAA8B,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EACH,UAAU,EACV,QAAQ,EACR,cAAc,EACd,WAAW,EACX,MAAM,EACN,UAAU,EACV,YAAY,EACZ,YAAY,GACf,MAAM,eAAe,CAAC;AAEvB,OAAO,EACH,OAAO,IAAI,WAAW,EACtB,UAAU,IAAI,UAAU,EAC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AC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;iBACzD;gBAED,6BAAK,KAAK,EAAE,MAAM,CAAC,uBAAuB;oBACtC,oBAAC,UAAU,IAAC,KAAK,EAAE,MAAM,CAAC,gBAAgB,GAAI;oBAC9C,6BAAK,KAAK,EAAE,MAAM,CAAC,gBAAgB,IAC9B,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU;wBACjC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC;wBAC7B,CAAC,CAAC,IAAI,CAAC,CAAC,CACF,kEAAkE,CACrE,CACL,CACJ,CACJ,CACT,CAAC,CAAC,CAAC,IAAI;YACP,OAAO;YACP,IAAI,CAAC,kBAAkB,EAAE,CACxB,CACT,CACM,CACd,CAAC;IACN,CAAC;CACJ;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\nimport Dropzone, { type DropzoneRef } from 'react-dropzone';\n\nimport {\n InputLabel,\n MenuItem,\n FormHelperText,\n FormControl,\n Select,\n IconButton,\n ListItemText,\n ListItemIcon,\n} from '@mui/material';\n\nimport {\n Refresh as IconRefresh,\n UploadFile as IconUpload,\n Delete as IconDelete,\n PlayArrow as IconPlay,\n MusicNote as IconAudio,\n Videocam as IconVideo,\n Article as IconText,\n Code as IconCode,\n UploadFile as UploadIcon,\n} from '@mui/icons-material';\n\nimport { DialogConfirm, Utils, I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemFileSelector } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n fullWidth: {\n width: '100%',\n },\n fullWidthOneButton: {\n width: 'calc(100% - 42px)',\n },\n fullWidthTwoButtons: {\n width: 'calc(100% - 84px)',\n },\n fullWidthThreeButtons: {\n width: 'calc(100% - 126x)',\n },\n dropZone: {\n width: '100%',\n height: '100%',\n position: 'absolute',\n },\n dropZoneEmpty: {},\n image: {\n objectFit: 'contain',\n margin: 'auto',\n display: 'flex',\n width: '100%',\n height: '100%',\n },\n uploadDiv: {\n position: 'relative',\n width: '100%',\n },\n uploadDivDragging: {\n opacity: 1,\n background: 'rgba(128,255,128,0.1)',\n },\n uploadCenterDiv: {\n margin: 5,\n border: '3px dashed grey',\n borderRadius: 5,\n width: '100%',\n height: '100%',\n position: 'absolute',\n display: 'flex',\n },\n uploadCenterIcon: {\n paddingTop: 10,\n width: 48,\n height: 48,\n },\n uploadCenterText: {\n fontSize: 16,\n },\n uploadCenterTextAndIcon: {\n textAlign: 'center',\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n },\n disabledOpacity: {\n opacity: 0.3,\n cursor: 'default',\n },\n error: {\n border: '2px solid red',\n },\n deleteButton: {},\n selectedImage: {\n height: 40,\n width: 40,\n display: 'inline-block',\n marginRight: 8,\n },\n};\n\nconst IMAGE_EXT = ['jpg', 'jpeg', 'svg', 'png', 'webp', 'gif', 'apng', 'avif', 'webp'];\nconst AUDIO_EXT = ['mp3', 'ogg', 'wav', 'aac'];\nconst VIDEO_EXT = ['avi', 'mp4', 'mov'];\nconst DOC_EXT = ['txt', 'log', 'html', 'htm'];\nconst JS_EXT = ['json', 'js', 'ts'];\n\ninterface ConfigFileSelectorProps extends ConfigGenericProps {\n schema: ConfigItemFileSelector;\n}\n\ninterface ConfigFileSelectorState extends ConfigGenericState {\n uploadFile?: boolean | 'dragging';\n uploadError?: boolean;\n files?: { name: string; size: string }[];\n deleteFile?: string;\n}\n\nclass ConfigFileSelector extends ConfigGeneric<ConfigFileSelectorProps, ConfigFileSelectorState> {\n private readonly dropzoneRef: React.RefObject<DropzoneRef>;\n\n private readonly imagePrefix: string;\n\n private objectID: string;\n\n private path: string;\n\n constructor(props: ConfigFileSelectorProps) {\n super(props);\n this.dropzoneRef = React.createRef();\n this.imagePrefix = this.props.oContext.imagePrefix ?? './files';\n }\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n\n this.objectID = (this.props.schema.objectID || '0_userdata.0').replace(\n '%INSTANCE%',\n (this.props.oContext.instance || 0).toString(),\n );\n this.path = this.props.schema.upload;\n if (this.path) {\n if (this.path === '/') {\n this.path = '';\n } else if (!this.path.endsWith('/')) {\n this.path = `${this.path}/`;\n }\n }\n\n // read files\n void this.updateFiles().then(() => {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n this.setState({ value });\n // subscribe on this folder\n this.props.oContext.socket\n .subscribeFiles(this.objectID, `${this.path}/*`, this.onFolderChanged)\n .catch(e => console.error(`Cannot subscribe: ${e}`));\n });\n }\n\n onFolderChanged = (_id: string, fileName: string): void => {\n if (this.path && fileName.startsWith(this.path)) {\n this.updateFiles().catch(e => console.error(`Cannot update files: ${e}`));\n }\n };\n\n componentWillUnmount(): void {\n this.props.oContext.socket\n .subscribeFiles(this.objectID, `${this.path}/*`, this.onFolderChanged)\n .catch(e => console.error(`Cannot subscribe: ${e}`));\n\n super.componentWillUnmount();\n }\n\n async updateFiles(): Promise<void> {\n const files = await this.readFiles(this.props.schema.pattern);\n await new Promise<void>(resolve => this.setState({ files }, resolve));\n }\n\n async readFolder(\n folderName: string,\n files: { name: string; size: string }[],\n filter: string,\n ): Promise<{ name: string; size: string }[]> {\n try {\n const dirFiles = await this.props.oContext.socket.readDir(\n this.objectID,\n folderName.replace(/^\\//, '') || null,\n );\n for (let f = 0; f < dirFiles.length; f++) {\n const file = dirFiles[f];\n if (file.isDir) {\n // read it\n await this.readFolder(`${folderName + file.file}/`, files, filter);\n } else {\n let ok = false;\n if (filter === '*.*' && file.file.includes('.')) {\n ok = true;\n } else if (!filter || filter === '*') {\n ok = true;\n } else if (filter === '.*' && file.file.startsWith('.')) {\n ok = true;\n } else {\n const regExp = new RegExp(`^${filter.replace(/\\./g, '\\\\.').replace(/\\*/g, '.*')}$`);\n ok = regExp.test(file.file);\n }\n\n if (ok) {\n files.push({\n name: folderName + file.file,\n size: file.stats ? Utils.formatBytes(file.stats.size) : '--',\n });\n }\n }\n }\n } catch (e) {\n console.error(`Cannot read \"${folderName}\": ${e}`);\n }\n\n return files;\n }\n\n async readFiles(pattern: string): Promise<{ name: string; size: string }[]> {\n const files: { name: string; size: string }[] = [];\n pattern = pattern || this.props.schema.pattern;\n if (!pattern) {\n pattern = '**/*.*';\n }\n let filter;\n const pos = pattern.lastIndexOf('/');\n if (pos === -1) {\n filter = pattern;\n } else {\n filter = pattern.substring(pos + 1);\n }\n\n if (pattern.startsWith('**')) {\n // read all folders\n await this.readFolder('/', files, filter);\n } else {\n const pos_ = pattern.lastIndexOf('/');\n if (pos_ === -1) {\n await this.readFolder('/', files, filter);\n } else {\n const folder = pattern.substring(0, pos_ + 1);\n await this.readFolder(folder, files, filter);\n }\n }\n\n return files;\n }\n\n onDrop(acceptedFiles: File[]): void {\n const file = acceptedFiles[0];\n const reader = new FileReader();\n const maxSize = this.props.schema.maxSize || 2 * 1024 * 1024;\n\n reader.onabort = () => console.log('file reading was aborted');\n reader.onerror = () => console.log('file reading has failed');\n reader.onload = (/* e: ProgressEvent<FileReader> */): void => {\n if (file.size > maxSize) {\n window.alert(I18n.t('jc_File is too big. Max %sk allowed. Try use SVG.', Math.round(maxSize / 1024)));\n return;\n }\n\n this.props.oContext.socket\n .writeFile64(this.objectID, this.path + file.name, reader.result as ArrayBuffer)\n .then(() => this.updateFiles())\n .then(() =>\n // Automatically select the new uploaded file\n this.setState({ value: this.path + file.name }, () =>\n this.onChange(this.props.attr, this.path + file.name),\n ),\n )\n .catch(e => window.alert(`Cannot upload file: ${e}`));\n };\n reader.readAsArrayBuffer(file);\n }\n\n renderDeleteDialog(): JSX.Element | null {\n if (!this.state.deleteFile) {\n return null;\n }\n return (\n <DialogConfirm\n title={I18n.t('jc_Are you sure?')}\n text={I18n.t('jc_File will be deleted')}\n ok={I18n.t('jc_Delete')}\n cancel={I18n.t('jc_Cancel')}\n onClose={isOk => {\n const deleteFile = this.state.deleteFile;\n this.setState({ deleteFile: '' }, () => {\n if (isOk) {\n this.props.oContext.socket\n .deleteFile(this.objectID, deleteFile)\n .then(() => this.updateFiles())\n .catch(e => window.alert(`Cannot delete file: ${e}`));\n }\n });\n }}\n />\n );\n }\n\n static base64ToArrayBuffer(base64: string): ArrayBufferLike {\n const binaryString = window.atob(base64);\n const len = binaryString.length;\n const bytes = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes.buffer;\n }\n\n loadFile(): Promise<{ file: string; mimeType: string }> {\n return this.props.oContext.socket.readFile(this.objectID, this.state.value, true);\n }\n\n play(): void {\n void this.loadFile().then(data => {\n if (typeof AudioContext !== 'undefined') {\n const oContext = new AudioContext();\n const buf: ArrayBuffer = ConfigFileSelector.base64ToArrayBuffer(data.file) as ArrayBuffer;\n void oContext.decodeAudioData(\n buf,\n (buffer: AudioBuffer): void => {\n const source = oContext.createBufferSource(); // creates a sound source\n source.buffer = buffer; // tell the source which sound to play\n source.connect(oContext.destination); // connect the source to the oContext's destination (the speakers)\n source.start(0);\n },\n (err: DOMException): void => window.alert(`Cannot play: ${err.message}`),\n );\n }\n });\n }\n\n getFileIcon(item: { value: string; label: string; extension?: string }): JSX.Element | null {\n if (!item?.extension) {\n return null;\n }\n if (IMAGE_EXT.includes(item.extension)) {\n return (\n <div\n style={{\n ...styles.selectedImage,\n backgroundImage: `url(${this.imagePrefix}/${this.objectID}/${item.value})`,\n backgroundSize: 'contain',\n backgroundRepeat: 'no-repeat',\n }}\n />\n );\n }\n if (AUDIO_EXT.includes(item.extension)) {\n return <IconAudio />;\n }\n if (DOC_EXT.includes(item.extension)) {\n return <IconText />;\n }\n if (VIDEO_EXT.includes(item.extension)) {\n return <IconVideo />;\n }\n if (JS_EXT.includes(item.extension)) {\n return <IconCode />;\n }\n return null;\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element | null {\n if (!this.state.files) {\n return null;\n }\n const folders: string[] = [];\n if (!this.props.schema.withFolder) {\n this.state.files.forEach(file => {\n const pos = file.name.lastIndexOf('/');\n if (pos === -1) {\n if (!folders.includes('/')) {\n folders.push('/');\n }\n } else {\n const folder = file.name.substring(0, pos + 1);\n if (!folders.includes(folder)) {\n folders.push(folder);\n }\n }\n });\n }\n\n const selectOptions: { value: string; label: string; extension?: string }[] = this.state.files.map(file => ({\n value: file.name,\n label:\n !this.props.schema.withFolder && folders.length === 1\n ? `${file.name.substring(folders[0].length)}`\n : `${file.name}${this.props.schema.noSize ? '' : `(${file.size})`}`,\n extension: file.name.toLowerCase().split('.').pop(),\n }));\n\n if (!this.props.schema.noNone) {\n selectOptions.unshift({ label: I18n.t('jc_none'), value: '' });\n }\n\n const item: { value: string; label: string; extension?: string } = selectOptions.find(\n _item => _item.value === this.state.value,\n );\n\n let buttons = 0;\n\n if (this.props.schema.upload) {\n buttons++;\n }\n if (this.props.schema.refresh) {\n buttons++;\n }\n const play =\n this.state.value &&\n (this.state.value.endsWith('.mp3') ||\n this.state.value.endsWith('.ogg') ||\n this.state.value.endsWith('.wav'));\n // show play button\n if (play) {\n buttons++;\n }\n\n const element = (\n <div style={styles.fullWidth}>\n <FormControl\n variant=\"standard\"\n style={{ width: `calc(100% - ${buttons * 42}px)` }}\n >\n {this.props.schema.label ? <InputLabel>{this.getText(this.props.schema.label)}</InputLabel> : null}\n <Select\n variant=\"standard\"\n error={!!error}\n disabled={!!disabled}\n value={this.state.value || '_'}\n renderValue={() => (\n <>\n {this.getFileIcon(item)}\n <span>{item?.label || ''}</span>\n </>\n )}\n onChange={e => {\n this.setState({ value: e.target.value === '_' ? '' : e.target.value }, () =>\n this.onChange(this.props.attr, this.state.value),\n );\n }}\n >\n {selectOptions.map(it => (\n <MenuItem\n key={it.value}\n value={it.value}\n >\n <ListItemIcon>{this.getFileIcon(it)}</ListItemIcon>\n <ListItemText>{it.label}</ListItemText>\n {this.props.schema.delete && item.value ? (\n <IconButton\n style={styles.deleteButton}\n size=\"small\"\n onClick={() => this.setState({ deleteFile: item.value })}\n >\n <IconDelete />\n </IconButton>\n ) : null}\n </MenuItem>\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 {this.props.schema.refresh && (\n <IconButton onClick={() => this.updateFiles()}>\n <IconRefresh />\n </IconButton>\n )}\n {this.props.schema.upload && (\n <IconButton onClick={() => this.dropzoneRef.current?.open()}>\n <IconUpload />\n </IconButton>\n )}\n {play && (\n <IconButton\n style={{ color: '#00FF00' }}\n onClick={() => this.play()}\n >\n <IconPlay />\n </IconButton>\n )}\n </div>\n );\n\n if (!this.props.schema.upload) {\n return (\n <>\n {element}\n {this.renderDeleteDialog()}\n </>\n );\n }\n let accept: Record<string, string[]> = { '*/*': [] };\n if (this.props.schema.fileTypes === 'image') {\n accept = {\n 'image/*': ['.png', '.jpg', '.svg', '.gif', '.apng', '.avif', '.webp'],\n };\n } else if (this.props.schema.fileTypes === 'audio') {\n accept = {\n 'audio/*': ['.mp3', '.ogg', '.wav', '.mp4'],\n };\n } else if (this.props.schema.fileTypes === 'text') {\n accept = {\n 'text/plain': ['.txt'],\n };\n }\n if (this.props.schema.pattern) {\n const last = this.props.schema.pattern.split('/').pop().toLowerCase().replace(/.*\\./, '');\n if (\n last === 'png' ||\n last === 'jpg' ||\n last === 'svg' ||\n last === 'gif' ||\n last === 'apng' ||\n last === 'avif' ||\n last === 'webp'\n ) {\n accept = {\n 'image/*': ['.png', '.jpg', '.svg', '.gif', '.apng', '.avif', '.webp'],\n };\n } else if (last === 'mp3' || last === 'ogg' || last === 'wav') {\n accept = {\n 'audio/*': ['.mp3', '.ogg', '.wav', '.mp4'],\n };\n } else if (last === 'ics') {\n accept = {\n 'text/calendar': ['.ics'],\n };\n } else if (last === 'txt') {\n accept = {\n 'text/plain': ['.txt'],\n };\n } else if (last === 'pem') {\n accept = {\n 'text/plain': ['.pem'],\n };\n } else {\n accept = {\n '*/*': [`.${last}`],\n };\n }\n }\n\n return (\n <Dropzone\n ref={this.dropzoneRef}\n multiple={false}\n accept={accept}\n noKeyboard\n noClick\n maxSize={this.props.schema.maxSize || 2 * 1024 * 1024}\n onDragEnter={() => {\n this.setState({ uploadFile: 'dragging' });\n }}\n onDragLeave={() => this.setState({ uploadFile: true })}\n onDrop={(acceptedFiles, errors) => {\n this.setState({ uploadFile: false });\n if (!acceptedFiles.length) {\n window.alert(errors?.[0]?.errors?.[0]?.message || I18n.t('jc_Cannot upload'));\n } else {\n this.onDrop(acceptedFiles);\n }\n }}\n >\n {({ getRootProps, getInputProps }) => (\n <div\n style={{\n ...styles.uploadDiv,\n ...(this.state.uploadFile === 'dragging' ? styles.uploadDivDragging : undefined),\n ...(disabled ? styles.disabledOpacity : undefined),\n }}\n {...getRootProps()}\n >\n <input {...getInputProps()} />\n {this.state.uploadFile === 'dragging' ? (\n <div\n style={{\n ...styles.uploadCenterDiv,\n ...(this.state.uploadError ? styles.error : undefined),\n }}\n >\n <div style={styles.uploadCenterTextAndIcon}>\n <UploadIcon style={styles.uploadCenterIcon} />\n <div style={styles.uploadCenterText}>\n {this.state.uploadFile === 'dragging'\n ? I18n.t('jc_Drop file here')\n : I18n.t(\n 'jc_Place your files here or click here to open the browse dialog',\n )}\n </div>\n </div>\n </div>\n ) : null}\n {element}\n {this.renderDeleteDialog()}\n </div>\n )}\n </Dropzone>\n );\n }\n}\n\nexport default ConfigFileSelector;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigFileSelector.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigFileSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,QAA8B,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EACH,UAAU,EACV,QAAQ,EACR,cAAc,EACd,WAAW,EACX,MAAM,EACN,U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a,EAAE,GAAI;YAC7B,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,CACpC,6BACI,KAAK,EAAE;oBACH,GAAG,MAAM,CAAC,eAAe;oBACzB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;iBACzD;gBAED,6BAAK,KAAK,EAAE,MAAM,CAAC,uBAAuB;oBACtC,oBAAC,UAAU,IAAC,KAAK,EAAE,MAAM,CAAC,gBAAgB,GAAI;oBAC9C,6BAAK,KAAK,EAAE,MAAM,CAAC,gBAAgB,IAC9B,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU;wBACjC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC;wBAC7B,CAAC,CAAC,IAAI,CAAC,CAAC,CACF,kEAAkE,CACrE,CACL,CACJ,CACJ,CACT,CAAC,CAAC,CAAC,IAAI;YACP,OAAO;YACP,IAAI,CAAC,kBAAkB,EAAE,CACxB,CACT,CACM,CACd,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\nimport Dropzone, { type DropzoneRef } from 'react-dropzone';\n\nimport {\n InputLabel,\n MenuItem,\n FormHelperText,\n FormControl,\n Select,\n IconButton,\n ListItemText,\n ListItemIcon,\n} from '@mui/material';\n\nimport {\n Refresh as IconRefresh,\n UploadFile as IconUpload,\n Delete as IconDelete,\n PlayArrow as IconPlay,\n MusicNote as IconAudio,\n Videocam as IconVideo,\n Article as IconText,\n Code as IconCode,\n UploadFile as UploadIcon,\n} from '@mui/icons-material';\n\nimport { DialogConfirm, Utils, I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemFileSelector } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n fullWidth: {\n width: '100%',\n },\n fullWidthOneButton: {\n width: 'calc(100% - 42px)',\n },\n fullWidthTwoButtons: {\n width: 'calc(100% - 84px)',\n },\n fullWidthThreeButtons: {\n width: 'calc(100% - 126x)',\n },\n dropZone: {\n width: '100%',\n height: '100%',\n position: 'absolute',\n },\n dropZoneEmpty: {},\n image: {\n objectFit: 'contain',\n margin: 'auto',\n display: 'flex',\n width: '100%',\n height: '100%',\n },\n uploadDiv: {\n position: 'relative',\n width: '100%',\n },\n uploadDivDragging: {\n opacity: 1,\n background: 'rgba(128,255,128,0.1)',\n },\n uploadCenterDiv: {\n margin: 5,\n border: '3px dashed grey',\n borderRadius: 5,\n width: '100%',\n height: '100%',\n position: 'absolute',\n display: 'flex',\n },\n uploadCenterIcon: {\n paddingTop: 10,\n width: 48,\n height: 48,\n },\n uploadCenterText: {\n fontSize: 16,\n },\n uploadCenterTextAndIcon: {\n textAlign: 'center',\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n },\n disabledOpacity: {\n opacity: 0.3,\n cursor: 'default',\n },\n error: {\n border: '2px solid red',\n },\n deleteButton: {},\n selectedImage: {\n height: 40,\n width: 40,\n display: 'inline-block',\n marginRight: 8,\n },\n};\n\nconst IMAGE_EXT = ['jpg', 'jpeg', 'svg', 'png', 'webp', 'gif', 'apng', 'avif', 'webp'];\nconst AUDIO_EXT = ['mp3', 'ogg', 'wav', 'aac'];\nconst VIDEO_EXT = ['avi', 'mp4', 'mov'];\nconst DOC_EXT = ['txt', 'log', 'html', 'htm'];\nconst JS_EXT = ['json', 'js', 'ts'];\n\ninterface ConfigFileSelectorProps extends ConfigGenericProps {\n schema: ConfigItemFileSelector;\n}\n\ninterface ConfigFileSelectorState extends ConfigGenericState {\n uploadFile?: boolean | 'dragging';\n uploadError?: boolean;\n files?: { name: string; size: string }[];\n deleteFile?: string;\n}\n\nexport default class ConfigFileSelector extends ConfigGeneric<ConfigFileSelectorProps, ConfigFileSelectorState> {\n private readonly dropzoneRef: React.RefObject<DropzoneRef>;\n\n private readonly imagePrefix: string;\n\n private objectID: string;\n\n private path: string;\n\n constructor(props: ConfigFileSelectorProps) {\n super(props);\n this.dropzoneRef = React.createRef();\n this.imagePrefix = this.props.oContext.imagePrefix ?? './files';\n }\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n\n this.objectID = (this.props.schema.objectID || '0_userdata.0').replace(\n '%INSTANCE%',\n (this.props.oContext.instance || 0).toString(),\n );\n this.path = this.props.schema.upload;\n if (this.path) {\n if (this.path === '/') {\n this.path = '';\n } else if (!this.path.endsWith('/')) {\n this.path = `${this.path}/`;\n }\n }\n\n // read files\n void this.updateFiles().then(() => {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n this.setState({ value });\n // subscribe to this folder\n this.props.oContext.socket\n .subscribeFiles(this.objectID, `${this.path}/*`, this.onFolderChanged)\n .catch(e => console.error(`Cannot subscribe: ${e}`));\n });\n }\n\n onFolderChanged = (_id: string, fileName: string): void => {\n if (this.path && fileName.startsWith(this.path)) {\n this.updateFiles().catch(e => console.error(`Cannot update files: ${e}`));\n }\n };\n\n componentWillUnmount(): void {\n this.props.oContext.socket\n .subscribeFiles(this.objectID, `${this.path}/*`, this.onFolderChanged)\n .catch(e => console.error(`Cannot subscribe: ${e}`));\n\n super.componentWillUnmount();\n }\n\n async updateFiles(): Promise<void> {\n const files = await this.readFiles(this.props.schema.pattern);\n await new Promise<void>(resolve => this.setState({ files }, resolve));\n }\n\n async readFolder(\n folderName: string,\n files: { name: string; size: string }[],\n filter: string,\n ): Promise<{ name: string; size: string }[]> {\n try {\n const dirFiles = await this.props.oContext.socket.readDir(\n this.objectID,\n folderName.replace(/^\\//, '') || null,\n );\n for (let f = 0; f < dirFiles.length; f++) {\n const file = dirFiles[f];\n if (file.isDir) {\n // read it\n await this.readFolder(`${folderName + file.file}/`, files, filter);\n } else {\n let ok = false;\n if (filter === '*.*' && file.file.includes('.')) {\n ok = true;\n } else if (!filter || filter === '*') {\n ok = true;\n } else if (filter === '.*' && file.file.startsWith('.')) {\n ok = true;\n } else {\n const regExp = new RegExp(`^${filter.replace(/\\./g, '\\\\.').replace(/\\*/g, '.*')}$`);\n ok = regExp.test(file.file);\n }\n\n if (ok) {\n files.push({\n name: folderName + file.file,\n size: file.stats ? Utils.formatBytes(file.stats.size) : '--',\n });\n }\n }\n }\n } catch (e) {\n console.error(`Cannot read \"${folderName}\": ${e}`);\n }\n\n return files;\n }\n\n async readFiles(pattern: string): Promise<{ name: string; size: string }[]> {\n const files: { name: string; size: string }[] = [];\n pattern = pattern || this.props.schema.pattern;\n if (!pattern) {\n pattern = '**/*.*';\n }\n let filter;\n const pos = pattern.lastIndexOf('/');\n if (pos === -1) {\n filter = pattern;\n } else {\n filter = pattern.substring(pos + 1);\n }\n\n if (pattern.startsWith('**')) {\n // read all folders\n await this.readFolder('/', files, filter);\n } else {\n const pos_ = pattern.lastIndexOf('/');\n if (pos_ === -1) {\n await this.readFolder('/', files, filter);\n } else {\n const folder = pattern.substring(0, pos_ + 1);\n await this.readFolder(folder, files, filter);\n }\n }\n\n return files;\n }\n\n onDrop(acceptedFiles: File[]): void {\n const file = acceptedFiles[0];\n const reader = new FileReader();\n const maxSize = this.props.schema.maxSize || 2 * 1024 * 1024;\n\n reader.onabort = () => console.log('file reading was aborted');\n reader.onerror = () => console.log('file reading has failed');\n reader.onload = (/* e: ProgressEvent<FileReader> */): void => {\n if (file.size > maxSize) {\n window.alert(I18n.t('jc_File is too big. Max %sk allowed. Try use SVG.', Math.round(maxSize / 1024)));\n return;\n }\n\n this.props.oContext.socket\n .writeFile64(this.objectID, this.path + file.name, reader.result as ArrayBuffer)\n .then(() => this.updateFiles())\n .then(() =>\n // Automatically select the new uploaded file\n this.setState({ value: this.path + file.name }, () =>\n this.onChange(this.props.attr, this.path + file.name),\n ),\n )\n .catch(e => window.alert(`Cannot upload file: ${e}`));\n };\n reader.readAsArrayBuffer(file);\n }\n\n renderDeleteDialog(): JSX.Element | null {\n if (!this.state.deleteFile) {\n return null;\n }\n return (\n <DialogConfirm\n title={I18n.t('jc_Are you sure?')}\n text={I18n.t('jc_File will be deleted')}\n ok={I18n.t('jc_Delete')}\n cancel={I18n.t('jc_Cancel')}\n onClose={isOk => {\n const deleteFile = this.state.deleteFile;\n this.setState({ deleteFile: '' }, () => {\n if (isOk) {\n this.props.oContext.socket\n .deleteFile(this.objectID, deleteFile)\n .then(() => this.updateFiles())\n .catch(e => window.alert(`Cannot delete file: ${e}`));\n }\n });\n }}\n />\n );\n }\n\n static base64ToArrayBuffer(base64: string): ArrayBufferLike {\n const binaryString = window.atob(base64);\n const len = binaryString.length;\n const bytes = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes.buffer;\n }\n\n loadFile(): Promise<{ file: string; mimeType: string }> {\n return this.props.oContext.socket.readFile(this.objectID, this.state.value, true);\n }\n\n play(): void {\n void this.loadFile().then(data => {\n if (typeof AudioContext !== 'undefined') {\n const oContext = new AudioContext();\n const buf: ArrayBuffer = ConfigFileSelector.base64ToArrayBuffer(data.file) as ArrayBuffer;\n void oContext.decodeAudioData(\n buf,\n (buffer: AudioBuffer): void => {\n const source = oContext.createBufferSource(); // creates a sound source\n source.buffer = buffer; // tell the source which sound to play\n source.connect(oContext.destination); // connect the source to the oContext's destination (the speakers)\n source.start(0);\n },\n (err: DOMException): void => window.alert(`Cannot play: ${err.message}`),\n );\n }\n });\n }\n\n getFileIcon(item: { value: string; label: string; extension?: string }): JSX.Element | null {\n if (!item?.extension) {\n return null;\n }\n if (IMAGE_EXT.includes(item.extension)) {\n return (\n <div\n style={{\n ...styles.selectedImage,\n backgroundImage: `url(${this.imagePrefix}/${this.objectID}/${item.value})`,\n backgroundSize: 'contain',\n backgroundRepeat: 'no-repeat',\n }}\n />\n );\n }\n if (AUDIO_EXT.includes(item.extension)) {\n return <IconAudio />;\n }\n if (DOC_EXT.includes(item.extension)) {\n return <IconText />;\n }\n if (VIDEO_EXT.includes(item.extension)) {\n return <IconVideo />;\n }\n if (JS_EXT.includes(item.extension)) {\n return <IconCode />;\n }\n return null;\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element | null {\n if (!this.state.files) {\n return null;\n }\n const folders: string[] = [];\n if (!this.props.schema.withFolder) {\n this.state.files.forEach(file => {\n const pos = file.name.lastIndexOf('/');\n if (pos === -1) {\n if (!folders.includes('/')) {\n folders.push('/');\n }\n } else {\n const folder = file.name.substring(0, pos + 1);\n if (!folders.includes(folder)) {\n folders.push(folder);\n }\n }\n });\n }\n\n const selectOptions: { value: string; label: string; extension?: string }[] = this.state.files.map(file => ({\n value: file.name,\n label:\n !this.props.schema.withFolder && folders.length === 1\n ? `${file.name.substring(folders[0].length)}`\n : `${file.name}${this.props.schema.noSize ? '' : `(${file.size})`}`,\n extension: file.name.toLowerCase().split('.').pop(),\n }));\n\n if (!this.props.schema.noNone) {\n selectOptions.unshift({ label: I18n.t('jc_none'), value: '' });\n }\n\n const item: { value: string; label: string; extension?: string } = selectOptions.find(\n _item => _item.value === this.state.value,\n );\n\n let buttons = 0;\n\n if (this.props.schema.upload) {\n buttons++;\n }\n if (this.props.schema.refresh) {\n buttons++;\n }\n const play =\n this.state.value &&\n (this.state.value.endsWith('.mp3') ||\n this.state.value.endsWith('.ogg') ||\n this.state.value.endsWith('.wav'));\n // show play button\n if (play) {\n buttons++;\n }\n\n const element = (\n <div style={styles.fullWidth}>\n <FormControl\n variant=\"standard\"\n style={{ width: `calc(100% - ${buttons * 42}px)` }}\n >\n {this.props.schema.label ? <InputLabel>{this.getText(this.props.schema.label)}</InputLabel> : null}\n <Select\n variant=\"standard\"\n error={!!error}\n disabled={!!disabled}\n value={this.state.value || '_'}\n renderValue={() => (\n <>\n {this.getFileIcon(item)}\n <span>{item?.label || ''}</span>\n </>\n )}\n onChange={e => {\n this.setState({ value: e.target.value === '_' ? '' : e.target.value }, () =>\n this.onChange(this.props.attr, this.state.value),\n );\n }}\n >\n {selectOptions.map(it => (\n <MenuItem\n key={it.value}\n value={it.value}\n >\n <ListItemIcon>{this.getFileIcon(it)}</ListItemIcon>\n <ListItemText>{it.label}</ListItemText>\n {this.props.schema.delete && it.value ? (\n <IconButton\n style={styles.deleteButton}\n size=\"small\"\n onClick={e => {\n e.stopPropagation();\n this.setState({ deleteFile: it.value });\n }}\n >\n <IconDelete />\n </IconButton>\n ) : null}\n </MenuItem>\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 {this.props.schema.refresh && (\n <IconButton onClick={() => this.updateFiles()}>\n <IconRefresh />\n </IconButton>\n )}\n {this.props.schema.upload && (\n <IconButton onClick={() => this.dropzoneRef.current?.open()}>\n <IconUpload />\n </IconButton>\n )}\n {play && (\n <IconButton\n style={{ color: '#00FF00' }}\n onClick={() => this.play()}\n >\n <IconPlay />\n </IconButton>\n )}\n </div>\n );\n\n if (!this.props.schema.upload) {\n return (\n <>\n {element}\n {this.renderDeleteDialog()}\n </>\n );\n }\n let accept: Record<string, string[]> = { '*/*': [] };\n if (this.props.schema.fileTypes === 'image') {\n accept = {\n 'image/*': ['.png', '.jpg', '.svg', '.gif', '.apng', '.avif', '.webp'],\n };\n } else if (this.props.schema.fileTypes === 'audio') {\n accept = {\n 'audio/*': ['.mp3', '.ogg', '.wav', '.mp4'],\n };\n } else if (this.props.schema.fileTypes === 'text') {\n accept = {\n 'text/plain': ['.txt'],\n };\n }\n if (this.props.schema.pattern) {\n const last = this.props.schema.pattern.split('/').pop().toLowerCase().replace(/.*\\./, '');\n if (\n last === 'png' ||\n last === 'jpg' ||\n last === 'svg' ||\n last === 'gif' ||\n last === 'apng' ||\n last === 'avif' ||\n last === 'webp'\n ) {\n accept = {\n 'image/*': ['.png', '.jpg', '.svg', '.gif', '.apng', '.avif', '.webp'],\n };\n } else if (last === 'mp3' || last === 'ogg' || last === 'wav') {\n accept = {\n 'audio/*': ['.mp3', '.ogg', '.wav', '.mp4'],\n };\n } else if (last === 'ics') {\n accept = {\n 'text/calendar': ['.ics'],\n };\n } else if (last === 'txt') {\n accept = {\n 'text/plain': ['.txt'],\n };\n } else if (last === 'pem') {\n accept = {\n 'text/plain': ['.pem'],\n };\n } else {\n accept = {\n '*/*': [`.${last}`],\n };\n }\n }\n\n return (\n <Dropzone\n ref={this.dropzoneRef}\n multiple={false}\n accept={accept}\n noKeyboard\n noClick\n maxSize={this.props.schema.maxSize || 2 * 1024 * 1024}\n onDragEnter={() => {\n this.setState({ uploadFile: 'dragging' });\n }}\n onDragLeave={() => this.setState({ uploadFile: true })}\n onDrop={(acceptedFiles, errors) => {\n this.setState({ uploadFile: false });\n if (!acceptedFiles.length) {\n window.alert(errors?.[0]?.errors?.[0]?.message || I18n.t('jc_Cannot upload'));\n } else {\n this.onDrop(acceptedFiles);\n }\n }}\n >\n {({ getRootProps, getInputProps }) => (\n <div\n style={{\n ...styles.uploadDiv,\n ...(this.state.uploadFile === 'dragging' ? styles.uploadDivDragging : undefined),\n ...(disabled ? styles.disabledOpacity : undefined),\n }}\n {...getRootProps()}\n >\n <input {...getInputProps()} />\n {this.state.uploadFile === 'dragging' ? (\n <div\n style={{\n ...styles.uploadCenterDiv,\n ...(this.state.uploadError ? styles.error : undefined),\n }}\n >\n <div style={styles.uploadCenterTextAndIcon}>\n <UploadIcon style={styles.uploadCenterIcon} />\n <div style={styles.uploadCenterText}>\n {this.state.uploadFile === 'dragging'\n ? I18n.t('jc_Drop file here')\n : I18n.t(\n 'jc_Place your files here or click here to open the browse dialog',\n )}\n </div>\n </div>\n </div>\n ) : null}\n {element}\n {this.renderDeleteDialog()}\n </div>\n )}\n </Dropzone>\n );\n }\n}\n"]}
|
|
@@ -122,8 +122,18 @@ export default class ConfigGeneric<Props extends ConfigGenericProps = ConfigGene
|
|
|
122
122
|
onChange(attr: string, newValue: unknown, cb?: () => void): Promise<void>;
|
|
123
123
|
/** Ensure that every bare getObject( call is preceded by "await". */
|
|
124
124
|
static ensureAwaitGetObject(code: string): string;
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Log the evaluation of a JS function to the browser console if the element has `debug: true`.
|
|
127
|
+
* Requested in https://github.com/ioBroker/ioBroker.admin/issues/3374
|
|
128
|
+
*
|
|
129
|
+
* @param funcName name of the evaluated function, e.g. `hidden`, `disabled`, `validator`
|
|
130
|
+
* @param func the JS function source that was executed
|
|
131
|
+
* @param result the value the function returned (or an Error if it threw)
|
|
132
|
+
* @param data the data object the function was executed against
|
|
133
|
+
*/
|
|
134
|
+
protected debugLog(funcName: string, func: string, result: unknown, data?: Record<string, any>): void;
|
|
135
|
+
execute(func: string | boolean | Record<string, string>, defaultValue: string | number | boolean, data: Record<string, any>, arrayIndex: number, globalData: Record<string, any>, funcName?: string): Promise<string | number | boolean>;
|
|
136
|
+
executeCustom(func: string | boolean | Record<string, string>, data: Record<string, any>, customObj: Record<string, any>, instanceObj: ioBroker.InstanceObject, arrayIndex: number, globalData: Record<string, any>, funcName?: string): Promise<string | boolean | number | null>;
|
|
127
137
|
calculate(schema: Record<string, any>): Promise<{
|
|
128
138
|
error: boolean;
|
|
129
139
|
disabled: boolean;
|
|
@@ -62,10 +62,10 @@ export default class ConfigGeneric extends Component {
|
|
|
62
62
|
async componentDidMount() {
|
|
63
63
|
if (this.props.schema?.defaultFunc) {
|
|
64
64
|
if (this.props.custom) {
|
|
65
|
-
this.defaultValue = await this.executeCustom(this.props.schema.defaultFunc, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData);
|
|
65
|
+
this.defaultValue = await this.executeCustom(this.props.schema.defaultFunc, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData, 'defaultFunc');
|
|
66
66
|
}
|
|
67
67
|
else if (this.props.schema.type !== 'state') {
|
|
68
|
-
this.defaultValue = await this.execute(this.props.schema.defaultFunc, this.props.schema.default, this.props.data, this.props.arrayIndex, this.props.globalData);
|
|
68
|
+
this.defaultValue = await this.execute(this.props.schema.defaultFunc, this.props.schema.default, this.props.data, this.props.arrayIndex, this.props.globalData, 'defaultFunc');
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
this.props.oContext.registerOnForceUpdate?.(this.props.attr, this.onUpdate);
|
|
@@ -410,7 +410,7 @@ export default class ConfigGeneric extends Component {
|
|
|
410
410
|
const data = JSON.parse(JSON.stringify(this.props.data));
|
|
411
411
|
ConfigGeneric.setValue(data, attr, newValue);
|
|
412
412
|
if (this.props.schema.confirm &&
|
|
413
|
-
(await this.execute(this.props.schema.confirm.condition, false, data, this.props.arrayIndex, this.props.globalData))) {
|
|
413
|
+
(await this.execute(this.props.schema.confirm.condition, false, data, this.props.arrayIndex, this.props.globalData, 'confirm.condition'))) {
|
|
414
414
|
return new Promise(resolve => {
|
|
415
415
|
this.setState({
|
|
416
416
|
confirmDialog: true,
|
|
@@ -433,7 +433,7 @@ export default class ConfigGeneric extends Component {
|
|
|
433
433
|
const dep = this.props.schema.confirmDependsOn[z];
|
|
434
434
|
if (dep.confirm) {
|
|
435
435
|
const val = ConfigGeneric.getValue(data, dep.attr);
|
|
436
|
-
if (await this.execute(dep.confirm.condition, false, data, this.props.arrayIndex, this.props.globalData)) {
|
|
436
|
+
if (await this.execute(dep.confirm.condition, false, data, this.props.arrayIndex, this.props.globalData, 'confirm.condition')) {
|
|
437
437
|
return new Promise(resolve => {
|
|
438
438
|
this.setState({
|
|
439
439
|
confirmDialog: true,
|
|
@@ -463,10 +463,10 @@ export default class ConfigGeneric extends Component {
|
|
|
463
463
|
const val = ConfigGeneric.getValue(data, dep.attr);
|
|
464
464
|
let _newValue;
|
|
465
465
|
if (this.props.custom) {
|
|
466
|
-
_newValue = await this.executeCustom(dep.onChange.calculateFunc, data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData);
|
|
466
|
+
_newValue = await this.executeCustom(dep.onChange.calculateFunc, data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData, 'onChange.calculateFunc');
|
|
467
467
|
}
|
|
468
468
|
else {
|
|
469
|
-
_newValue = await this.execute(dep.onChange.calculateFunc, val, data, this.props.arrayIndex, this.props.globalData);
|
|
469
|
+
_newValue = await this.execute(dep.onChange.calculateFunc, val, data, this.props.arrayIndex, this.props.globalData, 'onChange.calculateFunc');
|
|
470
470
|
}
|
|
471
471
|
if (_newValue !== val) {
|
|
472
472
|
ConfigGeneric.setValue(data, dep.attr, _newValue);
|
|
@@ -502,8 +502,8 @@ export default class ConfigGeneric extends Component {
|
|
|
502
502
|
if (this.props.schema.onChange && !this.props.schema.onChange.ignoreOwnChanges) {
|
|
503
503
|
const val = ConfigGeneric.getValue(data, this.props.attr);
|
|
504
504
|
const newValue_ = this.props.custom
|
|
505
|
-
? await this.executeCustom(this.props.schema.onChange.calculateFunc, data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData)
|
|
506
|
-
: await this.execute(this.props.schema.onChange.calculateFunc, val, data, this.props.arrayIndex, this.props.globalData);
|
|
505
|
+
? await this.executeCustom(this.props.schema.onChange.calculateFunc, data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData, 'onChange.calculateFunc')
|
|
506
|
+
: await this.execute(this.props.schema.onChange.calculateFunc, val, data, this.props.arrayIndex, this.props.globalData, 'onChange.calculateFunc');
|
|
507
507
|
if (newValue_ !== val) {
|
|
508
508
|
ConfigGeneric.setValue(data, this.props.attr, newValue_);
|
|
509
509
|
}
|
|
@@ -534,7 +534,35 @@ export default class ConfigGeneric extends Component {
|
|
|
534
534
|
return `await ${match}`;
|
|
535
535
|
});
|
|
536
536
|
}
|
|
537
|
-
|
|
537
|
+
/**
|
|
538
|
+
* Log the evaluation of a JS function to the browser console if the element has `debug: true`.
|
|
539
|
+
* Requested in https://github.com/ioBroker/ioBroker.admin/issues/3374
|
|
540
|
+
*
|
|
541
|
+
* @param funcName name of the evaluated function, e.g. `hidden`, `disabled`, `validator`
|
|
542
|
+
* @param func the JS function source that was executed
|
|
543
|
+
* @param result the value the function returned (or an Error if it threw)
|
|
544
|
+
* @param data the data object the function was executed against
|
|
545
|
+
*/
|
|
546
|
+
debugLog(funcName, func, result, data) {
|
|
547
|
+
if (!this.props.schema?.debug) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
const attr = this.props.attr || this.props.schema?.attr || '';
|
|
551
|
+
const label = `%c[jsonConfig]%c ${attr ? `${attr} → ` : ''}${funcName}`;
|
|
552
|
+
const payload = {
|
|
553
|
+
function: func,
|
|
554
|
+
result,
|
|
555
|
+
data: data ?? this.props.data,
|
|
556
|
+
arrayIndex: this.props.arrayIndex,
|
|
557
|
+
};
|
|
558
|
+
if (result instanceof Error) {
|
|
559
|
+
console.error(label, 'background:#b71c1c;color:#fff;border-radius:3px;padding:1px 4px', 'color:#e53935', payload);
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
console.log(label, 'background:#33691e;color:#fff;border-radius:3px;padding:1px 4px', 'color:#7cb342', payload);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
async execute(func, defaultValue, data, arrayIndex, globalData, funcName) {
|
|
538
566
|
let fun;
|
|
539
567
|
if (isObject(func)) {
|
|
540
568
|
fun = func.func;
|
|
@@ -554,14 +582,17 @@ export default class ConfigGeneric extends Component {
|
|
|
554
582
|
}
|
|
555
583
|
try {
|
|
556
584
|
const f = new this.AsyncFunction('data', 'originalData', '_system', '_alive', '_common', '_socket', '_instance', 'arrayIndex', 'globalData', '_changed', '_href', 'getObject', fun.includes('return') ? fun : `return ${fun}`);
|
|
557
|
-
|
|
585
|
+
const result = await f(data || this.props.data, this.props.originalData, this.props.oContext.systemConfig, this.props.alive, this.props.common, this.props.oContext.socket, this.props.oContext.instance, arrayIndex, globalData, this.props.changed, window.location.href, this.getObject);
|
|
586
|
+
this.debugLog(funcName || 'JS function', fun, result, data);
|
|
587
|
+
return result;
|
|
558
588
|
}
|
|
559
589
|
catch (e) {
|
|
590
|
+
this.debugLog(funcName || 'JS function', fun, e instanceof Error ? e : new Error(String(e)), data);
|
|
560
591
|
console.error(`Cannot execute ${JSON.stringify(func)}: ${e}`);
|
|
561
592
|
return defaultValue;
|
|
562
593
|
}
|
|
563
594
|
}
|
|
564
|
-
async executeCustom(func, data, customObj, instanceObj, arrayIndex, globalData) {
|
|
595
|
+
async executeCustom(func, data, customObj, instanceObj, arrayIndex, globalData, funcName) {
|
|
565
596
|
let fun;
|
|
566
597
|
if (isObject(func)) {
|
|
567
598
|
fun = func.func;
|
|
@@ -581,9 +612,12 @@ export default class ConfigGeneric extends Component {
|
|
|
581
612
|
}
|
|
582
613
|
try {
|
|
583
614
|
const f = new this.AsyncFunction('data', 'originalData', '_system', 'instanceObj', 'customObj', '_socket', 'arrayIndex', 'globalData', '_changed', '_href', 'getObject', fun.includes('return') ? fun : `return ${fun}`);
|
|
584
|
-
|
|
615
|
+
const result = await f(data || this.props.data, this.props.originalData, this.props.oContext.systemConfig, instanceObj, customObj, this.props.oContext.socket, arrayIndex, globalData, this.props.changed, window.location.href, this.getObject);
|
|
616
|
+
this.debugLog(funcName || 'JS function', fun, result, data);
|
|
617
|
+
return result;
|
|
585
618
|
}
|
|
586
619
|
catch (e) {
|
|
620
|
+
this.debugLog(funcName || 'JS function', fun, e instanceof Error ? e : new Error(String(e)), data);
|
|
587
621
|
console.error(`Cannot execute ${fun}: ${e}`);
|
|
588
622
|
return null;
|
|
589
623
|
}
|
|
@@ -595,14 +629,14 @@ export default class ConfigGeneric extends Component {
|
|
|
595
629
|
let defaultValue;
|
|
596
630
|
if (this.props.custom) {
|
|
597
631
|
error = schema.validator
|
|
598
|
-
? !(await this.executeCustom(schema.validator, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData))
|
|
632
|
+
? !(await this.executeCustom(schema.validator, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData, 'validator'))
|
|
599
633
|
: false;
|
|
600
634
|
if (schema.disabled === true) {
|
|
601
635
|
disabled = true;
|
|
602
636
|
}
|
|
603
637
|
else {
|
|
604
638
|
disabled = schema.disabled
|
|
605
|
-
? (await this.executeCustom(schema.disabled, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData))
|
|
639
|
+
? (await this.executeCustom(schema.disabled, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData, 'disabled'))
|
|
606
640
|
: false;
|
|
607
641
|
}
|
|
608
642
|
if (schema.hidden === true) {
|
|
@@ -610,23 +644,23 @@ export default class ConfigGeneric extends Component {
|
|
|
610
644
|
}
|
|
611
645
|
else {
|
|
612
646
|
hidden = schema.hidden
|
|
613
|
-
? (await this.executeCustom(schema.hidden, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData))
|
|
647
|
+
? (await this.executeCustom(schema.hidden, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData, 'hidden'))
|
|
614
648
|
: false;
|
|
615
649
|
}
|
|
616
650
|
defaultValue = schema.defaultFunc
|
|
617
|
-
? await this.executeCustom(schema.defaultFunc, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData)
|
|
651
|
+
? await this.executeCustom(schema.defaultFunc, this.props.data, this.props.customObj, this.props.oContext.instanceObj, this.props.arrayIndex, this.props.globalData, 'defaultFunc')
|
|
618
652
|
: schema.default;
|
|
619
653
|
}
|
|
620
654
|
else {
|
|
621
655
|
error = schema.validator
|
|
622
|
-
? !(await this.execute(schema.validator, false, this.props.data, this.props.arrayIndex, this.props.globalData))
|
|
656
|
+
? !(await this.execute(schema.validator, false, this.props.data, this.props.arrayIndex, this.props.globalData, 'validator'))
|
|
623
657
|
: false;
|
|
624
658
|
if (schema.disabled === true) {
|
|
625
659
|
disabled = true;
|
|
626
660
|
}
|
|
627
661
|
else {
|
|
628
662
|
disabled = schema.disabled
|
|
629
|
-
? (await this.execute(schema.disabled, false, this.props.data, this.props.arrayIndex, this.props.globalData))
|
|
663
|
+
? (await this.execute(schema.disabled, false, this.props.data, this.props.arrayIndex, this.props.globalData, 'disabled'))
|
|
630
664
|
: false;
|
|
631
665
|
}
|
|
632
666
|
if (schema.hidden === true) {
|
|
@@ -634,11 +668,11 @@ export default class ConfigGeneric extends Component {
|
|
|
634
668
|
}
|
|
635
669
|
else {
|
|
636
670
|
hidden = schema.hidden
|
|
637
|
-
? (await this.execute(schema.hidden, false, this.props.data, this.props.arrayIndex, this.props.globalData))
|
|
671
|
+
? (await this.execute(schema.hidden, false, this.props.data, this.props.arrayIndex, this.props.globalData, 'hidden'))
|
|
638
672
|
: false;
|
|
639
673
|
}
|
|
640
674
|
defaultValue = schema.defaultFunc
|
|
641
|
-
? await this.execute(schema.defaultFunc, schema.default, this.props.data, this.props.arrayIndex, this.props.globalData)
|
|
675
|
+
? await this.execute(schema.defaultFunc, schema.default, this.props.data, this.props.arrayIndex, this.props.globalData, 'defaultFunc')
|
|
642
676
|
: schema.default;
|
|
643
677
|
}
|
|
644
678
|
return {
|