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