react-cron-generator 1.3.13 → 2.0.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/README.md +4 -19
- package/dist/index.js +7498 -4
- package/dist/index.js.map +1 -0
- package/package.json +33 -13
- package/dist/cron-builder.css +0 -91
- package/dist/cron-tab/custom.js +0 -46
- package/dist/cron-tab/daily.js +0 -130
- package/dist/cron-tab/hourly.js +0 -143
- package/dist/cron-tab/minutes.js +0 -52
- package/dist/cron-tab/monthly.js +0 -175
- package/dist/cron-tab/weekly.js +0 -148
- package/dist/cron-tab/yearly.js +0 -32
- package/dist/cron.js +0 -245
- package/dist/hour-select/index.js +0 -47
- package/dist/localization/translation.json +0 -29
- package/dist/meta/index.js +0 -79
- package/dist/minutes-select/index.js +0 -47
package/dist/cron-tab/monthly.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
-
|
|
7
|
-
/* eslint-disable react/no-direct-mutation-state */
|
|
8
|
-
import React, { Component } from 'react';
|
|
9
|
-
import Minutes from '../minutes-select';
|
|
10
|
-
import Hour from '../hour-select';
|
|
11
|
-
|
|
12
|
-
var MonthlyCron = /*#__PURE__*/function (_Component) {
|
|
13
|
-
_inherits(MonthlyCron, _Component);
|
|
14
|
-
|
|
15
|
-
var _super = _createSuper(MonthlyCron);
|
|
16
|
-
|
|
17
|
-
function MonthlyCron(props) {
|
|
18
|
-
var _this;
|
|
19
|
-
|
|
20
|
-
_classCallCheck(this, MonthlyCron);
|
|
21
|
-
|
|
22
|
-
_this = _super.call(this, props);
|
|
23
|
-
_this.state = {
|
|
24
|
-
hour: 0,
|
|
25
|
-
minute: 0
|
|
26
|
-
};
|
|
27
|
-
_this.onDayChange = _this.onDayChange.bind(_assertThisInitialized(_this));
|
|
28
|
-
_this.onLastDayChange = _this.onLastDayChange.bind(_assertThisInitialized(_this));
|
|
29
|
-
_this.onAtHourChange = _this.onAtHourChange.bind(_assertThisInitialized(_this));
|
|
30
|
-
_this.onAtMinuteChange = _this.onAtMinuteChange.bind(_assertThisInitialized(_this));
|
|
31
|
-
return _this;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
_createClass(MonthlyCron, [{
|
|
35
|
-
key: "UNSAFE_componentWillMount",
|
|
36
|
-
value: function UNSAFE_componentWillMount() {
|
|
37
|
-
this.state.value = this.props.value;
|
|
38
|
-
|
|
39
|
-
if (this.state.value[3] === 'L') {
|
|
40
|
-
this.state.every = "2";
|
|
41
|
-
} else if (this.state.value[3] === 'LW') {
|
|
42
|
-
this.state.every = "3";
|
|
43
|
-
} else if (this.state.value[3].startsWith('L')) {
|
|
44
|
-
this.state.every = "4";
|
|
45
|
-
} else {
|
|
46
|
-
this.state.every = "1";
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}, {
|
|
50
|
-
key: "onDayChange",
|
|
51
|
-
value: function onDayChange(e) {
|
|
52
|
-
if (parseInt(e.target.value) > 0 && parseInt(e.target.value) <= 31 || e.target.value === "") {
|
|
53
|
-
var val = ['0', this.state.value[1] === '*' ? '0' : this.state.value[1], this.state.value[2] === '*' ? '0' : this.state.value[2], this.state.value[3], '1/1', '?', '*'];
|
|
54
|
-
val[3] = "".concat(e.target.value);
|
|
55
|
-
this.props.onChange(val);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
key: "onLastDayChange",
|
|
60
|
-
value: function onLastDayChange(e) {
|
|
61
|
-
if (parseInt(e.target.value) >> 0 && parseInt(e.target.value) <= 31 || e.target.value === "") {
|
|
62
|
-
var val = ['0', this.state.value[1] === '*' ? '0' : this.state.value[1], this.state.value[2] === '*' ? '0' : this.state.value[2], this.state.value[3], '1/1', '?', '*'];
|
|
63
|
-
|
|
64
|
-
if (e.target.value === '') {
|
|
65
|
-
val[3] = '';
|
|
66
|
-
} else {
|
|
67
|
-
val[3] = "L-".concat(e.target.value);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
this.props.onChange(val);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "onAtHourChange",
|
|
75
|
-
value: function onAtHourChange(e) {
|
|
76
|
-
var val = this.state.value;
|
|
77
|
-
val[2] = "".concat(e.target.value);
|
|
78
|
-
this.props.onChange(val);
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: "onAtMinuteChange",
|
|
82
|
-
value: function onAtMinuteChange(e) {
|
|
83
|
-
var val = this.state.value;
|
|
84
|
-
val[1] = "".concat(e.target.value);
|
|
85
|
-
this.props.onChange(val);
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "render",
|
|
89
|
-
value: function render() {
|
|
90
|
-
var _this2 = this;
|
|
91
|
-
|
|
92
|
-
var translateFn = this.props.translate;
|
|
93
|
-
this.state.value = this.props.value;
|
|
94
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
95
|
-
className: "tab-pane"
|
|
96
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
97
|
-
className: "well well-small"
|
|
98
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
99
|
-
type: "radio",
|
|
100
|
-
onChange: function onChange(e) {
|
|
101
|
-
_this2.setState({
|
|
102
|
-
every: e.target.value
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
_this2.props.onChange(['0', _this2.state.value[1] === '*' ? '0' : _this2.state.value[1], _this2.state.value[2] === '*' ? '0' : _this2.state.value[2], '1', '1/1', '?', '*']);
|
|
106
|
-
},
|
|
107
|
-
value: "1",
|
|
108
|
-
name: "MonthlyRadio",
|
|
109
|
-
checked: this.state.every === "1" ? true : false
|
|
110
|
-
}), translateFn('Day'), /*#__PURE__*/React.createElement("input", {
|
|
111
|
-
readOnly: this.state.every !== "1",
|
|
112
|
-
type: "number",
|
|
113
|
-
value: this.state.value[3],
|
|
114
|
-
onChange: this.onDayChange
|
|
115
|
-
}), translateFn('of every month(s)')), /*#__PURE__*/React.createElement("div", {
|
|
116
|
-
className: "well well-small"
|
|
117
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
118
|
-
onChange: function onChange(e) {
|
|
119
|
-
_this2.setState({
|
|
120
|
-
every: e.target.value
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
_this2.props.onChange(['0', _this2.state.value[1] === '*' ? '0' : _this2.state.value[1], _this2.state.value[2] === '*' ? '0' : _this2.state.value[2], 'L', '*', '?', '*']);
|
|
124
|
-
},
|
|
125
|
-
type: "radio",
|
|
126
|
-
value: "2",
|
|
127
|
-
name: "DailyRadio",
|
|
128
|
-
checked: this.state.every === "2" ? true : false
|
|
129
|
-
}), translateFn('Last day of every month')), /*#__PURE__*/React.createElement("div", {
|
|
130
|
-
className: "well well-small"
|
|
131
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
132
|
-
onChange: function onChange(e) {
|
|
133
|
-
_this2.setState({
|
|
134
|
-
every: e.target.value
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
_this2.props.onChange(['0', _this2.state.value[1] === '*' ? '0' : _this2.state.value[1], _this2.state.value[2] === '*' ? '0' : _this2.state.value[2], 'LW', '*', '?', '*']);
|
|
138
|
-
},
|
|
139
|
-
type: "radio",
|
|
140
|
-
value: "3",
|
|
141
|
-
name: "DailyRadio",
|
|
142
|
-
checked: this.state.every === "3" ? true : false
|
|
143
|
-
}), translateFn('On the last weekday of every month')), /*#__PURE__*/React.createElement("div", {
|
|
144
|
-
className: "well well-small"
|
|
145
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
146
|
-
type: "radio",
|
|
147
|
-
onChange: function onChange(e) {
|
|
148
|
-
_this2.setState({
|
|
149
|
-
every: e.target.value
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
_this2.props.onChange(['0', _this2.state.value[1] === '*' ? '0' : _this2.state.value[1], _this2.state.value[2] === '*' ? '0' : _this2.state.value[2], "L-".concat(1), '*', '?', '*']);
|
|
153
|
-
},
|
|
154
|
-
value: "4",
|
|
155
|
-
name: "MonthlyRadio",
|
|
156
|
-
checked: this.state.every === "4" ? true : false
|
|
157
|
-
}), /*#__PURE__*/React.createElement("input", {
|
|
158
|
-
readOnly: this.state.every !== "4",
|
|
159
|
-
type: "number",
|
|
160
|
-
value: this.state.value[3].split('-').length && this.state.value[3].split('-')[1] ? this.state.value[3].split('-')[1] : '',
|
|
161
|
-
onChange: this.onLastDayChange
|
|
162
|
-
}), translateFn('day(s) before the end of the month')), translateFn('Start time'), /*#__PURE__*/React.createElement(Hour, {
|
|
163
|
-
onChange: this.onAtHourChange,
|
|
164
|
-
value: this.state.value[2]
|
|
165
|
-
}), /*#__PURE__*/React.createElement(Minutes, {
|
|
166
|
-
onChange: this.onAtMinuteChange,
|
|
167
|
-
value: this.state.value[1]
|
|
168
|
-
}));
|
|
169
|
-
}
|
|
170
|
-
}]);
|
|
171
|
-
|
|
172
|
-
return MonthlyCron;
|
|
173
|
-
}(Component);
|
|
174
|
-
|
|
175
|
-
export { MonthlyCron as default };
|
package/dist/cron-tab/weekly.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
-
import React, { Component } from 'react';
|
|
7
|
-
import Minutes from '../minutes-select';
|
|
8
|
-
import Hour from '../hour-select';
|
|
9
|
-
|
|
10
|
-
var WeeklyCron = /*#__PURE__*/function (_Component) {
|
|
11
|
-
_inherits(WeeklyCron, _Component);
|
|
12
|
-
|
|
13
|
-
var _super = _createSuper(WeeklyCron);
|
|
14
|
-
|
|
15
|
-
function WeeklyCron(props) {
|
|
16
|
-
var _this;
|
|
17
|
-
|
|
18
|
-
_classCallCheck(this, WeeklyCron);
|
|
19
|
-
|
|
20
|
-
_this = _super.call(this, props);
|
|
21
|
-
_this.state = {};
|
|
22
|
-
_this.onAtHourChange = _this.onAtHourChange.bind(_assertThisInitialized(_this));
|
|
23
|
-
_this.onAtMinuteChange = _this.onAtMinuteChange.bind(_assertThisInitialized(_this));
|
|
24
|
-
_this.onCheck = _this.onCheck.bind(_assertThisInitialized(_this));
|
|
25
|
-
return _this;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
_createClass(WeeklyCron, [{
|
|
29
|
-
key: "onAtHourChange",
|
|
30
|
-
value: function onAtHourChange(e) {
|
|
31
|
-
var val = this.state.value;
|
|
32
|
-
val[0] = '0';
|
|
33
|
-
val[2] = "".concat(e.target.value);
|
|
34
|
-
this.props.onChange(val);
|
|
35
|
-
}
|
|
36
|
-
}, {
|
|
37
|
-
key: "onAtMinuteChange",
|
|
38
|
-
value: function onAtMinuteChange(e) {
|
|
39
|
-
var val = this.state.value;
|
|
40
|
-
val[0] = '0';
|
|
41
|
-
val[1] = "".concat(e.target.value);
|
|
42
|
-
this.props.onChange(val);
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
key: "onCheck",
|
|
46
|
-
value: function onCheck(e) {
|
|
47
|
-
var val = this.state.value;
|
|
48
|
-
val[0] = '0';
|
|
49
|
-
|
|
50
|
-
if (e.target.checked) {
|
|
51
|
-
this.onDayChecked(val, e);
|
|
52
|
-
} else {
|
|
53
|
-
this.onDayUnChecked(val, e);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
this.props.onChange(val);
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
key: "onDayChecked",
|
|
60
|
-
value: function onDayChecked(val, e) {
|
|
61
|
-
val[2] = "".concat(val[2]).split('/').length > 1 ? '0' : val[2].toString();
|
|
62
|
-
val[3] = '?';
|
|
63
|
-
val[4] = '*';
|
|
64
|
-
|
|
65
|
-
if (val[5] === '*' || val[5] === '?' || val[5] === 'MON-FRI') {
|
|
66
|
-
val[5] = e.target.value;
|
|
67
|
-
} else {
|
|
68
|
-
val[5] = val[5] + '!' + e.target.value;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
key: "onDayUnChecked",
|
|
73
|
-
value: function onDayUnChecked(val, e) {
|
|
74
|
-
val[5] = val[5].split('!');
|
|
75
|
-
|
|
76
|
-
if (val[5].length > 1) {
|
|
77
|
-
val[5].splice(val[5].indexOf(e.target.value), 1);
|
|
78
|
-
val[5] = val[5].toString().replace(/,/g, '!');
|
|
79
|
-
} else {
|
|
80
|
-
val[5] = '*';
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
key: "render",
|
|
85
|
-
value: function render() {
|
|
86
|
-
var translateFn = this.props.translate;
|
|
87
|
-
this.state.value = this.props.value;
|
|
88
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
89
|
-
className: "container-fluid"
|
|
90
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
91
|
-
className: "well well-small row"
|
|
92
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
93
|
-
className: "span6 col-sm-6"
|
|
94
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
95
|
-
className: "text_align_left"
|
|
96
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
97
|
-
type: "checkbox",
|
|
98
|
-
value: "MON",
|
|
99
|
-
onChange: this.onCheck,
|
|
100
|
-
checked: this.state.value[5].search('MON') !== -1 ? true : false
|
|
101
|
-
}), translateFn('Monday'), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", {
|
|
102
|
-
type: "checkbox",
|
|
103
|
-
value: "WED",
|
|
104
|
-
onChange: this.onCheck,
|
|
105
|
-
checked: this.state.value[5].search('WED') !== -1 ? true : false
|
|
106
|
-
}), translateFn('Wednesday'), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", {
|
|
107
|
-
type: "checkbox",
|
|
108
|
-
value: "FRI",
|
|
109
|
-
onChange: this.onCheck,
|
|
110
|
-
checked: this.state.value[5].search('FRI') !== -1 ? true : false
|
|
111
|
-
}), translateFn('Friday'), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", {
|
|
112
|
-
type: "checkbox",
|
|
113
|
-
value: "SUN",
|
|
114
|
-
onChange: this.onCheck,
|
|
115
|
-
checked: this.state.value[5].search('SUN') !== -1 ? true : false
|
|
116
|
-
}), translateFn('Sunday'))), /*#__PURE__*/React.createElement("div", {
|
|
117
|
-
className: "span6 col-sm-6"
|
|
118
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
119
|
-
className: "text_align_left"
|
|
120
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
121
|
-
type: "checkbox",
|
|
122
|
-
value: "TUE",
|
|
123
|
-
onChange: this.onCheck,
|
|
124
|
-
checked: this.state.value[5].search('TUE') !== -1 ? true : false
|
|
125
|
-
}), translateFn('Tuesday'), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", {
|
|
126
|
-
type: "checkbox",
|
|
127
|
-
value: "THU",
|
|
128
|
-
onChange: this.onCheck,
|
|
129
|
-
checked: this.state.value[5].search('THU') !== -1 ? true : false
|
|
130
|
-
}), translateFn('Thursday'), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("input", {
|
|
131
|
-
type: "checkbox",
|
|
132
|
-
value: "SAT",
|
|
133
|
-
onChange: this.onCheck,
|
|
134
|
-
checked: this.state.value[5].search('SAT') !== -1 ? true : false
|
|
135
|
-
}), translateFn('Saturday')), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null))), translateFn('Start time'), /*#__PURE__*/React.createElement(Hour, {
|
|
136
|
-
onChange: this.onAtHourChange,
|
|
137
|
-
value: this.state.value[2]
|
|
138
|
-
}), /*#__PURE__*/React.createElement(Minutes, {
|
|
139
|
-
onChange: this.onAtMinuteChange,
|
|
140
|
-
value: this.state.value[1]
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
}]);
|
|
144
|
-
|
|
145
|
-
return WeeklyCron;
|
|
146
|
-
}(Component);
|
|
147
|
-
|
|
148
|
-
export { WeeklyCron as default };
|
package/dist/cron-tab/yearly.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
-
import React, { Component } from 'react';
|
|
6
|
-
|
|
7
|
-
var YearlyCron = /*#__PURE__*/function (_Component) {
|
|
8
|
-
_inherits(YearlyCron, _Component);
|
|
9
|
-
|
|
10
|
-
var _super = _createSuper(YearlyCron);
|
|
11
|
-
|
|
12
|
-
function YearlyCron(props) {
|
|
13
|
-
var _this;
|
|
14
|
-
|
|
15
|
-
_classCallCheck(this, YearlyCron);
|
|
16
|
-
|
|
17
|
-
_this = _super.call(this, props);
|
|
18
|
-
_this.state = {};
|
|
19
|
-
return _this;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
_createClass(YearlyCron, [{
|
|
23
|
-
key: "render",
|
|
24
|
-
value: function render() {
|
|
25
|
-
return /*#__PURE__*/React.createElement("div", null, "yearly");
|
|
26
|
-
}
|
|
27
|
-
}]);
|
|
28
|
-
|
|
29
|
-
return YearlyCron;
|
|
30
|
-
}(Component);
|
|
31
|
-
|
|
32
|
-
export { YearlyCron as default };
|
package/dist/cron.js
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
-
|
|
6
|
-
/* eslint-disable react/no-direct-mutation-state */
|
|
7
|
-
import React, { Component } from 'react';
|
|
8
|
-
import cronstrue from 'cronstrue/i18n';
|
|
9
|
-
import { metadata, loadHeaders } from './meta';
|
|
10
|
-
import './cron-builder.css';
|
|
11
|
-
|
|
12
|
-
var Cron = /*#__PURE__*/function (_Component) {
|
|
13
|
-
_inherits(Cron, _Component);
|
|
14
|
-
|
|
15
|
-
var _super = _createSuper(Cron);
|
|
16
|
-
|
|
17
|
-
function Cron(props) {
|
|
18
|
-
var _this;
|
|
19
|
-
|
|
20
|
-
_classCallCheck(this, Cron);
|
|
21
|
-
|
|
22
|
-
_this = _super.call(this, props);
|
|
23
|
-
_this.state = {
|
|
24
|
-
headers: loadHeaders(_this.props.options),
|
|
25
|
-
locale: _this.props.locale ? _this.props.locale : 'en'
|
|
26
|
-
};
|
|
27
|
-
return _this;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
_createClass(Cron, [{
|
|
31
|
-
key: "UNSAFE_componentWillMount",
|
|
32
|
-
value: function UNSAFE_componentWillMount() {
|
|
33
|
-
this.setValue(this.props.value);
|
|
34
|
-
|
|
35
|
-
if (this.props.translateFn && !this.props.locale) {
|
|
36
|
-
console.log('Warning !!! locale not set while using translateFn');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (this.props.onRef) {
|
|
40
|
-
this.props.onRef(this);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
45
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
46
|
-
if (this.props.value !== nextProps.value && this.state.value) {
|
|
47
|
-
var newVal = '';
|
|
48
|
-
newVal = this.state.value.toString().replace(/,/g, ' ');
|
|
49
|
-
newVal = newVal.replace(/!/g, ',');
|
|
50
|
-
|
|
51
|
-
if (nextProps.value !== newVal) {
|
|
52
|
-
this.setValue(nextProps.value);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
key: "setValue",
|
|
58
|
-
value: function setValue(value) {
|
|
59
|
-
var prevState = this.state;
|
|
60
|
-
prevState.value = value;
|
|
61
|
-
var allHeaders = loadHeaders();
|
|
62
|
-
|
|
63
|
-
if (prevState.value && prevState.value.split(' ').length === 6) {
|
|
64
|
-
prevState.value += ' *';
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!prevState.value || prevState.value.split(' ').length !== 7) {
|
|
68
|
-
prevState.value = ['0', '0', '00', '1/1', '*', '?', '*'];
|
|
69
|
-
prevState.selectedTab = allHeaders[0];
|
|
70
|
-
this.parentChange(prevState.value);
|
|
71
|
-
} else {
|
|
72
|
-
prevState.value = prevState.value.replace(/,/g, '!').split(' ');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
var val = prevState.value;
|
|
76
|
-
|
|
77
|
-
if (val[1].search('/') !== -1 && val[2] === '*' && val[3] === '1/1') {
|
|
78
|
-
prevState.selectedTab = allHeaders[0];
|
|
79
|
-
} else if (val[3] === '1/1') {
|
|
80
|
-
prevState.selectedTab = allHeaders[1];
|
|
81
|
-
} else if (val[3].search('/') !== -1 || val[5] === 'MON-FRI') {
|
|
82
|
-
prevState.selectedTab = allHeaders[2];
|
|
83
|
-
} else if (val[3] === '?') {
|
|
84
|
-
prevState.selectedTab = allHeaders[3];
|
|
85
|
-
} else if (val[3].startsWith('L') || val[4] === '1/1') {
|
|
86
|
-
prevState.selectedTab = allHeaders[4];
|
|
87
|
-
} else {
|
|
88
|
-
prevState.selectedTab = allHeaders[0];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (!prevState.headers.includes(prevState.selectedTab)) {
|
|
92
|
-
prevState.selectedTab = prevState.headers[0];
|
|
93
|
-
} // this.parentChange(prevState.value)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this.setState(prevState);
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "tabChanged",
|
|
100
|
-
value: function tabChanged(tab) {
|
|
101
|
-
var _this2 = this;
|
|
102
|
-
|
|
103
|
-
if (this.state.selectedTab !== tab) {
|
|
104
|
-
this.setState({
|
|
105
|
-
selectedTab: tab,
|
|
106
|
-
value: this.defaultValue(tab)
|
|
107
|
-
}, function () {
|
|
108
|
-
return _this2.parentChange(_this2.defaultValue(tab));
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
key: "getHeaders",
|
|
114
|
-
value: function getHeaders() {
|
|
115
|
-
var _this3 = this;
|
|
116
|
-
|
|
117
|
-
return this.state.headers.map(function (d, index) {
|
|
118
|
-
return /*#__PURE__*/React.createElement("li", {
|
|
119
|
-
className: "nav-item",
|
|
120
|
-
key: index
|
|
121
|
-
}, /*#__PURE__*/React.createElement("a", {
|
|
122
|
-
className: "nav-link ".concat(_this3.state.selectedTab === d ? 'active' : ''),
|
|
123
|
-
onClick: _this3.tabChanged.bind(_this3, d)
|
|
124
|
-
}, _this3.translate(d)));
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "onValueChange",
|
|
129
|
-
value: function onValueChange(val) {
|
|
130
|
-
var _this4 = this;
|
|
131
|
-
|
|
132
|
-
if (val && val.length) {
|
|
133
|
-
this.setState({
|
|
134
|
-
value: val
|
|
135
|
-
}, function () {
|
|
136
|
-
return _this4.parentChange(val);
|
|
137
|
-
});
|
|
138
|
-
} else {
|
|
139
|
-
val = ['0', '0', '00', '1/1', '*', '?', '*'];
|
|
140
|
-
this.setState({
|
|
141
|
-
value: val
|
|
142
|
-
}, function () {
|
|
143
|
-
return _this4.parentChange(val);
|
|
144
|
-
}); // val = ['0','0','00','1/1','*','?','*'];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}, {
|
|
148
|
-
key: "parentChange",
|
|
149
|
-
value: function parentChange(val) {
|
|
150
|
-
var newVal = '';
|
|
151
|
-
newVal = val.toString().replace(/,/g, ' ');
|
|
152
|
-
newVal = newVal.replace(/!/g, ',');
|
|
153
|
-
this.props.onChange(newVal, this.getVal());
|
|
154
|
-
}
|
|
155
|
-
}, {
|
|
156
|
-
key: "getVal",
|
|
157
|
-
value: function getVal() {
|
|
158
|
-
var val = cronstrue.toString(this.state.value.toString().replace(/,/g, ' ').replace(/!/g, ','), {
|
|
159
|
-
throwExceptionOnParseError: false,
|
|
160
|
-
locale: this.state.locale
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
if (val.search('undefined') === -1) {
|
|
164
|
-
return val;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return '-';
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
key: "defaultValue",
|
|
171
|
-
value: function defaultValue(tab) {
|
|
172
|
-
var defaultValCron = metadata.find(function (m) {
|
|
173
|
-
return m.name == tab;
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
if (!defaultValCron || !defaultValCron.initialCron) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return defaultValCron.initialCron;
|
|
181
|
-
}
|
|
182
|
-
}, {
|
|
183
|
-
key: "getComponent",
|
|
184
|
-
value: function getComponent(tab) {
|
|
185
|
-
var index = this.state.headers.indexOf(tab);
|
|
186
|
-
|
|
187
|
-
if (metadata[index] === -1) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
var selectedMetaData = metadata.find(function (data) {
|
|
192
|
-
return data.name === tab;
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
if (!selectedMetaData) {
|
|
196
|
-
selectedMetaData = metadata[index];
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (!selectedMetaData) {
|
|
200
|
-
throw new Error('Value does not match any available headers.');
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
var CronComponent = selectedMetaData.component;
|
|
204
|
-
return /*#__PURE__*/React.createElement(CronComponent, {
|
|
205
|
-
translate: this.translate.bind(this),
|
|
206
|
-
value: this.state.value,
|
|
207
|
-
onChange: this.onValueChange.bind(this)
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}, {
|
|
211
|
-
key: "translate",
|
|
212
|
-
value: function translate(key) {
|
|
213
|
-
var translatedText = key;
|
|
214
|
-
|
|
215
|
-
if (this.props.translateFn) {
|
|
216
|
-
translatedText = this.props.translateFn(key);
|
|
217
|
-
|
|
218
|
-
if (typeof translatedText !== 'string') {
|
|
219
|
-
throw new Error('translateFn expects a string translation');
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return translatedText;
|
|
224
|
-
}
|
|
225
|
-
}, {
|
|
226
|
-
key: "render",
|
|
227
|
-
value: function render() {
|
|
228
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
229
|
-
className: "cron_builder"
|
|
230
|
-
}, /*#__PURE__*/React.createElement("ul", {
|
|
231
|
-
className: "nav nav-tabs"
|
|
232
|
-
}, this.getHeaders()), /*#__PURE__*/React.createElement("div", {
|
|
233
|
-
className: "cron_builder_bordering"
|
|
234
|
-
}, this.state.selectedTab ? this.getComponent(this.state.selectedTab) : "Select a header"), this.props.showResultText && /*#__PURE__*/React.createElement("div", {
|
|
235
|
-
className: "cron-builder-bg"
|
|
236
|
-
}, this.getVal()), this.props.showResultCron && /*#__PURE__*/React.createElement("div", {
|
|
237
|
-
className: "cron-builder-bg"
|
|
238
|
-
}, this.state.value.toString().replace(/,/g, ' ').replace(/!/g, ',')));
|
|
239
|
-
}
|
|
240
|
-
}]);
|
|
241
|
-
|
|
242
|
-
return Cron;
|
|
243
|
-
}(Component);
|
|
244
|
-
|
|
245
|
-
export { Cron as default };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
-
import React, { Component } from 'react';
|
|
6
|
-
|
|
7
|
-
var Hour = /*#__PURE__*/function (_Component) {
|
|
8
|
-
_inherits(Hour, _Component);
|
|
9
|
-
|
|
10
|
-
var _super = _createSuper(Hour);
|
|
11
|
-
|
|
12
|
-
function Hour() {
|
|
13
|
-
_classCallCheck(this, Hour);
|
|
14
|
-
|
|
15
|
-
return _super.apply(this, arguments);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
_createClass(Hour, [{
|
|
19
|
-
key: "render",
|
|
20
|
-
value: function render() {
|
|
21
|
-
return /*#__PURE__*/React.createElement("select", {
|
|
22
|
-
disabled: this.props.disabled === true ? true : false,
|
|
23
|
-
className: "hours",
|
|
24
|
-
onChange: this.props.onChange ? this.props.onChange : function () {},
|
|
25
|
-
value: this.props.value
|
|
26
|
-
}, this.buildOptions());
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: "buildOptions",
|
|
30
|
-
value: function buildOptions() {
|
|
31
|
-
var options = [];
|
|
32
|
-
|
|
33
|
-
for (var i = 0; i < 24; i++) {
|
|
34
|
-
options.push( /*#__PURE__*/React.createElement("option", {
|
|
35
|
-
key: i,
|
|
36
|
-
id: i
|
|
37
|
-
}, (i < 10 ? '0' : '') + i));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return options;
|
|
41
|
-
}
|
|
42
|
-
}]);
|
|
43
|
-
|
|
44
|
-
return Hour;
|
|
45
|
-
}(Component);
|
|
46
|
-
|
|
47
|
-
export { Hour as default };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Every": "Every",
|
|
3
|
-
"day(s)": "day(s)",
|
|
4
|
-
"Every week day": "Every week day",
|
|
5
|
-
"Start time": "Start time",
|
|
6
|
-
"hour": "hour",
|
|
7
|
-
"minutes(s)":"minutes(s)",
|
|
8
|
-
"At": "At",
|
|
9
|
-
"minute(s)": "minute(s)",
|
|
10
|
-
"Day": "Day",
|
|
11
|
-
"of every month(s)": "of every month(s)",
|
|
12
|
-
"Last day of every month": "Last day of every month",
|
|
13
|
-
"On the last weekday of every month": "On the last weekday of every month",
|
|
14
|
-
"day(s) before the end of the month": "day(s) before the end of the month",
|
|
15
|
-
"Monday": "Monday",
|
|
16
|
-
"Tuesday": "Tuesday",
|
|
17
|
-
"Wednesday": "Wednesday",
|
|
18
|
-
"Thursday": "Thursday",
|
|
19
|
-
"Friday": "Friday",
|
|
20
|
-
"Saturday": "Saturday",
|
|
21
|
-
"Sunday": "Sunday",
|
|
22
|
-
"Minutes": "Minutes",
|
|
23
|
-
"Hourly": "Hourly",
|
|
24
|
-
"Daily": "Daily",
|
|
25
|
-
"Weekly": "Weekly",
|
|
26
|
-
"Monthly": "Monthly",
|
|
27
|
-
"Custom": "Custom",
|
|
28
|
-
"Expression": "Expression"
|
|
29
|
-
}
|