@iobroker/adapter-react-v5 4.8.1 → 4.9.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 (265) hide show
  1. package/Components/Logo.d.ts +9 -50
  2. package/Components/Logo.js +106 -173
  3. package/Components/ObjectBrowser.d.ts +9 -0
  4. package/Components/ObjectBrowser.js +370 -165
  5. package/Components/ObjectBrowser.js.map +1 -1
  6. package/Components/SaveCloseButtons.d.ts +17 -61
  7. package/Components/SaveCloseButtons.js +64 -124
  8. package/Components/Schedule.d.ts +31 -6
  9. package/Components/Schedule.js +1144 -1562
  10. package/Components/TabContainer.d.ts +9 -37
  11. package/Components/TabContainer.js +49 -74
  12. package/Components/TabContent.d.ts +6 -27
  13. package/Components/TabContent.js +24 -67
  14. package/Components/TabHeader.d.ts +6 -11
  15. package/Components/TabHeader.js +11 -40
  16. package/Components/ToggleThemeMenu.d.ts +10 -8
  17. package/Components/ToggleThemeMenu.js +16 -36
  18. package/Components/types.d.ts +10 -2
  19. package/Dialogs/SelectID.d.ts +39 -114
  20. package/Dialogs/SelectID.js +141 -246
  21. package/LegacyConnection.d.ts +1 -1
  22. package/README.md +6 -2
  23. package/i18n.d.ts +2 -2
  24. package/index.d.ts +127 -126
  25. package/index.js +213 -192
  26. package/package.json +6 -7
  27. package/Components/JsonConfigComponent/ChipInput.d.ts +0 -12
  28. package/Components/JsonConfigComponent/ChipInput.js +0 -763
  29. package/Components/JsonConfigComponent/ChipInput.js.map +0 -1
  30. package/Components/JsonConfigComponent/ConfigAccordion.d.ts +0 -15
  31. package/Components/JsonConfigComponent/ConfigAccordion.js +0 -348
  32. package/Components/JsonConfigComponent/ConfigAccordion.js.map +0 -1
  33. package/Components/JsonConfigComponent/ConfigAlive.d.ts +0 -10
  34. package/Components/JsonConfigComponent/ConfigAlive.js +0 -105
  35. package/Components/JsonConfigComponent/ConfigAlive.js.map +0 -1
  36. package/Components/JsonConfigComponent/ConfigAutocomplete.d.ts +0 -37
  37. package/Components/JsonConfigComponent/ConfigAutocomplete.js +0 -73
  38. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.d.ts +0 -17
  39. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js +0 -131
  40. package/Components/JsonConfigComponent/ConfigCRON.d.ts +0 -15
  41. package/Components/JsonConfigComponent/ConfigCRON.js +0 -157
  42. package/Components/JsonConfigComponent/ConfigCRON.js.map +0 -1
  43. package/Components/JsonConfigComponent/ConfigCertCollection.d.ts +0 -14
  44. package/Components/JsonConfigComponent/ConfigCertCollection.js +0 -128
  45. package/Components/JsonConfigComponent/ConfigCertCollection.js.map +0 -1
  46. package/Components/JsonConfigComponent/ConfigCertificateSelect.d.ts +0 -14
  47. package/Components/JsonConfigComponent/ConfigCertificateSelect.js +0 -149
  48. package/Components/JsonConfigComponent/ConfigCertificateSelect.js.map +0 -1
  49. package/Components/JsonConfigComponent/ConfigCertificates.d.ts +0 -14
  50. package/Components/JsonConfigComponent/ConfigCertificates.js +0 -284
  51. package/Components/JsonConfigComponent/ConfigCertificates.js.map +0 -1
  52. package/Components/JsonConfigComponent/ConfigCheckLicense.d.ts +0 -3
  53. package/Components/JsonConfigComponent/ConfigCheckLicense.js +0 -821
  54. package/Components/JsonConfigComponent/ConfigCheckLicense.js.map +0 -1
  55. package/Components/JsonConfigComponent/ConfigCheckbox.d.ts +0 -15
  56. package/Components/JsonConfigComponent/ConfigCheckbox.js +0 -40
  57. package/Components/JsonConfigComponent/ConfigChip.d.ts +0 -14
  58. package/Components/JsonConfigComponent/ConfigChip.js +0 -120
  59. package/Components/JsonConfigComponent/ConfigChip.js.map +0 -1
  60. package/Components/JsonConfigComponent/ConfigColor.d.ts +0 -22
  61. package/Components/JsonConfigComponent/ConfigColor.js +0 -120
  62. package/Components/JsonConfigComponent/ConfigColor.js.map +0 -1
  63. package/Components/JsonConfigComponent/ConfigCoordinates.d.ts +0 -14
  64. package/Components/JsonConfigComponent/ConfigCoordinates.js +0 -265
  65. package/Components/JsonConfigComponent/ConfigCoordinates.js.map +0 -1
  66. package/Components/JsonConfigComponent/ConfigCustom.d.ts +0 -26
  67. package/Components/JsonConfigComponent/ConfigCustom.js +0 -316
  68. package/Components/JsonConfigComponent/ConfigCustom.js.map +0 -1
  69. package/Components/JsonConfigComponent/ConfigDatePicker.d.ts +0 -14
  70. package/Components/JsonConfigComponent/ConfigDatePicker.js +0 -91
  71. package/Components/JsonConfigComponent/ConfigDatePicker.js.map +0 -1
  72. package/Components/JsonConfigComponent/ConfigDeviceManager.d.ts +0 -6
  73. package/Components/JsonConfigComponent/ConfigDeviceManager.js +0 -18
  74. package/Components/JsonConfigComponent/ConfigFile.d.ts +0 -15
  75. package/Components/JsonConfigComponent/ConfigFile.js +0 -228
  76. package/Components/JsonConfigComponent/ConfigFile.js.map +0 -1
  77. package/Components/JsonConfigComponent/ConfigFileSelector.d.ts +0 -3
  78. package/Components/JsonConfigComponent/ConfigFileSelector.js +0 -625
  79. package/Components/JsonConfigComponent/ConfigFileSelector.js.map +0 -1
  80. package/Components/JsonConfigComponent/ConfigFunc.d.ts +0 -14
  81. package/Components/JsonConfigComponent/ConfigFunc.js +0 -124
  82. package/Components/JsonConfigComponent/ConfigFunc.js.map +0 -1
  83. package/Components/JsonConfigComponent/ConfigGeneric.d.ts +0 -95
  84. package/Components/JsonConfigComponent/ConfigGeneric.js +0 -646
  85. package/Components/JsonConfigComponent/ConfigIP.d.ts +0 -14
  86. package/Components/JsonConfigComponent/ConfigIP.js +0 -130
  87. package/Components/JsonConfigComponent/ConfigIP.js.map +0 -1
  88. package/Components/JsonConfigComponent/ConfigImageSendTo.d.ts +0 -10
  89. package/Components/JsonConfigComponent/ConfigImageSendTo.js +0 -114
  90. package/Components/JsonConfigComponent/ConfigImageSendTo.js.map +0 -1
  91. package/Components/JsonConfigComponent/ConfigImageUpload.d.ts +0 -14
  92. package/Components/JsonConfigComponent/ConfigImageUpload.js +0 -166
  93. package/Components/JsonConfigComponent/ConfigImageUpload.js.map +0 -1
  94. package/Components/JsonConfigComponent/ConfigInstanceSelect.d.ts +0 -14
  95. package/Components/JsonConfigComponent/ConfigInstanceSelect.js +0 -264
  96. package/Components/JsonConfigComponent/ConfigInstanceSelect.js.map +0 -1
  97. package/Components/JsonConfigComponent/ConfigInterface.d.ts +0 -14
  98. package/Components/JsonConfigComponent/ConfigInterface.js +0 -146
  99. package/Components/JsonConfigComponent/ConfigInterface.js.map +0 -1
  100. package/Components/JsonConfigComponent/ConfigJsonEditor.d.ts +0 -13
  101. package/Components/JsonConfigComponent/ConfigJsonEditor.js +0 -145
  102. package/Components/JsonConfigComponent/ConfigJsonEditor.js.map +0 -1
  103. package/Components/JsonConfigComponent/ConfigLanguage.d.ts +0 -7
  104. package/Components/JsonConfigComponent/ConfigLanguage.js +0 -110
  105. package/Components/JsonConfigComponent/ConfigLicense.d.ts +0 -24
  106. package/Components/JsonConfigComponent/ConfigLicense.js +0 -183
  107. package/Components/JsonConfigComponent/ConfigLicense.js.map +0 -1
  108. package/Components/JsonConfigComponent/ConfigNumber.d.ts +0 -17
  109. package/Components/JsonConfigComponent/ConfigNumber.js +0 -117
  110. package/Components/JsonConfigComponent/ConfigObjectId.d.ts +0 -17
  111. package/Components/JsonConfigComponent/ConfigObjectId.js +0 -167
  112. package/Components/JsonConfigComponent/ConfigObjectId.js.map +0 -1
  113. package/Components/JsonConfigComponent/ConfigPanel.d.ts +0 -3
  114. package/Components/JsonConfigComponent/ConfigPanel.js +0 -396
  115. package/Components/JsonConfigComponent/ConfigPanel.js.map +0 -1
  116. package/Components/JsonConfigComponent/ConfigPassword.d.ts +0 -14
  117. package/Components/JsonConfigComponent/ConfigPassword.js +0 -193
  118. package/Components/JsonConfigComponent/ConfigPassword.js.map +0 -1
  119. package/Components/JsonConfigComponent/ConfigPattern.d.ts +0 -21
  120. package/Components/JsonConfigComponent/ConfigPattern.js +0 -65
  121. package/Components/JsonConfigComponent/ConfigPattern.js.map +0 -1
  122. package/Components/JsonConfigComponent/ConfigPort.d.ts +0 -3
  123. package/Components/JsonConfigComponent/ConfigPort.js +0 -176
  124. package/Components/JsonConfigComponent/ConfigRoom.d.ts +0 -14
  125. package/Components/JsonConfigComponent/ConfigRoom.js +0 -124
  126. package/Components/JsonConfigComponent/ConfigRoom.js.map +0 -1
  127. package/Components/JsonConfigComponent/ConfigSelect.d.ts +0 -14
  128. package/Components/JsonConfigComponent/ConfigSelect.js +0 -159
  129. package/Components/JsonConfigComponent/ConfigSelect.js.map +0 -1
  130. package/Components/JsonConfigComponent/ConfigSelectSendTo.d.ts +0 -17
  131. package/Components/JsonConfigComponent/ConfigSelectSendTo.js +0 -272
  132. package/Components/JsonConfigComponent/ConfigSelectSendTo.js.map +0 -1
  133. package/Components/JsonConfigComponent/ConfigSendto.d.ts +0 -24
  134. package/Components/JsonConfigComponent/ConfigSendto.js +0 -294
  135. package/Components/JsonConfigComponent/ConfigSetState.d.ts +0 -18
  136. package/Components/JsonConfigComponent/ConfigSetState.js +0 -185
  137. package/Components/JsonConfigComponent/ConfigSetState.js.map +0 -1
  138. package/Components/JsonConfigComponent/ConfigSlider.d.ts +0 -14
  139. package/Components/JsonConfigComponent/ConfigSlider.js +0 -119
  140. package/Components/JsonConfigComponent/ConfigSlider.js.map +0 -1
  141. package/Components/JsonConfigComponent/ConfigStaticDivider.d.ts +0 -14
  142. package/Components/JsonConfigComponent/ConfigStaticDivider.js +0 -68
  143. package/Components/JsonConfigComponent/ConfigStaticDivider.js.map +0 -1
  144. package/Components/JsonConfigComponent/ConfigStaticHeader.d.ts +0 -14
  145. package/Components/JsonConfigComponent/ConfigStaticHeader.js +0 -81
  146. package/Components/JsonConfigComponent/ConfigStaticHeader.js.map +0 -1
  147. package/Components/JsonConfigComponent/ConfigStaticImage.d.ts +0 -14
  148. package/Components/JsonConfigComponent/ConfigStaticImage.js +0 -71
  149. package/Components/JsonConfigComponent/ConfigStaticImage.js.map +0 -1
  150. package/Components/JsonConfigComponent/ConfigStaticText.d.ts +0 -14
  151. package/Components/JsonConfigComponent/ConfigStaticText.js +0 -88
  152. package/Components/JsonConfigComponent/ConfigStaticText.js.map +0 -1
  153. package/Components/JsonConfigComponent/ConfigTable.d.ts +0 -3
  154. package/Components/JsonConfigComponent/ConfigTable.js +0 -1064
  155. package/Components/JsonConfigComponent/ConfigTable.js.map +0 -1
  156. package/Components/JsonConfigComponent/ConfigTabs.d.ts +0 -34
  157. package/Components/JsonConfigComponent/ConfigTabs.js +0 -162
  158. package/Components/JsonConfigComponent/ConfigTabs.js.map +0 -1
  159. package/Components/JsonConfigComponent/ConfigText.d.ts +0 -14
  160. package/Components/JsonConfigComponent/ConfigText.js +0 -226
  161. package/Components/JsonConfigComponent/ConfigText.js.map +0 -1
  162. package/Components/JsonConfigComponent/ConfigTextSendTo.d.ts +0 -10
  163. package/Components/JsonConfigComponent/ConfigTextSendTo.js +0 -129
  164. package/Components/JsonConfigComponent/ConfigTextSendTo.js.map +0 -1
  165. package/Components/JsonConfigComponent/ConfigTimePicker.d.ts +0 -14
  166. package/Components/JsonConfigComponent/ConfigTimePicker.js +0 -85
  167. package/Components/JsonConfigComponent/ConfigTimePicker.js.map +0 -1
  168. package/Components/JsonConfigComponent/ConfigTopic.d.ts +0 -17
  169. package/Components/JsonConfigComponent/ConfigTopic.js +0 -110
  170. package/Components/JsonConfigComponent/ConfigTopic.js.map +0 -1
  171. package/Components/JsonConfigComponent/ConfigUUID.d.ts +0 -15
  172. package/Components/JsonConfigComponent/ConfigUUID.js +0 -95
  173. package/Components/JsonConfigComponent/ConfigUUID.js.map +0 -1
  174. package/Components/JsonConfigComponent/ConfigUser.d.ts +0 -14
  175. package/Components/JsonConfigComponent/ConfigUser.js +0 -142
  176. package/Components/JsonConfigComponent/ConfigUser.js.map +0 -1
  177. package/Components/JsonConfigComponent/DeviceManager/Communication.d.ts +0 -63
  178. package/Components/JsonConfigComponent/DeviceManager/Communication.js +0 -268
  179. package/Components/JsonConfigComponent/DeviceManager/DeviceActionButton.d.ts +0 -11
  180. package/Components/JsonConfigComponent/DeviceManager/DeviceActionButton.js +0 -15
  181. package/Components/JsonConfigComponent/DeviceManager/DeviceCard.d.ts +0 -53
  182. package/Components/JsonConfigComponent/DeviceManager/DeviceCard.js +0 -340
  183. package/Components/JsonConfigComponent/DeviceManager/DeviceControl.d.ts +0 -45
  184. package/Components/JsonConfigComponent/DeviceManager/DeviceControl.js +0 -146
  185. package/Components/JsonConfigComponent/DeviceManager/DeviceImageUpload.d.ts +0 -12
  186. package/Components/JsonConfigComponent/DeviceManager/DeviceImageUpload.js +0 -69
  187. package/Components/JsonConfigComponent/DeviceManager/DeviceList.d.ts +0 -51
  188. package/Components/JsonConfigComponent/DeviceManager/DeviceList.js +0 -226
  189. package/Components/JsonConfigComponent/DeviceManager/DeviceStatus.d.ts +0 -13
  190. package/Components/JsonConfigComponent/DeviceManager/DeviceStatus.js +0 -111
  191. package/Components/JsonConfigComponent/DeviceManager/InstanceActionButton.d.ts +0 -7
  192. package/Components/JsonConfigComponent/DeviceManager/InstanceActionButton.js +0 -16
  193. package/Components/JsonConfigComponent/DeviceManager/JsonConfig.d.ts +0 -11
  194. package/Components/JsonConfigComponent/DeviceManager/JsonConfig.js +0 -94
  195. package/Components/JsonConfigComponent/DeviceManager/TooltipButton.d.ts +0 -10
  196. package/Components/JsonConfigComponent/DeviceManager/TooltipButton.js +0 -22
  197. package/Components/JsonConfigComponent/DeviceManager/Utils.d.ts +0 -12
  198. package/Components/JsonConfigComponent/DeviceManager/Utils.js +0 -158
  199. package/Components/JsonConfigComponent/DeviceManager/i18n/de.json +0 -21
  200. package/Components/JsonConfigComponent/DeviceManager/i18n/en.json +0 -21
  201. package/Components/JsonConfigComponent/DeviceManager/i18n/es.json +0 -21
  202. package/Components/JsonConfigComponent/DeviceManager/i18n/fr.json +0 -21
  203. package/Components/JsonConfigComponent/DeviceManager/i18n/i18n.d.ts +0 -26
  204. package/Components/JsonConfigComponent/DeviceManager/i18n/it.json +0 -21
  205. package/Components/JsonConfigComponent/DeviceManager/i18n/nl.json +0 -21
  206. package/Components/JsonConfigComponent/DeviceManager/i18n/pl.json +0 -21
  207. package/Components/JsonConfigComponent/DeviceManager/i18n/pt.json +0 -21
  208. package/Components/JsonConfigComponent/DeviceManager/i18n/ru.json +0 -21
  209. package/Components/JsonConfigComponent/DeviceManager/i18n/uk.json +0 -21
  210. package/Components/JsonConfigComponent/DeviceManager/i18n/zh-cn.json +0 -21
  211. package/Components/JsonConfigComponent/DeviceManager/index.d.ts +0 -2
  212. package/Components/JsonConfigComponent/DeviceManager/index.js +0 -10
  213. package/Components/JsonConfigComponent/DeviceManager/index.js.map +0 -1
  214. package/Components/JsonConfigComponent/index.d.ts +0 -26
  215. package/Components/JsonConfigComponent/index.js +0 -520
  216. package/Components/JsonConfigComponent/index.js.map +0 -1
  217. package/Components/JsonConfigComponent/wrapper/AdminConnection.d.ts +0 -2
  218. package/Components/JsonConfigComponent/wrapper/AdminConnection.js +0 -7
  219. package/Components/JsonConfigComponent/wrapper/Components/ColorPicker.d.ts +0 -2
  220. package/Components/JsonConfigComponent/wrapper/Components/ColorPicker.js +0 -10
  221. package/Components/JsonConfigComponent/wrapper/Components/ColorPicker.js.map +0 -1
  222. package/Components/JsonConfigComponent/wrapper/Components/Icon.d.ts +0 -2
  223. package/Components/JsonConfigComponent/wrapper/Components/Icon.js +0 -10
  224. package/Components/JsonConfigComponent/wrapper/Components/Icon.js.map +0 -1
  225. package/Components/JsonConfigComponent/wrapper/Components/TextWithIcon.d.ts +0 -2
  226. package/Components/JsonConfigComponent/wrapper/Components/TextWithIcon.js +0 -10
  227. package/Components/JsonConfigComponent/wrapper/Components/TextWithIcon.js.map +0 -1
  228. package/Components/JsonConfigComponent/wrapper/Components/UploadImage.d.ts +0 -2
  229. package/Components/JsonConfigComponent/wrapper/Components/UploadImage.js +0 -10
  230. package/Components/JsonConfigComponent/wrapper/Components/UploadImage.js.map +0 -1
  231. package/Components/JsonConfigComponent/wrapper/Components/Utils.d.ts +0 -2
  232. package/Components/JsonConfigComponent/wrapper/Components/Utils.js +0 -10
  233. package/Components/JsonConfigComponent/wrapper/Components/Utils.js.map +0 -1
  234. package/Components/JsonConfigComponent/wrapper/Dialogs/Confirm.d.ts +0 -2
  235. package/Components/JsonConfigComponent/wrapper/Dialogs/Confirm.js +0 -10
  236. package/Components/JsonConfigComponent/wrapper/Dialogs/Confirm.js.map +0 -1
  237. package/Components/JsonConfigComponent/wrapper/Dialogs/Cron.d.ts +0 -2
  238. package/Components/JsonConfigComponent/wrapper/Dialogs/Cron.js +0 -10
  239. package/Components/JsonConfigComponent/wrapper/Dialogs/Cron.js.map +0 -1
  240. package/Components/JsonConfigComponent/wrapper/Dialogs/Error.d.ts +0 -2
  241. package/Components/JsonConfigComponent/wrapper/Dialogs/Error.js +0 -10
  242. package/Components/JsonConfigComponent/wrapper/Dialogs/Error.js.map +0 -1
  243. package/Components/JsonConfigComponent/wrapper/Dialogs/Message.d.ts +0 -2
  244. package/Components/JsonConfigComponent/wrapper/Dialogs/Message.js +0 -10
  245. package/Components/JsonConfigComponent/wrapper/Dialogs/Message.js.map +0 -1
  246. package/Components/JsonConfigComponent/wrapper/Dialogs/SelectFile.d.ts +0 -2
  247. package/Components/JsonConfigComponent/wrapper/Dialogs/SelectFile.js +0 -10
  248. package/Components/JsonConfigComponent/wrapper/Dialogs/SelectFile.js.map +0 -1
  249. package/Components/JsonConfigComponent/wrapper/Dialogs/SelectID.d.ts +0 -2
  250. package/Components/JsonConfigComponent/wrapper/Dialogs/SelectID.js +0 -10
  251. package/Components/JsonConfigComponent/wrapper/Dialogs/SelectID.js.map +0 -1
  252. package/Components/JsonConfigComponent/wrapper/i18n.d.ts +0 -2
  253. package/Components/JsonConfigComponent/wrapper/i18n.js +0 -10
  254. package/Components/JsonConfigComponent/wrapper/i18n.js.map +0 -1
  255. package/Components/JsonConfigComponent/wrapper/icons/IconCopy.d.ts +0 -2
  256. package/Components/JsonConfigComponent/wrapper/icons/IconCopy.js +0 -10
  257. package/Components/JsonConfigComponent/wrapper/icons/IconCopy.js.map +0 -1
  258. package/Components/Logo.js.map +0 -1
  259. package/Components/SaveCloseButtons.js.map +0 -1
  260. package/Components/Schedule.js.map +0 -1
  261. package/Components/TabContainer.js.map +0 -1
  262. package/Components/TabContent.js.map +0 -1
  263. package/Components/TabHeader.js.map +0 -1
  264. package/Components/ToggleThemeMenu.js.map +0 -1
  265. package/Dialogs/SelectID.js.map +0 -1
