From af4616ccf28fa13fdd05840d9e733ab01c43c42f Mon Sep 17 00:00:00 2001 From: Jelco <53396500+Jelcoo@users.noreply.github.com> Date: Mon, 28 Mar 2022 21:43:45 +0200 Subject: [PATCH] Add cron cheatsheet (#3866) --- .../server/schedules/EditScheduleModal.tsx | 19 ++++++- .../schedules/ScheduleCheatsheetCards.tsx | 55 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 resources/scripts/components/server/schedules/ScheduleCheatsheetCards.tsx diff --git a/resources/scripts/components/server/schedules/EditScheduleModal.tsx b/resources/scripts/components/server/schedules/EditScheduleModal.tsx index 57602f2ed..d61ef6361 100644 --- a/resources/scripts/components/server/schedules/EditScheduleModal.tsx +++ b/resources/scripts/components/server/schedules/EditScheduleModal.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useEffect } from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import { Schedule } from '@/api/server/schedules/getServerSchedules'; import Field from '@/components/elements/Field'; import { Form, Formik, FormikHelpers } from 'formik'; @@ -12,6 +12,8 @@ import tw from 'twin.macro'; import Button from '@/components/elements/Button'; import ModalContext from '@/context/ModalContext'; import asModal from '@/hoc/asModal'; +import Switch from '@/components/elements/Switch'; +import ScheduleCheatsheetCards from '@/components/server/schedules/ScheduleCheatsheetCards'; interface Props { schedule?: Schedule; @@ -34,6 +36,7 @@ const EditScheduleModal = ({ schedule }: Props) => { const uuid = ServerContext.useStoreState(state => state.server.data!.uuid); const appendSchedule = ServerContext.useStoreActions(actions => actions.schedules.appendSchedule); + const [ showCheatsheet, setShowCheetsheet ] = useState(false); useEffect(() => { return () => { @@ -103,6 +106,20 @@ const EditScheduleModal = ({ schedule }: Props) => { The schedule system supports the use of Cronjob syntax when defining when tasks should begin running. Use the fields above to specify when these tasks should begin running.

+
+ setShowCheetsheet(s => !s)} + /> + {showCheatsheet && +
+ +
+ } +
{ + return ( + <> +
+
+

Examples

+
+
*/5 * * * *
+
every 5 minutes
+
+
+
0 */1 * * *
+
every hour
+
+
+
0 8-12 * * *
+
hour range
+
+
+
0 0 * * *
+
once a day
+
+
+
0 0 * * MON
+
every Monday
+
+
+
+
+

Special Characters

+
+
+
*
+
any value
+
+
+
,
+
value list separator
+
+
+
-
+
range values
+
+
+
/
+
step values
+
+
+
+ + ); +};