Update UI

This commit is contained in:
2026-05-16 09:12:18 +10:00
parent ec9cbf115a
commit a369bc7975
+100 -19
View File
@@ -7,13 +7,13 @@
<div class="max-w-7xl mx-auto px-4 py-6">
<!-- Header -->
<div class="flex items-center justify-between mb-6">
<div>
<div class="flex items-start justify-between gap-4 mb-6">
<div class="min-w-0">
<h1 class="text-2xl font-bold text-gray-900">{% trans "Price Monitor" %}</h1>
<p class="text-sm text-gray-500 mt-0.5">{% trans "Track product prices and get notified on drops" %}</p>
</div>
<a href="{% url 'pricemon-add' %}"
class="inline-flex items-center px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-lg hover:bg-indigo-700 transition">
class="flex-shrink-0 inline-flex items-center px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-lg hover:bg-indigo-700 transition">
<svg class="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
</svg>
@@ -22,7 +22,7 @@
</div>
<!-- Stat cards -->
<div class="grid grid-cols-2 sm:grid-cols-3 gap-4 mb-6">
<div class="grid grid-cols-3 gap-3 sm:gap-4 mb-6">
<div class="bg-white rounded-lg shadow-sm border border-gray-100 p-4">
<div class="text-xs text-gray-400 font-medium uppercase tracking-wide mb-1">{% trans "Watchers" %}</div>
<div class="text-2xl font-bold text-gray-900">{{ total_watchers }}</div>
@@ -54,23 +54,107 @@
</div>
{% endif %}
<!-- Watchers Table -->
<!-- Watchers List -->
<div class="bg-white rounded-lg shadow-sm border border-gray-100 overflow-hidden">
{% if watchers %}
<table class="min-w-full divide-y divide-gray-200 text-sm">
<!-- Mobile / Card view (default, hidden on lg+) -->
<div class="divide-y divide-gray-100 lg:hidden">
{% for watcher in watchers %}
<div class="p-4" id="watcher-row-{{ watcher.pk }}">
<!-- Top row: name + badge + price -->
<div class="flex items-start justify-between gap-3">
<div class="flex-1 min-w-0">
<div class="flex items-center flex-wrap gap-2">
<span class="font-medium text-gray-900 leading-tight">{{ watcher.name }}</span>
{% if watcher.enabled %}
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-700">{% trans "Active" %}</span>
{% else %}
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-500">{% trans "Paused" %}</span>
{% endif %}
</div>
<a href="{{ watcher.url }}" target="_blank" rel="noopener"
class="text-xs text-indigo-500 hover:underline truncate block mt-0.5 max-w-full">
{{ watcher.url|truncatechars:55 }}
</a>
<div class="flex flex-wrap gap-3 mt-1.5 text-xs text-gray-400">
{% if watcher.last_checked_at %}
<span>{% trans "Checked" %} {{ watcher.last_checked_at|timesince }} {% trans "ago" %}</span>
{% else %}
<span>{% trans "Never checked" %}</span>
{% endif %}
<span>{{ watcher.get_check_interval_hours_display }}</span>
</div>
</div>
<div class="flex-shrink-0 text-right">
{% if watcher.last_price %}
<span class="text-xl font-bold text-gray-900">${{ watcher.last_price }}</span>
{% else %}
<span class="text-gray-400 text-lg"></span>
{% endif %}
</div>
</div>
<!-- Actions row -->
<div class="flex items-center justify-end gap-1 mt-3 pt-2 border-t border-gray-50">
<button
hx-post="{% url 'pricemon-check-now' watcher.pk %}"
hx-confirm="Run a price check now for {{ watcher.name }}?"
hx-swap="none"
hx-on::after-request="if(event.detail.successful) window.location.reload()"
title="{% trans 'Check Now' %}"
class="p-2 rounded text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 transition">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
</button>
<a href="{% url 'pricemon-history' watcher.pk %}"
title="{% trans 'Price History' %}"
class="p-2 rounded text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 transition">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
</svg>
</a>
<a href="{% url 'pricemon-edit' watcher.pk %}"
title="{% trans 'Edit' %}"
class="p-2 rounded text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 transition">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<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>
</a>
<form method="post" action="{% url 'pricemon-delete' watcher.pk %}" class="inline"
onsubmit="return confirm('Delete watcher {{ watcher.name }}?')">
{% csrf_token %}
<button type="submit" title="{% trans 'Delete' %}"
class="p-2 rounded text-gray-400 hover:text-red-600 hover:bg-red-50 transition">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
</svg>
</button>
</form>
</div>
</div>
{% endfor %}
</div>
<!-- Desktop / Table view (hidden below lg) -->
<table class="hidden lg:table min-w-full divide-y divide-gray-200 text-sm">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">{% trans "Product" %}</th>
<th class="px-4 py-3 text-right text-xs font-semibold text-gray-500 uppercase tracking-wider">{% trans "Current Price" %}</th>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider hidden sm:table-cell">{% trans "Last Checked" %}</th>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider hidden md:table-cell">{% trans "Interval" %}</th>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">{% trans "Last Checked" %}</th>
<th class="px-4 py-3 text-left text-xs font-semibold text-gray-500 uppercase tracking-wider">{% trans "Interval" %}</th>
<th class="px-4 py-3 text-center text-xs font-semibold text-gray-500 uppercase tracking-wider">{% trans "Status" %}</th>
<th class="px-4 py-3 text-right text-xs font-semibold text-gray-500 uppercase tracking-wider">{% trans "Actions" %}</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
{% for watcher in watchers %}
<tr class="hover:bg-gray-50" id="watcher-row-{{ watcher.pk }}">
<tr class="hover:bg-gray-50" id="watcher-row-desktop-{{ watcher.pk }}">
<td class="px-4 py-3">
<div class="font-medium text-gray-900">{{ watcher.name }}</div>
<a href="{{ watcher.url }}" target="_blank" rel="noopener"
@@ -85,14 +169,14 @@
<span class="text-gray-400"></span>
{% endif %}
</td>
<td class="px-4 py-3 text-gray-500 hidden sm:table-cell">
<td class="px-4 py-3 text-gray-500">
{% if watcher.last_checked_at %}
{{ watcher.last_checked_at|timesince }} {% trans "ago" %}
{% else %}
<span class="text-gray-300">{% trans "Never" %}</span>
{% endif %}
</td>
<td class="px-4 py-3 text-gray-500 hidden md:table-cell">
<td class="px-4 py-3 text-gray-500">
{{ watcher.get_check_interval_hours_display }}
</td>
<td class="px-4 py-3 text-center">
@@ -104,42 +188,38 @@
</td>
<td class="px-4 py-3 text-right">
<div class="flex items-center justify-end gap-1">
<!-- Check Now -->
<button
hx-post="{% url 'pricemon-check-now' watcher.pk %}"
hx-confirm="Run a price check now for {{ watcher.name }}?"
hx-swap="none"
hx-on::after-request="if(event.detail.successful) window.location.reload()"
title="Check Now"
title="{% trans 'Check Now' %}"
class="p-1.5 rounded text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 transition">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
</button>
<!-- History -->
<a href="{% url 'pricemon-history' watcher.pk %}"
title="Price History"
title="{% trans 'Price History' %}"
class="p-1.5 rounded text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 transition">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/>
</svg>
</a>
<!-- Edit -->
<a href="{% url 'pricemon-edit' watcher.pk %}"
title="Edit"
title="{% trans 'Edit' %}"
class="p-1.5 rounded text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 transition">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<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>
</a>
<!-- Delete -->
<form method="post" action="{% url 'pricemon-delete' watcher.pk %}" class="inline"
onsubmit="return confirm('Delete watcher {{ watcher.name }}?')">
{% csrf_token %}
<button type="submit" title="Delete"
<button type="submit" title="{% trans 'Delete' %}"
class="p-1.5 rounded text-gray-400 hover:text-red-600 hover:bg-red-50 transition">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
@@ -153,6 +233,7 @@
{% endfor %}
</tbody>
</table>
{% else %}
<div class="text-center py-16 text-gray-400">
<svg class="w-12 h-12 mx-auto mb-3 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">