@iobroker/adapter-react-v5 3.1.22 → 3.1.25
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/Components/FileBrowser.js +26 -9
- package/Components/FileBrowser.js.map +1 -1
- package/Components/FileViewer.js +27 -22
- package/Components/FileViewer.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigSendto.js +171 -9
- package/Components/JsonConfigComponent/ConfigSendto.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigText.js +24 -3
- package/Components/JsonConfigComponent/ConfigText.js.map +1 -1
- package/Components/JsonConfigComponent/index.js +21 -17
- package/Components/JsonConfigComponent/index.js.map +1 -1
- package/Components/ObjectBrowser.js +383 -454
- package/Components/ObjectBrowser.js.map +1 -1
- package/README.md +9 -0
- package/i18n/de.json +4 -1
- package/i18n/en.json +4 -1
- package/i18n/es.json +4 -1
- package/i18n/fr.json +4 -1
- package/i18n/it.json +4 -1
- package/i18n/nl.json +4 -1
- package/i18n/pl.json +4 -1
- package/i18n/pt.json +4 -1
- package/i18n/ru.json +4 -1
- package/i18n/zh-cn.json +4 -1
- package/index.js +1 -0
- package/package.json +1 -1
package/Components/FileViewer.js
CHANGED
|
@@ -29,6 +29,8 @@ var _styles = require("@mui/styles");
|
|
|
29
29
|
|
|
30
30
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
31
|
|
|
32
|
+
var _buffer = require("buffer");
|
|
33
|
+
|
|
32
34
|
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
33
35
|
|
|
34
36
|
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
@@ -94,7 +96,7 @@ var styles = function styles(theme) {
|
|
|
94
96
|
|
|
95
97
|
var EXTENSIONS = {
|
|
96
98
|
images: ['png', 'jpg', 'svg', 'jpeg', 'bmp'],
|
|
97
|
-
code: ['js', 'json', 'md'],
|
|
99
|
+
code: ['js', 'json', 'json5', 'md'],
|
|
98
100
|
txt: ['log', 'txt', 'html', 'css', 'xml'],
|
|
99
101
|
audio: ['mp3', 'wav', 'ogg', 'acc'],
|
|
100
102
|
video: ['mp4', 'mov', 'avi']
|
|
@@ -163,7 +165,7 @@ var FileViewer = /*#__PURE__*/function (_Component) {
|
|
|
163
165
|
var adapter = parts[0];
|
|
164
166
|
var name = parts.splice(1).join('/');
|
|
165
167
|
|
|
166
|
-
_this.props.socket.writeFile64(adapter, name, Buffer.from(data).toString('base64')).then(function (_) {
|
|
168
|
+
_this.props.socket.writeFile64(adapter, name, _buffer.Buffer.from(data).toString('base64')).then(function (_) {
|
|
167
169
|
return _this.props.onClose();
|
|
168
170
|
})["catch"](function (e) {
|
|
169
171
|
return window.alert('Cannot write file: ' + e);
|
|
@@ -250,26 +252,6 @@ var FileViewer = /*#__PURE__*/function (_Component) {
|
|
|
250
252
|
var name = parts.splice(1).join('/');
|
|
251
253
|
this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);
|
|
252
254
|
}
|
|
253
|
-
}, {
|
|
254
|
-
key: "getEditFile",
|
|
255
|
-
value: function getEditFile(ext) {
|
|
256
|
-
switch (ext) {
|
|
257
|
-
case 'json':
|
|
258
|
-
return 'json';
|
|
259
|
-
|
|
260
|
-
case 'js':
|
|
261
|
-
return 'javascript';
|
|
262
|
-
|
|
263
|
-
case 'html':
|
|
264
|
-
return 'html';
|
|
265
|
-
|
|
266
|
-
case 'txt':
|
|
267
|
-
return 'html';
|
|
268
|
-
|
|
269
|
-
default:
|
|
270
|
-
return 'json';
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
255
|
}, {
|
|
274
256
|
key: "getContent",
|
|
275
257
|
value: function getContent() {
|
|
@@ -361,6 +343,29 @@ var FileViewer = /*#__PURE__*/function (_Component) {
|
|
|
361
343
|
startIcon: /*#__PURE__*/_react["default"].createElement(_Close["default"], null)
|
|
362
344
|
}, this.props.t('Close'))));
|
|
363
345
|
}
|
|
346
|
+
}], [{
|
|
347
|
+
key: "getEditFile",
|
|
348
|
+
value: function getEditFile(ext) {
|
|
349
|
+
switch (ext) {
|
|
350
|
+
case 'json':
|
|
351
|
+
return 'json';
|
|
352
|
+
|
|
353
|
+
case 'json5':
|
|
354
|
+
return 'json5';
|
|
355
|
+
|
|
356
|
+
case 'js':
|
|
357
|
+
return 'javascript';
|
|
358
|
+
|
|
359
|
+
case 'html':
|
|
360
|
+
return 'html';
|
|
361
|
+
|
|
362
|
+
case 'txt':
|
|
363
|
+
return 'html';
|
|
364
|
+
|
|
365
|
+
default:
|
|
366
|
+
return 'json';
|
|
367
|
+
}
|
|
368
|
+
}
|
|
364
369
|
}]);
|
|
365
370
|
return FileViewer;
|
|
366
371
|
}(_react.Component);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileViewer.js","names":["styles","theme","dialog","height","paper","content","textAlign","textarea","width","img","objectFit","dialogTitle","justifyContent","display","EXTENSIONS","images","code","txt","audio","video","bufferToBase64","buffer","binary","bytes","Uint8Array","len","byteLength","i","String","fromCharCode","window","btoa","FileViewer","props","id","fileName","size","state","changed","timeout","clearTimeout","setTimeout","alert","text","readFile","setState","forceUpdate","Date","now","parts","href","split","data","editingValue","splice","adapter","name","join","socket","writeFile64","Buffer","from","toString","then","_","onClose","e","ext","Utils","getFileExtension","editing","formatEditFile","copyPossible","includes","imgError","file","undefined","newState","type","detectMimeType","supportSubscribes","subscribeFiles","onFileChanged","clsx","classes","getClassBackgroundImage","target","onerror","newValue","readOnly","scrollPaper","t","setStateBackgroundImage","getContent","copyToClipboard","Component","propTypes","PropTypes","func","lang","string","expertMode","bool","isRequired","_export","withWidth","withStyles"],"sources":["FileViewer.js"],"sourcesContent":["import React, { Component } from 'react';\nimport { withStyles } from '@mui/styles';\nimport PropTypes from 'prop-types';\n\nimport TextField from '@mui/material/TextField';\nimport Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogActions from '@mui/material/DialogActions';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport { IconButton } from '@mui/material';\n\nimport IconNoIcon from '../icons/IconNoIcon';\nimport withWidth from './withWidth';\nimport Utils from './Utils';\n\n// Icons\nimport { FaCopy as CopyIcon } from 'react-icons/fa';\nimport Brightness5Icon from '@mui/icons-material/Brightness6';\nimport CloseIcon from '@mui/icons-material/Close';\nimport SaveIcon from '@mui/icons-material/Save';\n\nconst styles = theme => ({\n dialog: {\n height: '100%',\n },\n paper: {\n height: 'calc(100% - 64px)',\n },\n content: {\n textAlign: 'center',\n },\n textarea: {\n width: '100%',\n height: '100%',\n },\n img: {\n width: 'auto',\n height: 'calc(100% - 5px)',\n objectFit: 'contain',\n },\n dialogTitle: {\n justifyContent: 'space-between',\n display: 'flex'\n }\n});\n\nexport const EXTENSIONS = {\n images: ['png', 'jpg', 'svg', 'jpeg', 'bmp'],\n code: ['js', 'json', 'md'],\n txt: ['log', 'txt', 'html', 'css', 'xml'],\n audio: ['mp3', 'wav', 'ogg', 'acc'],\n video: ['mp4', 'mov', 'avi'],\n};\n\nfunction bufferToBase64(buffer) {\n let binary = '';\n let bytes = new Uint8Array(buffer);\n let len = bytes.byteLength;\n for (let i = 0; i < len && i < 50; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return window.btoa(binary);\n}\n\n/**\n * @typedef {object} FileViewerProps\n * @property {import('../types').Translator} t Translation function\n * @property {ioBroker.Languages} [lang] The selected language.\n * @property {boolean} [expertMode] Is expert mode enabled? (default: false)\n * @property {() => void} onClose Callback when the viewer is closed.\n * @property {string} href The URL to the file to be displayed.\n *\n * @extends {React.Component<FileViewerProps>}\n */\nclass FileViewer extends Component {\n /**\n * @param {Readonly<FileViewerProps>} props\n */\n constructor(props) {\n super(props);\n const ext = Utils.getFileExtension(this.props.href);\n\n this.state = {\n text: null,\n code: null,\n ext,\n editing: !!this.props.formatEditFile || false,\n editingValue: null,\n copyPossible: EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext),\n forceUpdate: Date.now(),\n changed: false,\n imgError: false,\n };\n }\n\n readFile() {\n if (this.props.href) {\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n\n this.props.socket.readFile(adapter, name)\n .then(data => {\n if (data.file !== undefined) {\n data = data.file;\n }\n\n const newState = {copyPossible: this.state.copyPossible};\n // try to detect valid extension\n if (data.type === 'Buffer') {\n const ext = Utils.detectMimeType(bufferToBase64(data.data));\n if (ext) {\n newState.ext = ext;\n newState.copyPossible = EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext);\n }\n }\n\n if (newState.copyPossible) {\n if (EXTENSIONS.txt.includes(this.state.ext)) {\n newState.text = data;\n newState.editingValue = data;\n } else if (EXTENSIONS.code.includes(this.state.ext)) {\n newState.code = data;\n newState.editingValue = data;\n }\n }\n\n this.setState(newState);\n })\n .catch(e => window.alert('Cannot read file: ' + e));\n }\n }\n\n componentDidMount() {\n this.readFile();\n\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n\n this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);\n }\n\n componentWillUnmount() {\n this.timeout && clearTimeout(this.timeout);\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);\n }\n\n onFileChanged = (id, fileName, size) => {\n if (!this.state.changed) {\n this.timeout && clearTimeout(this.timeout);\n this.timeout = setTimeout(() => {\n this.timeout = null;\n if (size === null) {\n window.alert('Show file was deleted!');\n } else if (this.state.text !== null || this.state.code !== null) {\n this.readFile();\n } else {\n this.setState({ forceUpdate: Date.now() });\n }\n }, 300);\n }\n };\n\n writeFile64 = () => {\n const parts = this.props.href.split('/');\n const data = this.state.editingValue;\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n this.props.socket.writeFile64(adapter, name, Buffer.from(data).toString('base64'))\n .then(_ => this.props.onClose())\n .catch(e => window.alert('Cannot write file: ' + e));\n }\n\n getEditFile(ext) {\n switch (ext) {\n case 'json':\n return 'json';\n case 'js':\n return 'javascript';\n case 'html':\n return 'html';\n case 'txt':\n return 'html';\n default:\n return 'json';\n }\n }\n\n getContent() {\n if (EXTENSIONS.images.includes(this.state.ext)) {\n if (this.state.imgError) {\n return <IconNoIcon className={Utils.clsx(this.props.classes.img, this.props.getClassBackgroundImage())} />;\n } else {\n return <img\n onError={e => {\n e.target.onerror = null;\n this.setState({ imgError: true });\n }}\n className={Utils.clsx(this.props.classes.img, this.props.getClassBackgroundImage())}\n src={this.props.href + '?ts=' + this.state.forceUpdate}\n alt={this.props.href}\n />;\n }\n } else if (this.state.code !== null || this.state.text !== null || this.state.editing) {\n return <TextField\n variant=\"standard\"\n className={ this.props.classes.textarea }\n multiline\n value={ this.state.editingValue || this.state.code || this.state.text }\n onChange={newValue => this.setState({ editingValue: newValue, changed: true })}\n InputProps={{ readOnly: !this.state.editing,}}\n />;\n }\n }\n\n render() {\n return <Dialog\n classes={{ scrollPaper: this.props.classes.dialog, paper: this.props.classes.paper }}\n scroll=\"paper\"\n open={!!this.props.href}\n onClose={() => this.props.onClose()}\n fullWidth={true}\n maxWidth=\"xl\"\n aria-labelledby=\"form-dialog-title\"\n >\n <div className={this.props.classes.dialogTitle}>\n <DialogTitle id=\"form-dialog-title\">{this.props.t(this.state.editing ? 'Edit' : 'View') + ': ' + this.props.href}</DialogTitle>\n {EXTENSIONS.images.includes(this.state.ext) && <div>\n <IconButton size=\"large\"\n color={'inherit'}\n onClick={this.props.setStateBackgroundImage}\n >\n <Brightness5Icon />\n </IconButton>\n </div>\n }\n </div>\n <DialogContent className={this.props.classes.content}>\n {this.getContent()}\n </DialogContent>\n <DialogActions>\n {this.state.copyPossible ?\n <Button\n color=\"grey\"\n onClick={e => Utils.copyToClipboard(this.state.text || this.state.code, e)}\n startIcon={<CopyIcon />}\n >\n {this.props.t('Copy content')}\n </Button> : null}\n {this.state.editing ?\n <Button\n color=\"grey\"\n disabled={this.state.editingValue === this.state.code || this.state.editingValue === this.state.text}\n variant=\"contained\"\n onClick={this.writeFile64}\n startIcon={<SaveIcon />}\n >\n {this.props.t('Save')}\n </Button> : null}\n <Button\n variant=\"contained\"\n onClick={() => this.props.onClose()}\n color=\"primary\"\n startIcon={<CloseIcon />}\n >\n {this.props.t('Close')}\n </Button>\n </DialogActions>\n </Dialog>;\n }\n}\n\nFileViewer.propTypes = {\n t: PropTypes.func,\n lang: PropTypes.string,\n expertMode: PropTypes.bool,\n onClose: PropTypes.func,\n href: PropTypes.string.isRequired,\n supportSubscribes: PropTypes.bool,\n};\n\n/** @type {typeof FileViewer} */\nconst _export = withWidth()(withStyles(styles)(FileViewer));\nexport default _export;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,MAAM,EAAE;MACJC,MAAM,EAAE;IADJ,CADa;IAIrBC,KAAK,EAAE;MACHD,MAAM,EAAE;IADL,CAJc;IAOrBE,OAAO,EAAE;MACLC,SAAS,EAAE;IADN,CAPY;IAUrBC,QAAQ,EAAE;MACNC,KAAK,EAAE,MADD;MAENL,MAAM,EAAE;IAFF,CAVW;IAcrBM,GAAG,EAAE;MACDD,KAAK,EAAE,MADN;MAEDL,MAAM,EAAE,kBAFP;MAGDO,SAAS,EAAE;IAHV,CAdgB;IAmBrBC,WAAW,EAAE;MACTC,cAAc,EAAE,eADP;MAETC,OAAO,EAAE;IAFA;EAnBQ,CAAL;AAAA,CAApB;;AAyBO,IAAMC,UAAU,GAAG;EACtBC,MAAM,EAAE,CAAC,KAAD,EAAQ,KAAR,EAAe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,KAAL,CAAWiC,OAAX,gBACG,gCAAC,kBAAD;QACI,KAAK,EAAC,MADV;QAEI,QAAQ,EAAE,KAAKjC,KAAL,CAAWgB,YAAX,KAA4B,KAAKhB,KAAL,CAAWrB,IAAvC,IAA+C,KAAKqB,KAAL,CAAWgB,YAAX,KAA4B,KAAKhB,KAAL,CAAWM,IAFpG;QAGI,OAAO,EAAC,WAHZ;QAII,OAAO,EAAE,KAAKgB,WAJlB;QAKI,SAAS,eAAE,gCAAC,gBAAD;MALf,GAOK,KAAK1B,KAAL,CAAW0D,CAAX,CAAa,MAAb,CAPL,CADH,GASe,IAlBpB,eAmBI,gCAAC,kBAAD;QACI,OAAO,EAAC,WADZ;QAEI,OAAO,EAAE;UAAA,OAAM,MAAI,CAAC1D,KAAL,CAAWgC,OAAX,EAAN;QAAA,CAFb;QAGI,KAAK,EAAC,SAHV;QAII,SAAS,eAAE,gCAAC,iBAAD;MAJf,GAMK,KAAKhC,KAAL,CAAW0D,CAAX,CAAa,OAAb,CANL,CAnBJ,CAxBG,CAAP;IAqDH;;;EA3MoBI,gB;;AA8MzB/D,UAAU,CAACgE,SAAX,GAAuB;EACnBL,CAAC,EAAEM,qBAAA,CAAUC,IADM;EAEnBC,IAAI,EAAEF,qBAAA,CAAUG,MAFG;EAGnBC,UAAU,EAAEJ,qBAAA,CAAUK,IAHH;EAInBrC,OAAO,EAAEgC,qBAAA,CAAUC,IAJA;EAKnBhD,IAAI,EAAE+C,qBAAA,CAAUG,MAAV,CAAiBG,UALJ;EAMnBvB,iBAAiB,EAAEiB,qBAAA,CAAUK;AANV,CAAvB;AASA;;AACA,IAAME,OAAO,GAAG,IAAAC,qBAAA,IAAY,IAAAC,kBAAA,EAAW1G,MAAX,EAAmBgC,UAAnB,CAAZ,CAAhB;;eACewE,O"}
|
|
1
|
+
{"version":3,"file":"FileViewer.js","names":["styles","theme","dialog","height","paper","content","textAlign","textarea","width","img","objectFit","dialogTitle","justifyContent","display","EXTENSIONS","images","code","txt","audio","video","bufferToBase64","buffer","binary","bytes","Uint8Array","len","byteLength","i","String","fromCharCode","window","btoa","FileViewer","props","id","fileName","size","state","changed","timeout","clearTimeout","setTimeout","alert","text","readFile","setState","forceUpdate","Date","now","parts","href","split","data","editingValue","splice","adapter","name","join","socket","writeFile64","Buffer","from","toString","then","_","onClose","e","ext","Utils","getFileExtension","editing","formatEditFile","copyPossible","includes","imgError","file","undefined","newState","type","detectMimeType","supportSubscribes","subscribeFiles","onFileChanged","clsx","classes","getClassBackgroundImage","target","onerror","newValue","readOnly","scrollPaper","t","setStateBackgroundImage","getContent","copyToClipboard","Component","propTypes","PropTypes","func","lang","string","expertMode","bool","isRequired","_export","withWidth","withStyles"],"sources":["FileViewer.js"],"sourcesContent":["import React, { Component } from 'react';\nimport { withStyles } from '@mui/styles';\nimport PropTypes from 'prop-types';\n\nimport { Buffer } from 'buffer';\n\nimport TextField from '@mui/material/TextField';\nimport Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogActions from '@mui/material/DialogActions';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport { IconButton } from '@mui/material';\n\nimport IconNoIcon from '../icons/IconNoIcon';\nimport withWidth from './withWidth';\nimport Utils from './Utils';\n\n// Icons\nimport { FaCopy as CopyIcon } from 'react-icons/fa';\nimport Brightness5Icon from '@mui/icons-material/Brightness6';\nimport CloseIcon from '@mui/icons-material/Close';\nimport SaveIcon from '@mui/icons-material/Save';\n\nconst styles = theme => ({\n dialog: {\n height: '100%',\n },\n paper: {\n height: 'calc(100% - 64px)',\n },\n content: {\n textAlign: 'center',\n },\n textarea: {\n width: '100%',\n height: '100%',\n },\n img: {\n width: 'auto',\n height: 'calc(100% - 5px)',\n objectFit: 'contain',\n },\n dialogTitle: {\n justifyContent: 'space-between',\n display: 'flex'\n }\n});\n\nexport const EXTENSIONS = {\n images: ['png', 'jpg', 'svg', 'jpeg', 'bmp'],\n code: ['js', 'json', 'json5', 'md'],\n txt: ['log', 'txt', 'html', 'css', 'xml'],\n audio: ['mp3', 'wav', 'ogg', 'acc'],\n video: ['mp4', 'mov', 'avi'],\n};\n\nfunction bufferToBase64(buffer) {\n let binary = '';\n let bytes = new Uint8Array(buffer);\n let len = bytes.byteLength;\n for (let i = 0; i < len && i < 50; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return window.btoa(binary);\n}\n\n/**\n * @typedef {object} FileViewerProps\n * @property {import('../types').Translator} t Translation function\n * @property {ioBroker.Languages} [lang] The selected language.\n * @property {boolean} [expertMode] Is expert mode enabled? (default: false)\n * @property {() => void} onClose Callback when the viewer is closed.\n * @property {string} href The URL to the file to be displayed.\n *\n * @extends {React.Component<FileViewerProps>}\n */\nclass FileViewer extends Component {\n /**\n * @param {Readonly<FileViewerProps>} props\n */\n constructor(props) {\n super(props);\n const ext = Utils.getFileExtension(this.props.href);\n\n this.state = {\n text: null,\n code: null,\n ext,\n editing: !!this.props.formatEditFile || false,\n editingValue: null,\n copyPossible: EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext),\n forceUpdate: Date.now(),\n changed: false,\n imgError: false,\n };\n }\n\n readFile() {\n if (this.props.href) {\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n\n this.props.socket.readFile(adapter, name)\n .then(data => {\n if (data.file !== undefined) {\n data = data.file;\n }\n\n const newState = {copyPossible: this.state.copyPossible};\n // try to detect valid extension\n if (data.type === 'Buffer') {\n const ext = Utils.detectMimeType(bufferToBase64(data.data));\n if (ext) {\n newState.ext = ext;\n newState.copyPossible = EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext);\n }\n }\n\n if (newState.copyPossible) {\n if (EXTENSIONS.txt.includes(this.state.ext)) {\n newState.text = data;\n newState.editingValue = data;\n } else if (EXTENSIONS.code.includes(this.state.ext)) {\n newState.code = data;\n newState.editingValue = data;\n }\n }\n\n this.setState(newState);\n })\n .catch(e => window.alert('Cannot read file: ' + e));\n }\n }\n\n componentDidMount() {\n this.readFile();\n\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n\n this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);\n }\n\n componentWillUnmount() {\n this.timeout && clearTimeout(this.timeout);\n const parts = this.props.href.split('/');\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);\n }\n\n onFileChanged = (id, fileName, size) => {\n if (!this.state.changed) {\n this.timeout && clearTimeout(this.timeout);\n this.timeout = setTimeout(() => {\n this.timeout = null;\n if (size === null) {\n window.alert('Show file was deleted!');\n } else if (this.state.text !== null || this.state.code !== null) {\n this.readFile();\n } else {\n this.setState({ forceUpdate: Date.now() });\n }\n }, 300);\n }\n };\n\n writeFile64 = () => {\n const parts = this.props.href.split('/');\n const data = this.state.editingValue;\n parts.splice(0, 2);\n const adapter = parts[0];\n const name = parts.splice(1).join('/');\n this.props.socket.writeFile64(adapter, name, Buffer.from(data).toString('base64'))\n .then(_ => this.props.onClose())\n .catch(e => window.alert('Cannot write file: ' + e));\n }\n\n static getEditFile(ext) {\n switch (ext) {\n case 'json':\n return 'json';\n case 'json5':\n return 'json5';\n case 'js':\n return 'javascript';\n case 'html':\n return 'html';\n case 'txt':\n return 'html';\n default:\n return 'json';\n }\n }\n\n getContent() {\n if (EXTENSIONS.images.includes(this.state.ext)) {\n if (this.state.imgError) {\n return <IconNoIcon className={Utils.clsx(this.props.classes.img, this.props.getClassBackgroundImage())} />;\n } else {\n return <img\n onError={e => {\n e.target.onerror = null;\n this.setState({ imgError: true });\n }}\n className={Utils.clsx(this.props.classes.img, this.props.getClassBackgroundImage())}\n src={this.props.href + '?ts=' + this.state.forceUpdate}\n alt={this.props.href}\n />;\n }\n } else if (this.state.code !== null || this.state.text !== null || this.state.editing) {\n return <TextField\n variant=\"standard\"\n className={ this.props.classes.textarea }\n multiline\n value={ this.state.editingValue || this.state.code || this.state.text }\n onChange={newValue => this.setState({ editingValue: newValue, changed: true })}\n InputProps={{ readOnly: !this.state.editing }}\n />;\n }\n }\n\n render() {\n return <Dialog\n classes={{ scrollPaper: this.props.classes.dialog, paper: this.props.classes.paper }}\n scroll=\"paper\"\n open={!!this.props.href}\n onClose={() => this.props.onClose()}\n fullWidth={true}\n maxWidth=\"xl\"\n aria-labelledby=\"form-dialog-title\"\n >\n <div className={this.props.classes.dialogTitle}>\n <DialogTitle id=\"form-dialog-title\">{this.props.t(this.state.editing ? 'Edit' : 'View') + ': ' + this.props.href}</DialogTitle>\n {EXTENSIONS.images.includes(this.state.ext) && <div>\n <IconButton size=\"large\"\n color={'inherit'}\n onClick={this.props.setStateBackgroundImage}\n >\n <Brightness5Icon />\n </IconButton>\n </div>\n }\n </div>\n <DialogContent className={this.props.classes.content}>\n {this.getContent()}\n </DialogContent>\n <DialogActions>\n {this.state.copyPossible ?\n <Button\n color=\"grey\"\n onClick={e => Utils.copyToClipboard(this.state.text || this.state.code, e)}\n startIcon={<CopyIcon />}\n >\n {this.props.t('Copy content')}\n </Button> : null}\n {this.state.editing ?\n <Button\n color=\"grey\"\n disabled={this.state.editingValue === this.state.code || this.state.editingValue === this.state.text}\n variant=\"contained\"\n onClick={this.writeFile64}\n startIcon={<SaveIcon />}\n >\n {this.props.t('Save')}\n </Button> : null}\n <Button\n variant=\"contained\"\n onClick={() => this.props.onClose()}\n color=\"primary\"\n startIcon={<CloseIcon />}\n >\n {this.props.t('Close')}\n </Button>\n </DialogActions>\n </Dialog>;\n }\n}\n\nFileViewer.propTypes = {\n t: PropTypes.func,\n lang: PropTypes.string,\n expertMode: PropTypes.bool,\n onClose: PropTypes.func,\n href: PropTypes.string.isRequired,\n supportSubscribes: PropTypes.bool,\n};\n\n/** @type {typeof FileViewer} */\nconst _export = withWidth()(withStyles(styles)(FileViewer));\nexport default _export;\n"],"mappings":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I,OAAO,MAAP;;QACJ,KAAK,OAAL;UACI,OAAO,OAAP;;QACJ,KAAK,IAAL;UACI,OAAO,YAAP;;QACJ,KAAK,MAAL;UACI,OAAO,MAAP;;QACJ,KAAK,KAAL;UACI,OAAO,MAAP;;QACJ;UACI,OAAO,MAAP;MAZR;IAcH;;;EA1HoB4B,gB;;AAgNzB/D,UAAU,CAACgE,SAAX,GAAuB;EACnBL,CAAC,EAAEM,qBAAA,CAAUC,IADM;EAEnBC,IAAI,EAAEF,qBAAA,CAAUG,MAFG;EAGnBC,UAAU,EAAEJ,qBAAA,CAAUK,IAHH;EAInBrC,OAAO,EAAEgC,qBAAA,CAAUC,IAJA;EAKnBhD,IAAI,EAAE+C,qBAAA,CAAUG,MAAV,CAAiBG,UALJ;EAMnBvB,iBAAiB,EAAEiB,qBAAA,CAAUK;AANV,CAAvB;AASA;;AACA,IAAME,OAAO,GAAG,IAAAC,qBAAA,IAAY,IAAAC,kBAAA,EAAW1G,MAAX,EAAmBgC,UAAnB,CAAZ,CAAhB;;eACewE,O"}
|
|
@@ -7,8 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
10
12
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
13
|
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
|
|
16
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
+
|
|
12
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
19
|
|
|
14
20
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -47,6 +53,10 @@ var _Error2 = _interopRequireDefault(require("@mui/icons-material/Error"));
|
|
|
47
53
|
|
|
48
54
|
var _Info = _interopRequireDefault(require("@mui/icons-material/Info"));
|
|
49
55
|
|
|
56
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
57
|
+
|
|
58
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
59
|
+
|
|
50
60
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
51
61
|
|
|
52
62
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
@@ -64,6 +74,82 @@ var styles = function styles(theme) {
|
|
|
64
74
|
};
|
|
65
75
|
};
|
|
66
76
|
|
|
77
|
+
function ip2int(ip) {
|
|
78
|
+
return ip.split('.').reduce(function (ipInt, octet) {
|
|
79
|
+
return (ipInt << 8) + parseInt(octet, 10);
|
|
80
|
+
}, 0) >>> 0;
|
|
81
|
+
} // copied from iobroker.admin/src-rx/src/Utils.js
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
function findNetworkAddressOfHost(obj, localIp) {
|
|
85
|
+
var _obj$native, _obj$native$hardware;
|
|
86
|
+
|
|
87
|
+
var networkInterfaces = obj === null || obj === void 0 ? void 0 : (_obj$native = obj["native"]) === null || _obj$native === void 0 ? void 0 : (_obj$native$hardware = _obj$native.hardware) === null || _obj$native$hardware === void 0 ? void 0 : _obj$native$hardware.networkInterfaces;
|
|
88
|
+
|
|
89
|
+
if (!networkInterfaces) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
var hostIp;
|
|
94
|
+
Object.keys(networkInterfaces).forEach(function (inter) {
|
|
95
|
+
return networkInterfaces[inter].forEach(function (ip) {
|
|
96
|
+
if (ip.internal) {
|
|
97
|
+
return;
|
|
98
|
+
} else if (localIp.includes(':') && ip.family !== 'IPv6') {
|
|
99
|
+
return;
|
|
100
|
+
} else if (localIp.includes('.') && !localIp.match(/[^.\d]/) && ip.family !== 'IPv4') {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\d]/)) {
|
|
105
|
+
// if DNS name
|
|
106
|
+
hostIp = ip.address;
|
|
107
|
+
} else {
|
|
108
|
+
if (ip.family === 'IPv4' && localIp.includes('.') && (ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))) {
|
|
109
|
+
hostIp = ip.address;
|
|
110
|
+
} else {
|
|
111
|
+
hostIp = ip.address;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
if (!hostIp) {
|
|
118
|
+
Object.keys(networkInterfaces).forEach(function (inter) {
|
|
119
|
+
networkInterfaces[inter].forEach(function (ip) {
|
|
120
|
+
if (ip.internal) {
|
|
121
|
+
return;
|
|
122
|
+
} else if (localIp.includes(':') && ip.family !== 'IPv6') {
|
|
123
|
+
return;
|
|
124
|
+
} else if (localIp.includes('.') && !localIp.match(/[^.\d]/) && ip.family !== 'IPv4') {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\d]/)) {
|
|
129
|
+
// if DNS name
|
|
130
|
+
hostIp = ip.address;
|
|
131
|
+
} else {
|
|
132
|
+
hostIp = ip.address;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!hostIp) {
|
|
139
|
+
Object.keys(networkInterfaces).forEach(function (inter) {
|
|
140
|
+
networkInterfaces[inter].forEach(function (ip) {
|
|
141
|
+
if (ip.internal) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
hostIp = ip.address;
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return hostIp;
|
|
151
|
+
}
|
|
152
|
+
|
|
67
153
|
var ConfigSendto = /*#__PURE__*/function (_ConfigGeneric) {
|
|
68
154
|
(0, _inherits2["default"])(ConfigSendto, _ConfigGeneric);
|
|
69
155
|
|
|
@@ -76,13 +162,72 @@ var ConfigSendto = /*#__PURE__*/function (_ConfigGeneric) {
|
|
|
76
162
|
|
|
77
163
|
(0, _createClass2["default"])(ConfigSendto, [{
|
|
78
164
|
key: "componentDidMount",
|
|
79
|
-
value: function
|
|
80
|
-
(0,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
165
|
+
value: function () {
|
|
166
|
+
var _componentDidMount = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
167
|
+
var hostname, adminInstance, instanceObj, hostObj, ip;
|
|
168
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
169
|
+
while (1) {
|
|
170
|
+
switch (_context.prev = _context.next) {
|
|
171
|
+
case 0:
|
|
172
|
+
(0, _get2["default"])((0, _getPrototypeOf2["default"])(ConfigSendto.prototype), "componentDidMount", this).call(this);
|
|
173
|
+
hostname = window.location.hostname;
|
|
174
|
+
|
|
175
|
+
if (!this.props.schema.openUrl) {
|
|
176
|
+
_context.next = 19;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
_context.next = 5;
|
|
181
|
+
return this.props.socket.getCurrentInstance();
|
|
182
|
+
|
|
183
|
+
case 5:
|
|
184
|
+
adminInstance = _context.sent;
|
|
185
|
+
_context.next = 8;
|
|
186
|
+
return this.props.socket.getObject("system.adapter.".concat(adminInstance));
|
|
187
|
+
|
|
188
|
+
case 8:
|
|
189
|
+
instanceObj = _context.sent;
|
|
190
|
+
_context.next = 11;
|
|
191
|
+
return this.props.socket.getObject("system.host.".concat(instanceObj.common.host));
|
|
192
|
+
|
|
193
|
+
case 11:
|
|
194
|
+
hostObj = _context.sent;
|
|
195
|
+
ip = findNetworkAddressOfHost(hostObj, window.location.hostname);
|
|
196
|
+
|
|
197
|
+
if (!ip) {
|
|
198
|
+
_context.next = 17;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
hostname = ip + ':' + window.location.port;
|
|
203
|
+
_context.next = 19;
|
|
204
|
+
break;
|
|
205
|
+
|
|
206
|
+
case 17:
|
|
207
|
+
console.warn("Cannot find suitable IP in host ".concat(instanceObj.common.host, " for ").concat(instanceObj._id));
|
|
208
|
+
return _context.abrupt("return", null);
|
|
209
|
+
|
|
210
|
+
case 19:
|
|
211
|
+
this.setState({
|
|
212
|
+
_error: '',
|
|
213
|
+
_message: '',
|
|
214
|
+
hostname: hostname
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
case 20:
|
|
218
|
+
case "end":
|
|
219
|
+
return _context.stop();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}, _callee, this);
|
|
223
|
+
}));
|
|
224
|
+
|
|
225
|
+
function componentDidMount() {
|
|
226
|
+
return _componentDidMount.apply(this, arguments);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return componentDidMount;
|
|
230
|
+
}()
|
|
86
231
|
}, {
|
|
87
232
|
key: "renderErrorDialog",
|
|
88
233
|
value: function renderErrorDialog() {
|
|
@@ -127,10 +272,15 @@ var ConfigSendto = /*#__PURE__*/function (_ConfigGeneric) {
|
|
|
127
272
|
var _this3 = this;
|
|
128
273
|
|
|
129
274
|
this.props.onCommandRunning(true);
|
|
275
|
+
|
|
276
|
+
var _origin = "".concat(window.location.protocol, "//").concat(this.state.hostname).concat(window.location.pathname.replace(/\/index\.html$/, ''));
|
|
277
|
+
|
|
130
278
|
var data = this.props.schema.data;
|
|
131
279
|
|
|
132
280
|
if (data === undefined && this.props.schema.jsonData) {
|
|
133
|
-
data = this.getPattern(this.props.schema.jsonData, {},
|
|
281
|
+
data = this.getPattern(this.props.schema.jsonData, {}, _objectSpread({
|
|
282
|
+
_origin: _origin
|
|
283
|
+
}, this.props.data));
|
|
134
284
|
|
|
135
285
|
try {
|
|
136
286
|
data = JSON.parse(data);
|
|
@@ -143,6 +293,12 @@ var ConfigSendto = /*#__PURE__*/function (_ConfigGeneric) {
|
|
|
143
293
|
data = null;
|
|
144
294
|
}
|
|
145
295
|
|
|
296
|
+
if (this.props.schema.openUrl && !data) {
|
|
297
|
+
data = {
|
|
298
|
+
_origin: "".concat(window.location.protocol, "//").concat(this.state.hostname).concat(window.location.pathname.replace(/\/index\.html$/, ''))
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
146
302
|
this.props.socket.sendTo("".concat(this.props.adapterName, ".").concat(this.props.instance), this.props.schema.command || 'send', data).then(function (response) {
|
|
147
303
|
if (response !== null && response !== void 0 && response.error) {
|
|
148
304
|
if (_this3.props.schema.error && _this3.props.schema.error[response.error]) {
|
|
@@ -163,7 +319,9 @@ var ConfigSendto = /*#__PURE__*/function (_ConfigGeneric) {
|
|
|
163
319
|
});
|
|
164
320
|
}
|
|
165
321
|
} else {
|
|
166
|
-
if (response !== null && response !== void 0 && response.
|
|
322
|
+
if (response !== null && response !== void 0 && response.openUrl && _this3.props.schema.openUrl) {
|
|
323
|
+
window.open(response.openUrl, response.window || _this3.props.schema.window || '_blank');
|
|
324
|
+
} else if (response !== null && response !== void 0 && response.result && _this3.props.schema.result && _this3.props.schema.result[response.result]) {
|
|
167
325
|
var text = _this3.getText(_this3.props.schema.result[response.result]);
|
|
168
326
|
|
|
169
327
|
if (response.args) {
|
|
@@ -180,6 +338,10 @@ var ConfigSendto = /*#__PURE__*/function (_ConfigGeneric) {
|
|
|
180
338
|
window.alert(_i18n["default"].t('ra_Ok'));
|
|
181
339
|
}
|
|
182
340
|
}
|
|
341
|
+
|
|
342
|
+
if (response !== null && response !== void 0 && response.saveConfig) {
|
|
343
|
+
_this3.props.onChange(null, null, null, true);
|
|
344
|
+
}
|
|
183
345
|
}
|
|
184
346
|
})["catch"](function (e) {
|
|
185
347
|
if (_this3.props.schema.error && _this3.props.schema.error[e.toString()]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigSendto.js","names":["styles","theme","fullWidth","width","icon","height","marginRight","ConfigSendto","setState","_error","_message","state","undefined","props","onCommandRunning","data","schema","jsonData","getPattern","JSON","parse","e","console","error","socket","sendTo","adapterName","instance","command","then","response","getText","args","forEach","arg","replace","I18n","t","result","text","window","alert","stringify","toString","confirmDialog","confirm","confirmData","type","title","ok","cancel","isOk","_onClick","disabled","defaultValue","classes","variant","color","label","noTranslation","renderErrorDialog","renderMessageDialog","ConfigGeneric","propTypes","PropTypes","object","isRequired","themeType","string","themeName","style","className","onError","func","onChange","number","commandRunning","bool","withStyles"],"sources":["JsonConfigComponent/ConfigSendto.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@mui/styles';\n\nimport Button from '@mui/material/Button';\n\nimport I18n from '../../i18n';\nimport Icon from '../Icon';\nimport DialogError from '../../Dialogs/Error';\nimport DialogMessage from '../../Dialogs/Message';\nimport ConfirmDialog from '../../Dialogs/Confirm';\n\nimport ConfigGeneric from './ConfigGeneric';\nimport IconWarning from '@mui/icons-material/Warning';\nimport IconError from '@mui/icons-material/Error';\nimport IconInfo from '@mui/icons-material/Info';\n\nconst styles = theme => ({\n fullWidth: {\n width: '100%'\n },\n icon: {\n width: 24,\n height: 24,\n marginRight: 4\n }\n});\n\nclass ConfigSendto extends ConfigGeneric {\n componentDidMount() {\n super.componentDidMount();\n\n this.setState( {_error: '', _message: ''});\n }\n\n renderErrorDialog() {\n if (this.state._error) {\n return <DialogError text={this.state._error} classes={undefined} onClose={() => this.setState({_error: ''})} />;\n } else {\n return null;\n }\n }\n\n renderMessageDialog() {\n if (this.state._message) {\n return <DialogMessage text={this.state._message} classes={undefined} onClose={() => this.setState({_error: ''})} />;\n } else {\n return null;\n }\n }\n\n _onClick() {\n this.props.onCommandRunning(true);\n\n let data = this.props.schema.data;\n if (data === undefined && this.props.schema.jsonData) {\n data = this.getPattern(this.props.schema.jsonData, {}, this.props.data);\n try {\n data = JSON.parse(data);\n } catch (e) {\n console.error('Cannot parse json data: ' + data);\n }\n }\n if (data === undefined) {\n data = null;\n }\n\n this.props.socket.sendTo(\n `${this.props.adapterName}.${this.props.instance}`,\n this.props.schema.command || 'send',\n data\n )\n .then(response => {\n if (response?.error) {\n if (this.props.schema.error && this.props.schema.error[response.error]) {\n let error = this.getText(this.props.schema.error[response.error]);\n if (response.args) {\n response.args.forEach(arg => error = error.replace('%s', arg));\n }\n this.setState({_error: error});\n } else {\n this.setState({_error: response.error ? I18n.t(response.error) : I18n.t('ra_Error')});\n }\n } else {\n if (response?.result && this.props.schema.result && this.props.schema.result[response.result]) {\n let text = this.getText(this.props.schema.result[response.result]);\n if (response.args) {\n response.args.forEach(arg => text = text.replace('%s', arg));\n }\n window.alert(text);\n } else {\n if (response?.result) {\n window.alert(typeof response.result === 'object' ? JSON.stringify(response.result) : response.result);\n } else {\n window.alert(I18n.t('ra_Ok'));\n }\n }\n }\n })\n .catch(e => {\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(() => this.props.onCommandRunning(false))\n }\n\n renderConfirmDialog() {\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 <ConfirmDialog\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 =>\n this.setState({ confirmDialog: false}, () =>\n isOk && this._onClick())\n }\n />;\n }\n\n renderItem(error, disabled, defaultValue) {\n return <div className={this.props.classes.fullWidth}>\n <Button\n variant={this.props.schema.variant || undefined}\n color={this.props.schema.color || 'grey'}\n className={this.props.classes.fullWidth}\n disabled={disabled}\n onClick={() => {\n if (this.props.schema.confirm) {\n this.setState({confirmDialog: true});\n } else {\n this._onClick();\n }\n }}\n >\n {this.props.schema.icon ? <Icon src={this.props.schema.icon} className={this.props.classes.icon}/> : null}\n {this.getText(this.props.schema.label, this.props.schema.noTranslation)}\n </Button>\n {this.renderErrorDialog()}\n {this.renderMessageDialog()}\n </div>;\n }\n}\n\nConfigSendto.propTypes = {\n socket: PropTypes.object.isRequired,\n themeType: PropTypes.string,\n themeName: PropTypes.string,\n style: PropTypes.object,\n className: PropTypes.string,\n data: PropTypes.object.isRequired,\n schema: PropTypes.object,\n onError: PropTypes.func,\n onChange: PropTypes.func,\n adapterName: PropTypes.string,\n instance: PropTypes.number,\n commandRunning: PropTypes.bool,\n onCommandRunning: PropTypes.func,\n};\n\nexport default withStyles(styles)(ConfigSendto);"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,SAAS,EAAE;MACPC,KAAK,EAAE;IADA,CADU;IAIrBC,IAAI,EAAE;MACFD,KAAK,EAAE,EADL;MAEFE,MAAM,EAAE,EAFN;MAGFC,WAAW,EAAE;IAHX;EAJe,CAAL;AAAA,CAApB;;IAWMC,Y;;;;;;;;;;;;WACF,6BAAoB;MAChB;MAEA,KAAKC,QAAL,CAAe;QAACC,MAAM,EAAE,EAAT;QAAaC,QAAQ,EAAE;MAAvB,CAAf;IACH;;;WAED,6BAAoB;MAAA;;MAChB,IAAI,KAAKC,KAAL,CAAWF,MAAf,EAAuB;QACnB,oBAAO,gCAAC,iBAAD;UAAa,IAAI,EAAE,KAAKE,KAAL,CAAWF,MAA9B;UAAsC,OAAO,EAAEG,SAA/C;UAA0D,OAAO,EAAE;YAAA,OAAM,KAAI,CAACJ,QAAL,CAAc;cAACC,MAAM,EAAE;YAAT,CAAd,CAAN;UAAA;QAAnE,EAAP;MACH,CAFD,MAEO;QACH,OAAO,IAAP;MACH;IACJ;;;WAED,+BAAsB;MAAA;;MAClB,IAAI,KAAKE,KAAL,CAAWD,QAAf,EAAyB;QACrB,oBAAO,gCAAC,mBAAD;UAAe,IAAI,EAAE,KAAKC,KAAL,CAAWD,QAAhC;UAA0C,OAAO,EAAEE,SAAnD;UAA8D,OAAO,EAAE;YAAA,OAAM,MAAI,CAACJ,QAAL,CAAc;cAACC,MAAM,EAAE;YAAT,CAAd,CAAN;UAAA;QAAvE,EAAP;MACH,CAFD,MAEO;QACH,OAAO,IAA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IAZL;EAarB/D,gBAAgB,EAAEkD,qBAAA,CAAUS;AAbP,CAAzB;;eAgBe,IAAAK,kBAAA,EAAW9E,MAAX,EAAmBO,YAAnB,C"}
|
|
1
|
+
{"version":3,"file":"ConfigSendto.js","names":["styles","theme","fullWidth","width","icon","height","marginRight","ip2int","ip","split","reduce","ipInt","octet","parseInt","findNetworkAddressOfHost","obj","localIp","networkInterfaces","hardware","hostIp","Object","keys","forEach","inter","internal","includes","family","match","address","netmask","ConfigSendto","hostname","window","location","props","schema","openUrl","socket","getCurrentInstance","adminInstance","getObject","instanceObj","common","host","hostObj","port","console","warn","_id","setState","_error","_message","state","undefined","onCommandRunning","_origin","protocol","pathname","replace","data","jsonData","getPattern","JSON","parse","e","error","sendTo","adapterName","instance","command","then","response","getText","args","arg","I18n","t","open","result","text","alert","stringify","saveConfig","onChange","toString","confirmDialog","confirm","confirmData","type","title","ok","cancel","isOk","_onClick","disabled","defaultValue","classes","variant","color","label","noTranslation","renderErrorDialog","renderMessageDialog","ConfigGeneric","propTypes","PropTypes","object","isRequired","themeType","string","themeName","style","className","onError","func","number","commandRunning","bool","withStyles"],"sources":["JsonConfigComponent/ConfigSendto.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@mui/styles';\n\nimport Button from '@mui/material/Button';\n\nimport I18n from '../../i18n';\nimport Icon from '../Icon';\nimport DialogError from '../../Dialogs/Error';\nimport DialogMessage from '../../Dialogs/Message';\nimport ConfirmDialog from '../../Dialogs/Confirm';\n\nimport ConfigGeneric from './ConfigGeneric';\nimport IconWarning from '@mui/icons-material/Warning';\nimport IconError from '@mui/icons-material/Error';\nimport IconInfo from '@mui/icons-material/Info';\n\nconst styles = theme => ({\n fullWidth: {\n width: '100%'\n },\n icon: {\n width: 24,\n height: 24,\n marginRight: 4\n }\n});\n\nfunction ip2int(ip) {\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, localIp) {\n const networkInterfaces = obj?.native?.hardware?.networkInterfaces;\n if (!networkInterfaces) {\n return null;\n }\n\n let hostIp;\n Object.keys(networkInterfaces).forEach(inter =>\n networkInterfaces[inter].forEach(ip => {\n if (ip.internal) {\n return;\n } else if (localIp.includes(':') && ip.family !== 'IPv6') {\n return;\n } else if (localIp.includes('.') && !localIp.match(/[^.\\d]/) && ip.family !== 'IPv4') {\n return;\n }\n if (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\\d]/)) { // if DNS name\n hostIp = ip.address;\n } else {\n if (ip.family === 'IPv4' && localIp.includes('.') &&\n (ip2int(localIp) & ip2int(ip.netmask)) === (ip2int(ip.address) & ip2int(ip.netmask))) {\n hostIp = ip.address;\n } else {\n hostIp = ip.address;\n }\n }\n }));\n\n if (!hostIp) {\n Object.keys(networkInterfaces).forEach(inter => {\n networkInterfaces[inter].forEach(ip => {\n if (ip.internal) {\n return;\n } else if (localIp.includes(':') && ip.family !== 'IPv6') {\n return;\n } else if (localIp.includes('.') && !localIp.match(/[^.\\d]/) && ip.family !== 'IPv4') {\n return;\n }\n if (localIp === '127.0.0.0' || localIp === 'localhost' || localIp.match(/[^.\\d]/)) { // 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 => {\n if (ip.internal) {\n return;\n }\n hostIp = ip.address;\n });\n });\n }\n\n return hostIp;\n}\n\n\nclass ConfigSendto extends ConfigGeneric {\n async componentDidMount() {\n super.componentDidMount();\n\n let hostname = window.location.hostname;\n if (this.props.schema.openUrl) {\n // read admin host\n const adminInstance = await this.props.socket.getCurrentInstance();\n const instanceObj = await this.props.socket.getObject(`system.adapter.${adminInstance}`);\n const hostObj = await this.props.socket.getObject(`system.host.${instanceObj.common.host}`);\n\n const ip = findNetworkAddressOfHost(hostObj, window.location.hostname);\n if (ip) {\n hostname = ip + ':' + window.location.port;\n } else {\n console.warn(`Cannot find suitable IP in host ${instanceObj.common.host} for ${instanceObj._id}`);\n return null;\n }\n }\n this.setState( { _error: '', _message: '', hostname });\n }\n\n renderErrorDialog() {\n if (this.state._error) {\n return <DialogError text={this.state._error} classes={undefined} onClose={() => this.setState({_error: ''})} />;\n } else {\n return null;\n }\n }\n\n renderMessageDialog() {\n if (this.state._message) {\n return <DialogMessage text={this.state._message} classes={undefined} onClose={() => this.setState({_error: ''})} />;\n } else {\n return null;\n }\n }\n\n _onClick() {\n this.props.onCommandRunning(true);\n\n const _origin = `${window.location.protocol}//${this.state.hostname}${window.location.pathname.replace(/\\/index\\.html$/, '')}`\n\n let data = this.props.schema.data;\n if (data === undefined && this.props.schema.jsonData) {\n data = this.getPattern(this.props.schema.jsonData, {}, {\n _origin,\n ...this.props.data\n });\n try {\n data = JSON.parse(data);\n } catch (e) {\n console.error('Cannot parse json data: ' + data);\n }\n }\n if (data === undefined) {\n data = null;\n }\n if (this.props.schema.openUrl && !data) {\n data = { _origin: `${window.location.protocol}//${this.state.hostname}${window.location.pathname.replace(/\\/index\\.html$/, '')}` };\n }\n\n this.props.socket.sendTo(\n `${this.props.adapterName}.${this.props.instance}`,\n this.props.schema.command || 'send',\n data\n )\n .then(response => {\n if (response?.error) {\n if (this.props.schema.error && this.props.schema.error[response.error]) {\n let error = this.getText(this.props.schema.error[response.error]);\n if (response.args) {\n response.args.forEach(arg => error = error.replace('%s', arg));\n }\n this.setState({_error: error});\n } else {\n this.setState({_error: response.error ? I18n.t(response.error) : I18n.t('ra_Error')});\n }\n } else {\n if (response?.openUrl && this.props.schema.openUrl) {\n window.open(response.openUrl, response.window || this.props.schema.window || '_blank');\n } else\n if (response?.result && this.props.schema.result && this.props.schema.result[response.result]) {\n let text = this.getText(this.props.schema.result[response.result]);\n if (response.args) {\n response.args.forEach(arg => text = text.replace('%s', arg));\n }\n window.alert(text);\n } else {\n if (response?.result) {\n window.alert(typeof response.result === 'object' ? JSON.stringify(response.result) : response.result);\n } else {\n window.alert(I18n.t('ra_Ok'));\n }\n }\n\n if (response?.saveConfig) {\n this.props.onChange(null, null, null, true);\n }\n }\n })\n .catch(e => {\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(() => this.props.onCommandRunning(false))\n }\n\n renderConfirmDialog() {\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 <ConfirmDialog\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 =>\n this.setState({ confirmDialog: false}, () =>\n isOk && this._onClick())\n }\n />;\n }\n\n renderItem(error, disabled, defaultValue) {\n return <div className={this.props.classes.fullWidth}>\n <Button\n variant={this.props.schema.variant || undefined}\n color={this.props.schema.color || 'grey'}\n className={this.props.classes.fullWidth}\n disabled={disabled}\n onClick={() => {\n if (this.props.schema.confirm) {\n this.setState({confirmDialog: true});\n } else {\n this._onClick();\n }\n }}\n >\n {this.props.schema.icon ? <Icon src={this.props.schema.icon} className={this.props.classes.icon}/> : null}\n {this.getText(this.props.schema.label, this.props.schema.noTranslation)}\n </Button>\n {this.renderErrorDialog()}\n {this.renderMessageDialog()}\n </div>;\n }\n}\n\nConfigSendto.propTypes = {\n socket: PropTypes.object.isRequired,\n themeType: PropTypes.string,\n themeName: PropTypes.string,\n style: PropTypes.object,\n className: PropTypes.string,\n data: PropTypes.object.isRequired,\n schema: PropTypes.object,\n onError: PropTypes.func,\n onChange: PropTypes.func,\n adapterName: PropTypes.string,\n instance: PropTypes.number,\n commandRunning: PropTypes.bool,\n onCommandRunning: PropTypes.func,\n};\n\nexport default withStyles(styles)(ConfigSendto);"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,SAAS,EAAE;MACPC,KAAK,EAAE;IADA,CADU;IAIrBC,IAAI,EAAE;MACFD,KAAK,EAAE,EADL;MAEFE,MAAM,EAAE,EAFN;MAGFC,WAAW,EAAE;IAHX;EAJe,CAAL;AAAA,CAApB;;AAWA,SAASC,MAAT,CAAgBC,EAAhB,EAAoB;EAChB,OAAOA,EAAE,CAACC,KAAH,CAAS,GAAT,EAAcC,MAAd,CAAqB,UAACC,KAAD,EAAQC,KAAR;IAAA,OAAkB,CAACD,KAAK,IAAI,CAAV,IAAeE,QAAQ,CAACD,KAAD,EAAQ,EAAR,CAAzC;EAAA,CAArB,EAA2E,CAA3E,MAAkF,CAAzF;AACH,C,CAED;;;AACA,SAASE,wBAAT,CAAkCC,GAAlC,EAAuCC,OAAvC,EAAgD;EAAA;;EAC5C,IAAMC,iBAAiB,GAAGF,GAAH,aAAGA,GAAH,sCAAGA,GAAG,UAAN,wEAAG,YAAaG,QAAhB,yDAAG,qBAAuBD,iBAAjD;;EACA,IAAI,CAACA,iBAAL,EAAwB;IACpB,OAAO,IAAP;EACH;;EAED,IAAIE,MAAJ;EACAC,MAAM,CAACC,IAAP,CAAYJ,iBAAZ,EAA+BK,OAA/B,CAAuC,UAAAC,KAAK;IAAA,OACxCN,iBAAiB,CAACM,KAAD,CAAjB,CAAyBD,OAAzB,CAAiC,UAAAd,EAAE,EAAI;MACnC,IAAIA,EAAE,CA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B,YAAnB,C"}
|
|
@@ -65,7 +65,11 @@ var ConfigText = /*#__PURE__*/function (_ConfigGeneric) {
|
|
|
65
65
|
var value = _ConfigGeneric2["default"].getValue(this.props.data, this.props.attr);
|
|
66
66
|
|
|
67
67
|
this.setState({
|
|
68
|
-
value: value
|
|
68
|
+
value: value,
|
|
69
|
+
tempValue: {
|
|
70
|
+
value: value,
|
|
71
|
+
ts: Date.now()
|
|
72
|
+
}
|
|
69
73
|
});
|
|
70
74
|
}
|
|
71
75
|
}, {
|
|
@@ -75,6 +79,20 @@ var ConfigText = /*#__PURE__*/function (_ConfigGeneric) {
|
|
|
75
79
|
|
|
76
80
|
var isIndeterminate = Array.isArray(this.state.value) || this.state.value === _ConfigGeneric2["default"].DIFFERENT_VALUE;
|
|
77
81
|
|
|
82
|
+
if (this.state.tempValue.value !== this.state.value) {
|
|
83
|
+
this.updateTimeout && clearTimeout(this.updateTimeout);
|
|
84
|
+
this.updateTimeout = setTimeout(function () {
|
|
85
|
+
_this.updateTimeout = null;
|
|
86
|
+
|
|
87
|
+
_this.setState({
|
|
88
|
+
value: _this.state.tempValue.value
|
|
89
|
+
});
|
|
90
|
+
}, 30);
|
|
91
|
+
} else if (this.updateTimeout) {
|
|
92
|
+
clearTimeout(this.updateTimeout);
|
|
93
|
+
this.updateTimeout = null;
|
|
94
|
+
}
|
|
95
|
+
|
|
78
96
|
if (isIndeterminate) {
|
|
79
97
|
var arr = (0, _toConsumableArray2["default"])(this.state.value).map(function (item) {
|
|
80
98
|
return {
|
|
@@ -142,9 +160,12 @@ var ConfigText = /*#__PURE__*/function (_ConfigGeneric) {
|
|
|
142
160
|
value: function getDerivedStateFromProps(props, state) {
|
|
143
161
|
var value = _ConfigGeneric2["default"].getValue(props.data, props.attr);
|
|
144
162
|
|
|
145
|
-
if (value === null || value === undefined || value.toString().trim() !== (state.
|
|
163
|
+
if (value === null || value === undefined || value.toString().trim() !== (state.tempValue || '').toString().trim()) {
|
|
146
164
|
return {
|
|
147
|
-
|
|
165
|
+
tempValue: {
|
|
166
|
+
value: value,
|
|
167
|
+
ts: Date.now()
|
|
168
|
+
}
|
|
148
169
|
};
|
|
149
170
|
} else {
|
|
150
171
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigText.js","names":["styles","theme","indeterminate","opacity","ConfigText","value","ConfigGeneric","getValue","props","data","attr","setState","error","disabled","defaultValue","isIndeterminate","Array","isArray","state","DIFFERENT_VALUE","arr","map","item","label","toString","unshift","I18n","t","DIFFERENT_LABEL","classes","option","_","onChange","params","getText","schema","placeholder","renderHelp","help","helpLink","noTranslation","undefined","maxLength","max","e","target","trim","propTypes","socket","PropTypes","object","isRequired","themeType","string","themeName","style","className","onError","func","withStyles"],"sources":["JsonConfigComponent/ConfigText.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@mui/styles';\n\nimport { Autocomplete, TextField } from '@mui/material';\n\nimport I18n from '../../i18n';\n\nimport ConfigGeneric from './ConfigGeneric';\n\nconst styles = theme => ({\n indeterminate: {\n opacity: 0.5\n }\n});\n\nclass ConfigText extends ConfigGeneric {\n componentDidMount() {\n super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n this.setState({ value });\n }\n\n static getDerivedStateFromProps(props, state) {\n const value = ConfigGeneric.getValue(props.data, props.attr);\n if (value === null || value === undefined || value.toString().trim() !== (state.
|
|
1
|
+
{"version":3,"file":"ConfigText.js","names":["styles","theme","indeterminate","opacity","ConfigText","value","ConfigGeneric","getValue","props","data","attr","setState","tempValue","ts","Date","now","error","disabled","defaultValue","isIndeterminate","Array","isArray","state","DIFFERENT_VALUE","updateTimeout","clearTimeout","setTimeout","arr","map","item","label","toString","unshift","I18n","t","DIFFERENT_LABEL","classes","option","_","onChange","params","getText","schema","placeholder","renderHelp","help","helpLink","noTranslation","undefined","maxLength","max","e","target","trim","propTypes","socket","PropTypes","object","isRequired","themeType","string","themeName","style","className","onError","func","withStyles"],"sources":["JsonConfigComponent/ConfigText.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@mui/styles';\n\nimport { Autocomplete, TextField } from '@mui/material';\n\nimport I18n from '../../i18n';\n\nimport ConfigGeneric from './ConfigGeneric';\n\nconst styles = theme => ({\n indeterminate: {\n opacity: 0.5\n }\n});\n\nclass ConfigText extends ConfigGeneric {\n componentDidMount() {\n super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n this.setState({ value, tempValue: { value, ts: Date.now() } });\n }\n\n static getDerivedStateFromProps(props, state) {\n const value = ConfigGeneric.getValue(props.data, props.attr);\n if (value === null || value === undefined || value.toString().trim() !== (state.tempValue || '').toString().trim()) {\n return { tempValue: { value, ts: Date.now() } };\n } else {\n return null;\n }\n }\n\n renderItem(error, disabled, defaultValue) {\n let isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_VALUE;\n\n if (this.state.tempValue.value !== this.state.value) {\n this.updateTimeout && clearTimeout(this.updateTimeout);\n this.updateTimeout = setTimeout(() => {\n this.updateTimeout = null;\n this.setState({ value: this.state.tempValue.value });\n }, 30)\n } else if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n this.updateTimeout = null;\n }\n\n if (isIndeterminate) {\n const arr = [...this.state.value].map(item => ({label: item.toString(), value: item}));\n arr.unshift({label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE});\n\n return <Autocomplete\n className={this.props.classes.indeterminate}\n fullWidth\n value={arr[0]}\n getOptionSelected={(option, value) => option.label === value.label}\n onChange={(_, value) =>\n this.onChange(this.props.attr, value ? value.value : '')}\n options={arr}\n getOptionLabel={option => option.label}\n renderInput={params => <TextField\n variant=\"standard\"\n {...params}\n error={!!error}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}\n disabled={!!disabled}\n />}\n />;\n } else {\n return <TextField\n variant=\"standard\"\n fullWidth\n value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}\n error={!!error}\n disabled={!!disabled}\n inputProps={{maxLength: this.props.schema.maxLength || this.props.schema.max || undefined}}\n onChange={e => {\n const value = e.target.value;\n this.setState({value}, () =>\n this.onChange(this.props.attr, this.props.schema.trim === false ? value : (value || '').trim()));\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}\n />;\n }\n }\n}\n\nConfigText.propTypes = {\n socket: PropTypes.object.isRequired,\n themeType: PropTypes.string,\n themeName: PropTypes.string,\n style: PropTypes.object,\n className: PropTypes.string,\n data: PropTypes.object.isRequired,\n schema: PropTypes.object,\n onError: PropTypes.func,\n onChange: PropTypes.func,\n};\n\nexport default withStyles(styles)(ConfigText);"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;AAEA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,aAAa,EAAE;MACXC,OAAO,EAAE;IADE;EADM,CAAL;AAAA,CAApB;;IAMMC,U;;;;;;;;;;;;WACF,6BAAoB;MAChB;;MACA,IAAMC,KAAK,GAAGC,0BAAA,CAAcC,QAAd,CAAuB,KAAKC,KAAL,CAAWC,IAAlC,EAAwC,KAAKD,KAAL,CAAWE,IAAnD,CAAd;;MACA,KAAKC,QAAL,CAAc;QAAEN,KAAK,EAALA,KAAF;QAASO,SAAS,EAAE;UAAEP,KAAK,EAALA,KAAF;UAASQ,EAAE,EAAEC,IAAI,CAACC,GAAL;QAAb;MAApB,CAAd;IACH;;;WAWD,oBAAWC,KAAX,EAAkBC,QAAlB,EAA4BC,YAA5B,EAA0C;MAAA;;MACtC,IAAIC,eAAe,GAAGC,K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