@iobroker/adapter-react-v5 7.2.4 → 7.3.0

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 +7 -15
  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 +5 -3
  20. package/{Components → build/Components}/FileBrowser.js +230 -236
  21. package/build/Components/FileBrowser.js.map +1 -0
  22. package/build/Components/FileViewer.d.ts +49 -0
  23. package/build/Components/FileViewer.js +247 -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 +4 -4
  56. package/{Components → build/Components}/ObjectBrowser.js +1159 -1122
  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 +2 -2
  65. package/{Components → build/Components}/Schedule.js +242 -257
  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 -58
  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 +45 -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} +36 -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 +5 -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 +5 -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 +8 -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 +6 -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 +5 -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 +4 -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 +14 -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 +5 -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 +6 -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 +5 -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 +4 -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 +5 -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 +5 -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 +4 -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 +5 -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 +5 -0
  220. package/build/icons/IconState.js.map +1 -0
  221. package/build/index.d.ts +76 -0
  222. package/build/index.js +75 -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 -48
  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 -2560
  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 -8947
  322. package/src/Components/Router.tsx +0 -90
  323. package/src/Components/SaveCloseButtons.tsx +0 -117
  324. package/src/Components/Schedule.tsx +0 -1998
  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,561 +0,0 @@
1
- import React, { Component } from 'react';
2
-
3
- import { Checkbox, Button, MenuItem, Select, FormControlLabel, AppBar, Tabs, Tab, TextField } from '@mui/material';
4
-
5
- import I18n from '../i18n';
6
- import convertCronToText from './SimpleCron/cronText';
7
-
8
- const styles: Record<string, React.CSSProperties> = {
9
- mainDiv: {
10
- width: '100%',
11
- height: '100%',
12
- },
13
- periodSelect: {
14
- // margin: '0 10px 60px 10px',
15
- display: 'block',
16
- width: 250,
17
- },
18
- slider: {
19
- marginTop: 20,
20
- display: 'block',
21
- width: '100%',
22
- },
23
- tabContent: {
24
- padding: 20,
25
- height: 'calc(100% - 240px)',
26
- overflow: 'auto',
27
- },
28
- numberButton: {
29
- padding: 4,
30
- minWidth: 40,
31
- margin: 5,
32
- },
33
- numberButtonBreak: {
34
- display: 'block',
35
- },
36
- appBar: {
37
- color: 'white',
38
- },
39
- warning: {
40
- marginLeft: 16,
41
- color: 'red',
42
- fontSize: 12,
43
- },
44
- };
45
-
46
- const WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
47
- const MONTHS = [
48
- 'January',
49
- 'February',
50
- 'March',
51
- 'April',
52
- 'May',
53
- 'June',
54
- 'July',
55
- 'August',
56
- 'September',
57
- 'October',
58
- 'November',
59
- 'December',
60
- ];
61
-
62
- // 5-7,9-11 => [5,6,7,9,10,11]
63
- function convertMinusIntoArray(value: string | false | undefined, max: number): number[] {
64
- const result: number[] = [];
65
-
66
- if (value === '*') {
67
- if (max === 24 || max === 60 || max === 7) {
68
- for (let i = 0; i < max; i++) {
69
- result.push(i);
70
- }
71
- } else {
72
- for (let i = 1; i <= max; i++) {
73
- result.push(i);
74
- }
75
- }
76
- return result; // array with entries max
77
- }
78
-
79
- const parts = (value || '').toString().split(',');
80
-
81
- for (let p = 0; p < parts.length; p++) {
82
- if (!parts[p].trim().length) {
83
- continue;
84
- }
85
- const items = parts[p].trim().split('-');
86
- if (items.length > 1) {
87
- const iMax = parseInt(items[1], 10);
88
- for (let i = parseInt(items[0], 10); i <= iMax; i++) {
89
- result.push(i);
90
- }
91
- } else {
92
- result.push(parseInt(parts[p], 10));
93
- }
94
- }
95
-
96
- result.sort();
97
-
98
- // remove double entries
99
- for (let p = result.length - 1; p >= 0; p--) {
100
- if (result[p] === result[p + 1]) {
101
- result.splice(p + 1, 1);
102
- }
103
- }
104
-
105
- return result;
106
- }
107
-
108
- // [5,6,7,9,10,11] => 5-7,9-11
109
- function convertArrayIntoMinus(value: number | number[], max: number): string {
110
- if (typeof value !== 'object') {
111
- value = [value];
112
- }
113
- if (value.length === max) {
114
- return '*';
115
- }
116
- const newParts = [];
117
- if (!value.length) {
118
- return '-';
119
- }
120
- value = value.map(a => parseInt(a as any as string, 10));
121
-
122
- value.sort((a, b) => a - b);
123
-
124
- let start = value[0];
125
- let end = value[0];
126
- for (let p = 1; p < value.length; p++) {
127
- if (value[p] - 1 !== parseInt(value[p - 1] as any as string, 10)) {
128
- if (start === end) {
129
- newParts.push(start);
130
- } else if (end - 1 === start) {
131
- newParts.push(`${start},${end}`);
132
- } else {
133
- newParts.push(`${start}-${end}`);
134
- }
135
- start = value[p];
136
- }
137
- end = value[p];
138
- }
139
-
140
- if (start === end) {
141
- newParts.push(start);
142
- } else if (end - 1 === start) {
143
- newParts.push(`${start},${end}`);
144
- } else {
145
- newParts.push(`${start}-${end}`);
146
- }
147
-
148
- return newParts.join(',');
149
- }
150
-
151
- type CronNames = 'seconds' | 'minutes' | 'hours' | 'dates' | 'months' | 'dow';
152
-
153
- interface CronProps {
154
- seconds: string | false | null;
155
- minutes: string | null;
156
- hours: string | null;
157
- dates: string | null;
158
- months: string | null;
159
- dow: string | null;
160
- }
161
-
162
- interface ComplexCronProps {
163
- cronExpression: string;
164
- onChange: (cron: string) => void;
165
- language: ioBroker.Languages;
166
- }
167
-
168
- // type CronModes = 'every' | 'everyN' | 'specific';
169
-
170
- interface ComplexCronState {
171
- extended: boolean;
172
- tab: number;
173
- cron: string;
174
- seconds?: string | false;
175
- minutes?: string;
176
- hours?: string;
177
- dates?: string;
178
- months?: string;
179
- dow?: string;
180
- modes: CronProps;
181
- }
182
-
183
- class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
184
- constructor(props: ComplexCronProps) {
185
- super(props);
186
- let cron =
187
- typeof this.props.cronExpression === 'string'
188
- ? this.props.cronExpression.replace(/^["']/, '').replace(/["']\n?$/, '')
189
- : '';
190
- if (cron[0] === '{') {
191
- cron = '';
192
- }
193
- const state = ComplexCron.cron2state(cron || '* * * * *');
194
-
195
- this.state = {
196
- extended: false,
197
- tab: state.seconds !== false ? 1 : 0,
198
- cron: ComplexCron.state2cron(state),
199
- modes: {
200
- seconds: null,
201
- minutes: null,
202
- hours: null,
203
- dates: null,
204
- months: null,
205
- dow: null,
206
- },
207
- };
208
- Object.assign(this.state, state);
209
- if (this.state.cron !== this.props.cronExpression) {
210
- setTimeout(() => this.props.onChange && this.props.onChange(this.state.cron), 100);
211
- }
212
- }
213
-
214
- static cron2state(cron: string): CronProps {
215
- cron = cron.replace(/['"]/g, '').trim();
216
- const cronParts = cron.split(' ').map(p => p.trim());
217
- let options: CronProps;
218
-
219
- if (cronParts.length === 6) {
220
- options = {
221
- seconds: cronParts[0] || '*',
222
- minutes: cronParts[1] || '*',
223
- hours: cronParts[2] || '*',
224
- dates: cronParts[3] || '*',
225
- months: cronParts[4] || '*',
226
- dow: cronParts[5] || '*',
227
- };
228
- } else {
229
- options = {
230
- seconds: false,
231
- minutes: cronParts[0] || '*',
232
- hours: cronParts[1] || '*',
233
- dates: cronParts[2] || '*',
234
- months: cronParts[3] || '*',
235
- dow: cronParts[4] || '*',
236
- };
237
- }
238
- return options;
239
- }
240
-
241
- static state2cron(state: ComplexCronState | CronProps): string {
242
- let text = `${state.minutes} ${state.hours} ${state.dates} ${state.months} ${state.dow}`;
243
- if (state.seconds !== false) {
244
- text = `${state.seconds} ${text}`;
245
- }
246
- return text;
247
- }
248
-
249
- recalcCron(): void {
250
- const cron = ComplexCron.state2cron(this.state);
251
- if (cron !== this.state.cron) {
252
- this.setState({ cron }, () => this.props.onChange && this.props.onChange(this.state.cron));
253
- }
254
- }
255
-
256
- onToggle(i: boolean | number, type: CronNames, max: number): void {
257
- if (i === true) {
258
- this.setCronAttr(type, '*');
259
- } else if (i === false) {
260
- if (max === 60 || max === 24) {
261
- this.setCronAttr(type, '0');
262
- } else {
263
- this.setCronAttr(type, '1');
264
- }
265
- } else {
266
- const nums = convertMinusIntoArray(this.state[type], max);
267
- const pos = nums.indexOf(i);
268
- if (pos !== -1) {
269
- nums.splice(pos, 1);
270
- } else {
271
- nums.push(i);
272
- nums.sort();
273
- }
274
- this.setCronAttr(type, convertArrayIntoMinus(nums, max));
275
- }
276
- }
277
-
278
- getDigitsSelector(type: CronNames, max: number): React.JSX.Element[] {
279
- let values = [];
280
- if (max === 7) {
281
- values = [1, 2, 3, 4, 5, 6, 0];
282
- } else if (max === 60 || max === 24) {
283
- for (let i = 0; i < max; i++) {
284
- values.push(i);
285
- }
286
- } else {
287
- for (let i = 1; i <= max; i++) {
288
- values.push(i);
289
- }
290
- }
291
-
292
- const parts = convertMinusIntoArray(this.state[type], max);
293
-
294
- return [
295
- <Button
296
- key="removeall"
297
- variant="outlined"
298
- style={styles.numberButton}
299
- // style={{paddingBottom: 20}}
300
- color="primary"
301
- onClick={() => this.onToggle(false, type, max)}
302
- >
303
- {I18n.t('ra_Deselect all')}
304
- </Button>,
305
- <Button
306
- key="addall"
307
- variant="contained"
308
- // style={{paddingBottom: 20}}
309
- style={styles.numberButton}
310
- color="secondary"
311
- onClick={() => this.onToggle(true, type, max)}
312
- >
313
- {I18n.t('ra_Select all')}
314
- </Button>,
315
- <div key="all">
316
- {values.map(i => [
317
- (max === 7 && i === 4) ||
318
- (max === 12 && i === 7) ||
319
- (max === 31 && !((i - 1) % 10)) ||
320
- (max === 60 && i && !(i % 10)) ||
321
- (max === 24 && i && !(i % 6)) ? (
322
- <div
323
- key={`allInner${i}`}
324
- style={{ width: '100%' }}
325
- />
326
- ) : null,
327
- <Button
328
- key={`_${i}`}
329
- variant={parts.indexOf(i) !== -1 ? 'contained' : 'outlined'}
330
- style={styles.numberButton}
331
- color={parts.indexOf(i) !== -1 ? 'secondary' : 'primary'}
332
- onClick={() => this.onToggle(i, type, max)}
333
- >
334
- {max === 7 ? I18n.t(WEEKDAYS[i]) : max === 12 ? MONTHS[i - 1] : i}
335
- </Button>,
336
- ])}
337
- </div>,
338
- ];
339
- }
340
-
341
- getPeriodsTab(type: CronNames, max: number): React.JSX.Element | null {
342
- const value = this.state[type];
343
- let every = value === '*';
344
- let everyN = value === undefined || value === null ? false : value.toString().includes('/');
345
- let select;
346
- if (this.state.modes[type] === null) {
347
- select = every ? 'every' : everyN ? 'everyN' : 'specific';
348
- const modes = JSON.parse(JSON.stringify(this.state.modes));
349
- modes[type] = select;
350
- setTimeout(() => this.setState({ modes }, () => this.recalcCron()), 100);
351
- return null;
352
- }
353
-
354
- every = this.state.modes[type] === 'every';
355
- everyN = this.state.modes[type] === 'everyN';
356
- select = this.state.modes[type];
357
-
358
- let valueNumber = 1;
359
- if (everyN && value) {
360
- valueNumber = parseInt(value.replace('*/', ''), 10) || 1;
361
- }
362
-
363
- return (
364
- <div>
365
- <Select
366
- variant="standard"
367
- style={{ ...styles.periodSelect, verticalAlign: 'bottom' }}
368
- value={select}
369
- onChange={e => {
370
- const modes = JSON.parse(JSON.stringify(this.state.modes));
371
- modes[type] = e.target.value;
372
- if (e.target.value === 'every') {
373
- this.setCronAttr(type, '*', modes);
374
- } else if (e.target.value === 'everyN') {
375
- const num = parseInt((this.state[type] || '').toString().replace('*/', ''), 10) || 1;
376
- this.setCronAttr(type, `*/${num}`, modes);
377
- } else if (e.target.value === 'specific') {
378
- let num = parseInt((this.state[type] || '').toString().split(',')[0], 10) || 0;
379
- if (!num && (type === 'months' || type === 'dates')) {
380
- num = 1;
381
- }
382
- this.setCronAttr(type, convertArrayIntoMinus(num, max), modes);
383
- }
384
- }}
385
- >
386
- <MenuItem
387
- key="every"
388
- value="every"
389
- >
390
- {I18n.t(`sc_every_${type}`)}
391
- </MenuItem>
392
- <MenuItem
393
- key="everyN"
394
- value="everyN"
395
- >
396
- {I18n.t(`sc_everyN_${type}`)}
397
- </MenuItem>
398
- <MenuItem
399
- key="specific"
400
- value="specific"
401
- >
402
- {I18n.t(`sc_specific_${type}`)}
403
- </MenuItem>
404
- </Select>
405
- {/* everyN && false && <span>{value}</span> */}
406
- {everyN && (
407
- <TextField
408
- variant="standard"
409
- key="interval"
410
- label={I18n.t(`sc_${type}`)}
411
- value={valueNumber}
412
- slotProps={{
413
- htmlInput: {
414
- min: 1,
415
- max,
416
- },
417
- inputLabel: {
418
- shrink: true,
419
- },
420
- }}
421
- onChange={e => {
422
- // @ts-expect-error is allowed
423
- this.setState({ [type]: `*/${e.target.value}` }, () => this.recalcCron());
424
- }}
425
- type="number"
426
- margin="normal"
427
- />
428
- )}
429
- {!every && !everyN && this.getDigitsSelector(type, max)}
430
- </div>
431
- );
432
- }
433
-
434
- static convertCronToText(cron: string, lang: ioBroker.Languages): string {
435
- if (cron.split(' ').includes('-')) {
436
- return I18n.t('ra_Invalid CRON');
437
- }
438
- return convertCronToText(cron, lang);
439
- }
440
-
441
- setCronAttr(attr: CronNames, value: string, modes?: CronProps): void {
442
- if (modes) {
443
- if (attr === 'seconds') {
444
- this.setState({ seconds: value, modes }, () => this.recalcCron());
445
- } else if (attr === 'minutes') {
446
- this.setState({ minutes: value, modes }, () => this.recalcCron());
447
- } else if (attr === 'hours') {
448
- this.setState({ hours: value, modes }, () => this.recalcCron());
449
- } else if (attr === 'dates') {
450
- this.setState({ dates: value, modes }, () => this.recalcCron());
451
- } else if (attr === 'months') {
452
- this.setState({ months: value, modes }, () => this.recalcCron());
453
- } else if (attr === 'dow') {
454
- this.setState({ dow: value, modes }, () => this.recalcCron());
455
- } else {
456
- this.setState({ modes }, () => this.recalcCron());
457
- }
458
- } else if (attr === 'seconds') {
459
- this.setState({ seconds: value }, () => this.recalcCron());
460
- } else if (attr === 'minutes') {
461
- this.setState({ minutes: value }, () => this.recalcCron());
462
- } else if (attr === 'hours') {
463
- this.setState({ hours: value }, () => this.recalcCron());
464
- } else if (attr === 'dates') {
465
- this.setState({ dates: value }, () => this.recalcCron());
466
- } else if (attr === 'months') {
467
- this.setState({ months: value }, () => this.recalcCron());
468
- } else if (attr === 'dow') {
469
- this.setState({ dow: value }, () => this.recalcCron());
470
- }
471
- }
472
-
473
- render(): React.JSX.Element {
474
- const tab = this.state.seconds !== false ? this.state.tab : this.state.tab + 1;
475
-
476
- // Detect if every minute or every second is activated
477
- const everyMinute = this.state.minutes === '*' || this.state.minutes === '*/1';
478
- const everySecond = this.state.seconds === '*' || this.state.seconds === '*/1';
479
-
480
- return (
481
- <div style={styles.mainDiv}>
482
- <div style={{ paddingLeft: 8, width: 'calc(100% - px)' }}>
483
- <TextField
484
- variant="standard"
485
- style={{ width: '100%' }}
486
- value={this.state.cron}
487
- disabled
488
- />
489
- </div>
490
- <div style={{ paddingLeft: 8, width: 'calc(100% - px)', height: 60 }}>
491
- {ComplexCron.convertCronToText(this.state.cron, this.props.language || 'en')}
492
- <span style={styles.warning}>
493
- {everySecond
494
- ? I18n.t('ra_warning_every_second')
495
- : everyMinute
496
- ? I18n.t('ra_warning_every_minute')
497
- : ''}
498
- </span>
499
- </div>
500
- <FormControlLabel
501
- control={
502
- <Checkbox
503
- checked={!!this.state.seconds}
504
- onChange={e =>
505
- this.setState({ seconds: e.target.checked ? '*' : false }, () => this.recalcCron())
506
- }
507
- />
508
- }
509
- label={I18n.t('ra_use seconds')}
510
- />
511
- <AppBar
512
- position="static"
513
- sx={{ '&.MuiAppBar-root': styles.appBar }}
514
- color="secondary"
515
- >
516
- <Tabs
517
- value={this.state.tab}
518
- style={styles.appBar}
519
- color="secondary"
520
- onChange={(_active, _tab) => this.setState({ tab: _tab })}
521
- >
522
- {this.state.seconds !== false && (
523
- <Tab
524
- id="sc_seconds"
525
- label={I18n.t('sc_seconds')}
526
- />
527
- )}
528
- <Tab
529
- id="minutes"
530
- label={I18n.t('sc_minutes')}
531
- />
532
- <Tab
533
- id="hours"
534
- label={I18n.t('sc_hours')}
535
- />
536
- <Tab
537
- id="dates"
538
- label={I18n.t('sc_dates')}
539
- />
540
- <Tab
541
- id="months"
542
- label={I18n.t('sc_months')}
543
- />
544
- <Tab
545
- id="dow"
546
- label={I18n.t('sc_dows')}
547
- />
548
- </Tabs>
549
- </AppBar>
550
- {tab === 0 && <div style={styles.tabContent}>{this.getPeriodsTab('seconds', 60)}</div>}
551
- {tab === 1 && <div style={styles.tabContent}>{this.getPeriodsTab('minutes', 60)}</div>}
552
- {tab === 2 && <div style={styles.tabContent}>{this.getPeriodsTab('hours', 24)}</div>}
553
- {tab === 3 && <div style={styles.tabContent}>{this.getPeriodsTab('dates', 31)}</div>}
554
- {tab === 4 && <div style={styles.tabContent}>{this.getPeriodsTab('months', 12)}</div>}
555
- {tab === 5 && <div style={styles.tabContent}>{this.getPeriodsTab('dow', 7)}</div>}
556
- </div>
557
- );
558
- }
559
- }
560
-
561
- export default ComplexCron;