Files
windmill/frontend/src/lib/components/flows/scheduleUtils.ts
T
Oliver VealandRuben Fiszel 0b444ce395 feat: improved cron/schedule editor (#1362)
* basic cron schedule editing ui

* schedules run in a user-specified timezone

* fix other uses of CronInput component

* use now() from database to schedule next job

* offset -> IANA timezone conversion on db migration

* sqlx ci

---------

Co-authored-by: Ruben Fiszel <ruben@rubenfiszel.com>
2023-04-05 16:37:24 +02:00

33 lines
693 B
TypeScript

import { ScheduleService } from '$lib/gen'
export type Schedule = {
args: Record<string, any>
cron: string
timezone: string
enabled: boolean
}
// Load the schedule of a flow given its path and the workspace
export async function loadFlowSchedule(path: string, workspace: string = ''): Promise<Schedule> {
const existsSchedule = await ScheduleService.existsSchedule({
workspace,
path
})
if (!existsSchedule) {
throw new Error(`Flow at path: ${path} doesn't exist`)
}
const schedule = await ScheduleService.getSchedule({
workspace,
path
})
return {
enabled: schedule.enabled,
cron: schedule.schedule,
timezone: schedule.timezone,
args: schedule.args ?? {}
}
}