@iobroker/gui-components 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +1450 -0
- package/build/AdminConnection.d.ts +1 -0
- package/build/AdminConnection.js +2 -0
- package/build/AdminConnection.js.map +1 -0
- package/build/Components/404.d.ts +4 -0
- package/build/Components/404.js +97 -0
- package/build/Components/404.js.map +1 -0
- package/build/Components/ColorPicker.d.ts +86 -0
- package/build/Components/ColorPicker.js +222 -0
- package/build/Components/ColorPicker.js.map +1 -0
- package/build/Components/ComplexCron.d.ts +40 -0
- package/build/Components/ComplexCron.js +401 -0
- package/build/Components/ComplexCron.js.map +1 -0
- package/build/Components/CopyToClipboard.d.ts +14 -0
- package/build/Components/CopyToClipboard.js +160 -0
- package/build/Components/CopyToClipboard.js.map +1 -0
- package/build/Components/CustomModal.d.ts +26 -0
- package/build/Components/CustomModal.js +62 -0
- package/build/Components/CustomModal.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeIcon.d.ts +29 -0
- package/build/Components/DeviceType/DeviceTypeIcon.js +108 -0
- package/build/Components/DeviceType/DeviceTypeIcon.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeOptions.d.ts +2 -0
- package/build/Components/DeviceType/DeviceTypeOptions.js +69 -0
- package/build/Components/DeviceType/DeviceTypeOptions.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeSelector.d.ts +20 -0
- package/build/Components/DeviceType/DeviceTypeSelector.js +83 -0
- package/build/Components/DeviceType/DeviceTypeSelector.js.map +1 -0
- package/build/Components/DeviceType/deviceTypeTranslations.d.ts +1 -0
- package/build/Components/DeviceType/deviceTypeTranslations.js +30 -0
- package/build/Components/DeviceType/deviceTypeTranslations.js.map +1 -0
- package/build/Components/DeviceType/i18n/de.json +46 -0
- package/build/Components/DeviceType/i18n/en.json +46 -0
- package/build/Components/DeviceType/i18n/fr.json +46 -0
- package/build/Components/DeviceType/i18n/it.json +46 -0
- package/build/Components/DeviceType/i18n/nl.json +46 -0
- package/build/Components/DeviceType/i18n/pl.json +46 -0
- package/build/Components/DeviceType/i18n/pt.json +46 -0
- package/build/Components/DeviceType/i18n/ru.json +46 -0
- package/build/Components/DeviceType/i18n/uk.json +46 -0
- package/build/Components/DeviceType/i18n/zh-cn.json +46 -0
- package/build/Components/DeviceType/icons/Cleaner.d.ts +3 -0
- package/build/Components/DeviceType/icons/Cleaner.js +14 -0
- package/build/Components/DeviceType/icons/Cleaner.js.map +1 -0
- package/build/Components/DeviceType/icons/DoorClosed.d.ts +3 -0
- package/build/Components/DeviceType/icons/DoorClosed.js +7 -0
- package/build/Components/DeviceType/icons/DoorClosed.js.map +1 -0
- package/build/Components/DeviceType/icons/DoorOpened.d.ts +3 -0
- package/build/Components/DeviceType/icons/DoorOpened.js +7 -0
- package/build/Components/DeviceType/icons/DoorOpened.js.map +1 -0
- package/build/Components/DeviceType/icons/FireOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/FireOff.js +8 -0
- package/build/Components/DeviceType/icons/FireOff.js.map +1 -0
- package/build/Components/DeviceType/icons/FireOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/FireOn.js +14 -0
- package/build/Components/DeviceType/icons/FireOn.js.map +1 -0
- package/build/Components/DeviceType/icons/FloodOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/FloodOff.js +11 -0
- package/build/Components/DeviceType/icons/FloodOff.js.map +1 -0
- package/build/Components/DeviceType/icons/FloodOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/FloodOn.js +18 -0
- package/build/Components/DeviceType/icons/FloodOn.js.map +1 -0
- package/build/Components/DeviceType/icons/Gate.d.ts +3 -0
- package/build/Components/DeviceType/icons/Gate.js +8 -0
- package/build/Components/DeviceType/icons/Gate.js.map +1 -0
- package/build/Components/DeviceType/icons/HeatValve.d.ts +3 -0
- package/build/Components/DeviceType/icons/HeatValve.js +6 -0
- package/build/Components/DeviceType/icons/HeatValve.js.map +1 -0
- package/build/Components/DeviceType/icons/Home.d.ts +3 -0
- package/build/Components/DeviceType/icons/Home.js +6 -0
- package/build/Components/DeviceType/icons/Home.js.map +1 -0
- package/build/Components/DeviceType/icons/Humidity.d.ts +3 -0
- package/build/Components/DeviceType/icons/Humidity.js +8 -0
- package/build/Components/DeviceType/icons/Humidity.js.map +1 -0
- package/build/Components/DeviceType/icons/IconHome.d.ts +5 -0
- package/build/Components/DeviceType/icons/IconHome.js +21 -0
- package/build/Components/DeviceType/icons/IconHome.js.map +1 -0
- package/build/Components/DeviceType/icons/Jalousie.d.ts +3 -0
- package/build/Components/DeviceType/icons/Jalousie.js +7 -0
- package/build/Components/DeviceType/icons/Jalousie.js.map +1 -0
- package/build/Components/DeviceType/icons/Material.d.ts +3 -0
- package/build/Components/DeviceType/icons/Material.js +8 -0
- package/build/Components/DeviceType/icons/Material.js.map +1 -0
- package/build/Components/DeviceType/icons/MotionOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/MotionOff.js +11 -0
- package/build/Components/DeviceType/icons/MotionOff.js.map +1 -0
- package/build/Components/DeviceType/icons/MotionOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/MotionOn.js +7 -0
- package/build/Components/DeviceType/icons/MotionOn.js.map +1 -0
- package/build/Components/DeviceType/icons/PushButton.d.ts +3 -0
- package/build/Components/DeviceType/icons/PushButton.js +9 -0
- package/build/Components/DeviceType/icons/PushButton.js.map +1 -0
- package/build/Components/DeviceType/icons/RGB.d.ts +3 -0
- package/build/Components/DeviceType/icons/RGB.js +43 -0
- package/build/Components/DeviceType/icons/RGB.js.map +1 -0
- package/build/Components/DeviceType/icons/RepairExpert.d.ts +3 -0
- package/build/Components/DeviceType/icons/RepairExpert.js +6 -0
- package/build/Components/DeviceType/icons/RepairExpert.js.map +1 -0
- package/build/Components/DeviceType/icons/Socket.d.ts +3 -0
- package/build/Components/DeviceType/icons/Socket.js +8 -0
- package/build/Components/DeviceType/icons/Socket.js.map +1 -0
- package/build/Components/DeviceType/icons/Thermometer.d.ts +3 -0
- package/build/Components/DeviceType/icons/Thermometer.js +7 -0
- package/build/Components/DeviceType/icons/Thermometer.js.map +1 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.d.ts +3 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.js +8 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.js.map +1 -0
- package/build/Components/DeviceType/icons/Thermostat.d.ts +3 -0
- package/build/Components/DeviceType/icons/Thermostat.js +9 -0
- package/build/Components/DeviceType/icons/Thermostat.js.map +1 -0
- package/build/Components/DeviceType/icons/Valve.d.ts +3 -0
- package/build/Components/DeviceType/icons/Valve.js +7 -0
- package/build/Components/DeviceType/icons/Valve.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowClosed.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowClosed.js +8 -0
- package/build/Components/DeviceType/icons/WindowClosed.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowOpened.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowOpened.js +9 -0
- package/build/Components/DeviceType/icons/WindowOpened.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowTilted.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowTilted.js +8 -0
- package/build/Components/DeviceType/icons/WindowTilted.js.map +1 -0
- package/build/Components/DeviceType/icons/index.d.ts +28 -0
- package/build/Components/DeviceType/icons/index.js +28 -0
- package/build/Components/DeviceType/icons/index.js.map +1 -0
- package/build/Components/FileBrowser.d.ts +187 -0
- package/build/Components/FileBrowser.js +1711 -0
- package/build/Components/FileBrowser.js.map +1 -0
- package/build/Components/FileViewer.d.ts +49 -0
- package/build/Components/FileViewer.js +247 -0
- package/build/Components/FileViewer.js.map +1 -0
- package/build/Components/Icon.d.ts +35 -0
- package/build/Components/Icon.js +140 -0
- package/build/Components/Icon.js.map +1 -0
- package/build/Components/IconPicker.d.ts +25 -0
- package/build/Components/IconPicker.js +72 -0
- package/build/Components/IconPicker.js.map +1 -0
- package/build/Components/IconSelector.d.ts +33 -0
- package/build/Components/IconSelector.js +2086 -0
- package/build/Components/IconSelector.js.map +1 -0
- package/build/Components/Image.d.ts +31 -0
- package/build/Components/Image.js +126 -0
- package/build/Components/Image.js.map +1 -0
- package/build/Components/InfoBox.d.ts +37 -0
- package/build/Components/InfoBox.js +115 -0
- package/build/Components/InfoBox.js.map +1 -0
- package/build/Components/IobUri.d.ts +14 -0
- package/build/Components/IobUri.js +168 -0
- package/build/Components/IobUri.js.map +1 -0
- package/build/Components/Loader.d.ts +31 -0
- package/build/Components/Loader.js +265 -0
- package/build/Components/Loader.js.map +1 -0
- package/build/Components/Loaders/MV.d.ts +17 -0
- package/build/Components/Loaders/MV.js +61 -0
- package/build/Components/Loaders/MV.js.map +1 -0
- package/build/Components/Loaders/PT.d.ts +27 -0
- package/build/Components/Loaders/PT.js +150 -0
- package/build/Components/Loaders/PT.js.map +1 -0
- package/build/Components/Loaders/Vendor.d.ts +22 -0
- package/build/Components/Loaders/Vendor.js +52 -0
- package/build/Components/Loaders/Vendor.js.map +1 -0
- package/build/Components/Logo.d.ts +18 -0
- package/build/Components/Logo.js +109 -0
- package/build/Components/Logo.js.map +1 -0
- package/build/Components/MDUtils.d.ts +11 -0
- package/build/Components/MDUtils.js +99 -0
- package/build/Components/MDUtils.js.map +1 -0
- package/build/Components/ObjectBrowser.d.ts +665 -0
- package/build/Components/ObjectBrowser.js +6245 -0
- package/build/Components/ObjectBrowser.js.map +1 -0
- package/build/Components/Router.d.ts +21 -0
- package/build/Components/Router.js +77 -0
- package/build/Components/Router.js.map +1 -0
- package/build/Components/SaveCloseButtons.d.ts +20 -0
- package/build/Components/SaveCloseButtons.js +65 -0
- package/build/Components/SaveCloseButtons.js.map +1 -0
- package/build/Components/Schedule.d.ts +62 -0
- package/build/Components/Schedule.js +1266 -0
- package/build/Components/Schedule.js.map +1 -0
- package/build/Components/SelectWithIcon.d.ts +37 -0
- package/build/Components/SelectWithIcon.js +139 -0
- package/build/Components/SelectWithIcon.js.map +1 -0
- package/build/Components/SimpleCron/cronText.d.ts +10 -0
- package/build/Components/SimpleCron/cronText.js +14 -0
- package/build/Components/SimpleCron/cronText.js.map +1 -0
- package/build/Components/SimpleCron/index.d.ts +55 -0
- package/build/Components/SimpleCron/index.js +698 -0
- package/build/Components/SimpleCron/index.js.map +1 -0
- package/build/Components/TabContainer.d.ts +15 -0
- package/build/Components/TabContainer.js +23 -0
- package/build/Components/TabContainer.js.map +1 -0
- package/build/Components/TabContent.d.ts +11 -0
- package/build/Components/TabContent.js +20 -0
- package/build/Components/TabContent.js.map +1 -0
- package/build/Components/TabHeader.d.ts +6 -0
- package/build/Components/TabHeader.js +6 -0
- package/build/Components/TabHeader.js.map +1 -0
- package/build/Components/TableResize.d.ts +45 -0
- package/build/Components/TableResize.js +204 -0
- package/build/Components/TableResize.js.map +1 -0
- package/build/Components/TextWithIcon.d.ts +21 -0
- package/build/Components/TextWithIcon.js +113 -0
- package/build/Components/TextWithIcon.js.map +1 -0
- package/build/Components/ToggleThemeMenu.d.ts +12 -0
- package/build/Components/ToggleThemeMenu.js +13 -0
- package/build/Components/ToggleThemeMenu.js.map +1 -0
- package/build/Components/TreeTable.d.ts +79 -0
- package/build/Components/TreeTable.js +538 -0
- package/build/Components/TreeTable.js.map +1 -0
- package/build/Components/UploadImage.d.ts +23 -0
- package/build/Components/UploadImage.js +516 -0
- package/build/Components/UploadImage.js.map +1 -0
- package/build/Components/Utils.d.ts +331 -0
- package/build/Components/Utils.js +1605 -0
- package/build/Components/Utils.js.map +1 -0
- package/build/Components/withWidth.d.ts +2 -0
- package/build/Components/withWidth.js +22 -0
- package/build/Components/withWidth.js.map +1 -0
- package/build/Connection.d.ts +1 -0
- package/build/Connection.js +2 -0
- package/build/Connection.js.map +1 -0
- package/build/Dialogs/ComplexCron.d.ts +24 -0
- package/build/Dialogs/ComplexCron.js +85 -0
- package/build/Dialogs/ComplexCron.js.map +1 -0
- package/build/Dialogs/Confirm.d.ts +39 -0
- package/build/Dialogs/Confirm.js +83 -0
- package/build/Dialogs/Confirm.js.map +1 -0
- package/build/Dialogs/Cron.d.ts +29 -0
- package/build/Dialogs/Cron.js +72 -0
- package/build/Dialogs/Cron.js.map +1 -0
- package/build/Dialogs/Error.d.ts +18 -0
- package/build/Dialogs/Error.js +27 -0
- package/build/Dialogs/Error.js.map +1 -0
- package/build/Dialogs/Message.d.ts +20 -0
- package/build/Dialogs/Message.js +29 -0
- package/build/Dialogs/Message.js.map +1 -0
- package/build/Dialogs/SelectFile.d.ts +85 -0
- package/build/Dialogs/SelectFile.js +115 -0
- package/build/Dialogs/SelectFile.js.map +1 -0
- package/build/Dialogs/SelectID.d.ts +102 -0
- package/build/Dialogs/SelectID.js +151 -0
- package/build/Dialogs/SelectID.js.map +1 -0
- package/build/Dialogs/SimpleCron.d.ts +19 -0
- package/build/Dialogs/SimpleCron.js +46 -0
- package/build/Dialogs/SimpleCron.js.map +1 -0
- package/build/Dialogs/TextInput.d.ts +2 -0
- package/build/Dialogs/TextInput.js +31 -0
- package/build/Dialogs/TextInput.js.map +1 -0
- package/build/GenericApp.d.ts +209 -0
- package/build/GenericApp.js +842 -0
- package/build/GenericApp.js.map +1 -0
- package/build/LegacyConnection.d.ts +938 -0
- package/build/LegacyConnection.js +2849 -0
- package/build/LegacyConnection.js.map +1 -0
- package/build/Prompt.d.ts +5 -0
- package/build/Prompt.js +19 -0
- package/build/Prompt.js.map +1 -0
- package/build/Theme.d.ts +5 -0
- package/build/Theme.js +344 -0
- package/build/Theme.js.map +1 -0
- package/build/assets/devices/parseNames.d.ts +0 -0
- package/build/assets/devices/parseNames.js +35 -0
- package/build/assets/devices/parseNames.js.map +1 -0
- package/build/assets/devices.json +1 -0
- package/build/assets/lamp_ceiling.svg +9 -0
- package/build/assets/lamp_table.svg +8 -0
- package/build/assets/no_icon.svg +9 -0
- package/build/assets/rooms/parseNames.d.ts +0 -0
- package/build/assets/rooms/parseNames.js +35 -0
- package/build/assets/rooms/parseNames.js.map +1 -0
- package/build/assets/rooms.json +1 -0
- package/build/dictionary.d.ts +1 -0
- package/build/dictionary.js +25 -0
- package/build/dictionary.js.map +1 -0
- package/build/globals.d.ts +19 -0
- package/build/i18n/de.json +480 -0
- package/build/i18n/en.json +480 -0
- package/build/i18n/es.json +480 -0
- package/build/i18n/fr.json +480 -0
- package/build/i18n/it.json +475 -0
- package/build/i18n/nl.json +475 -0
- package/build/i18n/pl.json +475 -0
- package/build/i18n/pt.json +475 -0
- package/build/i18n/ru.json +475 -0
- package/build/i18n/uk.json +475 -0
- package/build/i18n/zh-cn.json +475 -0
- package/build/i18n.d.ts +84 -0
- package/build/i18n.js +224 -0
- package/build/i18n.js.map +1 -0
- package/build/icons/IconAdapter.d.ts +3 -0
- package/build/icons/IconAdapter.js +7 -0
- package/build/icons/IconAdapter.js.map +1 -0
- package/build/icons/IconAlias.d.ts +3 -0
- package/build/icons/IconAlias.js +7 -0
- package/build/icons/IconAlias.js.map +1 -0
- package/build/icons/IconButtonImage.d.ts +3 -0
- package/build/icons/IconButtonImage.js +9 -0
- package/build/icons/IconButtonImage.js.map +1 -0
- package/build/icons/IconChannel.d.ts +3 -0
- package/build/icons/IconChannel.js +10 -0
- package/build/icons/IconChannel.js.map +1 -0
- package/build/icons/IconClearFilter.d.ts +3 -0
- package/build/icons/IconClearFilter.js +8 -0
- package/build/icons/IconClearFilter.js.map +1 -0
- package/build/icons/IconClosed.d.ts +3 -0
- package/build/icons/IconClosed.js +7 -0
- package/build/icons/IconClosed.js.map +1 -0
- package/build/icons/IconCopy.d.ts +3 -0
- package/build/icons/IconCopy.js +6 -0
- package/build/icons/IconCopy.js.map +1 -0
- package/build/icons/IconDevice.d.ts +3 -0
- package/build/icons/IconDevice.js +16 -0
- package/build/icons/IconDevice.js.map +1 -0
- package/build/icons/IconDocument.d.ts +3 -0
- package/build/icons/IconDocument.js +7 -0
- package/build/icons/IconDocument.js.map +1 -0
- package/build/icons/IconDocumentReadOnly.d.ts +3 -0
- package/build/icons/IconDocumentReadOnly.js +8 -0
- package/build/icons/IconDocumentReadOnly.js.map +1 -0
- package/build/icons/IconExpert.d.ts +3 -0
- package/build/icons/IconExpert.js +7 -0
- package/build/icons/IconExpert.js.map +1 -0
- package/build/icons/IconFx.d.ts +3 -0
- package/build/icons/IconFx.js +6 -0
- package/build/icons/IconFx.js.map +1 -0
- package/build/icons/IconInstance.d.ts +3 -0
- package/build/icons/IconInstance.js +7 -0
- package/build/icons/IconInstance.js.map +1 -0
- package/build/icons/IconLogout.d.ts +3 -0
- package/build/icons/IconLogout.js +7 -0
- package/build/icons/IconLogout.js.map +1 -0
- package/build/icons/IconNoIcon.d.ts +3 -0
- package/build/icons/IconNoIcon.js +6 -0
- package/build/icons/IconNoIcon.js.map +1 -0
- package/build/icons/IconOpen.d.ts +3 -0
- package/build/icons/IconOpen.js +7 -0
- package/build/icons/IconOpen.js.map +1 -0
- package/build/icons/IconState.d.ts +3 -0
- package/build/icons/IconState.js +7 -0
- package/build/icons/IconState.js.map +1 -0
- package/build/icons/IconVacuum.d.ts +3 -0
- package/build/icons/IconVacuum.js +12 -0
- package/build/icons/IconVacuum.js.map +1 -0
- package/build/index.css +56 -0
- package/build/index.d.ts +87 -0
- package/build/index.js +85 -0
- package/build/index.js.map +1 -0
- package/build/modulefederation.admin.config.d.ts +13 -0
- package/build/modulefederation.admin.config.js +45 -0
- package/build/modulefederation.admin.config.js.map +1 -0
- package/build/types.d.ts +236 -0
- package/i18n/de.json +480 -0
- package/i18n/en.json +480 -0
- package/i18n/es.json +480 -0
- package/i18n/fr.json +480 -0
- package/i18n/it.json +475 -0
- package/i18n/nl.json +475 -0
- package/i18n/pl.json +475 -0
- package/i18n/pt.json +475 -0
- package/i18n/ru.json +475 -0
- package/i18n/uk.json +475 -0
- package/i18n/zh-cn.json +475 -0
- package/index.css +56 -0
- package/modulefederation.admin.config.d.ts +20 -0
- package/modulefederation.admin.config.js +54 -0
- package/package.json +86 -0
- package/tasksExample.js +91 -0
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputLabel, MenuItem, Select, TextField, FormControl, FormControlLabel, Checkbox, } from '@mui/material';
|
|
3
|
+
import { convertCronToText } from './cronText';
|
|
4
|
+
import { I18n } from '../../i18n';
|
|
5
|
+
const styles = {
|
|
6
|
+
mainDiv: {
|
|
7
|
+
width: '100%',
|
|
8
|
+
height: '100%',
|
|
9
|
+
overflow: 'auto',
|
|
10
|
+
},
|
|
11
|
+
formControl: {
|
|
12
|
+
margin: 0,
|
|
13
|
+
minWidth: 120,
|
|
14
|
+
},
|
|
15
|
+
formControlMarginRight: {
|
|
16
|
+
marginRight: 5,
|
|
17
|
+
},
|
|
18
|
+
formControlPaddingTop: {
|
|
19
|
+
paddingTop: 6.2,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const PERIODIC = {
|
|
23
|
+
once: 'once',
|
|
24
|
+
interval: 'interval',
|
|
25
|
+
intervalBetween: 'intervalBetween',
|
|
26
|
+
specific: 'specific',
|
|
27
|
+
};
|
|
28
|
+
const PERIODIC_TYPES = {
|
|
29
|
+
seconds: 'seconds',
|
|
30
|
+
minutes: 'minutes',
|
|
31
|
+
// hours: 'hours',
|
|
32
|
+
};
|
|
33
|
+
const WEEKDAYS = [
|
|
34
|
+
'ra_Sunday',
|
|
35
|
+
'ra_Monday',
|
|
36
|
+
'ra_Tuesday',
|
|
37
|
+
'ra_Wednesday',
|
|
38
|
+
'ra_Thursday',
|
|
39
|
+
'ra_Friday',
|
|
40
|
+
'ra_Saturday',
|
|
41
|
+
'ra_Sunday',
|
|
42
|
+
];
|
|
43
|
+
function padding(num) {
|
|
44
|
+
if (num < 10) {
|
|
45
|
+
return `0${num}`;
|
|
46
|
+
}
|
|
47
|
+
return `${num}`;
|
|
48
|
+
}
|
|
49
|
+
const DEFAULT_STATE = {
|
|
50
|
+
mode: 'interval',
|
|
51
|
+
interval: {
|
|
52
|
+
period: 1,
|
|
53
|
+
unit: PERIODIC_TYPES.minutes,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
function text2weekdays(text) {
|
|
57
|
+
if (text === '*') {
|
|
58
|
+
return [0, 1, 2, 3, 4, 5, 6];
|
|
59
|
+
}
|
|
60
|
+
const parts = text.split(',');
|
|
61
|
+
const list = [];
|
|
62
|
+
parts.forEach(part => {
|
|
63
|
+
const _parts = part.split('-');
|
|
64
|
+
if (_parts.length === 2) {
|
|
65
|
+
const start = parseInt(_parts[0], 10);
|
|
66
|
+
const end = parseInt(_parts[1], 10);
|
|
67
|
+
for (let day = start; day <= end; day++) {
|
|
68
|
+
if (!list.includes(day === 7 ? 0 : day)) {
|
|
69
|
+
list.push(day === 7 ? 0 : day);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
if (part === '7') {
|
|
75
|
+
part = '0';
|
|
76
|
+
}
|
|
77
|
+
const numPart = parseInt(part, 10);
|
|
78
|
+
if (!list.includes(numPart)) {
|
|
79
|
+
list.push(numPart);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
list.sort();
|
|
84
|
+
return list;
|
|
85
|
+
}
|
|
86
|
+
export function cron2state(cron, force) {
|
|
87
|
+
cron = cron.replace(/['"]/g, '').trim();
|
|
88
|
+
const cronParts = cron.split(' ');
|
|
89
|
+
let options;
|
|
90
|
+
let state = null;
|
|
91
|
+
if (cronParts.length === 6) {
|
|
92
|
+
options = {
|
|
93
|
+
seconds: cronParts[0] || '*',
|
|
94
|
+
minutes: cronParts[1] || '*',
|
|
95
|
+
hours: cronParts[2] || '*',
|
|
96
|
+
date: cronParts[3] || '*',
|
|
97
|
+
months: cronParts[4] || '*',
|
|
98
|
+
dow: cronParts[5] || '*',
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
options = {
|
|
103
|
+
seconds: null,
|
|
104
|
+
minutes: cronParts[0] || '*',
|
|
105
|
+
hours: cronParts[1] || '*',
|
|
106
|
+
date: cronParts[2] || '*',
|
|
107
|
+
months: cronParts[3] || '*',
|
|
108
|
+
dow: cronParts[4] || '*',
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// * * * * *
|
|
112
|
+
if (options.seconds === null &&
|
|
113
|
+
options.minutes === '*' &&
|
|
114
|
+
options.hours === '*' &&
|
|
115
|
+
options.date === '*' &&
|
|
116
|
+
options.months === '*' &&
|
|
117
|
+
(options.dow === '*' || force)) {
|
|
118
|
+
state = {
|
|
119
|
+
mode: 'interval',
|
|
120
|
+
interval: {
|
|
121
|
+
period: 1,
|
|
122
|
+
unit: PERIODIC_TYPES.minutes,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
} // * * * * * *
|
|
126
|
+
if (options.seconds === '*' &&
|
|
127
|
+
options.minutes === '*' &&
|
|
128
|
+
options.hours === '*' &&
|
|
129
|
+
options.date === '*' &&
|
|
130
|
+
options.months === '*' &&
|
|
131
|
+
(options.dow === '*' || force)) {
|
|
132
|
+
state = {
|
|
133
|
+
mode: 'interval',
|
|
134
|
+
interval: {
|
|
135
|
+
period: 1,
|
|
136
|
+
unit: PERIODIC_TYPES.seconds,
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
else if (options.seconds === null &&
|
|
141
|
+
options.minutes.includes('/') &&
|
|
142
|
+
options.hours === '*' &&
|
|
143
|
+
options.date === '*' &&
|
|
144
|
+
options.months === '*' &&
|
|
145
|
+
(options.dow === '*' || force)) {
|
|
146
|
+
// */n * * * *
|
|
147
|
+
state = {
|
|
148
|
+
mode: 'interval',
|
|
149
|
+
interval: {
|
|
150
|
+
period: parseInt(options.minutes.split('/')[1], 10),
|
|
151
|
+
unit: PERIODIC_TYPES.minutes,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
else if (options.seconds !== null &&
|
|
156
|
+
options.seconds.includes('/') &&
|
|
157
|
+
options.minutes === '*' &&
|
|
158
|
+
options.hours === '*' &&
|
|
159
|
+
options.date === '*' &&
|
|
160
|
+
options.months === '*' &&
|
|
161
|
+
(options.dow === '*' || force)) {
|
|
162
|
+
// */n * * * * *
|
|
163
|
+
state = {
|
|
164
|
+
mode: 'interval',
|
|
165
|
+
interval: {
|
|
166
|
+
period: parseInt(options.seconds.split('/')[1], 10),
|
|
167
|
+
unit: PERIODIC_TYPES.seconds,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
else if (options.seconds !== null &&
|
|
172
|
+
options.seconds.includes('/') &&
|
|
173
|
+
options.minutes === '*' &&
|
|
174
|
+
options.hours.includes('-') &&
|
|
175
|
+
options.date === '*' &&
|
|
176
|
+
options.months === '*' &&
|
|
177
|
+
(options.dow === '*' || force)) {
|
|
178
|
+
// */n * 0-23 * * 1-7 or */n * 0-23 * * *
|
|
179
|
+
state = {
|
|
180
|
+
mode: 'intervalBetween',
|
|
181
|
+
intervalBetween: {
|
|
182
|
+
period: parseInt(options.seconds.split('/')[1], 10),
|
|
183
|
+
unit: PERIODIC_TYPES.seconds,
|
|
184
|
+
timeFrom: parseInt(options.hours.split('-')[0], 10),
|
|
185
|
+
timeTo: parseInt(options.hours.split('-')[1], 10),
|
|
186
|
+
weekdays: text2weekdays(options.dow),
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
else if (options.seconds === null &&
|
|
191
|
+
options.minutes.includes('/') &&
|
|
192
|
+
options.hours.includes('-') &&
|
|
193
|
+
options.date === '*' &&
|
|
194
|
+
options.months === '*' &&
|
|
195
|
+
(options.dow === '*' || force)) {
|
|
196
|
+
// */n 0-23 * * 1-7 or */n 0-23 * * *
|
|
197
|
+
state = {
|
|
198
|
+
mode: 'intervalBetween',
|
|
199
|
+
intervalBetween: {
|
|
200
|
+
period: parseInt(options.minutes.split('/')[1], 10),
|
|
201
|
+
unit: PERIODIC_TYPES.minutes,
|
|
202
|
+
timeFrom: parseInt(options.hours.split('-')[0], 10),
|
|
203
|
+
timeTo: parseInt(options.hours.split('-')[1], 10),
|
|
204
|
+
weekdays: text2weekdays(options.dow),
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
else if (options.seconds === null &&
|
|
209
|
+
parseInt(options.minutes, 10).toString() === options.minutes &&
|
|
210
|
+
parseInt(options.hours, 10).toString() === options.hours &&
|
|
211
|
+
options.date === '*' &&
|
|
212
|
+
options.months === '*' &&
|
|
213
|
+
(options.dow === '*' || force)) {
|
|
214
|
+
// m h * * 1-7 or m h * * *
|
|
215
|
+
state = {
|
|
216
|
+
mode: 'specific',
|
|
217
|
+
specific: {
|
|
218
|
+
time: `${padding(parseInt(options.hours, 10))}:${padding(parseInt(options.minutes, 10))}`,
|
|
219
|
+
weekdays: text2weekdays(options.dow),
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
else if (options.seconds === null &&
|
|
224
|
+
parseInt(options.minutes, 10).toString() === options.minutes &&
|
|
225
|
+
parseInt(options.hours, 10).toString() === options.hours &&
|
|
226
|
+
parseInt(options.date, 10).toString() === options.date &&
|
|
227
|
+
parseInt(options.months, 10).toString() === options.months &&
|
|
228
|
+
(options.dow === '*' || force)) {
|
|
229
|
+
// m h d M *
|
|
230
|
+
state = {
|
|
231
|
+
mode: 'once',
|
|
232
|
+
once: {
|
|
233
|
+
time: `${padding(parseInt(options.hours, 10))}:${padding(parseInt(options.minutes, 10))}`,
|
|
234
|
+
date: `${padding(parseInt(options.date, 10))}.${padding(parseInt(options.months, 10))}`,
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
return state;
|
|
239
|
+
}
|
|
240
|
+
export class SimpleCron extends React.Component {
|
|
241
|
+
constructor(props) {
|
|
242
|
+
super(props);
|
|
243
|
+
let cron = typeof props.cronExpression === 'string'
|
|
244
|
+
? props.cronExpression.replace(/^["']/, '').replace(/["']\n?$/, '')
|
|
245
|
+
: '';
|
|
246
|
+
if (cron[0] === '{') {
|
|
247
|
+
cron = '';
|
|
248
|
+
}
|
|
249
|
+
const state = cron2state(cron || '* * * * *', true) || DEFAULT_STATE;
|
|
250
|
+
this.state = {
|
|
251
|
+
extended: false,
|
|
252
|
+
cron: SimpleCron.state2cron(state),
|
|
253
|
+
mode: 'interval',
|
|
254
|
+
once: {
|
|
255
|
+
time: '00:00',
|
|
256
|
+
date: '',
|
|
257
|
+
},
|
|
258
|
+
interval: {
|
|
259
|
+
period: 1,
|
|
260
|
+
unit: PERIODIC_TYPES.minutes,
|
|
261
|
+
},
|
|
262
|
+
intervalBetween: {
|
|
263
|
+
period: 1,
|
|
264
|
+
unit: PERIODIC_TYPES.minutes,
|
|
265
|
+
timeFrom: 0,
|
|
266
|
+
timeTo: 23,
|
|
267
|
+
weekdays: [0, 1, 2, 3, 4, 5, 6],
|
|
268
|
+
},
|
|
269
|
+
specific: {
|
|
270
|
+
time: '00:00',
|
|
271
|
+
weekdays: [0, 1, 2, 3, 4, 5, 6],
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
Object.assign(this.state, state);
|
|
275
|
+
if (this.state.cron !== props.cronExpression) {
|
|
276
|
+
setTimeout(() => props.onChange && props.onChange(this.state.cron), 100);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
static periodArray2text(list, max = 7) {
|
|
280
|
+
max = max || 7;
|
|
281
|
+
if (list.length === max) {
|
|
282
|
+
return '*';
|
|
283
|
+
}
|
|
284
|
+
const text = [];
|
|
285
|
+
let start = null;
|
|
286
|
+
let end = null;
|
|
287
|
+
if (!list.length) {
|
|
288
|
+
return '_';
|
|
289
|
+
}
|
|
290
|
+
for (let i = 0; i < list.length; i++) {
|
|
291
|
+
if (start === null) {
|
|
292
|
+
start = list[i];
|
|
293
|
+
end = list[i];
|
|
294
|
+
}
|
|
295
|
+
else if (list[i - 1] + 1 === list[i]) {
|
|
296
|
+
end = list[i];
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
if (start !== end) {
|
|
300
|
+
text.push(`${start}-${end}`);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
text.push(start);
|
|
304
|
+
}
|
|
305
|
+
start = list[i];
|
|
306
|
+
end = list[i];
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (start !== end) {
|
|
310
|
+
text.push(`${start}-${end}`);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
text.push(start);
|
|
314
|
+
}
|
|
315
|
+
return text.join(',');
|
|
316
|
+
}
|
|
317
|
+
static text2weekdays(text) {
|
|
318
|
+
return text2weekdays(text);
|
|
319
|
+
}
|
|
320
|
+
static state2cron(state) {
|
|
321
|
+
let cron = '* * * * *';
|
|
322
|
+
if (state.mode === 'interval') {
|
|
323
|
+
const settings = state.interval || {
|
|
324
|
+
period: 1,
|
|
325
|
+
unit: PERIODIC_TYPES.minutes,
|
|
326
|
+
};
|
|
327
|
+
if (settings.period !== undefined && settings.period > 60) {
|
|
328
|
+
settings.period = 60;
|
|
329
|
+
}
|
|
330
|
+
if (settings.period !== undefined && settings.period < 1) {
|
|
331
|
+
settings.period = 1;
|
|
332
|
+
}
|
|
333
|
+
if (settings.minutes !== undefined && settings.minutes !== null && settings.minutes > 60) {
|
|
334
|
+
settings.minutes = 60;
|
|
335
|
+
}
|
|
336
|
+
if (settings.minutes !== undefined && settings.minutes !== null && settings.minutes < 1) {
|
|
337
|
+
settings.minutes = 1;
|
|
338
|
+
}
|
|
339
|
+
if (settings.hours !== undefined && settings.hours !== null && settings.hours > 24) {
|
|
340
|
+
settings.hours = 24;
|
|
341
|
+
}
|
|
342
|
+
if (settings.hours !== undefined && settings.hours !== null && settings.hours < 1) {
|
|
343
|
+
settings.hours = 1;
|
|
344
|
+
}
|
|
345
|
+
if (state.extended) {
|
|
346
|
+
cron = `${settings.minutes !== undefined && settings.minutes !== null && settings.minutes > 1 ? `*/${settings.minutes}` : '*'} ${settings.hours !== undefined && settings.hours !== null && settings.hours > 1 ? `*/${settings.hours}` : '*'} * * *`;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
switch (settings.unit) {
|
|
350
|
+
case PERIODIC_TYPES.seconds:
|
|
351
|
+
cron = `${settings.period > 1 ? `*/${settings.period}` : '*'} * * * * *`;
|
|
352
|
+
break;
|
|
353
|
+
case PERIODIC_TYPES.minutes:
|
|
354
|
+
cron = `${settings.period > 1 ? `*/${settings.period}` : '*'} * * * *`;
|
|
355
|
+
break;
|
|
356
|
+
default:
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
else if (state.mode === 'intervalBetween') {
|
|
362
|
+
const settings = state.intervalBetween || {
|
|
363
|
+
period: 1,
|
|
364
|
+
unit: PERIODIC_TYPES.minutes,
|
|
365
|
+
timeFrom: 0,
|
|
366
|
+
timeTo: 24,
|
|
367
|
+
weekdays: [0, 1, 2, 3, 4, 5, 6],
|
|
368
|
+
};
|
|
369
|
+
let hours;
|
|
370
|
+
settings.timeFrom = settings.timeFrom || 0;
|
|
371
|
+
settings.timeTo = settings.timeTo === undefined ? 24 : settings.timeTo;
|
|
372
|
+
if (settings.timeFrom !== 0 && settings.timeTo === 24) {
|
|
373
|
+
settings.timeTo = 23;
|
|
374
|
+
}
|
|
375
|
+
if (settings.timeFrom === 0 && settings.timeTo === 24) {
|
|
376
|
+
hours = '*';
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
hours = settings.timeFrom !== settings.timeTo ? `${settings.timeFrom}-${settings.timeTo}` : '*';
|
|
380
|
+
}
|
|
381
|
+
if (settings.period > 60) {
|
|
382
|
+
settings.period = 60;
|
|
383
|
+
}
|
|
384
|
+
if (settings.period < 1) {
|
|
385
|
+
settings.period = 1;
|
|
386
|
+
}
|
|
387
|
+
settings.unit = settings.unit || PERIODIC_TYPES.minutes;
|
|
388
|
+
switch (settings.unit) {
|
|
389
|
+
case PERIODIC_TYPES.seconds:
|
|
390
|
+
cron = `${settings.period > 1 ? `*/${settings.period}` : '*'} * ${hours} * * ${this.periodArray2text(settings.weekdays)}`;
|
|
391
|
+
break;
|
|
392
|
+
case PERIODIC_TYPES.minutes:
|
|
393
|
+
cron = `${settings.period > 1 ? `*/${settings.period}` : '*'} ${hours} * * ${this.periodArray2text(settings.weekdays)}`;
|
|
394
|
+
break;
|
|
395
|
+
default:
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
else if (state.mode === 'specific') {
|
|
400
|
+
const settings = state.specific || {
|
|
401
|
+
time: '00:00',
|
|
402
|
+
weekdays: [0, 1, 2, 3, 4, 5, 6],
|
|
403
|
+
};
|
|
404
|
+
const parts = (settings.time || '00:00').split(':');
|
|
405
|
+
let minutes = parseInt(parts[1], 10) || 0;
|
|
406
|
+
if (minutes > 59) {
|
|
407
|
+
minutes = 59;
|
|
408
|
+
}
|
|
409
|
+
if (minutes < 0) {
|
|
410
|
+
minutes = 0;
|
|
411
|
+
}
|
|
412
|
+
let hours = parseInt(parts[0], 10) || 0;
|
|
413
|
+
if (hours > 23) {
|
|
414
|
+
hours = 59;
|
|
415
|
+
}
|
|
416
|
+
if (hours < 0) {
|
|
417
|
+
hours = 0;
|
|
418
|
+
}
|
|
419
|
+
cron = `${minutes} ${hours} * * ${this.periodArray2text(settings.weekdays || [])}`;
|
|
420
|
+
}
|
|
421
|
+
else if (state.mode === 'once') {
|
|
422
|
+
const settings = state.once || {
|
|
423
|
+
time: '00:00',
|
|
424
|
+
date: '',
|
|
425
|
+
};
|
|
426
|
+
if (!settings.date) {
|
|
427
|
+
settings.date = `${new Date().getDate()}.${padding(new Date().getMonth() + 1)}`;
|
|
428
|
+
}
|
|
429
|
+
const parts = (settings.time || '00:00').split(':');
|
|
430
|
+
const partsDate = settings.date.split('.');
|
|
431
|
+
let minutes = parseInt(parts[1], 10) || 0;
|
|
432
|
+
if (minutes > 59) {
|
|
433
|
+
minutes = 59;
|
|
434
|
+
}
|
|
435
|
+
if (minutes < 0) {
|
|
436
|
+
minutes = 0;
|
|
437
|
+
}
|
|
438
|
+
let hours = parseInt(parts[0], 10) || 0;
|
|
439
|
+
if (hours > 23) {
|
|
440
|
+
hours = 59;
|
|
441
|
+
}
|
|
442
|
+
if (hours < 0) {
|
|
443
|
+
hours = 0;
|
|
444
|
+
}
|
|
445
|
+
let date = parseInt(partsDate[0], 10) || 1;
|
|
446
|
+
if (date > 31) {
|
|
447
|
+
date = 31;
|
|
448
|
+
}
|
|
449
|
+
if (date < 1) {
|
|
450
|
+
hours = 1;
|
|
451
|
+
}
|
|
452
|
+
let month = parseInt(partsDate[1], 10) || 1;
|
|
453
|
+
if (month > 12) {
|
|
454
|
+
month = 12;
|
|
455
|
+
}
|
|
456
|
+
if (month < 1) {
|
|
457
|
+
month = 1;
|
|
458
|
+
}
|
|
459
|
+
cron = `${minutes} ${hours} ${date} ${month} *`;
|
|
460
|
+
}
|
|
461
|
+
return cron;
|
|
462
|
+
}
|
|
463
|
+
recalcCron() {
|
|
464
|
+
this.onChange(SimpleCron.state2cron(this.state));
|
|
465
|
+
}
|
|
466
|
+
getControlsWeekdaysElements(type) {
|
|
467
|
+
const settings = type === 'intervalBetween' ? this.state.intervalBetween : this.state.specific;
|
|
468
|
+
return (React.createElement("div", { key: "weekdays", style: { paddingLeft: 8, width: 'calc(100% - 8px)', maxWidth: 600 } },
|
|
469
|
+
React.createElement("h5", null, I18n.t('ra_On weekdays')),
|
|
470
|
+
[1, 2, 3, 4, 5, 6, 0].map(day => (React.createElement(FormControlLabel, { key: WEEKDAYS[day], control: React.createElement(Checkbox, { checked: settings.weekdays.includes(day), onChange: e => {
|
|
471
|
+
const _settings = JSON.parse(JSON.stringify(this.state[type]));
|
|
472
|
+
const pos = _settings.weekdays.indexOf(day);
|
|
473
|
+
if (e.target.checked) {
|
|
474
|
+
if (pos === -1) {
|
|
475
|
+
_settings.weekdays.push(day);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
if (pos !== -1) {
|
|
480
|
+
_settings.weekdays.splice(pos, 1);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
_settings.weekdays.sort();
|
|
484
|
+
if (type === 'intervalBetween') {
|
|
485
|
+
this.setState({ intervalBetween: _settings }, () => this.recalcCron());
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
this.setState({ specific: _settings }, () => this.recalcCron());
|
|
489
|
+
}
|
|
490
|
+
}, value: day.toString() }), label: I18n.t(WEEKDAYS[day]) })))));
|
|
491
|
+
}
|
|
492
|
+
getControlsPeriodElements(type) {
|
|
493
|
+
const settings = type === 'interval' ? this.state.interval : this.state.intervalBetween;
|
|
494
|
+
if (this.state.extended) {
|
|
495
|
+
return (React.createElement("div", { key: "period", style: { paddingLeft: 8, display: 'inline-block' } },
|
|
496
|
+
React.createElement("h5", { style: { marginBottom: 5 } }, I18n.t('sc_period')),
|
|
497
|
+
React.createElement(TextField, { variant: "standard", style: { marginTop: 0, marginBottom: 0, verticalAlign: 'bottom' }, key: "value", label: I18n.t('sc_minutes'), value: settings.minutes, onChange: e => {
|
|
498
|
+
const _settings = JSON.parse(JSON.stringify(this.state[type]));
|
|
499
|
+
_settings.minutes = parseInt(e.target.value, 10);
|
|
500
|
+
if (_settings.minutes < 1) {
|
|
501
|
+
_settings.minutes = 1;
|
|
502
|
+
}
|
|
503
|
+
if (type === 'interval') {
|
|
504
|
+
this.setState({ interval: _settings }, () => this.recalcCron());
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
this.setState({ intervalBetween: _settings }, () => this.recalcCron());
|
|
508
|
+
}
|
|
509
|
+
}, slotProps: {
|
|
510
|
+
htmlInput: {
|
|
511
|
+
min: 1,
|
|
512
|
+
max: 60,
|
|
513
|
+
},
|
|
514
|
+
inputLabel: {
|
|
515
|
+
shrink: true,
|
|
516
|
+
},
|
|
517
|
+
}, type: "number", margin: "normal" }),
|
|
518
|
+
React.createElement(TextField, { variant: "standard", style: { marginTop: 0, marginBottom: 0, verticalAlign: 'bottom' }, key: "value", label: I18n.t('sc_hours'), value: settings.hours, onChange: e => {
|
|
519
|
+
const _settings = JSON.parse(JSON.stringify(this.state[type]));
|
|
520
|
+
_settings.hours = parseInt(e.target.value, 10);
|
|
521
|
+
if (_settings.hours < 1) {
|
|
522
|
+
_settings.hours = 1;
|
|
523
|
+
}
|
|
524
|
+
if (type === 'interval') {
|
|
525
|
+
this.setState({ interval: _settings }, () => this.recalcCron());
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
this.setState({ intervalBetween: _settings }, () => this.recalcCron());
|
|
529
|
+
}
|
|
530
|
+
}, slotProps: {
|
|
531
|
+
htmlInput: {
|
|
532
|
+
min: 1,
|
|
533
|
+
max: 24,
|
|
534
|
+
},
|
|
535
|
+
inputLabel: {
|
|
536
|
+
shrink: true,
|
|
537
|
+
},
|
|
538
|
+
}, type: "number", margin: "normal" })));
|
|
539
|
+
}
|
|
540
|
+
return (React.createElement("div", { key: "period", style: { paddingLeft: 8, display: 'inline-block' } },
|
|
541
|
+
React.createElement("h5", { style: { marginBottom: 5 } }, I18n.t('sc_period')),
|
|
542
|
+
React.createElement(TextField, { variant: "standard", style: { marginTop: 0, marginBottom: 0, verticalAlign: 'bottom' }, key: "value", label: I18n.t('sc_every'), value: settings.period, onChange: e => {
|
|
543
|
+
const _settings = JSON.parse(JSON.stringify(this.state[type]));
|
|
544
|
+
_settings.period = parseInt(e.target.value, 10);
|
|
545
|
+
if (_settings.period < 1) {
|
|
546
|
+
_settings.period = 1;
|
|
547
|
+
}
|
|
548
|
+
if (type === 'interval') {
|
|
549
|
+
this.setState({ interval: _settings }, () => this.recalcCron());
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
this.setState({ intervalBetween: _settings }, () => this.recalcCron());
|
|
553
|
+
}
|
|
554
|
+
}, slotProps: {
|
|
555
|
+
htmlInput: {
|
|
556
|
+
min: 1,
|
|
557
|
+
max: 60,
|
|
558
|
+
},
|
|
559
|
+
inputLabel: {
|
|
560
|
+
shrink: true,
|
|
561
|
+
},
|
|
562
|
+
}, type: "number", margin: "normal" }),
|
|
563
|
+
React.createElement(Select, { variant: "standard", style: { verticalAlign: 'bottom' }, value: settings.unit, onChange: e => {
|
|
564
|
+
const _settings = JSON.parse(JSON.stringify(this.state[type]));
|
|
565
|
+
_settings.unit = e.target.value;
|
|
566
|
+
if (type === 'interval') {
|
|
567
|
+
this.setState({ interval: _settings }, () => this.recalcCron());
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
this.setState({ intervalBetween: _settings }, () => this.recalcCron());
|
|
571
|
+
}
|
|
572
|
+
} },
|
|
573
|
+
React.createElement(MenuItem, { value: "seconds" }, I18n.t('sc_seconds')),
|
|
574
|
+
")",
|
|
575
|
+
React.createElement(MenuItem, { value: "minutes" }, I18n.t('sc_minutes')),
|
|
576
|
+
")")));
|
|
577
|
+
}
|
|
578
|
+
getControlsTime(type) {
|
|
579
|
+
const settings = type === 'once' ? this.state.once : this.state.specific;
|
|
580
|
+
return (React.createElement(FormControl, { variant: "standard", sx: {
|
|
581
|
+
...styles.formControl,
|
|
582
|
+
'&.MuiFormControl-root': styles.formControlMarginRight,
|
|
583
|
+
} },
|
|
584
|
+
React.createElement(TextField, { variant: "standard", key: "at", label: I18n.t('sc_time'), value: settings.time, type: "time", sx: (theme) => ({
|
|
585
|
+
'& input[type="time"]::-webkit-calendar-picker-indicator': {
|
|
586
|
+
filter: theme.palette.mode === 'dark' ? 'invert(80%)' : undefined,
|
|
587
|
+
},
|
|
588
|
+
}), onChange: e => {
|
|
589
|
+
const _settings = JSON.parse(JSON.stringify(this.state[type]));
|
|
590
|
+
_settings.time = e.target.value;
|
|
591
|
+
if (type === 'once') {
|
|
592
|
+
this.setState({ once: _settings }, () => this.recalcCron());
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
this.setState({ specific: _settings }, () => this.recalcCron());
|
|
596
|
+
}
|
|
597
|
+
}, slotProps: {
|
|
598
|
+
inputLabel: {
|
|
599
|
+
shrink: true,
|
|
600
|
+
},
|
|
601
|
+
}, margin: "normal" })));
|
|
602
|
+
}
|
|
603
|
+
getControlsDate() {
|
|
604
|
+
const settings = this.state.once;
|
|
605
|
+
if (!settings.date) {
|
|
606
|
+
const d = new Date();
|
|
607
|
+
settings.date = `${d.getDate()}.${padding(d.getMonth() + 1)}`;
|
|
608
|
+
}
|
|
609
|
+
// <InputLabel htmlFor="formatted-text-mask-input">{I18n.t('sc_at')}</InputLabel>
|
|
610
|
+
return (React.createElement(FormControl, { variant: "standard", style: styles.formControl },
|
|
611
|
+
React.createElement(TextField, { variant: "standard", key: "date", label: I18n.t('sc_date'), value: settings.date, type: "text", slotProps: {
|
|
612
|
+
htmlInput: {
|
|
613
|
+
style: styles.formControlPaddingTop,
|
|
614
|
+
},
|
|
615
|
+
inputLabel: {
|
|
616
|
+
shrink: true,
|
|
617
|
+
},
|
|
618
|
+
}, onChange: e => {
|
|
619
|
+
const _settings = JSON.parse(JSON.stringify(this.state.once));
|
|
620
|
+
_settings.date = e.target.value;
|
|
621
|
+
this.setState({ once: _settings }, () => this.recalcCron());
|
|
622
|
+
}, margin: "normal" })));
|
|
623
|
+
}
|
|
624
|
+
getOnceElements() {
|
|
625
|
+
return (React.createElement("div", { style: { marginLeft: 8 } },
|
|
626
|
+
this.getControlsTime('once'),
|
|
627
|
+
this.getControlsDate()));
|
|
628
|
+
}
|
|
629
|
+
getIntervalElements() {
|
|
630
|
+
return this.getControlsPeriodElements('interval');
|
|
631
|
+
}
|
|
632
|
+
getIntervalBetweenElements() {
|
|
633
|
+
const settings = this.state.intervalBetween;
|
|
634
|
+
return [
|
|
635
|
+
this.getControlsPeriodElements('intervalBetween'),
|
|
636
|
+
React.createElement("div", { key: "between", style: { paddingLeft: 8, display: 'inline-block', verticalAlign: 'top' } },
|
|
637
|
+
React.createElement("h5", { style: { marginBottom: 5 } }, I18n.t('sc_hours')),
|
|
638
|
+
React.createElement(FormControl, { variant: "standard", style: styles.formControl },
|
|
639
|
+
React.createElement(InputLabel, { shrink: true, htmlFor: "age-label-placeholder" }, I18n.t('sc_from')),
|
|
640
|
+
React.createElement(Select, { variant: "standard", style: { width: 100 }, value: settings.timeFrom, onChange: e => {
|
|
641
|
+
const _settings = JSON.parse(JSON.stringify(this.state.intervalBetween));
|
|
642
|
+
_settings.timeFrom = parseInt(e.target.value, 10);
|
|
643
|
+
if (_settings.timeTo === 24) {
|
|
644
|
+
_settings.timeTo = 23;
|
|
645
|
+
}
|
|
646
|
+
this.setState({ intervalBetween: _settings }, () => this.recalcCron());
|
|
647
|
+
} }, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23].map(hour => (React.createElement(MenuItem, { key: `B_${hour}`, value: hour }, `${padding(hour)}:00`))))),
|
|
648
|
+
React.createElement(FormControl, { variant: "standard", style: styles.formControl },
|
|
649
|
+
React.createElement(InputLabel, { shrink: true, htmlFor: "age-label-placeholder" }, I18n.t('sc_to')),
|
|
650
|
+
React.createElement(Select, { variant: "standard", style: { width: 100 }, value: settings.timeTo, onChange: e => {
|
|
651
|
+
const _settings = JSON.parse(JSON.stringify(this.state.intervalBetween));
|
|
652
|
+
_settings.timeTo = parseInt(e.target.value, 10);
|
|
653
|
+
this.setState({ intervalBetween: _settings }, () => this.recalcCron());
|
|
654
|
+
} },
|
|
655
|
+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23].map(hour => (React.createElement(MenuItem, { key: `A_${hour}`, value: hour }, `${padding(hour)}:00`))),
|
|
656
|
+
!settings.timeFrom && React.createElement(MenuItem, { value: 24 }, "00:00")))),
|
|
657
|
+
this.getControlsWeekdaysElements('intervalBetween'),
|
|
658
|
+
];
|
|
659
|
+
}
|
|
660
|
+
getSpecificTimeElements() {
|
|
661
|
+
return [
|
|
662
|
+
React.createElement("div", { key: "time", style: { marginLeft: 8 } }, this.getControlsTime('specific')),
|
|
663
|
+
this.getControlsWeekdaysElements('specific'),
|
|
664
|
+
];
|
|
665
|
+
}
|
|
666
|
+
onModeChange(mode) {
|
|
667
|
+
if (mode !== this.state.mode) {
|
|
668
|
+
this.setState({ mode }, () => this.recalcCron());
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
onChange(cron) {
|
|
672
|
+
if (cron !== this.state.cron) {
|
|
673
|
+
this.setState({ cron });
|
|
674
|
+
this.props.onChange && this.props.onChange(cron);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
render() {
|
|
678
|
+
return (React.createElement("div", { style: styles.mainDiv },
|
|
679
|
+
React.createElement("div", { style: { paddingLeft: 8, width: 'calc(100% - 8px)' } },
|
|
680
|
+
React.createElement(TextField, { variant: "standard", style: { width: '100%' }, value: this.state.cron, disabled: true, error: this.state.cron.includes('_') })),
|
|
681
|
+
React.createElement("div", { style: { paddingLeft: 8, width: 'calc(100% - 8px)', height: 60 } }, this.state.cron.includes('_')
|
|
682
|
+
? I18n.t('sc_invalid_cron')
|
|
683
|
+
: convertCronToText(this.state.cron, this.props.language || 'en')),
|
|
684
|
+
React.createElement("div", null,
|
|
685
|
+
React.createElement(FormControl, { variant: "standard", style: { ...styles.formControl, marginLeft: 8, marginTop: 8 } },
|
|
686
|
+
React.createElement(InputLabel, null, I18n.t('ra_Repeat')),
|
|
687
|
+
React.createElement(Select, { variant: "standard", value: this.state.mode, onChange: e => this.onModeChange(e.target.value), inputProps: { name: 'mode', id: 'mode' } },
|
|
688
|
+
React.createElement(MenuItem, { value: "once" }, I18n.t('sc_once')),
|
|
689
|
+
React.createElement(MenuItem, { value: "interval" }, I18n.t('sc_interval')),
|
|
690
|
+
React.createElement(MenuItem, { value: "intervalBetween" }, I18n.t('sc_intervalBetween')),
|
|
691
|
+
React.createElement(MenuItem, { value: "specific" }, I18n.t('sc_specific'))))),
|
|
692
|
+
this.state.mode === PERIODIC.once && this.getOnceElements(),
|
|
693
|
+
this.state.mode === 'interval' && this.getIntervalElements(),
|
|
694
|
+
this.state.mode === 'intervalBetween' && this.getIntervalBetweenElements(),
|
|
695
|
+
this.state.mode === 'specific' && this.getSpecificTimeElements()));
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
//# sourceMappingURL=index.js.map
|