@@ -1,1662 +1,1244 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
6
17
  });
7
- exports["default"] = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
16
- var _react = _interopRequireDefault(require("react"));
17
- var _propTypes = _interopRequireDefault(require("prop-types"));
18
- var _styles = require("@mui/styles");
19
- var _reactTextMask = _interopRequireDefault(require("react-text-mask"));
20
- var _material = require("@mui/material");
21
- var _i18n = _interopRequireDefault(require("../i18n"));
22
- var _excluded = ["inputRef"],
23
- _excluded2 = ["inputRef"];
24
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
26
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
27
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
28
- var styles = function styles(theme) {
29
- return {
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const react_1 = __importStar(require("react"));
30
+ const styles_1 = require("@mui/styles");
31
+ const material_1 = require("@mui/material");
32
+ const i18n_1 = __importDefault(require("../i18n"));
33
+ const styles = (theme) => ({
30
34
  hr: {
31
- border: 0,
32
- borderTop: '1px solid gray'
35
+ border: 0,
36
+ borderTop: '1px solid gray',
33
37
  },
34
38
  scrollWindow: {
35
- width: '100%',
36
- overflow: 'auto',
37
- height: 'calc(100% - 22px)'
39
+ width: '100%',
40
+ overflow: 'auto',
41
+ height: 'calc(100% - 22px)',
38
42
  },
39
43
  rowDiv: {
40
- width: '100%'
44
+ width: '100%',
41
45
  },
42
46
  modeDiv: {
43
- width: 200,
44
- display: 'inline-block',
45
- verticalAlign: 'top'
47
+ width: 200,
48
+ display: 'inline-block',
49
+ verticalAlign: 'top',
46
50
  },
47
51
  settingsDiv: {
48
- display: 'inline-block',
49
- verticalAlign: 'top'
52
+ display: 'inline-block',
53
+ verticalAlign: 'top',
50
54
  },
51
55
  inputTime: {
52
- width: 90,
53
- marginTop: 0,
54
- marginLeft: 5
56
+ width: 90,
57
+ marginTop: 0,
58
+ marginLeft: 5,
55
59
  },
56
60
  inputDate: {
57
- width: 140,
58
- marginTop: 0,
59
- marginLeft: 5
61
+ width: 140,
62
+ marginTop: 0,
63
+ marginLeft: 5,
60
64
  },
61
65
  inputEvery: {
62
- width: 40,
63
- marginLeft: 5,
64
- marginRight: 5
66
+ width: 40,
67
+ marginLeft: 5,
68
+ marginRight: 5,
65
69
  },
66
70
  inputRadio: {
67
- padding: '4px 12px',
68
- verticalAlign: 'top'
71
+ padding: '4px 12px',
72
+ verticalAlign: 'top',
69
73
  },
70
74
  inputGroup: {
71
- maxWidth: 400,
72
- display: 'inline-block'
75
+ maxWidth: 400,
76
+ display: 'inline-block',
73
77
  },
74
78
  inputGroupElement: {
75
- width: 120
79
+ width: 120,
76
80
  },
77
81
  inputDateDay: {
78
- width: 60
82
+ width: 60,
79
83
  },
80
84
  inputDateDayCheck: {
81
- padding: 4
85
+ padding: 4,
82
86
  },
83
87
  inputSmallCheck: {
84
- padding: 0
88
+ padding: 0,
85
89
  },
86
90
  rowOnce: {},
87
91
  rowDays: {
88
- background: theme.palette.mode !== 'dark' ? '#ddeaff' : '#4b5057'
92
+ background: theme.palette.mode !== 'dark' ? '#ddeaff' : '#4b5057',
89
93
  },
90
94
  rowDows: {
91
- background: theme.palette.mode !== 'dark' ? '#DDFFDD' : '#52646c'
95
+ background: theme.palette.mode !== 'dark' ? '#DDFFDD' : '#52646c',
92
96
  },
93
97
  rowDates: {
94
- background: theme.palette.mode !== 'dark' ? '#DDDDFF' : '#747a86'
98
+ background: theme.palette.mode !== 'dark' ? '#DDDDFF' : '#747a86',
95
99
  },
96
100
  rowWeeks: {
97
- background: theme.palette.mode !== 'dark' ? '#DDDDFF' : '#717680'
101
+ background: theme.palette.mode !== 'dark' ? '#DDDDFF' : '#717680',
98
102
  },
99
103
  rowMonths: {
100
- background: theme.palette.mode !== 'dark' ? '#DDFFFF' : '#1f5557'
104
+ background: theme.palette.mode !== 'dark' ? '#DDFFFF' : '#1f5557',
101
105
  },
102
106
  rowMonthsDates: {
103
- background: theme.palette.mode !== 'dark' ? '#EEFFFF' : '#3c5737',
104
- maxWidth: 600
107
+ background: theme.palette.mode !== 'dark' ? '#EEFFFF' : '#3c5737',
108
+ maxWidth: 600,
105
109
  },
106
110
  rowYears: {
107
- background: theme.palette.mode !== 'dark' ? '#fbffdd' : '#574b33'
111
+ background: theme.palette.mode !== 'dark' ? '#fbffdd' : '#574b33',
108
112
  },
109
113
  rowDaysDows: {
110
- background: theme.palette.mode !== 'dark' ? '#EEEAFF' : '#573544',
111
- paddingLeft: 10,
112
- paddingBottom: 10
114
+ background: theme.palette.mode !== 'dark' ? '#EEEAFF' : '#573544',
115
+ paddingLeft: 10,
116
+ paddingBottom: 10,
113
117
  },
114
118
  rowDowsDows: {
115
- background: theme.palette.mode !== 'dark' ? '#EEFFEE' : '#3d4c54',
116
- paddingLeft: 10,
117
- paddingBottom: 10
118
- }
119
- };
120
- };
121
- var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
122
- var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
123
- var PERIODS = {
124
- minutes: 'minutes',
125
- hours: 'hours'
119
+ background: theme.palette.mode !== 'dark' ? '#EEFFEE' : '#3d4c54',
120
+ paddingLeft: 10,
121
+ paddingBottom: 10,
122
+ },
123
+ });
124
+ const WEEKDAYS = [
125
+ 'Sunday',
126
+ 'Monday',
127
+ 'Tuesday',
128
+ 'Wednesday',
129
+ 'Thursday',
130
+ 'Friday',
131
+ 'Saturday',
132
+ 'Sunday',
133
+ ];
134
+ const MONTHS = [
135
+ 'January',
136
+ 'February',
137
+ 'March',
138
+ 'April',
139
+ 'May',
140
+ 'June',
141
+ 'July',
142
+ 'August',
143
+ 'September',
144
+ 'October',
145
+ 'November',
146
+ 'December',
147
+ ];
148
+ const PERIODS = {
149
+ minutes: 'minutes',
150
+ hours: 'hours',
126
151
  };
127
- var ASTRO = ['sunrise', 'sunriseEnd', 'goldenHourEnd', 'solarNoon', 'goldenHour', 'sunsetStart', 'sunset', 'dusk', 'nauticalDusk', 'night', 'nightEnd', 'nauticalDawn', 'dawn', 'nadir'];
152
+ const ASTRO = [
153
+ 'sunrise',
154
+ 'sunriseEnd',
155
+ 'goldenHourEnd',
156
+ 'solarNoon',
157
+ 'goldenHour',
158
+ 'sunsetStart',
159
+ 'sunset',
160
+ 'dusk',
161
+ 'nauticalDusk',
162
+ 'night',
163
+ 'nightEnd',
164
+ 'nauticalDawn',
165
+ 'dawn',
166
+ 'nadir',
167
+ ];
128
168
  function padding(num) {
129
- if (num < 10) {
130
- return "0".concat(num);
131
- }
132
- return "".concat(num);
133
- }
134
- function TextTime(props) {
135
- var inputRef = props.inputRef,
136
- other = (0, _objectWithoutProperties2["default"])(props, _excluded);
137
- return /*#__PURE__*/_react["default"].createElement(_reactTextMask["default"], (0, _extends2["default"])({}, other, {
138
- ref: inputRef,
139
- mask: [/[0-2]/, /[0-9]/, ':', /[0-5]/, /[0-9]/],
140
- placeholderChar: props.placeholder || '00:00',
141
- showMask: true
142
- }));
143
- }
144
- TextTime.propTypes = {
145
- inputRef: _propTypes["default"].func.isRequired
146
- };
147
- function TextDate(props) {
148
- var inputRef = props.inputRef,
149
- other = (0, _objectWithoutProperties2["default"])(props, _excluded2);
150
- return /*#__PURE__*/_react["default"].createElement(_reactTextMask["default"], (0, _extends2["default"])({}, other, {
151
- ref: inputRef,
152
- mask: [/[0-3]/, /[0-9]/, '.', /[0-1]/, /[0-9]/, '.', '2', '0', /[0-9]/, /[0-9]/],
153
- placeholderChar: props.placeholder || '01.01.2020',
154
- showMask: true
155
- }));
169
+ if (num < 10) {
170
+ return `0${num}`;
171
+ }
172
+ return `${num}`;
156
173
  }
