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

@@ -14,6 +14,7 @@ interface ScheduledJob {
name: string;
type: 'process' | 'command';
interval: 'short' | 'long' | 'fixed';
cronSchedule: string;
running?: () => boolean;
cancelFn?: () => void;
}
@@ -29,6 +30,7 @@ export const startJobs = (): void => {
name: 'Plex Recently Added Scan',
type: 'process',
interval: 'short',
cronSchedule: jobs['plex-recently-added-scan'].schedule,
job: schedule.scheduleJob(jobs['plex-recently-added-scan'].schedule, () => {
logger.info('Starting scheduled job: Plex Recently Added Scan', {
label: 'Jobs',
@@ -45,6 +47,7 @@ export const startJobs = (): void => {
name: 'Plex Full Library Scan',
type: 'process',
interval: 'long',
cronSchedule: jobs['plex-full-scan'].schedule,
job: schedule.scheduleJob(jobs['plex-full-scan'].schedule, () => {
logger.info('Starting scheduled job: Plex Full Library Scan', {
label: 'Jobs',
@@ -61,6 +64,7 @@ export const startJobs = (): void => {
name: 'Plex Watchlist Sync',
type: 'process',
interval: 'long',
cronSchedule: jobs['plex-watchlist-sync'].schedule,
job: schedule.scheduleJob(jobs['plex-watchlist-sync'].schedule, () => {
logger.info('Starting scheduled job: Plex Watchlist Sync', {
label: 'Jobs',
@@ -75,6 +79,7 @@ export const startJobs = (): void => {
name: 'Radarr Scan',
type: 'process',
interval: 'long',
cronSchedule: jobs['radarr-scan'].schedule,
job: schedule.scheduleJob(jobs['radarr-scan'].schedule, () => {
logger.info('Starting scheduled job: Radarr Scan', { label: 'Jobs' });
radarrScanner.run();
@@ -89,6 +94,7 @@ export const startJobs = (): void => {
name: 'Sonarr Scan',
type: 'process',
interval: 'long',
cronSchedule: jobs['sonarr-scan'].schedule,
job: schedule.scheduleJob(jobs['sonarr-scan'].schedule, () => {
logger.info('Starting scheduled job: Sonarr Scan', { label: 'Jobs' });
sonarrScanner.run();
@@ -103,6 +109,7 @@ export const startJobs = (): void => {
name: 'Download Sync',
type: 'command',
interval: 'fixed',
cronSchedule: jobs['download-sync'].schedule,
job: schedule.scheduleJob(jobs['download-sync'].schedule, () => {
logger.debug('Starting scheduled job: Download Sync', {
label: 'Jobs',
@@ -117,6 +124,7 @@ export const startJobs = (): void => {
name: 'Download Sync Reset',
type: 'command',
interval: 'long',
cronSchedule: jobs['download-sync-reset'].schedule,
job: schedule.scheduleJob(jobs['download-sync-reset'].schedule, () => {
logger.info('Starting scheduled job: Download Sync Reset', {
label: 'Jobs',