enhanced scheduler fixes

Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
Andy Miller
2025-08-25 14:05:19 +01:00
parent 04c761142d
commit 25f17ad9b1
2 changed files with 155 additions and 15 deletions

View File

@@ -1,3 +1,4 @@
<script src="{{ url('plugin://admin/themes/grav/js/clipboard-helper.js') }}"></script>
<div class="scheduler-content">
{% set data = admin.data('config/scheduler') %}
@@ -10,27 +11,21 @@
{# We have at least one active trigger method #}
{% if 'webhook' in active_triggers and 'cron' not in active_triggers %}
{# Webhook only mode #}
<div class="alert notice" style="display:flex;justify-content:space-between;">
<div>
<i class="fa fa-plug"></i> <strong>Webhook Active</strong> - Scheduler is ready to receive webhook triggers
</div>
<div class="alert notice secondary-accent">
<div id="show-instructions" class="button button-small button-outline float-right"><i class="fa fa-clock-o"></i> {{ "PLUGIN_ADMIN.SCHEDULER_INSTALL_INSTRUCTIONS"|t }}</div>
<i class="fa fa-plug"></i> <strong>Webhook Active</strong> - Scheduler is ready to receive webhook triggers
</div>
{% elseif 'cron' in active_triggers and 'webhook' in active_triggers %}
{# Both cron and webhook #}
<div class="alert notice secondary-accent" style="display:flex;justify-content:space-between;">
<div>
<i class="fa fa-check"></i> <strong>Cron & Webhook Active</strong> - Scheduler is running via cron and accepts webhook triggers
</div>
<div class="alert notice secondary-accent">
<div id="show-instructions" class="button button-small button-outline float-right"><i class="fa fa-clock-o"></i> {{ "PLUGIN_ADMIN.SCHEDULER_INSTALL_INSTRUCTIONS"|t }}</div>
<i class="fa fa-check"></i> <strong>Cron & Webhook Active</strong> - Scheduler is running via cron and accepts webhook triggers
</div>
{% elseif 'cron' in active_triggers %}
{# Cron only #}
<div class="alert notice secondary-accent" style="display:flex;justify-content:space-between;">
<div>
<i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SCHEDULER_INSTALLED_READY"|t }}
</div>
<div class="alert notice secondary-accent">
<div id="show-instructions" class="button button-small button-outline float-right"><i class="fa fa-clock-o"></i> {{ "PLUGIN_ADMIN.SCHEDULER_INSTALL_INSTRUCTIONS"|t }}</div>
<i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SCHEDULER_INSTALLED_READY"|t }}
</div>
{% endif %}
{% elseif cron_status == 2 %}
@@ -45,15 +40,31 @@
{% if webhook_enabled %}
<h3>Webhook Setup</h3>
<p>The scheduler is configured to use webhooks. To trigger jobs via webhook:</p>
<pre><code>curl -X POST {{ grav.base_url_absolute }}/scheduler/webhook \
-H "Authorization: Bearer YOUR_TOKEN"</code></pre>
{% set webhook_token = config.get('scheduler.modern.webhook.token') %}
{% if not webhook_token %}
{% set webhook_token = 'YOUR_TOKEN' %}
{% endif %}
<div class="form-input-wrapper form-input-addon-wrapper" style="margin: 1rem 0;">
<textarea id="webhook-setup-cmd" readonly rows="2" style="font-family: monospace; background: #f8f9fa; border: 1px solid #dee2e6; padding: 0.375rem 0.75rem; resize: none; white-space: pre; border-radius: 4px 0 0 4px;">curl -X POST "{{ grav.base_url_absolute }}/scheduler/webhook" \
-H "Authorization: Bearer {{ webhook_token }}"</textarea>
<div class="form-input-addon form-input-append" style="cursor: pointer; background: #e9ecef; border: 1px solid #dee2e6; border-left: 0; padding: 0.375rem 0.75rem; display: inline-flex; align-items: center; border-radius: 0 4px 4px 0;" onclick="GravClipboard.copy(this)">
<i class="fa fa-copy" style="margin-right: 0.25rem;"></i> Copy
</div>
</div>
<p>Make sure the <strong>scheduler-webhook</strong> plugin is installed and enabled.</p>
<hr>
<h3>Alternative: Cron Setup</h3>
{% endif %}
<pre><code>{{- grav.scheduler.getCronCommand()|trim -}}</code></pre>
<div class="form-input-wrapper form-input-addon-wrapper" style="margin: 1rem 0;">
<input type="text" id="cron-setup-cmd" readonly value="{{ grav.scheduler.getCronCommand()|trim }}" style="font-family: monospace; background: #f8f9fa; border: 1px solid #dee2e6; padding: 0.375rem 0.75rem; border-radius: 4px 0 0 4px;">
<div class="form-input-addon form-input-append" style="cursor: pointer; background: #e9ecef; border: 1px solid #dee2e6; border-left: 0; padding: 0.375rem 0.75rem; display: inline-flex; align-items: center; border-radius: 0 4px 4px 0;" onclick="GravClipboard.copy(this)">
<i class="fa fa-copy" style="margin-right: 0.25rem;"></i> Copy
</div>
</div>
<p>{{ "PLUGIN_ADMIN.SCHEDULER_POST_INSTRUCTIONS"|t([user])|raw }}</p>
</div>