react-cron-generator
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -44,5 +44,13 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
value: function onDayChange(e) { | ||
var val = ['0', this.state.value[1] === '*' ? '0' : this.state.value[1], this.state.value[2] === '*' ? '0' : this.state.value[2], '*', '*', '?', '*']; | ||
val[3] = "1/".concat(e.target.value); | ||
this.props.onChange(val); | ||
if (e.target.value > 0 && e.target.value < 32 || e.target.value == '') { | ||
var val = ['0', this.state.value[1] === '*' ? '0' : this.state.value[1], this.state.value[2] === '*' ? '0' : this.state.value[2], '*', '*', '?', '*']; | ||
if (e.target.value == '') { | ||
val[3] = ''; | ||
} else { | ||
val[3] = "1/".concat(e.target.value); | ||
} | ||
this.props.onChange(val); | ||
} | ||
} | ||
@@ -70,5 +78,5 @@ }, { | ||
return React.createElement("div", { | ||
className: "tab-pane" | ||
class: "tab-pane" | ||
}, React.createElement("div", { | ||
className: "well well-small" | ||
class: "well well-small" | ||
}, React.createElement("input", { | ||
@@ -92,3 +100,3 @@ type: "radio", | ||
}), "\xA0 day(s)"), React.createElement("div", { | ||
className: "well well-small" | ||
class: "well well-small" | ||
}, React.createElement("input", { | ||
@@ -106,5 +114,5 @@ onClick: function onClick(e) { | ||
checked: this.state.every ? false : true | ||
}), "\xA0 Every week day \xA0"), "\xA0 Start time \xA0", React.createElement("select", { | ||
}), "\xA0 Every week day\xA0"), "\xA0 Start time\xA0", React.createElement("select", { | ||
id: "DailyHours", | ||
className: "hours", | ||
class: "hours", | ||
onChange: this.onAtHourChange, | ||
@@ -162,3 +170,3 @@ value: this.state.value[2] | ||
id: "DailyMinutes", | ||
className: "minutes", | ||
class: "minutes", | ||
onChange: this.onAtMinuteChange, | ||
@@ -165,0 +173,0 @@ value: this.state.value[1] |
@@ -39,5 +39,11 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
value: function onHourChange(e) { | ||
if (this.state.every) { | ||
if (this.state.every && (e.target.value > 0 && e.target.value < 24 || e.target.value == '')) { | ||
var val = ['0', '0', '*', '*', '*', '?', '*']; | ||
val[2] = "0/".concat(e.target.value); | ||
if (e.target.value == '') { | ||
val[2] = ''; | ||
} else { | ||
val[2] = "0/".concat(e.target.value); | ||
} | ||
val[3] = '1/1'; | ||
@@ -82,3 +88,3 @@ this.props.onChange(val); | ||
_this2.props.onChange(); | ||
_this2.props.onChange(['0', '0', '0/1', '1/1', '*', '?', '*']); | ||
}, | ||
@@ -92,7 +98,5 @@ checked: this.state.every ? true : false | ||
}), React.createElement("span", null, "\xA0hour(s)\xA0")), React.createElement("div", { | ||
className: "container-fluid" | ||
className: "well row well-small margin-right-0 margin-left-0" | ||
}, React.createElement("div", { | ||
className: "well row well-small " | ||
}, React.createElement("div", { | ||
className: "col-md-offset-2 col-md-6 " | ||
className: "col-md-offset-2 col-md-6 text_align_right" | ||
}, React.createElement("input", { | ||
@@ -109,3 +113,3 @@ type: "radio", | ||
}), React.createElement("span", { | ||
className: "" | ||
className: "margin-right-10 " | ||
}, "\xA0At\xA0"), React.createElement("select", { | ||
@@ -121,3 +125,3 @@ className: "hours", | ||
value: this.state.value[1] | ||
}, this.getMinutes())))))); | ||
}, this.getMinutes()))))); | ||
} | ||
@@ -124,0 +128,0 @@ }, { |
@@ -13,4 +13,4 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import Monthly from './monthly'; | ||
import Yearly from './yearly'; // import './cron-builder.css'; | ||
import Yearly from './yearly'; | ||
import './cron-builder.css'; | ||
var tabs = ['Minutes', 'Hourly', 'Daily', 'Weekly', 'Monthly']; //,'Yearly' | ||
@@ -38,25 +38,58 @@ | ||
if (!this.props.value || this.props.value.split(' ').length !== 7) { | ||
this.state.value = ['0', '0', '0', '*', '*', '*', '*']; | ||
this.state.value = ['0', '0', '00', '1/1', '*', '?', '*']; | ||
this.state.selectedTab = tabs[0]; | ||
this.parentChange(this.state.value); | ||
} else { | ||
this.state.value = this.props.value.replace(/,/g, '!').split(' '); | ||
; | ||
var val = this.state.value; | ||
} | ||
if (val[1].search('/') !== -1 && val[2] == '*' && val[3] == '1/1') { | ||
this.state.selectedTab = tabs[0]; | ||
} else if (val[3] == '1/1') { | ||
this.state.selectedTab = tabs[1]; | ||
} else if (val[3].search('/') !== -1 || val[5] == 'MON-FRI') { | ||
this.state.selectedTab = tabs[2]; | ||
} else if (val[3] === '?') { | ||
this.state.selectedTab = tabs[3]; | ||
} else if (val[3].startsWith('L') || val[4] === '1/1') { | ||
this.state.selectedTab = tabs[4]; | ||
} else { | ||
this.state.selectedTab = tabs[0]; | ||
} | ||
var val = this.state.value; | ||
if (val[1].search('/') !== -1 && val[2] == '*' && val[3] == '1/1') { | ||
this.state.selectedTab = tabs[0]; | ||
} else if (val[3] == '1/1') { | ||
this.state.selectedTab = tabs[1]; | ||
} else if (val[3].search('/') !== -1 || val[5] == 'MON-FRI') { | ||
this.state.selectedTab = tabs[2]; | ||
} else if (val[3] === '?') { | ||
this.state.selectedTab = tabs[3]; | ||
} else if (val[3].startsWith('L') || val[4] === '1/1') { | ||
this.state.selectedTab = tabs[4]; | ||
} else { | ||
this.state.selectedTab = tabs[0]; | ||
} | ||
} | ||
}, { | ||
key: "defaultValue", | ||
value: function defaultValue(tab) { | ||
switch (tab) { | ||
case tabs[0]: | ||
return ['0', '0/1', '*', '*', '*', '?', '*']; | ||
break; | ||
case tabs[1]: | ||
return ['0', '0', '00', '1/1', '*', '?', '*']; | ||
break; | ||
case tabs[2]: | ||
return ['0', '0', '00', '1/1', '*', '?', '*']; | ||
break; | ||
case tabs[3]: | ||
return ['0', '0', '00', '?', '*', '*', '*']; | ||
break; | ||
case tabs[4]: | ||
return ['0', '0', '00', '1', '1/1', '?', '*']; | ||
break; | ||
case tabs[5]: | ||
return ['0', '0', '00', '1', '1/1', '?', '*']; | ||
break; | ||
default: | ||
return; | ||
} | ||
} | ||
}, { | ||
key: "tabChanged", | ||
@@ -66,4 +99,5 @@ value: function tabChanged(tab) { | ||
selectedTab: tab, | ||
value: ['0', '0', '0', '*', '*', '*', '*'] | ||
value: this.defaultValue(tab) | ||
}); | ||
this.parentChange(this.defaultValue(tab)); | ||
} | ||
@@ -86,4 +120,2 @@ }, { | ||
value: function onValueChange(val) { | ||
var newVal = ''; | ||
if (val && val.length) { | ||
@@ -95,7 +127,13 @@ this.setState({ | ||
this.setState({ | ||
value: ['0', '0', '0', '*', '*', '*', '*'] | ||
value: ['0', '0', '00', '1/1', '*', '?', '*'] | ||
}); | ||
val = ['0', '0', '0', '*', '*', '*', '*']; | ||
val = ['0', '0', '00', '1/1', '*', '?', '*']; | ||
} | ||
this.parentChange(val); | ||
} | ||
}, { | ||
key: "parentChange", | ||
value: function parentChange(val) { | ||
var newVal = ''; | ||
newVal = val.toString().replace(/,/g, ' '); | ||
@@ -107,2 +145,13 @@ newVal = newVal.replace(/!/g, ','); | ||
}, { | ||
key: "getVal", | ||
value: function getVal() { | ||
var val = cronstrue.toString(this.state.value.toString().replace(/,/g, ' ').replace(/!/g, ',')); | ||
if (val.search('undefined') === -1) { | ||
return val; | ||
} | ||
return '-'; | ||
} | ||
}, { | ||
key: "getComponent", | ||
@@ -158,8 +207,2 @@ value: function getComponent(tab) { | ||
}, { | ||
key: "getVal", | ||
value: function getVal() { | ||
var val = cronstrue.toString(this.state.value.toString().replace(/,/g, ' ').replace(/!/g, ',')); | ||
return val; | ||
} | ||
}, { | ||
key: "render", | ||
@@ -166,0 +209,0 @@ value: function render() { |
@@ -26,5 +26,11 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
value: function onChange(e) { | ||
if (e.target.value < 60) { | ||
if (e.target.value > 0 && e.target.value < 60 || e.target.value == '') { | ||
var val = ['0', '*', '*', '*', '*', '?', '*']; | ||
val[1] = "0/".concat(e.target.value); | ||
if (e.target.value == '') { | ||
val[1] = ''; | ||
} else { | ||
val[1] = "0/".concat(e.target.value); | ||
} | ||
this.props.onChange(val); | ||
@@ -31,0 +37,0 @@ } |
@@ -50,3 +50,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
value: function onDayChange(e) { | ||
if (parseInt(e.target.value) <= 31 || e.target.value == "") { | ||
if (parseInt(e.target.value) > 0 && parseInt(e.target.value) <= 31 || e.target.value == "") { | ||
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', '?', '*']; | ||
@@ -60,5 +60,11 @@ val[3] = "".concat(e.target.value); | ||
value: function onLastDayChange(e) { | ||
if (parseInt(e.target.value) <= 31 || e.target.value == "") { | ||
if (parseInt(e.target.value) >> 0 && parseInt(e.target.value) <= 31 || e.target.value == "") { | ||
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', '?', '*']; | ||
val[3] = "L-".concat(e.target.value); | ||
if (e.target.value == '') { | ||
val[3] = ''; | ||
} else { | ||
val[3] = "L-".concat(e.target.value); | ||
} | ||
this.props.onChange(val); | ||
@@ -88,5 +94,5 @@ } | ||
return React.createElement("div", { | ||
className: "tab-pane" | ||
class: "tab-pane" | ||
}, React.createElement("div", { | ||
className: "well well-small" | ||
class: "well well-small" | ||
}, React.createElement("input", { | ||
@@ -105,2 +111,3 @@ type: "radio", | ||
}), "\xA0Day\xA0", React.createElement("input", { | ||
readOnly: this.state.every !== "1", | ||
type: "number", | ||
@@ -110,3 +117,3 @@ value: this.state.value[3], | ||
}), "\xA0of every month(s)"), React.createElement("div", { | ||
className: "well well-small" | ||
class: "well well-small" | ||
}, React.createElement("input", { | ||
@@ -125,3 +132,3 @@ onChange: function onChange(e) { | ||
}), "\xA0 Last day of every month \xA0"), React.createElement("div", { | ||
className: "well well-small" | ||
class: "well well-small" | ||
}, React.createElement("input", { | ||
@@ -140,3 +147,3 @@ onChange: function onChange(e) { | ||
}), "\xA0 On the last weekday of every month \xA0"), React.createElement("div", { | ||
className: "well well-small" | ||
class: "well well-small" | ||
}, React.createElement("input", { | ||
@@ -149,3 +156,3 @@ type: "radio", | ||
_this2.props.onChange(['0', _this2.state.value[1] === '*' ? '0' : _this2.state.value[1], _this2.state.value[2] === '*' ? '0' : _this2.state.value[2], "L-".concat(0), '*', '?', '*']); | ||
_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), '*', '?', '*']); | ||
}, | ||
@@ -156,2 +163,3 @@ value: "4", | ||
}), React.createElement("input", { | ||
readOnly: this.state.every !== "4", | ||
type: "number", | ||
@@ -161,3 +169,3 @@ value: this.state.value[3].split('-')[1], | ||
}), "\xA0day(s) before the end of the month"), "\xA0 Start time \xA0", React.createElement("select", { | ||
className: "hours", | ||
class: "hours", | ||
onChange: this.onAtHourChange, | ||
@@ -215,3 +223,3 @@ value: this.state.value[2] | ||
value: "DailyMinutes", | ||
className: "minutes", | ||
class: "minutes", | ||
onChange: this.onAtMinuteChange | ||
@@ -218,0 +226,0 @@ }, "value", this.state.value[1]), React.createElement("option", { |
@@ -80,5 +80,5 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
}, React.createElement("div", { | ||
className: "well well-small row" | ||
class: "well well-small row" | ||
}, React.createElement("div", { | ||
className: "span6 col-sm-6" | ||
class: "span6 col-sm-6" | ||
}, React.createElement("div", { | ||
@@ -107,3 +107,3 @@ className: "text_align_left" | ||
}), "\xA0Sunday")), React.createElement("div", { | ||
className: "span6 col-sm-6" | ||
class: "span6 col-sm-6" | ||
}, React.createElement("div", { | ||
@@ -127,3 +127,3 @@ className: "text_align_left" | ||
}), "\xA0Saturday"), React.createElement("br", null), React.createElement("br", null))), "\xA0 Start time \xA0", React.createElement("select", { | ||
className: "hours", | ||
class: "hours", | ||
onChange: this.onAtHourChange, | ||
@@ -181,3 +181,3 @@ value: this.state.value[2] | ||
value: "DailyMinutes", | ||
className: "minutes", | ||
class: "minutes", | ||
onChange: this.onAtMinuteChange | ||
@@ -184,0 +184,0 @@ }, "value", this.state.value[1]), React.createElement("option", { |
{ | ||
"name": "react-cron-generator", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"keywords": [ | ||
@@ -9,3 +9,5 @@ "React cron generator", | ||
"cron", | ||
"React cron" | ||
"React cron", | ||
"cron builder", | ||
"cron ui" | ||
], | ||
@@ -12,0 +14,0 @@ "author": "Sojin antony", |
Sorry, the diff of this file is not supported yet
49666
1356