157
- TextDate.propTypes = {
158
- inputRef: _propTypes["default"].func.isRequired
159
- };
160
- var DEFAULT = {
161
- time: {
162
- exactTime: false,
163
- start: '00:00',
164
- end: '23:59',
165
- mode: 'hours',
166
- interval: 1
167
- },
168
- period: {
169
- once: '',
170
- days: 1,
171
- dows: '',
172
- dates: '',
173
- weeks: 0,
174
- months: '',
175
- years: 0,
176
- yearMonth: 0,
177
- yearDate: 0
178
- },
179
- valid: {
180
- from: '',
181
- to: ''
182
- }
174
+ // interface TextTimeProps {
175
+ // inputRef: React.RefObject<HTMLInputElement>;
176
+ // placeholder?: string;
177
+ // }
178
+ // function TextTime(props: TextTimeProps) {
179
+ // const { inputRef, ...other } = props;
180
+ //
181
+ // return <MaskedInput
182
+ // {...other}
183
+ // ref={inputRef}
184
+ // mask={[/[0-2]/, /[0-9]/, ':', /[0-5]/, /[0-9]/]}
185
+ // placeholderChar={props.placeholder || '00:00'}
186
+ // showMask
187
+ // />;
188
+ // }
189
+ // function TextDate(props: TextTimeProps) {
190
+ // const { inputRef, ...other } = props;
191
+ //
192
+ // return <MaskedInput
193
+ // {...other}
194
+ // ref={inputRef}
195
+ // mask={[/[0-3]/, /[0-9]/, '.', /[0-1]/, /[0-9]/, '.', '2', '0', /[0-9]/, /[0-9]/]}
196
+ // placeholderChar={props.placeholder || '01.01.2020'}
197
+ // showMask
198
+ // />;
199
+ // }
200
+ const DEFAULT = {
201
+ time: {
202
+ exactTime: false,
203
+ start: '00:00',
204
+ end: '23:59',
205
+ mode: 'hours',
206
+ interval: 1,
207
+ },
208
+ period: {
209
+ once: '',
210
+ days: 1,
211
+ dows: '',
212
+ dates: '',
213
+ weeks: 0,
214
+ months: '',
215
+ years: 0,
216
+ yearMonth: 0,
217
+ yearDate: 0,
218
+ },
219
+ valid: {
220
+ from: '',
221
+ to: '',
222
+ },
183
223
  };
184
224
  function string2USdate(date) {
185
- var parts = date.split('.');
186
- if (parts.length === 3) {
187
- return "".concat(parts[2], "-").concat(parts[1], "-").concat(parts[0]);
188
- }
189
- return '';
190
- }
191
- var Schedule = /*#__PURE__*/function (_React$Component) {
192
- (0, _inherits2["default"])(Schedule, _React$Component);
193
- var _super = _createSuper(Schedule);
194
- function Schedule(props) {
195
- var _this;
196
- (0, _classCallCheck2["default"])(this, Schedule);
197
- _this = _super.call(this, props);
198
- var schedule;
199
- if (_this.props.schedule && typeof _this.props.schedule === 'string' && _this.props.schedule[0] === '{') {
200
- try {
201
- schedule = JSON.parse(_this.props.schedule);
202
- } catch (e) {
203
- // ignore
204
- }
205
- }
206
- if ((!schedule || !Object.keys(schedule).length) && _this.props.onChange) {
207
- setTimeout(function () {
208
- return _this.onChange(_this.state.schedule, true);
209
- }, 200);
210
- }
211
- schedule = schedule || {};
212
- schedule = _objectSpread(_objectSpread({}, DEFAULT), schedule);
213
- schedule.valid.from = schedule.valid.from || Schedule.now2string();
214
- _this.refFrom = /*#__PURE__*/_react["default"].createRef();
215
- _this.refTo = /*#__PURE__*/_react["default"].createRef();
216
- _this.refOnce = /*#__PURE__*/_react["default"].createRef();
217
- _this.state = {
218
- schedule: schedule,
219
- desc: Schedule.state2text(schedule)
220
- };
221
- if (JSON.stringify(schedule) !== _this.props.schedule) {
222
- setTimeout(function () {
223
- return _this.props.onChange && _this.props.onChange(JSON.stringify(schedule));
224
- }, 100);
225
+ const parts = date.split('.');
226
+ if (parts.length === 3) {
227
+ return `${parts[2]}-${parts[1]}-${parts[0]}`;
225
228
  }
226
- return _this;
227
- }
228
- (0, _createClass2["default"])(Schedule, [{
229
- key: "onChange",
230
- value: function onChange(schedule, force) {
231
- var isDiff = JSON.stringify(schedule) !== JSON.stringify(this.state.schedule);
232
- if (force || isDiff) {
233
- isDiff && this.setState({
234
- schedule: schedule,
235
- desc: Schedule.state2text(schedule)
236
- });
237
- var copy = JSON.parse(JSON.stringify(schedule));
238
- if (copy.period.once) {
239
- var once = copy.period.once;
240
- delete copy.period;
241
- copy.period = {
242
- once: once
243
- };
244
- delete copy.valid;
245
- } else if (copy.period.days) {
246
- var days = copy.period.days;
247
- var dows = copy.period.dows;
248
- delete copy.period;
249
- copy.period = {
250
- days: days
251
- };
252
- if (dows && dows !== '[]') {
253
- copy.period.dows = dows;
254
- }
255
- } else if (copy.period.weeks) {
256
- var weeks = copy.period.weeks;
257
- var _dows = copy.period.dows;
258
- delete copy.period;
259
- copy.period = {
260
- weeks: weeks
261
- };
262
- if (_dows && _dows !== '[]') {
263
- copy.period.dows = _dows;
264
- }
265
- } else if (copy.period.months) {
266
- var months = copy.period.months;
267
- var dates = copy.period.dates;
268
- delete copy.period;
269
- copy.period = {
270
- months: months
271
- };
272
- if (dates && dates !== '[]') {
273
- copy.period.dates = dates;
274
- }
275
- } else if (copy.period.years) {
276
- var years = copy.period.years;
277
- var yearMonth = copy.period.yearMonth;
278
- var yearDate = copy.period.yearDate;
279
- delete copy.period;
280
- copy.period = {
281
- years: years,
282
- yearDate: yearDate
283
- };
284
- if (yearMonth) {
285
- copy.period.yearMonth = yearMonth;
286
- }
287
- }
288
- if (copy.time.exactTime) {
289
- delete copy.time.end;
290
- delete copy.time.mode;
291
- delete copy.time.interval;
292
- } else {
293
- delete copy.time.exactTime;
294
- }
295
- if (copy.valid) {
296
- if (!copy.valid.to) {
297
- delete copy.valid.to;
298
- }
299
- if (copy.period.days === 1 || copy.period.weeks === 1 || copy.period.months === 1 || copy.period.years === 1) {
300
- var from = Schedule.string2date(copy.valid.from);
301
- var today = new Date();
302
- today.setHours(0);
303
- today.setMinutes(0);
304
- today.setSeconds(0);
305
- today.setMilliseconds(0);
306
- if (from <= today) {
307
- delete copy.valid.from;
308
- }
309
- }
310
- if (!copy.valid.from && !copy.valid.to) {
311
- delete copy.valid;
312
- }
313
- }
314
- this.props.onChange && this.props.onChange(JSON.stringify(copy), Schedule.state2text(schedule));
315
- }
316
- }
317
- }, {
318
- key: "getTimePeriodElements",
319
- value: function getTimePeriodElements() {
320
- var _this2 = this;
321
- var schedule = this.state.schedule;
322
- var wholeDay = false;
323
- var day = false;
324
- var night = false;
325
- var fromTo = true;
326
- if (schedule.time.start === '00:00' && schedule.time.end === '24:00') {
327
- wholeDay = true;
328
- fromTo = false;
329
- } else if (schedule.time.start === 'sunrise') {
330
- day = true;
331
- fromTo = false;
332
- } else if (schedule.time.start === 'sunset') {
333
- night = true;
334
- fromTo = false;
335
- }
336
- return /*#__PURE__*/_react["default"].createElement("div", {
337
- key: "timePeriod",
338
- className: this.props.classes.rowDiv
339
- }, /*#__PURE__*/_react["default"].createElement("div", {
340
- className: this.props.classes.modeDiv
341
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
342
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
343
- className: this.props.classes.inputRadio,
344
- checked: !schedule.time.exactTime,
345
- onClick: function onClick() {
346
- var _schedule = JSON.parse(JSON.stringify(_this2.state.schedule));
347
- _schedule.time.exactTime = false;
348
- _this2.onChange(_schedule);
349
- }
350
- }),
351
- label: _i18n["default"].t('sch_intervalTime')
352
- })), /*#__PURE__*/_react["default"].createElement("div", {
353
- className: this.props.classes.settingsDiv
354
- }, /*#__PURE__*/_react["default"].createElement("div", {
355
- className: this.props.classes.settingsDiv
356
- }, !schedule.time.exactTime && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
357
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
358
- className: this.props.classes.inputRadio,
359
- checked: !!fromTo,
360
- onClick: function onClick() {
361
- var _schedule = JSON.parse(JSON.stringify(_this2.state.schedule));
362
- _schedule.time.start = '00:00';
363
- _schedule.time.end = '23:59';
364
- _this2.onChange(_schedule);
365
- }
366
- }),
367
- label: !fromTo ? _i18n["default"].t('sch_fromTo') : ''
368
- }), fromTo && [/*#__PURE__*/_react["default"].createElement(_material.TextField, {
369
- variant: "standard",
370
- className: this.props.classes.inputTime,
371
- style: {
372
- marginRight: 10
373
- },
374
- key: "exactTimeFrom",
375
- type: "time",
376
- value: this.state.schedule.time.start
377
- // InputProps={{inputComponent: TextTime}}
378
- ,
379
- onChange: function onChange(e) {
380
- var _schedule = JSON.parse(JSON.stringify(_this2.state.schedule));
381
- _schedule.time.start = e.target.value;
382
- _this2.onChange(_schedule);
383
- },
384
- InputLabelProps: {
385
- shrink: true
386
- },
387
- label: _i18n["default"].t('sch_from'),
388
- margin: "normal"
389
- }), /*#__PURE__*/_react["default"].createElement(_material.TextField, {
390
- variant: "standard",
391
- className: this.props.classes.inputTime,
392
- key: "exactTimeTo",
393
- type: "time",
394
- value: this.state.schedule.time.end
395
- // InputProps={{inputComponent: TextTime}}
396
- ,
397
- onChange: function onChange(e) {
398
- var _schedule = JSON.parse(JSON.stringify(_this2.state.schedule));
399
- _schedule.time.end = e.target.value;
400
- _this2.onChange(_schedule);
401
- },
402
- InputLabelProps: {
403
- shrink: true
404
- },
405
- label: _i18n["default"].t('sch_to'),
406
- margin: "normal"
407
- })])), !schedule.time.exactTime && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
408
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
409
- className: this.props.classes.inputRadio,
410
- checked: !!wholeDay,
411
- onClick: function onClick() {
412
- var _schedule = JSON.parse(JSON.stringify(_this2.state.schedule));
413
- _schedule.time.start = '00:00';
414
- _schedule.time.end = '24:00';
415
- _this2.onChange(_schedule);
416
- }
417
- }),
418
- label: _i18n["default"].t('sch_wholeDay')
419
- })), !schedule.time.exactTime && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
420
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
421
- className: this.props.classes.inputRadio,
422
- checked: !!day,
423
- onClick: function onClick() {
424
- var _schedule = JSON.parse(JSON.stringify(_this2.state.schedule));
425
- _schedule.time.start = 'sunrise';
426
- _schedule.time.end = 'sunset';
427
- _this2.onChange(_schedule);
428
- }
429
- }),
430
- label: _i18n["default"].t('sch_astroDay')
431
- })), !schedule.time.exactTime && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
432
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
433
- className: this.props.classes.inputRadio,
434
- checked: !!night,
435
- onClick: function onClick() {
436
- var _schedule = JSON.parse(JSON.stringify(_this2.state.schedule));
437
- _schedule.time.start = 'sunset';
438
- _schedule.time.end = 'sunrise';
439
- _this2.onChange(_schedule);
440
- }
441
- }),
442
- label: _i18n["default"].t('sch_astroNight')
443
- }))), !schedule.time.exactTime && this.getPeriodSettingsMinutes()));
444
- }
445
- }, {
446
- key: "getTimeExactElements",
447
- value: function getTimeExactElements() {
448
- var _this3 = this;
449
- var isAstro = ASTRO.includes(this.state.schedule.time.start);
450
- return /*#__PURE__*/_react["default"].createElement("div", {
451
- key: "timeExact",
452
- className: this.props.classes.rowDiv
453
- }, /*#__PURE__*/_react["default"].createElement("div", {
454
- className: this.props.classes.modeDiv
455
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
456
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
457
- className: this.props.classes.inputRadio,
458
- checked: !!this.state.schedule.time.exactTime,
459
- onClick: function onClick() {
460
- var schedule = JSON.parse(JSON.stringify(_this3.state.schedule));
461
- schedule.time.exactTime = true;
462
- _this3.onChange(schedule);
463
- }
464
- }),
465
- label: _i18n["default"].t('sch_exactTime')
466
- })), this.state.schedule.time.exactTime && /*#__PURE__*/_react["default"].createElement(_material.Select, {
467
- variant: "standard",
468
- value: isAstro ? this.state.schedule.time.start : '00:00',
469
- onChange: function onChange(e) {
470
- var _schedule = JSON.parse(JSON.stringify(_this3.state.schedule));
471
- _schedule.time.start = e.target.value;
472
- _this3.onChange(_schedule);
473
- }
474
- }, /*#__PURE__*/_react["default"].createElement(_material.MenuItem, {
475
- key: "specific",
476
- value: "00:00"
477
- }, _i18n["default"].t('sch_specificTime')), ASTRO.map(function (event) {
478
- return /*#__PURE__*/_react["default"].createElement(_material.MenuItem, {
479
- key: event,
480
- value: event
481
- }, _i18n["default"].t("sch_astro_".concat(event)));
482
- })), this.state.schedule.time.exactTime && !isAstro && /*#__PURE__*/_react["default"].createElement("div", {
483
- className: this.props.classes.settingsDiv
484
- }, /*#__PURE__*/_react["default"].createElement(_material.TextField, {
485
- variant: "standard",
486
- className: this.props.classes.inputTime,
487
- key: "exactTimeValue",
488
- value: this.state.schedule.time.start,
489
- type: "time"
490
- // inputComponent={TextTime}
491
- ,
492
- onChange: function onChange(e) {
493
- var _schedule = JSON.parse(JSON.stringify(_this3.state.schedule));
494
- _schedule.time.start = e.target.value;
495
- _this3.onChange(_schedule);
496
- },
497
- InputLabelProps: {
498
- shrink: true
499
- },
500
- margin: "normal"
501
- })));
502
- }
503
- }, {
504
- key: "getDivider",
505
- value: function getDivider() {
506
- return /*#__PURE__*/_react["default"].createElement("hr", {
507
- className: this.props.classes.hr
508
- });
509
- }
510
- }, {
511
- key: "getPeriodModes",
512
- value: function getPeriodModes() {
513
- var _this4 = this;
514
- var schedule = this.state.schedule;
515
- var isOnce = !schedule.period.dows && !schedule.period.months && !schedule.period.dates && !schedule.period.years && !schedule.period.days && !schedule.period.weeks;
516
- if (isOnce && !schedule.period.once) {
517
- schedule.period.once = Schedule.now2string(true);
518
- }
519
- return [
520
- /*#__PURE__*/
521
- // ----- once ---
522
- _react["default"].createElement("div", {
523
- key: "once",
524
- className: "".concat(this.props.classes.rowDiv, " ").concat(this.props.classes.rowOnce)
525
- }, /*#__PURE__*/_react["default"].createElement("div", {
526
- className: this.props.classes.modeDiv
527
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
528
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
529
- className: this.props.classes.inputRadio,
530
- checked: !!isOnce,
531
- onClick: function onClick() {
532
- var _schedule = JSON.parse(JSON.stringify(_this4.state.schedule));
533
- _schedule.period.once = _schedule.period.once || Schedule.now2string(true);
534
- _schedule.period.dows = '';
535
- _schedule.period.months = '';
536
- _schedule.period.dates = '';
537
- _schedule.period.years = 0;
538
- _schedule.period.yearDate = 0;
539
- _schedule.period.yearMonth = 0;
540
- _schedule.period.weeks = 0;
541
- _schedule.period.days = 0;
542
- _this4.onChange(_schedule);
543
- }
544
- }),
545
- label: _i18n["default"].t('sch_periodOnce')
546
- })), isOnce && /*#__PURE__*/_react["default"].createElement("div", {
547
- className: this.props.classes.settingsDiv
548
- }, /*#__PURE__*/_react["default"].createElement(_material.TextField, {
549
- variant: "standard",
550
- className: this.props.classes.inputDate,
551
- type: "date",
552
- ref: this.refOnce,
553
- key: "exactDateAt",
554
- defaultValue: string2USdate(schedule.period.once)
555
- // InputProps={{inputComponent: TextTime}}
556
- ,
557
- onChange: function onChange(e) {
558
- _this4.timerOnce && clearTimeout(_this4.timerOnce);
559
- _this4.refOnce.current.style.background = '#ff000030';
560
- _this4.timerOnce = setTimeout(function (value) {
561
- _this4.timerOnce = null;
562
- _this4.refOnce.current.style.background = '';
563
- var _schedule = JSON.parse(JSON.stringify(_this4.state.schedule));
564
- var date = Schedule.string2date(value);
565
- if (date.toString() !== 'Invalid Date') {
566
- _schedule.period.once = "".concat(padding(date.getDate()), ".").concat(padding(date.getMonth() + 1), ".").concat(date.getFullYear());
567
- _this4.onChange(_schedule);
229
+ return '';
230
+ }
231
+ class Schedule extends react_1.Component {
232
+ constructor(props) {
233
+ super(props);
234
+ this.timerOnce = null;
235
+ this.timerFrom = null;
236
+ this.timerTo = null;
237
+ let schedule = undefined;
238
+ if (this.props.schedule && typeof this.props.schedule === 'string' && this.props.schedule[0] === '{') {
239
+ try {
240
+ schedule = JSON.parse(this.props.schedule);
568
241
  }
569
- }, 1500, e.target.value);
570
- },
571
- InputLabelProps: {
572
- shrink: true
573
- },
574
- label: _i18n["default"].t('sch_at'),
575
- margin: "normal"
576
- }))),
577
- /*#__PURE__*/
578
- // ----- days ---
579
- _react["default"].createElement("div", {
580
- key: "days",
581
- className: "".concat(this.props.classes.rowDiv, " ").concat(this.props.classes.rowDays)
582
- }, /*#__PURE__*/_react["default"].createElement("div", {
583
- className: this.props.classes.modeDiv
584
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
585
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
586
- className: this.props.classes.inputRadio,
587
- checked: !!schedule.period.days,
588
- onClick: function onClick() {
589
- var _schedule = JSON.parse(JSON.stringify(_this4.state.schedule));
590
- _schedule.period.days = 1;
591
- _schedule.period.dows = '';
592
- _schedule.period.months = '';
593
- _schedule.period.dates = '';
594
- _schedule.period.years = 0;
595
- _schedule.period.yearDate = 0;
596
- _schedule.period.yearMonth = 0;
597
- _schedule.period.weeks = 0;
598
- _schedule.period.once = '';
599
- _this4.onChange(_schedule);
600
- }
601
- }),
602
- label: _i18n["default"].t('sch_periodDaily')
603
- })), /*#__PURE__*/_react["default"].createElement("div", {
604
- className: this.props.classes.settingsDiv
605
- }, this.getPeriodSettingsDaily(), schedule.period.days ? this.getPeriodSettingsWeekdays() : null)),
606
- /*#__PURE__*/
607
- // ----- days of weeks ---
608
- /*
609
- !schedule.period.days && (
610
- <div key="dows" className={this.props.classes.rowDiv + ' ' + this.props.classes.rowDows}>
611
- <div className={this.props.classes.modeDiv}>
612
- <FormControlLabel control={<Radio className={this.props.classes.inputRadio} checked={!!schedule.period.dows} onClick={() => {
613
- const schedule = JSON.parse(JSON.stringify(this.state.schedule));
614
- schedule.period.dows = schedule.period.dows ? '' : '[0,1,2,3,4,5,6]';
615
- this.onChange(schedule);
616
- }}/>}
617
- label={I18n.t('sch_periodWeekdays')} />
618
- </div>
619
- <div className={this.props.classes.settingsDiv}>
620
- {this.getPeriodSettingsWeekdays()}
621
- </div>
622
- </div>,
623
- */
624
- // ----- weeks ---
625
- _react["default"].createElement("div", {
626
- key: "weeks",
627
- className: "".concat(this.props.classes.rowDiv, " ").concat(this.props.classes.rowDows)
628
- }, /*#__PURE__*/_react["default"].createElement("div", {
629
- className: this.props.classes.modeDiv
630
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
631
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
632
- className: this.props.classes.inputRadio,
633
- checked: !!schedule.period.weeks,
634
- onClick: function onClick() {
635
- var _schedule = JSON.parse(JSON.stringify(_this4.state.schedule));
636
- _schedule.period.weeks = schedule.period.weeks ? 0 : 1;
637
- _schedule.period.dows = schedule.period.dows || '[0]';
638
- _schedule.period.months = '';
639
- _schedule.period.dates = '';
640
- _schedule.period.years = 0;
641
- _schedule.period.yearDate = 0;
642
- _schedule.period.yearMonth = 0;
643
- _schedule.period.days = 0;
644
- _schedule.period.once = '';
645
- _this4.onChange(_schedule);
646
- }
647
- }),
648
- label: _i18n["default"].t('sch_periodWeekly')
649
- })), /*#__PURE__*/_react["default"].createElement("div", {
650
- className: this.props.classes.settingsDiv
651
- }, /*#__PURE__*/_react["default"].createElement("div", {
652
- className: this.props.classes.settingsDiv
653
- }, this.getPeriodSettingsWeekly()), /*#__PURE__*/_react["default"].createElement("div", {
654
- className: "".concat(this.props.classes.settingsDiv, " ").concat(this.props.classes.rowDowsDows)
655
- }, this.state.schedule.period.weeks ? this.getPeriodSettingsWeekdays() : null))),
656
- /*#__PURE__*/
657
- // ----- months ---
658
- _react["default"].createElement("div", {
659
- key: "months",
660
- className: "".concat(this.props.classes.rowDiv, " ").concat(this.props.classes.rowMonths)
661
- }, /*#__PURE__*/_react["default"].createElement("div", {
662
- className: this.props.classes.modeDiv
663
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
664
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
665
- className: this.props.classes.inputRadio,
666
- checked: !!schedule.period.months,
667
- onClick: function onClick() {
668
- var _schedule = JSON.parse(JSON.stringify(_this4.state.schedule));
669
- _schedule.period.months = 1;
670
- _schedule.period.dows = '';
671
- _schedule.period.dates = '';
672
- _schedule.period.years = 0;
673
- _schedule.period.yearDate = 0;
674
- _schedule.period.yearMonth = 0;
675
- _schedule.period.weeks = 0;
676
- _schedule.period.days = 0;
677
- _schedule.period.once = '';
678
- _this4.onChange(_schedule);
679
- }
680
- }),
681
- label: _i18n["default"].t('sch_periodMonthly')
682
- })), /*#__PURE__*/_react["default"].createElement("div", {
683
- className: this.props.classes.settingsDiv
684
- }, this.getPeriodSettingsMonthly(), schedule.period.months ? /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
685
- className: "".concat(this.props.classes.settingsDiv, " ").concat(this.props.classes.rowMonthsDates)
686
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
687
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
688
- className: this.props.classes.inputRadio,
689
- checked: !!schedule.period.dates,
690
- onClick: function onClick() {
691
- var _schedule = JSON.parse(JSON.stringify(_this4.state.schedule));
692
- _schedule.period.months = _schedule.period.months || 1;
693
- var dates = [];
694
- for (var i = 1; i <= 31; i++) {
695
- dates.push(i);
242
+ catch (e) {
243
+ // ignore
696
244
  }
697
- _schedule.period.dates = _schedule.period.dates || JSON.stringify(dates);
698
- _schedule.period.dows = '';
699
- _schedule.period.years = 0;
700
- _schedule.period.yearDate = 0;
701
- _schedule.period.yearMonth = 0;
702
- _schedule.period.weeks = 0;
703
- _schedule.period.days = 0;
704
- _schedule.period.once = '';
705
- _this4.onChange(_schedule);
706
- }
707
- }),
708
- label: _i18n["default"].t('sch_periodDates')
709
- })), /*#__PURE__*/_react["default"].createElement("div", {
710
- className: "".concat(this.props.classes.settingsDiv, " ").concat(this.props.classes.rowMonthsDates)
711
- }, this.getPeriodSettingsDates())) : null)),
712
- /*#__PURE__*/
713
- // ----- years ---
714
- _react["default"].createElement("div", {
715
- key: "years",
716
- className: "".concat(this.props.classes.rowDiv, " ").concat(this.props.classes.rowYears)
717
- }, /*#__PURE__*/_react["default"].createElement("div", {
718
- className: this.props.classes.modeDiv
719
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
720
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
721
- className: this.props.classes.inputRadio,
722
- checked: !!schedule.period.years,
723
- onClick: function onClick() {
724
- var _schedule = JSON.parse(JSON.stringify(_this4.state.schedule));
725
- _schedule.period.years = 1;
726
- _schedule.period.yearDate = 1;
727
- _schedule.period.yearMonth = 1;
728
- _schedule.period.dows = '';
729
- _schedule.period.months = 0;
730
- _schedule.period.dates = '';
731
- _schedule.period.weeks = 0;
732
- _schedule.period.days = 0;
733
- _schedule.period.once = '';
734
- _this4.onChange(_schedule);
735
- }
736
- }),
737
- label: _i18n["default"].t('sch_periodYearly')
738
- })), /*#__PURE__*/_react["default"].createElement("div", {
739
- className: this.props.classes.settingsDiv
740
- }, /*#__PURE__*/_react["default"].createElement("div", {
741
- className: this.props.classes.settingsDiv
742
- }, this.getPeriodSettingsYearly()), !!schedule.period.years && /*#__PURE__*/_react["default"].createElement("div", {
743
- className: this.props.classes.settingsDiv
744
- }, /*#__PURE__*/_react["default"].createElement("span", null, _i18n["default"].t('sch_on')), /*#__PURE__*/_react["default"].createElement(_material.Input, {
745
- key: "input",
746
- value: this.state.schedule.period.yearDate,
747
- className: this.props.classes.inputEvery,
748
- type: "number",
749
- min: 1,
750
- max: 31,
751
- onChange: function onChange(e) {
752
- var _schedule = JSON.parse(JSON.stringify(_this4.state.schedule));
753
- _schedule.period.yearDate = parseInt(e.target.value, 10);
754
- if (_schedule.period.yearDate < 1) _schedule.period.yearDate = 31;
755
- if (_schedule.period.yearDate > 31) _schedule.period.yearDate = 1;
756
- _this4.onChange(_schedule);
757
245
  }
758
- }), /*#__PURE__*/_react["default"].createElement(_material.Select, {
759
- variant: "standard",
760
- value: schedule.period.yearMonth,
761
- onChange: function onChange(e) {
762
- var _schedule = JSON.parse(JSON.stringify(_this4.state.schedule));
763
- _schedule.period.yearMonth = e.target.value;
764
- _this4.onChange(_schedule);
765
- }
766
- }, /*#__PURE__*/_react["default"].createElement(_material.MenuItem, {
767
- key: "every",
768
- value: 0
769
- }, _i18n["default"].t('sch_yearEveryMonth')), MONTHS.map(function (month, i) {
770
- return /*#__PURE__*/_react["default"].createElement(_material.MenuItem, {
771
- key: month,
772
- value: i + 1
773
- }, _i18n["default"].t(month));
774
- })))))];
775
- }
776
- }, {
777
- key: "getPeriodSettingsMinutes",
778
- value: function getPeriodSettingsMinutes() {
779
- var _this5 = this;
780
- return /*#__PURE__*/_react["default"].createElement("div", {
781
- style: {
782
- display: 'inline-block'
246
+ else if (typeof this.props.schedule === 'object') {
247
+ schedule = this.props.schedule;
783
248
  }
784
- }, /*#__PURE__*/_react["default"].createElement("label", null, _i18n["default"].t('sch_every')), /*#__PURE__*/_react["default"].createElement(_material.Input, {
785
- value: this.state.schedule.time.interval,
786
- style: {
787
- verticalAlign: 'bottom'
788
- },
789
- className: this.props.classes.inputEvery,
790
- type: "number",
791
- min: 1,
792
- onChange: function onChange(e) {
793
- var _schedule = JSON.parse(JSON.stringify(_this5.state.schedule));
794
- _schedule.time.interval = parseInt(e.target.value, 10);
795
- _this5.onChange(_schedule);
249
+ if ((!schedule || !Object.keys(schedule).length)) {
250
+ setTimeout(() => this.onChange(this.state.schedule, true), 200);
251
+ schedule = DEFAULT;
796
252
  }
797
- }), /*#__PURE__*/_react["default"].createElement(_material.Select, {
798
- variant: "standard",
799
- value: this.state.schedule.time.mode,
800
- onChange: function onChange(e) {
801
- var _schedule = JSON.parse(JSON.stringify(_this5.state.schedule));
802
- _schedule.time.mode = e.target.value;
803
- _this5.onChange(_schedule);
253
+ schedule = Object.assign(Object.assign({}, DEFAULT), schedule);
254
+ schedule.valid.from = schedule.valid.from || Schedule.now2string();
255
+ this.refFrom = react_1.default.createRef();
256
+ this.refTo = react_1.default.createRef();
257
+ this.refOnce = react_1.default.createRef();
258
+ this.state = {
259
+ schedule,
260
+ desc: Schedule.state2text(schedule),
261
+ };
262
+ if (JSON.stringify(schedule) !== this.props.schedule) {
263
+ setTimeout(() => this.props.onChange && this.props.onChange(JSON.stringify(schedule)), 100);
804
264
  }
805
- }, /*#__PURE__*/_react["default"].createElement(_material.MenuItem, {
806
- value: PERIODS.minutes
807
- }, _i18n["default"].t('sch_periodMinutes')), /*#__PURE__*/_react["default"].createElement(_material.MenuItem, {
808
- value: PERIODS.hours
809
- }, _i18n["default"].t('sch_periodHours'))));
810
265
  }
811
- }, {
812
- key: "getPeriodSettingsWeekdays",
813
- value: function getPeriodSettingsWeekdays() {
814
- var _this6 = this;
815
- // || this.state.schedule.period.dows === '[1, 2, 3, 4, 5]' || this.state.schedule.period.dows === '[0, 6]'
816
- var schedule = this.state.schedule;
817
- var isSpecific = schedule.period.dows && schedule.period.dows !== '[1, 2, 3, 4, 5]' && schedule.period.dows !== '[0, 6]';
818
- return [/*#__PURE__*/_react["default"].createElement("div", {
819
- key: "workdays"
820
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
821
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
822
- className: this.props.classes.inputRadio,
823
- checked: schedule.period.dows === '[1, 2, 3, 4, 5]',
824
- onClick: function onClick() {
825
- var _schedule = JSON.parse(JSON.stringify(_this6.state.schedule));
826
- _schedule.period.dows = '[1, 2, 3, 4, 5]';
827
- if (_schedule.period.days) {
828
- _schedule.period.days = 1;
266
+ onChange(schedule, force) {
267
+ const isDiff = JSON.stringify(schedule) !== JSON.stringify(this.state.schedule);
268
+ if (force || isDiff) {
269
+ isDiff && this.setState({ schedule, desc: Schedule.state2text(schedule) });
270
+ const copy = JSON.parse(JSON.stringify(schedule));
271
+ if (copy.period.once) {
272
+ const once = copy.period.once;
273
+ delete copy.period;
274
+ copy.period = { once };
275
+ delete copy.valid;
829
276
  }
830
- _this6.onChange(_schedule);
831
- }
832
- }),
833
- label: _i18n["default"].t('sch_periodWorkdays')
834
- })), /*#__PURE__*/_react["default"].createElement("div", {
835
- key: "weekend"
836
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
837
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
838
- className: this.props.classes.inputRadio,
839
- checked: schedule.period.dows === '[0, 6]',
840
- onClick: function onClick() {
841
- var _schedule = JSON.parse(JSON.stringify(_this6.state.schedule));
842
- _schedule.period.dows = '[0, 6]';
843
- if (_schedule.period.days) {
844
- _schedule.period.days = 1;
277
+ else if (copy.period.days) {
278
+ const days = copy.period.days;
279
+ const daysOfWeek = copy.period.dows;
280
+ delete copy.period;
281
+ copy.period = { days };
282
+ if (daysOfWeek && daysOfWeek !== '[]') {
283
+ copy.period.dows = daysOfWeek;
284
+ }
845
285
  }
846
- _this6.onChange(_schedule);
847
- }
848
- }),
849
- label: _i18n["default"].t('sch_periodWeekend')
850
- })), /*#__PURE__*/_react["default"].createElement("div", {
851
- key: "specific",
852
- style: {
853
- verticalAlign: 'top'
854
- }
855
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
856
- style: {
857
- verticalAlign: 'top'
858
- },
859
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
860
- className: this.props.classes.inputRadio,
861
- checked: !!isSpecific,
862
- onClick: function onClick() {
863
- var _schedule = JSON.parse(JSON.stringify(_this6.state.schedule));
864
- _schedule.period.dows = '[0,1,2,3,4,5,6]';
865
- if (_schedule.period.days) {
866
- _schedule.period.days = 1;
286
+ else if (copy.period.weeks) {
287
+ const weeks = copy.period.weeks;
288
+ const daysOfWeek = copy.period.dows;
289
+ delete copy.period;
290
+ copy.period = { weeks };
291
+ if (daysOfWeek && daysOfWeek !== '[]') {
292
+ copy.period.dows = daysOfWeek;
293
+ }
867
294
  }
868
- _this6.onChange(_schedule);
869
- }
870
- }),
871
- label: _i18n["default"].t('sch_periodWeekdays')
872
- }), isSpecific && (schedule.period.days === 1 || schedule.period.weeks) && /*#__PURE__*/_react["default"].createElement(_material.FormGroup, {
873
- row: true,
874
- className: this.props.classes.inputGroup,
875
- style: {
876
- width: 150
877
- }
878
- }, [1, 2, 3, 4, 5, 6, 0].map(function (i) {
879
- return /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
880
- key: "specific_".concat(i),
881
- className: _this6.props.classes.inputGroupElement,
882
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
883
- className: _this6.props.classes.inputSmallCheck,
884
- checked: schedule.period.dows.includes(i.toString()),
885
- onChange: function onChange(e) {
886
- var _schedule = JSON.parse(JSON.stringify(_this6.state.schedule));
887
- var dows;
888
- try {
889
- dows = JSON.parse(_schedule.period.dows);
890
- } catch (err) {
891
- dows = [];
892
- }
893
- if (e.target.checked && !dows.includes(i)) {
894
- dows.push(i);
895
- } else if (!e.target.checked && dows.includes(i)) {
896
- dows.splice(dows.indexOf(i), 1);
897
- }
898
- dows.sort(function (a, b) {
899
- return a - b;
900
- });
901
- _schedule.period.dows = JSON.stringify(dows);
902
- if (_schedule.period.days) {
903
- _schedule.period.days = 1;
904
- }
905
- _this6.onChange(_schedule);
295
+ else if (copy.period.months) {
296
+ const months = copy.period.months;
297
+ const dates = copy.period.dates;
298
+ delete copy.period;
299
+ copy.period = { months };
300
+ if (dates && dates !== '[]') {
301
+ copy.period.dates = dates;
302
+ }
906
303
  }
907
- }),
908
- label: _i18n["default"].t(WEEKDAYS[i])
909
- });
910
- })))];
911
- }
912
- }, {
913
- key: "getPeriodSettingsDaily",
914
- value: function getPeriodSettingsDaily() {
915
- var _this7 = this;
916
- if (!this.state.schedule.period.days) {
917
- return null;
918
- }
919
- var schedule = this.state.schedule;
920
- return [/*#__PURE__*/_react["default"].createElement("div", {
921
- key: "every_day"
922
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
923
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
924
- className: this.props.classes.inputRadio,
925
- checked: schedule.period.days === 1 && !schedule.period.dows,
926
- onClick: function onClick() {
927
- var _schedule = JSON.parse(JSON.stringify(_this7.state.schedule));
928
- _schedule.period.days = 1;
929
- _schedule.period.dows = '';
930
- _this7.onChange(_schedule);
931
- }
932
- }),
933
- label: _i18n["default"].t('sch_periodEveryDay')
934
- })), /*#__PURE__*/_react["default"].createElement("div", {
935
- key: "everyN_day"
936
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
937
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
938
- className: this.props.classes.inputRadio,
939
- checked: schedule.period.days > 1,
940
- onClick: function onClick() {
941
- var _schedule = JSON.parse(JSON.stringify(_this7.state.schedule));
942
- _schedule.period.days = 2;
943
- _schedule.period.dows = '';
944
- _this7.onChange(_schedule);
945
- }
946
- }),
947
- label: _i18n["default"].t('sch_periodEvery')
948
- }), schedule.period.days > 1 && [/*#__PURE__*/_react["default"].createElement(_material.Input, {
949
- key: "input",
950
- value: this.state.schedule.period.days,
951
- className: this.props.classes.inputEvery,
952
- type: "number",
953
- min: 2,
954
- onChange: function onChange(e) {
955
- var _schedule = JSON.parse(JSON.stringify(_this7.state.schedule));
956
- _schedule.period.days = parseInt(e.target.value, 10);
957
- _schedule.period.dows = '';
958
- _this7.onChange(_schedule);
959
- }
960
- }), /*#__PURE__*/_react["default"].createElement("span", {
961
- key: "span",
962
- style: {
963
- paddingRight: 10
304
+ else if (copy.period.years) {
305
+ const years = copy.period.years;
306
+ const yearMonth = copy.period.yearMonth;
307
+ const yearDate = copy.period.yearDate;
308
+ delete copy.period;
309
+ copy.period = { years, yearDate };
310
+ if (yearMonth) {
311
+ copy.period.yearMonth = yearMonth;
312
+ }
313
+ }
314
+ if (copy.time.exactTime) {
315
+ delete copy.time.end;
316
+ delete copy.time.mode;
317
+ delete copy.time.interval;
318
+ }
319
+ else {
320
+ delete copy.time.exactTime;
321
+ }
322
+ if (copy.valid) {
323
+ if (!copy.valid.to) {
324
+ delete copy.valid.to;
325
+ }
326
+ if (copy.period.days === 1 || copy.period.weeks === 1 || copy.period.months === 1 || copy.period.years === 1) {
327
+ const from = Schedule.string2date(copy.valid.from);
328
+ const today = new Date();
329
+ today.setHours(0);
330
+ today.setMinutes(0);
331
+ today.setSeconds(0);
332
+ today.setMilliseconds(0);
333
+ if (from <= today) {
334
+ delete copy.valid.from;
335
+ }
336
+ }
337
+ if (!copy.valid.from && !copy.valid.to) {
338
+ delete copy.valid;
339
+ }
340
+ }
341
+ this.props.onChange && this.props.onChange(JSON.stringify(copy), Schedule.state2text(schedule));
964
342
  }
965
- }, _i18n["default"].t('sch_periodDay'))])];
966
343
  }
