- Create new home route with comprehensive dashboard statistics - Implement Mithril rendering support with new `mithril_loader.html` template - Add new routes for home and test pages in `app.py` - Create `lib/mithril.py` with Mithril rendering and error handling utilities - Update dashboard template to use new home route - Add detailed dashboard view with timer and HTTP function statistics
150 lines
9.7 KiB
HTML
150 lines
9.7 KiB
HTML
{% extends 'dashboard.html' %}
|
|
|
|
{% block page %}
|
|
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
<div class="flex items-center justify-between mb-8" data-id="51">
|
|
<h1 class="text-2xl font-bold text-gray-900">Timer Functions</h1>
|
|
<button
|
|
class="inline-flex items-center px-4 py-2 bg-green-600 hover:bg-green-700 text-white font-medium rounded-lg transition-colors duration-200"
|
|
hx-get="{{ url_for('timer.new') }}" hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
|
stroke="currentColor" class="w-5 h-5 mr-2">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"></path>
|
|
</svg>
|
|
Add Function
|
|
</button>
|
|
</div>
|
|
|
|
<div class="bg-white border border-gray-200 rounded-lg shadow-sm overflow-hidden min-h-[200px]">
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full">
|
|
<thead>
|
|
<tr class="bg-gray-50 border-b border-gray-200">
|
|
<th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">Name</th>
|
|
<th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">Schedule</th>
|
|
<th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">Next Run</th>
|
|
<th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">Status</th>
|
|
<th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-200">
|
|
{% for function in timer_functions %}
|
|
<tr class="hover:bg-gray-50">
|
|
<td class="px-6 py-4">
|
|
<div class="flex items-center gap-2 cursor-pointer"
|
|
hx-get="{{ url_for('timer.edit', function_id=function.id) }}" hx-target="#container"
|
|
hx-swap="innerHTML" hx-push-url="true">
|
|
<span class="font-medium text-gray-900">{{ function.name }}</span>
|
|
<span
|
|
class="bg-green-100 text-green-800 text-xs font-medium px-2.5 py-0.5 rounded-full">
|
|
{{ function.invocation_count }}
|
|
</span>
|
|
{% if function.last_run %}
|
|
<span class="bg-blue-100 text-blue-800 text-xs font-medium px-2.5 py-0.5 rounded-full">
|
|
Last run: {{ function.last_run.strftime('%Y-%m-%d %H:%M') }}
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
{% if function.trigger_type == 'interval' %}
|
|
<span class="inline-flex items-center">
|
|
<svg class="w-4 h-4 mr-1.5 text-gray-500" 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">
|
|
<svg class="w-4 h-4 mr-1.5 text-gray-500" 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 %}
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
{% if function.next_run %}
|
|
<span class="text-gray-900">{{ function.next_run.strftime('%Y-%m-%d %H:%M') }}</span>
|
|
{% else %}
|
|
<span class="text-gray-500">-</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
{% if function.enabled %}
|
|
<span
|
|
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
|
|
<svg class="w-2 h-2 mr-1.5 fill-current" viewBox="0 0 8 8">
|
|
<circle cx="4" cy="4" r="3" />
|
|
</svg>
|
|
Active
|
|
</span>
|
|
{% else %}
|
|
<span
|
|
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
|
|
<svg class="w-2 h-2 mr-1.5 fill-current" viewBox="0 0 8 8">
|
|
<circle cx="4" cy="4" r="3" />
|
|
</svg>
|
|
Paused
|
|
</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<div class="flex gap-2">
|
|
<button
|
|
class="inline-flex items-center p-1.5 text-gray-500 hover:text-gray-700 rounded-lg hover:bg-gray-100"
|
|
title="Edit" hx-get="{{ url_for('timer.edit', function_id=function.id) }}"
|
|
hx-target="#container" hx-swap="innerHTML" hx-push-url="true">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
|
|
viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
|
|
</svg>
|
|
</button>
|
|
<button
|
|
class="inline-flex items-center p-1.5 text-gray-500 hover:text-gray-700 rounded-lg hover:bg-gray-100"
|
|
title="{{ 'Pause' if function.enabled else 'Resume' }}"
|
|
hx-post="{{ url_for('timer.toggle', function_id=function.id) }}"
|
|
hx-target="#container" hx-swap="innerHTML">
|
|
{% if function.enabled %}
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
|
|
viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M10 9v6m4-6v6m7-3a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
</svg>
|
|
{% else %}
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
|
|
viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z" />
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
</svg>
|
|
{% endif %}
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
|
|
{% if timer_functions|length == 0 %}
|
|
<tr>
|
|
<td colspan="3" class="px-6 py-16 text-center">
|
|
<p class="text-gray-500 text-lg">No functions found</p>
|
|
<p class="text-gray-400 text-sm mt-2">Click the "Add Function" button to create your first
|
|
function</p>
|
|
</td>
|
|
</tr>
|
|
{% endif %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% endblock %} |