@iobroker/adapter-react-v5 6.1.3 → 6.1.6

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.
Files changed (74) hide show
  1. package/README.md +6 -0
  2. package/craco-module-federation.js +1 -1
  3. package/package.json +1 -1
  4. package/src/AdminConnection.tsx +3 -0
  5. package/src/Components/404.tsx +121 -0
  6. package/src/Components/ColorPicker.tsx +315 -0
  7. package/src/Components/ComplexCron.tsx +507 -0
  8. package/src/Components/CopyToClipboard.tsx +165 -0
  9. package/src/Components/CustomModal.tsx +163 -0
  10. package/src/Components/FileBrowser.tsx +2394 -0
  11. package/src/Components/FileViewer.tsx +384 -0
  12. package/src/Components/Icon.tsx +210 -0
  13. package/src/Components/IconPicker.tsx +149 -0
  14. package/src/Components/IconSelector.tsx +2202 -0
  15. package/src/Components/Image.tsx +176 -0
  16. package/src/Components/Loader.tsx +304 -0
  17. package/src/Components/Logo.tsx +166 -0
  18. package/src/Components/MDUtils.tsx +100 -0
  19. package/src/Components/ObjectBrowser.tsx +7915 -0
  20. package/src/Components/Router.tsx +90 -0
  21. package/src/Components/SaveCloseButtons.tsx +113 -0
  22. package/src/Components/Schedule.tsx +1724 -0
  23. package/src/Components/SelectWithIcon.tsx +197 -0
  24. package/src/Components/TabContainer.tsx +55 -0
  25. package/src/Components/TabContent.tsx +37 -0
  26. package/src/Components/TabHeader.tsx +19 -0
  27. package/src/Components/TableResize.tsx +259 -0
  28. package/src/Components/TextWithIcon.tsx +148 -0
  29. package/src/Components/ToggleThemeMenu.tsx +34 -0
  30. package/src/Components/TreeTable.tsx +919 -0
  31. package/src/Components/UploadImage.tsx +599 -0
  32. package/src/Components/Utils.tsx +1794 -0
  33. package/src/Components/loader.css +222 -0
  34. package/src/Components/withWidth.tsx +21 -0
  35. package/src/Connection.tsx +7 -0
  36. package/src/Dialogs/ComplexCron.tsx +129 -0
  37. package/src/Dialogs/Confirm.tsx +162 -0
  38. package/src/Dialogs/Cron.tsx +182 -0
  39. package/src/Dialogs/Error.tsx +72 -0
  40. package/src/Dialogs/Message.tsx +71 -0
  41. package/src/Dialogs/SelectFile.tsx +270 -0
  42. package/src/Dialogs/SelectID.tsx +298 -0
  43. package/src/Dialogs/SimpleCron.tsx +100 -0
  44. package/src/Dialogs/TextInput.tsx +107 -0
  45. package/src/GenericApp.tsx +976 -0
  46. package/src/LegacyConnection.tsx +3589 -0
  47. package/src/Prompt.tsx +20 -0
  48. package/src/Theme.tsx +479 -0
  49. package/src/icons/IconAdapter.tsx +20 -0
  50. package/src/icons/IconAlias.tsx +20 -0
  51. package/src/icons/IconChannel.tsx +21 -0
  52. package/src/icons/IconClearFilter.tsx +22 -0
  53. package/src/icons/IconClosed.tsx +17 -0
  54. package/src/icons/IconCopy.tsx +16 -0
  55. package/src/icons/IconDevice.tsx +27 -0
  56. package/src/icons/IconDocument.tsx +17 -0
  57. package/src/icons/IconDocumentReadOnly.tsx +18 -0
  58. package/src/icons/IconExpert.tsx +18 -0
  59. package/src/icons/IconFx.tsx +36 -0
  60. package/src/icons/IconInstance.tsx +20 -0
  61. package/src/icons/IconLogout.tsx +30 -0
  62. package/src/icons/IconNoIcon.tsx +19 -0
  63. package/src/icons/IconOpen.tsx +17 -0
  64. package/src/icons/IconProps.tsx +15 -0
  65. package/src/icons/IconState.tsx +17 -0
  66. package/src/index.css +55 -0
  67. package/assets/devices/list.json +0 -994
  68. package/assets/devices/names.txt +0 -63
  69. package/assets/devices/parseNames.d.ts +0 -0
  70. package/assets/devices/parseNames.js +0 -34
  71. package/assets/rooms/list.json +0 -946
  72. package/assets/rooms/names.txt +0 -60
  73. package/assets/rooms/parseNames.d.ts +0 -0
  74. package/assets/rooms/parseNames.js +0 -34
