Skip to content

Commit

Permalink
cron fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurik72 committed Feb 14, 2020
1 parent 4bc9341 commit 4e65e73
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion WebSource/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class App extends Component {
var debug = false;
if (debug) {
var obj = JSON.parse('[{"service":"RelayController","name":"Relay","enabled":true,"interval":100,"pin":5},{"service":"TimeController","name":"Time","enabled":true,"interval":1000,"timeoffs":7200,"dayloffs":3600,"server":"pool.ntp.org"},{"service":"RGBStripController","name":"RGBStrip","enabled":true,"interval":1,"pin":23,"numleds":8},{"service":"LDRController","name":"LDR","enabled":true,"interval":1000,"pin":0},{"service":"RFController","name":"RF","enabled":true,"interval":2,"pin":27}]');
var obj1 = JSON.parse('[{"type":"TimeToRGBStrip","source":"Time","destination":"Relay","value":[{"isOn":true,"isLdr":true,"time":"* 2 * * *","bg":1,"wxmode":-1}]},{"type":"RFToRelay","source":"RF","destination":"Relay","value":[{"isOn":true,"isswitch":true,"rfkey":13532516}]}]');
var obj1 = JSON.parse('[{"type":"TimeToRGBStrip","source":"Time","destination":"Relay","value":[{"isOn":true,"isLdr":true,"time":"* 2 * * * *","bg":1,"wxmode":-1}]},{"type":"RFToRelay","source":"RF","destination":"Relay","value":[{"isOn":true,"isswitch":true,"rfkey":13532516}]}]');
this.setState({ services: obj });
this.setState({ triggers: obj1 });
}
Expand Down
14 changes: 7 additions & 7 deletions WebSource/src/Components/Cronedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,26 @@ class CronEdit extends Component {

var tmp;
if (parts[1] != this.cron_minutes) {
this.cron_minutes = parts[0];
this.cron_selminutes = this.cronValueItemToList(true, 59, parts[0]);
this.cron_minutes = parts[1];
this.cron_selminutes = this.cronValueItemToList(true, 59, parts[1]);
//cronHelperSelectList(cron_minutes_id, (true, 59, parts[0]));
}
if (parts[2] != this.cron_hours) {
this.cron_hours = parts[1];
this.cron_selhours = this.cronValueItemToList(true, 23, parts[1]);
this.cron_hours = parts[2];
this.cron_selhours = this.cronValueItemToList(true, 23, parts[2]);

//cronHelperSelectList(cron_hours_id, cronValueItemToList(true, 23, parts[1]));
}
if (parts[3] != this.cron_dom) {
this.cron_dom = parts[2];
this.cron_dom = parts[3];
//cronHelperSelectList(cron_dom_id, cronValueItemToList(false, 31, parts[2]));
}
if (parts[4] != this.cron_months) {
this.cron_months = parts[3];
this.cron_months = parts[4];
//cronHelperSelectList(cron_months_id, cronValueItemToList(false, 12, parts[3]));
}
if (parts[5] != this.cron_dow) {
this.cron_dow = parts[4];
this.cron_dow = parts[5];
//cronHelperSelectList(cron_dow_id, cronValueItemToList(true, 6, parts[4]));
}
}
Expand Down
12 changes: 6 additions & 6 deletions WebSource/src/Components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ export function encode_chops(arr) {
}

export function convertCronToString(cronExpression) {
if (!cronExpression.match(/^((\*(\/[1-9][0-9]?)?|([0-9]{1,2}(-[0-9]{1,2})?)(,[0-9]{1,2}(-[0-9]{1,2})?)*)( |$)){6}$/))
if (typeof (cronExpression) != 'string' || !cronExpression.match(/^((\*(\/[1-9][0-9]?)?|([0-9]{1,2}(-[0-9]{1,2})?)(,[0-9]{1,2}(-[0-9]{1,2})?)*)( |$)){6}$/))
return "invalid expression";
var cron = cronExpression.split(" ");
var minutes = cron[0];
var hours = cron[1];
var dayOfMonth = cron[2];
var month = cron[3];
var dayOfWeek = cron[4];
var minutes = cron[1];
var hours = cron[2];
var dayOfMonth = cron[3];
var month = cron[4];
var dayOfWeek = cron[5];

var cronToString = "Runs at ";

Expand Down
10 changes: 5 additions & 5 deletions data/js/bundle.min.js

Large diffs are not rendered by default.

Binary file modified data/js/bundle.min.js.gz
Binary file not shown.

0 comments on commit 4e65e73

Please sign in to comment.