967
- }, {
968
- key: "getPeriodSettingsWeekly",
969
- value: function getPeriodSettingsWeekly() {
970
- var _this8 = this;
971
- if (!this.state.schedule.period.weeks) {
972
- return null;
973
- }
974
- var schedule = this.state.schedule;
975
- return [/*#__PURE__*/_react["default"].createElement("div", {
976
- key: "radios",
977
- style: {
978
- display: 'inline-block',
979
- verticalAlign: 'top'
344
+ static state2text(schedule) {
345
+ if (typeof schedule === 'string') {
346
+ try {
347
+ schedule = JSON.parse(schedule);
348
+ }
349
+ catch (e) {
350
+ return '';
351
+ }
980
352
  }
981
- }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
982
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
983
- className: this.props.classes.inputRadio,
984
- checked: schedule.period.weeks === 1,
985
- onClick: function onClick() {
986
- var _schedule = JSON.parse(JSON.stringify(_this8.state.schedule));
987
- _schedule.period.weeks = 1;
988
- _this8.onChange(_schedule);
989
- }
990
- }),
991
- label: _i18n["default"].t('sch_periodEveryWeek')
992
- })), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
993
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
994
- className: this.props.classes.inputRadio,
995
- checked: schedule.period.weeks > 1,
996
- onClick: function onClick() {
997
- var _schedule = JSON.parse(JSON.stringify(_this8.state.schedule));
998
- _schedule.period.weeks = 2;
999
- _this8.onChange(_schedule);
1000
- }
1001
- }),
1002
- label: _i18n["default"].t('sch_periodEvery')
1003
- }), schedule.period.weeks > 1 && [/*#__PURE__*/_react["default"].createElement(_material.Input, {
1004
- key: "input",
1005
- value: this.state.schedule.period.weeks,
1006
- className: this.props.classes.inputEvery,
1007
- type: "number",
1008
- min: 2,
1009
- onChange: function onChange(e) {
1010
- var _schedule = JSON.parse(JSON.stringify(_this8.state.schedule));
1011
- _schedule.period.weeks = parseInt(e.target.value, 10);
1012
- _this8.onChange(_schedule);
353
+ const desc = [];
354
+ const validFrom = Schedule.string2date(schedule.valid.from);
355
+ if (schedule.period.once) {
356
+ // once
357
+ const once = Schedule.string2date(schedule.period.once);
358
+ const now = new Date();
359
+ now.setMilliseconds(0);
360
+ now.setSeconds(0);
361
+ now.setMinutes(0);
362
+ now.setHours(0);
363
+ //
364
+ if (once < now) {
365
+ // will be not executed anymore, because start is in the past
366
+ return i18n_1.default.t('sch_desc_onceInPast');
367
+ }
368
+ // only once
369
+ desc.push(i18n_1.default.t('sch_desc_once_on', schedule.period.once));
1013
370
  }
1014
- }), /*#__PURE__*/_react["default"].createElement("span", {
1015
- key: "text"
1016
- }, _i18n["default"].t('sch_periodWeek'))]))];
1017
- }
1018
- }, {
1019
- key: "getPeriodSettingsDates",
1020
- value: function getPeriodSettingsDates() {
1021
- var _this9 = this;
1022
- if (!this.state.schedule.period.dates) {
1023
- return null;
1024
- }
1025
- var schedule = this.state.schedule;
1026
- var dates = [];
1027
- for (var i = 1; i <= 31; i++) {
1028
- dates.push(i);
1029
- }
1030
- var parsedDates = JSON.parse(schedule.period.dates);
1031
- return /*#__PURE__*/_react["default"].createElement(_material.FormGroup, {
1032
- row: true,
1033
- className: this.props.classes.inputGroup,
1034
- style: {
1035
- maxWidth: 620
371
+ else if (schedule.period.days) {
372
+ if (schedule.period.days === 1) {
373
+ if (schedule.period.dows) {
374
+ const daysOfWeek = JSON.parse(schedule.period.dows);
375
+ if (daysOfWeek.length === 2 && daysOfWeek[0] === 0 && daysOfWeek[1] === 6) {
376
+ // on weekends
377
+ desc.push(i18n_1.default.t('sch_desc_onWeekends'));
378
+ }
379
+ else if (daysOfWeek.length === 5 && daysOfWeek[0] === 1 && daysOfWeek[1] === 2 && daysOfWeek[2] === 3 && daysOfWeek[3] === 4 && daysOfWeek[4] === 5) {
380
+ // on workdays
381
+ desc.push(i18n_1.default.t('sch_desc_onWorkdays'));
382
+ }
383
+ else {
384
+ const tDows = daysOfWeek.map((day) => i18n_1.default.t(WEEKDAYS[day]));
385
+ if (tDows.length === 1) {
386
+ // on Monday
387
+ desc.push(i18n_1.default.t('sch_desc_onWeekday', tDows[0]));
388
+ }
389
+ else if (tDows.length === 7) {
390
+ // on every day
391
+ desc.push(i18n_1.default.t('sch_desc_everyDay'));
392
+ }
393
+ else {
394
+ const last = tDows.pop();
395
+ // on Monday and Sunday
396
+ desc.push(i18n_1.default.t('sch_desc_onWeekdays', tDows.join(', '), last));
397
+ }
398
+ }
399
+ }
400
+ else {
401
+ desc.push(i18n_1.default.t('sch_desc_everyDay'));
402
+ }
403
+ }
404
+ else {
405
+ desc.push(i18n_1.default.t('sch_desc_everyNDay', schedule.period.days.toString()));
406
+ }
1036
407
  }
1037
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1038
- className: this.props.classes.inputDateDay,
1039
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
1040
- className: this.props.classes.inputDateDayCheck,
1041
- checked: parsedDates.length === 31,
1042
- onChange: function onChange() {
1043
- var _schedule = JSON.parse(JSON.stringify(_this9.state.schedule));
1044
- var _dates = [];
1045
- for (var _i = 1; _i <= 31; _i++) {
1046
- _dates.push(_i);
408
+ else if (schedule.period.weeks) {
409
+ if (schedule.period.weeks === 1) {
410
+ desc.push(i18n_1.default.t('sch_desc_everyWeek'));
1047
411
  }
1048
- _schedule.period.dates = JSON.stringify(_dates);
1049
- _this9.onChange(_schedule);
1050
- }
1051
- }),
1052
- label: _i18n["default"].t('sch_all')
1053
- }), /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1054
- className: this.props.classes.inputDateDay,
1055
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
1056
- className: this.props.classes.inputDateDayCheck,
1057
- checked: !parsedDates.length,
1058
- onChange: function onChange() {
1059
- var _schedule = JSON.parse(JSON.stringify(_this9.state.schedule));
1060
- _schedule.period.dates = '[]';
1061
- _this9.onChange(_schedule);
1062
- }
1063
- }),
1064
- label: _i18n["default"].t('sch_no_one')
1065
- }), parsedDates.length !== 31 && !!parsedDates.length && /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1066
- className: this.props.classes.inputDateDay,
1067
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
1068
- className: this.props.classes.inputDateDayCheck,
1069
- checked: false,
1070
- onChange: function onChange() {
1071
- var _schedule = JSON.parse(JSON.stringify(_this9.state.schedule));
1072
- var result = [];
1073
- var _parsedDates = JSON.parse(_schedule.period.dates);
1074
- for (var _i2 = 1; _i2 <= 31; _i2++) {
1075
- if (!_parsedDates.includes(_i2)) {
1076
- result.push(_i2);
1077
- }
412
+ else {
413
+ desc.push(i18n_1.default.t('sch_desc_everyNWeeks', schedule.period.weeks.toString()));
1078
414
  }
1079
- result.sort(function (a, b) {
1080
- return a - b;
1081
- });
1082
- _schedule.period.dates = JSON.stringify(result);
1083
- _this9.onChange(_schedule);
1084
- }
1085
- }),
1086
- label: _i18n["default"].t('sch_invert')
1087
- }), /*#__PURE__*/_react["default"].createElement("div", null), dates.map(function (i) {
1088
- return /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1089
- key: "date_".concat(i),
1090
- className: _this9.props.classes.inputDateDay,
1091
- style: !i ? {
1092
- opacity: 0,
1093
- cursor: 'default',
1094
- userSelect: 'none',
1095
- pointerEvents: 'none'
1096
- } : {},
1097
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
1098
- className: _this9.props.classes.inputDateDayCheck,
1099
- checked: JSON.parse(schedule.period.dates).includes(i),
1100
- onChange: function onChange(e) {
1101
- var _schedule = JSON.parse(JSON.stringify(_this9.state.schedule));
1102
- var _dates;
1103
- try {
1104
- _dates = JSON.parse(_schedule.period.dates);
1105
- } catch (err) {
1106
- _dates = [];
1107
- }
1108
- if (e.target.checked && !_dates.includes(i)) {
1109
- _dates.push(i);
1110
- } else if (!e.target.checked && _dates.includes(i)) {
1111
- _dates.splice(_dates.indexOf(i), 1);
1112
- }
1113
- _dates.sort(function (a, b) {
1114
- return a - b;
1115
- });
1116
- _schedule.period.dates = JSON.stringify(_dates);
1117
- _this9.onChange(_schedule);
415
+ if (schedule.period.dows) {
416
+ const daysOfWeek = JSON.parse(schedule.period.dows);
417
+ if (daysOfWeek.length === 2 && daysOfWeek[0] === 0 && daysOfWeek[1] === 6) {
418
+ // on weekends
419
+ desc.push(i18n_1.default.t('sch_desc_onWeekends'));
420
+ }
421
+ else if (daysOfWeek.length === 5 && daysOfWeek[0] === 1 && daysOfWeek[1] === 2 && daysOfWeek[2] === 3 && daysOfWeek[3] === 4 && daysOfWeek[4] === 5) {
422
+ // on workdays
423
+ desc.push(i18n_1.default.t('sch_desc_onWorkdays'));
424
+ }
425
+ else {
426
+ const tDows = daysOfWeek.map((day) => i18n_1.default.t(WEEKDAYS[day]));
427
+ if (tDows.length === 1) {
428
+ // on Monday
429
+ desc.push(i18n_1.default.t('sch_desc_onWeekday', tDows[0]));
430
+ }
431
+ else if (tDows.length === 7) {
432
+ // on every day
433
+ desc.push(i18n_1.default.t('sch_desc_everyDay'));
434
+ }
435
+ else {
436
+ const last = tDows.pop();
437
+ // on Monday and Sunday
438
+ desc.push(i18n_1.default.t('sch_desc_onWeekdays', tDows.join(', '), last));
439
+ }
440
+ }
1118
441
  }
1119
- }),
1120
- label: i < 10 ? [/*#__PURE__*/_react["default"].createElement("span", {
1121
- key: "0",
1122
- style: {
1123
- opacity: 0
442
+ else {
443
+ return i18n_1.default.t('sch_desc_never');
1124
444
  }
1125
- }, "0"), /*#__PURE__*/_react["default"].createElement("span", {
1126
- key: "num"
1127
- }, i)] : i
1128
- });
1129
- }));
1130
- }
1131
- }, {
1132
- key: "getPeriodSettingsMonthly",
1133
- value: function getPeriodSettingsMonthly() {
1134
- var _this10 = this;
1135
- if (!this.state.schedule.period.months) {
1136
- return null;
1137
- }
1138
- var schedule = this.state.schedule;
1139
- var parsedMonths = typeof schedule.period.months === 'string' ? JSON.parse(schedule.period.months) : [];
1140
- return [/*#__PURE__*/_react["default"].createElement("div", {
1141
- key: "every"
1142
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1143
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
1144
- className: this.props.classes.inputRadio,
1145
- checked: typeof schedule.period.months === 'number' && schedule.period.months === 1,
1146
- onClick: function onClick() {
1147
- var _schedule = JSON.parse(JSON.stringify(_this10.state.schedule));
1148
- _schedule.period.months = 1;
1149
- _this10.onChange(schedule);
1150
- }
1151
- }),
1152
- label: _i18n["default"].t('sch_periodEveryMonth')
1153
- })), /*#__PURE__*/_react["default"].createElement("div", {
1154
- key: "everyN"
1155
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1156
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
1157
- className: this.props.classes.inputRadio,
1158
- checked: typeof schedule.period.months === 'number' && schedule.period.months > 1,
1159
- onClick: function onClick() {
1160
- var _schedule = JSON.parse(JSON.stringify(_this10.state.schedule));
1161
- _schedule.period.months = 2;
1162
- _this10.onChange(_schedule);
1163
- }
1164
- }),
1165
- label: _i18n["default"].t('sch_periodEvery')
1166
- }), typeof schedule.period.months === 'number' && schedule.period.months > 1 && [/*#__PURE__*/_react["default"].createElement(_material.Input, {
1167
- key: "input",
1168
- value: schedule.period.months,
1169
- className: this.props.classes.inputEvery,
1170
- type: "number",
1171
- min: 2,
1172
- onChange: function onChange(e) {
1173
- var _schedule = JSON.parse(JSON.stringify(_this10.state.schedule));
1174
- _schedule.period.months = parseInt(e.target.value, 10);
1175
- if (_schedule.period.months < 1) _schedule.period.months = 1;
1176
- _this10.onChange(_schedule);
1177
- }
1178
- }), /*#__PURE__*/_react["default"].createElement("span", {
1179
- key: "text"
1180
- }, _i18n["default"].t('sch_periodMonth'))]), /*#__PURE__*/_react["default"].createElement("div", {
1181
- key: "specific",
1182
- style: {
1183
- verticalAlign: 'top'
1184
445
  }
1185
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1186
- style: {
1187
- verticalAlign: 'top'
1188
- },
1189
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
1190
- className: this.props.classes.inputRadio,
1191
- checked: typeof schedule.period.months === 'string',
1192
- onClick: function onClick() {
1193
- var _schedule = JSON.parse(JSON.stringify(_this10.state.schedule));
1194
- _schedule.period.months = '[1,2,3,4,5,6,7,8,9,10,11,12]';
1195
- _this10.onChange(_schedule);
1196
- }
1197
- }),
1198
- label: _i18n["default"].t('sch_periodSpecificMonths')
1199
- }), typeof schedule.period.months === 'string' && /*#__PURE__*/_react["default"].createElement(_material.FormGroup, {
1200
- row: true,
1201
- className: this.props.classes.inputGroup
1202
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1203
- className: this.props.classes.inputDateDay,
1204
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
1205
- className: this.props.classes.inputDateDayCheck,
1206
- checked: parsedMonths.length === 12,
1207
- onChange: function onChange() {
1208
- var _schedule = JSON.parse(JSON.stringify(_this10.state.schedule));
1209
- var months = [];
1210
- for (var i = 1; i <= 12; i++) {
1211
- months.push(i);
446
+ else if (schedule.period.months) {
447
+ if (schedule.period.dates) {
448
+ const dates = JSON.parse(schedule.period.dates);
449
+ if (dates.length === 1) {
450
+ // in 1 of month
451
+ desc.push(i18n_1.default.t('sch_desc_onDate', dates[0]));
452
+ }
453
+ else if (dates.length === 31) {
454
+ desc.push(i18n_1.default.t('sch_desc_onEveryDate'));
455
+ }
456
+ else if (!dates.length) {
457
+ return i18n_1.default.t('sch_desc_never');
458
+ }
459
+ else {
460
+ const last = dates.pop();
461
+ // in 1 and 4 of month
462
+ desc.push(i18n_1.default.t('sch_desc_onDates', dates.join(', '), last));
463
+ }
1212
464
  }
1213
- _schedule.period.months = JSON.stringify(months);
1214
- _this10.onChange(_schedule);
1215
- }
1216
- }),
1217
- label: _i18n["default"].t('sch_all')
1218
- }), /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1219
- className: this.props.classes.inputDateDay,
1220
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
1221
- className: this.props.classes.inputDateDayCheck,
1222
- checked: !parsedMonths.length,
1223
- onChange: function onChange() {
1224
- var _schedule = JSON.parse(JSON.stringify(_this10.state.schedule));
1225
- _schedule.period.months = '[]';
1226
- _this10.onChange(_schedule);
1227
- }
1228
- }),
1229
- label: _i18n["default"].t('sch_no_one')
1230
- }), parsedMonths.length !== 12 && !!parsedMonths.length && /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1231
- className: this.props.classes.inputDateDay,
1232
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
1233
- className: this.props.classes.inputDateDayCheck,
1234
- checked: false,
1235
- onChange: function onChange() {
1236
- var _schedule = JSON.parse(JSON.stringify(_this10.state.schedule));
1237
- var result = [];
1238
- var _parsedMonths = JSON.parse(_schedule.period.months);
1239
- for (var i = 1; i <= 12; i++) {
1240
- if (!_parsedMonths.includes(i)) {
1241
- result.push(i);
1242
- }
465
+ else {
466
+ desc.push(i18n_1.default.t('sch_desc_onEveryDate'));
1243
467
  }
1244
- result.sort(function (a, b) {
1245
- return a - b;
1246
- });
1247
- _schedule.period.months = JSON.stringify(result);
1248
- _this10.onChange(_schedule);
1249
- }
1250
- }),
1251
- label: _i18n["default"].t('sch_invert')
1252
- }), /*#__PURE__*/_react["default"].createElement("div", null), MONTHS.map(function (month, i) {
1253
- return /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1254
- className: _this10.props.classes.inputGroupElement,
1255
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
1256
- className: _this10.props.classes.inputSmallCheck,
1257
- checked: JSON.parse(schedule.period.months).includes(i + 1),
1258
- onChange: function onChange(e) {
1259
- var _schedule = JSON.parse(JSON.stringify(_this10.state.schedule));
1260
- var months;
1261
- try {
1262
- months = JSON.parse(_schedule.period.months);
1263
- } catch (err) {
1264
- months = [];
1265
- }
1266
- if (e.target.checked && !months.includes(i + 1)) {
1267
- months.push(i + 1);
1268
- } else if (!e.target.checked && months.includes(i + 1)) {
1269
- months.splice(months.indexOf(i + 1), 1);
1270
- }
1271
- months.sort(function (a, b) {
1272
- return a - b;
1273
- });
1274
- _schedule.period.months = JSON.stringify(months);
1275
- _this10.onChange(_schedule);
468
+ if (schedule.period.months === 1) {
469
+ desc.push(i18n_1.default.t('sch_desc_everyMonth'));
470
+ }
471
+ else if (typeof schedule.period.months === 'number') {
472
+ desc.push(i18n_1.default.t('sch_desc_everyNMonths', schedule.period.months.toString()));
473
+ }
474
+ else {
475
+ const months = JSON.parse(schedule.period.months);
476
+ const tMonths = months.map((month) => i18n_1.default.t(MONTHS[month - 1]));
477
+ if (!tMonths.length) {
478
+ // in January
479
+ return i18n_1.default.t('sch_desc_never');
480
+ }
481
+ if (tMonths.length === 1) {
482
+ // in January
483
+ desc.push(i18n_1.default.t('sch_desc_onMonth', tMonths[0]));
484
+ }
485
+ else if (tMonths.length === 12) {
486
+ // every month
487
+ desc.push(i18n_1.default.t('sch_desc_everyMonth'));
488
+ }
489
+ else {
490
+ const last = tMonths.pop();
491
+ // in January and May
492
+ desc.push(i18n_1.default.t('sch_desc_onMonths', tMonths.join(', '), last));
493
+ }
1276
494
  }
1277
- }),
1278
- label: _i18n["default"].t(month)
1279
- });
1280
- })))];
1281
- }
1282
- }, {
1283
- key: "getPeriodSettingsYearly",
1284
- value: function getPeriodSettingsYearly() {
1285
- var _this11 = this;
1286
- if (!this.state.schedule.period.years) {
1287
- return null;
1288
- }
1289
- var schedule = this.state.schedule;
1290
- return [/*#__PURE__*/_react["default"].createElement("div", {
1291
- key: "year"
1292
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1293
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
1294
- className: this.props.classes.inputRadio,
1295
- checked: schedule.period.years === 1,
1296
- onClick: function onClick() {
1297
- var _schedule = JSON.parse(JSON.stringify(_this11.state.schedule));
1298
- _schedule.period.years = 1;
1299
- _this11.onChange(_schedule);
1300
- }
1301
- }),
1302
- label: _i18n["default"].t('sch_periodEveryYear')
1303
- })), /*#__PURE__*/_react["default"].createElement("div", {
1304
- key: "every"
1305
- }, /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1306
- control: /*#__PURE__*/_react["default"].createElement(_material.Radio, {
1307
- className: this.props.classes.inputRadio,
1308
- checked: schedule.period.years > 1,
1309
- onClick: function onClick() {
1310
- var _schedule = JSON.parse(JSON.stringify(_this11.state.schedule));
1311
- _schedule.period.years = 2;
1312
- _this11.onChange(_schedule);
1313
- }
1314
- }),
1315
- label: _i18n["default"].t('sch_periodEvery')
1316
- }), schedule.period.years > 1 && [/*#__PURE__*/_react["default"].createElement(_material.Input, {
1317
- key: "input",
1318
- value: this.state.schedule.period.years,
1319
- className: this.props.classes.inputEvery,
1320
- type: "number",
1321
- min: 2,
1322
- onChange: function onChange(e) {
1323
- var _schedule = JSON.parse(JSON.stringify(_this11.state.schedule));
1324
- _schedule.period.years = parseInt(e.target.value, 10);
1325
- if (_schedule.period.years < 1) _schedule.period.years = 1;
1326
- _this11.onChange(_schedule);
1327
495
  }
1328
- }), /*#__PURE__*/_react["default"].createElement("span", {
1329
- key: "text"
1330
- }, _i18n["default"].t('sch_periodYear'))])];
1331
- }
1332
- }, {
1333
- key: "getValidSettings",
1334
- value: function getValidSettings() {
1335
- var _this12 = this;
1336
- var schedule = this.state.schedule;
1337
- // ----- from ---
1338
- return /*#__PURE__*/_react["default"].createElement("div", {
1339
- className: this.props.classes.rowDiv
1340
- }, /*#__PURE__*/_react["default"].createElement("div", {
1341
- className: this.props.classes.modeDiv,
1342
- style: {
1343
- verticalAlign: 'middle'
496
+ else if (schedule.period.years) {
497
+ if (schedule.period.years === 1) {
498
+ desc.push(i18n_1.default.t('sch_desc_everyYear'));
499
+ }
500
+ else {
501
+ desc.push(i18n_1.default.t('sch_desc_everyNYears', schedule.period.years.toString()));
502
+ }
503
+ desc.push(i18n_1.default.t('sch_desc_onDate', schedule.period.yearDate.toString(), schedule.period.yearMonth ? i18n_1.default.t(MONTHS[schedule.period.yearMonth - 1]) : i18n_1.default.t('sch_desc_everyMonth')));
1344
504
  }
1345
- }, /*#__PURE__*/_react["default"].createElement("span", {
1346
- style: {
1347
- fontWeight: 'bold',
1348
- paddingRight: 10
505
+ // time
506
+ if (schedule.time.exactTime) {
507
+ if (ASTRO.indexOf(schedule.time.start) !== -1) {
508
+ // at sunset
509
+ desc.push(i18n_1.default.t('sch_desc_atTime', i18n_1.default.t(`sch_astro_${schedule.time.start}`)));
510
+ }
511
+ else {
512
+ // at HH:MM
513
+ desc.push(i18n_1.default.t('sch_desc_atTime', schedule.time.start));
514
+ }
1349
515
  }
1350
- }, _i18n["default"].t('sch_valid')), /*#__PURE__*/_react["default"].createElement("span", null, _i18n["default"].t('sch_validFrom'))), /*#__PURE__*/_react["default"].createElement("div", {
1351
- className: this.props.classes.settingsDiv
1352
- }, /*#__PURE__*/_react["default"].createElement(_material.TextField, {
1353
- variant: "standard",
1354
- className: this.props.classes.inputDate,
1355
- style: {
1356
- marginRight: 10
1357
- },
1358
- key: "exactTimeFrom",
1359
- inputRef: this.refFrom,
1360
- defaultValue: string2USdate(schedule.valid.from),
1361
- type: "date"
1362
- // inputComponent={TextDate}
1363
- ,
1364
- onChange: function onChange(e) {
1365
- _this12.timerFrom && clearTimeout(_this12.timerFrom);
1366
- _this12.refFrom.current.style.background = '#ff000030';
1367
- _this12.timerFrom = setTimeout(function (value) {
1368
- _this12.timerFrom = null;
1369
- _this12.refFrom.current.style.background = '';
1370
- var _schedule = JSON.parse(JSON.stringify(_this12.state.schedule));
1371
- var date = Schedule.string2date(value);
1372
- if (date.toString() !== 'Invalid Date') {
1373
- _schedule.valid.from = "".concat(padding(date.getDate()), ".").concat(padding(date.getMonth() + 1), ".").concat(date.getFullYear());
1374
- _this12.onChange(_schedule);
516
+ else {
517
+ if (schedule.time.mode === PERIODS.minutes) {
518
+ if (schedule.time.interval === 1) {
519
+ // every minute
520
+ desc.push(i18n_1.default.t('sch_desc_everyMinute'));
521
+ }
522
+ else {
523
+ // every N minutes
524
+ desc.push(i18n_1.default.t('sch_desc_everyNMinutes', schedule.time.interval.toString()));
525
+ }
1375
526
  }
1376
- }, 1500, e.target.value);
1377
- },
1378
- InputLabelProps: {
1379
- shrink: true
1380
- },
1381
- margin: "normal"
1382
- }), /*#__PURE__*/_react["default"].createElement(_material.FormControlLabel, {
1383
- control: /*#__PURE__*/_react["default"].createElement(_material.Checkbox, {
1384
- className: this.props.classes.inputRadio,
1385
- checked: !!schedule.valid.to,
1386
- onClick: function onClick() {
1387
- var _schedule = JSON.parse(JSON.stringify(_this12.state.schedule));
1388
- _schedule.valid.to = _schedule.valid.to ? '' : Schedule.now2string(true);
1389
- _this12.onChange(_schedule);
1390
- }
1391
- }),
1392
- label: _i18n["default"].t('sch_validTo')
1393
- }), !!schedule.valid.to && /*#__PURE__*/_react["default"].createElement(_material.TextField, {
1394
- variant: "standard",
1395
- inputRef: this.refTo,
1396
- className: this.props.classes.inputDate,
1397
- style: {
1398
- marginRight: 10
1399
- },
1400
- key: "exactTimeFrom",
1401
- type: "date",
1402
- defaultValue: string2USdate(schedule.valid.to)
1403
- // inputComponent={TextDate}
1404
- ,
1405
- onChange: function onChange(e) {
1406
- _this12.timerTo && clearTimeout(_this12.timerTo);
1407
- _this12.refTo.current.style.background = '#ff000030';
1408
- _this12.timerTo = setTimeout(function (value) {
1409
- _this12.timerTo = null;
1410
- _this12.refTo.current.style.background = '';
1411
- var _schedule = JSON.parse(JSON.stringify(_this12.state.schedule));
1412
- var date = Schedule.string2date(value);
1413
- if (date.toString() !== 'Invalid Date') {
1414
- _schedule.valid.to = "".concat(padding(date.getDate()), ".").concat(padding(date.getMonth() + 1), ".").concat(date.getFullYear());
1415
- _this12.onChange(_schedule);
527
+ else if (schedule.time.interval === 1) {
528
+ // every minute
529
+ desc.push(i18n_1.default.t('sch_desc_everyHour'));
530
+ }
531
+ else {
532
+ // every N minutes
533
+ desc.push(i18n_1.default.t('sch_desc_everyNHours', schedule.time.interval.toString()));
534
+ }
535
+ const start = ASTRO.indexOf(schedule.time.start) !== -1 ? i18n_1.default.t(`sch_astro_${schedule.time.start}`) : schedule.time.start;
536
+ const end = ASTRO.indexOf(schedule.time.end) !== -1 ? i18n_1.default.t(`sch_astro_${schedule.time.end}`) : schedule.time.end;
537
+ if (start !== '00:00' || (end !== '24:00' && end !== '23:59')) {
538
+ // from HH:mm to HH:mm
539
+ desc.push(i18n_1.default.t('sch_desc_intervalFromTo', start, end));
540
+ }
541
+ }
542
+ if (!schedule.period.once) {
543
+ // valid
544
+ if (validFrom.getTime() > Date.now() && schedule.valid.to) {
545
+ // from XXX to XXXX
546
+ desc.push(i18n_1.default.t('sch_desc_validFromTo', schedule.valid.from, schedule.valid.to));
547
+ }
548
+ else if (validFrom.getTime() > Date.now()) {
549
+ // from XXXX
550
+ desc.push(i18n_1.default.t('sch_desc_validFrom', schedule.valid.from));
551
+ }
552
+ else if (schedule.valid.to) {
553
+ // till XXXX
554
+ desc.push(i18n_1.default.t('sch_desc_validTo', schedule.valid.to));
1416
555
  }
1417
- }, 1500, e.target.value);
1418
- },
1419
- InputLabelProps: {
1420
- shrink: true
1421
- },
1422
- margin: "normal"
1423
- })));
1424
- }
1425
- }, {
1426
- key: "render",
1427
- value: function render() {
1428
- return /*#__PURE__*/_react["default"].createElement("div", {
1429
- style: {
1430
- height: 'calc(100% - 48px)',
1431
- width: '100%',
1432
- overflow: 'hidden'
1433
556
  }
1434
- }, /*#__PURE__*/_react["default"].createElement("div", null, this.state.desc), /*#__PURE__*/_react["default"].createElement("div", {
1435
- className: this.props.classes.scrollWindow
1436
- }, /*#__PURE__*/_react["default"].createElement("h5", null, _i18n["default"].t('sch_time')), this.getTimePeriodElements(), this.getTimeExactElements(), this.getDivider(), /*#__PURE__*/_react["default"].createElement("h5", null, _i18n["default"].t('sch_period')), this.getPeriodModes(), !this.state.schedule.period.once && this.getDivider(), !this.state.schedule.period.once && this.getValidSettings()));
557
+ return desc.join(' ');
1437
558
  }
1438
- }], [{
1439
- key: "state2text",
1440
- value: function state2text(schedule) {
1441
- if (typeof schedule === 'string') {
1442
- try {
1443
- schedule = JSON.parse(schedule);
1444
- } catch (e) {
1445
- schedule = {};
559
+ getTimePeriodElements() {
560
+ const schedule = this.state.schedule;
561
+ let wholeDay = false;
562
+ let day = false;
563
+ let night = false;
564
+ let fromTo = true;
565
+ if (schedule.time.start === '00:00' && schedule.time.end === '24:00') {
566
+ wholeDay = true;
567
+ fromTo = false;
1446
568
  }
1447
- }
1448
- var desc = [];
1449
- var validFrom = Schedule.string2date(schedule.valid.from);
1450
- if (schedule.period.once) {
1451
- // once
1452
- var once = Schedule.string2date(schedule.period.once);
1453
- var now = new Date();
1454
- now.setMilliseconds(0);
1455
- now.setSeconds(0);
1456
- now.setMinutes(0);
1457
- now.setHours(0);
1458
-
1459
- //
1460
- if (once < now) {
1461
- // will be not executed anymore, because start is in the past
1462
- return _i18n["default"].t('sch_desc_onceInPast');
569
+ else if (schedule.time.start === 'sunrise') {
570
+ day = true;
571
+ fromTo = false;
1463
572
  }
1464
- // only once
1465
- desc.push(_i18n["default"].t('sch_desc_once_on', schedule.period.once));
1466
- } else if (schedule.period.days) {
1467
- if (schedule.period.days === 1) {
1468
- if (schedule.period.dows) {
1469
- var dows = JSON.parse(schedule.period.dows);
1470
- if (dows.length === 2 && dows[0] === 0 && dows[1] === 6) {
1471
- // on weekends
1472
- desc.push(_i18n["default"].t('sch_desc_onWeekends'));
1473
- } else if (dows.length === 5 && dows[0] === 1 && dows[1] === 2 && dows[2] === 3 && dows[3] === 4 && dows[4] === 5) {
1474
- // on workdays
1475
- desc.push(_i18n["default"].t('sch_desc_onWorkdays'));
1476
- } else {
1477
- var tDows = dows.map(function (day) {
1478
- return _i18n["default"].t(WEEKDAYS[day]);
1479
- });
1480
- if (tDows.length === 1) {
1481
- // on Monday
1482
- desc.push(_i18n["default"].t('sch_desc_onWeekday', tDows[0]));
1483
- } else if (tDows.length === 7) {
1484
- // on every day
1485
- desc.push(_i18n["default"].t('sch_desc_everyDay'));
1486
- } else {
1487
- var last = tDows.pop();
1488
- // on Monday and Sunday
1489
- desc.push(_i18n["default"].t('sch_desc_onWeekdays', tDows.join(', '), last));
1490
- }
1491
- }
1492
- } else {
1493
- desc.push(_i18n["default"].t('sch_desc_everyDay'));
1494
- }
1495
- } else {
1496
- desc.push(_i18n["default"].t('sch_desc_everyNDay', schedule.period.days));
573
+ else if (schedule.time.start === 'sunset') {
574
+ night = true;
575
+ fromTo = false;
1497
576
  }
1498
- } else if (schedule.period.weeks) {
1499
- if (schedule.period.weeks === 1) {
1500
- desc.push(_i18n["default"].t('sch_desc_everyWeek'));
1501
- } else {
1502
- desc.push(_i18n["default"].t('sch_desc_everyNWeeks', schedule.period.weeks));
577
+ return react_1.default.createElement("div", { key: "timePeriod", className: this.props.classes.rowDiv },
578
+ react_1.default.createElement("div", { className: this.props.classes.modeDiv },
579
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !schedule.time.exactTime, onClick: () => {
580
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
581
+ _schedule.time.exactTime = false;
582
+ this.onChange(_schedule);
583
+ } }), label: i18n_1.default.t('sch_intervalTime') })),
584
+ react_1.default.createElement("div", { className: this.props.classes.settingsDiv },
585
+ react_1.default.createElement("div", { className: this.props.classes.settingsDiv },
586
+ !schedule.time.exactTime && react_1.default.createElement("div", null,
587
+ react_1.default.createElement("div", null,
588
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!fromTo, onClick: () => {
589
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
590
+ _schedule.time.start = '00:00';
591
+ _schedule.time.end = '23:59';
592
+ this.onChange(_schedule);
593
+ } }), label: !fromTo ? i18n_1.default.t('sch_fromTo') : '' }),
594
+ fromTo && [
595
+ react_1.default.createElement(material_1.TextField, { variant: "standard", className: this.props.classes.inputTime, style: { marginRight: 10 }, key: "exactTimeFrom", type: "time", value: this.state.schedule.time.start,
596
+ // InputProps={{inputComponent: TextTime}}
597
+ onChange: e => {
598
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
599
+ _schedule.time.start = e.target.value;
600
+ this.onChange(_schedule);
601
+ }, InputLabelProps: { shrink: true }, label: i18n_1.default.t('sch_from'), margin: "normal" }),
602
+ react_1.default.createElement(material_1.TextField, { variant: "standard", className: this.props.classes.inputTime, key: "exactTimeTo", type: "time", value: this.state.schedule.time.end,
603
+ // InputProps={{inputComponent: TextTime}}
604
+ onChange: e => {
605
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
606
+ _schedule.time.end = e.target.value;
607
+ this.onChange(_schedule);
608
+ }, InputLabelProps: { shrink: true }, label: i18n_1.default.t('sch_to'), margin: "normal" }),
609
+ ])),
610
+ !schedule.time.exactTime && react_1.default.createElement("div", null,
611
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!wholeDay, onClick: () => {
612
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
613
+ _schedule.time.start = '00:00';
614
+ _schedule.time.end = '24:00';
615
+ this.onChange(_schedule);
616
+ } }), label: i18n_1.default.t('sch_wholeDay') })),
617
+ !schedule.time.exactTime && react_1.default.createElement("div", null,
618
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!day, onClick: () => {
619
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
620
+ _schedule.time.start = 'sunrise';
621
+ _schedule.time.end = 'sunset';
622
+ this.onChange(_schedule);
623
+ } }), label: i18n_1.default.t('sch_astroDay') })),
624
+ !schedule.time.exactTime && react_1.default.createElement("div", null,
625
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!night, onClick: () => {
626
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
627
+ _schedule.time.start = 'sunset';
628
+ _schedule.time.end = 'sunrise';
629
+ this.onChange(_schedule);
630
+ } }), label: i18n_1.default.t('sch_astroNight') }))),
631
+ !schedule.time.exactTime && this.getPeriodSettingsMinutes()));
632
+ }
633
+ getTimeExactElements() {
634
+ const isAstro = ASTRO.includes(this.state.schedule.time.start);
635
+ return react_1.default.createElement("div", { key: "timeExact", className: this.props.classes.rowDiv },
636
+ react_1.default.createElement("div", { className: this.props.classes.modeDiv },
637
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!this.state.schedule.time.exactTime, onClick: () => {
638
+ const schedule = JSON.parse(JSON.stringify(this.state.schedule));
639
+ schedule.time.exactTime = true;
640
+ this.onChange(schedule);
641
+ } }), label: i18n_1.default.t('sch_exactTime') })),
642
+ this.state.schedule.time.exactTime && react_1.default.createElement(material_1.Select, { variant: "standard", value: isAstro ? this.state.schedule.time.start : '00:00', onChange: e => {
643
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
644
+ _schedule.time.start = e.target.value;
645
+ this.onChange(_schedule);
646
+ } },
647
+ react_1.default.createElement(material_1.MenuItem, { key: "specific", value: "00:00" }, i18n_1.default.t('sch_specificTime')),
648
+ ASTRO.map(event => react_1.default.createElement(material_1.MenuItem, { key: event, value: event }, i18n_1.default.t(`sch_astro_${event}`)))),
649
+ this.state.schedule.time.exactTime && !isAstro &&
650
+ react_1.default.createElement("div", { className: this.props.classes.settingsDiv },
651
+ react_1.default.createElement(material_1.TextField, { variant: "standard", className: this.props.classes.inputTime, key: "exactTimeValue", value: this.state.schedule.time.start, type: "time",
652
+ // inputComponent={TextTime}
653
+ onChange: e => {
654
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
655
+ _schedule.time.start = e.target.value;
656
+ this.onChange(_schedule);
657
+ }, InputLabelProps: { shrink: true }, margin: "normal" })));
658
+ }
659
+ getDivider() {
660
+ return react_1.default.createElement("hr", { className: this.props.classes.hr });
661
+ }
662
+ getPeriodModes() {
663
+ const schedule = this.state.schedule;
664
+ const isOnce = !schedule.period.dows && !schedule.period.months && !schedule.period.dates && !schedule.period.years && !schedule.period.days && !schedule.period.weeks;
665
+ if (isOnce && !schedule.period.once) {
666
+ schedule.period.once = Schedule.now2string(true);
1503
667
  }
1504
- if (schedule.period.dows) {
1505
- var _dows2 = JSON.parse(schedule.period.dows);
1506
- if (_dows2.length === 2 && _dows2[0] === 0 && _dows2[1] === 6) {
1507
- // on weekends
1508
- desc.push(_i18n["default"].t('sch_desc_onWeekends'));
1509
- } else if (_dows2.length === 5 && _dows2[0] === 1 && _dows2[1] === 2 && _dows2[2] === 3 && _dows2[3] === 4 && _dows2[4] === 5) {
1510
- // on workdays
1511
- desc.push(_i18n["default"].t('sch_desc_onWorkdays'));
1512
- } else {
1513
- var _tDows = _dows2.map(function (day) {
1514
- return _i18n["default"].t(WEEKDAYS[day]);
1515
- });
1516
- if (_tDows.length === 1) {
1517
- // on Monday
1518
- desc.push(_i18n["default"].t('sch_desc_onWeekday', _tDows[0]));
1519
- } else if (_tDows.length === 7) {
1520
- // on every day
1521
- desc.push(_i18n["default"].t('sch_desc_everyDay'));
1522
- } else {
1523
- var _last = _tDows.pop();
1524
- // on Monday and Sunday
1525
- desc.push(_i18n["default"].t('sch_desc_onWeekdays', _tDows.join(', '), _last));
1526
- }
1527
- }
1528
- } else {
1529
- return _i18n["default"].t('sch_desc_never');
668
+ return [
669
+ // ----- once ---
670
+ react_1.default.createElement("div", { key: "once", className: `${this.props.classes.rowDiv} ${this.props.classes.rowOnce}` },
671
+ react_1.default.createElement("div", { className: this.props.classes.modeDiv },
672
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!isOnce, onClick: () => {
673
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
674
+ _schedule.period.once = _schedule.period.once || Schedule.now2string(true);
675
+ _schedule.period.dows = '';
676
+ _schedule.period.months = '';
677
+ _schedule.period.dates = '';
678
+ _schedule.period.years = 0;
679
+ _schedule.period.yearDate = 0;
680
+ _schedule.period.yearMonth = 0;
681
+ _schedule.period.weeks = 0;
682
+ _schedule.period.days = 0;
683
+ this.onChange(_schedule);
684
+ } }), label: i18n_1.default.t('sch_periodOnce') })),
685
+ isOnce && react_1.default.createElement("div", { className: this.props.classes.settingsDiv },
686
+ react_1.default.createElement(material_1.TextField, { variant: "standard", className: this.props.classes.inputDate, type: "date", ref: this.refOnce, key: "exactDateAt", defaultValue: string2USdate(schedule.period.once),
687
+ // InputProps={{inputComponent: TextTime}}
688
+ onChange: e => {
689
+ this.timerOnce && clearTimeout(this.timerOnce);
690
+ this.timerOnce = null;
691
+ if (this.refOnce.current) {
692
+ this.refOnce.current.style.background = '#ff000030';
693
+ }
694
+ this.timerOnce = setTimeout(value => {
695
+ this.timerOnce = null;
696
+ if (this.refOnce.current) {
697
+ this.refOnce.current.style.background = '';
698
+ }
699
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
700
+ const date = Schedule.string2date(value);
701
+ if (date.toString() !== 'Invalid Date') {
702
+ _schedule.period.once = `${padding(date.getDate())}.${padding(date.getMonth() + 1)}.${date.getFullYear()}`;
703
+ this.onChange(_schedule);
704
+ }
705
+ }, 1500, e.target.value);
706
+ }, InputLabelProps: { shrink: true }, label: i18n_1.default.t('sch_at'), margin: "normal" }))),
707
+ // ----- days ---
708
+ react_1.default.createElement("div", { key: "days", className: `${this.props.classes.rowDiv} ${this.props.classes.rowDays}` },
709
+ react_1.default.createElement("div", { className: this.props.classes.modeDiv },
710
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!schedule.period.days, onClick: () => {
711
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
712
+ _schedule.period.days = 1;
713
+ _schedule.period.dows = '';
714
+ _schedule.period.months = '';
715
+ _schedule.period.dates = '';
716
+ _schedule.period.years = 0;
717
+ _schedule.period.yearDate = 0;
718
+ _schedule.period.yearMonth = 0;
719
+ _schedule.period.weeks = 0;
720
+ _schedule.period.once = '';
721
+ this.onChange(_schedule);
722
+ } }), label: i18n_1.default.t('sch_periodDaily') })),
723
+ react_1.default.createElement("div", { className: this.props.classes.settingsDiv },
724
+ this.getPeriodSettingsDaily(),
725
+ schedule.period.days ? this.getPeriodSettingsWeekdays() : null)),
726
+ // ----- days of weeks ---
727
+ /*
728
+ !schedule.period.days && (
729
+ <div key="dows" className={this.props.classes.rowDiv + ' ' + this.props.classes.rowDows}>
730
+ <div className={this.props.classes.modeDiv}>
731
+ <FormControlLabel control={<Radio className={this.props.classes.inputRadio} checked={!!schedule.period.dows} onClick={() => {
732
+ const schedule = JSON.parse(JSON.stringify(this.state.schedule));
733
+ schedule.period.dows = schedule.period.dows ? '' : '[0,1,2,3,4,5,6]';
734
+ this.onChange(schedule);
735
+ }}/>}
736
+ label={I18n.t('sch_periodWeekdays')} />
737
+ </div>
738
+ <div className={this.props.classes.settingsDiv}>
739
+ {this.getPeriodSettingsWeekdays()}
740
+ </div>
741
+ </div>,
742
+ */
743
+ // ----- weeks ---
744
+ react_1.default.createElement("div", { key: "weeks", className: `${this.props.classes.rowDiv} ${this.props.classes.rowDows}` },
745
+ react_1.default.createElement("div", { className: this.props.classes.modeDiv },
746
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!schedule.period.weeks, onClick: () => {
747
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
748
+ _schedule.period.weeks = schedule.period.weeks ? 0 : 1;
749
+ _schedule.period.dows = schedule.period.dows || '[0]';
750
+ _schedule.period.months = '';
751
+ _schedule.period.dates = '';
752
+ _schedule.period.years = 0;
753
+ _schedule.period.yearDate = 0;
754
+ _schedule.period.yearMonth = 0;
755
+ _schedule.period.days = 0;
756
+ _schedule.period.once = '';
757
+ this.onChange(_schedule);
758
+ } }), label: i18n_1.default.t('sch_periodWeekly') })),
759
+ react_1.default.createElement("div", { className: this.props.classes.settingsDiv },
760
+ react_1.default.createElement("div", { className: this.props.classes.settingsDiv }, this.getPeriodSettingsWeekly()),
761
+ react_1.default.createElement("div", { className: `${this.props.classes.settingsDiv} ${this.props.classes.rowDowsDows}` }, this.state.schedule.period.weeks ? this.getPeriodSettingsWeekdays() : null))),
762
+ // ----- months ---
763
+ react_1.default.createElement("div", { key: "months", className: `${this.props.classes.rowDiv} ${this.props.classes.rowMonths}` },
764
+ react_1.default.createElement("div", { className: this.props.classes.modeDiv },
765
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!schedule.period.months, onClick: () => {
766
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
767
+ _schedule.period.months = 1;
768
+ _schedule.period.dows = '';
769
+ _schedule.period.dates = '';
770
+ _schedule.period.years = 0;
771
+ _schedule.period.yearDate = 0;
772
+ _schedule.period.yearMonth = 0;
773
+ _schedule.period.weeks = 0;
774
+ _schedule.period.days = 0;
775
+ _schedule.period.once = '';
776
+ this.onChange(_schedule);
777
+ } }), label: i18n_1.default.t('sch_periodMonthly') })),
778
+ react_1.default.createElement("div", { className: this.props.classes.settingsDiv },
779
+ this.getPeriodSettingsMonthly(),
780
+ schedule.period.months ? react_1.default.createElement("div", null,
781
+ react_1.default.createElement("div", { className: `${this.props.classes.settingsDiv} ${this.props.classes.rowMonthsDates}` },
782
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputRadio, checked: !!schedule.period.dates, onClick: () => {
783
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
784
+ _schedule.period.months = _schedule.period.months || 1;
785
+ const dates = [];
786
+ for (let i = 1; i <= 31; i++) {
787
+ dates.push(i);
788
+ }
789
+ _schedule.period.dates = _schedule.period.dates || JSON.stringify(dates);
790
+ _schedule.period.dows = '';
791
+ _schedule.period.years = 0;
792
+ _schedule.period.yearDate = 0;
793
+ _schedule.period.yearMonth = 0;
794
+ _schedule.period.weeks = 0;
795
+ _schedule.period.days = 0;
796
+ _schedule.period.once = '';
797
+ this.onChange(_schedule);
798
+ } }), label: i18n_1.default.t('sch_periodDates') })),
799
+ react_1.default.createElement("div", { className: `${this.props.classes.settingsDiv} ${this.props.classes.rowMonthsDates}` }, this.getPeriodSettingsDates())) : null)),
800
+ // ----- years ---
801
+ react_1.default.createElement("div", { key: "years", className: `${this.props.classes.rowDiv} ${this.props.classes.rowYears}` },
802
+ react_1.default.createElement("div", { className: this.props.classes.modeDiv },
803
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!schedule.period.years, onClick: () => {
804
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
805
+ _schedule.period.years = 1;
806
+ _schedule.period.yearDate = 1;
807
+ _schedule.period.yearMonth = 1;
808
+ _schedule.period.dows = '';
809
+ _schedule.period.months = 0;
810
+ _schedule.period.dates = '';
811
+ _schedule.period.weeks = 0;
812
+ _schedule.period.days = 0;
813
+ _schedule.period.once = '';
814
+ this.onChange(_schedule);
815
+ } }), label: i18n_1.default.t('sch_periodYearly') })),
816
+ react_1.default.createElement("div", { className: this.props.classes.settingsDiv },
817
+ react_1.default.createElement("div", { className: this.props.classes.settingsDiv }, this.getPeriodSettingsYearly()),
818
+ !!schedule.period.years && react_1.default.createElement("div", { className: this.props.classes.settingsDiv },
819
+ react_1.default.createElement("span", null, i18n_1.default.t('sch_on')),
820
+ react_1.default.createElement(material_1.Input, { key: "input", value: this.state.schedule.period.yearDate, className: this.props.classes.inputEvery, type: "number", inputProps: { min: 1, max: 31 }, onChange: e => {
821
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
822
+ _schedule.period.yearDate = parseInt(e.target.value, 10);
823
+ if (_schedule.period.yearDate < 1)
824
+ _schedule.period.yearDate = 31;
825
+ if (_schedule.period.yearDate > 31)
826
+ _schedule.period.yearDate = 1;
827
+ this.onChange(_schedule);
828
+ } }),
829
+ react_1.default.createElement(material_1.Select, { variant: "standard", value: schedule.period.yearMonth, onChange: e => {
830
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
831
+ _schedule.period.yearMonth = e.target.value;
832
+ this.onChange(_schedule);
833
+ } },
834
+ react_1.default.createElement(material_1.MenuItem, { key: "every", value: 0 }, i18n_1.default.t('sch_yearEveryMonth')),
835
+ MONTHS.map((month, i) => react_1.default.createElement(material_1.MenuItem, { key: month, value: i + 1 }, i18n_1.default.t(month))))))),
836
+ ];
837
+ }
838
+ getPeriodSettingsMinutes() {
839
+ return react_1.default.createElement("div", { style: { display: 'inline-block' } },
840
+ react_1.default.createElement("label", null, i18n_1.default.t('sch_every')),
841
+ react_1.default.createElement(material_1.Input, { value: this.state.schedule.time.interval, style: { verticalAlign: 'bottom' }, className: this.props.classes.inputEvery, type: "number", inputProps: { min: 1 }, onChange: e => {
842
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
843
+ _schedule.time.interval = parseInt(e.target.value, 10);
844
+ this.onChange(_schedule);
845
+ } }),
846
+ react_1.default.createElement(material_1.Select, { variant: "standard", value: this.state.schedule.time.mode, onChange: e => {
847
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
848
+ _schedule.time.mode = e.target.value;
849
+ this.onChange(_schedule);
850
+ } },
851
+ react_1.default.createElement(material_1.MenuItem, { value: PERIODS.minutes }, i18n_1.default.t('sch_periodMinutes')),
852
+ react_1.default.createElement(material_1.MenuItem, { value: PERIODS.hours }, i18n_1.default.t('sch_periodHours'))));
853
+ }
854
+ getPeriodSettingsWeekdays() {
855
+ // || this.state.schedule.period.dows === '[1, 2, 3, 4, 5]' || this.state.schedule.period.dows === '[0, 6]'
856
+ const schedule = this.state.schedule;
857
+ const isSpecific = schedule.period.dows && schedule.period.dows !== '[1, 2, 3, 4, 5]' && schedule.period.dows !== '[0, 6]';
858
+ return [
859
+ react_1.default.createElement("div", { key: "workdays" },
860
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: schedule.period.dows === '[1, 2, 3, 4, 5]', onClick: () => {
861
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
862
+ _schedule.period.dows = '[1, 2, 3, 4, 5]';
863
+ if (_schedule.period.days) {
864
+ _schedule.period.days = 1;
865
+ }
866
+ this.onChange(_schedule);
867
+ } }), label: i18n_1.default.t('sch_periodWorkdays') })),
868
+ react_1.default.createElement("div", { key: "weekend" },
869
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: schedule.period.dows === '[0, 6]', onClick: () => {
870
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
871
+ _schedule.period.dows = '[0, 6]';
872
+ if (_schedule.period.days) {
873
+ _schedule.period.days = 1;
874
+ }
875
+ this.onChange(_schedule);
876
+ } }), label: i18n_1.default.t('sch_periodWeekend') })),
877
+ react_1.default.createElement("div", { key: "specific", style: { verticalAlign: 'top' } },
878
+ react_1.default.createElement(material_1.FormControlLabel, { style: { verticalAlign: 'top' }, control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: !!isSpecific, onClick: () => {
879
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
880
+ _schedule.period.dows = '[0, 1, 2, 3, 4, 5, 6]';
881
+ if (_schedule.period.days) {
882
+ _schedule.period.days = 1;
883
+ }
884
+ this.onChange(_schedule);
885
+ } }), label: i18n_1.default.t('sch_periodWeekdays') }),
886
+ isSpecific && (schedule.period.days === 1 || schedule.period.weeks) &&
887
+ react_1.default.createElement(material_1.FormGroup, { row: true, className: this.props.classes.inputGroup, style: { width: 150 } }, [1, 2, 3, 4, 5, 6, 0].map(i => react_1.default.createElement(material_1.FormControlLabel, { key: `specific_${i}`, className: this.props.classes.inputGroupElement, control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputSmallCheck, checked: schedule.period.dows.includes(i.toString()), onChange: e => {
888
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
889
+ let daysOfWeek;
890
+ try {
891
+ daysOfWeek = JSON.parse(_schedule.period.dows);
892
+ }
893
+ catch (err) {
894
+ daysOfWeek = [];
895
+ }
896
+ if (e.target.checked && !daysOfWeek.includes(i)) {
897
+ daysOfWeek.push(i);
898
+ }
899
+ else if (!e.target.checked && daysOfWeek.includes(i)) {
900
+ daysOfWeek.splice(daysOfWeek.indexOf(i), 1);
901
+ }
902
+ daysOfWeek.sort((a, b) => a - b);
903
+ _schedule.period.dows = JSON.stringify(daysOfWeek);
904
+ if (_schedule.period.days) {
905
+ _schedule.period.days = 1;
906
+ }
907
+ this.onChange(_schedule);
908
+ } }), label: i18n_1.default.t(WEEKDAYS[i]) })))),
909
+ ];
910
+ }
911
+ getPeriodSettingsDaily() {
912
+ if (!this.state.schedule.period.days) {
913
+ return null;
1530
914
  }
1531
- } else if (schedule.period.months) {
1532
- if (schedule.period.dates) {
1533
- var dates = JSON.parse(schedule.period.dates);
1534
- if (dates.length === 1) {
1535
- // in 1 of month
1536
- desc.push(_i18n["default"].t('sch_desc_onDate', dates[0]));
1537
- } else if (dates.length === 31) {
1538
- desc.push(_i18n["default"].t('sch_desc_onEveryDate'));
1539
- } else if (!dates.length) {
1540
- return _i18n["default"].t('sch_desc_never');
1541
- } else {
1542
- var _last2 = dates.pop();
1543
- // in 1 and 4 of month
1544
- desc.push(_i18n["default"].t('sch_desc_onDates', dates.join(', '), _last2));
1545
- }
1546
- } else {
1547
- desc.push(_i18n["default"].t('sch_desc_onEveryDate'));
915
+ const schedule = this.state.schedule;
916
+ return [
917
+ react_1.default.createElement("div", { key: "every_day" },
918
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: schedule.period.days === 1 && !schedule.period.dows, onClick: () => {
919
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
920
+ _schedule.period.days = 1;
921
+ _schedule.period.dows = '';
922
+ this.onChange(_schedule);
923
+ } }), label: i18n_1.default.t('sch_periodEveryDay') })),
924
+ react_1.default.createElement("div", { key: "everyN_day" },
925
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: schedule.period.days > 1, onClick: () => {
926
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
927
+ _schedule.period.days = 2;
928
+ _schedule.period.dows = '';
929
+ this.onChange(_schedule);
930
+ } }), label: i18n_1.default.t('sch_periodEvery') }),
931
+ schedule.period.days > 1 && [
932
+ react_1.default.createElement(material_1.Input, { key: "input", value: this.state.schedule.period.days, className: this.props.classes.inputEvery, type: "number", inputProps: { min: 2 }, onChange: e => {
933
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
934
+ _schedule.period.days = parseInt(e.target.value, 10);
935
+ _schedule.period.dows = '';
936
+ this.onChange(_schedule);
937
+ } }),
938
+ react_1.default.createElement("span", { key: "span", style: { paddingRight: 10 } }, i18n_1.default.t('sch_periodDay')),
939
+ ]),
940
+ ];
941
+ }
942
+ getPeriodSettingsWeekly() {
943
+ if (!this.state.schedule.period.weeks) {
944
+ return null;
1548
945
  }
1549
- if (schedule.period.months === 1) {
1550
- desc.push(_i18n["default"].t('sch_desc_everyMonth'));
1551
- } else if (typeof schedule.period.months === 'number') {
1552
- desc.push(_i18n["default"].t('sch_desc_everyNMonths', schedule.period.months));
1553
- } else {
1554
- var months = JSON.parse(schedule.period.months);
1555
- var tMonths = months.map(function (month) {
1556
- return _i18n["default"].t(MONTHS[month - 1]);
1557
- });
1558
- if (!tMonths.length) {
1559
- // in January
1560
- return _i18n["default"].t('sch_desc_never');
1561
- }
1562
- if (tMonths.length === 1) {
1563
- // in January
1564
- desc.push(_i18n["default"].t('sch_desc_onMonth', tMonths[0]));
1565
- } else if (tMonths.length === 12) {
1566
- // every month
1567
- desc.push(_i18n["default"].t('sch_desc_everyMonth'));
1568
- } else {
1569
- var _last3 = tMonths.pop();
1570
- // in January and May
1571
- desc.push(_i18n["default"].t('sch_desc_onMonths', tMonths.join(', '), _last3));
1572
- }
946
+ const schedule = this.state.schedule;
947
+ return [
948
+ react_1.default.createElement("div", { key: "radios", style: { display: 'inline-block', verticalAlign: 'top' } },
949
+ react_1.default.createElement("div", null,
950
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: schedule.period.weeks === 1, onClick: () => {
951
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
952
+ _schedule.period.weeks = 1;
953
+ this.onChange(_schedule);
954
+ } }), label: i18n_1.default.t('sch_periodEveryWeek') })),
955
+ react_1.default.createElement("div", null,
956
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: schedule.period.weeks > 1, onClick: () => {
957
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
958
+ _schedule.period.weeks = 2;
959
+ this.onChange(_schedule);
960
+ } }), label: i18n_1.default.t('sch_periodEvery') }),
961
+ schedule.period.weeks > 1 && [
962
+ react_1.default.createElement(material_1.Input, { key: "input", value: this.state.schedule.period.weeks, className: this.props.classes.inputEvery, type: "number", inputProps: { min: 2 }, onChange: e => {
963
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
964
+ _schedule.period.weeks = parseInt(e.target.value, 10);
965
+ this.onChange(_schedule);
966
+ } }),
967
+ react_1.default.createElement("span", { key: "text" }, i18n_1.default.t('sch_periodWeek')),
968
+ ])),
969
+ ];
970
+ }
971
+ getPeriodSettingsDates() {
972
+ if (!this.state.schedule.period.dates) {
973
+ return null;
1573
974
  }
1574
- } else if (schedule.period.years) {
1575
- if (schedule.period.years === 1) {
1576
- desc.push(_i18n["default"].t('sch_desc_everyYear'));
1577
- } else {
1578
- desc.push(_i18n["default"].t('sch_desc_everyNYears', schedule.period.years));
975
+ const schedule = this.state.schedule;
976
+ const dates = [];
977
+ for (let i = 1; i <= 31; i++) {
978
+ dates.push(i);
1579
979
  }
1580
- desc.push(_i18n["default"].t('sch_desc_onDate', schedule.period.yearDate, schedule.period.yearMonth ? _i18n["default"].t(MONTHS[schedule.period.yearMonth - 1]) : _i18n["default"].t('sch_desc_everyMonth')));
1581
- }
1582
-
1583
- // time
1584
- if (schedule.time.exactTime) {
1585
- if (ASTRO.indexOf(schedule.time.start) !== -1) {
1586
- // at sunset
1587
- desc.push(_i18n["default"].t('sch_desc_atTime', _i18n["default"].t("sch_astro_".concat(schedule.time.start))));
1588
- } else {
1589
- // at HH:MM
1590
- desc.push(_i18n["default"].t('sch_desc_atTime', schedule.time.start));
980
+ const parsedDates = JSON.parse(schedule.period.dates);
981
+ return react_1.default.createElement(material_1.FormGroup, { row: true, className: this.props.classes.inputGroup, style: { maxWidth: 620 } },
982
+ react_1.default.createElement(material_1.FormControlLabel, { className: this.props.classes.inputDateDay, control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputDateDayCheck, checked: parsedDates.length === 31, onChange: () => {
983
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
984
+ const _dates = [];
985
+ for (let i = 1; i <= 31; i++) {
986
+ _dates.push(i);
987
+ }
988
+ _schedule.period.dates = JSON.stringify(_dates);
989
+ this.onChange(_schedule);
990
+ } }), label: i18n_1.default.t('sch_all') }),
991
+ react_1.default.createElement(material_1.FormControlLabel, { className: this.props.classes.inputDateDay, control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputDateDayCheck, checked: !parsedDates.length, onChange: () => {
992
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
993
+ _schedule.period.dates = '[]';
994
+ this.onChange(_schedule);
995
+ } }), label: i18n_1.default.t('sch_no_one') }),
996
+ parsedDates.length !== 31 && !!parsedDates.length &&
997
+ react_1.default.createElement(material_1.FormControlLabel, { className: this.props.classes.inputDateDay, control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputDateDayCheck, checked: false, onChange: () => {
998
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
999
+ const result = [];
1000
+ const _parsedDates = JSON.parse(_schedule.period.dates);
1001
+ for (let i = 1; i <= 31; i++) {
1002
+ if (!_parsedDates.includes(i)) {
1003
+ result.push(i);
1004
+ }
1005
+ }
1006
+ result.sort((a, b) => a - b);
1007
+ _schedule.period.dates = JSON.stringify(result);
1008
+ this.onChange(_schedule);
1009
+ } }), label: i18n_1.default.t('sch_invert') }),
1010
+ react_1.default.createElement("div", null),
1011
+ dates.map(i => react_1.default.createElement(material_1.FormControlLabel, { key: `date_${i}`, className: this.props.classes.inputDateDay, style: !i ? {
1012
+ opacity: 0,
1013
+ cursor: 'default',
1014
+ userSelect: 'none',
1015
+ pointerEvents: 'none',
1016
+ } : {}, control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputDateDayCheck, checked: JSON.parse(schedule.period.dates).includes(i), onChange: e => {
1017
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1018
+ let _dates;
1019
+ try {
1020
+ _dates = JSON.parse(_schedule.period.dates);
1021
+ }
1022
+ catch (err) {
1023
+ _dates = [];
1024
+ }
1025
+ if (e.target.checked && !_dates.includes(i)) {
1026
+ _dates.push(i);
1027
+ }
1028
+ else if (!e.target.checked && _dates.includes(i)) {
1029
+ _dates.splice(_dates.indexOf(i), 1);
1030
+ }
1031
+ _dates.sort((a, b) => a - b);
1032
+ _schedule.period.dates = JSON.stringify(_dates);
1033
+ this.onChange(_schedule);
1034
+ } }), label: i < 10 ? [
1035
+ react_1.default.createElement("span", { key: "0", style: { opacity: 0 } }, "0"),
1036
+ react_1.default.createElement("span", { key: "num" }, i),
1037
+ ] : i })));
1038
+ }
1039
+ getPeriodSettingsMonthly() {
1040
+ if (!this.state.schedule.period.months) {
1041
+ return null;
1591
1042
  }
1592
- } else {
1593
- if (schedule.time.mode === PERIODS.minutes) {
1594
- if (schedule.time.interval === 1) {
1595
- // every minute
1596
- desc.push(_i18n["default"].t('sch_desc_everyMinute'));
1597
- } else {
1598
- // every N minutes
1599
- desc.push(_i18n["default"].t('sch_desc_everyNMinutes', schedule.time.interval));
1600
- }
1601
- } else if (schedule.time.interval === 1) {
1602
- // every minute
1603
- desc.push(_i18n["default"].t('sch_desc_everyHour'));
1604
- } else {
1605
- // every N minutes
1606
- desc.push(_i18n["default"].t('sch_desc_everyNHours', schedule.time.interval));
1043
+ const schedule = this.state.schedule;
1044
+ const parsedMonths = typeof schedule.period.months === 'string' ? JSON.parse(schedule.period.months) : [];
1045
+ return [
1046
+ react_1.default.createElement("div", { key: "every" },
1047
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: typeof schedule.period.months === 'number' && schedule.period.months === 1, onClick: () => {
1048
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1049
+ _schedule.period.months = 1;
1050
+ this.onChange(schedule);
1051
+ } }), label: i18n_1.default.t('sch_periodEveryMonth') })),
1052
+ react_1.default.createElement("div", { key: "everyN" },
1053
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: typeof schedule.period.months === 'number' && schedule.period.months > 1, onClick: () => {
1054
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1055
+ _schedule.period.months = 2;
1056
+ this.onChange(_schedule);
1057
+ } }), label: i18n_1.default.t('sch_periodEvery') }),
1058
+ typeof schedule.period.months === 'number' && schedule.period.months > 1 && [
1059
+ react_1.default.createElement(material_1.Input, { key: "input", value: schedule.period.months, className: this.props.classes.inputEvery, type: "number", inputProps: { min: 2 }, onChange: e => {
1060
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1061
+ _schedule.period.months = parseInt(e.target.value, 10);
1062
+ if (_schedule.period.months < 1)
1063
+ _schedule.period.months = 1;
1064
+ this.onChange(_schedule);
1065
+ } }),
1066
+ react_1.default.createElement("span", { key: "text" }, i18n_1.default.t('sch_periodMonth')),
1067
+ ]),
1068
+ react_1.default.createElement("div", { key: "specific", style: { verticalAlign: 'top' } },
1069
+ react_1.default.createElement(material_1.FormControlLabel, { style: { verticalAlign: 'top' }, control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: typeof schedule.period.months === 'string', onClick: () => {
1070
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1071
+ _schedule.period.months = '[1,2,3,4,5,6,7,8,9,10,11,12]';
1072
+ this.onChange(_schedule);
1073
+ } }), label: i18n_1.default.t('sch_periodSpecificMonths') }),
1074
+ typeof schedule.period.months === 'string' &&
1075
+ react_1.default.createElement(material_1.FormGroup, { row: true, className: this.props.classes.inputGroup },
1076
+ react_1.default.createElement(material_1.FormControlLabel, { className: this.props.classes.inputDateDay, control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputDateDayCheck, checked: parsedMonths.length === 12, onChange: () => {
1077
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1078
+ const months = [];
1079
+ for (let i = 1; i <= 12; i++) {
1080
+ months.push(i);
1081
+ }
1082
+ _schedule.period.months = JSON.stringify(months);
1083
+ this.onChange(_schedule);
1084
+ } }), label: i18n_1.default.t('sch_all') }),
1085
+ react_1.default.createElement(material_1.FormControlLabel, { className: this.props.classes.inputDateDay, control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputDateDayCheck, checked: !parsedMonths.length, onChange: () => {
1086
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1087
+ _schedule.period.months = '[]';
1088
+ this.onChange(_schedule);
1089
+ } }), label: i18n_1.default.t('sch_no_one') }),
1090
+ parsedMonths.length !== 12 && !!parsedMonths.length &&
1091
+ react_1.default.createElement(material_1.FormControlLabel, { className: this.props.classes.inputDateDay, control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputDateDayCheck, checked: false, onChange: () => {
1092
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1093
+ const result = [];
1094
+ const _parsedMonths = JSON.parse(_schedule.period.months);
1095
+ for (let i = 1; i <= 12; i++) {
1096
+ if (!_parsedMonths.includes(i)) {
1097
+ result.push(i);
1098
+ }
1099
+ }
1100
+ result.sort((a, b) => a - b);
1101
+ _schedule.period.months = JSON.stringify(result);
1102
+ this.onChange(_schedule);
1103
+ } }), label: i18n_1.default.t('sch_invert') }),
1104
+ react_1.default.createElement("div", null),
1105
+ MONTHS.map((month, i) => react_1.default.createElement(material_1.FormControlLabel, { className: this.props.classes.inputGroupElement, control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputSmallCheck, checked: typeof schedule.period.months === 'string' ? JSON.parse(schedule.period.months).includes(i + 1) : schedule.period.months === i, onChange: e => {
1106
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1107
+ let months;
1108
+ try {
1109
+ months = JSON.parse(_schedule.period.months);
1110
+ }
1111
+ catch (err) {
1112
+ months = [];
1113
+ }
1114
+ if (e.target.checked && !months.includes(i + 1)) {
1115
+ months.push(i + 1);
1116
+ }
1117
+ else if (!e.target.checked && months.includes(i + 1)) {
1118
+ months.splice(months.indexOf(i + 1), 1);
1119
+ }
1120
+ months.sort((a, b) => a - b);
1121
+ _schedule.period.months = JSON.stringify(months);
1122
+ this.onChange(_schedule);
1123
+ } }), label: i18n_1.default.t(month) })))),
1124
+ ];
1125
+ }
1126
+ getPeriodSettingsYearly() {
1127
+ if (!this.state.schedule.period.years) {
1128
+ return null;
1607
1129
  }
1608
- var start = ASTRO.indexOf(schedule.time.start) !== -1 ? _i18n["default"].t("sch_astro_".concat(schedule.time.start)) : schedule.time.start;
1609
- var end = ASTRO.indexOf(schedule.time.end) !== -1 ? _i18n["default"].t("sch_astro_".concat(schedule.time.end)) : schedule.time.end;
1610
- if (start !== '00:00' || end !== '24:00' && end !== '23:59') {
1611
- // from HH:mm to HH:mm
1612
- desc.push(_i18n["default"].t('sch_desc_intervalFromTo', start, end));
1130
+ const schedule = this.state.schedule;
1131
+ return [
1132
+ react_1.default.createElement("div", { key: "year" },
1133
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: schedule.period.years === 1, onClick: () => {
1134
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1135
+ _schedule.period.years = 1;
1136
+ this.onChange(_schedule);
1137
+ } }), label: i18n_1.default.t('sch_periodEveryYear') })),
1138
+ react_1.default.createElement("div", { key: "every" },
1139
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Radio, { className: this.props.classes.inputRadio, checked: schedule.period.years > 1, onClick: () => {
1140
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1141
+ _schedule.period.years = 2;
1142
+ this.onChange(_schedule);
1143
+ } }), label: i18n_1.default.t('sch_periodEvery') }),
1144
+ schedule.period.years > 1 && [
1145
+ react_1.default.createElement(material_1.Input, { key: "input", value: this.state.schedule.period.years, className: this.props.classes.inputEvery, type: "number", inputProps: { min: 2 }, onChange: e => {
1146
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1147
+ _schedule.period.years = parseInt(e.target.value, 10);
1148
+ if (_schedule.period.years < 1)
1149
+ _schedule.period.years = 1;
1150
+ this.onChange(_schedule);
1151
+ } }),
1152
+ react_1.default.createElement("span", { key: "text" }, i18n_1.default.t('sch_periodYear')),
1153
+ ]),
1154
+ ];
1155
+ }
1156
+ static now2string(isEnd) {
1157
+ const d = new Date();
1158
+ d.setHours(0);
1159
+ d.setMinutes(0);
1160
+ d.setSeconds(0);
1161
+ d.setMilliseconds(0);
1162
+ if (isEnd) {
1163
+ d.setDate(d.getDate() + 2);
1164
+ d.setMilliseconds(d.getMilliseconds() - 1);
1613
1165
  }
1614
- }
1615
- if (!schedule.period.once) {
1616
- // valid
1617
- if (validFrom.getTime() > Date.now() && schedule.valid.to) {
1618
- // from XXX to XXXX
1619
- desc.push(_i18n["default"].t('sch_desc_validFromTo', schedule.valid.from, schedule.valid.to));
1620
- } else if (validFrom.getTime() > Date.now()) {
1621
- // from XXXX
1622
- desc.push(_i18n["default"].t('sch_desc_validFrom', schedule.valid.from));
1623
- } else if (schedule.valid.to) {
1624
- // till XXXX
1625
- desc.push(_i18n["default"].t('sch_desc_validTo', schedule.valid.to));
1166
+ return `${padding(d.getDate())}.${padding(d.getMonth() + 1)}.${padding(d.getFullYear())}`;
1167
+ }
1168
+ static string2date(str) {
1169
+ let parts = str.split('.'); // 31.12.2019
1170
+ if (parts.length === 1) {
1171
+ parts = str.split('-'); // 2018-12-31
1172
+ return new Date(parseInt(parts[0], 10), parseInt(parts[1], 10) - 1, parseInt(parts[2], 10));
1626
1173
  }
1627
- }
1628
- return desc.join(' ');
1174
+ return new Date(parseInt(parts[2], 10), parseInt(parts[1], 10) - 1, parseInt(parts[0], 10));
1629
1175
  }