@@ -0,0 +1,384 @@
1
+ // File viewer in adapter-react does not support write
2
+ // import { Buffer } from 'buffer';
3
+ import React, { Component } from 'react';
4
+
5
+ import {
6
+ TextField,
7
+ Button,
8
+ Dialog,
9
+ DialogActions,
10
+ DialogContent,
11
+ DialogTitle,
12
+ IconButton,
13
+ } from '@mui/material';
14
+
15
+ // Icons
16
+ import { FaCopy as CopyIcon } from 'react-icons/fa';
17
+ import {
18
+ Close as CloseIcon,
19
+ Save as SaveIcon,
20
+ Brightness6 as Brightness5Icon,
21
+ } from '@mui/icons-material';
22
+
23
+ import type { Connection } from '@iobroker/socket-client';
24
+
25
+ import IconNoIcon from '../icons/IconNoIcon';
26
+ import withWidth from './withWidth';
27
+ import Utils from './Utils';
28
+ import { Translate } from '../types';
29
+ import Icon from './Icon';
30
+ // File viewer in adapter-react does not use ace editor
31
+ // import * as ace from 'ace-builds';
32
+ // import 'ace-builds/src-noconflict/ext-modelist';
33
+ // import Editor from './Editor';
34
+
35
+ // const modelist = ace.require('ace/ext/modelist');
36
+
37
+ const styles: Record<string, React.CSSProperties> = {
38
+ dialog: {
39
+ height: '100%',
40
+ },
41
+ paper: {
42
+ height: 'calc(100% - 64px)',
43
+ },
44
+ content: {
45
+ textAlign: 'center',
46
+ },
47
+ textarea: {
48
+ width: '100%',
49
+ height: '100%',
50
+ },
51
+ img: {
52
+ width: 'auto',
53
+ height: 'calc(100% - 5px)',
54
+ objectFit: 'contain',
55
+ },
56
+ dialogTitle: {
57
+ justifyContent: 'space-between',
58
+ display: 'flex',
59
+ },
60
+ };
61
+
62
+ export const EXTENSIONS = {
63
+ images: ['png', 'jpg', 'svg', 'jpeg', 'bmp', 'gif', 'apng', 'avif', 'webp'],
64
+ code: ['js', 'json', 'json5', 'md'],
65
+ txt: ['log', 'txt', 'html', 'css', 'xml', 'ics'],
66
+ audio: ['mp3', 'wav', 'ogg', 'acc'],
67
+ video: ['mp4', 'mov', 'avi'],
68
+ };
69
+
70
+ function bufferToBase64(buffer: Buffer, isFull?: boolean) {
71
+ let binary = '';
72
+ const bytes = new Uint8Array(buffer);
73
+ const len = bytes.byteLength;
74
+ for (let i = 0; i < len && (isFull || i < 50); i++) {
75
+ binary += String.fromCharCode(bytes[i]);
76
+ }
77
+ return window.btoa(binary);
78
+ }
79
+
80
+ interface FileViewerProps {
81
+ /** Translation function */
82
+ t: Translate;
83
+ /** Callback when the viewer is closed. */
84
+ onClose: () => void;
85
+ /** The URL (file path) to the file to be displayed. */
86
+ href: string;
87
+ // formatEditFile?: string;
88
+ socket: Connection;
89
+ setStateBackgroundImage: () => void;
90
+ // themeType: ThemeType;
91
+ getStyleBackgroundImage: () => React.CSSProperties | null;
92
+ /** Flag is the js-controller support subscribe on file */
93
+ supportSubscribes?: boolean;
94
+ }
95
+
96
+ interface FileViewerState {
97
+ text: string | null;
98
+ code: string | null;
99
+ ext: string | null;
100
+ editing: boolean;
101
+ editingValue: string | null;
102
+ copyPossible: boolean;
103
+ forceUpdate: number;
104
+ changed: boolean;
105
+ imgError: boolean;
106
+ }
107
+
108
+ class FileViewer extends Component<FileViewerProps, FileViewerState> {
109
+ private timeout: ReturnType<typeof setTimeout> | null = null;
110
+
111
+ constructor(props: FileViewerProps) {
112
+ super(props);
113
+ const ext = Utils.getFileExtension(props.href);
114
+
115
+ this.state = {
116
+ text: null,
117
+ code: null,
118
+ ext,
119
+ // File viewer in adapter-react does not support write
120
+ editing: /* !!this.props.formatEditFile || */ false,
121
+ editingValue: null,
122
+ copyPossible: !!ext && (EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext)),
123
+ forceUpdate: Date.now(),
124
+ changed: false,
125
+ imgError: false,
126
+ };
127
+ }
128
+
129
+ readFile() {
130
+ if (this.props.href) {
131
+ const parts = this.props.href.split('/');
132
+ parts.splice(0, 2);
133
+ const adapter = parts[0];
134
+ const name = parts.splice(1).join('/');
135
+
136
+ this.props.socket.readFile(adapter, name)
137
+ .then((data: { data: Buffer; type: string } | { file: string; mimeType: string }) => {
138
+ let fileData: string = '';
139
+ if ((data as { file: string; mimeType: string }).file !== undefined) {
140
+ fileData = (data as { file: string; mimeType: string }).file;
141
+ }
142
+
143
+ const newState: Partial<FileViewerState> = { copyPossible: this.state.copyPossible, ext: this.state.ext };
144
+ // try to detect valid extension
145
+ if ((data as { data: Buffer; type: string }).type === 'Buffer') {
146
+ if (name.toLowerCase().endsWith('.json5')) {
147
+ newState.ext = 'json5';
148
+ newState.copyPossible = true;
149
+ try {
150
+ fileData = atob(bufferToBase64((data as { data: Buffer; type: string }).data, true));
151
+ } catch (e) {
152
+ console.error('Cannot convert base64 to string');
153
+ fileData = '';
154
+ }
155
+ } else {
156
+ const ext = Utils.detectMimeType(bufferToBase64((data as { data: Buffer; type: string }).data));
157
+ if (ext) {
158
+ newState.ext = ext;
159
+ newState.copyPossible = EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext);
160
+ }
161
+ }
162
+ }
163
+
164
+ if (newState.copyPossible) {
165
+ if (newState.ext && EXTENSIONS.txt.includes(newState.ext)) {
166
+ newState.text = fileData;
167
+ newState.editingValue = fileData;
168
+ } else if (newState.ext && EXTENSIONS.code.includes(newState.ext)) {
169
+ newState.code = fileData;
170
+ newState.editingValue = fileData;
171
+ }
172
+ }
173
+
174
+ this.setState(newState as FileViewerState);
175
+ })
176
+ .catch(e => window.alert(`Cannot read file: ${e}`));
177
+ }
178
+ }
179
+
180
+ componentDidMount() {
181
+ this.readFile();
182
+
183
+ const parts = this.props.href.split('/');
184
+ parts.splice(0, 2);
185
+ const adapter = parts[0];
186
+ const name = parts.splice(1).join('/');
187
+
188
+ this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);
189
+ }
190
+
191
+ componentWillUnmount() {
192
+ this.timeout && clearTimeout(this.timeout);
193
+ const parts = this.props.href.split('/');
194
+ parts.splice(0, 2);
195
+ const adapter = parts[0];
196
+ const name = parts.splice(1).join('/');
197
+ this.props.supportSubscribes && this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);
198
+ }
199
+
200
+ onFileChanged = (id: string, fileName: string, size: number | null) => {
201
+ if (!this.state.changed) {
202
+ this.timeout && clearTimeout(this.timeout);
203
+ this.timeout = setTimeout(() => {
204
+ this.timeout = null;
205
+ if (size === null) {
206
+ window.alert('Show file was deleted!');
207
+ } else if (this.state.text !== null || this.state.code !== null) {
208
+ this.readFile();
209
+ } else {
210
+ this.setState({ forceUpdate: Date.now() });
211
+ }
212
+ }, 300);
213
+ }
214
+ };
215
+
216
+ // eslint-disable-next-line class-methods-use-this
217
+ writeFile64 = () => {
218
+ /*
219
+ // File viewer in adapter-react does not support write
220
+ const parts = this.props.href.split('/');
221
+ const data = this.state.editingValue;
222
+ parts.splice(0, 2);
223
+ const adapter = parts[0];
224
+ const name = parts.splice(1).join('/');
225
+ this.props.socket.writeFile64(adapter, name, Buffer.from(data).toString('base64'))
226
+ .then(() => this.props.onClose())
227
+ .catch(e => window.alert(`Cannot write file: ${e}`));
228
+ */
229
+ };
230
+
231
+ static getEditFile(ext: string | null) {
232
+ switch (ext) {
233
+ case 'json':
234
+ return 'json';
235
+ case 'json5':
236
+ return 'json5';
237
+ case 'js':
238
+ return 'javascript';
239
+ case 'html':
240
+ return 'html';
241
+ case 'txt':
242
+ return 'html';
243
+ default:
244
+ // e.g. ace/mode/text
245
+ return 'text';
246
+ }
247
+ }
248
+
249
+ getContent() {
250
+ if (this.state.ext && EXTENSIONS.images.includes(this.state.ext)) {
251
+ if (this.state.imgError) {
252
+ return <IconNoIcon style={{ ...styles.img, ...this.props.getStyleBackgroundImage() }} />;
253
+ }
254
+ return <Icon
255
+ onError={e => {
256
+ (e.target as HTMLImageElement).onerror = null;
257
+ this.setState({ imgError: true });
258
+ }}
259
+ style={{ ...styles.img, ...this.props.getStyleBackgroundImage() }}
260
+ src={`${this.props.href}?ts=${this.state.forceUpdate}`}
261
+ alt={this.props.href}
262
+ />;
263
+ }
264
+ if (this.state.ext && EXTENSIONS.audio.includes(this.state.ext)) {
265
+ return <div
266
+ style={{
267
+ width: '100%',
268
+ height: '100%',
269
+ display: 'flex',
270
+ justifyContent: 'center',
271
+ alignItems: 'center',
272
+ }}
273
+ >
274
+ {/* eslint-disable-next-line jsx-a11y/media-has-caption */}
275
+ <audio
276
+ style={{ width: '100%' }}
277
+ src={this.props.href}
278
+ controls
279
+ ></audio>
280
+ </div>;
281
+ }
282
+ if (this.state.ext && EXTENSIONS.video.includes(this.state.ext)) {
283
+ return (
284
+ <div
285
+ style={{
286
+ width: '100%',
287
+ height: '100%',
288
+ display: 'flex',
289
+ justifyContent: 'center',
290
+ alignItems: 'center',
291
+ }}
292
+ >
293
+ {/* eslint-disable-next-line jsx-a11y/media-has-caption */}
294
+ <video style={{ width: '100%', height: '100%' }} controls>
295
+ <source src={this.props.href} type={`video/${this.state.ext}}`} />
296
+ </video>
297
+ </div>
298
+ );
299
+ }
300
+ if (this.state.code !== null || this.state.text !== null || this.state.editing) {
301
+ // File viewer in adapter-react does not support write
302
+ // return <Editor
303
+ // mode={FileViewer.getEditFile(this.props.formatEditFile)}
304
+ // themeType={this.props.themeType}
305
+ // value={this.state.editingValue || this.state.code || this.state.text}
306
+ // onChange={this.state.editing ? newValue => this.setState({ editingValue: newValue, changed: true }) : undefined}
307
+ // />;
308
+ return <TextField
309
+ variant="standard"
310
+ style={styles.textarea}
311
+ multiline
312
+ value={this.state.editingValue || this.state.code || this.state.text}
313
+ // onChange={newValue => this.setState({ editingValue: newValue, changed: true })}
314
+ InputProps={{ readOnly: !this.state.editing }}
315
+ />;
316
+ }
317
+ return null;
318
+ }
319
+
320
+ render() {
321
+ return <Dialog
322
+ sx={{
323
+ '&.MuiDialog-scrollPaper': styles.dialog,
324
+ '& .MuiDialog-paper': styles.paper,
325
+ }}
326
+ scroll="paper"
327
+ open={!!this.props.href}
328
+ onClose={() => this.props.onClose()}
329
+ fullWidth
330
+ maxWidth="xl"
331
+ aria-labelledby="ar_dialog_file_view_title"
332
+ >
333
+ <div style={styles.dialogTitle}>
334
+ <DialogTitle id="ar_dialog_file_view_title">{`${this.props.t(this.state.editing ? 'Edit' : 'View')}: ${this.props.href}`}</DialogTitle>
335
+ {this.state.ext && EXTENSIONS.images.includes(this.state.ext) && <div>
336
+ <IconButton
337
+ size="large"
338
+ color="inherit"
339
+ onClick={this.props.setStateBackgroundImage}
340
+ >
341
+ <Brightness5Icon />
342
+ </IconButton>
343
+ </div>}
344
+ </div>
345
+ <DialogContent style={styles.content}>
346
+ {this.getContent()}
347
+ </DialogContent>
348
+ <DialogActions>
349
+ {this.state.copyPossible ?
350
+ <Button
351
+ color="grey"
352
+ onClick={e => {
353
+ e.stopPropagation();
354
+ e.preventDefault();
355
+ Utils.copyToClipboard(this.state.text || this.state.code || '');
356
+ }}
357
+ startIcon={<CopyIcon />}
358
+ >
359
+ {this.props.t('Copy content')}
360
+ </Button> : null}
361
+ {this.state.editing ?
362
+ <Button
363
+ color="grey"
364
+ disabled={this.state.editingValue === this.state.code || this.state.editingValue === this.state.text}
365
+ variant="contained"
366
+ onClick={this.writeFile64}
367
+ startIcon={<SaveIcon />}
368
+ >
369
+ {this.props.t('Save')}
370
+ </Button> : null}
371
+ <Button
372
+ variant="contained"
373
+ onClick={() => this.props.onClose()}
374
+ color="primary"
375
+ startIcon={<CloseIcon />}
376
+ >
377
+ {this.props.t('Close')}
378
+ </Button>
379
+ </DialogActions>
380
+ </Dialog>;
381
+ }
382
+ }
383
+
384
+ export default withWidth()(FileViewer);
@@ -0,0 +1,210 @@
1
+ import React, { ReactEventHandler } from 'react';
2
+ import SVG from 'react-inlinesvg';
3
+
4
+ import { Box } from '@mui/material';
5
+
6
+ import {
7
+ SettingsApplications as IconSystem,
8
+ Photo as IconPhoto,
9
+ SupervisedUserCircle as IconGroup,
10
+ PersonOutlined as IconUser,
11
+ Router as IconHost,
12
+ Wifi as IconConnection,
13
+ Info as IconInfo,
14
+ Description as IconMeta,
15
+ } from '@mui/icons-material';
16
+
17
+ import IconAlias from '../icons/IconAlias';
18
+ import Utils from './Utils';
19
+
20
+ export function getSystemIcon(obj: ioBroker.Object | null): React.JSX.Element | null {
21
+ let icon;
22
+ const id = obj?._id;
23
+
24
+ if (!id) {
25
+ return null;
26
+ }
27
+
28
+ // system or design has special icons
29
+ if (id.startsWith('_design/') || (id === 'system')) {
30
+ icon = <IconSystem className="iconOwn" />;
31
+ } else if (id === '0_userdata' || id === '0_userdata.0') {
32
+ icon = <IconPhoto className="iconOwn" />;
33
+ } else if (id === 'alias' || id === 'alias.0') {
34
+ icon = <IconAlias className="iconOwn" />;
35
+ } else if (id === 'system.adapter') {
36
+ icon = <IconSystem className="iconOwn" />;
37
+ } else if (id === 'system.group') {
38
+ icon = <IconGroup className="iconOwn" />;
39
+ } else if (id === 'system.user') {
40
+ icon = <IconUser className="iconOwn" />;
41
+ } else if (id === 'system.host') {
42
+ icon = <IconHost className="iconOwn" />;
43
+ } else if (id.endsWith('.connection') || id.endsWith('.connected')) {
44
+ icon = <IconConnection className="iconOwn" />;
45
+ } else if (id.endsWith('.info')) {
46
+ icon = <IconInfo className="iconOwn" />;
47
+ } else if (obj?.type === 'meta') {
48
+ icon = <IconMeta className="iconOwn" />;
49
+ }
50
+
51
+ return icon || null;
52
+ }
53
+
54
+ export function getSelectIdIcon(obj: ioBroker.Object | null, imagePrefix?: string): string | null {
55
+ imagePrefix = imagePrefix || '.'; // http://localhost:8081';
56
+ let src = '';
57
+ const common = obj?.common;
58
+
59
+ if (common) {
60
+ const cIcon = common.icon;
61
+ if (cIcon) {
62
+ if (!cIcon.startsWith('data:image/')) {
63
+ if (cIcon.includes('.')) {
64
+ let instance;
65
+ if (obj.type === 'instance' || obj.type === 'adapter') {
66
+ src = `${imagePrefix}/adapter/${common.name}/${cIcon}`;
67
+ } else if (obj._id && obj._id.startsWith('system.adapter.')) {
68
+ instance = obj._id.split('.', 3);
69
+ if (cIcon[0] === '/') {
70
+ instance[2] += cIcon;
71
+ } else {
72
+ instance[2] += `/${cIcon}`;
73
+ }
74
+ src = `${imagePrefix}/adapter/${instance[2]}`;
75
+ } else {
76
+ instance = obj._id.split('.', 2);
77
+ if (cIcon[0] === '/') {
78
+ instance[0] += cIcon;
79
+ } else {
80
+ instance[0] += `/${cIcon}`;
81
+ }
82
+ src = `${imagePrefix}/adapter/${instance[0]}`;
83
+ }
84
+ } else {
85
+ return null;
86
+ }
87
+ } else {
88
+ // base 64 image
89
+ src = cIcon;
90
+ }
91
+ }
92
+ }
93
+
94
+ return src || null;
95
+ }
96
+
97
+ interface IconProps {
98
+ /** URL, UTF-8 character, or svg code (data:image/svg...) */
99
+ src: string | React.JSX.Element | null | undefined;
100
+ /** Class name */
101
+ className?: string;
102
+ /** Style for image */
103
+ style?: React.CSSProperties;
104
+ sx?: Record<string, any>;
105
+ /** Tooltip */
106
+ title?: string;
107
+ /** Styles for utf-8 characters */
108
+ styleUTF8?: React.CSSProperties;
109
+ onError?: ReactEventHandler<HTMLImageElement>;
110
+ ref?: React.RefObject<HTMLImageElement>;
111
+ /** Alternative text for image */
112
+ alt?: string;
113
+ }
114
+
115
+ const REMOTE_SERVER = window.location.hostname.endsWith('iobroker.in');
116
+ const REMOTE_PREFIX = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
117
+
118
+ export default function Icon(props: IconProps) {
119
+ if (props.src) {
120
+ if (typeof props.src === 'string') {
121
+ if (props.src.length < 3) {
122
+ // utf-8 char
123
+ if (props.sx) {
124
+ return <Box
125
+ component="span"
126
+ sx={props.sx}
127
+ title={props.title || undefined}
128
+ style={{ height: 27, marginTop: -8, ...(props.styleUTF8 || props.style) }}
129
+ className={Utils.clsx(props.className, 'iconOwn')}
130
+ >
131
+ {props.src}
132
+ </Box>;
133
+ }
134
+ return <span
135
+ title={props.title || undefined}
136
+ style={{ height: 27, marginTop: -8, ...(props.styleUTF8 || props.style) }}
137
+ className={Utils.clsx(props.className, 'iconOwn')}
138
+ >
139
+ {props.src}
140
+ </span>;
141
+ }
142
+ if (props.src.startsWith('data:image/svg')) {
143
+ return <SVG
144
+ title={props.title || undefined}
145
+ src={props.src}
146
+ className={Utils.clsx(props.className, 'iconOwn')}
147
+ width={props.style?.width || 28}
148
+ height={props.style?.height || props.style?.width || 28}
149
+ style={props.style || {}}
150
+ />;
151
+ }
152
+ if (REMOTE_SERVER && !props.src.startsWith('http://') && !props.src.startsWith('https://')) {
153
+ let src = props.src;
154
+ if (src.startsWith('./')) {
155
+ src = REMOTE_PREFIX + src.substring(2);
156
+ } else if (!src.startsWith('/')) {
157
+ src = REMOTE_PREFIX + src;
158
+ }
159
+
160
+ if (props.sx) {
161
+ return <Box
162
+ component="img"
163
+ sx={props.sx}
164
+ title={props.title || undefined}
165
+ style={props.style || {}}
166
+ className={Utils.clsx(props.className, 'iconOwn')}
167
+ src={`https://remote-files.iobroker.in${src}`}
168
+ alt={props.alt || undefined}
169
+ ref={props.ref}
170
+ onError={e => props.onError && props.onError(e)}
171
+ />;
172
+ }
173
+ return <img
174
+ title={props.title || undefined}
175
+ style={props.style || {}}
176
+ className={Utils.clsx(props.className, 'iconOwn')}
177
+ src={`https://remote-files.iobroker.in${src}`}
178
+ alt={props.alt || undefined}
179
+ ref={props.ref}
180
+ onError={e => props.onError && props.onError(e)}
181
+ />;
182
+ }
183
+ if (props.sx) {
184
+ return <Box
185
+ component="img"
186
+ sx={props.sx}
187
+ title={props.title || undefined}
188
+ style={props.style || {}}
189
+ className={Utils.clsx(props.className, 'iconOwn')}
190
+ src={props.src}
191
+ alt={props.alt || undefined}
192
+ ref={props.ref}
193
+ onError={props.onError}
194
+ />;
195
+ }
196
+ return <img
197
+ title={props.title || undefined}
198
+ style={props.style || {}}
199
+ className={Utils.clsx(props.className, 'iconOwn')}
200
+ src={props.src}
201
+ alt={props.alt || undefined}
202
+ ref={props.ref}
203
+ onError={props.onError}
204
+ />;
205
+ }
206
+
207
+ return props.src;
208
+ }
209
+ return null;
210
+ }