@iobroker/adapter-react-v5 7.0.2 → 7.1.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.
- package/Components/404.d.ts +3 -2
- package/Components/404.js +3 -2
- package/Components/ColorPicker.d.ts +22 -8
- package/Components/ColorPicker.js +34 -17
- package/Components/ComplexCron.js +24 -24
- package/Components/CopyToClipboard.d.ts +10 -1
- package/Components/CopyToClipboard.js +17 -8
- package/Components/CustomModal.d.ts +1 -1
- package/Components/CustomModal.js +8 -8
- package/Components/FileBrowser.d.ts +11 -11
- package/Components/FileBrowser.js +135 -152
- package/Components/FileViewer.js +34 -23
- package/Components/Icon.d.ts +16 -2
- package/Components/Icon.js +19 -8
- package/Components/IconPicker.js +10 -14
- package/Components/IconSelector.d.ts +1 -1
- package/Components/IconSelector.js +64 -74
- package/Components/Image.d.ts +8 -4
- package/Components/Image.js +13 -32
- package/Components/Loader.d.ts +2 -2
- package/Components/Loader.js +21 -18
- package/Components/Loaders/MV.d.ts +6 -1
- package/Components/Loaders/MV.js +23 -7
- package/Components/Loaders/PT.d.ts +7 -2
- package/Components/Loaders/PT.js +20 -7
- package/Components/Loaders/Vendor.d.ts +2 -2
- package/Components/Loaders/Vendor.js +15 -7
- package/Components/Logo.js +16 -18
- package/Components/MDUtils.d.ts +1 -1
- package/Components/MDUtils.js +8 -4
- package/Components/ObjectBrowser.d.ts +40 -39
- package/Components/ObjectBrowser.js +550 -435
- package/Components/Router.d.ts +1 -3
- package/Components/Router.js +3 -1
- package/Components/SaveCloseButtons.d.ts +3 -3
- package/Components/SaveCloseButtons.js +3 -3
- package/Components/Schedule.d.ts +15 -15
- package/Components/Schedule.js +177 -154
- package/Components/SelectWithIcon.d.ts +2 -2
- package/Components/SelectWithIcon.js +45 -34
- package/Components/SimpleCron/index.js +83 -43
- package/Components/TabContainer.js +2 -2
- package/Components/TabContent.js +1 -1
- package/Components/TabHeader.js +1 -1
- package/Components/TableResize.d.ts +2 -2
- package/Components/TableResize.js +5 -5
- package/Components/TextWithIcon.d.ts +1 -1
- package/Components/TextWithIcon.js +10 -8
- package/Components/ToggleThemeMenu.d.ts +2 -2
- package/Components/ToggleThemeMenu.js +3 -3
- package/Components/TreeTable.d.ts +18 -18
- package/Components/TreeTable.js +76 -72
- package/Components/UploadImage.d.ts +2 -2
- package/Components/UploadImage.js +25 -21
- package/Components/Utils.d.ts +42 -22
- package/Components/Utils.js +66 -65
- package/Components/withWidth.d.ts +2 -2
- package/Components/withWidth.js +10 -6
- package/Dialogs/ComplexCron.d.ts +2 -2
- package/Dialogs/ComplexCron.js +3 -3
- package/Dialogs/Confirm.d.ts +4 -4
- package/Dialogs/Confirm.js +18 -8
- package/Dialogs/Cron.d.ts +3 -3
- package/Dialogs/Cron.js +21 -17
- package/Dialogs/Error.d.ts +3 -3
- package/Dialogs/Error.js +6 -4
- package/Dialogs/Message.d.ts +3 -3
- package/Dialogs/Message.js +6 -4
- package/Dialogs/SelectFile.d.ts +4 -4
- package/Dialogs/SelectFile.js +6 -4
- package/Dialogs/SelectID.d.ts +12 -10
- package/Dialogs/SelectID.js +12 -8
- package/Dialogs/SimpleCron.d.ts +2 -2
- package/Dialogs/SimpleCron.js +2 -2
- package/Dialogs/TextInput.d.ts +2 -2
- package/Dialogs/TextInput.js +3 -3
- package/GenericApp.d.ts +19 -13
- package/GenericApp.js +128 -85
- package/LegacyConnection.d.ts +240 -248
- package/LegacyConnection.js +500 -525
- package/README.md +1234 -1170
- package/Theme.d.ts +1 -1
- package/Theme.js +9 -12
- package/assets/devices.json +1 -0
- package/assets/rooms.json +1 -0
- package/craco-module-federation.js +3 -12
- package/i18n/de.json +434 -434
- package/i18n/en.json +434 -434
- package/i18n/es.json +434 -434
- package/i18n/fr.json +434 -434
- package/i18n/it.json +434 -434
- package/i18n/nl.json +434 -434
- package/i18n/pl.json +434 -434
- package/i18n/pt.json +434 -434
- package/i18n/ru.json +434 -434
- package/i18n/uk.json +434 -434
- package/i18n/zh-cn.json +434 -434
- package/i18n.d.ts +26 -19
- package/i18n.js +28 -22
- package/icons/IconAdapter.js +2 -2
- package/icons/IconAlias.js +2 -2
- package/icons/IconChannel.js +2 -2
- package/icons/IconClearFilter.js +2 -2
- package/icons/IconClosed.js +2 -2
- package/icons/IconCopy.js +2 -2
- package/icons/IconDevice.js +2 -2
- package/icons/IconDocument.js +2 -2
- package/icons/IconDocumentReadOnly.js +2 -2
- package/icons/IconExpert.js +2 -2
- package/icons/IconFx.js +2 -2
- package/icons/IconInstance.js +2 -2
- package/icons/IconLogout.js +2 -2
- package/icons/IconNoIcon.js +2 -2
- package/icons/IconOpen.d.ts +2 -2
- package/icons/IconOpen.js +2 -2
- package/icons/IconProps.d.ts +4 -3
- package/icons/IconState.d.ts +2 -2
- package/icons/IconState.js +2 -2
- package/index.css +3 -2
- package/package.json +1 -1
- package/src/Components/404.tsx +32 -31
- package/src/Components/ColorPicker.tsx +142 -114
- package/src/Components/ComplexCron.tsx +174 -137
- package/src/Components/CopyToClipboard.tsx +22 -9
- package/src/Components/CustomModal.tsx +76 -69
- package/src/Components/FileBrowser.tsx +959 -852
- package/src/Components/FileViewer.tsx +146 -127
- package/src/Components/Icon.tsx +80 -52
- package/src/Components/IconPicker.tsx +83 -67
- package/src/Components/IconSelector.tsx +159 -141
- package/src/Components/Image.tsx +43 -26
- package/src/Components/Loader.tsx +56 -32
- package/src/Components/Logo.tsx +62 -52
- package/src/Components/MDUtils.tsx +10 -6
- package/src/Components/ObjectBrowser.tsx +3198 -2478
- package/src/Components/Router.tsx +11 -11
- package/src/Components/SaveCloseButtons.tsx +43 -39
- package/src/Components/Schedule.tsx +1091 -853
- package/src/Components/SelectWithIcon.tsx +135 -93
- package/src/Components/TabContainer.tsx +21 -19
- package/src/Components/TabContent.tsx +13 -12
- package/src/Components/TabHeader.tsx +10 -9
- package/src/Components/TableResize.tsx +52 -37
- package/src/Components/TextWithIcon.tsx +30 -19
- package/src/Components/ToggleThemeMenu.tsx +31 -13
- package/src/Components/TreeTable.tsx +468 -385
- package/src/Components/UploadImage.tsx +153 -121
- package/src/Components/Utils.tsx +135 -127
- package/src/Components/loader.css +40 -31
- package/src/Components/withWidth.tsx +23 -12
- package/src/Connection.tsx +1 -3
- package/src/Dialogs/ComplexCron.tsx +55 -61
- package/src/Dialogs/Confirm.tsx +88 -65
- package/src/Dialogs/Cron.tsx +122 -112
- package/src/Dialogs/Error.tsx +37 -42
- package/src/Dialogs/Message.tsx +39 -37
- package/src/Dialogs/SelectFile.tsx +95 -85
- package/src/Dialogs/SelectID.tsx +141 -129
- package/src/Dialogs/SimpleCron.tsx +44 -44
- package/src/Dialogs/TextInput.tsx +60 -68
- package/src/GenericApp.tsx +342 -242
- package/src/LegacyConnection.tsx +972 -842
- package/src/Prompt.tsx +3 -1
- package/src/Theme.tsx +19 -26
- package/src/icons/IconAdapter.tsx +16 -14
- package/src/icons/IconAlias.tsx +16 -14
- package/src/icons/IconChannel.tsx +55 -16
- package/src/icons/IconClearFilter.tsx +17 -15
- package/src/icons/IconClosed.tsx +16 -11
- package/src/icons/IconCopy.tsx +16 -11
- package/src/icons/IconDevice.tsx +121 -22
- package/src/icons/IconDocument.tsx +16 -11
- package/src/icons/IconDocumentReadOnly.tsx +21 -12
- package/src/icons/IconExpert.tsx +20 -12
- package/src/icons/IconFx.tsx +16 -14
- package/src/icons/IconInstance.tsx +16 -14
- package/src/icons/IconLogout.tsx +20 -18
- package/src/icons/IconNoIcon.tsx +16 -14
- package/src/icons/IconOpen.tsx +17 -12
- package/src/icons/IconProps.tsx +4 -3
- package/src/icons/IconState.tsx +34 -13
- package/src/index.css +3 -2
- package/tasks.js +91 -0
- package/types.d.ts +141 -0
- package/Components/Loaders/PT.css +0 -109
- package/Components/Loaders/Vendor.css +0 -13
- package/Components/loader.css +0 -222
- package/Components/types.d.ts +0 -82
- package/assets/devices/Alarm Systems.svg +0 -19
- package/assets/devices/Amplifier.svg +0 -22
- package/assets/devices/Awnings.svg +0 -5
- package/assets/devices/Battery Status.svg +0 -5
- package/assets/devices/Ceiling Spotlights.svg +0 -16
- package/assets/devices/Chandelier.svg +0 -7
- package/assets/devices/Climate.svg +0 -12
- package/assets/devices/Coffee Makers.svg +0 -6
- package/assets/devices/Cold Water.svg +0 -31
- package/assets/devices/Computer.svg +0 -21
- package/assets/devices/Consumption.svg +0 -8
- package/assets/devices/Curtains.svg +0 -43
- package/assets/devices/Dishwashers.svg +0 -12
- package/assets/devices/Doors.svg +0 -6
- package/assets/devices/Doorstep.svg +0 -35
- package/assets/devices/Dryer.svg +0 -14
- package/assets/devices/Fan.svg +0 -20
- package/assets/devices/Floor Lamps.svg +0 -5
- package/assets/devices/Garage Doors.svg +0 -9
- package/assets/devices/Gates.svg +0 -32
- package/assets/devices/Hairdryer.svg +0 -23
- package/assets/devices/Handle.svg +0 -6
- package/assets/devices/Hanging Lamps.svg +0 -9
- package/assets/devices/Heater.svg +0 -44
- package/assets/devices/Hoods.svg +0 -12
- package/assets/devices/Hot Water.svg +0 -10
- package/assets/devices/Humidity.svg +0 -41
- package/assets/devices/Iron.svg +0 -5
- package/assets/devices/Irrigation.svg +0 -23
- package/assets/devices/Led Strip.svg +0 -31
- package/assets/devices/Light.svg +0 -30
- package/assets/devices/Lightings.svg +0 -46
- package/assets/devices/Lock.svg +0 -19
- package/assets/devices/Louvre.svg +0 -7
- package/assets/devices/Mowing Machine.svg +0 -9
- package/assets/devices/Music.svg +0 -13
- package/assets/devices/Outdoor Blinds.svg +0 -7
- package/assets/devices/People.svg +0 -19
- package/assets/devices/Pool.svg +0 -8
- package/assets/devices/Power Consumption.svg +0 -13
- package/assets/devices/Printer.svg +0 -10
- package/assets/devices/Pump.svg +0 -10
- package/assets/devices/Receiver.svg +0 -19
- package/assets/devices/Sconces.svg +0 -10
- package/assets/devices/Security.svg +0 -34
- package/assets/devices/Shading.svg +0 -5
- package/assets/devices/Shutters.svg +0 -11
- package/assets/devices/SmokeDetector.svg +0 -13
- package/assets/devices/Sockets.svg +0 -13
- package/assets/devices/Speaker.svg +0 -35
- package/assets/devices/Stove.svg +0 -12
- package/assets/devices/Table Lamps.svg +0 -12
- package/assets/devices/Temperature Sensors.svg +0 -28
- package/assets/devices/Tv.svg +0 -8
- package/assets/devices/Vacuum Cleaner.svg +0 -16
- package/assets/devices/Ventilation.svg +0 -12
- package/assets/devices/Washing Machines.svg +0 -16
- package/assets/devices/Water Consumption.svg +0 -6
- package/assets/devices/Water Heater.svg +0 -8
- package/assets/devices/Water.svg +0 -40
- package/assets/devices/Weather.svg +0 -28
- package/assets/devices/Window.svg +0 -8
- package/assets/rooms/Anteroom.svg +0 -53
- package/assets/rooms/Attic.svg +0 -21
- package/assets/rooms/Balcony.svg +0 -13
- package/assets/rooms/Barn.svg +0 -6
- package/assets/rooms/Basement.svg +0 -5
- package/assets/rooms/Bathroom.svg +0 -38
- package/assets/rooms/Bedroom.svg +0 -5
- package/assets/rooms/Boiler Room.svg +0 -13
- package/assets/rooms/Carport.svg +0 -17
- package/assets/rooms/Cellar.svg +0 -89
- package/assets/rooms/Chamber.svg +0 -9
- package/assets/rooms/Corridor.svg +0 -53
- package/assets/rooms/Dining Area.svg +0 -37
- package/assets/rooms/Dining Room.svg +0 -37
- package/assets/rooms/Dining.svg +0 -37
- package/assets/rooms/Dressing Room.svg +0 -5
- package/assets/rooms/Driveway.svg +0 -15
- package/assets/rooms/Entrance.svg +0 -44
- package/assets/rooms/Equipment Room.svg +0 -15
- package/assets/rooms/Front Yard.svg +0 -64
- package/assets/rooms/Gallery.svg +0 -14
- package/assets/rooms/Garage.svg +0 -20
- package/assets/rooms/Garden.svg +0 -13
- package/assets/rooms/Ground Floor.svg +0 -95
- package/assets/rooms/Guest Bathroom.svg +0 -33
- package/assets/rooms/Guest Room.svg +0 -5
- package/assets/rooms/Gym.svg +0 -5
- package/assets/rooms/Hall.svg +0 -19
- package/assets/rooms/Home Theater.svg +0 -8
- package/assets/rooms/Kitchen.svg +0 -18
- package/assets/rooms/Laundry Room.svg +0 -12
- package/assets/rooms/Living Area.svg +0 -11
- package/assets/rooms/Living Room.svg +0 -10
- package/assets/rooms/Locker Room.svg +0 -17
- package/assets/rooms/Nursery.svg +0 -5
- package/assets/rooms/Office.svg +0 -8
- package/assets/rooms/Outdoors.svg +0 -7
- package/assets/rooms/Playroom.svg +0 -6
- package/assets/rooms/Pool.svg +0 -8
- package/assets/rooms/Rear Wall.svg +0 -30
- package/assets/rooms/Second Floor.svg +0 -95
- package/assets/rooms/Shed.svg +0 -16
- package/assets/rooms/Sleeping Area.svg +0 -22
- package/assets/rooms/Stairway.svg +0 -5
- package/assets/rooms/Stairwell.svg +0 -15
- package/assets/rooms/Storeroom.svg +0 -5
- package/assets/rooms/Summer House.svg +0 -27
- package/assets/rooms/Swimming Pool.svg +0 -21
- package/assets/rooms/Terrace.svg +0 -7
- package/assets/rooms/Toilet.svg +0 -10
- package/assets/rooms/Upstairs.svg +0 -6
- package/assets/rooms/Wardrobe.svg +0 -60
- package/assets/rooms/Washroom.svg +0 -20
- package/assets/rooms/Wc.svg +0 -10
- package/assets/rooms/Windscreen.svg +0 -60
- package/assets/rooms/Workshop.svg +0 -23
- package/assets/rooms/Workspace.svg +0 -8
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
Checkbox,
|
|
5
|
-
Button,
|
|
6
|
-
MenuItem,
|
|
7
|
-
Select,
|
|
8
|
-
FormControlLabel,
|
|
9
|
-
AppBar,
|
|
10
|
-
Tabs,
|
|
11
|
-
Tab,
|
|
12
|
-
TextField, Box,
|
|
13
|
-
} from '@mui/material';
|
|
3
|
+
import { Checkbox, Button, MenuItem, Select, FormControlLabel, AppBar, Tabs, Tab, TextField } from '@mui/material';
|
|
14
4
|
|
|
15
5
|
import I18n from '../i18n';
|
|
16
6
|
import convertCronToText from './SimpleCron/cronText';
|
|
@@ -48,16 +38,7 @@ const styles: Record<string, React.CSSProperties> = {
|
|
|
48
38
|
},
|
|
49
39
|
};
|
|
50
40
|
|
|
51
|
-
const WEEKDAYS = [
|
|
52
|
-
'Sunday',
|
|
53
|
-
'Monday',
|
|
54
|
-
'Tuesday',
|
|
55
|
-
'Wednesday',
|
|
56
|
-
'Thursday',
|
|
57
|
-
'Friday',
|
|
58
|
-
'Saturday',
|
|
59
|
-
'Sunday',
|
|
60
|
-
];
|
|
41
|
+
const WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
|
|
61
42
|
const MONTHS = [
|
|
62
43
|
'January',
|
|
63
44
|
'February',
|
|
@@ -120,7 +101,7 @@ function convertMinusIntoArray(value: string | false | undefined, max: number):
|
|
|
120
101
|
}
|
|
121
102
|
|
|
122
103
|
// [5,6,7,9,10,11] => 5-7,9-11
|
|
123
|
-
function convertArrayIntoMinus(value: number | number
|
|
104
|
+
function convertArrayIntoMinus(value: number | number[], max: number): string {
|
|
124
105
|
if (typeof value !== 'object') {
|
|
125
106
|
value = [value];
|
|
126
107
|
}
|
|
@@ -197,8 +178,10 @@ interface ComplexCronState {
|
|
|
197
178
|
class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
|
|
198
179
|
constructor(props: ComplexCronProps) {
|
|
199
180
|
super(props);
|
|
200
|
-
let cron =
|
|
201
|
-
this.props.cronExpression
|
|
181
|
+
let cron =
|
|
182
|
+
typeof this.props.cronExpression === 'string'
|
|
183
|
+
? this.props.cronExpression.replace(/^["']/, '').replace(/["']\n?$/, '')
|
|
184
|
+
: '';
|
|
202
185
|
if (cron[0] === '{') {
|
|
203
186
|
cron = '';
|
|
204
187
|
}
|
|
@@ -258,15 +241,14 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
|
|
|
258
241
|
return text;
|
|
259
242
|
}
|
|
260
243
|
|
|
261
|
-
recalcCron() {
|
|
244
|
+
recalcCron(): void {
|
|
262
245
|
const cron = ComplexCron.state2cron(this.state);
|
|
263
246
|
if (cron !== this.state.cron) {
|
|
264
|
-
this.setState({ cron }, () =>
|
|
265
|
-
this.props.onChange && this.props.onChange(this.state.cron));
|
|
247
|
+
this.setState({ cron }, () => this.props.onChange && this.props.onChange(this.state.cron));
|
|
266
248
|
}
|
|
267
249
|
}
|
|
268
250
|
|
|
269
|
-
onToggle(i: boolean | number, type: CronNames, max: number) {
|
|
251
|
+
onToggle(i: boolean | number, type: CronNames, max: number): void {
|
|
270
252
|
if (i === true) {
|
|
271
253
|
this.setCronAttr(type, '*');
|
|
272
254
|
} else if (i === false) {
|
|
@@ -288,7 +270,7 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
|
|
|
288
270
|
}
|
|
289
271
|
}
|
|
290
272
|
|
|
291
|
-
getDigitsSelector(type: CronNames, max: number) {
|
|
273
|
+
getDigitsSelector(type: CronNames, max: number): React.JSX.Element[] {
|
|
292
274
|
let values = [];
|
|
293
275
|
if (max === 7) {
|
|
294
276
|
values = [1, 2, 3, 4, 5, 6, 0];
|
|
@@ -326,13 +308,17 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
|
|
|
326
308
|
{I18n.t('ra_Select all')}
|
|
327
309
|
</Button>,
|
|
328
310
|
<div key="all">
|
|
329
|
-
{values.map(i =>
|
|
330
|
-
|
|
311
|
+
{values.map(i => [
|
|
312
|
+
(max === 7 && i === 4) ||
|
|
331
313
|
(max === 12 && i === 7) ||
|
|
332
314
|
(max === 31 && !((i - 1) % 10)) ||
|
|
333
315
|
(max === 60 && i && !(i % 10)) ||
|
|
334
|
-
(max === 24 && i && !(i % 6))
|
|
335
|
-
<div
|
|
316
|
+
(max === 24 && i && !(i % 6)) ? (
|
|
317
|
+
<div
|
|
318
|
+
key={`allInner${i}`}
|
|
319
|
+
style={{ width: '100%' }}
|
|
320
|
+
/>
|
|
321
|
+
) : null,
|
|
336
322
|
<Button
|
|
337
323
|
key={`_${i}`}
|
|
338
324
|
variant={parts.indexOf(i) !== -1 ? 'contained' : 'outlined'}
|
|
@@ -340,9 +326,9 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
|
|
|
340
326
|
color={parts.indexOf(i) !== -1 ? 'secondary' : 'primary'}
|
|
341
327
|
onClick={() => this.onToggle(i, type, max)}
|
|
342
328
|
>
|
|
343
|
-
{max === 7 ? I18n.t(WEEKDAYS[i]) :
|
|
329
|
+
{max === 7 ? I18n.t(WEEKDAYS[i]) : max === 12 ? MONTHS[i - 1] : i}
|
|
344
330
|
</Button>,
|
|
345
|
-
|
|
331
|
+
])}
|
|
346
332
|
</div>,
|
|
347
333
|
];
|
|
348
334
|
}
|
|
@@ -353,7 +339,7 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
|
|
|
353
339
|
let everyN = value === undefined || value === null ? false : value.toString().includes('/');
|
|
354
340
|
let select;
|
|
355
341
|
if (this.state.modes[type] === null) {
|
|
356
|
-
select = every ? 'every' :
|
|
342
|
+
select = every ? 'every' : everyN ? 'everyN' : 'specific';
|
|
357
343
|
const modes = JSON.parse(JSON.stringify(this.state.modes));
|
|
358
344
|
modes[type] = select;
|
|
359
345
|
setTimeout(() => this.setState({ modes }, () => this.recalcCron()), 100);
|
|
@@ -369,49 +355,75 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
|
|
|
369
355
|
valueNumber = parseInt(value.replace('*/', ''), 10) || 1;
|
|
370
356
|
}
|
|
371
357
|
|
|
372
|
-
return
|
|
373
|
-
<
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
num
|
|
358
|
+
return (
|
|
359
|
+
<div>
|
|
360
|
+
<Select
|
|
361
|
+
variant="standard"
|
|
362
|
+
style={{ ...styles.periodSelect, verticalAlign: 'bottom' }}
|
|
363
|
+
value={select}
|
|
364
|
+
onChange={e => {
|
|
365
|
+
const modes = JSON.parse(JSON.stringify(this.state.modes));
|
|
366
|
+
modes[type] = e.target.value;
|
|
367
|
+
if (e.target.value === 'every') {
|
|
368
|
+
this.setCronAttr(type, '*', modes);
|
|
369
|
+
} else if (e.target.value === 'everyN') {
|
|
370
|
+
const num = parseInt((this.state[type] || '').toString().replace('*/', ''), 10) || 1;
|
|
371
|
+
this.setCronAttr(type, `*/${num}`, modes);
|
|
372
|
+
} else if (e.target.value === 'specific') {
|
|
373
|
+
let num = parseInt((this.state[type] || '').toString().split(',')[0], 10) || 0;
|
|
374
|
+
if (!num && (type === 'months' || type === 'dates')) {
|
|
375
|
+
num = 1;
|
|
376
|
+
}
|
|
377
|
+
this.setCronAttr(type, convertArrayIntoMinus(num, max), modes);
|
|
389
378
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
379
|
+
}}
|
|
380
|
+
>
|
|
381
|
+
<MenuItem
|
|
382
|
+
key="every"
|
|
383
|
+
value="every"
|
|
384
|
+
>
|
|
385
|
+
{I18n.t(`sc_every_${type}`)}
|
|
386
|
+
</MenuItem>
|
|
387
|
+
<MenuItem
|
|
388
|
+
key="everyN"
|
|
389
|
+
value="everyN"
|
|
390
|
+
>
|
|
391
|
+
{I18n.t(`sc_everyN_${type}`)}
|
|
392
|
+
</MenuItem>
|
|
393
|
+
<MenuItem
|
|
394
|
+
key="specific"
|
|
395
|
+
value="specific"
|
|
396
|
+
>
|
|
397
|
+
{I18n.t(`sc_specific_${type}`)}
|
|
398
|
+
</MenuItem>
|
|
399
|
+
</Select>
|
|
400
|
+
{/* everyN && false && <span>{value}</span> */}
|
|
401
|
+
{everyN && (
|
|
402
|
+
<TextField
|
|
403
|
+
variant="standard"
|
|
404
|
+
key="interval"
|
|
405
|
+
label={I18n.t(`sc_${type}`)}
|
|
406
|
+
value={valueNumber}
|
|
407
|
+
slotProps={{
|
|
408
|
+
htmlInput: {
|
|
409
|
+
min: 1,
|
|
410
|
+
max,
|
|
411
|
+
},
|
|
412
|
+
inputLabel: {
|
|
413
|
+
shrink: true,
|
|
414
|
+
},
|
|
415
|
+
}}
|
|
416
|
+
onChange={e => {
|
|
417
|
+
// @ts-expect-error is allowed
|
|
418
|
+
this.setState({ [type]: `*/${e.target.value}` }, () => this.recalcCron());
|
|
419
|
+
}}
|
|
420
|
+
type="number"
|
|
421
|
+
margin="normal"
|
|
422
|
+
/>
|
|
423
|
+
)}
|
|
424
|
+
{!every && !everyN && this.getDigitsSelector(type, max)}
|
|
425
|
+
</div>
|
|
426
|
+
);
|
|
415
427
|
}
|
|
416
428
|
|
|
417
429
|
static convertCronToText(cron: string, lang: ioBroker.Languages): string {
|
|
@@ -421,86 +433,111 @@ class ComplexCron extends Component<ComplexCronProps, ComplexCronState> {
|
|
|
421
433
|
return convertCronToText(cron, lang);
|
|
422
434
|
}
|
|
423
435
|
|
|
424
|
-
setCronAttr(attr: CronNames, value: string, modes?: CronProps) {
|
|
436
|
+
setCronAttr(attr: CronNames, value: string, modes?: CronProps): void {
|
|
425
437
|
if (modes) {
|
|
426
438
|
if (attr === 'seconds') {
|
|
427
|
-
this.setState({ seconds: value, modes }, () =>
|
|
428
|
-
this.recalcCron());
|
|
439
|
+
this.setState({ seconds: value, modes }, () => this.recalcCron());
|
|
429
440
|
} else if (attr === 'minutes') {
|
|
430
|
-
this.setState({ minutes: value, modes }, () =>
|
|
431
|
-
this.recalcCron());
|
|
441
|
+
this.setState({ minutes: value, modes }, () => this.recalcCron());
|
|
432
442
|
} else if (attr === 'hours') {
|
|
433
|
-
this.setState({ hours: value, modes }, () =>
|
|
434
|
-
this.recalcCron());
|
|
443
|
+
this.setState({ hours: value, modes }, () => this.recalcCron());
|
|
435
444
|
} else if (attr === 'dates') {
|
|
436
|
-
this.setState({ dates: value, modes }, () =>
|
|
437
|
-
this.recalcCron());
|
|
445
|
+
this.setState({ dates: value, modes }, () => this.recalcCron());
|
|
438
446
|
} else if (attr === 'months') {
|
|
439
|
-
this.setState({ months: value, modes }, () =>
|
|
440
|
-
this.recalcCron());
|
|
447
|
+
this.setState({ months: value, modes }, () => this.recalcCron());
|
|
441
448
|
} else if (attr === 'dow') {
|
|
442
|
-
this.setState({ dow: value, modes }, () =>
|
|
443
|
-
this.recalcCron());
|
|
449
|
+
this.setState({ dow: value, modes }, () => this.recalcCron());
|
|
444
450
|
} else {
|
|
445
|
-
this.setState({ modes }, () =>
|
|
446
|
-
this.recalcCron());
|
|
451
|
+
this.setState({ modes }, () => this.recalcCron());
|
|
447
452
|
}
|
|
448
453
|
} else if (attr === 'seconds') {
|
|
449
|
-
this.setState({ seconds: value }, () =>
|
|
450
|
-
this.recalcCron());
|
|
454
|
+
this.setState({ seconds: value }, () => this.recalcCron());
|
|
451
455
|
} else if (attr === 'minutes') {
|
|
452
|
-
this.setState({ minutes: value }, () =>
|
|
453
|
-
this.recalcCron());
|
|
456
|
+
this.setState({ minutes: value }, () => this.recalcCron());
|
|
454
457
|
} else if (attr === 'hours') {
|
|
455
|
-
this.setState({ hours: value }, () =>
|
|
456
|
-
this.recalcCron());
|
|
458
|
+
this.setState({ hours: value }, () => this.recalcCron());
|
|
457
459
|
} else if (attr === 'dates') {
|
|
458
|
-
this.setState({ dates: value }, () =>
|
|
459
|
-
this.recalcCron());
|
|
460
|
+
this.setState({ dates: value }, () => this.recalcCron());
|
|
460
461
|
} else if (attr === 'months') {
|
|
461
|
-
this.setState({ months: value }, () =>
|
|
462
|
-
this.recalcCron());
|
|
462
|
+
this.setState({ months: value }, () => this.recalcCron());
|
|
463
463
|
} else if (attr === 'dow') {
|
|
464
|
-
this.setState({ dow: value }, () =>
|
|
465
|
-
this.recalcCron());
|
|
464
|
+
this.setState({ dow: value }, () => this.recalcCron());
|
|
466
465
|
}
|
|
467
466
|
}
|
|
468
467
|
|
|
469
|
-
render() {
|
|
468
|
+
render(): React.JSX.Element {
|
|
470
469
|
const tab = this.state.seconds !== false ? this.state.tab : this.state.tab + 1;
|
|
471
|
-
return
|
|
472
|
-
<div style={
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
470
|
+
return (
|
|
471
|
+
<div style={styles.mainDiv}>
|
|
472
|
+
<div style={{ paddingLeft: 8, width: '100%' }}>
|
|
473
|
+
<TextField
|
|
474
|
+
variant="standard"
|
|
475
|
+
style={{ width: '100%' }}
|
|
476
|
+
value={this.state.cron}
|
|
477
|
+
disabled
|
|
478
|
+
/>
|
|
479
|
+
</div>
|
|
480
|
+
<div style={{ paddingLeft: 8, width: '100%', height: 60 }}>
|
|
481
|
+
{ComplexCron.convertCronToText(this.state.cron, this.props.language || 'en')}
|
|
482
|
+
</div>
|
|
483
|
+
<FormControlLabel
|
|
484
|
+
control={
|
|
485
|
+
<Checkbox
|
|
486
|
+
checked={!!this.state.seconds}
|
|
487
|
+
onChange={e =>
|
|
488
|
+
this.setState({ seconds: e.target.checked ? '*' : false }, () => this.recalcCron())
|
|
489
|
+
}
|
|
490
|
+
/>
|
|
491
|
+
}
|
|
492
|
+
label={I18n.t('ra_use seconds')}
|
|
493
|
+
/>
|
|
494
|
+
<AppBar
|
|
495
|
+
position="static"
|
|
496
|
+
sx={{ '&.MuiAppBar-root': styles.appBar }}
|
|
485
497
|
color="secondary"
|
|
486
|
-
onChange={(active, _tab) =>
|
|
487
|
-
this.setState({ tab: _tab })}
|
|
488
498
|
>
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
499
|
+
<Tabs
|
|
500
|
+
value={this.state.tab}
|
|
501
|
+
style={styles.appBar}
|
|
502
|
+
color="secondary"
|
|
503
|
+
onChange={(active, _tab) => this.setState({ tab: _tab })}
|
|
504
|
+
>
|
|
505
|
+
{this.state.seconds !== false && (
|
|
506
|
+
<Tab
|
|
507
|
+
id="sc_seconds"
|
|
508
|
+
label={I18n.t('sc_seconds')}
|
|
509
|
+
/>
|
|
510
|
+
)}
|
|
511
|
+
<Tab
|
|
512
|
+
id="minutes"
|
|
513
|
+
label={I18n.t('sc_minutes')}
|
|
514
|
+
/>
|
|
515
|
+
<Tab
|
|
516
|
+
id="hours"
|
|
517
|
+
label={I18n.t('sc_hours')}
|
|
518
|
+
/>
|
|
519
|
+
<Tab
|
|
520
|
+
id="dates"
|
|
521
|
+
label={I18n.t('sc_dates')}
|
|
522
|
+
/>
|
|
523
|
+
<Tab
|
|
524
|
+
id="months"
|
|
525
|
+
label={I18n.t('sc_months')}
|
|
526
|
+
/>
|
|
527
|
+
<Tab
|
|
528
|
+
id="dow"
|
|
529
|
+
label={I18n.t('sc_dows')}
|
|
530
|
+
/>
|
|
531
|
+
</Tabs>
|
|
532
|
+
</AppBar>
|
|
533
|
+
{tab === 0 && <div style={styles.tabContent}>{this.getPeriodsTab('seconds', 60)}</div>}
|
|
534
|
+
{tab === 1 && <div style={styles.tabContent}>{this.getPeriodsTab('minutes', 60)}</div>}
|
|
535
|
+
{tab === 2 && <div style={styles.tabContent}>{this.getPeriodsTab('hours', 24)}</div>}
|
|
536
|
+
{tab === 3 && <div style={styles.tabContent}>{this.getPeriodsTab('dates', 31)}</div>}
|
|
537
|
+
{tab === 4 && <div style={styles.tabContent}>{this.getPeriodsTab('months', 12)}</div>}
|
|
538
|
+
{tab === 5 && <div style={styles.tabContent}>{this.getPeriodsTab('dow', 7)}</div>}
|
|
539
|
+
</div>
|
|
540
|
+
);
|
|
504
541
|
}
|
|
505
542
|
}
|
|
506
543
|
|
|
@@ -34,7 +34,9 @@ function deselectCurrent() {
|
|
|
34
34
|
ranges.push(selection.getRangeAt(i));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
switch (
|
|
37
|
+
switch (
|
|
38
|
+
active?.tagName.toUpperCase() // .toUpperCase handles XHTML
|
|
39
|
+
) {
|
|
38
40
|
case 'INPUT':
|
|
39
41
|
case 'TEXTAREA':
|
|
40
42
|
active.blur();
|
|
@@ -47,8 +49,7 @@ function deselectCurrent() {
|
|
|
47
49
|
|
|
48
50
|
selection.removeAllRanges();
|
|
49
51
|
return () => {
|
|
50
|
-
selection.type === 'Caret' &&
|
|
51
|
-
selection.removeAllRanges();
|
|
52
|
+
selection.type === 'Caret' && selection.removeAllRanges();
|
|
52
53
|
|
|
53
54
|
if (!selection.rangeCount) {
|
|
54
55
|
ranges.forEach(range => selection.addRange(range));
|
|
@@ -73,7 +74,19 @@ function format(message: string): string {
|
|
|
73
74
|
return message.replace(/#{\s*key\s*}/g, copyKey);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Copy text to clipboard
|
|
79
|
+
*
|
|
80
|
+
* @param text Text to copy
|
|
81
|
+
* @param options Options
|
|
82
|
+
* @param options.debug Debug mode
|
|
83
|
+
* @param options.format Format of the data
|
|
84
|
+
* @param options.message Message to show in prompt
|
|
85
|
+
*/
|
|
86
|
+
function copy(
|
|
87
|
+
text: string,
|
|
88
|
+
options?: { debug?: boolean; format?: 'text/plain' | 'text/html'; message?: string },
|
|
89
|
+
): boolean {
|
|
77
90
|
let reselectPrevious;
|
|
78
91
|
let range;
|
|
79
92
|
let selection;
|
|
@@ -100,21 +113,20 @@ function copy(text: string, options?: { debug?: boolean; format?: string; messag
|
|
|
100
113
|
// used to preserve spaces and line breaks
|
|
101
114
|
mark.style.whiteSpace = 'pre';
|
|
102
115
|
// do not inherit user-select (it may be `none`)
|
|
103
|
-
mark.style.webkitUserSelect = 'text';
|
|
104
|
-
mark.style.MozUserSelect = 'text';
|
|
105
|
-
mark.style.msUserSelect = 'text';
|
|
106
116
|
mark.style.userSelect = 'text';
|
|
107
117
|
mark.addEventListener('copy', e => {
|
|
108
118
|
e.stopPropagation();
|
|
109
119
|
if (options?.format) {
|
|
110
120
|
e.preventDefault();
|
|
111
|
-
if (typeof e.clipboardData === 'undefined') {
|
|
121
|
+
if (typeof e.clipboardData === 'undefined') {
|
|
122
|
+
// IE 11
|
|
112
123
|
debug && console.warn('unable to use e.clipboardData');
|
|
113
124
|
debug && console.warn('trying IE specific stuff');
|
|
114
125
|
(window as any).clipboardData?.clearData();
|
|
115
126
|
const _format = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting.default;
|
|
116
127
|
(window as any).clipboardData?.setData(_format, text);
|
|
117
|
-
} else {
|
|
128
|
+
} else {
|
|
129
|
+
// all other browsers
|
|
118
130
|
e.clipboardData?.clearData();
|
|
119
131
|
e.clipboardData?.setData(options.format, text);
|
|
120
132
|
}
|
|
@@ -126,6 +138,7 @@ function copy(text: string, options?: { debug?: boolean; format?: string; messag
|
|
|
126
138
|
range.selectNodeContents(mark);
|
|
127
139
|
selection?.addRange(range);
|
|
128
140
|
|
|
141
|
+
// there is no alternative for execCommand
|
|
129
142
|
const successful = document.execCommand('copy');
|
|
130
143
|
if (!successful) {
|
|
131
144
|
throw new Error('copy command was unsuccessful');
|