@iobroker/adapter-react-v5 7.1.1 → 7.1.4

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.
@@ -61,6 +61,11 @@ const styles = {
61
61
  appBar: {
62
62
  color: 'white',
63
63
  },
64
+ warning: {
65
+ marginLeft: 16,
66
+ color: 'red',
67
+ fontSize: 12,
68
+ },
64
69
  };
65
70
  const WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
66
71
  const MONTHS = [
@@ -391,13 +396,22 @@ class ComplexCron extends react_1.Component {
391
396
  }
392
397
  render() {
393
398
  const tab = this.state.seconds !== false ? this.state.tab : this.state.tab + 1;
399
+ // Detect if every minute or every second is activated
400
+ const everyMinute = this.state.minutes === '*' || this.state.minutes === '*/1';
401
+ const everySecond = this.state.seconds === '*' || this.state.seconds === '*/1';
394
402
  return (react_1.default.createElement("div", { style: styles.mainDiv },
395
403
  react_1.default.createElement("div", { style: { paddingLeft: 8, width: '100%' } },
396
404
  react_1.default.createElement(material_1.TextField, { variant: "standard", style: { width: '100%' }, value: this.state.cron, disabled: true })),
397
- react_1.default.createElement("div", { style: { paddingLeft: 8, width: '100%', height: 60 } }, ComplexCron.convertCronToText(this.state.cron, this.props.language || 'en')),
405
+ react_1.default.createElement("div", { style: { paddingLeft: 8, width: '100%', height: 60 } },
406
+ ComplexCron.convertCronToText(this.state.cron, this.props.language || 'en'),
407
+ react_1.default.createElement("span", { style: styles.warning }, everySecond
408
+ ? i18n_1.default.t('ra_warning_every_second')
409
+ : everyMinute
410
+ ? i18n_1.default.t('ra_warning_every_minute')
411
+ : '')),
398
412
  react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Checkbox, { checked: !!this.state.seconds, onChange: e => this.setState({ seconds: e.target.checked ? '*' : false }, () => this.recalcCron()) }), label: i18n_1.default.t('ra_use seconds') }),
399
413
  react_1.default.createElement(material_1.AppBar, { position: "static", sx: { '&.MuiAppBar-root': styles.appBar }, color: "secondary" },
400
- react_1.default.createElement(material_1.Tabs, { value: this.state.tab, style: styles.appBar, color: "secondary", onChange: (active, _tab) => this.setState({ tab: _tab }) },
414
+ react_1.default.createElement(material_1.Tabs, { value: this.state.tab, style: styles.appBar, color: "secondary", onChange: (_active, _tab) => this.setState({ tab: _tab }) },
401
415
  this.state.seconds !== false && (react_1.default.createElement(material_1.Tab, { id: "sc_seconds", label: i18n_1.default.t('sc_seconds') })),
402
416
  react_1.default.createElement(material_1.Tab, { id: "minutes", label: i18n_1.default.t('sc_minutes') }),
403
417
  react_1.default.createElement(material_1.Tab, { id: "hours", label: i18n_1.default.t('sc_hours') }),
@@ -11,11 +11,13 @@ interface DialogCronProps {
11
11
  }
12
12
  interface DialogCronState {
13
13
  cron: string;
14
+ showWarning: '' | 'everySecond' | 'everyMinute';
14
15
  }
15
16
  declare class DialogComplexCron extends React.Component<DialogCronProps, DialogCronState> {
16
17
  constructor(props: DialogCronProps);
17
18
  handleCancel(): void;
18
- handleOk(): void;
19
+ handleOk(ignoreCheck?: boolean): void;
20
+ renderWarningDialog(): JSX.Element | null;
19
21
  handleClear(): void;
20
22
  render(): JSX.Element;
21
23
  }
@@ -7,6 +7,7 @@ const react_1 = __importDefault(require("react"));
7
7
  const material_1 = require("@mui/material");
8
8
  const icons_material_1 = require("@mui/icons-material");
9
9
  const ComplexCron_1 = __importDefault(require("../Components/ComplexCron"));
10
+ const Confirm_1 = __importDefault(require("../Dialogs/Confirm"));
10
11
  const i18n_1 = __importDefault(require("../i18n"));
11
12
  // Generate cron expression
12
13
  const styles = {
@@ -35,22 +36,48 @@ class DialogComplexCron extends react_1.default.Component {
35
36
  }
36
37
  }
37
38
  this.state = {
39
+ showWarning: '',
38
40
  cron,
39
41
  };
40
42
  }
41
43
  handleCancel() {
42
44
  this.props.onClose();
43
45
  }
44
- handleOk() {
46
+ handleOk(ignoreCheck) {
47
+ if (!ignoreCheck) {
48
+ // Check if the CRON will be executed every second or every minute and warn about it
49
+ const cron = ComplexCron_1.default.cron2state(this.state.cron);
50
+ if (cron.seconds === '*' || cron.seconds === '*/1') {
51
+ this.setState({ showWarning: 'everySecond' });
52
+ return;
53
+ }
54
+ if (cron.minutes === '*' || cron.minutes === '*/1') {
55
+ this.setState({ showWarning: 'everyMinute' });
56
+ return;
57
+ }
58
+ }
45
59
  this.props.onOk(this.state.cron);
46
60
  this.props.onClose();
47
61
  }
62
+ renderWarningDialog() {
63
+ if (!this.state.showWarning) {
64
+ return null;
65
+ }
66
+ return (react_1.default.createElement(Confirm_1.default, { title: i18n_1.default.t('ra_Please confirm'), text: i18n_1.default.t(this.state.showWarning === 'everySecond'
67
+ ? 'ra_The schedule will be executed every second. Are you sure?'
68
+ : 'ra_The schedule will be executed every minute. Are you sure?'), onClose: (ok) => this.setState({ showWarning: '' }, () => {
69
+ if (ok) {
70
+ this.handleOk(true);
71
+ }
72
+ }) }));
73
+ }
48
74
  handleClear() {
49
75
  this.props.onOk(false);
50
76
  this.props.onClose();
51
77
  }
52
78
  render() {
53
79
  return (react_1.default.createElement(material_1.Dialog, { onClose: () => { }, maxWidth: "md", fullWidth: true, sx: { '& .MuiDialog-paper': styles.dialogPaper }, open: !0, "aria-labelledby": "cron-dialog-title" },
80
+ this.renderWarningDialog(),
54
81
  react_1.default.createElement(material_1.DialogTitle, { id: "cron-dialog-title" }, this.props.title || i18n_1.default.t('ra_Define schedule...')),
55
82
  react_1.default.createElement(material_1.DialogContent, { style: { height: '100%', overflow: 'hidden' } },
56
83
  react_1.default.createElement(ComplexCron_1.default, { cronExpression: this.state.cron, onChange: cron => this.setState({ cron }), language: i18n_1.default.getLanguage() })),
package/README.md CHANGED
@@ -13,7 +13,7 @@ If you want to create the configuration page with ReactJS:
13
13
  - Change `name` from `src` to `ADAPTERNAME-admin` (Of course replace `ADAPTERNAME` with yours)
14
14
  - Add to devDependencies:
15
15
  ```
16
- "@iobroker/adapter-react-v5": "^7.1.1",
16
+ "@iobroker/adapter-react-v5": "^7.1.4",
17
17
  ```
18
18
  Versions can be higher.
19
19
  So your `src/package.json` should look like:
@@ -24,7 +24,7 @@ If you want to create the configuration page with ReactJS:
24
24
  "version": "0.1.0",
25
25
  "private": true,
26
26
  "dependencies": {
27
- "@iobroker/adapter-react-v5": "^7.1.1",
27
+ "@iobroker/adapter-react-v5": "^7.1.4",
28
28
  "@iobroker/build-tools": "^1.0.0",
29
29
  "@iobroker/eslint-config": "^0.1.2",
30
30
  "@mui/material": "^6.0.2",
@@ -697,6 +697,15 @@ You can find the migration instructions:
697
697
  -->
698
698
 
699
699
  ## Changelog
700
+ ### 7.1.4 (2024-09-15)
701
+
702
+ - (bluefox) Updated socket classes
703
+
704
+ ### 7.1.3 (2024-09-15)
705
+
706
+ - (bluefox) Updated socket classes
707
+ - (bluefox) Added additional confirmation dialog for CRONs for every minute execution
708
+
700
709
  ### 7.1.1 (2024-09-13)
701
710
 
702
711
  - (bluefox) Corrected TabContainer