Skip to content

Commit

Permalink
feat(Node): add the Scheduler Node (#4223)
Browse files Browse the repository at this point in the history
* ✨ Create Schedule node with MVP structure

* ✨ Add 24 increments for hours picker

* 🚨  Lintfix

* Add timestamp, add hour minute and cron expression

* Fix bug where there was one extra interval object

* Fix default value from fixedCollection

* 🐛 UI fixes

* 🎨 Changed logic to reflect UI fixes

* Fix auto intitialising

* Deprecated interval and cron in favor of schedule node

* 🐛 Ui fixes

* 🐛 Fix issue with week intervals

* 🚨 Lint fixes

* change order of days in the week to chronological order
  • Loading branch information
agobrech committed Oct 18, 2022
1 parent 1aa21ed commit 128c3b8
Show file tree
Hide file tree
Showing 8 changed files with 555 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Cron/Cron.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
}
]
},
"alias": ["Time", "Scheduler", "Polling"],
"alias": ["Time", "Scheduler", "Polling", "Cron", "Interval"],
"subcategories": {
"Core Nodes": ["Flow"]
}
Expand Down
5 changes: 4 additions & 1 deletion packages/nodes-base/nodes/Cron/Cron.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class Cron implements INodeType {
icon: 'fa:calendar',
group: ['trigger', 'schedule'],
version: 1,
hidden: true,
description: 'Triggers the workflow at a specific time',
eventTriggerDescription: '',
activationMessage:
Expand Down Expand Up @@ -69,7 +70,9 @@ export class Cron implements INodeType {
const timezone = this.getTimezone();

// Start the cron-jobs
const cronJobs = cronTimes.map(cronTime => new CronJob(cronTime, executeTrigger, undefined, true, timezone));
const cronJobs = cronTimes.map(
(cronTime) => new CronJob(cronTime, executeTrigger, undefined, true, timezone),
);

// Stop the cron-jobs
async function closeFunction() {
Expand Down
1 change: 1 addition & 0 deletions packages/nodes-base/nodes/Interval/Interval.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class Interval implements INodeType {
icon: 'fa:hourglass',
group: ['trigger', 'schedule'],
version: 1,
hidden: true,
description: 'Triggers the workflow in a given interval',
eventTriggerDescription: '',
activationMessage:
Expand Down
9 changes: 9 additions & 0 deletions packages/nodes-base/nodes/Schedule/CronInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { IDataObject } from 'n8n-workflow';

export type ICronExpression = [
string | Date,
string | Date,
string | Date,
string | Date,
string | Date,
];
18 changes: 18 additions & 0 deletions packages/nodes-base/nodes/Schedule/ScheduleTrigger.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"node": "n8n-nodes-base.scheduleTrigger",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Core Nodes"],
"resources": {
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/nodes/n8n-nodes-base.scheduleTrigger/"
}
],
"generic": []
},
"alias": ["Time", "Scheduler", "Polling", "Cron", "Interval"],
"subcategories": {
"Core Nodes": ["Flow"]
}
}

0 comments on commit 128c3b8

Please sign in to comment.