feat(jobs): show current job frequency in edit modal (#3008)

* fix(jobs): reset job schedule edit modal values when closed

* feat(jobs): show job's current frequency

* fix(jobs): reset job schedule edit modal values when cancelled

* chore: rebase

* refactor(jobs): use reducer instead of several react states

* fix(jobs): reset modal state when opening instead of closing the modal

This prevents the modal state from glitching when saving/closing the modal

* feat(jobs): parse job schedule cron string

unavailable locale will fallback to english
This commit is contained in:
Danshil Kokil Mungur
2022-09-12 05:14:27 +04:00
committed by GitHub
parent 611ceeb5f4
commit 99fc9a2da0
6 changed files with 114 additions and 27 deletions

View File

@@ -433,6 +433,7 @@ settingsRoutes.get('/jobs', (_req, res) => {
name: job.name,
type: job.type,
interval: job.interval,
cronSchedule: job.cronSchedule,
nextExecutionTime: job.job.nextInvocation(),
running: job.running ? job.running() : false,
}))
@@ -453,6 +454,7 @@ settingsRoutes.post<{ jobId: string }>('/jobs/:jobId/run', (req, res, next) => {
name: scheduledJob.name,
type: scheduledJob.type,
interval: scheduledJob.interval,
cronSchedule: scheduledJob.cronSchedule,
nextExecutionTime: scheduledJob.job.nextInvocation(),
running: scheduledJob.running ? scheduledJob.running() : false,
});
@@ -478,6 +480,7 @@ settingsRoutes.post<{ jobId: string }>(
name: scheduledJob.name,
type: scheduledJob.type,
interval: scheduledJob.interval,
cronSchedule: scheduledJob.cronSchedule,
nextExecutionTime: scheduledJob.job.nextInvocation(),
running: scheduledJob.running ? scheduledJob.running() : false,
});
@@ -502,11 +505,14 @@ settingsRoutes.post<{ jobId: string }>(
settings.jobs[scheduledJob.id].schedule = req.body.schedule;
settings.save();
scheduledJob.cronSchedule = req.body.schedule;
return res.status(200).json({
id: scheduledJob.id,
name: scheduledJob.name,
type: scheduledJob.type,
interval: scheduledJob.interval,
cronSchedule: scheduledJob.cronSchedule,
nextExecutionTime: scheduledJob.job.nextInvocation(),
running: scheduledJob.running ? scheduledJob.running() : false,
});