From 6b11de258a8039fe7729130ede35d47592be7cbe Mon Sep 17 00:00:00 2001 From: Corentin Thomasset Date: Mon, 18 Apr 2022 09:18:48 +0200 Subject: [PATCH] refactor(crontab): list instead of table on small screen --- .../crontab-generator/crontab-generator.vue | 198 ++++++++++-------- 1 file changed, 106 insertions(+), 92 deletions(-) diff --git a/src/tools/crontab-generator/crontab-generator.vue b/src/tools/crontab-generator/crontab-generator.vue index 0b1501bd..52dcb6cc 100644 --- a/src/tools/crontab-generator/crontab-generator.vue +++ b/src/tools/crontab-generator/crontab-generator.vue @@ -49,7 +49,26 @@ * * * * * * command - + + +
Symbol: {{ symbol }}
+
Meaning: {{ meaning }}
+
Example: {{ example }}
+
Equivalent: {{ equivalent }}
+
+
+ - - * - Any value + + {{ symbol }} + {{ meaning }} - * * * * + {{ example }} - Every minute - - - - - Range of values - - 1-10 * * * - - Minutes 1 through 10 - - - , - List of values - - 1,10 * * * - - At minutes 1 and 10 - - - / - Step values - - */10 * * * - - Every 10 minutes - - - @yearly - Once every year at midnight of 1 January - - @yearly - - 0 0 1 1 * - - - @annually - Same as @yearly - - @annually - - 0 0 1 1 * - - - @monthly - Once a month at midnight on the first day - - @monthly - - 0 0 1 * * - - - @weekly - Once a week at midnight on Sunday morning - - @weekly - - 0 0 * * 0 - - - @daily - Once a day at midnight - - @daily - - 0 0 * * * - - - @midnight - Same as @daily - - @midnight - - 0 0 * * * - - - @hourly - Once an hour at the beginning of the hour - - @hourly - - 0 * * * * - - - @reboot - Run at startup - - + {{ equivalent }} @@ -183,12 +119,15 @@ import cronstrue from 'cronstrue' import { isValidCron } from 'cron-validator' import { computed, reactive, ref } from 'vue'; import { useValidation } from '@/composable/validation'; +import { useStyleStore } from '@/stores/style.store'; function isCronValid(v: string) { return isValidCron(v, { allowBlankDay: true, alias: true, seconds: true }) } +const styleStore = useStyleStore() + const cron = ref('40 * * * *') const cronstrueConfig = reactive({ verbose: true, @@ -197,6 +136,81 @@ const cronstrueConfig = reactive({ throwExceptionOnParseError: true }) +const helpers = [ + { + "symbol": "*", + "meaning": "Any value", + "example": "* * * *", + "equivalent": "Every minute" + }, + { + "symbol": "-", + "meaning": "Range of values", + "example": "1-10 * * *", + "equivalent": "Minutes 1 through 10" + }, + { + "symbol": ",", + "meaning": "List of values", + "example": "1,10 * * *", + "equivalent": "At minutes 1 and 10" + }, + { + "symbol": "/", + "meaning": "Step values", + "example": "*/10 * * *", + "equivalent": "Every 10 minutes" + }, + { + "symbol": "@yearly", + "meaning": "Once every year at midnight of 1 January", + "example": "@yearly", + "equivalent": "0 0 1 1 *" + }, + { + "symbol": "@annually", + "meaning": "Same as @yearly", + "example": "@annually", + "equivalent": "0 0 1 1 *" + }, + { + "symbol": "@monthly", + "meaning": "Once a month at midnight on the first day", + "example": "@monthly", + "equivalent": "0 0 1 * *" + }, + { + "symbol": "@weekly", + "meaning": "Once a week at midnight on Sunday morning", + "example": "@weekly", + "equivalent": "0 0 * * 0" + }, + { + "symbol": "@daily", + "meaning": "Once a day at midnight", + "example": "@daily", + "equivalent": "0 0 * * *" + }, + { + "symbol": "@midnight", + "meaning": "Same as @daily", + "example": "@midnight", + "equivalent": "0 0 * * *" + }, + { + "symbol": "@hourly", + "meaning": "Once an hour at the beginning of the hour", + "example": "@hourly", + "equivalent": "0 * * * *" + }, + { + "symbol": "@reboot", + "meaning": "Run at startup", + "example": "", + "equivalent": "" + } +] + const cronString = computed(() => { if (isCronValid(cron.value)) { return cronstrue.toString(cron.value, cronstrueConfig)