1630
- }, {
1631
- key: "now2string",
1632
- value: function now2string(isEnd) {
1633
- var d = new Date();
1634
- d.setHours(0);
1635
- d.setMinutes(0);
1636
- d.setSeconds(0);
1637
- d.setMilliseconds(0);
1638
- if (isEnd) {
1639
- d.setDate(d.getDate() + 2);
1640
- d.setMilliseconds(d.getMilliseconds() - 1);
1641
- }
1642
- return "".concat(padding(d.getDate()), ".").concat(padding(d.getMonth() + 1), ".").concat(padding(d.getFullYear()));
1176
+ getValidSettings() {
1177
+ const schedule = this.state.schedule;
1178
+ // ----- from ---
1179
+ return react_1.default.createElement("div", { className: this.props.classes.rowDiv },
1180
+ react_1.default.createElement("div", { className: this.props.classes.modeDiv, style: { verticalAlign: 'middle' } },
1181
+ react_1.default.createElement("span", { style: { fontWeight: 'bold', paddingRight: 10 } }, i18n_1.default.t('sch_valid')),
1182
+ react_1.default.createElement("span", null, i18n_1.default.t('sch_validFrom'))),
1183
+ react_1.default.createElement("div", { className: this.props.classes.settingsDiv },
1184
+ react_1.default.createElement(material_1.TextField, { variant: "standard", className: this.props.classes.inputDate, style: { marginRight: 10 }, key: "exactTimeFrom", inputRef: this.refFrom, defaultValue: string2USdate(schedule.valid.from), type: "date",
1185
+ // inputComponent={TextDate}
1186
+ onChange: e => {
1187
+ this.timerFrom && clearTimeout(this.timerFrom);
1188
+ if (this.refFrom.current) {
1189
+ this.refFrom.current.style.background = '#ff000030';
1190
+ }
1191
+ this.timerFrom = setTimeout(value => {
1192
+ this.timerFrom = null;
1193
+ if (this.refFrom.current) {
1194
+ this.refFrom.current.style.background = '';
1195
+ }
1196
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1197
+ const date = Schedule.string2date(value);
1198
+ if (date.toString() !== 'Invalid Date') {
1199
+ _schedule.valid.from = `${padding(date.getDate())}.${padding(date.getMonth() + 1)}.${date.getFullYear()}`;
1200
+ this.onChange(_schedule);
1201
+ }
1202
+ }, 1500, e.target.value);
1203
+ }, InputLabelProps: { shrink: true }, margin: "normal" }),
1204
+ react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Checkbox, { className: this.props.classes.inputRadio, checked: !!schedule.valid.to, onClick: () => {
1205
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1206
+ _schedule.valid.to = _schedule.valid.to ? '' : Schedule.now2string(true);
1207
+ this.onChange(_schedule);
1208
+ } }), label: i18n_1.default.t('sch_validTo') }),
1209
+ !!schedule.valid.to && react_1.default.createElement(material_1.TextField, { variant: "standard", inputRef: this.refTo, className: this.props.classes.inputDate, style: { marginRight: 10 }, key: "exactTimeFrom", type: "date", defaultValue: string2USdate(schedule.valid.to),
1210
+ // inputComponent={TextDate}
1211
+ onChange: e => {
1212
+ this.timerTo && clearTimeout(this.timerTo);
1213
+ if (this.refTo.current) {
1214
+ this.refTo.current.style.background = '#ff000030';
1215
+ }
1216
+ this.timerTo = setTimeout(value => {
1217
+ this.timerTo = null;
1218
+ if (this.refTo.current) {
1219
+ this.refTo.current.style.background = '';
1220
+ }
1221
+ const _schedule = JSON.parse(JSON.stringify(this.state.schedule));
1222
+ const date = Schedule.string2date(value);
1223
+ if (date.toString() !== 'Invalid Date') {
1224
+ _schedule.valid.to = `${padding(date.getDate())}.${padding(date.getMonth() + 1)}.${date.getFullYear()}`;
1225
+ this.onChange(_schedule);
1226
+ }
1227
+ }, 1500, e.target.value);
1228
+ }, InputLabelProps: { shrink: true }, margin: "normal" })));
1643
1229
  }
