mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-04 05:19:12 -04:00
Merge 6248546e4b
into b47d132839
This commit is contained in:
commit
7c7e933da4
3 changed files with 47 additions and 0 deletions
|
@ -56,6 +56,7 @@
|
||||||
"colord": "^2.9.3",
|
"colord": "^2.9.3",
|
||||||
"composerize-ts": "^0.6.2",
|
"composerize-ts": "^0.6.2",
|
||||||
"country-code-lookup": "^0.1.0",
|
"country-code-lookup": "^0.1.0",
|
||||||
|
"cron-parser": "^4.9.0",
|
||||||
"cron-validator": "^1.3.1",
|
"cron-validator": "^1.3.1",
|
||||||
"cronstrue": "^2.26.0",
|
"cronstrue": "^2.26.0",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
|
|
15
pnpm-lock.yaml
generated
15
pnpm-lock.yaml
generated
|
@ -65,6 +65,9 @@ dependencies:
|
||||||
country-code-lookup:
|
country-code-lookup:
|
||||||
specifier: ^0.1.0
|
specifier: ^0.1.0
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
|
cron-parser:
|
||||||
|
specifier: ^4.9.0
|
||||||
|
version: 4.9.0
|
||||||
cron-validator:
|
cron-validator:
|
||||||
specifier: ^1.3.1
|
specifier: ^1.3.1
|
||||||
version: 1.3.1
|
version: 1.3.1
|
||||||
|
@ -4682,6 +4685,13 @@ packages:
|
||||||
resolution: {integrity: sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==}
|
resolution: {integrity: sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/cron-parser@4.9.0:
|
||||||
|
resolution: {integrity: sha512-p0SaNjrHOnQeR8/VnfGbmg9te2kfyYSQ7Sc/j/6DtPL3JQvKxmjO9TSjNFpujqV3vEYYBvNNvXSxzyksBWAx1Q==}
|
||||||
|
engines: {node: '>=12.0.0'}
|
||||||
|
dependencies:
|
||||||
|
luxon: 3.5.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
/cron-validator@1.3.1:
|
/cron-validator@1.3.1:
|
||||||
resolution: {integrity: sha512-C1HsxuPCY/5opR55G5/WNzyEGDWFVG+6GLrA+fW/sCTcP6A6NTjUP2AK7B8n2PyFs90kDG2qzwm8LMheADku6A==}
|
resolution: {integrity: sha512-C1HsxuPCY/5opR55G5/WNzyEGDWFVG+6GLrA+fW/sCTcP6A6NTjUP2AK7B8n2PyFs90kDG2qzwm8LMheADku6A==}
|
||||||
dev: false
|
dev: false
|
||||||
|
@ -6834,6 +6844,11 @@ packages:
|
||||||
dependencies:
|
dependencies:
|
||||||
yallist: 4.0.0
|
yallist: 4.0.0
|
||||||
|
|
||||||
|
/luxon@3.5.0:
|
||||||
|
resolution: {integrity: sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/magic-string@0.25.9:
|
/magic-string@0.25.9:
|
||||||
resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==}
|
resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import cronstrue from 'cronstrue';
|
import cronstrue from 'cronstrue';
|
||||||
import { isValidCron } from 'cron-validator';
|
import { isValidCron } from 'cron-validator';
|
||||||
|
import { parseExpression } from 'cron-parser';
|
||||||
import { useStyleStore } from '@/stores/style.store';
|
import { useStyleStore } from '@/stores/style.store';
|
||||||
|
|
||||||
function isCronValid(v: string) {
|
function isCronValid(v: string) {
|
||||||
|
@ -92,6 +93,15 @@ const helpers = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function getLastExecutionTimes(cronExpression: string) {
|
||||||
|
const interval = parseExpression(cronExpression);
|
||||||
|
const times = [];
|
||||||
|
for (let i = 0; i < 5; i++) {
|
||||||
|
times.push(interval.next().toJSON());
|
||||||
|
}
|
||||||
|
return times;
|
||||||
|
}
|
||||||
|
|
||||||
const cronString = computed(() => {
|
const cronString = computed(() => {
|
||||||
if (isCronValid(cron.value)) {
|
if (isCronValid(cron.value)) {
|
||||||
return cronstrue.toString(cron.value, cronstrueConfig);
|
return cronstrue.toString(cron.value, cronstrueConfig);
|
||||||
|
@ -99,6 +109,15 @@ const cronString = computed(() => {
|
||||||
return ' ';
|
return ' ';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const executionTimesString = computed(() => {
|
||||||
|
if (isCronValid(cron.value)) {
|
||||||
|
const lastExecutionTimes = getLastExecutionTimes(cron.value);
|
||||||
|
const executionTimesString = lastExecutionTimes.join('\n');
|
||||||
|
return `Next 5 execution times:\n${executionTimesString}`;
|
||||||
|
}
|
||||||
|
return ' ';
|
||||||
|
});
|
||||||
|
|
||||||
const cronValidationRules = [
|
const cronValidationRules = [
|
||||||
{
|
{
|
||||||
validator: (value: string) => isCronValid(value),
|
validator: (value: string) => isCronValid(value),
|
||||||
|
@ -123,6 +142,10 @@ const cronValidationRules = [
|
||||||
{{ cronString }}
|
{{ cronString }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="cron-execution-string">
|
||||||
|
{{ executionTimesString }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<n-divider />
|
<n-divider />
|
||||||
|
|
||||||
<div flex justify-center>
|
<div flex justify-center>
|
||||||
|
@ -187,6 +210,14 @@ const cronValidationRules = [
|
||||||
margin: 5px 0 15px;
|
margin: 5px 0 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cron-execution-string{
|
||||||
|
text-align: center;
|
||||||
|
font-size: 14px;
|
||||||
|
opacity: 0.8;
|
||||||
|
margin: 5px 0 15px;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue