first pass at a daily scheduler
This commit is contained in:
parent
fcc3166a75
commit
0c35cacdde
2 changed files with 55 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import trigger_reactive from './custom/trigger_reactive.js'
|
|||
import trigger_timer from './custom/trigger_timer.js'
|
||||
import trigger_schedule from './custom/trigger_schedule.js'
|
||||
import schedule_hourly from './custom/schedule_hourly.js'
|
||||
import schedule_daily from './custom/schedule_daily.js'
|
||||
import selector_comparison from './custom/selector_comparison.js'
|
||||
import action_publish_to_feed from './custom/action_publish_to_feed.js'
|
||||
import action_send_email from './custom/action_send_email.js'
|
||||
|
|
@ -44,6 +45,7 @@ export default {
|
|||
|
||||
// Schedules
|
||||
schedule_hourly,
|
||||
schedule_daily,
|
||||
|
||||
// Values
|
||||
math_number,
|
||||
|
|
|
|||
53
src/blocks/custom/schedule_daily.js
Normal file
53
src/blocks/custom/schedule_daily.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { map, range } from 'lodash-es'
|
||||
|
||||
|
||||
export default {
|
||||
type: "schedule_daily",
|
||||
|
||||
toolbox: {
|
||||
category: 'Schedules',
|
||||
},
|
||||
|
||||
visualization: {
|
||||
colour: 232,
|
||||
},
|
||||
|
||||
connections: {
|
||||
mode: "value",
|
||||
output: "schedule"
|
||||
},
|
||||
|
||||
lines: [
|
||||
[ "Daily", "LEFT" ],
|
||||
|
||||
[ "...at hour:", {
|
||||
field: "AT_HOUR",
|
||||
options: map(range(1, 13), hour => ([ hour.toString(), (hour%12).toString() ]))
|
||||
}],
|
||||
|
||||
[ "...at minute:", {
|
||||
field: "AT_MINUTE",
|
||||
options: map(map(range(60), String), idx => ([ idx, idx ]))
|
||||
}],
|
||||
|
||||
[ "", {
|
||||
field: "AM_PM",
|
||||
options: [
|
||||
["AM", "am"],
|
||||
["PM", "pm"],
|
||||
]
|
||||
}]
|
||||
],
|
||||
|
||||
generators: {
|
||||
json: block => {
|
||||
const
|
||||
isPm = block.getFieldValue('AM_PM') === "pm",
|
||||
atHour = parseInt(block.getFieldValue('AT_HOUR'), 10) + (isPm ? 12 : 0),
|
||||
atMinute = parseInt(block.getFieldValue('AT_MINUTE'), 10),
|
||||
crontab = `${atMinute} ${atHour} * * *`
|
||||
|
||||
return [ crontab , 0 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue