Add support for cron expressions for scheduling timer functions
This commit is contained in:
@@ -38,7 +38,9 @@ history_url=url_for('timer.history', function_id=function_id)) }}
|
||||
showDeleteButton: true,
|
||||
isTimer: true,
|
||||
showTimerSettings: true,
|
||||
frequencyMinutes: {{ timer_function.frequency_minutes }},
|
||||
triggerType: '{{ timer_function.trigger_type }}',
|
||||
frequencyMinutes: {{ timer_function.frequency_minutes or "null" }},
|
||||
cronExpression: '{{ timer_function.cron_expression or "" }}',
|
||||
cancelUrl: "{{ url_for('timer.overview') }}",
|
||||
generateUrl: "{{ url_for('llm.generate_script') }}",
|
||||
showPublicToggle: false,
|
||||
|
||||
@@ -36,6 +36,7 @@ title='New Timer Function')
|
||||
showTimerSettings: true,
|
||||
triggerType: 'interval',
|
||||
frequencyMinutes: 60,
|
||||
cronExpression: '',
|
||||
runtime: 'node',
|
||||
showPublicToggle: false,
|
||||
showLogRequestToggle: false,
|
||||
|
||||
@@ -58,27 +58,39 @@
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
{% if function.trigger_type == 'interval' %}
|
||||
<span class="inline-flex items-center text-gray-700 dark:text-gray-300">
|
||||
<svg class="w-4 h-4 mr-1.5 text-gray-500 dark:text-gray-400"
|
||||
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99" />
|
||||
</svg>
|
||||
Every {{ function.frequency_minutes }} minutes
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="inline-flex items-center text-gray-700 dark:text-gray-300">
|
||||
<svg class="w-4 h-4 mr-1.5 text-gray-500 dark:text-gray-400"
|
||||
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5" />
|
||||
</svg>
|
||||
{{ function.run_date.strftime('%Y-%m-%d %H:%M') }}
|
||||
</span>
|
||||
{% endif %}
|
||||
<div class="flex flex-col gap-1">
|
||||
{% if function.trigger_type == 'cron' %}
|
||||
<span
|
||||
class="inline-flex items-center text-xs font-medium text-orange-800 dark:text-orange-300">
|
||||
<span
|
||||
class="bg-orange-100 dark:bg-orange-900/30 px-2 py-0.5 rounded-full uppercase mr-2">
|
||||
Cron
|
||||
</span>
|
||||
</span>
|
||||
<code
|
||||
class="text-xs font-mono bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded">{{ function.cron_expression }}</code>
|
||||
{% elif function.trigger_type == 'interval' %}
|
||||
<span
|
||||
class="inline-flex items-center text-xs font-medium text-blue-800 dark:text-blue-300">
|
||||
<span
|
||||
class="bg-blue-100 dark:bg-blue-900/30 px-2 py-0.5 rounded-full uppercase mr-2">
|
||||
Interval
|
||||
</span>
|
||||
</span>
|
||||
<span class="text-sm text-gray-700 dark:text-gray-300">Every {{
|
||||
function.frequency_minutes }} minutes</span>
|
||||
{% else %}
|
||||
<span
|
||||
class="inline-flex items-center text-xs font-medium text-purple-800 dark:text-purple-300">
|
||||
<span
|
||||
class="bg-purple-100 dark:bg-purple-900/30 px-2 py-0.5 rounded-full uppercase mr-2">
|
||||
One-Time
|
||||
</span>
|
||||
</span>
|
||||
<span class="text-sm text-gray-700 dark:text-gray-300">{{
|
||||
function.run_date.strftime('%Y-%m-%d %H:%M') }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
{% if function.next_run %}
|
||||
|
||||
Reference in New Issue
Block a user