1644
- }, {
1645
- key: "string2date",
1646
- value: function string2date(str) {
1647
- var parts = str.split('.'); // 31.12.2019
1648
- if (parts.length === 1) {
1649
- parts = str.split('-'); // 2018-12-31
1650
- return new Date(parseInt(parts[0], 10), parseInt(parts[1], 10) - 1, parseInt(parts[2], 10));
1651
- }
1652
- return new Date(parseInt(parts[2], 10), parseInt(parts[1], 10) - 1, parseInt(parts[0], 10));
1230
+ render() {
1231
+ return react_1.default.createElement("div", { style: { height: 'calc(100% - 48px)', width: '100%', overflow: 'hidden' } },
1232
+ react_1.default.createElement("div", null, this.state.desc),
1233
+ react_1.default.createElement("div", { className: this.props.classes.scrollWindow },
1234
+ react_1.default.createElement("h5", null, i18n_1.default.t('sch_time')),
1235
+ this.getTimePeriodElements(),
1236
+ this.getTimeExactElements(),
1237
+ this.getDivider(),
1238
+ react_1.default.createElement("h5", null, i18n_1.default.t('sch_period')),
1239
+ this.getPeriodModes(),
1240
+ !this.state.schedule.period.once && this.getDivider(),
1241
+ !this.state.schedule.period.once && this.getValidSettings()));
1653
1242
  }
1654
- }]);
1655
- return Schedule;
1656
- }(_react["default"].Component);
1657
- Schedule.propTypes = {
1658
- schedule: _propTypes["default"].string,
1659
- onChange: _propTypes["default"].func.isRequired
1660
- };
1661
- var _default = exports["default"] = (0, _styles.withStyles)(styles)(Schedule);
1662
- //# sourceMappingURL=Schedule.js.map
1243
+ }
1244
+ exports.default = (0, styles_1.withStyles)(styles)(Schedule);